9 @tests = split(/\n/, <<EOF);
11 0 0 a b c, , a b c 0 1 2 3 4 5 6 7
12 8 0 a b c, , 0 1 2 3 4 5 6 7 a b c
13 7 0 6.5, , 0 1 2 3 4 5 6 6.5 7
14 1 0 a b c d e f g h i j,, 0 a b c d e f g h i j 1 2 3 4 5 6 7
15 0 1 a, 0, a 1 2 3 4 5 6 7
16 1 6 x y z, 1 2 3 4 5 6, 0 x y z 7
17 0 7 x y z, 0 1 2 3 4 5 6, x y z 7
18 1 7 x y z, 1 2 3 4 5 6 7, 0 x y z
23 plan tests => 10 + @tests*2;
24 die "blech" unless @tests;
28 is( join(':',@x), '1:2:3:1:2:3', 'push array onto array');
30 is( join(':',@x), '1:2:3:1:2:3:4', 'push integer onto array');
32 # test autovivification
33 push @$undef1, 1, 2, 3;
34 is( join(':',@$undef1), '1:2:3', 'autovivify array');
36 # test implicit dereference errors
37 eval "push 42, 0, 1, 2, 3";
38 like ( $@, qr/must be array/, 'push onto a literal integer');
41 eval q{ push $hashref, 0, 1, 2, 3 };
42 like( $@, qr/Experimental push on scalar is now forbidden/, 'push onto a hashref');
44 eval q{ push bless([]), 0, 1, 2, 3 };
45 like( $@, qr/Experimental push on scalar is now forbidden/, 'push onto a blessed array ref');
51 my($first, $second) = ([1], [2]);
52 sub two_things { return +($first, $second) }
53 push @{ two_things() }, 3;
54 is( join(':',@$first), '1', "\$first = [ @$first ];");
55 is( join(':',@$second), '2:3', "\$second = [ @$second ]");
58 foreach $line (@tests) {
59 ($list,$get,$leave) = split(/,\t*/,$line);
60 ($pos, $len, @list) = split(' ',$list);
61 @get = split(' ',$get);
62 @leave = split(' ',$leave);
63 @x = (0,1,2,3,4,5,6,7);
65 @got = splice(@x, $pos, $len, @list);
68 @got = splice(@x, $pos);
70 is(join(':',@got), join(':',@get), "got: @got == @get");
71 is(join(':',@x), join(':',@leave), "left: @x == @leave");
77 my @readonly_array = 10..11;
78 Internals::SvREADONLY(@readonly_array, 1);
79 eval { push @readonly_array, () };
80 is $@, '', "can push empty list onto readonly array";
82 eval { push @readonly_array, 9 };
83 like $@, qr/^Modification of a read-only value/,
84 "croak when pushing onto readonly array";
87 1; # this file is require'd by lib/tie-stdpush.t