X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F32_next_method_edge_cases.t;h=5af7004ce0c6ec0914d16da1ae2276d140c7103a;hb=58f0eafe995440a1387b49470c07d517b218065a;hp=0e5e913552b571efffb4ef068bce5872677ce664;hpb=4e47d2a4aadec10a1b894cbae0bfc607757c4dfe;p=gitmo%2FClass-C3.git diff --git a/t/32_next_method_edge_cases.t b/t/32_next_method_edge_cases.t index 0e5e913..5af7004 100644 --- a/t/32_next_method_edge_cases.t +++ b/t/32_next_method_edge_cases.t @@ -3,14 +3,12 @@ use strict; use warnings; -use Test::More tests => 9; +use Test::More tests => 12; BEGIN { use_ok('Class::C3'); } -use Sub::Name; - { { @@ -38,21 +36,55 @@ use Sub::Name; use warnings; use Class::C3; our @ISA = ('Foo'); + } + + my $bar = Bar->new(); + isa_ok($bar, 'Bar'); + isa_ok($bar, 'Foo'); + + # test it working with with Sub::Name + SKIP: { + eval 'use Sub::Name'; + skip "Sub::Name is required for this test", 3 if $@; + + my $m = sub { (shift)->next::method() }; + Sub::Name::subname('Bar::bar', $m); + { + no strict 'refs'; + *{'Bar::bar'} = $m; + } + + Class::C3::initialize(); + + can_ok($bar, 'bar'); + my $value = eval { $bar->bar() }; + ok(!$@, '... calling bar() succedded') || diag $@; + is($value, 'Foo::bar', '... got the right return value too'); } - my $m = sub { (shift)->next::method() }; - subname('Bar::bar', $m); + # test it failing without Sub::Name { - no strict 'refs'; - *{'Bar::bar'} = $m; - } + package Baz; + use strict; + use warnings; + use Class::C3; + our @ISA = ('Foo'); + } + + my $baz = Baz->new(); + isa_ok($baz, 'Baz'); + isa_ok($baz, 'Foo'); + + { + my $m = sub { (shift)->next::method() }; + { + no strict 'refs'; + *{'Baz::bar'} = $m; + } - my $bar = Bar->new(); - isa_ok($bar, 'Bar'); - isa_ok($bar, 'Foo'); + Class::C3::initialize(); - can_ok($bar, 'bar'); - my $value = eval { $bar->bar() }; - ok(!$@, '... calling bar() succedded') || diag $@; - is($value, 'Foo::bar', '... got the right return value too'); + eval { $baz->bar() }; + ok($@, '... calling bar() with next::method failed') || diag $@; + } } \ No newline at end of file