Commit | Line | Data |
136add00 |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
4 | use Test::More; |
5 | |
6 | use Package::Stash; |
7 | |
8 | my $foo_stash = Package::Stash->new('Foo'); |
9 | $foo_stash->add_package_symbol('&foo' => sub { caller(0) }); |
10 | is((Foo::foo())[3], 'main::__ANON__', "no subname if not requested"); |
11 | |
12 | $foo_stash->add_package_symbol('&bar' => sub { caller(0) }, subname => 'bar'); |
13 | is((Foo::bar())[3], 'Foo::bar', "got the right subname with implicit package"); |
14 | |
15 | $foo_stash->add_package_symbol('&baz' => sub { caller(0) }, subname => 'BAZ'); |
16 | is((Foo::baz())[3], 'Foo::BAZ', "got the right subname with implicit package and different glob name"); |
17 | |
18 | $foo_stash->add_package_symbol('&quux' => sub { caller(0) }, subname => 'Bar::quux'); |
19 | is((Foo::quux())[3], 'Bar::quux', "got the right subname with explicit package"); |
20 | |
21 | done_testing; |