8 use Variable::Magic qw/wizard cast dispell VMG_UVAR VMG_OP_INFO_NAME VMG_OP_INFO_OBJECT/;
15 plan skip_all => 'uvar magic is required to test symbol table hooks';
21 . join (', ', map { <<CB;
24 return 0 if \$d->{guard};
25 local \$d->{guard} = 1;
26 push \@{\$mg{$_}}, \$_[2];
30 } qw/fetch store exists delete/);
32 $code .= ', data => sub { +{ guard => 0 } }';
48 our $what = @Hlagh::stuff;
52 is $@, "ok\n", 'stash: variables compiled fine';
54 fetch => [ qw/thing stuff/ ],
55 store => [ qw/thing stuff/ ],
56 }, 'stash: variables';
71 is $@, "ok\n", 'stash: function definitions compiled fine';
73 store => [ qw/eat shoot leave shoot/ ],
74 }, 'stash: function definitions';
91 is $@, "ok\n", 'stash: function calls compiled fine';
93 fetch => [ qw/eat shoot leave roam yawn roam/ ],
94 store => [ qw/eat shoot leave roam yawn roam/ ],
95 }, 'stash: function calls';
101 eval q{ Hlagh->shoot() };
103 is $@, '', 'stash: valid method call ran fine';
105 fetch => [ qw/shoot/ ],
106 }, 'stash: valid method call';
115 BEGIN { @ISA = 'Hlagh' }
119 is $@, '', 'inherited valid method call ran fine';
121 fetch => [ qw/ISA shoot/ ],
122 }, 'stash: direct method call';
128 eval q{ Hlagh->unknown() };
130 like $@, qr/^Can't locate object method "unknown" via package "Hlagh"/, 'stash: invalid method call croaked';
132 fetch => [ qw/unknown/ ],
133 store => [ qw/unknown AUTOLOAD/ ],
134 }, 'stash: invalid method call';
140 eval q{ Hlagher->also_unknown() };
142 like $@, qr/^Can't locate object method "also_unknown" via package "Hlagher"/, 'stash: invalid inherited method call croaked';
144 fetch => [ qw/also_unknown AUTOLOAD/ ],
145 }, 'stash: invalid method call';
153 undef &nevermentioned;
158 is $@, '', 'stash: delete executed fine';
161 qw/nevermentioned nevermentioned eat eat shoot shoot nevermentioned/
167 is_deeply \%mg, { }, 'stash: magic that remains at END time' if $run;
170 dispell %Hlagh::, $wiz;
175 use vars qw/$AUTOLOAD/;
177 sub AUTOLOAD { return $AUTOLOAD }
180 cast %AutoHlagh::, $wiz;
185 my $res = eval q{ AutoHlagh->autoloaded() };
187 is $@, '', 'stash: autoloaded method call ran fine';
188 is $res, 'AutoHlagh::autoloaded',
189 'stash: autoloaded method call returned the right thing';
191 fetch => [ qw/autoloaded/ ],
192 store => [ qw/autoloaded AUTOLOAD AUTOLOAD/ ],
193 }, 'stash: autoloaded method call';
200 BEGIN { @ISA = ('AutoHlagh') }
206 my $res = eval q{ AutoHlagher->also_autoloaded() };
208 is $@, '', 'stash: inherited autoloaded method call ran fine';
209 is $res, 'AutoHlagher::also_autoloaded',
210 'stash: inherited autoloaded method returned the right thing';
212 fetch => [ qw/also_autoloaded AUTOLOAD/ ],
213 store => [ qw/AUTOLOAD/ ],
214 }, 'stash: inherited autoloaded method call';
217 dispell %AutoHlagh::, $wiz;
220 . join (', ', map { <<CB;
223 return 0 if \$d->{guard};
224 local \$d->{guard} = 1;
225 is \$_[3], undef, 'stash: undef op';
229 } qw/fetch store exists delete/);
231 $code .= ', data => sub { +{ guard => 0 } }';
233 $wiz = eval $code . ', op_info => ' . VMG_OP_INFO_NAME;
244 is $@, "ok\n", 'stash: function call with op name compiled fine';
246 dispell %Hlagh::, $wiz;
248 $wiz = eval $code . ', op_info => ' . VMG_OP_INFO_OBJECT;
259 is $@, "ok\n", 'stash: function call with op object compiled fine';
261 dispell %Hlagh::, $wiz;