diff options
Diffstat (limited to 't/cmd.subval')
-rw-r--r-- | t/cmd.subval | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/t/cmd.subval b/t/cmd.subval index 490276ae05..e2dc47bbed 100644 --- a/t/cmd.subval +++ b/t/cmd.subval @@ -1,6 +1,6 @@ #!./perl -# $Header: cmd.subval,v 2.0 88/06/05 00:12:26 root Exp $ +# $Header: cmd.subval,v 3.0 89/10/18 15:24:52 lwall Locked $ sub foo1 { 'true1'; @@ -9,7 +9,8 @@ sub foo1 { sub foo2 { 'true1'; - if ($_[0]) { 'true2'; } else { 'true3'; } + if ($_[0]) { return 'true2'; } else { return 'true3'; } + 'true0'; } sub foo3 { @@ -32,22 +33,22 @@ sub foo6 { 'true2' unless $_[0]; } -print "1..22\n"; +print "1..26\n"; -if (do foo1(0) eq '') {print "ok 1\n";} else {print "not ok 1\n";} +if (do foo1(0) eq '0') {print "ok 1\n";} else {print "not ok 1 $foo\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 foo3(1) eq '1') {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(0) eq '0') {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";} +if (do foo6(1) eq '1') {print "ok 12\n";} else {print "not ok 12 $x\n";} # Now test to see that recursion works using a Fibonacci number generator @@ -76,3 +77,25 @@ for ($i = 1; $i <= 10; $i++) { print "not ok $foo\n"; } } + +sub ary1 { + (1,2,3); +} + +print &ary1 eq 3 ? "ok 23\n" : "not ok 23\n"; + +print join(':',&ary1) eq '1:2:3' ? "ok 24\n" : "not ok 24\n"; + +sub ary2 { + do { + return (1,2,3); + (3,2,1); + }; + 0; +} + +print &ary2 eq 3 ? "ok 25\n" : "not ok 25\n"; + +$x = join(':',&ary2); +print $x eq '1:2:3' ? "ok 26\n" : "not ok 26 $x\n"; + |