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