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