You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: kmp-nativecoroutines-core/src/nativeCoroutinesMain/kotlin/com/rickclephas/kmp/nativecoroutines/NativeCallback.kt
Copy file name to clipboardExpand all lines: kmp-nativecoroutines-core/src/nativeCoroutinesMain/kotlin/com/rickclephas/kmp/nativecoroutines/NativeCancellable.kt
Copy file name to clipboardExpand all lines: kmp-nativecoroutines-core/src/nativeCoroutinesMain/kotlin/com/rickclephas/kmp/nativecoroutines/NativeFlow.kt
Copy file name to clipboardExpand all lines: kmp-nativecoroutines-core/src/nativeCoroutinesMain/kotlin/com/rickclephas/kmp/nativecoroutines/NativeSuspend.kt
Copy file name to clipboardExpand all lines: kmp-nativecoroutines-core/src/nativeCoroutinesTest/kotlin/com/rickclephas/kmp/nativecoroutines/NativeFlowTests.kt
+13-9Lines changed: 13 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -11,16 +11,16 @@ class NativeFlowTests {
11
11
12
12
@Test
13
13
fun`ensure frozen`() {
14
-
val flow = flow<RandomValue> { }
14
+
val flow = flow<RandomValue> { }
15
15
assertFalse(flow.isFrozen, "Flow shouldn't be frozen yet")
16
16
val nativeFlow = flow.asNativeFlow()
17
17
assertTrue(nativeFlow.isFrozen, "NativeFlow should be frozen")
18
18
assertTrue(flow.isFrozen, "Flow should be frozen")
19
19
}
20
20
21
21
@Test
22
-
fun`ensure completion callback is invoked`() = runBlocking {
23
-
val flow = flow<RandomValue> { }
22
+
fun`ensure completion callback is invoked`() =kotlinx.coroutines.runBlocking {
23
+
val flow = flow<RandomValue> { }
24
24
val job =Job()
25
25
val nativeFlow = flow.asNativeFlow(CoroutineScope(job))
26
26
val completionCount = atomic(0)
@@ -33,15 +33,15 @@ class NativeFlowTests {
33
33
}
34
34
35
35
@Test
36
-
fun`ensure exceptions are received as errors`() = runBlocking {
36
+
fun`ensure exceptions are received as errors`() =kotlinx.coroutines.runBlocking {
37
37
val exception =RandomException()
38
38
val flow = flow<RandomValue> { throw exception }
39
39
val job =Job()
40
40
val nativeFlow = flow.asNativeFlow(CoroutineScope(job))
41
41
val completionCount = atomic(0)
42
42
nativeFlow({ _, _ -> }, { error, _ ->
43
43
assertNotNull(error, "Flow should complete with an error")
44
-
val kotlinException = error.userInfo["KotlinException"]
44
+
val kotlinException = error.kotlinCause
45
45
assertSame(exception, kotlinException, "Kotlin exception should be the same exception")
46
46
completionCount.incrementAndGet()
47
47
})
@@ -50,7 +50,7 @@ class NativeFlowTests {
50
50
}
51
51
52
52
@Test
53
-
fun`ensure values are received`() = runBlocking {
53
+
fun`ensure values are received`() =kotlinx.coroutines.runBlocking {
54
54
val values =listOf(RandomValue(), RandomValue(), RandomValue(), RandomValue())
55
55
val flow = flow { values.forEach { emit(it) } }
56
56
val job =Job()
@@ -61,18 +61,22 @@ class NativeFlowTests {
61
61
receivedValueCount.incrementAndGet()
62
62
}, { _, _ -> })
63
63
job.children.forEach { it.join() } // Waits for the collection to complete
64
-
assertEquals(values.size, receivedValueCount.value, "Item callback should be called for every value")
64
+
assertEquals(
65
+
values.size,
66
+
receivedValueCount.value,
67
+
"Item callback should be called for every value"
68
+
)
65
69
}
66
70
67
71
@Test
68
-
fun`ensure collection is cancelled`() = runBlocking {
72
+
fun`ensure collection is cancelled`() =kotlinx.coroutines.runBlocking {
69
73
val flow =MutableSharedFlow<RandomValue>()
70
74
val job =Job()
71
75
val nativeFlow = flow.asNativeFlow(CoroutineScope(job))
Copy file name to clipboardExpand all lines: kmp-nativecoroutines-core/src/nativeCoroutinesTest/kotlin/com/rickclephas/kmp/nativecoroutines/NativeSuspendTests.kt
0 commit comments