Testing tryFinallyChain seems untrivial so it still require kotlin stdlib
This commit is contained in:
parent
529508bf74
commit
28ab658dd2
@ -12,7 +12,7 @@ class TryFinallyChainScope @PublishedApi internal constructor() {
|
||||
this._actualException?.let { e -> throw e }
|
||||
}
|
||||
|
||||
inline fun action(fn: () -> Unit) {
|
||||
inline fun action(fn: () -> Unit): TryFinallyChainScope {
|
||||
contract {
|
||||
callsInPlace(fn, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
@ -21,5 +21,6 @@ class TryFinallyChainScope @PublishedApi internal constructor() {
|
||||
onError = { err -> this._actualException?.addSuppressed(err) ?: run { this._actualException = err } },
|
||||
action = fn
|
||||
)
|
||||
return this
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import org.testng.annotations.Test
|
||||
import org.testng.asserts.Assertion
|
||||
import ru.landgrafhomyak.utility.highlevel_try_finally.safeAutoClose1
|
||||
import ru.landgrafhomyak.utility.highlevel_try_finally.tryFinallyChain
|
||||
import java.lang.AssertionError
|
||||
|
||||
@Test
|
||||
class KotlinStdlibDependencyTest {
|
||||
@ -52,15 +53,15 @@ class KotlinStdlibDependencyTest {
|
||||
try {
|
||||
@Suppress("KotlinUnreachableCode")
|
||||
tryFinallyChain { chain ->
|
||||
chain.action { }
|
||||
// chain.action { }
|
||||
chain.action { throw CustomTestException() }
|
||||
chain.action { throw CustomTestException() }
|
||||
chain.action { }
|
||||
chain.action { }
|
||||
}
|
||||
} catch (_: CustomTestException) {
|
||||
} catch (_: LinkageError) {
|
||||
Assertion().assertTrue(false, "safeAutoClose still has dependency on kotlin stdlib")
|
||||
} catch (e: LinkageError) {
|
||||
throw AssertionError("safeAutoClose still has dependency on kotlin stdlib", e)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user