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