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