test coverage bits

This commit is contained in:
Paul R. Tagliamonte 2013-04-01 22:07:05 -04:00
parent 397db464a5
commit c4b270a727
3 changed files with 26 additions and 4 deletions

View File

@ -233,7 +233,11 @@ class String(State):
if char == "n": if char == "n":
self.nodes.append("\n") self.nodes.append("\n")
return return
raise LexException("Unknown modifier") if char == "\\":
self.nodes.append("\\")
return
raise LexException("Unknown modifier: `%s'" % (char))
if char == "\"": if char == "\"":
return Idle return Idle

View File

@ -89,15 +89,15 @@ def test_ast_non_kwapplyable():
def test_ast_print(): def test_ast_print():
""" Ensure print doesn't suck. """
code = hy_compile(tokenize("(print \"foo\")")).body[0] code = hy_compile(tokenize("(print \"foo\")")).body[0]
if sys.version_info[0] >= 3: if sys.version_info[0] >= 3:
assert type(code.value) == ast.Call assert type(code.value) == ast.Call
return return
assert type(code) == ast.Print assert type(code) == ast.Print
def test_ast_print(): def test_ast_tuple():
""" Ensure print doesn't suck. """ """ Ensure tuples work. """
code = hy_compile(tokenize("(, 1 2 3)")).body[0].value code = hy_compile(tokenize("(, 1 2 3)")).body[0].value
assert type(code) == ast.Tuple assert type(code) == ast.Tuple

View File

@ -148,3 +148,21 @@ def test_nospace():
assert entry.end_line == 1 assert entry.end_line == 1
assert entry.end_column == 13 assert entry.end_column == 13
def test_escapes():
""" Ensure we can escape things """
entry = tokenize("(foo \"foo\\n\")")[0]
assert entry[1] == "foo\n"
try:
entry = tokenize("(foo \"foo\s\")")[0]
assert True is False
except LexException:
pass
def test_hashbang():
""" Ensure we can escape things """
entry = tokenize("#!this is a comment\n")
assert entry == []