6 use Test::More tests => 17;
8 use Variable::Magic qw/wizard cast dispell MGf_COPY VMG_UVAR/;
14 for (0 .. 11) { return 0 unless $c[$_] == $x[$_]; }
18 my $wiz = wizard get => sub { ++$c[0] },
19 set => sub { ++$c[1] },
20 len => sub { ++$c[2]; $_[2] },
21 clear => sub { ++$c[3] },
22 free => sub { ++$c[4] },
23 copy => sub { ++$c[5] },
24 dup => sub { ++$c[6] },
25 local => sub { ++$c[7] },
26 fetch => sub { ++$c[8] },
27 store => sub { ++$c[9] },
28 'exists' => sub { ++$c[10] },
29 'delete' => sub { ++$c[11] };
30 ok(check(), 'hash : create wizard');
32 my %n = map { $_ => int rand 1000 } qw/foo bar baz qux/;
36 ok(check(), 'hash : cast');
41 ok(check(), 'hash : assign element to');
44 ok(check(), 'hash : assign to');
47 ok(check(), 'hash : interpolate');
50 ok(check(), 'hash : reference');
52 my @b = @a{qw/bar qux/};
53 $x[5] += 2 if MGf_COPY;
54 $x[8] += 2 if VMG_UVAR;
55 ok(check(), 'hash : slice');
57 %a = map { $_ => 1 } qw/a b d/;
59 $x[5] += 3 if MGf_COPY && $^V && $^V gt 5.9.3;
60 $x[9] += 3 if VMG_UVAR;
61 ok(check(), 'hash : assign');
66 ok(check(), 'hash : assign old element');
71 ok(check(), 'hash : assign new element');
74 ok(check(), 'hash : buckets');
77 ok(check(), 'hash : keys');
80 ok(check(), 'hash : values');
82 while (my ($k, $v) = each %a) { }
83 ok(check(), 'hash : each');
90 ok(check(), 'hash : scope end');
94 ok(check(), 'hash : undef');
97 ok(check(), 'hash : dispel');