[KT-11027] Fix the issue

This commit is contained in:
Alexey Andreev
2016-02-15 15:20:44 +03:00
parent c28b701ccf
commit 56cb7c2677
4 changed files with 42 additions and 9 deletions
@@ -4,7 +4,10 @@ package foo
fun box(): String {
var result = testFun(-1) + testFun(0) + testFun(5) + testFun(9) + testFun(10) + testFun(150)
return if (result == "misshithithitmisshit!") "OK" else "fail"
if (result != "misshithithitmisshit!") 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 {
var lower = Wrapper(0)
@@ -16,6 +19,12 @@ fun testFun(index: Int): String {
else -> "miss"
}
}
fun testFun2(index: Int): String {
return when (Wrapper(index)) {
!in Wrapper(0)..Wrapper(9) -> "hit"
else -> "miss"
}
}
class Wrapper(val value: Int) : Comparable<Wrapper> {
operator fun rangeTo(upper: Wrapper) = WrapperRange(this, upper)
@@ -4,7 +4,10 @@ package foo
fun box(): String {
var result = testFun(-1) + testFun(0) + testFun(5) + testFun(9) + testFun(10) + testFun(150) + testFun(800)
return if (result == "misshithithitmisshit!@@@" && invocationCount == 7) "OK" else "fail"
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
@@ -15,6 +18,12 @@ fun testFun(index: Int): String {
else -> "miss"
}
}
fun testFun2(index: Int): String {
return when(index) {
!in 0..9 -> "hit"
else -> "miss"
}
}
fun get(value: Int): Int {
invocationCount++