]> git.vpit.fr Git - perl/modules/autovivification.git/blobdiff - t/30-array.t
This is 0.18
[perl/modules/autovivification.git] / t / 30-array.t
index c6be2aa5df8aa7af7d630cef06d9424e51aad274..af31ea4d21260f7c9c3ef0f5ef4f5a3e72ce3123 100644 (file)
@@ -3,9 +3,9 @@
 use strict;
 use warnings;
 
-use Test::More tests => 6 * 3 * 274;
-
 use lib 't/lib';
+use Test::Leaner tests => 9 * 3 * 302;
+
 use autovivification::TestCases;
 
 while (<DATA>) {
@@ -116,6 +116,20 @@ $x->[$N[0]] = 1 # 1 for $x->[$N[1]]; () # '', undef, [ 1, undef ] # +delete
 $x->[$N[0]] = 1 # 1 for $x->[$N[0]]; () # '', undef, [ 1 ] # +store
 $x->[$N[0]] = 1 # 1 for $x->[$N[1]]; () # '', undef, [ 1, undef ] # +store
 
+$x # do_nothing($x->[$N[0]]); () # '', undef, [ ]
+$x # do_nothing($x->[$N[0]]); () # '', undef, [ ] #
+$x # do_nothing($x->[$N[0]]); () # '', undef, [ ] # +fetch
+$x # do_nothing($x->[$N[0]]); () # '', undef, [ ] # +exists
+$x # do_nothing($x->[$N[0]]); () # '', undef, [ ] # +delete
+$x # do_nothing($x->[$N[0]]); () # qr/^Can't vivify reference/, undef, undef # +store
+
+$x # set_arg($x->[$N[0]]); () # '', undef, [ 1 ]
+$x # set_arg($x->[$N[0]]); () # '', undef, [ 1 ] #
+$x # set_arg($x->[$N[0]]); () # '', undef, [ 1 ] # +fetch
+$x # set_arg($x->[$N[0]]); () # '', undef, [ 1 ] # +exists
+$x # set_arg($x->[$N[0]]); () # '', undef, [ 1 ] # +delete
+$x # set_arg($x->[$N[0]]); () # qr/^Can't vivify reference/, undef, undef # +store
+
 --- dereferencing ---
 
 $x # no warnings 'uninitialized'; my @a = @$x; () # ($strict ? qr/^Can't use an undefined value as an ARRAY reference/ : ''), undef, undef
@@ -130,6 +144,28 @@ $x->[$N[0]] = 1 # my @a = @$x; () # '', undef, [ 1 ] # +exists
 $x->[$N[0]] = 1 # my @a = @$x; () # '', undef, [ 1 ] # +delete
 $x->[$N[0]] = 1 # my @a = @$x; () # '', undef, [ 1 ] # +store
 
+--- slice ---
+
+$x # my @a = @$x[$N[0], $N[1]]; \@a # '', [ undef, undef ], [ ]
+$x # my @a = @$x[$N[0], $N[1]]; \@a # '', [ undef, undef ], undef #
+$x # my @a = @$x[$N[0], $N[1]]; \@a # '', [ undef, undef ], undef # +fetch
+$x # my @a = @$x[$N[0], $N[1]]; \@a # '', [ undef, undef ], [ ] # +exists
+$x # my @a = @$x[$N[0], $N[1]]; \@a # '', [ undef, undef ], [ ] # +delete
+$x # my @a = @$x[$N[0], $N[1]]; \@a # '', [ undef, undef ], [ ] # +store
+
+$x->[$N[1]] = 0 # my @a = @$x[$N[0], $N[1]]; \@a # '', [ undef, 0 ], [ undef, 0 ] # +fetch
+
+$x # @$x[$N[0], $N[1]] = (1, 2); () # '', undef, [ 1, 2 ]
+$x # @$x[$N[0], $N[1]] = (1, 2); () # '', undef, [ 1, 2 ] #
+$x # @$x[$N[0], $N[1]] = (1, 2); () # '', undef, [ 1, 2 ] # +fetch
+$x # @$x[$N[0], $N[1]] = (1, 2); () # '', undef, [ 1, 2 ] # +exists
+$x # @$x[$N[0], $N[1]] = (1, 2); () # '', undef, [ 1, 2 ] # +delete
+$x # @$x[$N[0], $N[1]] = (1, 2); () # qr/^Can't vivify reference/, undef, undef # +store
+
+$x->[$N[0]] = 0 # @$x[$N[0], $N[1]] = (1, 2); () # '', undef, [ 1, 2 ] # +store
+$x->[$N[2]] = 0 # @$x[$N[0], $N[1]] = (1, 2); () # '', undef, [ 1, 2, 0 ] # +store
+$x->[$N[0]] = 0, $x->[$N[1]] = 0 # @$x[$N[0], $N[1]] = (1, 2); () # '', undef, [ 1, 2 ] # +store
+
 --- exists ---
 
 $x # exists $x->[$N[0]] # '', '', [ ]