• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package kotlinx.coroutines.test
2 
3 /**
4  * Runs [test], and then invokes [block], passing to it the lambda that functionally behaves
5  * the same way [test] does.
6  */
testResultMapnull7 fun testResultMap(block: (() -> Unit) -> Unit, test: () -> TestResult): TestResult = testResultChain(
8     block = test,
9     after = {
10         block { it.getOrThrow() }
11         createTestResult { }
12     }
13 )
14 
15 /**
16  * Chains together [block] and [after], passing the result of [block] to [after].
17  */
testResultChainnull18 expect fun testResultChain(block: () -> TestResult, after: (Result<Unit>) -> TestResult): TestResult
19 
20 fun testResultChain(vararg chained: (Result<Unit>) -> TestResult, initialResult: Result<Unit> = Result.success(Unit)): TestResult =
21     if (chained.isEmpty()) {
22         createTestResult {
23             initialResult.getOrThrow()
24         }
25     } else {
<lambda>null26         testResultChain(block = {
27             chained[0](initialResult)
28         }) {
29             testResultChain(*chained.drop(1).toTypedArray(), initialResult = it)
30         }
31     }
32