X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F31-array.t;h=3613dba460618f33ac1e085e713c065c67c54b47;hb=9ad970e109ea4caa9767db1bda9d475444920c7a;hp=b5ff1ede5d542aca4a3071cb965dc1a9ac81299e;hpb=6a204757f3b9c5d10bc57e21cbb65c0e29688066;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/31-array.t b/t/31-array.t index b5ff1ed..3613dba 100644 --- a/t/31-array.t +++ b/t/31-array.t @@ -5,13 +5,18 @@ use warnings; use Test::More tests => 2 * 27 + 13 + 1; -use Variable::Magic qw/cast dispell VMG_COMPAT_ARRAY_PUSH_NOLEN VMG_COMPAT_ARRAY_PUSH_NOLEN_VOID VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID VMG_COMPAT_ARRAY_UNDEF_CLEAR/; +use Variable::Magic qw< + cast dispell + VMG_COMPAT_ARRAY_PUSH_NOLEN VMG_COMPAT_ARRAY_PUSH_NOLEN_VOID + VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID + VMG_COMPAT_ARRAY_UNDEF_CLEAR +>; use lib 't/lib'; use Variable::Magic::TestWatcher; my $wiz = init_watcher - [ qw/get set len clear free copy dup local fetch store exists delete/ ], + [ qw ], 'array'; my @n = map { int rand 1000 } 1 .. 5; @@ -33,7 +38,7 @@ $b = watch { \@a } { }, 'reference'; @b = watch { @a[2 .. 4] } { }, 'slice'; is_deeply \@b, [ @n[2 .. 4] ], 'array: slice correctly'; -watch { @a = qw/a b d/ } { set => 3, clear => 1 }, 'assign'; +watch { @a = qw } { set => 3, clear => 1 }, 'assign'; watch { $a[2] = 'c' } { }, 'assign old element'; @@ -52,7 +57,7 @@ is $b, 3, 'array: length @ correctly'; watch { $b = $#a } { len => 1 }, 'length $#'; is $b, 2, 'array: length $# correctly'; -watch { push @a, 'x'; () } +watch { push @a, 'x'; () } # push looks at the static context { set => 1, (len => 1) x !VMG_COMPAT_ARRAY_PUSH_NOLEN_VOID }, 'push (void)'; @@ -64,7 +69,7 @@ is $b, 5, 'array: push (scalar) correctly'; $b = watch { pop @a } { set => 1, len => 1 }, 'pop'; is $b, 'y', 'array: pop correctly'; -watch { unshift @a, 'z'; () } +watch { unshift @a, 'z'; () } # unshift looks at the static context { set => 1, (len => 1) x !VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID }, 'unshift (void)'; @@ -74,7 +79,7 @@ is $b, 6, 'unshift (scalar) correctly'; $b = watch { shift @a } { set => 1, len => 1 }, 'shift'; is $b, 't', 'array: shift correctly'; -watch { my $i; @a = map ++$i, @a; () } { set => 5, len => 1, clear => 1}, 'map'; +watch { my $i; @a = map ++$i, @a } { set => 5, len => 1, clear => 1}, 'map'; @b = watch { grep { $_ >= 4 } @a } { len => 1 }, 'grep'; is_deeply \@b, [ 4 .. 5 ], 'array: grep correctly';