From 7c2a92b82e9808d3c5ea29b47d1c59d663fe984a Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 27 Jan 2026 00:30:56 +0000 Subject: Add compiler improvements and comprehensive test suite - 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 --- spec/outputs/test/chaining_comparison_spec.lua | 85 ++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 spec/outputs/test/chaining_comparison_spec.lua (limited to 'spec/outputs/test/chaining_comparison_spec.lua') diff --git a/spec/outputs/test/chaining_comparison_spec.lua b/spec/outputs/test/chaining_comparison_spec.lua new file mode 100644 index 0000000..fe61fae --- /dev/null +++ b/spec/outputs/test/chaining_comparison_spec.lua @@ -0,0 +1,85 @@ +local _anon_func_0 = function() + local _cond_0 = "b" + if not ("a" < _cond_0) then + return false + else + return _cond_0 < "c" + end +end +local _anon_func_1 = function() + local _cond_0 = "b" + if not ("a" <= _cond_0) then + return false + else + return _cond_0 <= "c" + end +end +local _anon_func_2 = function(v) + local _cond_0 = v(2) + if not (v(1) < _cond_0) then + return false + else + return _cond_0 < v(3) + end +end +return describe("chaining comparison", function() + it("should support simple chaining", function() + assert.is_true(1 < 2 and 2 < 3) + assert.is_true(1 <= 2 and 2 <= 3) + assert.is_true(3 > 2 and 2 > 1) + return assert.is_true(3 >= 2 and 2 >= 1) + end) + it("should support complex chaining", function() + return assert.is_true(1 < 2 and 2 <= 2 and 2 < 3 and 3 == 3 and 3 > 2 and 2 >= 1 and 1 == 1 and 1 < 3 and 3 ~= 5) + end) + it("should work with variables", function() + local a = 5 + assert.is_true(1 <= a and a <= 10) + assert.is_true(a >= 3) + return assert.is_true(a <= 10) + end) + it("should handle mixed comparisons", function() + local x = 5 + assert.is_true(1 < x and x < 10) + return assert.is_true(1 <= x and x <= 5) + end) + it("should work with string comparisons", function() + assert.is_true(_anon_func_0()) + return assert.is_true(_anon_func_1()) + end) + it("should handle edge cases", function() + assert.is_true(0 <= 0 and 0 <= 0) + return assert.is_true(-5 < 0 and 0 < 5) + end) + it("should work in expressions", function() + local result + if 1 < 2 and 2 < 3 then + result = "yes" + else + result = "no" + end + return assert.same(result, "yes") + end) + it("should support != operator", function() + assert.is_true(1 ~= 2 and 2 ~= 3) + return assert.is_true(1 ~= 2 and 2 ~= 3) + end) + it("should handle boolean results", function() + assert.is_true(1 < 2 and 2 < 3) + return assert.is_false(3 < 2 and 2 < 1) + end) + it("should work with function calls", function() + local v + v = function(x) + return x + end + return assert.is_true(_anon_func_2(v)) + end) + it("should handle negation", function() + return assert.is_true(-10 < -5 and -5 < 0) + end) + return it("should support mixed operators", function() + assert.is_true(1 < 2 and 2 <= 2 and 2 < 3) + return assert.is_true(3 > 2 and 2 >= 2 and 2 > 1) + end) +end) -- cgit v1.2.3-55-g6feb