6 use Test::More tests => 18;
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 = (a => 1, d => 3);
59 $x[5] += 2 if VMG_UVAR;
60 $x[9] += 2 if VMG_UVAR;
61 ok(check(), 'hash : assign from list');
63 %a = map { $_ => 1 } qw/a b d/;
65 $x[5] += 3 if VMG_UVAR;
66 $x[9] += 3 if VMG_UVAR;
67 ok(check(), 'hash : assign from map');
72 ok(check(), 'hash : assign old element');
77 ok(check(), 'hash : assign new element');
80 ok(check(), 'hash : buckets');
83 ok(check(), 'hash : keys');
86 ok(check(), 'hash : values');
88 while (my ($k, $v) = each %a) { }
89 ok(check(), 'hash : each');
96 ok(check(), 'hash : scope end');
100 ok(check(), 'hash : undef');
103 ok(check(), 'hash : dispel');