From e3b70d88800a7e50e76e57db6556a2e8ea067057 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 13 Jun 2022 10:45:45 +0200 Subject: [PATCH] Add control flow indent tests --- test/indent/control-flow.tig | 22 ++++++++++++++++++++++ test/indent_spec.lua | 9 +++++++++ 2 files changed, 31 insertions(+) create mode 100644 test/indent/control-flow.tig diff --git a/test/indent/control-flow.tig b/test/indent/control-flow.tig new file mode 100644 index 0000000..abbadfa --- /dev/null +++ b/test/indent/control-flow.tig @@ -0,0 +1,22 @@ +( + if + 12 + then + 27 + else + 42 + ; + + for + i := 12 + to + 27 + do + 42 + ; + + while + 0 + do + break +) diff --git a/test/indent_spec.lua b/test/indent_spec.lua index d158bdf..57f69a5 100644 --- a/test/indent_spec.lua +++ b/test/indent_spec.lua @@ -40,6 +40,15 @@ describe("indent Tiger:", function() runner:new_line("classes.tig", { on_line = 13, text = "var a := 0", indent = 2 }, "class type after method") runner:new_line("classes.tig", { on_line = 14, text = "var a := 0", indent = 0 }, "after class type") + runner:new_line("control-flow.tig", { on_line = 2, text = "true", indent = 4 }, "if condition", XFAIL) + runner:new_line("control-flow.tig", { on_line = 4, text = "true", indent = 4 }, "if consequence", XFAIL) + runner:new_line("control-flow.tig", { on_line = 4, text = "true", indent = 4 }, "if alternative", XFAIL) + runner:new_line("control-flow.tig", { on_line = 10, text = "start := 0", indent = 4 }, "for index start", XFAIL) + runner:new_line("control-flow.tig", { on_line = 12, text = "the_end", indent = 4 }, "for index end", XFAIL) + runner:new_line("control-flow.tig", { on_line = 14, text = "break", indent = 4 }, "for body", XFAIL) + 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("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)