From 46b4a3e6d5b4160dc8d71ed0d0ad9e9fb2f95eed Mon Sep 17 00:00:00 2001 From: ayazhafiz Date: Thu, 23 Dec 2021 15:17:45 -0600 Subject: [PATCH 1/2] Add test for nested if parsing Closes #169 It seems the above issue was resolved a long time ago but there wasn't a test for it --- compiler/parse/tests/test_parse.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/parse/tests/test_parse.rs b/compiler/parse/tests/test_parse.rs index 9524b40c47..b563bc3c58 100644 --- a/compiler/parse/tests/test_parse.rs +++ b/compiler/parse/tests/test_parse.rs @@ -164,6 +164,7 @@ mod test_parse { pass/negative_float.expr, pass/negative_int.expr, pass/nested_def_annotation.module, + pass/nested_if.expr, pass/nested_module.header, pass/newline_after_equals.expr, // Regression test for https://github.com/rtfeldman/roc/issues/51 pass/newline_after_mul.expr, From 6d9a5b6b0d902b25195fb6ee36b3ee4aedcb9630 Mon Sep 17 00:00:00 2001 From: ayazhafiz Date: Thu, 23 Dec 2021 17:52:56 -0600 Subject: [PATCH 2/2] Actually add the test files --- .../snapshots/pass/nested_if.expr.result-ast | 50 +++++++++++++++++++ .../tests/snapshots/pass/nested_if.expr.roc | 6 +++ 2 files changed, 56 insertions(+) create mode 100644 compiler/parse/tests/snapshots/pass/nested_if.expr.result-ast create mode 100644 compiler/parse/tests/snapshots/pass/nested_if.expr.roc diff --git a/compiler/parse/tests/snapshots/pass/nested_if.expr.result-ast b/compiler/parse/tests/snapshots/pass/nested_if.expr.result-ast new file mode 100644 index 0000000000..9a2e97e67c --- /dev/null +++ b/compiler/parse/tests/snapshots/pass/nested_if.expr.result-ast @@ -0,0 +1,50 @@ +If( + [ + ( + |L 0-0, C 3-5| Var { + module_name: "", + ident: "t1", + }, + |L 1-1, C 2-3| SpaceBefore( + SpaceAfter( + Num( + "1", + ), + [ + Newline, + ], + ), + [ + Newline, + ], + ), + ), + ( + |L 2-2, C 8-10| Var { + module_name: "", + ident: "t2", + }, + |L 3-3, C 2-3| SpaceBefore( + SpaceAfter( + Num( + "2", + ), + [ + Newline, + ], + ), + [ + Newline, + ], + ), + ), + ], + |L 5-5, C 2-3| SpaceBefore( + Num( + "3", + ), + [ + Newline, + ], + ), +) diff --git a/compiler/parse/tests/snapshots/pass/nested_if.expr.roc b/compiler/parse/tests/snapshots/pass/nested_if.expr.roc new file mode 100644 index 0000000000..4f8ee31829 --- /dev/null +++ b/compiler/parse/tests/snapshots/pass/nested_if.expr.roc @@ -0,0 +1,6 @@ +if t1 then + 1 +else if t2 then + 2 +else + 3