diff options
author | Larry Wall <lwall@netlabs.com> | 1991-03-21 00:00:00 +0000 |
---|---|---|
committer | Larry Wall <lwall@netlabs.com> | 1991-03-21 00:00:00 +0000 |
commit | fe14fcc35f78a371a174a1d14256c2f35ae4262b (patch) | |
tree | d472cb1055c47b9701cb0840969aacdbdbc9354a /t/op/eval.t | |
parent | 27e2fb84680b9cc1db17238d5bf10b97626f477f (diff) | |
download | perl-fe14fcc35f78a371a174a1d14256c2f35ae4262b.tar.gz |
perl 4.0.00: (no release announcement available)perl-4.0.00
So far, 4.0 is still a beta test version. For the last production
version, look in pub/perl.3.0/kits@44.
Diffstat (limited to 't/op/eval.t')
-rw-r--r-- | t/op/eval.t | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/t/op/eval.t b/t/op/eval.t new file mode 100644 index 0000000000..464162c0a3 --- /dev/null +++ b/t/op/eval.t @@ -0,0 +1,42 @@ +#!./perl + +# $Header: eval.t,v 4.0 91/03/20 01:52:20 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,'>Op.eval'); +print try 'print "ok 10\n"; unlink "Op.eval";',"\n"; +close try; + +do 'Op.eval'; print $@; |