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