6 BEGIN { chdir '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
27 is($foo->bar(), 'Foo::bar', '... got the right return value');
29 # fail calling it from a subclass
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() succedded') || diag $@;
58 is($value, 'Foo::bar', '... got the right return value too');
61 # test it failing without Sub::Name
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");
97 # Test next::method/can with UNIVERSAL methods
101 sub kan { shift->next::can }
105 sub baz { shift->next::can }
107 sub foo { shift->next::method }
108 sub bar { shift->next::method }
111 is eval { M->foo }, "foo", 'next::method with implicit UNIVERSAL';
112 is eval { M->bar }, "bar", 'n::m w/superclass of implicit UNIVERSAL';
115 'univ superclasses next::cannot their own methods';
116 is kan UNIVERSAL, undef,
117 'UNIVERSAL next::cannot its own methods';
120 sub b::cnadd { shift->next::can }
122 'univ supersuperclass noxt::can method in its immediate subclasses';