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:
Bob Nystrom
2014-01-20 21:20:22 +00:00
parent ebb47d30e6
commit cf5a34025b
14 changed files with 148 additions and 38 deletions
+4 -4
View File
@@ -12,11 +12,11 @@ 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((2...5).max) // expect: 5
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
IO.print((0...3).max) // expect: 3
IO.print((-5...3).max) // expect: 3
IO.print((-5...-2).max) // expect: -2
// Exclusive backwards range.
IO.print((5...2).max) // expect: 5