6 BEGIN { chdir 't' if -d 't'; require q(./test.pl); @INC = qw "../lib lib" }
17 sub new { bless {}, $_[0] }
18 sub bar { 'Foo::bar' }
21 # call the submethod in the direct instance
24 object_ok($foo, 'Foo');
27 is($foo->bar(), 'Foo::bar', '... got the right return value');
29 # fail calling it from a subclass
40 object_ok($bar, 'Bar');
41 object_ok($bar, 'Foo');
43 # test it working with with Sub::Name
46 skip("Sub::Name is required for this test", 3) if $@;
48 my $m = sub { (shift)->next::method() };
49 Sub::Name::subname('Bar::bar', $m);
56 my $value = eval { $bar->bar() };
57 ok(!$@, '... calling bar() succeeded') || diag $@;
58 is($value, 'Foo::bar', '... got the right return value too');
61 # test it failing without Sub::Name
71 object_ok($baz, 'Baz');
72 object_ok($baz, 'Foo');
75 my $m = sub { (shift)->next::method() };
82 ok($@, '... calling bar() with next::method failed') || diag $@;
85 # Test with non-existing class (used to segfault)
89 sub foo { No::Such::Class->next::can }
93 is($@, '', "->next::can on non-existing package name");