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:
Ilya Gorbunov
2016-11-04 05:01:08 +03:00
parent f5cc53c157
commit d91f3cba0b
5 changed files with 46 additions and 10 deletions
@@ -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))