feat: add isInclusive field to ObjRange and implement proper exclusive range iteration
Add isInclusive boolean to ObjRange struct to distinguish between inclusive (..) and exclusive (...) ranges. Update wrenNewRange signature to accept isInclusive parameter. Implement correct iteration logic for both ascending and descending ranges, handling empty exclusive ranges and floating-point iteration. Add type validation for range RHS operands. Update min/max/to properties to return raw endpoint values instead of adjusted ones. Add comprehensive test coverage for inclusive/exclusive ranges, negative ranges, empty ranges, floating-point iteration, isInclusive property, toString, and type error cases.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// Ordered range.
|
||||
IO.print((2..5).from) // expect: 2
|
||||
IO.print((3..3).from) // expect: 3
|
||||
IO.print((0..3).from) // expect: 0
|
||||
IO.print((-5..3).from) // expect: -5
|
||||
IO.print((-5..-2).from) // expect: -5
|
||||
|
||||
// Backwards range.
|
||||
IO.print((5..2).from) // expect: 5
|
||||
IO.print((3..0).from) // expect: 3
|
||||
IO.print((3..-5).from) // expect: 3
|
||||
IO.print((-2..-5).from) // expect: -2
|
||||
|
||||
// Exclusive ordered range.
|
||||
IO.print((2...5).from) // expect: 2
|
||||
IO.print((3...3).from) // expect: 3
|
||||
IO.print((0...3).from) // expect: 0
|
||||
IO.print((-5...3).from) // expect: -5
|
||||
IO.print((-5...-2).from) // expect: -5
|
||||
|
||||
// Exclusive backwards range.
|
||||
IO.print((5...2).from) // expect: 5
|
||||
IO.print((3...0).from) // expect: 3
|
||||
IO.print((3...-5).from) // expect: 3
|
||||
IO.print((-2...-5).from) // expect: -2
|
||||
|
||||
// TODO: Test toString.
|
||||
// TODO: Non-number RHS.
|
||||
// TODO: Non-integer RHS.
|
||||
// TODO: Range iteration.
|
||||
// TODO: Empty or negative ranges.
|
||||
Reference in New Issue
Block a user