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.
3 lines
95 B
Plaintext
3 lines
95 B
Plaintext
var a = {1: 2, 3: 4}
|
|
a.values.iterate("2") // expect runtime error: Iterator must be a number.
|