diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-02-12 09:08:12 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-02-12 09:08:12 +0800 |
| commit | 640dcd82b30629f54596820c09144dfff10cb2c0 (patch) | |
| tree | e6c1822f459b8afc64d06a86459cf676ea7c74c2 /spec/inputs/test | |
| parent | 4e7edb2bd615e0a86b593c56c3392fab2110b1a1 (diff) | |
| download | yuescript-640dcd82b30629f54596820c09144dfff10cb2c0.tar.gz yuescript-640dcd82b30629f54596820c09144dfff10cb2c0.tar.bz2 yuescript-640dcd82b30629f54596820c09144dfff10cb2c0.zip | |
Added more tests.
Diffstat (limited to 'spec/inputs/test')
| -rw-r--r-- | spec/inputs/test/break_multiple_values_spec.yue | 19 | ||||
| -rw-r--r-- | spec/inputs/test/format_spec.yue | 7 |
2 files changed, 24 insertions, 2 deletions
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", -> | |||
| 838 | break | 838 | break |
| 839 | assert.same x, 5 | 839 | assert.same x, 5 |
| 840 | assert.same y, 15 | 840 | assert.same y, 15 |
| 841 | |||
| 842 | it "should allow nesting do and for", -> | ||
| 843 | x, y = do | ||
| 844 | min, max = 1, 10 | ||
| 845 | if max > min | ||
| 846 | break for j = min, max | ||
| 847 | break j, j * 10 if j > 5 | ||
| 848 | break 0, 0 | ||
| 849 | assert.same x, 6 | ||
| 850 | assert.same y, 60 | ||
| 851 | |||
| 852 | it "should allow nesting do and with", -> | ||
| 853 | x = with a: 123, b: true | ||
| 854 | do | ||
| 855 | if .b | ||
| 856 | break with a: .a, b: .b, c: "ok" | ||
| 857 | if .b and .c == "ok" | ||
| 858 | break .a | ||
| 859 | 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 = [ | |||
| 113 | "spec/inputs/test/loops_spec.yue" | 113 | "spec/inputs/test/loops_spec.yue" |
| 114 | "spec/inputs/test/if_assignment_spec.yue" | 114 | "spec/inputs/test/if_assignment_spec.yue" |
| 115 | "spec/inputs/test/tables_advanced_spec.yue" | 115 | "spec/inputs/test/tables_advanced_spec.yue" |
| 116 | "spec/inputs/test/break_multiple_values_spec.yue" | ||
| 116 | "spec/inputs/unicode/macro_export.yue" | 117 | "spec/inputs/unicode/macro_export.yue" |
| 117 | "spec/inputs/unicode/attrib.yue" | 118 | "spec/inputs/unicode/attrib.yue" |
| 118 | "spec/inputs/unicode/macro.yue" | 119 | "spec/inputs/unicode/macro.yue" |
| @@ -179,11 +180,13 @@ for file in *files | |||
| 179 | code = f\read "a*" | 180 | code = f\read "a*" |
| 180 | f\close! | 181 | f\close! |
| 181 | 182 | ||
| 182 | original_ast = yue.to_ast code | 183 | original_ast, err = yue.to_ast code |
| 184 | assert.is_nil err | ||
| 183 | assert.is_not_nil original_ast | 185 | assert.is_not_nil original_ast |
| 184 | rewriteLineCol original_ast | 186 | rewriteLineCol original_ast |
| 185 | formated = yue.format code, 0, true | 187 | formated = yue.format code, 0, true |
| 186 | ast = yue.to_ast formated | 188 | ast, err = yue.to_ast formated |
| 189 | assert.is_nil err | ||
| 187 | assert.is_not_nil ast | 190 | assert.is_not_nil ast |
| 188 | rewriteLineCol ast | 191 | rewriteLineCol ast |
| 189 | assert.same original_ast, ast | 192 | assert.same original_ast, ast |
