Skip to content

Commit

Permalink
Add a test for failure to parse chained comparisons, fix #56
Browse files Browse the repository at this point in the history
  • Loading branch information
boolangery committed Oct 27, 2024
1 parent 228449c commit c451b46
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions luaparser/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,13 @@ def test_cont_int_5(self):
tree = ast.parse(
textwrap.dedent(
"""
function table.pack(...)
repeat
print("value of a:", a)
a = a + 1;
until( a > 15 )
end
"""
function table.pack(...)
repeat
print("value of a:", a)
a = a + 1;
until( a > 15 )
end
"""
)
)
nodes = ast.walk(tree)
Expand Down Expand Up @@ -291,4 +291,24 @@ def test_cont_int_7(self):
# Brackets are absent in output of AST->source_code conversion #57
def test_cont_int_8(self):
source = r"result = (a + b) / (c + d)"
self.assertEqual(source, ast.to_lua_source(ast.parse(source)))
self.assertEqual(source, ast.to_lua_source(ast.parse(source)))

# Failure to parse chained comparisons #56
def test_cont_int_9(self):
tree = ast.parse(textwrap.dedent("""
if false == false == false then
x = 2
end
"""))
exp = Chunk(
Block([
If(
test=EqToOp(left=EqToOp(left=FalseExpr(), right=FalseExpr()), right=FalseExpr()),
body=Block([
Assign([Name("x")], [Number(2)])
]),
orelse=None,
)
])
)
self.assertEqual(exp, tree)

0 comments on commit c451b46

Please sign in to comment.