diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-06-13 11:42:43 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-06-13 11:42:43 -0500 |
commit | a1c10d3a2df2bb969aa0cdca2aeab9ce913d6f88 (patch) | |
tree | 6d62e9d3836c24b63bc470350ca285de820a2bb1 /t | |
parent | c61010aafbd9317870eeb7f3fd2f1baca88d873c (diff) | |
download | package-stash-a1c10d3a2df2bb969aa0cdca2aeab9ce913d6f88.tar.gz package-stash-a1c10d3a2df2bb969aa0cdca2aeab9ce913d6f88.zip |
stop autovivifying on get
Diffstat (limited to 't')
-rw-r--r-- | t/004-get.t | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/t/004-get.t b/t/004-get.t index 15e252f..89d7567 100644 --- a/t/004-get.t +++ b/t/004-get.t @@ -6,21 +6,43 @@ use Test::More; use Package::Stash; { - my $stash = Package::Stash->new('Foo'); - my $val = $stash->get_package_symbol('%foo'); - is(ref($val), 'HASH', "got something"); - $val->{bar} = 1; - is_deeply($stash->get_package_symbol('%foo'), {bar => 1}, - "got the right variable"); + BEGIN { + my $stash = Package::Stash->new('Foo'); + my $val = $stash->get_package_symbol('%foo'); + is($val, undef, "got nothing yet"); + } + { + no warnings 'void', 'once'; + %Foo::foo; + } + BEGIN { + my $stash = Package::Stash->new('Foo'); + my $val = $stash->get_package_symbol('%foo'); + is(ref($val), 'HASH', "got something"); + $val->{bar} = 1; + is_deeply($stash->get_package_symbol('%foo'), {bar => 1}, + "got the right variable"); + } } { - my $stash = Package::Stash->new('Bar'); - my $val = $stash->get_package_symbol('@foo'); - is(ref($val), 'ARRAY', "got something"); - push @$val, 1; - is_deeply($stash->get_package_symbol('@foo'), [1], - "got the right variable"); + BEGIN { + my $stash = Package::Stash->new('Bar'); + my $val = $stash->get_package_symbol('@foo'); + is($val, undef, "got something"); + } + { + no warnings 'void', 'once'; + @Bar::foo; + } + BEGIN { + my $stash = Package::Stash->new('Bar'); + my $val = $stash->get_package_symbol('@foo'); + is(ref($val), 'ARRAY', "got something"); + push @$val, 1; + is_deeply($stash->get_package_symbol('@foo'), [1], + "got the right variable"); + } } done_testing; |