xref: /openbsd/gnu/usr.bin/perl/t/cmd/mod.t (revision e0680481)
1#!./perl
2
3print "1..15\n";
4
5print "ok 1\n" if 1;
6print "not ok 1\n" unless 1;
7
8print "ok 2\n" unless 0;
9print "not ok 2\n" if 0;
10
111 && (print "not ok 3\n") if 0;
121 && (print "ok 3\n") if 1;
130 || (print "not ok 4\n") if 0;
140 || (print "ok 4\n") if 1;
15
16$x = 0;
17do {$x[$x] = $x;} while ($x++) < 10;
18if (join(' ',@x) eq '0 1 2 3 4 5 6 7 8 9 10') {
19	print "ok 5\n";
20} else {
21	print "not ok 5 @x\n";
22}
23
24$x = 15;
25$x = 10 while $x < 10;
26if ($x == 15) {print "ok 6\n";} else {print "not ok 6\n";}
27
28$y[$_] = $_ * 2 foreach @x;
29if (join(' ',@y) eq '0 2 4 6 8 10 12 14 16 18 20') {
30	print "ok 7\n";
31} else {
32	print "not ok 7 @y\n";
33}
34
35# Well this is fragile...
36open(foo,'./TEST') || open(foo,'TEST') || open(foo,'t/TEST');
37$x = 0;
38$x++ while <foo>;
39print $x > 50 && $x < 2000 ? "ok 8\n" : "not ok 8\n";
40
41$x = -0.5;
42print "not " if scalar($x) < 0 and $x >= 0;
43print "ok 9\n";
44
45print "not " unless (-(-$x) < 0) == ($x < 0);
46print "ok 10\n";
47
48print "ok 11\n" if $x < 0;
49print "not ok 11\n" unless $x < 0;
50
51print "ok 12\n" unless $x > 0;
52print "not ok 12\n" if $x > 0;
53
54# This used to cause a segfault
55$x = "".("".do{"foo" for (1)});
56print "ok 13\n";
57
58$x = 0;
59do { ++$x } while 0;
60if ($x == 1) {
61    print "ok 14\n";
62} else {
63    print "not ok 14 # $x\n";
64}
65
66$x = 0;
67do { ++$x } until 1;
68if ($x == 1) {
69    print "ok 15\n";
70} else {
71    print "not ok 15 # $x\n";
72}
73