summaryrefslogtreecommitdiff
path: root/t/basics/import_unimport.t
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2015-06-06 17:50:16 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2015-06-06 17:50:16 +0000
commit5ac2026f7eed78958d69d051e7a8e993dcf51205 (patch)
tree298c3d2f08bdfe5689998b11892d72a897985be1 /t/basics/import_unimport.t
downloadMoose-tarball-5ac2026f7eed78958d69d051e7a8e993dcf51205.tar.gz
Diffstat (limited to 't/basics/import_unimport.t')
-rw-r--r--t/basics/import_unimport.t98
1 files changed, 98 insertions, 0 deletions
diff --git a/t/basics/import_unimport.t b/t/basics/import_unimport.t
new file mode 100644
index 0000000..b44fea7
--- /dev/null
+++ b/t/basics/import_unimport.t
@@ -0,0 +1,98 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+
+my @moose_exports = qw(
+ extends with
+ has
+ before after around
+ override
+ augment
+ super inner
+ blessed confess
+);
+
+{
+ package Foo;
+
+ eval 'use Moose';
+ die $@ if $@;
+}
+
+can_ok('Foo', $_) for @moose_exports;
+
+{
+ package Foo;
+
+ eval 'no Moose';
+ die $@ if $@;
+}
+
+ok(!Foo->can($_), '... Foo can no longer do ' . $_) for @moose_exports;
+
+# and check the type constraints as well
+
+my @moose_type_constraint_exports = qw(
+ type subtype as where message
+ coerce from via
+ enum
+ find_type_constraint
+);
+
+{
+ package Bar;
+
+ eval 'use Moose::Util::TypeConstraints';
+ die $@ if $@;
+}
+
+can_ok('Bar', $_) for @moose_type_constraint_exports;
+
+{
+ package Bar;
+
+ eval 'no Moose::Util::TypeConstraints';
+ die $@ if $@;
+}
+
+ok(!Bar->can($_), '... Bar can no longer do ' . $_) for @moose_type_constraint_exports;
+
+
+{
+ package Baz;
+
+ use Moose;
+ use Scalar::Util qw( blessed );
+
+ no Moose;
+}
+
+can_ok( 'Baz', 'blessed' );
+
+{
+ package Moo;
+
+ use Scalar::Util qw( blessed );
+ use Moose;
+
+ no Moose;
+}
+
+can_ok( 'Moo', 'blessed' );
+
+my $blessed;
+{
+ package Quux;
+
+ use Scalar::Util qw( blessed );
+ use Moose blessed => { -as => \$blessed };
+
+ no Moose;
+}
+
+can_ok( 'Quux', 'blessed' );
+is( $blessed, \&Scalar::Util::blessed );
+
+done_testing;