Commit | Line | Data |
2b637511 |
1 | BEGIN { $^P |= 0x210 } |
16c23894 |
2 | |
2b637511 |
3 | use Test::More 0.88; |
16c23894 |
4 | use Sub::Name; |
5 | |
6 | my $x = subname foo => sub { (caller 0)[3] }; |
3967e628 |
7 | my $line = __LINE__ - 1; |
8 | my $file = __FILE__; |
9 | my $anon = $DB::sub{"main::__ANON__[${file}:${line}]"}; |
10 | |
2b637511 |
11 | is($x->(), "main::foo"); |
16c23894 |
12 | |
13 | package Blork; |
14 | |
15 | use Sub::Name; |
16 | |
17 | subname " Bar!", $x; |
2b637511 |
18 | ::is($x->(), "Blork:: Bar!"); |
16c23894 |
19 | |
20 | subname "Foo::Bar::Baz", $x; |
2b637511 |
21 | ::is($x->(), "Foo::Bar::Baz"); |
16c23894 |
22 | |
bbd01306 |
23 | subname "subname (dynamic $_)", \&subname for 1 .. 3; |
24 | |
25 | for (4 .. 5) { |
26 | subname "Dynamic $_", $x; |
2b637511 |
27 | ::is($x->(), "Blork::Dynamic $_"); |
bbd01306 |
28 | } |
16c23894 |
29 | |
2b637511 |
30 | ::is($DB::sub{"main::foo"}, $anon); |
3967e628 |
31 | |
32 | for (4 .. 5) { |
2b637511 |
33 | ::is($DB::sub{"Blork::Dynamic $_"}, $anon); |
3967e628 |
34 | } |
35 | |
3967e628 |
36 | for ("Blork:: Bar!", "Foo::Bar::Baz") { |
2b637511 |
37 | ::is($DB::sub{$_}, $anon); |
3967e628 |
38 | } |
39 | |
2b637511 |
40 | ::done_testing; |
16c23894 |
41 | # vim: ft=perl |