Skip to content

Commit 3b564d4

Browse files
committed
added spaces in concat output, added numeric concat test
1 parent 1f8a419 commit 3b564d4

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

luaparser/printers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def visit(self, node: OrLoOp) -> str:
539539

540540
@visit.register
541541
def visit(self, node: Concat) -> str:
542-
return self.do_visit(node.left) + ".." + self.do_visit(node.right)
542+
return self.do_visit(node.left) + " .. " + self.do_visit(node.right)
543543

544544
@visit.register
545545
def visit(self, node: UMinusOp) -> str:

luaparser/tests/test_expressions.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ def test_logic_not(self):
359359
""" 3.4.6 – Concatenation """
360360
""" ----------------------------------------------------------------------- """
361361

362-
def test_concatenation(self):
363-
tree = ast.parse(r'str = "begin".."end"')
362+
def test_string_concatenation(self):
363+
tree = ast.parse(r'str = "begin" .. "end"')
364364
exp = Chunk(
365365
Block(
366366
[
@@ -378,6 +378,25 @@ def test_concatenation(self):
378378
)
379379
self.assertEqual(exp, tree)
380380

381+
def test_number_concatenation(self):
382+
tree = ast.parse(r'str = 1 .. 2')
383+
exp = Chunk(
384+
Block(
385+
[
386+
Assign(
387+
targets=[Name("str")],
388+
values=[
389+
Concat(
390+
left=Number(1),
391+
right=Number(2),
392+
)
393+
],
394+
)
395+
]
396+
)
397+
)
398+
self.assertEqual(exp, tree)
399+
381400
""" ----------------------------------------------------------------------- """
382401
""" 3.4.7 – The Length Operator """
383402
""" ----------------------------------------------------------------------- """

0 commit comments

Comments
 (0)