adding in test for more stuff.
This commit is contained in:
parent
457d84e3f7
commit
8f20829b08
@ -1,3 +1,12 @@
|
||||
class HYExpression(list):
|
||||
def __init__(self, nodes):
|
||||
self += nodes
|
||||
|
||||
def get_invocation(self):
|
||||
fn = self[0] if len(self) > 0 else ""
|
||||
args = self[1:] if len(self) > 1 else []
|
||||
|
||||
return {
|
||||
"function": fn,
|
||||
"args": args
|
||||
}
|
||||
|
0
tests/lang/__init__.py
Normal file
0
tests/lang/__init__.py
Normal file
24
tests/lang/test_expression.py
Normal file
24
tests/lang/test_expression.py
Normal file
@ -0,0 +1,24 @@
|
||||
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.
|
||||
"""
|
||||
|
||||
|
||||
def test_fn_split():
|
||||
"""Test if we can get a statement something right."""
|
||||
one, two = tokenize(code)
|
||||
assert one.get_invocation() == {
|
||||
"function": "+",
|
||||
"args": [
|
||||
"1", "1"
|
||||
]
|
||||
}
|
||||
assert two.get_invocation() == {
|
||||
"function": "fn",
|
||||
"args": [
|
||||
"foo", "bar"
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user