From b4d5e8f2352341e9f12e875692778aa5fc00f122 Mon Sep 17 00:00:00 2001 From: peefy Date: Sun, 18 Feb 2024 09:32:19 +0800 Subject: [PATCH] test: add orelse AST printer test cases Signed-off-by: peefy --- kclvm/ast_pretty/src/test_data/orelse.input | 31 ++++++++++++++++++++ kclvm/ast_pretty/src/test_data/orelse.output | 31 ++++++++++++++++++++ kclvm/ast_pretty/src/tests.rs | 3 +- 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 kclvm/ast_pretty/src/test_data/orelse.input create mode 100644 kclvm/ast_pretty/src/test_data/orelse.output diff --git a/kclvm/ast_pretty/src/test_data/orelse.input b/kclvm/ast_pretty/src/test_data/orelse.input new file mode 100644 index 000000000..613d7ec74 --- /dev/null +++ b/kclvm/ast_pretty/src/test_data/orelse.input @@ -0,0 +1,31 @@ +if True: + a = 1 +else: + if True: + b = 2 + + if True: + c = 3 + +d = [ + if True: + 1 + else: + if True: + 2 + + if True: + 3 + +] +e = { + if True: + a = 1 + else: + if True: + b = 2 + + if True: + c = 3 + +} diff --git a/kclvm/ast_pretty/src/test_data/orelse.output b/kclvm/ast_pretty/src/test_data/orelse.output new file mode 100644 index 000000000..613d7ec74 --- /dev/null +++ b/kclvm/ast_pretty/src/test_data/orelse.output @@ -0,0 +1,31 @@ +if True: + a = 1 +else: + if True: + b = 2 + + if True: + c = 3 + +d = [ + if True: + 1 + else: + if True: + 2 + + if True: + 3 + +] +e = { + if True: + a = 1 + else: + if True: + b = 2 + + if True: + c = 3 + +} diff --git a/kclvm/ast_pretty/src/tests.rs b/kclvm/ast_pretty/src/tests.rs index 2867c1a38..5ef2f2494 100644 --- a/kclvm/ast_pretty/src/tests.rs +++ b/kclvm/ast_pretty/src/tests.rs @@ -6,7 +6,7 @@ use pretty_assertions::assert_eq; const FILE_INPUT_SUFFIX: &str = ".input"; const FILE_OUTPUT_SUFFIX: &str = ".output"; -const TEST_CASES: &[&str; 16] = &[ +const TEST_CASES: &[&str] = &[ "arguments", "empty", "if_stmt", @@ -18,6 +18,7 @@ const TEST_CASES: &[&str; 16] = &[ "index_sign", "joined_str", "lambda", + "orelse", "quant", "rule", "str",