Files
wren/test/range/iterator_value.wren
T
Bob Nystrom ebb47d30e6 feat: replace Wren Range class with native C object for performance
Remove the Range class definition from corelib.wren and implement it as a native C type with ObjRange struct, adding native methods for from, to, min, max, iterate, and iteratorValue. Move range operator handling from Num class to native num_dotDot and num_dotDotDot functions. Update VM to support OBJ_RANGE type in marking, printing, and type checking. Add comprehensive test suite for range operations including ordered, backwards, and exclusive ranges.
2014-01-20 16:45:15 +00:00

12 lines
352 B
Plaintext

var range = 1..3
IO.print(range.iteratorValue(1)) // expect: 1
IO.print(range.iteratorValue(2)) // expect: 2
IO.print(range.iteratorValue(3)) // expect: 3
// Doesn't bother to bounds check.
IO.print(range.iteratorValue(-2)) // expect: -2
IO.print(range.iteratorValue(5)) // expect: 5
// Or type check.
IO.print(range.iteratorValue("s")) // expect: s