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('Code');
77 my $val = $stash->get_package_symbol('&foo');
78 is($val, undef, "got nothing yet");
81 no warnings 'void', 'once';
85 my $stash = Package::Stash->new('Code');
86 my $val = $stash->get_package_symbol('&foo');
87 is(ref($val), 'CODE', "got something");
88 is(prototype($val), undef, "got the right variable");
89 &Scalar::Util::set_prototype($val, '&');
90 is($stash->get_package_symbol('&foo'), $val,
91 "got the right variable");
92 is(prototype($stash->get_package_symbol('&foo')), '&',
93 "got the right variable");
94 is(prototype(\&Code::foo), '&',
95 "stash has the right variable");
101 my $stash = Package::Stash->new('Io');
102 my $val = $stash->get_package_symbol('FOO');
103 is($val, undef, "got nothing yet");
106 no warnings 'void', 'once';
111 my $stash = Package::Stash->new('Io');
112 my $val = $stash->get_package_symbol('FOO');
115 open $val, '<', \$str;
116 is(readline($stash->get_package_symbol('FOO')), "foo",
117 "got the right variable");
118 seek($stash->get_package_symbol('FOO'), 0, 0);
121 ::isa_ok(*FOO{IO}, 'IO');
123 "stash has the right variable");
129 my $stash = Package::Stash->new('Hash::Vivify');
130 my $val = $stash->get_or_add_package_symbol('%foo');
131 is(ref($val), 'HASH', "got something");
133 is_deeply($stash->get_or_add_package_symbol('%foo'), {bar => 1},
134 "got the right variable");
136 is_deeply(\%Hash::Vivify::foo, {bar => 1},
137 "stash has the right variable");
141 my $stash = Package::Stash->new('Array::Vivify');
142 my $val = $stash->get_or_add_package_symbol('@foo');
143 is(ref($val), 'ARRAY', "got something");
145 is_deeply($stash->get_or_add_package_symbol('@foo'), [1],
146 "got the right variable");
148 is_deeply(\@Array::Vivify::foo, [1],
149 "stash has the right variable");
153 my $stash = Package::Stash->new('Scalar::Vivify');
154 my $val = $stash->get_or_add_package_symbol('$foo');
155 is(ref($val), 'SCALAR', "got something");
157 is_deeply($stash->get_or_add_package_symbol('$foo'), \1,
158 "got the right variable");
160 is($Scalar::Vivify::foo, 1,
161 "stash has the right variable");
166 my $stash = Package::Stash->new('Io::Vivify');
167 my $val = $stash->get_or_add_package_symbol('FOO');
170 open $val, '<', \$str;
171 is(readline($stash->get_package_symbol('FOO')), "foo",
172 "got the right variable");
173 seek($stash->get_package_symbol('FOO'), 0, 0);
178 ::isa_ok(*FOO{IO}, 'IO');
180 "stash has the right variable");