diff options
Diffstat (limited to 't/07-subname.t')
-rw-r--r-- | t/07-subname.t | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/t/07-subname.t b/t/07-subname.t new file mode 100644 index 0000000..a686384 --- /dev/null +++ b/t/07-subname.t @@ -0,0 +1,21 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +use Package::Stash; + +my $foo_stash = Package::Stash->new('Foo'); +$foo_stash->add_package_symbol('&foo' => sub { caller(0) }); +is((Foo::foo())[3], 'main::__ANON__', "no subname if not requested"); + +$foo_stash->add_package_symbol('&bar' => sub { caller(0) }, subname => 'bar'); +is((Foo::bar())[3], 'Foo::bar', "got the right subname with implicit package"); + +$foo_stash->add_package_symbol('&baz' => sub { caller(0) }, subname => 'BAZ'); +is((Foo::baz())[3], 'Foo::BAZ', "got the right subname with implicit package and different glob name"); + +$foo_stash->add_package_symbol('&quux' => sub { caller(0) }, subname => 'Bar::quux'); +is((Foo::quux())[3], 'Bar::quux', "got the right subname with explicit package"); + +done_testing; |