2013-03-01 04:37:23 +01:00
|
|
|
from hy.models.expression import HyExpression
|
2013-03-03 01:28:10 +01:00
|
|
|
from hy.models.integer import HyInteger
|
2013-03-01 04:37:23 +01:00
|
|
|
from hy.models.symbol import HySymbol
|
2013-03-03 00:40:00 +01:00
|
|
|
from hy.models.string import HyString
|
2013-03-01 04:27:20 +01:00
|
|
|
|
2013-03-03 01:28:10 +01:00
|
|
|
from hy.lex import tokenize
|
|
|
|
|
2013-03-01 04:27:20 +01:00
|
|
|
|
2013-03-03 00:40:00 +01:00
|
|
|
def test_lex_expression_symbols():
|
2013-03-01 04:27:20 +01:00
|
|
|
objs = tokenize("(foo bar)")
|
2013-03-01 04:37:23 +01:00
|
|
|
assert objs == [HyExpression([HySymbol("foo"), HySymbol("bar")])]
|
2013-03-03 00:40:00 +01:00
|
|
|
|
2013-03-03 01:41:55 +01:00
|
|
|
|
2013-03-03 00:40:00 +01:00
|
|
|
def test_lex_expression_strings():
|
|
|
|
objs = tokenize("(foo \"bar\")")
|
|
|
|
assert objs == [HyExpression([HySymbol("foo"), HyString("bar")])]
|
2013-03-03 01:28:10 +01:00
|
|
|
|
2013-03-03 01:41:55 +01:00
|
|
|
|
2013-03-03 01:28:10 +01:00
|
|
|
def test_lex_expression_integer():
|
|
|
|
objs = tokenize("(foo 2)")
|
|
|
|
assert objs == [HyExpression([HySymbol("foo"), HyInteger(2)])]
|
2013-03-03 01:41:55 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_lex_line_counting():
|
|
|
|
objs = tokenize("(foo 2)")
|
|
|
|
entry = objs[0]
|
|
|
|
|
|
|
|
assert entry.start_line == 1
|
|
|
|
assert entry.start_column == 1
|
|
|
|
|
|
|
|
assert entry.end_line == 1
|
|
|
|
assert entry.end_column == 7
|