Commit | Line | Data |
31f8ec72 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
571dd39f |
6 | use Test::More tests => 45; |
31f8ec72 |
7 | |
8 | BEGIN { |
9 | use_ok('Moose'); |
10 | } |
11 | |
12 | my @moose_exports = qw( |
13 | extends with |
14 | has |
15 | before after around |
3279ab4a |
16 | override |
17 | augment |
3279ab4a |
18 | ); |
19 | |
20 | my @moose_not_unimported = qw( |
2a0f3bd3 |
21 | super inner |
31f8ec72 |
22 | ); |
23 | |
24 | { |
25 | package Foo; |
26 | } |
27 | |
28 | eval q{ |
29 | package Foo; |
30 | use Moose; |
31 | }; |
32 | ok(!$@, '... Moose succesfully exported into Foo'); |
33 | |
34 | can_ok('Foo', $_) for @moose_exports; |
3279ab4a |
35 | can_ok('Foo', $_) for @moose_not_unimported; |
31f8ec72 |
36 | |
37 | eval q{ |
38 | package Foo; |
39 | no Moose; |
40 | }; |
41 | ok(!$@, '... Moose succesfully un-exported from Foo'); |
42 | |
3279ab4a |
43 | ok(!Foo->can($_), '... Foo can no longer do ' . $_) for @moose_exports; |
44 | can_ok('Foo', $_) for @moose_not_unimported; |
45 | |
571dd39f |
46 | # and check the type constraints as well |
47 | |
48 | my @moose_type_constraint_exports = qw( |
49 | type subtype as where message |
50 | coerce from via |
51 | enum |
52 | find_type_constraint |
53 | ); |
54 | |
55 | { |
56 | package Bar; |
57 | } |
58 | |
59 | eval q{ |
60 | package Bar; |
61 | use Moose::Util::TypeConstraints; |
62 | }; |
63 | ok(!$@, '... Moose::Util::TypeConstraints succesfully exported into Bar'); |
64 | |
65 | can_ok('Bar', $_) for @moose_type_constraint_exports; |
66 | |
67 | eval q{ |
68 | package Bar; |
69 | no Moose::Util::TypeConstraints; |
70 | }; |
71 | ok(!$@, '... Moose::Util::TypeConstraints succesfully un-exported from Bar'); |
72 | |
73 | ok(!Bar->can($_), '... Bar can no longer do ' . $_) for @moose_type_constraint_exports; |
74 | |