11 my $stash = Package::Stash->new('Hash');
12 my $val = $stash->get_symbol('%foo');
13 is($val, undef, "got nothing yet");
16 no warnings 'void', 'once';
20 my $stash = Package::Stash->new('Hash');
21 my $val = $stash->get_symbol('%foo');
22 is(ref($val), 'HASH', "got something");
24 is_deeply($stash->get_symbol('%foo'), {bar => 1},
25 "got the right variable");
26 is_deeply(\%Hash::foo, {bar => 1},
27 "stash has the right variable");
33 my $stash = Package::Stash->new('Array');
34 my $val = $stash->get_symbol('@foo');
35 is($val, undef, "got nothing yet");
38 no warnings 'void', 'once';
42 my $stash = Package::Stash->new('Array');
43 my $val = $stash->get_symbol('@foo');
44 is(ref($val), 'ARRAY', "got something");
46 is_deeply($stash->get_symbol('@foo'), [1],
47 "got the right variable");
48 is_deeply(\@Array::foo, [1],
49 "stash has the right variable");
55 my $stash = Package::Stash->new('Scalar');
56 my $val = $stash->get_symbol('$foo');
57 is($val, undef, "got nothing yet");
60 no warnings 'void', 'once';
64 my $stash = Package::Stash->new('Scalar');
65 my $val = $stash->get_symbol('$foo');
66 is(ref($val), 'SCALAR', "got something");
68 is_deeply($stash->get_symbol('$foo'), \1,
69 "got the right variable");
71 "stash has the right variable");
77 my $stash = Package::Stash->new('Code');
78 my $val = $stash->get_symbol('&foo');
79 is($val, undef, "got nothing yet");
82 no warnings 'void', 'once';
86 my $stash = Package::Stash->new('Code');
87 my $val = $stash->get_symbol('&foo');
88 is(ref($val), 'CODE', "got something");
89 is(prototype($val), undef, "got the right variable");
90 &Scalar::Util::set_prototype($val, '&');
91 is($stash->get_symbol('&foo'), $val,
92 "got the right variable");
93 is(prototype($stash->get_symbol('&foo')), '&',
94 "got the right variable");
95 is(prototype(\&Code::foo), '&',
96 "stash has the right variable");
102 my $stash = Package::Stash->new('Io');
103 my $val = $stash->get_symbol('FOO');
104 is($val, undef, "got nothing yet");
107 no warnings 'void', 'once';
112 my $stash = Package::Stash->new('Io');
113 my $val = $stash->get_symbol('FOO');
116 open $val, '<', \$str;
117 is(readline($stash->get_symbol('FOO')), "foo",
118 "got the right variable");
119 seek($stash->get_symbol('FOO'), 0, 0);
122 ::isa_ok(*FOO{IO}, 'IO');
124 "stash has the right variable");
130 my $stash = Package::Stash->new('Hash::Vivify');
131 my $val = $stash->get_or_add_symbol('%foo');
132 is(ref($val), 'HASH', "got something");
134 is_deeply($stash->get_or_add_symbol('%foo'), {bar => 1},
135 "got the right variable");
137 is_deeply(\%Hash::Vivify::foo, {bar => 1},
138 "stash has the right variable");
142 my $stash = Package::Stash->new('Array::Vivify');
143 my $val = $stash->get_or_add_symbol('@foo');
144 is(ref($val), 'ARRAY', "got something");
146 is_deeply($stash->get_or_add_symbol('@foo'), [1],
147 "got the right variable");
149 is_deeply(\@Array::Vivify::foo, [1],
150 "stash has the right variable");
154 my $stash = Package::Stash->new('Scalar::Vivify');
155 my $val = $stash->get_or_add_symbol('$foo');
156 is(ref($val), 'SCALAR', "got something");
158 is_deeply($stash->get_or_add_symbol('$foo'), \1,
159 "got the right variable");
161 is($Scalar::Vivify::foo, 1,
162 "stash has the right variable");
167 my $stash = Package::Stash->new('Io::Vivify');
168 my $val = $stash->get_or_add_symbol('FOO');
171 open $val, '<', \$str;
172 is(readline($stash->get_symbol('FOO')), "foo",
173 "got the right variable");
174 seek($stash->get_symbol('FOO'), 0, 0);
179 ::isa_ok(*FOO{IO}, 'IO');
181 "stash has the right variable");