diff --git a/tests/test_lex.py b/tests/test_lex.py index 976ea3b..ba8dd36 100644 --- a/tests/test_lex.py +++ b/tests/test_lex.py @@ -3,25 +3,40 @@ from hy.models.integer import HyInteger from hy.models.symbol import HySymbol from hy.models.string import HyString +from hy.lex.states import LexException + from hy.lex import tokenize +def test_lex_exception(): + """ Ensure tokenize throws a fit on a partial input """ + try: + objs = tokenize("(foo") + assert True == False + except LexException: + pass + + def test_lex_expression_symbols(): + """ Make sure that expressions produce symbols """ objs = tokenize("(foo bar)") assert objs == [HyExpression([HySymbol("foo"), HySymbol("bar")])] def test_lex_expression_strings(): + """ Test that expressions can produce symbols """ objs = tokenize("(foo \"bar\")") assert objs == [HyExpression([HySymbol("foo"), HyString("bar")])] def test_lex_expression_integer(): + """ Make sure expressions can produce integers """ objs = tokenize("(foo 2)") assert objs == [HyExpression([HySymbol("foo"), HyInteger(2)])] def test_lex_line_counting(): + """ Make sure we can count lines / columns """ entry = tokenize("(foo 2)")[0] assert entry.start_line == 1