feat: implement Map.keys, Map.values iterators and proper toString with key-value formatting

Add MapKeySequence and MapValueSequence classes in core.wren to expose iterable key and value views on Map instances. Implement native iterate_, keyIteratorValue_, and valueIteratorValue_ primitives in wren_core.c to support these sequences. Replace the stub Map.toString with a full implementation that iterates keys and formats each entry as "key: value", handling empty maps and nested maps correctly. Include comprehensive test suites for key iteration, value iteration, iterator type validation, and toString output across multiple orderings.
This commit is contained in:
Bob Nystrom
2015-01-25 18:27:38 +00:00
parent 56123c71e3
commit f093d0a42a
9 changed files with 250 additions and 4 deletions
@@ -0,0 +1,2 @@
var a = {1: 2, 3: 4}
a.keys.iterate(1.5) // expect runtime error: Iterator must be an integer.