We only need local $? if we inline calls to DEMOLISH
[gitmo/Moose.git] / t / cmop / anon_packages.t
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 use Test::More;
5 use Test::Fatal;
6
7 use Class::MOP;
8
9 {
10     my $name;
11     {
12         my $anon = Class::MOP::Package->create_anon;
13         $name = $anon->name;
14         $anon->add_package_symbol('&foo' => sub {});
15         can_ok($name, 'foo');
16         ok($anon->is_anon, "is anon");
17     }
18
19     ok(!$name->can('foo'), "!$name->can('foo')");
20 }
21
22 {
23     my $name;
24     {
25         my $anon = Class::MOP::Package->create_anon(weaken => 0);
26         $name = $anon->name;
27         $anon->add_package_symbol('&foo' => sub {});
28         can_ok($name, 'foo');
29         ok($anon->is_anon, "is anon");
30     }
31
32     can_ok($name, 'foo');
33 }
34
35 {
36     like(exception { Class::MOP::Package->create_anon(cache => 1) },
37          qr/^Packages are not cacheable/,
38          "can't cache anon packages");
39 }
40
41 done_testing;