3 # $RCSfile: subval.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:13 $
7 if ($_[0]) { 'true2'; }
12 if ($_[0]) { return 'true2'; } else { return 'true3'; }
18 unless ($_[0]) { 'true2'; }
23 unless ($_[0]) { 'true2'; } else { 'true3'; }
38 if (&foo1(0) eq '0') {print "ok 1\n";} else {print "not ok 1 $foo\n";}
39 if (&foo1(1) eq 'true2') {print "ok 2\n";} else {print "not ok 2\n";}
40 if (&foo2(0) eq 'true3') {print "ok 3\n";} else {print "not ok 3\n";}
41 if (&foo2(1) eq 'true2') {print "ok 4\n";} else {print "not ok 4\n";}
43 if (&foo3(0) eq 'true2') {print "ok 5\n";} else {print "not ok 5\n";}
44 if (&foo3(1) eq '1') {print "ok 6\n";} else {print "not ok 6\n";}
45 if (&foo4(0) eq 'true2') {print "ok 7\n";} else {print "not ok 7\n";}
46 if (&foo4(1) eq 'true3') {print "ok 8\n";} else {print "not ok 8\n";}
48 if (&foo5(0) eq '0') {print "ok 9\n";} else {print "not ok 9\n";}
49 if (&foo5(1) eq 'true2') {print "ok 10\n";} else {print "not ok 10\n";}
50 if (&foo6(0) eq 'true2') {print "ok 11\n";} else {print "not ok 11\n";}
51 if (&foo6(1) eq '1') {print "ok 12\n";} else {print "not ok 12 $x\n";}
53 # Now test to see that recursion works using a Fibonacci number generator
63 $foo = &fib($arg-1) + &fib($arg-2);
69 @good = (0,1,1,2,3,5,8,13,21,34,55,89);
71 for ($i = 1; $i <= 10; $i++) {
73 if (&fib($i) == $good[$i]) {
77 print "not ok $foo\n";
85 print &ary1 eq 3 ? "ok 23\n" : "not ok 23\n";
87 print join(':',&ary1) eq '1:2:3' ? "ok 24\n" : "not ok 24\n";
97 print &ary2 eq 3 ? "ok 25\n" : "not ok 25\n";
100 print $x eq '1:2:3' ? "ok 26\n" : "not ok 26 $x\n";
103 local($num,$P,$F,$L) = @_;
105 print "$p:$f:$l" eq "$P:$F:$L" ? "ok $num\n" : "not ok $num $p:$f:$l ne $P:$F:$L\n";
108 &somesub(27, 'main', __FILE__, __LINE__);
111 &main'somesub(28, 'foo', __FILE__, __LINE__);
115 open(FOO,">Cmd_subval.tmp");
116 print FOO "blah blah\n";
117 close FOO or die "Can't close Cmd_subval.tmp: $!";
120 close F or die "Can't close: $!";
124 close F or die "Can't close: $!";
127 unlink 'Cmd_subval.tmp';
132 open(F, 'Cmd_subval.tmp') || die "can't open: $!\n";
134 eof F ? print "not ok $i\n" : print "ok $i\n";
140 open(F, 'Cmd_subval.tmp') || die "test: can't open: $!\n";
142 eof F ? print "not ok $i\n" : print "ok $i\n";
144 close F or die "Can't close: $!";
151 eof UNIQ ? print "(not ok $i)\n" : print "ok $i\n";
156 sub main'file_package {
159 open(F, 'Cmd_subval.tmp') || die "can't open: $!\n";
161 eof F ? print "not ok $main'i\n" : print "ok $main'i\n";
164 sub main'info_package {
167 open(F, 'Cmd_subval.tmp') || die "can't open: $!\n";
169 eof F ? print "not ok $main'i\n" : print "ok $main'i\n";
177 eof UNIQ ? print "not ok $main'i\n" : print "ok $main'i\n";
181 sub autov { $_[0] = 23 };
184 print keys %$href ? 'not ' : '', "ok 35\n";
186 print join(':', %$href) eq 'b:23' ? '' : 'not ', "ok 36\n";