Skip to content

Commit b44924f

Browse files
committed
Adding a few additional tests to the parser
1 parent 0be7da1 commit b44924f

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

test.lua

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,39 @@ e = [=[
11901190
r = parse(s)
11911191
assert(r == e)
11921192

1193+
s = [=[
1194+
local x = 0
1195+
local t = {x}
1196+
]=]
1197+
e = [=[
1198+
{ `Local{ { `Id "x" }, { `Number "0" } }, `Local{ { `Id "t" }, { `Table{ `Id "x" } } } }
1199+
]=]
1200+
1201+
r = parse(s)
1202+
assert(r == e)
1203+
1204+
s = [=[
1205+
local x = 0
1206+
local t = {x = 1}
1207+
]=]
1208+
e = [=[
1209+
{ `Local{ { `Id "x" }, { `Number "0" } }, `Local{ { `Id "t" }, { `Table{ `Pair{ `String "x", `Number "1" } } } } }
1210+
]=]
1211+
1212+
r = parse(s)
1213+
assert(r == e)
1214+
1215+
s = [=[
1216+
local x = 0
1217+
local t = {x == 1}
1218+
]=]
1219+
e = [=[
1220+
{ `Local{ { `Id "x" }, { `Number "0" } }, `Local{ { `Id "t" }, { `Table{ `Op{ "eq", `Id "x", `Number "1" } } } } }
1221+
]=]
1222+
1223+
r = parse(s)
1224+
assert(r == e)
1225+
11931226
-- vararg
11941227

11951228
s = [=[
@@ -1396,6 +1429,17 @@ test.lua:1:15: syntax error, unexpected token, invalid start of statement
13961429
r = parse(s)
13971430
assert(r == e)
13981431

1432+
s = [=[
1433+
local s = "1 + 1 = "
1434+
print(s .. 1+1)
1435+
]=]
1436+
e = [=[
1437+
{ `Local{ { `Id "s" }, { `String "1 + 1 = " } }, `Call{ `Id "print", `Op{ "concat", `Id "s", `Op{ "add", `Number "1", `Number "1" } } } }
1438+
]=]
1439+
1440+
r = parse(s)
1441+
assert(r == e)
1442+
13991443
-- for generic
14001444

14011445
s = [=[

0 commit comments

Comments
 (0)