From: gfx Date: Thu, 3 Dec 2009 03:58:20 +0000 (+0900) Subject: Add some tests X-Git-Tag: 0.40_09~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b4d1723ead47f05198e369a2d38ba9e4a3a59354;p=gitmo%2FMouse.git Add some tests --- diff --git a/t/001_mouse/003-mouse-object.t b/t/001_mouse/003-mouse-object.t index 85c6581..d47a00d 100644 --- a/t/001_mouse/003-mouse-object.t +++ b/t/001_mouse/003-mouse-object.t @@ -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 index 0000000..d977089 --- /dev/null +++ b/t/001_mouse/062-package-symbol.t @@ -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 index 0000000..9aa2e3b --- /dev/null +++ b/t/001_mouse/063-meta-of-metaclasses.t @@ -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'); +