aboutsummaryrefslogtreecommitdiff
path: root/app/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/test')
-rw-r--r--app/src/test/kotlin/com/pitchedapps/frost/injectors/CssAssetsTest.kt16
-rw-r--r--app/src/test/kotlin/com/pitchedapps/frost/injectors/JsAssetsTest.kt16
-rw-r--r--app/src/test/kotlin/com/pitchedapps/frost/utils/CoroutineTest.kt45
3 files changed, 77 insertions, 0 deletions
diff --git a/app/src/test/kotlin/com/pitchedapps/frost/injectors/CssAssetsTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/injectors/CssAssetsTest.kt
new file mode 100644
index 00000000..0613d28e
--- /dev/null
+++ b/app/src/test/kotlin/com/pitchedapps/frost/injectors/CssAssetsTest.kt
@@ -0,0 +1,16 @@
+package com.pitchedapps.frost.injectors
+
+import java.io.File
+import kotlin.test.Test
+import kotlin.test.assertTrue
+
+class CssAssetsTest {
+
+ @Test
+ fun verifyAssetsExist() {
+ CssAssets.values().forEach { asset ->
+ val file = File("src/web/assets/css/${asset.folder}/${asset.file}").absoluteFile
+ assertTrue(file.exists(), "${asset.name} not found at ${file.path}")
+ }
+ }
+} \ No newline at end of file
diff --git a/app/src/test/kotlin/com/pitchedapps/frost/injectors/JsAssetsTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/injectors/JsAssetsTest.kt
new file mode 100644
index 00000000..eab62b27
--- /dev/null
+++ b/app/src/test/kotlin/com/pitchedapps/frost/injectors/JsAssetsTest.kt
@@ -0,0 +1,16 @@
+package com.pitchedapps.frost.injectors
+
+import java.io.File
+import kotlin.test.Test
+import kotlin.test.assertTrue
+
+class JsAssetsTest {
+
+ @Test
+ fun verifyAssetsExist() {
+ JsAssets.values().forEach { asset ->
+ val file = File("src/web/assets/js/${asset.file}").absoluteFile
+ assertTrue(file.exists(), "${asset.name} not found at ${file.path}")
+ }
+ }
+} \ No newline at end of file
diff --git a/app/src/test/kotlin/com/pitchedapps/frost/utils/CoroutineTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/utils/CoroutineTest.kt
index fb302648..e93f507c 100644
--- a/app/src/test/kotlin/com/pitchedapps/frost/utils/CoroutineTest.kt
+++ b/app/src/test/kotlin/com/pitchedapps/frost/utils/CoroutineTest.kt
@@ -16,9 +16,11 @@
*/
package com.pitchedapps.frost.utils
+import com.pitchedapps.frost.kotlin.Flyweight
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.GlobalScope
+import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.async
import kotlinx.coroutines.channels.BroadcastChannel
@@ -243,4 +245,47 @@ class CoroutineTest {
)
}
}
+
+ @Test
+ fun exceptionChecks() {
+ val mainTag = "main-test"
+ val mainDispatcher = Executors.newSingleThreadExecutor { r ->
+ Thread(r, mainTag)
+ }.asCoroutineDispatcher()
+ val channel = Channel<Int>()
+
+ val job = SupervisorJob()
+
+ val flyweight = Flyweight<Int, Int>(GlobalScope, 200L) {
+ throw java.lang.RuntimeException("Flyweight exception")
+ }
+
+ suspend fun crash(): Boolean = withContext(Dispatchers.IO) {
+ try {
+ withContext(Dispatchers.Default) {
+ flyweight.fetch(0).await()
+ }
+ true
+ } catch (e: java.lang.Exception) {
+ false
+ }
+ }
+
+ runBlocking(mainDispatcher + job) {
+ launch {
+ val i = channel.receive()
+ println("Received $i")
+ }
+ launch {
+ println("A")
+ println(crash())
+ println("B")
+ channel.offer(1)
+ }
+// launch {
+// delay(2000)
+// job.cancel()
+// }
+ }
+ }
}