Add test for the optional record field separator
@@ -643,8 +643,8 @@ describe("Titan parser", function()
assert_program_ast([[
record List
- p: {Point};
- next: List;
+ p: {Point}
+ next: List
end
]], {
{ _tag = "TopLevel_Record",
@@ -656,6 +656,26 @@ describe("Titan parser", function()
})
end)
+ it("can parse the record field optional separator", function()
+ local ast = {{ fields = { { name = "x" }, { name = "y" } } }}
+
+ assert_program_ast([[
+ record Point x: float y: float end
+ ]], ast)
+
+ assert_program_ast([[
+ record Point x: float; y: float end
+ ]], ast)
+
+ assert_program_ast([[
+ record Point x: float y: float; end
+ ]], ast)
+
+ assert_program_ast([[
+ record Point x: float; y: float; end
+ ]], ast)
+ end)
+
it("can parse record constructors", function()
assert_expression_ast([[ { x = 1.1, y = 2.2 } ]],
{ _tag = "Exp_InitList", fields = {
