Make suspend functions callable inside test(worker) { }

We don't need `crossinline` for `testBody`. Usage of cross-inline makes suspend functions non-callable in the test body, which forbids patterns like:
```
test(worker) {
  sharedFlow.emit(someValue)
  // assert worker processed it
}
```
This commit is contained in:
Patrick Steiger
2023-11-09 12:54:18 -03:00
parent 6847098360
commit cbd11f7927
2 changed files with 3 additions and 1 deletions
@@ -190,6 +190,8 @@ class RibCoroutineWorkerTest {
assertThat(worker.innerCoroutineCompleted).isFalse()
assertThat(worker.onStopRan).isFalse()
test(worker) {
// Quick check that suspend functions can be called inside this block
delay(0)
// Assert onStart and inner coroutine started but have not finished (it has delays)
assertThat(it.onStartStarted).isTrue()
assertThat(it.innerCoroutineStarted).isTrue()
@@ -39,7 +39,7 @@ import kotlinx.coroutines.test.runCurrent
@OptIn(ExperimentalCoroutinesApi::class)
public inline fun <T : RibCoroutineWorker> TestScope.test(
worker: T,
crossinline testBody: TestScope.(T) -> Unit,
testBody: TestScope.(T) -> Unit,
) {
val dispatcher = StandardTestDispatcher(testScheduler)
val handle = bind(worker, dispatcher)