py/parse: Fix handling of empty input so it raises an exception.

This commit is contained in:
Damien George
2015-07-24 15:05:56 +00:00
parent fa7c61dfab
commit 96f0dd3cbc
3 changed files with 30 additions and 1 deletions

24
tests/basics/parser.py Normal file
View File

@@ -0,0 +1,24 @@
# parser tests
# completely empty string
# uPy and CPy differ for this case
#try:
# compile("", "stdin", "single")
#except SyntaxError:
# print("SyntaxError")
try:
compile("", "stdin", "eval")
except SyntaxError:
print("SyntaxError")
compile("", "stdin", "exec")
# empty continued line
try:
compile("\\\n", "stdin", "single")
except SyntaxError:
print("SyntaxError")
try:
compile("\\\n", "stdin", "eval")
except SyntaxError:
print("SyntaxError")
compile("\\\n", "stdin", "exec")