File tree 6 files changed +149
-22
lines changed
6 files changed +149
-22
lines changed Original file line number Diff line number Diff line change 1
1
val ideaActive: Boolean by project.extra
2
2
val isMacosHost: Boolean by project.extra
3
+
3
4
kotlin {
4
5
sourceSets {
5
6
if (ideaActive) {
@@ -13,28 +14,6 @@ kotlin {
13
14
}
14
15
15
16
get(" posixMain" ).dependsOn(posixIde)
16
- } else {
17
- configure(listOf (watchosArm32().compilations.get(" main" ).defaultSourceSet)) {
18
- kotlin.srcDir(" iosArm32/src" )
19
- }
20
-
21
- configure(
22
- listOf (
23
- watchosArm64().compilations.get(" main" ).defaultSourceSet,
24
- tvosArm64().compilations.get(" main" ).defaultSourceSet
25
- )
26
- ) {
27
- kotlin.srcDir(" iosArm64/src" )
28
- }
29
-
30
- configure(
31
- listOf (
32
- watchosX86().compilations.get(" main" ).defaultSourceSet,
33
- tvosX64().compilations.get(" main" ).defaultSourceSet
34
- )
35
- ) {
36
- kotlin.srcDir(" iosX64" )
37
- }
38
17
}
39
18
}
40
19
}
Original file line number Diff line number Diff line change
1
+ @file:Suppress(" INVISIBLE_MEMBER" , " INVISIBLE_REFERENCE" )
2
+
3
+ package io.ktor.test.dispatcher
4
+
5
+ import kotlinx.coroutines.*
6
+ import kotlin.coroutines.*
7
+ import platform.Foundation.*
8
+
9
+ /* *
10
+ * Amount of time any task is processed and can't be rescheduled.
11
+ */
12
+ private const val TIME_QUANTUM = 0.01
13
+
14
+ /* *
15
+ * Test runner for native suspend tests.
16
+ */
17
+ actual fun testSuspend (
18
+ context : CoroutineContext ,
19
+ block : suspend CoroutineScope .() -> Unit
20
+ ): Unit = runBlocking {
21
+ val loop = coroutineContext[ContinuationInterceptor ] as EventLoop
22
+
23
+ val task = launch { block() }
24
+ while (! task.isCompleted) {
25
+ val date = NSDate ().addTimeInterval(TIME_QUANTUM ) as NSDate
26
+ NSRunLoop .mainRunLoop.runUntilDate(date)
27
+
28
+ loop.processNextEvent()
29
+ }
30
+ }
Original file line number Diff line number Diff line change
1
+ @file:Suppress(" INVISIBLE_MEMBER" , " INVISIBLE_REFERENCE" )
2
+
3
+ import kotlinx.coroutines.*
4
+ import kotlin.coroutines.*
5
+ import platform.Foundation.*
6
+
7
+ /* *
8
+ * Amount of time any task is processed and can't be rescheduled.
9
+ */
10
+ private const val TIME_QUANTUM = 0.01
11
+
12
+ /* *
13
+ * Test runner for native suspend tests.
14
+ */
15
+ actual fun testSuspend (
16
+ context : CoroutineContext ,
17
+ block : suspend CoroutineScope .() -> Unit
18
+ ): Unit = runBlocking {
19
+ val loop = coroutineContext[ContinuationInterceptor ] as EventLoop
20
+
21
+ val task = launch { block() }
22
+ while (! task.isCompleted) {
23
+ val date = NSDate ().addTimeInterval(TIME_QUANTUM ) as NSDate
24
+ NSRunLoop .mainRunLoop.runUntilDate(date)
25
+
26
+ loop.processNextEvent()
27
+ }
28
+ }
Original file line number Diff line number Diff line change
1
+ @file:Suppress(" INVISIBLE_MEMBER" , " INVISIBLE_REFERENCE" )
2
+
3
+ package io.ktor.test.dispatcher
4
+
5
+ import kotlinx.coroutines.*
6
+ import kotlin.coroutines.*
7
+ import platform.Foundation.*
8
+
9
+ /* *
10
+ * Amount of time any task is processed and can't be rescheduled.
11
+ */
12
+ private const val TIME_QUANTUM = 0.01
13
+
14
+ /* *
15
+ * Test runner for native suspend tests.
16
+ */
17
+ actual fun testSuspend (
18
+ context : CoroutineContext ,
19
+ block : suspend CoroutineScope .() -> Unit
20
+ ): Unit = runBlocking {
21
+ val loop = coroutineContext[ContinuationInterceptor ] as EventLoop
22
+
23
+ val task = launch { block() }
24
+ while (! task.isCompleted) {
25
+ val date = NSDate ().addTimeInterval(TIME_QUANTUM ) as NSDate
26
+ NSRunLoop .mainRunLoop.runUntilDate(date)
27
+
28
+ loop.processNextEvent()
29
+ }
30
+ }
Original file line number Diff line number Diff line change
1
+ @file:Suppress(" INVISIBLE_MEMBER" , " INVISIBLE_REFERENCE" )
2
+
3
+ package io.ktor.test.dispatcher
4
+
5
+ import kotlinx.coroutines.*
6
+ import kotlin.coroutines.*
7
+ import platform.Foundation.*
8
+
9
+ /* *
10
+ * Amount of time any task is processed and can't be rescheduled.
11
+ */
12
+ private const val TIME_QUANTUM = 0.01
13
+
14
+ /* *
15
+ * Test runner for native suspend tests.
16
+ */
17
+ actual fun testSuspend (
18
+ context : CoroutineContext ,
19
+ block : suspend CoroutineScope .() -> Unit
20
+ ): Unit = runBlocking {
21
+ val loop = coroutineContext[ContinuationInterceptor ] as EventLoop
22
+
23
+ val task = launch { block() }
24
+ while (! task.isCompleted) {
25
+ val date = NSDate ().addTimeInterval(TIME_QUANTUM ) as NSDate
26
+ NSRunLoop .mainRunLoop.runUntilDate(date)
27
+
28
+ loop.processNextEvent()
29
+ }
30
+ }
Original file line number Diff line number Diff line change
1
+ @file:Suppress(" INVISIBLE_MEMBER" , " INVISIBLE_REFERENCE" )
2
+
3
+ package io.ktor.test.dispatcher
4
+
5
+ import kotlinx.coroutines.*
6
+ import kotlin.coroutines.*
7
+ import platform.Foundation.*
8
+
9
+ /* *
10
+ * Amount of time any task is processed and can't be rescheduled.
11
+ */
12
+ private const val TIME_QUANTUM = 0.01
13
+
14
+ /* *
15
+ * Test runner for native suspend tests.
16
+ */
17
+ actual fun testSuspend (
18
+ context : CoroutineContext ,
19
+ block : suspend CoroutineScope .() -> Unit
20
+ ): Unit = runBlocking {
21
+ val loop = coroutineContext[ContinuationInterceptor ] as EventLoop
22
+
23
+ val task = launch { block() }
24
+ while (! task.isCompleted) {
25
+ val date = NSDate ().addTimeInterval(TIME_QUANTUM ) as NSDate
26
+ NSRunLoop .mainRunLoop.runUntilDate(date)
27
+
28
+ loop.processNextEvent()
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments