}
}
- if (SvRMAGICAL(sv) && !tied) {
+ if (SvRMAGICAL(sv) && !tied && !(action & (HV_FETCH_ISSTORE|HV_DELETE))) {
/* Temporarily hide the RMAGICAL flag of the hash so it isn't wrongly
* mistaken for a tied hash by the rest of hv_common. It will be reset by
* the op_ppaddr of a new fake op injected between the current and the next
use strict;
use warnings;
-use Test::More tests => (2 * 22 + 7) + (2 * 5 + 5) + 1;
+use Test::More tests => (2 * 24 + 7) + (2 * 5 + 5) + 1;
use Variable::Magic qw<cast dispell VMG_UVAR>;
'assign element to';
is $s, $n{foo}, 'hash: assign element to correctly';
-for (1 .. 2) {
- $s = watch { exists $h{foo} } +{ (exists => 1) x VMG_UVAR }, "exists ($_)";
- ok $s, "hash: exists correctly ($_)";
-}
-
my %b;
watch { %b = %h } { }, 'assign to';
is_deeply \%b, \%n, 'hash: assign to correctly';
+{ (fetch => 2) x VMG_UVAR }, 'slice';
is_deeply \@b, [ @n{qw<bar qux>} ], 'hash: slice correctly';
+# exists
+
+watch { exists $h{bar} } +{ (exists => 1) x VMG_UVAR },'exists in void context';
+
+for (1 .. 2) {
+ $s = watch { exists $h{bar} } +{ (exists => 1) x VMG_UVAR },
+ "exists in scalar context ($_)";
+ ok $s, "hash: exists correctly ($_)";
+}
+
watch { %h = () } { clear => 1 }, 'empty in list context';
+watch { $h{a} = -1; %h = (b => $h{a}) }
+ +{ (fetch => 1, store => 2, copy => 2) x VMG_UVAR, clear => 1 },
+ 'empty and set in void context';
+
watch { %h = (a => 1, d => 3) }
+{ (store => 2, copy => 2) x VMG_UVAR, clear => 1 },
'assign from list in void context';