6 BEGIN { chdir 't' if -d 't'; require q(./test.pl);
7 set_up_inc('../lib', 'lib');
19 sub new { bless {}, $_[0] }
20 sub bar { 'Foo::bar' }
23 # call the submethod in the direct instance
26 object_ok($foo, 'Foo');
29 is($foo->bar(), 'Foo::bar', '... got the right return value');
31 # fail calling it from a subclass
42 object_ok($bar, 'Bar');
43 object_ok($bar, 'Foo');
45 # test it working with with Sub::Name
48 skip("Sub::Name is required for this test", 3) if $@;
50 my $m = sub { (shift)->next::method() };
51 Sub::Name::subname('Bar::bar', $m);
58 my $value = eval { $bar->bar() };
59 ok(!$@, '... calling bar() succeeded') || diag $@;
60 is($value, 'Foo::bar', '... got the right return value too');
63 # test it failing without Sub::Name
73 object_ok($baz, 'Baz');
74 object_ok($baz, 'Foo');
77 my $m = sub { (shift)->next::method() };
84 ok($@, '... calling bar() with next::method failed') || diag $@;
87 # Test with non-existing class (used to segfault)
91 sub foo { No::Such::Class->next::can }
95 is($@, '', "->next::can on non-existing package name");