This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: updated patch on the sysread, syswrite for VMS
[perl5.git] / t / op / list.t
CommitLineData
8d063cd8
LW
1#!./perl
2
79072805 3# $RCSfile: list.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:02 $
8d063cd8 4
a687059c 5print "1..27\n";
8d063cd8
LW
6
7@foo = (1, 2, 3, 4);
8if ($foo[0] == 1 && $foo[3] == 4) {print "ok 1\n";} else {print "not ok 1\n";}
9
a687059c 10$_ = join(':',@foo);
8d063cd8
LW
11if ($_ eq '1:2:3:4') {print "ok 2\n";} else {print "not ok 2\n";}
12
13($a,$b,$c,$d) = (1,2,3,4);
14if ("$a;$b;$c;$d" eq '1;2;3;4') {print "ok 3\n";} else {print "not ok 3\n";}
15
16($c,$b,$a) = split(/ /,"111 222 333");
17if ("$a;$b;$c" eq '333;222;111') {print "ok 4\n";} else {print "not ok 4\n";}
18
19($a,$b,$c) = ($c,$b,$a);
a687059c 20if ("$a;$b;$c" eq '111;222;333') {print "ok 5\n";} else {print "not ok 5 $a;$b;$c\n";}
8d063cd8
LW
21
22($a, $b) = ($b, $a);
23if ("$a;$b;$c" eq '222;111;333') {print "ok 6\n";} else {print "not ok 6\n";}
24
25($a, $b[1], $c{2}, $d) = (1, 2, 3, 4);
26if ($a eq 1) {print "ok 7\n";} else {print "not ok 7\n";}
27if ($b[1] eq 2) {print "ok 8\n";} else {print "not ok 8\n";}
28if ($c{2} eq 3) {print "ok 9\n";} else {print "not ok 9\n";}
29if ($d eq 4) {print "ok 10\n";} else {print "not ok 10\n";}
30
31@foo = (1,2,3,4,5,6,7,8);
32($a, $b, $c, $d) = @foo;
33print "#11 $a;$b;$c;$d eq 1;2;3;4\n";
34if ("$a;$b;$c;$d" eq '1;2;3;4') {print "ok 11\n";} else {print "not ok 11\n";}
378cc40b 35
a687059c
LW
36@foo = @bar = (1);
37if (join(':',@foo,@bar) eq '1:1') {print "ok 12\n";} else {print "not ok 12\n";}
378cc40b
LW
38
39@foo = ();
40@foo = 1+2+3;
41if (join(':',@foo) eq '6') {print "ok 13\n";} else {print "not ok 13\n";}
42
43for ($x = 0; $x < 3; $x++) {
44 ($a, $b, $c) =
45 $x == 0?
46 ('ok ', 14, "\n"):
47 $x == 1?
48 ('ok ', 15, "\n"):
49 # default
50 ('ok ', 16, "\n");
51
52 print $a,$b,$c;
53}
54
55@a = ($x == 12345 || (1,2,3));
56if (join('',@a) eq '123') {print "ok 17\n";} else {print "not ok 17\n";}
57
58@a = ($x == $x || (4,5,6));
59if (join('',@a) eq '1') {print "ok 18\n";} else {print "not ok 18\n";}
a687059c
LW
60
61if (join('',1,2,(3,4,5)) eq '12345'){print "ok 19\n";}else{print "not ok 19\n";}
62if (join('',(1,2,3,4,5)) eq '12345'){print "ok 20\n";}else{print "not ok 20\n";}
63if (join('',(1,2,3,4),5) eq '12345'){print "ok 21\n";}else{print "not ok 21\n";}
64if (join('',1,(2,3,4),5) eq '12345'){print "ok 22\n";}else{print "not ok 22\n";}
65if (join('',1,2,(3,4),5) eq '12345'){print "ok 23\n";}else{print "not ok 23\n";}
66if (join('',1,2,3,(4),5) eq '12345'){print "ok 24\n";}else{print "not ok 24\n";}
67
68for ($x = 0; $x < 3; $x++) {
69 ($a, $b, $c) = do {
70 if ($x == 0) {
71 ('ok ', 25, "\n");
72 }
73 elsif ($x == 1) {
74 ('ok ', 26, "\n");
75 }
76 else {
77 ('ok ', 27, "\n");
78 }
79 };
80
81 print $a,$b,$c;
82}
83