JS: move expressions test to box tests

This commit is contained in:
Alexey Andreev
2016-08-26 19:32:17 +03:00
parent 2bf0199959
commit b159049be8
314 changed files with 2380 additions and 2185 deletions
@@ -0,0 +1,32 @@
// see KT-7683
// WhenTranslator must recognize KtWhenConditionInRange and produce faster code when matched expression is Int
package foo
fun box(): String {
var result = testFun(-1) + testFun(0) + testFun(5) + testFun(9) + testFun(10) + testFun(150) + testFun(800)
if (result != "misshithithitmisshit!@@@" || invocationCount != 7) return "fail1:" + result
result = testFun2(-1) + testFun2(0) + testFun2(9) + testFun2(10)
if (result != "hitmissmisshit") return "fail2:" + result
return "OK"
}
fun testFun(index: Int): String {
val thirdRange = 500..1000
return when (get(index)) {
in 0..9 -> "hit"
in 100.rangeTo(200) -> "hit!"
in thirdRange -> "@@@"
else -> "miss"
}
}
fun testFun2(index: Int): String {
return when(index) {
!in 0..9 -> "hit"
else -> "miss"
}
}
fun get(value: Int): Int {
invocationCount++
return value
}
var invocationCount = 0