6 use Test::More tests => 24;
8 use Variable::Magic qw/wizard cast dispell VMG_COMPAT_ARRAY_PUSH_NOLEN VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID VMG_COMPAT_ARRAY_UNDEF_CLEAR/;
14 is join(':', map { (defined) ? $_ : 'u' } @c[0 .. 11]),
15 join(':', map { (defined) ? $_ : 'u' } @x[0 .. 11]),
19 my $wiz = wizard get => sub { ++$c[0] },
20 set => sub { ++$c[1] },
21 len => sub { ++$c[2]; $_[2] },
22 clear => sub { ++$c[3] },
23 free => sub { ++$c[4] },
24 copy => sub { ++$c[5] },
25 dup => sub { ++$c[6] },
26 local => sub { ++$c[7] },
27 fetch => sub { ++$c[8] },
28 store => sub { ++$c[9] },
29 'exists' => sub { ++$c[10] },
30 'delete' => sub { ++$c[11] };
31 check('array : create wizard');
33 my @n = map { int rand 1000 } 1 .. 5;
37 check('array : cast');
40 check('array : assign element to');
44 check('array : assign to');
48 check('array : interpolate');
51 check('array : reference');
54 check('array : slice');
58 check('array : assign');
61 check('array : assign old element');
65 check('array : assign new element');
68 ++$x[1]; ++$x[2] unless VMG_COMPAT_ARRAY_PUSH_NOLEN;
69 check('array : push (void)');
72 ++$x[1]; ++$x[2] unless VMG_COMPAT_ARRAY_PUSH_NOLEN;
73 check('array : push (scalar)');
80 ++$x[1]; ++$x[2] unless VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID;
81 check('array : unshift (void)');
85 check('array : unshift (scalar)');
89 check('array : shift');
93 check('array : length @');
97 check('array : length $#');
100 $x[1] += 6; ++$x[2]; ++$x[3];
101 check('array : map');
103 @b = grep { defined && $_ >= ord('b') } @a;
105 check('array : grep');
109 check('array : for');
116 check('array : scope end');
119 ++$x[3] if VMG_COMPAT_ARRAY_UNDEF_CLEAR;
120 check('array : undef');
123 check('array : dispel');