Add record declaration indentation
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Bruno BELANYI 2022-06-13 11:24:47 +02:00
parent 964c9a685d
commit 7927a8cde7
3 changed files with 26 additions and 12 deletions

View file

@ -54,6 +54,10 @@
"}" @branch "}" @branch
(record_expression "}" @indent_end) (record_expression "}" @indent_end)
(record_type) @indent
"}" @branch
(record_type "}" @indent_end)
(variable_declaration) @indent (variable_declaration) @indent
; }}} ; }}}

View file

@ -1,6 +1,12 @@
let let
type array_of_int = array of int type array_of_int = array of int
type record = {
a: int,
b: string,
c: type
}
var a := var a :=
"a string" "a string"
in in

View file

@ -66,17 +66,21 @@ describe("indent Tiger:", function()
runner:new_line("groupings.tig", { on_line = 8, text = "a := a + 1;", indent = 2 }, "after sequence") runner:new_line("groupings.tig", { on_line = 8, text = "a := a + 1;", indent = 2 }, "after sequence")
runner:new_line("groupings.tig", { on_line = 10, text = "+ 1", indent = 0 }, "after 'end'") runner:new_line("groupings.tig", { on_line = 10, text = "+ 1", indent = 0 }, "after 'end'")
runner:new_line("values-and-expressions.tig", { on_line = 4, text = "0", indent = 4 }, "variable declaration init value", XFAIL) runner:new_line("values-and-expressions.tig", { on_line = 4, text = "field: record,", indent = 4 }, "record type beginning", XFAIL)
runner:new_line("values-and-expressions.tig", { on_line = 5, text = "+ a", indent = 4 }, "variable declaration init follow-up") runner:new_line("values-and-expressions.tig", { on_line = 5, text = "field: record,", indent = 4 }, "record type middle")
runner:new_line("values-and-expressions.tig", { on_line = 7, text = "a", indent = 4 }, "array index", XFAIL) runner:new_line("values-and-expressions.tig", { on_line = 7, text = ",field: record", indent = 4 }, "record type end")
runner:new_line("values-and-expressions.tig", { on_line = 8, text = "+ a", indent = 4 }, "array index follow-up") runner:new_line("values-and-expressions.tig", { on_line = 8, text = "var a := 0", indent = 2 }, "after record type")
runner:new_line("values-and-expressions.tig", { on_line = 9, text = "+ a", indent = 2 }, "after array value") runner:new_line("values-and-expressions.tig", { on_line = 10, text = "0", indent = 4 }, "variable declaration init value", XFAIL)
runner:new_line("values-and-expressions.tig", { on_line = 12, text = "a", indent = 4 }, "array expression size", XFAIL) runner:new_line("values-and-expressions.tig", { on_line = 11, text = "+ a", indent = 4 }, "variable declaration init follow-up")
runner:new_line("values-and-expressions.tig", { on_line = 14, text = "of", indent = 2 }, "array expression after size") runner:new_line("values-and-expressions.tig", { on_line = 13, text = "a", indent = 4 }, "array index", XFAIL)
runner:new_line("values-and-expressions.tig", { on_line = 15, text = "a", indent = 4 }, "array expression init value", XFAIL) runner:new_line("values-and-expressions.tig", { on_line = 14, text = "+ a", indent = 4 }, "array index follow-up")
runner:new_line("values-and-expressions.tig", { on_line = 19, text = "field = 0,", indent = 4 }, "record expression beginning", XFAIL) runner:new_line("values-and-expressions.tig", { on_line = 15, text = "+ a", indent = 2 }, "after array value")
runner:new_line("values-and-expressions.tig", { on_line = 20, text = "field = 0,", indent = 4 }, "record expression middle") runner:new_line("values-and-expressions.tig", { on_line = 18, text = "a", indent = 4 }, "array expression size", XFAIL)
runner:new_line("values-and-expressions.tig", { on_line = 22, text = ",field = 0", indent = 4 }, "record expression end") runner:new_line("values-and-expressions.tig", { on_line = 20, text = "of", indent = 2 }, "array expression after size")
runner:new_line("values-and-expressions.tig", { on_line = 23, text = "a := 0", indent = 2 }, "after record expression") runner:new_line("values-and-expressions.tig", { on_line = 21, text = "a", indent = 4 }, "array expression init value", XFAIL)
runner:new_line("values-and-expressions.tig", { on_line = 25, text = "field = 0,", indent = 4 }, "record expression beginning", XFAIL)
runner:new_line("values-and-expressions.tig", { on_line = 26, text = "field = 0,", indent = 4 }, "record expression middle")
runner:new_line("values-and-expressions.tig", { on_line = 28, text = ",field = 0", indent = 4 }, "record expression end")
runner:new_line("values-and-expressions.tig", { on_line = 29, text = "a := 0", indent = 2 }, "after record expression")
end) end)
end) end)