summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2000-06-20 19:13:27 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2000-06-20 19:13:27 (GMT)
commit3c0d013db40bd704908d7067228d35ed3f6b46c5 (patch)
tree932a7ddacbcb0b45bba5b24e5ac5a1a137c83901 /Lib/test
parent94988067b96c6187fd940eaff99c2c5a68daac68 (diff)
downloadcpython-3c0d013db40bd704908d7067228d35ed3f6b46c5.zip
cpython-3c0d013db40bd704908d7067228d35ed3f6b46c5.tar.gz
cpython-3c0d013db40bd704908d7067228d35ed3f6b46c5.tar.bz2
verify that Python raises SyntaxError for long and deeply-nested expressions
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/output/test_longexp2
-rw-r--r--Lib/test/test_longexp.py18
2 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/output/test_longexp b/Lib/test/output/test_longexp
new file mode 100644
index 0000000..73a101d
--- /dev/null
+++ b/Lib/test/output/test_longexp
@@ -0,0 +1,2 @@
+test_longexp
+Caught SyntaxError for long expression: expression too long
diff --git a/Lib/test/test_longexp.py b/Lib/test/test_longexp.py
new file mode 100644
index 0000000..38eb79b
--- /dev/null
+++ b/Lib/test/test_longexp.py
@@ -0,0 +1,18 @@
+REPS = 8192
+
+try:
+ eval("2+2+" * REPS + "+3.14159265")
+except SyntaxError, msg:
+ print "Caught SyntaxError for long expression:", msg
+else:
+ print "Long expression did not raise SyntaxError"
+
+## This test prints "s_push: parser stack overflow" on stderr,
+ ## which seems to confuse the test harness
+##try:
+## eval("(2+" * REPS + "0" + ")" * REPS)
+##except SyntaxError:
+## pass
+##else:
+## print "Deeply nested expression did not raised SyntaxError"
+