diff --git a/test/indent/functions.tig b/test/indent/functions.tig new file mode 100644 index 0000000..22ce051 --- /dev/null +++ b/test/indent/functions.tig @@ -0,0 +1,14 @@ +primitive long_parameter_list( + a: int, + b: string, + c: type +) + +function f() = + ( + long_parameter_list( + 1, + "2", + nil + ) + ) diff --git a/test/indent_spec.lua b/test/indent_spec.lua index 57f69a5..0edc991 100644 --- a/test/indent_spec.lua +++ b/test/indent_spec.lua @@ -49,6 +49,17 @@ describe("indent Tiger:", function() runner:new_line("control-flow.tig", { on_line = 18, text = "true", indent = 4 }, "while condition", XFAIL) runner:new_line("control-flow.tig", { on_line = 20, text = "break", indent = 4 }, "while body", XFAIL) + runner:new_line("functions.tig", { on_line = 1, text = "parameter: int,", indent = 2 }, "parameter list beginning", XFAIL) + runner:new_line("functions.tig", { on_line = 2, text = "parameter: int,", indent = 2 }, "parameter list middle") + runner:new_line("functions.tig", { on_line = 4, text = ",parameter: int", indent = 2 }, "parameter list end") + runner:new_line("functions.tig", { on_line = 5, text = "var a := 0", indent = 0 }, "after parameter list") + runner:new_line("functions.tig", { on_line = 7, text = "print(a)", indent = 2 }, "function body", XFAIL) + runner:new_line("functions.tig", { on_line = 9, text = "a,", indent = 6 }, "function call beginning", XFAIL) + runner:new_line("functions.tig", { on_line = 10, text = "a,", indent = 6 }, "function call middle") + runner:new_line("functions.tig", { on_line = 12, text = ",a", indent = 6 }, "function call end") + runner:new_line("functions.tig", { on_line = 13, text = "; print(a)", indent = 4 }, "after function call") + runner:new_line("functions.tig", { on_line = 14, text = "var a := 12", indent = 0 }, "after function declaration", XFAIL) + runner:new_line("groupings.tig", { on_line = 2, text = "var b := 0", indent = 2 }, "let declarations") runner:new_line("groupings.tig", { on_line = 3, text = "a := a + 1", indent = 2 }, "after 'in'", XFAIL) runner:new_line("groupings.tig", { on_line = 4, text = "a := a + 1;", indent = 4 }, "sequence", XFAIL)