X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F030_roles%2F009_more_role_edge_cases.t;h=e9923f0424dc6213a9e1313d1be1ee1770a2a08e;hb=b60e6c86035f456705cdce2516736d74c8799ee3;hp=b0ff5529a3a2cc9a2262bdb82d64f04c005a2d7c;hpb=e59a5c292a333cac504b65ebd4bba20b5e98d796;p=gitmo%2FMoose.git diff --git a/t/030_roles/009_more_role_edge_cases.t b/t/030_roles/009_more_role_edge_cases.t index b0ff552..e9923f0 100644 --- a/t/030_roles/009_more_role_edge_cases.t +++ b/t/030_roles/009_more_role_edge_cases.t @@ -3,20 +3,18 @@ use strict; use warnings; -use Test::More tests => 77; +use Test::More tests => 74; use Test::Exception; -BEGIN { - use_ok('Moose'); -} + { # NOTE: - # this tests that repeated role - # composition will not cause + # this tests that repeated role + # composition will not cause # a conflict between two methods # which are actually the same anyway - + { package RootA; use Moose::Role; @@ -33,8 +31,8 @@ BEGIN { package SubAB; use Moose; - ::lives_ok { - with "SubAA", "RootA"; + ::lives_ok { + with "SubAA", "RootA"; } '... role was composed as expected'; } @@ -48,31 +46,31 @@ BEGIN { can_ok( $i, "foo" ); my $foo_rv; - lives_ok { - $foo_rv = $i->foo; + lives_ok { + $foo_rv = $i->foo; } '... called foo successfully'; is($foo_rv, "RootA::foo", "... got the right foo rv"); } { # NOTE: - # this edge cases shows the application of - # an after modifier over a method which + # this edge cases shows the application of + # an after modifier over a method which # was added during role composotion. # The way this will work is as follows: - # role SubBA will consume RootB and - # get a local copy of RootB::foo, it + # role SubBA will consume RootB and + # get a local copy of RootB::foo, it # will also store a deferred after modifier - # to be applied to whatever class SubBA is + # to be applied to whatever class SubBA is # composed into. # When class SubBB comsumed role SubBA, the - # RootB::foo method is added to SubBB, then - # the deferred after modifier from SubBA is + # RootB::foo method is added to SubBB, then + # the deferred after modifier from SubBA is # applied to it. - # It is important to note that the application - # of the after modifier does not happen until + # It is important to note that the application + # of the after modifier does not happen until # role SubBA is composed into SubAA. - + { package RootB; use Moose::Role; @@ -97,7 +95,7 @@ BEGIN { package SubBB; use Moose; - ::lives_ok { + ::lives_ok { with "SubBA"; } '... composed the role successfully'; } @@ -108,32 +106,32 @@ BEGIN { isa_ok( my $i = SubBB->new, "SubBB" ); can_ok( $i, "foo" ); - + my $foo_rv; - lives_ok { - $foo_rv = $i->foo + lives_ok { + $foo_rv = $i->foo } '... called foo successfully'; is( $foo_rv, "RootB::foo", "foo rv" ); is( $i->counter, 1, "after hook called" ); - + lives_ok { $i->foo } '... called foo successfully (again)'; is( $i->counter, 2, "after hook called (again)" ); - - can_ok('SubBA', 'foo'); - my $subba_foo_rv; - lives_ok { - $subba_foo_rv = SubBA::foo(); - } '... called the sub as a function correctly'; - is($subba_foo_rv, 'RootB::foo', '... the SubBA->foo is still the RootB version'); + + ok(SubBA->meta->has_method('foo'), '... this has the foo method'); + #my $subba_foo_rv; + #lives_ok { + # $subba_foo_rv = SubBA::foo(); + #} '... called the sub as a function correctly'; + #is($subba_foo_rv, 'RootB::foo', '... the SubBA->foo is still the RootB version'); } { # NOTE: # this checks that an override method # does not try to trample over a locally - # composed in method. In this case the - # RootC::foo, which is composed into - # SubCA cannot be trampled with an + # composed in method. In this case the + # RootC::foo, which is composed into + # SubCA cannot be trampled with an # override of 'foo' { package RootC; @@ -146,15 +144,15 @@ BEGIN { with "RootC"; - ::dies_ok { + ::dies_ok { override foo => sub { "overridden" }; } '... cannot compose an override over a local method'; } } # NOTE: -# need to talk to Yuval about the motivation behind -# this test, I am not sure we are testing anything +# need to talk to Yuval about the motivation behind +# this test, I am not sure we are testing anything # useful here (although more tests cant hurt) { @@ -186,10 +184,10 @@ BEGIN { with "ConcreteA"; # NOTE: - # this was originally override, but + # this was originally override, but # that wont work (see above set of tests) # so I switched it to around. - # However, this may not be testing the + # However, this may not be testing the # same thing that was originally intended around other => sub { return ( (shift)->() . " + c" ); @@ -220,12 +218,12 @@ BEGIN { is( eval { $class->another }, "abstract", "provided by abstract" ); is( eval { $class->other }, "concrete a", "provided by concrete a" ); is( eval { $class->method }, "concrete b", "provided by concrete b" ); - } + } { package ClassWithSome; use Moose; - + eval { with ::shuffle qw/ConcreteC ConcreteB/ }; ::ok( !$@, "composition without abstract" ) || ::diag $@;