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;
173 . join (', ', map { <<CB;
176 return 0 if \$d->{guard};
177 local \$d->{guard} = 1;
178 is \$_[3], undef, 'stash: undef op';
182 } qw/fetch store exists delete/);
184 $code .= ', data => sub { +{ guard => 0 } }';
186 $wiz = eval $code . ', op_info => ' . VMG_OP_INFO_NAME;
197 is $@, "ok\n", 'stash: function call with op name compiled fine';
199 dispell %Hlagh::, $wiz;
201 $wiz = eval $code . ', op_info => ' . VMG_OP_INFO_OBJECT;
212 is $@, "ok\n", 'stash: function call with op object compiled fine';
214 dispell %Hlagh::, $wiz;