Add some tests for goto &Moose::import
Dave Rolsky [Thu, 14 Aug 2008 13:59:48 +0000 (13:59 +0000)]
MANIFEST
t/050_metaclasses/014_goto_moose_import.t [new file with mode: 0644]

index 85b6f9b..f412755 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -187,6 +187,7 @@ t/050_metaclasses/010_extending_and_embedding_back_compat.t
 t/050_metaclasses/011_init_meta.t
 t/050_metaclasses/012_moose_exporter.t
 t/050_metaclasses/013_metaclass_traits.t
+t/050_metaclasses/014_goto_moose_import.t
 t/060_compat/001_module_refresh_compat.t
 t/060_compat/002_moose_respects_base.t
 t/060_compat/003_foreign_inheritence.t
diff --git a/t/050_metaclasses/014_goto_moose_import.t b/t/050_metaclasses/014_goto_moose_import.t
new file mode 100644 (file)
index 0000000..77f45ff
--- /dev/null
@@ -0,0 +1,59 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+use Test::Exception;
+
+# Some packages out in the wild cooperate with Moose by using goto
+# &Moose::import. we want to make sure it still works.
+
+{
+    package MooseAlike1;
+
+    use strict;
+    use warnings;
+
+    use Moose ();
+
+    sub import {
+        goto &Moose::import;
+    }
+}
+
+{
+    package Foo;
+
+    MooseAlike1->import();
+
+    ::lives_ok( sub { has( 'size' ) },
+                'has was exported via MooseAlike1' );
+}
+
+{
+    package MooseAlike2;
+
+    use strict;
+    use warnings;
+
+    use Moose ();
+
+    my $import = \&Moose::import;
+    sub import {
+        goto $import;
+    }
+}
+
+{
+    package Bar;
+
+    MooseAlike2->import();
+
+    ::lives_ok( sub { has( 'size' ) },
+                'has was exported via MooseAlike2' );
+}
+
+
+
+