diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-05-31 12:53:53 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-08-27 11:47:08 -0500 |
commit | 136add003a9d7cf795718f7af6cc7565b71052c2 (patch) | |
tree | 4e0f30c6fce5e5f7d8dd3d263e4f79a1bfef42a8 /t/07-subname.t | |
parent | 9488328b8551006f79cc8e3cf144209e39774dd1 (diff) | |
download | package-stash-136add003a9d7cf795718f7af6cc7565b71052c2.tar.gz package-stash-136add003a9d7cf795718f7af6cc7565b71052c2.zip |
optionally subname added substopic/subname
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; |