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