Permalink
Browse files

test coverage bits

  • Loading branch information...
1 parent 397db46 commit c4b270a7279d2d939618642f2d2cf08e715a3a81 @paultag committed Apr 2, 2013
Showing with 26 additions and 4 deletions.
  1. +5 −1 hy/lex/states.py
  2. +3 −3 tests/compilers/test_ast.py
  3. +18 −0 tests/lex/test_lex.py
View
6 hy/lex/states.py
@@ -233,7 +233,11 @@ def process(self, char):
if char == "n":
self.nodes.append("\n")
return
- raise LexException("Unknown modifier")
+ if char == "\\":
+ self.nodes.append("\\")
+ return
+
+ raise LexException("Unknown modifier: `%s'" % (char))
if char == "\"":
return Idle
View
6 tests/compilers/test_ast.py
@@ -89,15 +89,15 @@ def test_ast_non_kwapplyable():
def test_ast_print():
- """ Ensure print doesn't suck. """
code = hy_compile(tokenize("(print \"foo\")")).body[0]
+
if sys.version_info[0] >= 3:
assert type(code.value) == ast.Call
return
assert type(code) == ast.Print
-def test_ast_print():
- """ Ensure print doesn't suck. """
+def test_ast_tuple():
+ """ Ensure tuples work. """
code = hy_compile(tokenize("(, 1 2 3)")).body[0].value
assert type(code) == ast.Tuple
View
18 tests/lex/test_lex.py
@@ -148,3 +148,21 @@ def test_nospace():
assert entry.end_line == 1
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 == []

0 comments on commit c4b270a

Please sign in to comment.