my $run;
if (VMG_UVAR) {
- plan tests => 13;
+ plan tests => 23;
$run = 1;
} else {
plan skip_all => 'uvar magic is required to test symbol table hooks';
}, 'stash: variables';
}
+{
+ local %mg;
+
+ eval q[
+ die "ok\n";
+ package Hlagh;
+ sub eat;
+ sub shoot;
+ sub leave { "bye" };
+ sub shoot { "bang" };
+ ];
+
+ is $@, "ok\n", 'stash: function definitions compiled fine';
+ is_deeply \%mg, {
+ store => [ qw/eat shoot leave shoot/ ],
+ }, 'stash: function definitions';
+}
+
{
local %mg;
eval q{
die "ok\n";
package Hlagh;
- foo();
- bar();
- foo();
+ eat();
+ shoot();
+ leave();
+ roam();
+ yawn();
+ roam();
};
is $@, "ok\n", 'stash: function calls compiled fine';
is_deeply \%mg, {
- fetch => [ qw/foo bar foo/ ],
- store => [ qw/foo bar foo/ ],
+ fetch => [ qw/eat shoot leave roam yawn roam/ ],
+ store => [ qw/eat shoot leave roam yawn roam/ ],
}, 'stash: function calls';
}
+{
+ local %mg;
+
+ eval q{ Hlagh->shoot() };
+
+ is $@, '', 'stash: valid method call ran fine';
+ is_deeply \%mg, {
+ fetch => [ qw/shoot/ ],
+ }, 'stash: valid method call';
+}
+
+{
+ local %mg;
+
+ eval q[
+ package Hlagher;
+ our @ISA;
+ BEGIN { @ISA = 'Hlagh' }
+ Hlagher->shoot()
+ ];
+
+ is $@, '', 'inherited valid method call ran fine';
+ is_deeply \%mg, {
+ fetch => [ qw/ISA shoot/ ],
+ }, 'stash: direct method call';
+}
+
+{
+ local %mg;
+
+ eval q{ Hlagh->unknown() };
+
+ like $@, qr/^Can't locate object method "unknown" via package "Hlagh"/, 'stash: invalid method call croaked';
+ is_deeply \%mg, {
+ fetch => [ qw/unknown/ ],
+ store => [ qw/unknown AUTOLOAD/ ],
+ }, 'stash: invalid method call';
+}
+
+{
+ local %mg;
+
+ eval q{ Hlagher->also_unknown() };
+
+ like $@, qr/^Can't locate object method "also_unknown" via package "Hlagher"/, 'stash: invalid inherited method call croaked';
+ is_deeply \%mg, {
+ fetch => [ qw/also_unknown AUTOLOAD/ ],
+ }, 'stash: invalid method call';
+}
+
{
local %mg;
eval q{
package Hlagh;
- undef &foo;
+ undef &nevermentioned;
+ undef &eat;
+ undef &shoot;
};
is $@, '', 'stash: delete executed fine';
is_deeply \%mg, {
- store => [ qw/foo foo foo/ ],
+ store => [
+ qw/nevermentioned nevermentioned eat eat shoot shoot nevermentioned/
+ ],
}, 'stash: delete';
}