3 use Test::More tests => 21;
5 use Variable::Magic qw/wizard cast dispell/;
11 for (0 .. 4) { return 0 unless $c[$_] == $x[$_]; }
15 my $wiz = wizard get => sub { ++$c[0] },
16 set => sub { ++$c[1] },
17 len => sub { ++$c[2]; $_[2] },
18 clear => sub { ++$c[3] },
19 free => sub { ++$c[4] };
20 ok(check(), 'array : create wizard');
22 my @n = map { int rand 1000 } 1 .. 5;
26 ok(check(), 'array : cast');
29 ok(check(), 'array : assign element to');
33 ok(check(), 'array : assign to');
37 ok(check(), 'array : interpolate');
40 ok(check(), 'array : reference');
43 ok(check(), 'array : slice');
47 ok(check(), 'array : assign');
50 ok(check(), 'array : assign old element');
54 ok(check(), 'array : assign new element');
57 ++$x[1]; ++$x[2] unless $^V && $^V gt 5.9.2; # since 5.9.3
58 ok(check(), 'array : push');
62 ok(check(), 'array : pop');
66 ok(check(), 'array : unshift');
70 ok(check(), 'array : shift');
74 ok(check(), 'array : length');
77 $x[1] += 4; ++$x[2]; ++$x[3];
78 ok(check(), 'array : map');
80 @b = grep { defined && $_ >= ord('b') } @a;
82 ok(check(), 'array : grep');
86 ok(check(), 'array : for');
93 ok(check(), 'array : scope end');
96 ++$x[3] if $^V && $^V gt 5.9.4; # since 5.9.5 - see #43357
97 ok(check(), 'array : undef');
100 ok(check(), 'array : dispel');