s/metaclass/__PACKAGE__->meta/
[gitmo/Moose.git] / t / 010_basics / 009_import_unimport.t
CommitLineData
31f8ec72 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
07af02bd 6use Test::More tests => 47;
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
2a0f3bd3 18 super inner
5a3217de 19 make_immutable
31f8ec72 20);
21
22{
23 package Foo;
24}
25
26eval q{
27 package Foo;
28 use Moose;
29};
30ok(!$@, '... Moose succesfully exported into Foo');
31
32can_ok('Foo', $_) for @moose_exports;
33
34eval q{
35 package Foo;
36 no Moose;
37};
38ok(!$@, '... Moose succesfully un-exported from Foo');
39
3279ab4a 40ok(!Foo->can($_), '... Foo can no longer do ' . $_) for @moose_exports;
3279ab4a 41
571dd39f 42# and check the type constraints as well
43
44my @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
55eval q{
56 package Bar;
57 use Moose::Util::TypeConstraints;
58};
59ok(!$@, '... Moose::Util::TypeConstraints succesfully exported into Bar');
60
61can_ok('Bar', $_) for @moose_type_constraint_exports;
62
63eval q{
64 package Bar;
65 no Moose::Util::TypeConstraints;
66};
67ok(!$@, '... Moose::Util::TypeConstraints succesfully un-exported from Bar');
68
69ok(!Bar->can($_), '... Bar can no longer do ' . $_) for @moose_type_constraint_exports;
70