hy/tests/lang/test_expression.py

35 lines
688 B
Python
Raw Normal View History

2012-12-15 23:39:10 +01:00
from hy.lex.tokenize import tokenize
from hy.lang.expression import HYExpression
code = """
(+ 1 1) ; this is a test.
(fn foo bar) ; this is a test.
"""
2012-12-15 23:47:05 +01:00
def test_basics():
"""Test the basics"""
assert {
"function": "fn",
"args": [
"one"
]
} == HYExpression(["fn", "one"]).get_invocation()
2012-12-15 23:39:10 +01:00
def test_fn_split():
"""Test if we can get a statement something right."""
one, two = tokenize(code)
assert one.get_invocation() == {
"function": "+",
"args": [
2012-12-17 03:44:14 +01:00
1, 1
2012-12-15 23:39:10 +01:00
]
}
assert two.get_invocation() == {
"function": "fn",
"args": [
"foo", "bar"
]
}