3 # $RCSfile: eval.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:48 $
7 eval 'print "ok 1\n";';
9 if ($@ eq '') {print "ok 2\n";} else {print "not ok 2\n";}
11 eval "\$foo\n = # this is a comment\n'ok 3';";
14 eval "\$foo\n = # this is a comment\n'ok 4\n';";
18 $foo =;'; # this tests for a call through yyerror()
19 if ($@ =~ /line 2/) {print "ok 5\n";} else {print "not ok 5\n";}
21 print eval '$foo = /'; # this tests for a call through fatal()
22 if ($@ =~ /Search/) {print "ok 6\n";} else {print "not ok 6\n";}
24 print eval '"ok 7\n";';
26 # calculate a factorial with recursive evals
29 $fact = 'if ($foo <= 1) {1;} else {push(@x,$foo--); (eval $fact) * pop(@x);}';
31 if ($ans == 120) {print "ok 8\n";} else {print "not ok 8\n";}
34 $fact = 'local($foo)=$foo; $foo <= 1 ? 1 : $foo-- * (eval $fact);';
36 if ($ans == 120) {print "ok 9\n";} else {print "not ok 9 $ans\n";}
39 print try 'print "ok 10\n"; unlink "Op.eval";',"\n";
42 do 'Op.eval'; print $@;
44 # Test the singlequoted eval optimizer
48 eval 'print "ok ", $i++, "\n"';
55 } || print "ok 15\n$@";