Adding in better tests & a fix.
This commit is contained in:
parent
d9b6fe7d79
commit
457d84e3f7
@ -19,7 +19,7 @@ class State(object):
|
||||
self.sub_machine.process(x)
|
||||
idle = type(self.sub_machine.state) == Idle
|
||||
if idle:
|
||||
self.nodes.append(self.sub_machine.nodes)
|
||||
self.nodes += self.sub_machine.nodes
|
||||
self.sub_machine = None
|
||||
return
|
||||
|
||||
|
@ -2,10 +2,14 @@ from hy.lex.tokenize import tokenize
|
||||
|
||||
|
||||
def test_simple_tokenize():
|
||||
"""Checking we can still handle something simple."""
|
||||
|
||||
assert [["+", "1", "1"]] == tokenize("(+ 1 1)")
|
||||
|
||||
|
||||
def test_double_tokenize():
|
||||
"""Checking if we can lex two things at once."""
|
||||
|
||||
assert [
|
||||
["+", "1", "2"],
|
||||
["-", "1", "1"]
|
||||
@ -13,8 +17,44 @@ def test_double_tokenize():
|
||||
|
||||
|
||||
def test_simple_recurse():
|
||||
""" Test recursion """
|
||||
assert [
|
||||
'+', '1', [
|
||||
'+', '1', '1'
|
||||
['fn',
|
||||
'one',
|
||||
['fn', 'two'],
|
||||
]
|
||||
] == tokenize("(+ 1 (+ 1 1))")
|
||||
] == tokenize("(fn one (fn two))")
|
||||
|
||||
|
||||
def test_mid_recurse():
|
||||
""" Test some crazy recursion """
|
||||
|
||||
assert [
|
||||
['fn',
|
||||
'one',
|
||||
['fn', 'two'],
|
||||
['fn', 'three'],
|
||||
]
|
||||
] == tokenize("(fn one (fn two)(fn three))")
|
||||
|
||||
|
||||
def test_full_recurse():
|
||||
""" Test something we could see for real """
|
||||
assert [
|
||||
['fn',
|
||||
'el',
|
||||
['+',
|
||||
'1',
|
||||
'2',
|
||||
['==',
|
||||
'1',
|
||||
'20'
|
||||
],
|
||||
['-',
|
||||
'1',
|
||||
'1'
|
||||
],
|
||||
]
|
||||
],
|
||||
['fn1', 'foo', 'bar']
|
||||
] == tokenize("(fn el (+ 1 2 (== 1 20) (- 1 1)))(fn1 foo bar)")
|
||||
|
Loading…
Reference in New Issue
Block a user