summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLarry Wall <lwall@jpl-devvax.jpl.nasa.gov>1988-01-27 22:18:25 +0000
committerLarry Wall <lwall@jpl-devvax.jpl.nasa.gov>1988-01-27 22:18:25 +0000
commita559c25918b1466cdb50c9f978a86f01be0bac10 (patch)
treeffbe6c7bc07144d291a61555d002e7969110f248 /t
parenta1cc2bdc08f9aa1504f32e5b0b782c2b3cffd124 (diff)
downloadperl-a559c25918b1466cdb50c9f978a86f01be0bac10.tar.gz
perl 1.0 patch 8: perl needed an eval operator and a symbolic debugger
I didn't add an eval operator to the original perl because I hadn't thought of any good uses for it. Recently I thought of some. Along with creating the eval operator, this patch introduces a symbolic debugger for perl scripts, which makes use of eval to interpret some debugging commands. Having eval also lets me emulate awk's FOO=bar command line behavior with a line such as the one a2p now inserts at the beginning of translated scripts.
Diffstat (limited to 't')
-rw-r--r--t/base.lex13
-rw-r--r--t/op.eval20
2 files changed, 31 insertions, 2 deletions
diff --git a/t/base.lex b/t/base.lex
index 2cfe311ed8..015f442c77 100644
--- a/t/base.lex
+++ b/t/base.lex
@@ -1,8 +1,8 @@
#!./perl
-# $Header: base.lex,v 1.0 87/12/18 13:11:51 root Exp $
+# $Header: base.lex,v 1.0.1.1 88/01/28 10:37:00 root Exp $
-print "1..4\n";
+print "1..6\n";
$ # this is the register <space>
= 'x';
@@ -21,3 +21,12 @@ if ($x eq '-1') {print "ok 3\n";} else {print "not ok 3\n";}
$x = '\\'; # ';
if (length($x) == 1) {print "ok 4\n";} else {print "not ok 4\n";}
+
+eval 'while (0) {
+ print "foo\n";
+}
+/^/ && (print "ok 5\n");
+';
+
+eval '$foo{1} / 1;';
+if (!$@) {print "ok 6\n";} else {print "not ok 6\n";}
diff --git a/t/op.eval b/t/op.eval
new file mode 100644
index 0000000000..191571015c
--- /dev/null
+++ b/t/op.eval
@@ -0,0 +1,20 @@
+#!./perl
+
+print "1..6\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;
+
+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()
+if ($@ =~ /Search/) {print "ok 6\n";} else {print "not ok 6\n";}