home *** CD-ROM | disk | FTP | other *** search
- #!./perl
-
- # $Header: op.eval,v 3.0 89/10/18 15:28:53 lwall Locked $
-
- print "1..10\n";
-
- eval 'print "ok 1\n";';
-
- if ($@ eq '') {print "ok 2\n";} else {print "not ok 2\n";}
-
- eval "\$foo\n = # this is a comment\n'ok 3';";
- print $foo,"\n";
-
- eval "\$foo\n = # this is a comment\n'ok 4\n';";
- print $foo;
-
- print eval '
- $foo ='; # this tests for a call through yyerror()
- if ($@ =~ /line 2/) {print "ok 5\n";} else {print "not ok 5\n";}
-
- 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; $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,'>Tmp.Eval');
- print try 'print "ok 10\n"; unlink "Tmp.Eval";',"\n";
- close try;
-
- do 'Tmp.Eval'; print $@;
-