From 640dcd82b30629f54596820c09144dfff10cb2c0 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Thu, 12 Feb 2026 09:08:12 +0800 Subject: Added more tests. --- spec/inputs/test/break_multiple_values_spec.yue | 19 +++++++++++++++++++ spec/inputs/test/format_spec.yue | 7 +++++-- 2 files changed, 24 insertions(+), 2 deletions(-) (limited to 'spec/inputs') diff --git a/spec/inputs/test/break_multiple_values_spec.yue b/spec/inputs/test/break_multiple_values_spec.yue index 846be00..053008d 100644 --- a/spec/inputs/test/break_multiple_values_spec.yue +++ b/spec/inputs/test/break_multiple_values_spec.yue @@ -838,3 +838,22 @@ describe "break with multiple values", -> break assert.same x, 5 assert.same y, 15 + + it "should allow nesting do and for", -> + x, y = do + min, max = 1, 10 + if max > min + break for j = min, max + break j, j * 10 if j > 5 + break 0, 0 + assert.same x, 6 + assert.same y, 60 + + it "should allow nesting do and with", -> + x = with a: 123, b: true + do + if .b + break with a: .a, b: .b, c: "ok" + if .b and .c == "ok" + break .a + assert.same x, 123 diff --git a/spec/inputs/test/format_spec.yue b/spec/inputs/test/format_spec.yue index afe9331..8c6096a 100644 --- a/spec/inputs/test/format_spec.yue +++ b/spec/inputs/test/format_spec.yue @@ -113,6 +113,7 @@ files = [ "spec/inputs/test/loops_spec.yue" "spec/inputs/test/if_assignment_spec.yue" "spec/inputs/test/tables_advanced_spec.yue" + "spec/inputs/test/break_multiple_values_spec.yue" "spec/inputs/unicode/macro_export.yue" "spec/inputs/unicode/attrib.yue" "spec/inputs/unicode/macro.yue" @@ -179,11 +180,13 @@ for file in *files code = f\read "a*" f\close! - original_ast = yue.to_ast code + original_ast, err = yue.to_ast code + assert.is_nil err assert.is_not_nil original_ast rewriteLineCol original_ast formated = yue.format code, 0, true - ast = yue.to_ast formated + ast, err = yue.to_ast formated + assert.is_nil err assert.is_not_nil ast rewriteLineCol ast assert.same original_ast, ast -- cgit v1.2.3-55-g6feb