-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Range.lowerBound and Range.upperBound is correct for open ranges:
let rangeExclusiveInt = 1..<3
XCTAssertEqual(rangeExclusiveInt.lowerBound, 1)
XCTAssertEqual(rangeExclusiveInt.upperBound, 3)
But for ClosedRange, the upperBound is incorrect: Swift expects 1...3 to be 3, but SkipLib reports 4:
let rangeInclusiveInt = 1...3
XCTAssertEqual(rangeInclusiveInt.lowerBound, 1)
XCTAssertEqual(rangeInclusiveInt.upperBound, 3) // java.lang.AssertionError: 4 != 3
The reason is that we always translate upperBound into endInclusive + 1, since we assume open ranges. Kotlin doesn't distinguish between open ranges and closed ranges (they are both IntRange), so I'm not sure if there is any way of handling this correctly short of having our own independent Range structures.
Metadata
Metadata
Assignees
Labels
No labels