+@b = watch { values %h } { }, 'values';
+is_deeply [ sort { $a <=> $b } @b ], [ 1, 1, 2, 3 ], 'hash: values correctly';
+
+watch { while (my ($k, $v) = each %h) { } } { }, 'each';
+
+watch {
+ my %b = %n;
+ watch { cast %b, $wiz } { }, 'cast 2';
+} { free => 1 }, 'scope end';
+
+watch { undef %h } { clear => 1 }, 'undef';
+
+watch { dispell %h, $wiz } { }, 'dispell';
+
+SKIP: {
+ my $SKIP;
+
+ if (!VMG_UVAR) {
+ $SKIP = 'uvar magic';
+ } else {
+ local $@;
+ unless (eval { require B; require B::Deparse; 1 }) {
+ $SKIP = 'B and B::Deparse';
+ }
+ }
+ if ($SKIP) {
+ $SKIP .= ' required to test uvar/clear interaction fix';
+ skip $SKIP => 2 * ( 2 * 5 + 5);
+ }
+
+ my $bd = B::Deparse->new;
+
+ my %h1 = (a => 13, b => 15);
+ my %h2 = (a => 17, b => 19);
+
+ my @tests = (
+ [ \%h1 => 'first hash' => (14, 16) ],
+ [ \%h2 => 'second hash' => (18, 20) ],
+ );
+
+ for my $test (@tests) {
+ my ($h, $desc, @exp) = @$test;
+
+ watch { &cast($h, $wiz) } { }, "cast clear/uvar on $desc";
+
+ my $code = sub { my $x = $h->{$_[0]}; ++$x; $x };
+ my $before = $bd->coderef2text($code);
+ my $res;
+
+ watch { $res = $code->('a') } { fetch => 1 }, "fetch constant 'a' from $desc";
+ is $res, $exp[0], "uvar: fetch constant 'a' from $desc was correct";
+
+ my $after = $bd->coderef2text($code);
+ is $before, $after,
+ "uvar: code deparses correctly after constant fetch from $desc";
+
+ my $key = 'b';
+ watch { $res = $code->($key) } { fetch => 1 },"fetch variable 'b' from $desc";
+ is $res, $exp[1], "uvar: fetch variable 'b' from $desc was correct";
+
+ $after = $bd->coderef2text($code);
+ is $before, $after,
+ "uvar: code deparses correctly after variable fetch from $desc";
+
+ watch { %$h = () } { clear => 1 }, "fixed clear for $desc";
+
+ watch { &dispell($h, $wiz) } { }, "dispell clear/uvar from $desc";
+
+ ok(!(B::svref_2object($h)->FLAGS & B::SVs_RMG()),
+ "$desc no longer has the RMG flag set");
+ }
+}