File tree 3 files changed +37
-8
lines changed
kotlinx-coroutines-core/js/test
kotlinx-coroutines-test/js/src
3 files changed +37
-8
lines changed Original file line number Diff line number Diff line change @@ -10,8 +10,14 @@ public actual val isStressTest: Boolean = false
10
10
public actual val stressTestMultiplier: Int = 1
11
11
public actual val stressTestMultiplierSqrt: Int = 1
12
12
13
- @Suppress(" ACTUAL_WITHOUT_EXPECT" , " ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE" )
14
- public actual typealias TestResult = Promise <Unit >
13
+ @JsName(" Promise" )
14
+ external class MyPromise {
15
+ fun then (onFulfilled : ((Unit ) -> Unit ), onRejected : ((Throwable ) -> Unit )): MyPromise
16
+ fun then (onFulfilled : ((Unit ) -> Unit )): MyPromise
17
+ }
18
+
19
+ /* * Always a `Promise<Unit>` */
20
+ public actual typealias TestResult = MyPromise
15
21
16
22
public actual val isNative = false
17
23
@@ -131,7 +137,7 @@ public actual open class TestBase actual constructor() {
131
137
check(actionIndex == 0 || finished) { " Expecting that 'finish(...)' was invoked, but it was not" }
132
138
}
133
139
lastTestPromise = result
134
- return result
140
+ return result as MyPromise
135
141
}
136
142
}
137
143
Original file line number Diff line number Diff line change 3
3
*/
4
4
5
5
package kotlinx.coroutines.test
6
+
6
7
import kotlinx.coroutines.*
7
- import kotlin.js .*
8
+ import kotlinx.coroutines.test.internal .*
8
9
9
- @Suppress(" ACTUAL_WITHOUT_EXPECT" , " ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE" )
10
- public actual typealias TestResult = Promise <Unit >
10
+ public actual typealias TestResult = JsPromiseInterfaceForTesting
11
11
12
12
internal actual fun createTestResult (testProcedure : suspend CoroutineScope .() -> Unit ): TestResult =
13
13
GlobalScope .promise {
14
14
testProcedure()
15
- }
15
+ } as JsPromiseInterfaceForTesting
16
16
17
- internal actual fun dumpCoroutines () { }
17
+ internal actual fun dumpCoroutines () {}
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3
+ */
4
+
5
+ package kotlinx.coroutines.test.internal
6
+
7
+ /* This is a declaration of JS's `Promise<Unit>`. We need to keep it a separate class, because
8
+ `actual typealias TestResult = Promise<Unit>` fails: you can't instantiate an `expect class` with a typealias to
9
+ a parametric class. So, we make a non-parametric class just for this. */
10
+ /* *
11
+ * @suppress
12
+ */
13
+ @JsName(" Promise" )
14
+ public external class JsPromiseInterfaceForTesting {
15
+ /* *
16
+ * @suppress
17
+ */
18
+ public fun then (onFulfilled : ((Unit ) -> Unit ), onRejected : ((Throwable ) -> Unit )): JsPromiseInterfaceForTesting
19
+ /* *
20
+ * @suppress
21
+ */
22
+ public fun then (onFulfilled : ((Unit ) -> Unit )): JsPromiseInterfaceForTesting
23
+ }
You can’t perform that action at this time.
0 commit comments