stop autovivifying on get
[gitmo/Package-Stash-PP.git] / t / 004-get.t
CommitLineData
d2d3faf4 1#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More;
5
e94260da 6use Package::Stash;
d2d3faf4 7
8{
a1c10d3a 9 BEGIN {
10 my $stash = Package::Stash->new('Foo');
11 my $val = $stash->get_package_symbol('%foo');
12 is($val, undef, "got nothing yet");
13 }
14 {
15 no warnings 'void', 'once';
16 %Foo::foo;
17 }
18 BEGIN {
19 my $stash = Package::Stash->new('Foo');
20 my $val = $stash->get_package_symbol('%foo');
21 is(ref($val), 'HASH', "got something");
22 $val->{bar} = 1;
23 is_deeply($stash->get_package_symbol('%foo'), {bar => 1},
24 "got the right variable");
25 }
d2d3faf4 26}
27
28{
a1c10d3a 29 BEGIN {
30 my $stash = Package::Stash->new('Bar');
31 my $val = $stash->get_package_symbol('@foo');
32 is($val, undef, "got something");
33 }
34 {
35 no warnings 'void', 'once';
36 @Bar::foo;
37 }
38 BEGIN {
39 my $stash = Package::Stash->new('Bar');
40 my $val = $stash->get_package_symbol('@foo');
41 is(ref($val), 'ARRAY', "got something");
42 push @$val, 1;
43 is_deeply($stash->get_package_symbol('@foo'), [1],
44 "got the right variable");
45 }
d2d3faf4 46}
47
48done_testing;