+curr_test($t);
+
+# qw() is no longer a runtime split, it's compiletime.
+is (qw(foo bar snorfle)[2], 'snorfle');
+
+@ary = (12,23,34,45,56);
+
+is(shift(@ary), 12);
+is(pop(@ary), 56);
+is(push(@ary,56), 4);
+is(unshift(@ary,12), 5);
+
+sub foo { "a" }
+@foo=(foo())[0,0];
+is ($foo[1], "a");
+
+# bugid #15439 - clearing an array calls destructors which may try
+# to modify the array - caused 'Attempt to free unreferenced scalar'
+
+my $got = runperl (
+ prog => q{
+ sub X::DESTROY { @a = () }
+ @a = (bless {}, q{X});
+ @a = ();
+ },
+ stderr => 1
+ );
+
+$got =~ s/\n/ /g;
+is ($got, '');
+
+# Test negative and funky indices.
+
+
+{
+ my @a = 0..4;
+ is($a[-1], 4);
+ is($a[-2], 3);
+ is($a[-5], 0);
+ ok(!defined $a[-6]);
+
+ is($a[2.1] , 2);
+ is($a[2.9] , 2);
+ is($a[undef], 0);
+ is($a["3rd"], 3);
+}
+
+
+{
+ my @a;
+ eval '$a[-1] = 0';
+ like($@, qr/Modification of non-creatable array value attempted, subscript -1/, "\$a[-1] = 0");
+}
+
+sub test_arylen {
+ my $ref = shift;
+ local $^W = 1;
+ is ($$ref, undef, "\$# on freed array is undef");
+ my @warn;
+ local $SIG{__WARN__} = sub {push @warn, "@_"};
+ $$ref = 1000;
+ is (scalar @warn, 1);
+ like ($warn[0], qr/^Attempt to set length of freed array/);
+}
+
+{
+ my $a = \$#{[]};
+ # Need a new statement to make it go out of scope
+ test_arylen ($a);
+ test_arylen (do {my @a; \$#a});
+}
+
+{
+ use vars '@array';
+
+ my $outer = \$#array;
+ is ($$outer, -1);
+ is (scalar @array, 0);
+
+ $$outer = 3;
+ is ($$outer, 3);
+ is (scalar @array, 4);
+
+ my $ref = \@array;
+
+ my $inner;
+ {
+ local @array;
+ $inner = \$#array;
+
+ is ($$inner, -1);
+ is (scalar @array, 0);
+ $$outer = 6;
+
+ is (scalar @$ref, 7);
+
+ is ($$inner, -1);
+ is (scalar @array, 0);
+
+ $$inner = 42;
+ }
+
+ is (scalar @array, 7);
+ is ($$outer, 6);
+
+ is ($$inner, undef, "orphaned $#foo is always undef");
+
+ is (scalar @array, 7);
+ is ($$outer, 6);
+
+ $$inner = 1;
+
+ is (scalar @array, 7);
+ is ($$outer, 6);
+
+ $$inner = 503; # Bang!
+
+ is (scalar @array, 7);
+ is ($$outer, 6);
+}
+
+{
+ # Bug #36211
+ use vars '@array';
+ for (1,2) {
+ {
+ local @a;
+ is ($#a, -1);
+ @a=(1..4)
+ }
+ }
+}
+
+{
+ # Bug #37350
+ my @array = (1..4);
+ $#{@array} = 7;
+ is ($#{4}, 7);
+
+ my $x;
+ $#{$x} = 3;
+ is(scalar @$x, 4);
+
+ push @{@array}, 23;
+ is ($4[8], 23);
+}
+{
+ # Bug #37350 -- once more with a global
+ use vars '@array';
+ @array = (1..4);
+ $#{@array} = 7;
+ is ($#{4}, 7);
+
+ my $x;
+ $#{$x} = 3;
+ is(scalar @$x, 4);
+
+ push @{@array}, 23;
+ is ($4[8], 23);
+}
+
+# more tests for AASSIGN_COMMON
+
+{
+ our($x,$y,$z) = (1..3);
+ our($y,$z) = ($x,$y);
+ is("$x $y $z", "1 1 2");
+}
+{
+ our($x,$y,$z) = (1..3);
+ (our $y, our $z) = ($x,$y);
+ is("$x $y $z", "1 1 2");
+}
+{
+ # AASSIGN_COMMON detection with logical operators
+ my $true = 1;
+ our($x,$y,$z) = (1..3);
+ (our $y, our $z) = $true && ($x,$y);
+ is("$x $y $z", "1 1 2");
+}
+
+# [perl #70171]
+{
+ my $x = get_x(); my %x = %$x; sub get_x { %x=(1..4); return \%x };
+ is(
+ join(" ", map +($_,$x{$_}), sort keys %x), "1 2 3 4",
+ 'bug 70171 (self-assignment via my %x = %$x)'
+ );
+ my $y = get_y(); my @y = @$y; sub get_y { @y=(1..4); return \@y };
+ is(
+ "@y", "1 2 3 4",
+ 'bug 70171 (self-assignment via my @x = @$x)'
+ );
+}
+
+# [perl #70171], [perl #82110]
+{
+ my ($i, $ra, $rh);
+ again:
+ my @a = @$ra; # common assignment on 2nd attempt
+ my %h = %$rh; # common assignment on 2nd attempt
+ @a = qw(1 2 3 4);
+ %h = qw(a 1 b 2 c 3 d 4);
+ $ra = \@a;
+ $rh = \%h;
+ goto again unless $i++;
+
+ is("@a", "1 2 3 4",
+ 'bug 70171 (self-assignment via my @x = @$x) - goto variant'
+ );
+ is(
+ join(" ", map +($_,$h{$_}), sort keys %h), "a 1 b 2 c 3 d 4",
+ 'bug 70171 (self-assignment via my %x = %$x) - goto variant'
+ );
+}
+
+
+*trit = *scile; $trit[0];
+ok(1, 'aelem_fast on a nonexistent array does not crash');
+
+# [perl #107440]
+sub A::DESTROY { $::ra = 0 }
+$::ra = [ bless [], 'A' ];
+undef @$::ra;
+pass 'no crash when freeing array that is being undeffed';
+$::ra = [ bless [], 'A' ];
+@$::ra = ('a'..'z');
+pass 'no crash when freeing array that is being cleared';
+
+# [perl #85670] Copying magic to elements
+SKIP: {
+ skip "no Scalar::Util::weaken on miniperl", 1, if is_miniperl;
+ require Scalar::Util;
+ package glelp {
+ Scalar::Util::weaken ($a = \@ISA);
+ @ISA = qw(Foo);
+ Scalar::Util::weaken ($a = \$ISA[0]);
+ ::is @ISA, 1, 'backref magic is not copied to elements';
+ }
+}
+package peen {
+ $#ISA = -1;
+ @ISA = qw(Foo);
+ $ISA[0] = qw(Sphare);
+
+ sub Sphare::pling { 'pling' }
+
+ ::is eval { pling peen }, 'pling',
+ 'arylen_p magic does not stop isa magic from being copied';
+}