10 my $stash = Package::Stash->new('Hash');
11 my $val = $stash->get_package_symbol('%foo');
12 is($val, undef, "got nothing yet");
15 no warnings 'void', 'once';
19 my $stash = Package::Stash->new('Hash');
20 my $val = $stash->get_package_symbol('%foo');
21 is(ref($val), 'HASH', "got something");
23 is_deeply($stash->get_package_symbol('%foo'), {bar => 1},
24 "got the right variable");
25 is_deeply(\%Hash::foo, {bar => 1},
26 "stash has the right variable");
32 my $stash = Package::Stash->new('Array');
33 my $val = $stash->get_package_symbol('@foo');
34 is($val, undef, "got nothing yet");
37 no warnings 'void', 'once';
41 my $stash = Package::Stash->new('Array');
42 my $val = $stash->get_package_symbol('@foo');
43 is(ref($val), 'ARRAY', "got something");
45 is_deeply($stash->get_package_symbol('@foo'), [1],
46 "got the right variable");
47 is_deeply(\@Array::foo, [1],
48 "stash has the right variable");
54 my $stash = Package::Stash->new('Scalar');
55 my $val = $stash->get_package_symbol('$foo');
56 is($val, undef, "got nothing yet");
59 no warnings 'void', 'once';
63 my $stash = Package::Stash->new('Scalar');
64 my $val = $stash->get_package_symbol('$foo');
65 is(ref($val), 'SCALAR', "got something");
67 is_deeply($stash->get_package_symbol('$foo'), \1,
68 "got the right variable");
70 "stash has the right variable");
76 my $stash = Package::Stash->new('Io');
77 my $val = $stash->get_package_symbol('FOO');
78 is($val, undef, "got nothing yet");
81 no warnings 'void', 'once';
86 my $stash = Package::Stash->new('Io');
87 my $val = $stash->get_package_symbol('FOO');
90 open $val, '<', \$str;
91 is(readline($stash->get_package_symbol('FOO')), "foo",
92 "got the right variable");
93 seek($stash->get_package_symbol('FOO'), 0, 0);
96 ::isa_ok(*FOO{IO}, 'IO');
98 "stash has the right variable");
104 my $stash = Package::Stash->new('Hash::Vivify');
105 my $val = $stash->get_or_add_package_symbol('%foo');
106 is(ref($val), 'HASH', "got something");
108 is_deeply($stash->get_or_add_package_symbol('%foo'), {bar => 1},
109 "got the right variable");
111 is_deeply(\%Hash::Vivify::foo, {bar => 1},
112 "stash has the right variable");
116 my $stash = Package::Stash->new('Array::Vivify');
117 my $val = $stash->get_or_add_package_symbol('@foo');
118 is(ref($val), 'ARRAY', "got something");
120 is_deeply($stash->get_or_add_package_symbol('@foo'), [1],
121 "got the right variable");
123 is_deeply(\@Array::Vivify::foo, [1],
124 "stash has the right variable");
128 my $stash = Package::Stash->new('Scalar::Vivify');
129 my $val = $stash->get_or_add_package_symbol('$foo');
130 is(ref($val), 'SCALAR', "got something");
132 is_deeply($stash->get_or_add_package_symbol('$foo'), \1,
133 "got the right variable");
135 is($Scalar::Vivify::foo, 1,
136 "stash has the right variable");
141 my $stash = Package::Stash->new('Io::Vivify');
142 my $val = $stash->get_or_add_package_symbol('FOO');
145 open $val, '<', \$str;
146 is(readline($stash->get_package_symbol('FOO')), "foo",
147 "got the right variable");
148 seek($stash->get_package_symbol('FOO'), 0, 0);
153 ::isa_ok(*FOO{IO}, 'IO');
155 "stash has the right variable");