1use strict;
2use warnings;
3
4use Test::More;
5
6
7my @moose_exports = qw(
8    extends with
9    has
10    before after around
11    override
12    augment
13    super inner
14    blessed confess
15);
16
17{
18    package Foo;
19
20    eval 'use Moose';
21    die $@ if $@;
22}
23
24can_ok('Foo', $_) for @moose_exports;
25
26{
27    package Foo;
28
29    eval 'no Moose';
30    die $@ if $@;
31}
32
33ok(!Foo->can($_), '... Foo can no longer do ' . $_) for @moose_exports;
34
35# and check the type constraints as well
36
37my @moose_type_constraint_exports = qw(
38    type subtype as where message
39    coerce from via
40    enum
41    find_type_constraint
42);
43
44{
45    package Bar;
46
47    eval 'use Moose::Util::TypeConstraints';
48    die $@ if $@;
49}
50
51can_ok('Bar', $_) for @moose_type_constraint_exports;
52
53{
54    package Bar;
55
56    eval 'no Moose::Util::TypeConstraints';
57    die $@ if $@;
58}
59
60ok(!Bar->can($_), '... Bar can no longer do ' . $_) for @moose_type_constraint_exports;
61
62
63{
64    package Baz;
65
66    use Moose;
67    use Scalar::Util qw( blessed );
68
69    no Moose;
70}
71
72can_ok( 'Baz', 'blessed' );
73
74{
75    package Moo;
76
77    use Scalar::Util qw( blessed );
78    use Moose;
79
80    no Moose;
81}
82
83can_ok( 'Moo', 'blessed' );
84
85my $blessed;
86{
87    package Quux;
88
89    use Scalar::Util qw( blessed );
90    use Moose blessed => { -as => \$blessed };
91
92    no Moose;
93}
94
95can_ok( 'Quux', 'blessed' );
96is( $blessed, \&Scalar::Util::blessed );
97
98done_testing;
99