fix for prototype undecl issue when type constraint utils loaded before consumers...
[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
2a0f3bd3 18 super inner
31f8ec72 19);
20
21{
22 package Foo;
23}
24
25eval q{
26 package Foo;
27 use Moose;
28};
29ok(!$@, '... Moose succesfully exported into Foo');
30
31can_ok('Foo', $_) for @moose_exports;
32
33eval q{
34 package Foo;
35 no Moose;
36};
37ok(!$@, '... Moose succesfully un-exported from Foo');
38
3279ab4a 39ok(!Foo->can($_), '... Foo can no longer do ' . $_) for @moose_exports;
3279ab4a 40
571dd39f 41# and check the type constraints as well
42
43my @moose_type_constraint_exports = qw(
44 type subtype as where message
45 coerce from via
46 enum
47 find_type_constraint
48);
49
50{
51 package Bar;
52}
53
54eval q{
55 package Bar;
56 use Moose::Util::TypeConstraints;
57};
58ok(!$@, '... Moose::Util::TypeConstraints succesfully exported into Bar');
59
60can_ok('Bar', $_) for @moose_type_constraint_exports;
61
62eval q{
63 package Bar;
64 no Moose::Util::TypeConstraints;
65};
66ok(!$@, '... Moose::Util::TypeConstraints succesfully un-exported from Bar');
67
68ok(!Bar->can($_), '... Bar can no longer do ' . $_) for @moose_type_constraint_exports;
69