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/chaining_comparison_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/chaining_comparison_spec.yue')
| -rw-r--r-- | spec/inputs/test/chaining_comparison_spec.yue | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/inputs/test/chaining_comparison_spec.yue b/spec/inputs/test/chaining_comparison_spec.yue new file mode 100644 index 0000000..f86cf5f --- /dev/null +++ b/spec/inputs/test/chaining_comparison_spec.yue | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | describe "chaining comparison", -> | ||
| 2 | it "should support simple chaining", -> | ||
| 3 | assert.is_true 1 < 2 < 3 | ||
| 4 | assert.is_true 1 <= 2 <= 3 | ||
| 5 | assert.is_true 3 > 2 > 1 | ||
| 6 | assert.is_true 3 >= 2 >= 1 | ||
| 7 | |||
| 8 | it "should support complex chaining", -> | ||
| 9 | assert.is_true 1 < 2 <= 2 < 3 == 3 > 2 >= 1 == 1 < 3 ~= 5 | ||
| 10 | |||
| 11 | it "should work with variables", -> | ||
| 12 | a = 5 | ||
| 13 | assert.is_true 1 <= a <= 10 | ||
| 14 | assert.is_true a >= 3 | ||
| 15 | assert.is_true a <= 10 | ||
| 16 | |||
| 17 | it "should handle mixed comparisons", -> | ||
| 18 | x = 5 | ||
| 19 | assert.is_true 1 < x < 10 | ||
| 20 | assert.is_true 1 <= x <= 5 | ||
| 21 | |||
| 22 | it "should work with string comparisons", -> | ||
| 23 | assert.is_true "a" < "b" < "c" | ||
| 24 | assert.is_true "a" <= "b" <= "c" | ||
| 25 | |||
| 26 | it "should handle edge cases", -> | ||
| 27 | assert.is_true 0 <= 0 <= 0 | ||
| 28 | assert.is_true -5 < 0 < 5 | ||
| 29 | |||
| 30 | it "should work in expressions", -> | ||
| 31 | result = if 1 < 2 < 3 | ||
| 32 | "yes" | ||
| 33 | else | ||
| 34 | "no" | ||
| 35 | assert.same result, "yes" | ||
| 36 | |||
| 37 | it "should support != operator", -> | ||
| 38 | assert.is_true 1 != 2 != 3 | ||
| 39 | assert.is_true 1 ~= 2 ~= 3 | ||
| 40 | |||
| 41 | it "should handle boolean results", -> | ||
| 42 | assert.is_true 1 < 2 < 3 | ||
| 43 | assert.is_false 3 < 2 < 1 | ||
| 44 | |||
| 45 | it "should work with function calls", -> | ||
| 46 | v = (x) -> x | ||
| 47 | assert.is_true v(1) < v(2) < v(3) | ||
| 48 | |||
| 49 | it "should handle negation", -> | ||
| 50 | assert.is_true -10 < -5 < 0 | ||
| 51 | |||
| 52 | it "should support mixed operators", -> | ||
| 53 | assert.is_true 1 < 2 <= 2 < 3 | ||
| 54 | assert.is_true 3 > 2 >= 2 > 1 | ||
