summaryrefslogtreecommitdiff
path: root/t/op.eval
diff options
context:
space:
mode:
Diffstat (limited to 't/op.eval')
-rw-r--r--t/op.eval28
1 files changed, 25 insertions, 3 deletions
diff --git a/t/op.eval b/t/op.eval
index 191571015c..2456181ff2 100644
--- a/t/op.eval
+++ b/t/op.eval
@@ -1,6 +1,8 @@
#!./perl
-print "1..6\n";
+# $Header: op.eval,v 2.0 88/06/05 00:13:40 root Exp $
+
+print "1..10\n";
eval 'print "ok 1\n";';
@@ -12,9 +14,29 @@ print $foo,"\n";
eval "\$foo\n = # this is a comment\n'ok 4\n';";
print $foo;
-eval '
+print eval '
$foo ='; # this tests for a call through yyerror()
if ($@ =~ /line 2/) {print "ok 5\n";} else {print "not ok 5\n";}
-eval '$foo = /'; # this tests for a call through fatal()
+print eval '$foo = /'; # this tests for a call through fatal()
if ($@ =~ /Search/) {print "ok 6\n";} else {print "not ok 6\n";}
+
+print eval '"ok 7\n";';
+
+# calculate a factorial with recursive evals
+
+$foo = 5;
+$fact = 'if ($foo <= 1) {1;} else {push(@x,$foo--); (eval $fact) * pop(@x);}';
+$ans = eval $fact;
+if ($ans == 120) {print "ok 8\n";} else {print "not ok 8\n";}
+
+$foo = 5;
+$fact = 'local($foo); $foo <= 1 ? 1 : $foo-- * (eval $fact);';
+$ans = eval $fact;
+if ($ans == 120) {print "ok 9\n";} else {print "not ok 9 $ans\n";}
+
+open(try,'>Op.eval');
+print try 'print "ok 10\n"; unlink "Op.eval";',"\n";
+close try;
+
+do 'Op.eval'; print $@;