6 use Test::More tests => 21;
8 use Variable::Magic qw/wizard cast dispell VMG_COMPAT_ARRAY_PUSH_NOLEN VMG_COMPAT_ARRAY_UNDEF_CLEAR/;
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(), 'array : create wizard');
32 my @n = map { int rand 1000 } 1 .. 5;
36 ok(check(), 'array : cast');
39 ok(check(), 'array : assign element to');
43 ok(check(), 'array : assign to');
47 ok(check(), 'array : interpolate');
50 ok(check(), 'array : reference');
53 ok(check(), 'array : slice');
57 ok(check(), 'array : assign');
60 ok(check(), 'array : assign old element');
64 ok(check(), 'array : assign new element');
67 ++$x[1]; ++$x[2] unless VMG_COMPAT_ARRAY_PUSH_NOLEN;
68 ok(check(), 'array : push');
72 ok(check(), 'array : pop');
76 ok(check(), 'array : unshift');
80 ok(check(), 'array : shift');
84 ok(check(), 'array : length');
87 $x[1] += 4; ++$x[2]; ++$x[3];
88 ok(check(), 'array : map');
90 @b = grep { defined && $_ >= ord('b') } @a;
92 ok(check(), 'array : grep');
96 ok(check(), 'array : for');
103 ok(check(), 'array : scope end');
106 ++$x[3] if VMG_COMPAT_ARRAY_UNDEF_CLEAR;
107 ok(check(), 'array : undef');
110 ok(check(), 'array : dispel');