File tree Expand file tree Collapse file tree 4 files changed +38
-8
lines changed
kotlinx-coroutines-core/js/test Expand file tree Collapse file tree 4 files changed +38
-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
@@ -135,7 +141,7 @@ public actual open class TestBase actual constructor() {
135
141
check(actionIndex == 0 || finished) { " Expecting that 'finish(...)' was invoked, but it was not" }
136
142
}
137
143
lastTestPromise = result
138
- return result
144
+ return result as MyPromise
139
145
}
140
146
}
141
147
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ class TestDispatchersTest: OrderedExecutionTestBase() {
22
22
23
23
/* * Tests that asynchronous execution of tests does not happen concurrently with [AfterTest]. */
24
24
@Test
25
+ @NoJs // doesn't work because of KT-63359
25
26
fun testMainMocking () = runTest {
26
27
val mainAtStart = TestMainDispatcher .currentTestDispatcher
27
28
assertNotNull(mainAtStart)
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