1#!./perl 2 3$| = 1; 4 5use strict; 6use Test::More; 7 8plan(skip_all => "skipped for VMS") if $^O eq 'VMS'; 9plan(tests => 12); 10 11use Env qw(@FOO); 12use vars qw(@BAR); 13 14sub array_equal 15{ 16 my ($a, $b) = @_; 17 return 0 unless scalar(@$a) == scalar(@$b); 18 for my $i (0..scalar(@$a) - 1) { 19 return 0 unless $a->[$i] eq $b->[$i]; 20 } 21 return 1; 22} 23 24@FOO = qw(a B c); 25@BAR = qw(a B c); 26is_deeply(\@FOO, \@BAR, "Assignment"); 27 28$FOO[1] = 'b'; 29$BAR[1] = 'b'; 30is_deeply(\@FOO, \@BAR, "Storing"); 31 32$#FOO = 0; 33$#BAR = 0; 34is_deeply(\@FOO, \@BAR, "Truncation"); 35 36push @FOO, 'b', 'c'; 37push @BAR, 'b', 'c'; 38is_deeply(\@FOO, \@BAR, "Push"); 39 40pop @FOO; 41pop @BAR; 42is_deeply(\@FOO, \@BAR, "Pop"); 43 44shift @FOO; 45shift @BAR; 46is_deeply(\@FOO, \@BAR, "Shift"); 47 48push @FOO, 'c'; 49push @BAR, 'c'; 50is_deeply(\@FOO, \@BAR, "Push"); 51 52unshift @FOO, 'a'; 53unshift @BAR, 'a'; 54is_deeply(\@FOO, \@BAR, "Unshift"); 55 56@FOO = reverse @FOO; 57@BAR = reverse @BAR; 58is_deeply(\@FOO, \@BAR, "Reverse"); 59 60@FOO = sort @FOO; 61@BAR = sort @BAR; 62is_deeply(\@FOO, \@BAR, "Sort"); 63 64splice @FOO, 1, 1, 'B'; 65splice @BAR, 1, 1, 'B'; 66is_deeply(\@FOO, \@BAR, "Splice"); 67 68my $foo = $ENV{FOO}; 69() = splice @FOO, 0, 0; 70is $ENV{FOO}, $foo, 'Splice in list context'; 71