optionally subname added subs
[gitmo/Package-Stash.git] / t / 07-subname.t
CommitLineData
136add00 1#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More;
5
6use Package::Stash;
7
8my $foo_stash = Package::Stash->new('Foo');
9$foo_stash->add_package_symbol('&foo' => sub { caller(0) });
10is((Foo::foo())[3], 'main::__ANON__', "no subname if not requested");
11
12$foo_stash->add_package_symbol('&bar' => sub { caller(0) }, subname => 'bar');
13is((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');
16is((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');
19is((Foo::quux())[3], 'Bar::quux', "got the right subname with explicit package");
20
21done_testing;