tests: Add tests to exercise lexer; and some more complex number tests.
This commit is contained in:
@@ -4,9 +4,28 @@ def test_syntax(code):
|
||||
try:
|
||||
exec(code)
|
||||
print("no SyntaxError")
|
||||
except IndentationError:
|
||||
print("IndentationError")
|
||||
except SyntaxError:
|
||||
print("SyntaxError")
|
||||
|
||||
# non-newline after line-continuation character (lexer error)
|
||||
test_syntax("a \\a\n")
|
||||
|
||||
# dedent mismatch (lexer error)
|
||||
test_syntax("def f():\n a\n a\n")
|
||||
|
||||
# unclosed string (lexer error)
|
||||
test_syntax("'abc")
|
||||
|
||||
# invalid (lexer error)
|
||||
test_syntax("!")
|
||||
test_syntax("$")
|
||||
test_syntax("`")
|
||||
|
||||
# bad indentation (lexer error)
|
||||
test_syntax(" a\n")
|
||||
|
||||
# can't assign to literals
|
||||
test_syntax("1 = 2")
|
||||
test_syntax("'' = 1")
|
||||
|
||||
Reference in New Issue
Block a user