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/inputs/test/while_assignment_spec.yue | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 spec/inputs/test/while_assignment_spec.yue (limited to 'spec/inputs/test/while_assignment_spec.yue') diff --git a/spec/inputs/test/while_assignment_spec.yue b/spec/inputs/test/while_assignment_spec.yue new file mode 100644 index 0000000..1c98e58 --- /dev/null +++ b/spec/inputs/test/while_assignment_spec.yue @@ -0,0 +1,42 @@ +describe "while assignment", -> + it "should loop while value is truthy", -> + counter = 0 + get_next = -> + if counter < 3 + counter += 1 + counter + else + nil + results = {} + while val := get_next! + table.insert results, val + assert.same results, {1, 2, 3} + + it "should work with function results", -> + counter = 0 + fn = -> + counter += 1 + if counter <= 3 + counter * 10 + else + nil + + sum = 0 + while val := fn! + sum += val + assert.same sum, 60 -- (10+20+30) + + it "should exit immediately on nil", -> + get_val = -> nil + counter = 0 + while val := get_val! + counter += 1 + assert.same counter, 0 + + it "should support break in loop", -> + items = {1, 2, 3, 4, 5} + sum = 0 + for item in *items + sum += item + break if sum > 6 + assert.same sum, 10 -- cgit v1.2.3-55-g6feb