X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fbasic.t;h=b0f99360e042ae6a16d7715c6dabad24bb79b9d1;hb=acbc69c4f1ade78eb1d6f951cb6336af4297d996;hp=a106e9e79147cb0e3a59b943effe2ec9e95fa365;hpb=7ef54f40657ca05b95a31e7c81c28c2446b2cf37;p=gitmo%2FPackage-Stash.git diff --git a/t/basic.t b/t/basic.t index a106e9e..b0f9936 100644 --- a/t/basic.t +++ b/t/basic.t @@ -251,7 +251,13 @@ is($foo_stash->get_symbol('@foo'), $ARRAY, '... got the right values for @Foo::f } { - $foo_stash->add_symbol('%zork'); + $foo_stash->add_symbol('%bare'); + ok(!$foo_stash->has_symbol('$bare'), + "add_symbol with single argument doesn't vivify scalar slot"); +} + +{ + $foo_stash->add_symbol('%zork', {}); my $syms = $foo_stash->get_all_symbols('HASH'); @@ -265,10 +271,9 @@ is($foo_stash->get_symbol('@foo'), $ARRAY, '... got the right values for @Foo::f is($syms->{$symbol}, $foo_stash->get_symbol('%' . $symbol), '... got the right symbol'); } - no warnings 'once'; is_deeply( $syms, - { zork => \%Foo::zork }, + { zork => *{ $Foo::{zork} }{HASH} }, "got the right ones", ); } @@ -417,4 +422,24 @@ like(exception { ); } +for my $package ('Foo:Bar', 'Foo/Bar', 'Foo Bar', 'Foo:::Bar', '') { + like( + exception { Package::Stash->new($package) }, + qr/^$package is not a module name/, + "$package is not a module name" + ); +} + +like( + exception { Package::Stash->new([]) }, + qr/^Package::Stash->new must be passed the name of the package to access/, + "module name must be a string" +); + +like( + exception { Package::Stash->new(undef) }, + qr/^Package::Stash->new must be passed the name of the package to access/, + "module name must be a string" +); + done_testing;