blob: 2b4962f58ab8054f8b29fae562aa25e5af0909b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#!./perl
# $Header: cmd.subval,v 1.0 87/12/18 13:12:12 root Exp $
sub foo1 {
'true1';
if ($_[0]) { 'true2'; }
}
sub foo2 {
'true1';
if ($_[0]) { 'true2'; } else { 'true3'; }
}
sub foo3 {
'true1';
unless ($_[0]) { 'true2'; }
}
sub foo4 {
'true1';
unless ($_[0]) { 'true2'; } else { 'true3'; }
}
sub foo5 {
'true1';
'true2' if $_[0];
}
sub foo6 {
'true1';
'true2' unless $_[0];
}
print "1..12\n";
if (do foo1(0) eq '') {print "ok 1\n";} else {print "not ok 1\n";}
if (do foo1(1) eq 'true2') {print "ok 2\n";} else {print "not ok 2\n";}
if (do foo2(0) eq 'true3') {print "ok 3\n";} else {print "not ok 3\n";}
if (do foo2(1) eq 'true2') {print "ok 4\n";} else {print "not ok 4\n";}
if (do foo3(0) eq 'true2') {print "ok 5\n";} else {print "not ok 5\n";}
if (do foo3(1) eq '') {print "ok 6\n";} else {print "not ok 6\n";}
if (do foo4(0) eq 'true2') {print "ok 7\n";} else {print "not ok 7\n";}
if (do foo4(1) eq 'true3') {print "ok 8\n";} else {print "not ok 8\n";}
if (do foo5(0) eq '') {print "ok 9\n";} else {print "not ok 9\n";}
if (do foo5(1) eq 'true2') {print "ok 10\n";} else {print "not ok 10\n";}
if (do foo6(0) eq 'true2') {print "ok 11\n";} else {print "not ok 11\n";}
if (do foo6(1) eq '') {print "ok 12\n";} else {print "not ok 12\n";}
|