perl 2.0 (no announcement message available)
[p5sagit/p5-mst-13.2.git] / t / op.eval
CommitLineData
a559c259 1#!./perl
2
378cc40b 3# $Header: op.eval,v 2.0 88/06/05 00:13:40 root Exp $
4
5print "1..10\n";
a559c259 6
7eval 'print "ok 1\n";';
8
9if ($@ eq '') {print "ok 2\n";} else {print "not ok 2\n";}
10
11eval "\$foo\n = # this is a comment\n'ok 3';";
12print $foo,"\n";
13
14eval "\$foo\n = # this is a comment\n'ok 4\n';";
15print $foo;
16
378cc40b 17print eval '
a559c259 18$foo ='; # this tests for a call through yyerror()
19if ($@ =~ /line 2/) {print "ok 5\n";} else {print "not ok 5\n";}
20
378cc40b 21print eval '$foo = /'; # this tests for a call through fatal()
a559c259 22if ($@ =~ /Search/) {print "ok 6\n";} else {print "not ok 6\n";}
378cc40b 23
24print eval '"ok 7\n";';
25
26# calculate a factorial with recursive evals
27
28$foo = 5;
29$fact = 'if ($foo <= 1) {1;} else {push(@x,$foo--); (eval $fact) * pop(@x);}';
30$ans = eval $fact;
31if ($ans == 120) {print "ok 8\n";} else {print "not ok 8\n";}
32
33$foo = 5;
34$fact = 'local($foo); $foo <= 1 ? 1 : $foo-- * (eval $fact);';
35$ans = eval $fact;
36if ($ans == 120) {print "ok 9\n";} else {print "not ok 9 $ans\n";}
37
38open(try,'>Op.eval');
39print try 'print "ok 10\n"; unlink "Op.eval";',"\n";
40close try;
41
42do 'Op.eval'; print $@;