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