12 my $stash = Package::Stash->new('Hash');
13 my $val = $stash->get_symbol('%foo');
14 is($val, undef, "got nothing yet");
17 no warnings 'void', 'once';
21 my $stash = Package::Stash->new('Hash');
22 my $val = $stash->get_symbol('%foo');
23 is(ref($val), 'HASH', "got something");
25 is_deeply($stash->get_symbol('%foo'), {bar => 1},
26 "got the right variable");
27 is_deeply(\%Hash::foo, {bar => 1},
28 "stash has the right variable");
34 my $stash = Package::Stash->new('Array');
35 my $val = $stash->get_symbol('@foo');
36 is($val, undef, "got nothing yet");
39 no warnings 'void', 'once';
43 my $stash = Package::Stash->new('Array');
44 my $val = $stash->get_symbol('@foo');
45 is(ref($val), 'ARRAY', "got something");
47 is_deeply($stash->get_symbol('@foo'), [1],
48 "got the right variable");
49 is_deeply(\@Array::foo, [1],
50 "stash has the right variable");
56 my $stash = Package::Stash->new('Scalar');
57 my $val = $stash->get_symbol('$foo');
58 is($val, undef, "got nothing yet");
61 no warnings 'void', 'once';
65 my $stash = Package::Stash->new('Scalar');
66 my $val = $stash->get_symbol('$foo');
67 is(ref($val), 'SCALAR', "got something");
69 is_deeply($stash->get_symbol('$foo'), \1,
70 "got the right variable");
72 "stash has the right variable");
78 my $stash = Package::Stash->new('Code');
79 my $val = $stash->get_symbol('&foo');
80 is($val, undef, "got nothing yet");
83 no warnings 'void', 'once';
87 my $stash = Package::Stash->new('Code');
88 my $val = $stash->get_symbol('&foo');
89 is(ref($val), 'CODE', "got something");
90 is(prototype($val), undef, "got the right variable");
91 &Scalar::Util::set_prototype($val, '&');
92 is($stash->get_symbol('&foo'), $val,
93 "got the right variable");
94 is(prototype($stash->get_symbol('&foo')), '&',
95 "got the right variable");
96 is(prototype(\&Code::foo), '&',
97 "stash has the right variable");
103 my $stash = Package::Stash->new('Io');
104 my $val = $stash->get_symbol('FOO');
105 is($val, undef, "got nothing yet");
108 no warnings 'void', 'once';
113 my $stash = Package::Stash->new('Io');
114 my $val = $stash->get_symbol('FOO');
117 open $val, '<', \$str;
118 is(readline($stash->get_symbol('FOO')), "foo",
119 "got the right variable");
120 seek($stash->get_symbol('FOO'), 0, 0);
123 ::isa_ok(*FOO{IO}, 'IO');
125 "stash has the right variable");
131 my $stash = Package::Stash->new('Hash::Vivify');
132 my $val = $stash->get_or_add_symbol('%foo');
133 is(ref($val), 'HASH', "got something");
135 is_deeply($stash->get_or_add_symbol('%foo'), {bar => 1},
136 "got the right variable");
138 is_deeply(\%Hash::Vivify::foo, {bar => 1},
139 "stash has the right variable");
143 my $stash = Package::Stash->new('Array::Vivify');
144 my $val = $stash->get_or_add_symbol('@foo');
145 is(ref($val), 'ARRAY', "got something");
147 is_deeply($stash->get_or_add_symbol('@foo'), [1],
148 "got the right variable");
150 is_deeply(\@Array::Vivify::foo, [1],
151 "stash has the right variable");
155 my $stash = Package::Stash->new('Scalar::Vivify');
156 my $val = $stash->get_or_add_symbol('$foo');
157 is(ref($val), 'SCALAR', "got something");
159 is_deeply($stash->get_or_add_symbol('$foo'), \1,
160 "got the right variable");
162 is($Scalar::Vivify::foo, 1,
163 "stash has the right variable");
168 my $stash = Package::Stash->new('Io::Vivify');
169 my $val = $stash->get_or_add_symbol('FOO');
172 open $val, '<', \$str;
173 is(readline($stash->get_symbol('FOO')), "foo",
174 "got the right variable");
175 seek($stash->get_symbol('FOO'), 0, 0);
180 ::isa_ok(*FOO{IO}, 'IO');
182 "stash has the right variable");