Add additional invariant to check in Range.contains optimization tests.
Change expectations for double and float ranges according to #KT-4481 #KT-5044 #KT-4481 Custom 'rangeTo' might be unoptimized, but still 'in' should not diverge from 'contains'.
This commit is contained in:
@@ -5,7 +5,10 @@
|
||||
|
||||
fun check(x: Float, left: Float, right: Float): Boolean {
|
||||
val result = x in left..right
|
||||
assert(result == checkUnoptimized(x, left..right))
|
||||
val manual = x >= left && x <= right
|
||||
val range = left..right
|
||||
assert(result == manual) { "Failed: optimized === manual for $range" }
|
||||
assert(result == checkUnoptimized(x, range)) { "Failed: optimized === unoptimized for $range" }
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -19,13 +22,13 @@ fun box(): String {
|
||||
|
||||
assert(check(Float.MIN_VALUE, 0.0f, 1.0f))
|
||||
assert(check(Float.MAX_VALUE, Float.MAX_VALUE - Float.MIN_VALUE, Float.MAX_VALUE))
|
||||
assert(check(Float.NaN, Float.NaN, Float.NaN))
|
||||
assert(!check(Float.NaN, Float.NaN, Float.NaN))
|
||||
assert(!check(0.0f, Float.NaN, Float.NaN))
|
||||
|
||||
assert(check(-0.0f, -0.0f, +0.0f))
|
||||
assert(check(-0.0f, -0.0f, -0.0f))
|
||||
assert(!check(-0.0f, +0.0f, +0.0f))
|
||||
assert(!check(+0.0f, -0.0f, -0.0f))
|
||||
assert(check(-0.0f, +0.0f, +0.0f))
|
||||
assert(check(+0.0f, -0.0f, -0.0f))
|
||||
assert(check(+0.0f, +0.0f, +0.0f))
|
||||
assert(check(+0.0f, -0.0f, +0.0f))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user