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.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// Ordered range.
|
||||
IO.print((2..5).max) // expect: 5
|
||||
IO.print((3..3).max) // expect: 3
|
||||
IO.print((0..3).max) // expect: 3
|
||||
IO.print((-5..3).max) // expect: 3
|
||||
IO.print((-5..-2).max) // expect: -2
|
||||
|
||||
// Backwards range.
|
||||
IO.print((5..2).max) // expect: 5
|
||||
IO.print((3..0).max) // expect: 3
|
||||
IO.print((3..-5).max) // expect: 3
|
||||
IO.print((-2..-5).max) // expect: -2
|
||||
|
||||
// Exclusive ordered range.
|
||||
IO.print((2...5).max) // expect: 4
|
||||
IO.print((3...3).max) // expect: 3
|
||||
IO.print((0...3).max) // expect: 2
|
||||
IO.print((-5...3).max) // expect: 2
|
||||
IO.print((-5...-2).max) // expect: -3
|
||||
|
||||
// Exclusive backwards range.
|
||||
IO.print((5...2).max) // expect: 5
|
||||
IO.print((3...0).max) // expect: 3
|
||||
IO.print((3...-5).max) // expect: 3
|
||||
IO.print((-2...-5).max) // expect: -2
|
||||
Reference in New Issue
Block a user