summaryrefslogtreecommitdiff
path: root/sw-ui-kt/src/test/kotlin
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@booking.com>2020-03-27 10:38:21 +0100
committerJoffrey Bion <joffrey.bion@booking.com>2020-03-27 10:59:39 +0100
commitea07b9685836c9231230ec1c728cea0c8eef5958 (patch)
tree97591060aaff2668e7d8658ab712d09e1d8b1e83 /sw-ui-kt/src/test/kotlin
parentAdd sagas and components for game scene (diff)
downloadseven-wonders-ea07b9685836c9231230ec1c728cea0c8eef5958.tar.gz
seven-wonders-ea07b9685836c9231230ec1c728cea0c8eef5958.tar.bz2
seven-wonders-ea07b9685836c9231230ec1c728cea0c8eef5958.zip
Fix awaitFirst (crashes when inlined)
Diffstat (limited to 'sw-ui-kt/src/test/kotlin')
-rw-r--r--sw-ui-kt/src/test/kotlin/org/luxons/sevenwonders/ui/utils/CoroutineUtilsTest.kt24
1 files changed, 24 insertions, 0 deletions
diff --git a/sw-ui-kt/src/test/kotlin/org/luxons/sevenwonders/ui/utils/CoroutineUtilsTest.kt b/sw-ui-kt/src/test/kotlin/org/luxons/sevenwonders/ui/utils/CoroutineUtilsTest.kt
new file mode 100644
index 00000000..d633f6f2
--- /dev/null
+++ b/sw-ui-kt/src/test/kotlin/org/luxons/sevenwonders/ui/utils/CoroutineUtilsTest.kt
@@ -0,0 +1,24 @@
+package org.luxons.sevenwonders.ui.utils
+
+import kotlinx.coroutines.GlobalScope
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.promise
+import kotlin.test.Test
+import kotlin.test.assertEquals
+
+class CoroutineUtilsTest {
+
+ @Test
+ fun awaitFirstTest(): dynamic = GlobalScope.promise {
+ val s = awaitFirst(
+ { delay(100); "1" },
+ { delay(200); "2" }
+ )
+ assertEquals("1", s)
+ val s2 = awaitFirst(
+ { delay(150); "1" },
+ { delay(50); "2" }
+ )
+ assertEquals("2", s2)
+ }
+}
bgstack15