More compatibility
[gitmo/Mouse.git] / t / 010_basics / 009_import_unimport.t
CommitLineData
60ad2cb7 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 41;
7
8
9my @moose_exports = qw(
10 extends with
11 has
12 before after around
13 override
14 augment
15 super inner
16);
17
18{
19 package Foo;
20
21 eval 'use Mouse';
22 die $@ if $@;
23}
24
25can_ok('Foo', $_) for @moose_exports;
26
27{
28 package Foo;
29
30 eval 'no Mouse';
31 die $@ if $@;
32}
33
34ok(!Foo->can($_), '... Foo can no longer do ' . $_) for @moose_exports;
35
36# and check the type constraints as well
37
38my @moose_type_constraint_exports = qw(
39 type subtype as where message
40 coerce from via
41 enum
42 find_type_constraint
43);
44
45{
46 package Bar;
47
48 eval 'use Mouse::Util::TypeConstraints';
49 die $@ if $@;
50}
51
52can_ok('Bar', $_) for @moose_type_constraint_exports;
53
54{
55 package Bar;
56
57 eval 'no Mouse::Util::TypeConstraints';
58 die $@ if $@;
59}
60
61{
62 local $TODO = 'Mouse::Util::TypeConstraints->unimport is not yet supported';
63 ok(!Bar->can($_), '... Bar can no longer do ' . $_) for @moose_type_constraint_exports;
64}
65
66{
67 package Baz;
68
69 use Scalar::Util qw( blessed );
70 use Mouse;
71
72 no Mouse;
73}
74
75can_ok( 'Baz', 'blessed' );