diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-01-27 00:30:56 +0000 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-01-27 00:30:56 +0000 |
| commit | 7c2a92b82e9808d3c5ea29b47d1c59d663fe984a (patch) | |
| tree | ceba95c48bd8d5d9fff3d1206483ddf073c0e03d /spec/inputs/test/multiline_args_spec.yue | |
| parent | e70e63a9737ed3a9e72f1329901075498190e6b4 (diff) | |
| download | yuescript-compiler-improvements.tar.gz yuescript-compiler-improvements.tar.bz2 yuescript-compiler-improvements.zip | |
Add compiler improvements and comprehensive test suitecompiler-improvements
- Fixed path option handling to avoid semicolon concatenation issues
- Added exception handling for std::length_error and general exceptions
- Added comprehensive test specifications for advanced language features
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'spec/inputs/test/multiline_args_spec.yue')
| -rw-r--r-- | spec/inputs/test/multiline_args_spec.yue | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/spec/inputs/test/multiline_args_spec.yue b/spec/inputs/test/multiline_args_spec.yue new file mode 100644 index 0000000..bbb06f9 --- /dev/null +++ b/spec/inputs/test/multiline_args_spec.yue | |||
| @@ -0,0 +1,125 @@ | |||
| 1 | describe "multiline arguments", -> | ||
| 2 | it "should split arguments across lines", -> | ||
| 3 | sum = (a, b, c) -> a + b + c | ||
| 4 | result = sum 5, 4, 3, | ||
| 5 | 8, 9, 10 | ||
| 6 | assert.same result, 39 | ||
| 7 | |||
| 8 | it "should handle nested function calls", -> | ||
| 9 | outer = (a, b, c, d, e, f) -> a + b + c + d + e + f | ||
| 10 | result = outer 5, 6, 7, | ||
| 11 | 6, 2, 3 | ||
| 12 | assert.same result, 29 | ||
| 13 | |||
| 14 | it "should work with string arguments", -> | ||
| 15 | fn = (a, b, c, d) -> a .. b .. c .. d | ||
| 16 | result = fn "hello", | ||
| 17 | " ", "world", "!" | ||
| 18 | assert.same result, "hello world!" | ||
| 19 | |||
| 20 | it "should support table arguments", -> | ||
| 21 | fn = (a, b, c) -> {a, b, c} | ||
| 22 | result = fn {1, 2}, | ||
| 23 | {3, 4}, | ||
| 24 | {5, 6} | ||
| 25 | assert.same result, {{1, 2}, {3, 4}, {5, 6}} | ||
| 26 | |||
| 27 | it "should handle mixed types", -> | ||
| 28 | fn = (a, b, c, d) -> {a, b, c, d} | ||
| 29 | result = fn "text", | ||
| 30 | 123, | ||
| 31 | true, | ||
| 32 | nil | ||
| 33 | assert.same result, {"text", 123, true, nil} | ||
| 34 | |||
| 35 | it "should work in table literal", -> | ||
| 36 | fn = (a, b) -> a + b | ||
| 37 | result = [ | ||
| 38 | 1, 2, 3, 4, fn 4, 5, | ||
| 39 | 5, 6, | ||
| 40 | 8, 9, 10 | ||
| 41 | ] | ||
| 42 | assert.same result, {1, 2, 3, 4, 9, 8, 9, 10} | ||
| 43 | |||
| 44 | it "should handle deeply nested indentation", -> | ||
| 45 | y = [ fn 1, 2, 3, | ||
| 46 | 4, 5, | ||
| 47 | 5, 6, 7 | ||
| 48 | ] | ||
| 49 | |||
| 50 | -- Create the function first | ||
| 51 | fn = (a, b, c, d, e, f, g) -> a + b + c + d + e + f + g | ||
| 52 | |||
| 53 | result = y[1] | ||
| 54 | assert.same result, 22 | ||
| 55 | |||
| 56 | it "should work with conditional statements", -> | ||
| 57 | fn = (a, b, c, d, e) -> a + b + c + d + e | ||
| 58 | |||
| 59 | result = if fn 1, 2, 3, | ||
| 60 | "hello", | ||
| 61 | "world" | ||
| 62 | "yes" | ||
| 63 | else | ||
| 64 | "no" | ||
| 65 | assert.same result, "yes" | ||
| 66 | |||
| 67 | it "should support function expressions", -> | ||
| 68 | double = (x) -> x * 2 | ||
| 69 | result = double 5, | ||
| 70 | 10 | ||
| 71 | assert.same result, 20 | ||
| 72 | |||
| 73 | it "should handle chained function calls", -> | ||
| 74 | add = (a, b) -> a + b | ||
| 75 | multiply = (a, b) -> a * b | ||
| 76 | |||
| 77 | result = multiply add 1, 2, | ||
| 78 | add 3, 4 | ||
| 79 | assert.same result, 21 | ||
| 80 | |||
| 81 | it "should work with method calls", -> | ||
| 82 | obj = | ||
| 83 | value: 10 | ||
| 84 | add: (a, b) => @value + a + b | ||
| 85 | |||
| 86 | result = obj\add 5, 10, | ||
| 87 | 15 | ||
| 88 | assert.same result, 40 | ||
| 89 | |||
| 90 | it "should support many arguments", -> | ||
| 91 | sum_many = (...) -> | ||
| 92 | total = 0 | ||
| 93 | for i = 1, select '#', ... | ||
| 94 | total += select(i, ...) if type(select(i, ...)) == "number" | ||
| 95 | total | ||
| 96 | |||
| 97 | result = sum_many 1, 2, 3, | ||
| 98 | 4, 5, 6, | ||
| 99 | 7, 8, 9 | ||
| 100 | assert.same result, 45 | ||
| 101 | |||
| 102 | it "should work with return statement", -> | ||
| 103 | fn = (a, b) -> a + b | ||
| 104 | get_value = -> | ||
| 105 | return fn 10, 20, | ||
| 106 | 30 | ||
| 107 | |||
| 108 | result = get_value! | ||
| 109 | assert.same result, 60 | ||
| 110 | |||
| 111 | it "should handle default parameters", -> | ||
| 112 | fn = (a = 1, b = 2, c = 3) -> a + b + c | ||
| 113 | result = fn 10, | ||
| 114 | 20, | ||
| 115 | 30 | ||
| 116 | assert.same result, 60 | ||
| 117 | |||
| 118 | it "should work with varargs", -> | ||
| 119 | collect = (...) -> | ||
| 120 | {...} | ||
| 121 | |||
| 122 | result = collect 1, 2, | ||
| 123 | 3, 4, | ||
| 124 | 5, 6 | ||
| 125 | assert.same result, {1, 2, 3, 4, 5, 6} | ||
