From 15c072cfe47346894d81c5a190ffb617897683a2 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Wed, 21 Apr 2021 13:58:42 -0400 Subject: [PATCH] condensed constant declaration tests --- cerise/parser.c | 102 ++++++++++++++++-------------------------------- 1 file changed, 34 insertions(+), 68 deletions(-) diff --git a/cerise/parser.c b/cerise/parser.c index a5a9f69..16609c4 100644 --- a/cerise/parser.c +++ b/cerise/parser.c @@ -536,82 +536,48 @@ TEST_SUITE(Grammar) { TEST(Should parse basic module syntax) { - parse_module("Empty", - "module Empty; end Empty;"); - parse_module("ModA", - "module ModA; import ModB; end ModA;"); + parse_module("Empty", "module Empty; end Empty;"); + parse_module("ModA", "module ModA; import ModB; end ModA;"); } TEST(Should parse imports) { - parse_rule(import_list, 0, - "import A;"); - parse_rule(import_list, 0, - "import A = ModA;"); - parse_rule(import_list, 0, - "import A, B;"); - parse_rule(import_list, 0, - "import A, B = ModB, C;"); + parse_rule(import_list, 0, "import A;"); + parse_rule(import_list, 0, "import A = ModA;"); + parse_rule(import_list, 0, "import A, B;"); + parse_rule(import_list, 0, "import A, B = ModB, C;"); } TEST(Should parse constant declarations and expressions) { - parse_rule(const_decl, 0, - "FOO = 123"); - parse_rule(const_decl, 0, - "FOO = 123.123"); - parse_rule(const_decl, 0, - "FOO = \"\""); - parse_rule(const_decl, 0, - "FOO = true"); - parse_rule(const_decl, 0, - "FOO = false"); -// parse_rule(const_decl, 0, -// "FOO = nil"); - parse_rule(const_decl, 0, - "FOO = not true"); - parse_rule(const_decl, 0, - "FOO = (not false)"); - parse_rule(const_decl, 0, - "FOO = +1"); - parse_rule(const_decl, 0, - "FOO = -1"); - parse_rule(const_decl, 0, - "FOO = +1.0"); - parse_rule(const_decl, 0, - "FOO = -1.0"); - parse_rule(const_decl, 0, - "FOO = 1 + 2"); - parse_rule(const_decl, 0, - "FOO = 1.0 + 2.0"); - parse_rule(const_decl, 0, - "FOO = 1 - 2"); - parse_rule(const_decl, 0, - "FOO = 1.0 - 2.0"); - parse_rule(const_decl, 0, - "FOO = 3 * 2"); - parse_rule(const_decl, 0, - "FOO = 3.0 * 2.0"); - parse_rule(const_decl, 0, - "FOO = 4 / 2"); - parse_rule(const_decl, 0, - "FOO = 3.0 / 4.0"); - parse_rule(const_decl, 0, - "FOO = 5 % 3"); - parse_rule(const_decl, 0, - "FOO = 5 == 3"); - parse_rule(const_decl, 0, - "FOO = 5 != 3"); - parse_rule(const_decl, 0, - "FOO = 5 < 3"); - parse_rule(const_decl, 0, - "FOO = 5 <= 3"); - parse_rule(const_decl, 0, - "FOO = 5 > 3"); - parse_rule(const_decl, 0, - "FOO = 5 >= 3"); - parse_rule(const_decl, 0, - "FOO = 5, BAR = FOO - 3"); + parse_rule(const_decl, 0, "FOO = 123"); + parse_rule(const_decl, 0, "FOO = 123.123"); + parse_rule(const_decl, 0, "FOO = \"\""); + parse_rule(const_decl, 0, "FOO = true"); + parse_rule(const_decl, 0, "FOO = false"); +// parse_rule(const_decl, 0, "FOO = nil"); + parse_rule(const_decl, 0, "FOO = not true"); + parse_rule(const_decl, 0, "FOO = (not false)"); + parse_rule(const_decl, 0, "FOO = +1"); + parse_rule(const_decl, 0, "FOO = -1"); + parse_rule(const_decl, 0, "FOO = +1.0"); + parse_rule(const_decl, 0, "FOO = -1.0"); + parse_rule(const_decl, 0, "FOO = 1 + 2"); + parse_rule(const_decl, 0, "FOO = 1.0 + 2.0"); + parse_rule(const_decl, 0, "FOO = 1 - 2"); + parse_rule(const_decl, 0, "FOO = 1.0 - 2.0"); + parse_rule(const_decl, 0, "FOO = 3 * 2"); + parse_rule(const_decl, 0, "FOO = 3.0 * 2.0"); + parse_rule(const_decl, 0, "FOO = 4 / 2"); + parse_rule(const_decl, 0, "FOO = 3.0 / 4.0"); + parse_rule(const_decl, 0, "FOO = 5 % 3"); + parse_rule(const_decl, 0, "FOO = 5 == 3"); + parse_rule(const_decl, 0, "FOO = 5 != 3"); + parse_rule(const_decl, 0, "FOO = 5 < 3"); + parse_rule(const_decl, 0, "FOO = 5 <= 3"); + parse_rule(const_decl, 0, "FOO = 5 > 3"); + parse_rule(const_decl, 0, "FOO = 5 >= 3"); + parse_rule(const_decl, 0, "FOO = 5, BAR = FOO - 3"); } } #endif -- 2.49.0