summaryrefslogtreecommitdiffstats
path: root/t/07-subname.t
blob: a686384bca83a52420a3f3ccdea07f876bf032f0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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;