It is, but I wouldn’t want my normal synchronous code to be tainted by coroutines solely so I can test it. Someone in ASG mentiond using something like
// Return an adjusted range that encompasses [value].
private fun IntRange.adjustBounds(value: Int): IntRange {
var adjustedRange = this
while (value !in adjustedRange) {
adjustedRange = adjustedRange.decrement()
}
return adjustedRange
}
The types we’re working on isn’t an IntRange, but a custom range type, so doing something like coercing it with the stdlib isn’t an option. I don’t know of a better way to do this, I could elaborate on what precisely we’re doing but I’m not sure it’s important.