X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F32-hash.t;h=8803e35ac39c63d179bc95ff2df18892f92dbaf7;hb=c78c1790ebe43372ca405385d4cc053121b53ba0;hp=164c6ed51091e97a18b9ad2e8f836fc8ff38f079;hpb=1b88e230428d6cc4f3ff364fbcfd7f5c1a40fedc;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/32-hash.t b/t/32-hash.t index 164c6ed..8803e35 100644 --- a/t/32-hash.t +++ b/t/32-hash.t @@ -19,8 +19,7 @@ my %h = %n; check { cast %h, $wiz } { }, 'cast'; -my $s; -check { $s = $h{foo} } +{ (fetch => 1) x VMG_UVAR }, +my $s = check { $h{foo} } +{ (fetch => 1) x VMG_UVAR }, # (copy => 1) x MGf_COPY # if clear magic 'assign element to'; is $s, $n{foo}, 'hash: assign element to correctly'; @@ -32,10 +31,9 @@ my %b; check { %b = %h } { }, 'assign to'; is_deeply \%b, \%n, 'hash: assign to correctly'; -check { $s = \%h } { }, 'reference'; +$s = check { \%h } { }, 'reference'; -my @b; -check { @b = @h{qw/bar qux/} } +my @b = check { @h{qw/bar qux/} } +{ (fetch => 2) x VMG_UVAR }, 'slice'; # (copy => 2) x MGf_COPY # if clear magic is_deeply \@b, [ @n{qw/bar qux/} ], 'hash: slice correctly'; @@ -56,12 +54,12 @@ check { $h{d} = 2; () } +{ (store => 1) x VMG_UVAR }, check { $h{c} = 3; () } +{ (store => 1, copy => 1) x VMG_UVAR }, 'assign new element'; -check { $s = %h } { }, 'buckets'; +$s = check { %h } { }, 'buckets'; -check { @b = keys %h } { }, 'keys'; +@b = check { keys %h } { }, 'keys'; is_deeply [ sort @b ], [ qw/a b c d/ ], 'hash: keys correctly'; -check { @b = values %h } { }, 'values'; +@b = check { values %h } { }, 'values'; is_deeply [ sort { $a <=> $b } @b ], [ 1, 1, 2, 3 ], 'hash: values correctly'; check { while (my ($k, $v) = each %h) { } } { }, 'each';