X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F001_mouse%2F100-meta-class.t;h=934b1b44118e2a8f7b47232bfb9771606cd16d93;hb=1134f6943d6fefc9f72055de5552b2ed7ccbec45;hp=c76b2dae3fcfec3d191e45833696abfaf3b17390;hpb=920139b3efca66d2caeeef306c97fa0da62c6b73;p=gitmo%2FMouse.git diff --git a/t/001_mouse/100-meta-class.t b/t/001_mouse/100-meta-class.t index c76b2da..934b1b4 100644 --- a/t/001_mouse/100-meta-class.t +++ b/t/001_mouse/100-meta-class.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 26; +use Test::More; use Test::Exception; { package Class; @@ -18,6 +18,8 @@ use Test::Exception; sub stub; sub stub_with_attr :method; + sub king { 'king' } + no Mouse; } { @@ -60,13 +62,23 @@ ok(!$meta->has_attribute('nonexistent_attribute')); ok($meta->has_method('pawn')); lives_and{ - ok($meta->get_method('pawn')); - is($meta->get_method('pawn')->name, 'pawn'); - is($meta->get_method('pawn')->package_name, 'Class'); + my $pawn = $meta->get_method('pawn'); + ok($pawn); + is($pawn->name, 'pawn'); + is($pawn->package_name, 'Class'); + is($pawn->fully_qualified_name, 'Class::pawn'); + + is $pawn, $pawn; + + my $king = $meta->get_method('king'); + isnt $pawn, $king; + + $meta->add_method(king => sub{ 'fool' }); + isnt $king, $meta->get_method('king'); }; is( join(' ', sort $meta->get_method_list), - join(' ', sort qw(meta pawn has_pawn MY_CONST stub stub_with_attr)) + join(' ', sort qw(meta pawn king has_pawn MY_CONST stub stub_with_attr)) ); eval q{ @@ -101,13 +113,14 @@ can_ok($child_meta, 'find_method_by_name'); is $child_meta->find_method_by_name('child_method')->fully_qualified_name, 'Child::child_method'; is $child_meta->find_method_by_name('pawn')->fully_qualified_name, 'Class::pawn'; -{ - local $TODO = 'should be Class::MY_CONST'; - is( join(' ', sort map{ $_->fully_qualified_name } grep{ $_->package_name ne 'Mouse::Object' } $child_meta->get_all_methods), - join(' ', sort qw( - Child::bishop Child::child_method Child::meta - Class::MY_CONST Class::has_pawn Class::pawn Class::stub Class::stub_with_attr - )) - ); -} +is( join(' ', sort map{ $_->fully_qualified_name } grep{ $_->package_name ne 'Mouse::Object' } $child_meta->get_all_methods), + join(' ', sort qw( + Child::bishop Child::child_method Child::meta + + Class::MY_CONST Class::has_pawn Class::pawn Class::king Class::stub Class::stub_with_attr + )) +); + +done_testing; +