From 136add003a9d7cf795718f7af6cc7565b71052c2 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 31 May 2010 12:53:53 -0500 Subject: optionally subname added subs --- t/07-subname.t | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 t/07-subname.t (limited to 't/07-subname.t') 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; -- cgit v1.2.3-54-g00ecf