From 3b2796d9ad7bbe181d856bbb391f2c5da20c7d3c Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 13 Jun 2022 10:33:49 +0200 Subject: [PATCH] Add class indent tests --- test/indent/classes.tig | 14 ++++++++++++++ test/indent_spec.lua | 10 ++++++++++ 2 files changed, 24 insertions(+) create mode 100644 test/indent/classes.tig diff --git a/test/indent/classes.tig b/test/indent/classes.tig new file mode 100644 index 0000000..542a40e --- /dev/null +++ b/test/indent/classes.tig @@ -0,0 +1,14 @@ +class A { + var a := 12 + + method method() : int = 1 +} + +type B = class extends A { + var b := 27 + + method another_method() = ( + print("called"); + self.b + self.method() + ) +} diff --git a/test/indent_spec.lua b/test/indent_spec.lua index f414d60..d158bdf 100644 --- a/test/indent_spec.lua +++ b/test/indent_spec.lua @@ -30,6 +30,16 @@ describe("indent Tiger:", function() end) describe("new line:", function() + runner:new_line("classes.tig", { on_line = 1, text = "var a := 0", indent = 2 }, "class declaration beginning", XFAIL) + runner:new_line("classes.tig", { on_line = 2, text = "var a := 0", indent = 2 }, "class declaration after field") + runner:new_line("classes.tig", { on_line = 4, text = "var a := 0", indent = 2 }, "class declaration after method") + runner:new_line("classes.tig", { on_line = 5, text = "var a := 0", indent = 0 }, "after class declaration") + runner:new_line("classes.tig", { on_line = 7, text = "var a := 0", indent = 2 }, "class type beginning", XFAIL) + runner:new_line("classes.tig", { on_line = 8, text = "var a := 0", indent = 2 }, "class type after field") + runner:new_line("classes.tig", { on_line = 10, text = "self.a := 0", indent = 4 }, "inside method", XFAIL) + 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("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)