]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - t/31-array.t
This is 0.64
[perl/modules/Variable-Magic.git] / t / 31-array.t
index b5ff1ede5d542aca4a3071cb965dc1a9ac81299e..3613dba460618f33ac1e085e713c065c67c54b47 100644 (file)
@@ -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<get set len clear free copy dup local fetch store exists delete> ],
         '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<a b d> } { 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';