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