diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-06-13 11:55:28 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-06-13 11:55:28 -0500 |
commit | e55803fce07b2fda98971fcb17698eef8a2fe4bb (patch) | |
tree | 50e54ede011b2a98c710db4d67e2d537355bc722 /t | |
parent | a1c10d3a2df2bb969aa0cdca2aeab9ce913d6f88 (diff) | |
download | package-stash-e55803fce07b2fda98971fcb17698eef8a2fe4bb.tar.gz package-stash-e55803fce07b2fda98971fcb17698eef8a2fe4bb.zip |
add get_or_add_package_symbol, for the vivify behavior
Diffstat (limited to 't')
-rw-r--r-- | t/004-get.t | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/t/004-get.t b/t/004-get.t index 89d7567..ebeb864 100644 --- a/t/004-get.t +++ b/t/004-get.t @@ -45,4 +45,22 @@ use Package::Stash; } } +{ + my $stash = Package::Stash->new('Baz'); + my $val = $stash->get_or_add_package_symbol('%foo'); + is(ref($val), 'HASH', "got something"); + $val->{bar} = 1; + is_deeply($stash->get_or_add_package_symbol('%foo'), {bar => 1}, + "got the right variable"); +} + +{ + my $stash = Package::Stash->new('Quux'); + my $val = $stash->get_or_add_package_symbol('@foo'); + is(ref($val), 'ARRAY', "got something"); + push @$val, 1; + is_deeply($stash->get_or_add_package_symbol('@foo'), [1], + "got the right variable"); +} + done_testing; |