Add tests for traits
gfx [Fri, 12 Feb 2010 12:57:37 +0000 (21:57 +0900)]
t/001_mouse/067-traits.t [new file with mode: 0644]

diff --git a/t/001_mouse/067-traits.t b/t/001_mouse/067-traits.t
new file mode 100644 (file)
index 0000000..97c79e8
--- /dev/null
@@ -0,0 +1,77 @@
+#!perl
+use strict;
+use warnings;
+
+use Test::More;
+
+use Test::Mouse qw(does_ok);
+
+BEGIN{
+    package MyMouseX::Foo::Method;
+    use Mouse::Role;
+
+    sub foo {}
+
+    package MyMouseX::Bar::Method;
+    use Mouse::Role;
+
+    sub bar {}
+
+    package MyMouseX::Foo;
+    use Mouse::Exporter;
+    use Mouse::Util::MetaRole;
+
+    Mouse::Exporter->setup_import_methods(
+        also => 'Mouse',
+    );
+    sub init_meta {
+        my(undef, %options) = @_;
+
+        my $meta = Mouse->init_meta(%options);
+        Mouse::Util::MetaRole::apply_metaroles(
+            for             => $options{for_class},
+            class_metaroles => {
+                method => ['MyMouseX::Foo::Method'],
+            },
+        );
+    }
+
+    $INC{'MyMouseX/Foo.pm'} = __FILE__;
+
+    package MyMouseX::Bar;
+    use Mouse::Exporter;
+    use Mouse::Util::MetaRole;
+
+    Mouse::Exporter->setup_import_methods(
+        also => 'Mouse',
+    );
+    sub init_meta {
+        my(undef, %options) = @_;
+
+        my $meta = Mouse->init_meta(%options);
+        Mouse::Util::MetaRole::apply_metaroles(
+            for             => $options{for_class},
+            class_metaroles => {
+                method => ['MyMouseX::Bar::Method'],
+            },
+        );
+    }
+
+    $INC{'MyMouseX/Bar.pm'} = __FILE__;
+}
+{
+    package ClassA;
+    use MyMouseX::Foo;
+
+    sub a {}
+
+    package ClassB;
+    use MyMouseX::Bar;
+
+    sub b {}
+}
+
+does_ok(ClassA->meta->get_method('a'), 'MyMouseX::Foo::Method');
+does_ok(ClassB->meta->get_method('b'), 'MyMouseX::Bar::Method');
+
+done_testing;