61c6ea89dc38491673ab0431b9e33e053dfaad97
[gitmo/Mouse.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 => 40;
7
8
9 my @moose_exports = qw(
10     extends with
11     has
12     before after around
13     override
14     augment
15     super inner
16 );
17
18 {
19     package Foo;
20
21     eval 'use Mouse';
22     die $@ if $@;
23 }
24
25 can_ok('Foo', $_) for @moose_exports;
26
27 {
28     package Foo;
29
30     eval 'no Mouse';
31     die $@ if $@;
32 }
33
34 ok(!Foo->can($_), '... Foo can no longer do ' . $_) for @moose_exports;
35
36 # and check the type constraints as well
37
38 my @moose_type_constraint_exports = qw(
39     type subtype as where message
40     coerce from via
41     enum
42     find_type_constraint
43 );
44
45 {
46     package Bar;
47
48     eval 'use Mouse::Util::TypeConstraints';
49     die $@ if $@;
50 }
51
52 can_ok('Bar', $_) for @moose_type_constraint_exports;
53
54 {
55     package Bar;
56
57     eval 'no Mouse::Util::TypeConstraints';
58     die $@ if $@;
59 }
60
61
62 ok(!Bar->can($_), '... Bar can no longer do ' . $_) for @moose_type_constraint_exports;
63
64