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/implicit_object_spec.yue | 164 ++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 spec/inputs/test/implicit_object_spec.yue (limited to 'spec/inputs/test/implicit_object_spec.yue') diff --git a/spec/inputs/test/implicit_object_spec.yue b/spec/inputs/test/implicit_object_spec.yue new file mode 100644 index 0000000..cea926e --- /dev/null +++ b/spec/inputs/test/implicit_object_spec.yue @@ -0,0 +1,164 @@ +describe "implicit object", -> + it "should create list with asterisk", -> + list = + * 1 + * 2 + * 3 + assert.same list, {1, 2, 3} + + it "should create list with dash", -> + items = + - "a" + - "b" + - "c" + assert.same items, {"a", "b", "c"} + + it "should work with function call", -> + results = [] + fn = + * 1 + * 2 + * 3 + + for item in *fn + table.insert results, item + + assert.same results, {1, 2, 3} + + it "should support nested implicit objects", -> + tb = + name: "test" + + values: + - "a" + - "b" + - "c" + + objects: + - name: "first" + value: 1 + - name: "second" + value: 2 + + assert.same tb.values, {"a", "b", "c"} + assert.same tb.objects[1].name, "first" + assert.same tb.objects[2].value, 2 + + it "should work with return statement", -> + fn = -> + return + * 1 + * 2 + * 3 + + assert.same fn!, {1, 2, 3} + + it "should handle mixed content", -> + tb = + key: "value" + + items: + - 1 + - 2 + + other: "data" + + assert.same tb.key, "value" + assert.same tb.items, {1, 2} + assert.same tb.other, "data" + + it "should work in assignment", -> + list = + * "x" + * "y" + * "z" + + assert.same list, {"x", "y", "z"} + + it "should support nested structures with asterisk", -> + tb = + * 1 + * 2 + nested: + * 3 + * 4 + + assert.same tb[1], 1 + assert.same tb[2], 2 + assert.same tb.nested, {3, 4} + + it "should handle implicit object in tables", -> + tb = { + name: "test" + + list: + - 1 + - 2 + + value: 42 + } + + assert.same tb.list, {1, 2} + + it "should work with expressions", -> + x = 10 + list = + * x + 1 + * x + 2 + * x + 3 + + assert.same list, {11, 12, 13} + + it "should support method calls in implicit object", -> + tb = + name: "test" + items: + - name: "item1" + getName: => @name + - name: "item2" + getName: => @name + + assert.same tb.items[1]\getName!, "item1" + assert.same tb.items[2]\getName!, "item2" + + it "should work with complex nested structures", -> + config = + database: + host: "localhost" + ports: + - 8080 + - 8081 + - 8082 + + servers: + - name: "server1" + port: 8080 + - name: "server2" + port: 8081 + + assert.same config.database.ports, {8080, 8081, 8082} + assert.same config.servers[1].name, "server1" + + it "should handle empty implicit object", -> + tb = + items: + - + + assert.same tb.items, {nil} + + it "should work in function arguments", -> + fn = (items) -> #items + result = fn + * 1 + * 2 + * 3 + assert.same result, 3 + + it "should support mixed asterisk and dash", -> + tb = + values: + * 1 + - 2 + * 3 + + assert.same tb.values, {1, 2, 3} -- cgit v1.2.3-55-g6feb