Add some tests
gfx [Thu, 3 Dec 2009 03:58:20 +0000 (12:58 +0900)]
t/001_mouse/003-mouse-object.t
t/001_mouse/062-package-symbol.t [new file with mode: 0644]
t/001_mouse/063-meta-of-metaclasses.t [new file with mode: 0644]

index 85c6581..d47a00d 100644 (file)
@@ -1,9 +1,8 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Test::More tests => 2;
+use Test::More tests => 1;
 
 require Mouse;
-ok($INC{"Mouse/Object.pm"}, "loading Mouse loads Mouse::Object");
-can_ok('Mouse::Object' => 'new');
 
+can_ok('Mouse::Object' => 'new');
diff --git a/t/001_mouse/062-package-symbol.t b/t/001_mouse/062-package-symbol.t
new file mode 100644 (file)
index 0000000..d977089
--- /dev/null
@@ -0,0 +1,37 @@
+#!perl
+use strict;
+use warnings;
+
+use Test::More tests => 17;
+
+{
+    package Foo;
+    use Mouse;
+
+    sub code { 42 }
+
+    our $scalar = 'bar';
+
+    our %hash = (a => 'b');
+
+    our @array = ('foo');
+}
+
+my $meta = Foo->meta;
+
+foreach my $sym(qw(&code $scalar %hash @array *code *scalar *hash *array)){
+    ok $meta->has_package_symbol($sym),      "has_package_symbol('$sym')";
+}
+
+ok !$meta->has_package_symbol('$hogehoge');
+ok !$meta->has_package_symbol('%array');
+
+is $meta->get_package_symbol('&code'),   \&Foo::code;
+is $meta->get_package_symbol('$scalar'), \$Foo::scalar;
+is $meta->get_package_symbol('%hash'),   \%Foo::hash;
+is $meta->get_package_symbol('@array'),  \@Foo::array;
+is $meta->get_package_symbol('*code'), \*Foo::code;
+
+is $meta->get_package_symbol('$hogehoge'), undef;
+is $meta->get_package_symbol('%array'),    undef;
+
diff --git a/t/001_mouse/063-meta-of-metaclasses.t b/t/001_mouse/063-meta-of-metaclasses.t
new file mode 100644 (file)
index 0000000..9aa2e3b
--- /dev/null
@@ -0,0 +1,18 @@
+#!perl
+use strict;
+use warnings;
+
+use Test::More tests => 6;
+
+use Mouse ();
+
+can_ok('Mouse::Meta::Class', 'meta');
+can_ok('Mouse::Meta::Role', 'meta');
+
+my $meta = Mouse::Meta::Class->meta;
+can_ok($meta->constructor_class, 'meta');
+can_ok($meta->destructor_class, 'meta');
+can_ok($meta->attribute_metaclass, 'meta');
+
+can_ok($meta->get_method('is_anon_class'), 'meta');
+