File: smoke.t

package info (click to toggle)
libsub-name-perl 0.28-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 864 kB
  • sloc: perl: 201; makefile: 3
file content (45 lines) | stat: -rw-r--r-- 803 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use strict;
use warnings;

BEGIN { $^P |= 0x210 }

use Test::More;
use if $ENV{AUTHOR_TESTING}, 'Test::Warnings';
use Sub::Name;

my $x = subname foo => sub { (caller 0)[3] };
my $line = __LINE__ - 1;
my $file = __FILE__;
my $anon = $DB::sub{"main::__ANON__[${file}:${line}]"};

is($x->(), "main::foo");

package Blork;

use Sub::Name;

subname " Bar!", $x;
::is($x->(), "Blork:: Bar!");

subname "Foo::Bar::Baz", $x;
::is($x->(), "Foo::Bar::Baz");

subname "subname (dynamic $_)", \&subname  for 1 .. 3;

for (4 .. 5) {
    subname "Dynamic $_", $x;
    ::is($x->(), "Blork::Dynamic $_");
}

::is($DB::sub{"main::foo"}, $anon);

for (4 .. 5) {
    ::is($DB::sub{"Blork::Dynamic $_"}, $anon);
}

for ("Blork:: Bar!", "Foo::Bar::Baz") {
    ::is($DB::sub{$_}, $anon);
}

::done_testing();
# vim: ft=perl