Class::MOP::load_class change
[gitmo/Moose.git] / t / 018_import_unimport.t
CommitLineData
31f8ec72 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
571dd39f 6use Test::More tests => 45;
31f8ec72 7
8BEGIN {
9 use_ok('Moose');
10}
11
12my @moose_exports = qw(
13 extends with
14 has
15 before after around
3279ab4a 16 override
17 augment
3279ab4a 18);
19
20my @moose_not_unimported = qw(
2a0f3bd3 21 super inner
31f8ec72 22);
23
24{
25 package Foo;
26}
27
28eval q{
29 package Foo;
30 use Moose;
31};
32ok(!$@, '... Moose succesfully exported into Foo');
33
34can_ok('Foo', $_) for @moose_exports;
3279ab4a 35can_ok('Foo', $_) for @moose_not_unimported;
31f8ec72 36
37eval q{
38 package Foo;
39 no Moose;
40};
41ok(!$@, '... Moose succesfully un-exported from Foo');
42
3279ab4a 43ok(!Foo->can($_), '... Foo can no longer do ' . $_) for @moose_exports;
44can_ok('Foo', $_) for @moose_not_unimported;
45
571dd39f 46# and check the type constraints as well
47
48my @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
59eval q{
60 package Bar;
61 use Moose::Util::TypeConstraints;
62};
63ok(!$@, '... Moose::Util::TypeConstraints succesfully exported into Bar');
64
65can_ok('Bar', $_) for @moose_type_constraint_exports;
66
67eval q{
68 package Bar;
69 no Moose::Util::TypeConstraints;
70};
71ok(!$@, '... Moose::Util::TypeConstraints succesfully un-exported from Bar');
72
73ok(!Bar->can($_), '... Bar can no longer do ' . $_) for @moose_type_constraint_exports;
74