Add regression tests for obsolete issues

#KT-50909
 #KT-50974
 #KT-51888
This commit is contained in:
Alexander Udalov
2022-09-23 22:06:30 +02:00
parent e7b5e74f78
commit 4baa74f396
11 changed files with 142 additions and 0 deletions
@@ -0,0 +1,29 @@
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: JVM
// WITH_STDLIB
// MODULE: lib
// FILE: lib.kt
public class WhateverUseCase : UseCaseWithParameter<Result<Int>, Int> {
override operator fun invoke(param: Result<Int>): Result<Int> {
return param.onFailure {
return if (it is NumberFormatException)
Result.success(0)
else
Result.failure(it)
}
}
}
interface UseCaseWithParameter<P, R> {
operator fun invoke(param: P) : Result<R>
}
// MODULE: main(lib)
// FILE: main.kt
fun box(): String {
val useCase = WhateverUseCase()
return if (useCase(Result.failure(NumberFormatException())) == Result.success(0)) "OK"
else "Fail"
}