Commit | Line | Data |
---|---|---|
f58cd386 BB |
1 | #!/usr/bin/perl |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
6 | require q(./test.pl); plan(tests => 4); | |
7 | ||
8 | use mro; | |
9 | ||
10 | { | |
11 | package Proxy; | |
12 | our @ISA = qw//; | |
13 | sub next_proxy { goto &next::method } | |
14 | sub maybe_proxy { goto &maybe::next::method } | |
15 | sub can_proxy { goto &next::can } | |
16 | ||
17 | package TBase; | |
18 | our @ISA = qw//; | |
19 | sub foo { 42 } | |
20 | sub bar { 24 } | |
21 | # baz doesn't exist intentionally | |
22 | sub quux { 242 } | |
23 | ||
24 | package TTop; | |
25 | our @ISA = qw/TBase/; | |
26 | sub foo { shift->Proxy::next_proxy() } | |
27 | sub bar { shift->Proxy::maybe_proxy() } | |
28 | sub baz { shift->Proxy::maybe_proxy() } | |
29 | sub quux { shift->Proxy::can_proxy()->() } | |
30 | } | |
31 | ||
32 | is(TTop->foo, 42, 'proxy next::method via goto'); | |
33 | is(TTop->bar, 24, 'proxy maybe::next::method via goto'); | |
34 | ok(!TTop->baz, 'proxy maybe::next::method via goto with no method'); | |
35 | is(TTop->quux, 242, 'proxy next::can via goto'); |