6 if (join('',@ary) eq '12345') {print "ok 1\n";} else {print "not ok 1\n";}
8 $tmp = $ary[$#ary]; --$#ary;
9 if ($tmp == 5) {print "ok 2\n";} else {print "not ok 2\n";}
10 if ($#ary == 3) {print "ok 3\n";} else {print "not ok 3\n";}
11 if (join('',@ary) eq '1234') {print "ok 4\n";} else {print "not ok 4\n";}
15 if (join('',@ary) eq '12345') {print "ok 5\n";} else {print "not ok 5\n";}
17 $tmp = $ary[$#ary]; --$#ary;
18 if ($tmp == 5) {print "ok 6\n";} else {print "not ok 6\n";}
19 if ($#ary == 4) {print "ok 7\n";} else {print "not ok 7\n";}
20 if (join('',@ary) eq '1234') {print "ok 8\n";} else {print "not ok 8\n";}
22 if ($ary[5] eq '') {print "ok 9\n";} else {print "not ok 9\n";}
24 $#ary += 1; # see if element 5 gone for good
25 if ($#ary == 5) {print "ok 10\n";} else {print "not ok 10\n";}
26 if (defined $ary[5]) {print "not ok 11\n";} else {print "ok 11\n";}
30 $r = join(',', $#foo, @foo);
31 if ($r eq "-1") {print "ok 12\n";} else {print "not ok 12 $r\n";}
33 $r = join(',', $#foo, @foo);
34 if ($r eq "0,0") {print "ok 13\n";} else {print "not ok 13 $r\n";}
36 $r = join(',', $#foo, @foo);
37 if ($r eq "2,0,,2") {print "ok 14\n";} else {print "not ok 14 $r\n";}
41 $r = join(',', $#bar, @bar);
42 if ($r eq "1,0,1") {print "ok 15\n";} else {print "not ok 15 $r\n";}
44 $r = join(',', $#bar, @bar);
45 if ($r eq "-1") {print "ok 16\n";} else {print "not ok 16 $r\n";}
47 $r = join(',', $#bar, @bar);
48 if ($r eq "0,0") {print "ok 17\n";} else {print "not ok 17 $r\n";}
50 $r = join(',', $#bar, @bar);
51 if ($r eq "2,0,,2") {print "ok 18\n";} else {print "not ok 18 $r\n";}
55 $r = join(',', $#bar, @bar);
56 if ($r eq "0,0") {print "ok 19\n";} else {print "not ok 19 $r\n";}
58 $r = join(',', $#bar, @bar);
59 if ($r eq "2,0,,2") {print "ok 20\n";} else {print "not ok 20 $r\n";}
61 $foo = 'now is the time';
62 if (($F1,$F2,$Etc) = ($foo =~ /^(\S+)\s+(\S+)\s*(.*)/)) {
63 if ($F1 eq 'now' && $F2 eq 'is' && $Etc eq 'the time') {
75 if ($cnt = (($F1,$F2,$Etc) = ($foo =~ /^(\S+)\s+(\S+)\s*(.*)/))) {
76 print "not ok 22 $cnt $F1:$F2:$Etc\n";
82 %foo = ('blurfl','dyick','foo','bar','etc.','etc.');
84 print $bar{'foo'} eq 'bar' ? "ok 23\n" : "not ok 23\n";
86 print $bar{'foo'} eq '' ? "ok 24\n" : "not ok 24\n";
87 (%bar,$a,$b) = (%foo,'how','now');
88 print $bar{'foo'} eq 'bar' ? "ok 25\n" : "not ok 25\n";
89 print $bar{'how'} eq 'now' ? "ok 26\n" : "not ok 26\n";
90 @bar{keys %foo} = values %foo;
91 print $bar{'foo'} eq 'bar' ? "ok 27\n" : "not ok 27\n";
92 print $bar{'how'} eq 'now' ? "ok 28\n" : "not ok 28\n";
94 @foo = grep(/e/,split(' ','now is the time for all good men to come to'));
95 print join(' ',@foo) eq 'the time men come' ? "ok 29\n" : "not ok 29\n";
97 @foo = grep(!/e/,split(' ','now is the time for all good men to come to'));
98 print join(' ',@foo) eq 'now is for all good to to' ? "ok 30\n" : "not ok 30\n";
100 $foo = join('',('a','b','c','d','e','f')[0..5]);
101 print $foo eq 'abcdef' ? "ok 31\n" : "not ok 31\n";
103 $foo = join('',('a','b','c','d','e','f')[0..1]);
104 print $foo eq 'ab' ? "ok 32\n" : "not ok 32\n";
106 $foo = join('',('a','b','c','d','e','f')[6]);
107 print $foo eq '' ? "ok 33\n" : "not ok 33\n";
109 @foo = ('a','b','c','d','e','f')[0,2,4];
110 @bar = ('a','b','c','d','e','f')[1,3,5];
111 $foo = join('',(@foo,@bar)[0..5]);
112 print $foo eq 'acebdf' ? "ok 34\n" : "not ok 34\n";
114 $foo = ('a','b','c','d','e','f')[0,2,4];
115 print $foo eq 'e' ? "ok 35\n" : "not ok 35\n";
117 $foo = ('a','b','c','d','e','f')[1];
118 print $foo eq 'b' ? "ok 36\n" : "not ok 36\n";
120 @foo = ( 'foo', 'bar', 'burbl');
122 print $#foo == 3 ? "ok 37\n" : "not ok 37\n";
124 # various AASSIGN_COMMON checks (see newASSIGNOP() in op.c)
127 sub t { ++$test; print "not " unless $_[0]; print "ok $test\n"; }
130 t("@foo" eq "foo bar burbl blah"); # 38
133 t("@foo" eq "bar burbl blah"); # 39
135 @foo = ('XXX',@foo, 'YYY');
136 t("@foo" eq "XXX bar burbl blah YYY"); # 40
138 @foo = @foo = qw(foo bar burbl blah);
139 t("@foo" eq "foo bar burbl blah"); # 41
141 @bar = @foo = qw(foo bar); # 42
142 t("@foo" eq "foo bar");
143 t("@bar" eq "foo bar"); # 43
145 # try the same with local
146 @foo = ( 'foo', 'bar', 'burbl', 'blah');
150 t("@foo" eq "foo bar burbl blah"); # 44
152 local (undef,@foo) = @foo;
153 t("@foo" eq "bar burbl blah"); # 45
155 local @foo = ('XXX',@foo,'YYY');
156 t("@foo" eq "XXX bar burbl blah YYY"); # 46
158 local @foo = local(@foo) = qw(foo bar burbl blah);
159 t("@foo" eq "foo bar burbl blah"); # 47
161 local (@bar) = local(@foo) = qw(foo bar);
162 t("@foo" eq "foo bar"); # 48
163 t("@bar" eq "foo bar"); # 49
165 t("@foo" eq "foo bar burbl blah"); # 50
167 t("@foo" eq "XXX bar burbl blah YYY"); # 51
169 t("@foo" eq "bar burbl blah"); # 52
171 t("@foo" eq "foo bar burbl blah"); # 53
174 # try the same with my
178 t("@foo" eq "foo bar burbl blah"); # 54
180 my (undef,@foo) = @foo;
181 t("@foo" eq "bar burbl blah"); # 55
183 my @foo = ('XXX',@foo,'YYY');
184 t("@foo" eq "XXX bar burbl blah YYY"); # 56
186 my @foo = my @foo = qw(foo bar burbl blah);
187 t("@foo" eq "foo bar burbl blah"); # 57
189 my (@bar) = my(@foo) = qw(foo bar);
190 t("@foo" eq "foo bar"); # 58
191 t("@bar" eq "foo bar"); # 59
193 t("@foo" eq "foo bar burbl blah"); # 60
195 t("@foo" eq "XXX bar burbl blah YYY"); # 61
197 t("@foo" eq "bar burbl blah"); # 62
199 t("@foo" eq "foo bar burbl blah"); # 63