diff options
author | Allan Wang <me@allanwang.ca> | 2019-02-05 23:16:29 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-05 23:16:29 -0500 |
commit | 8e3bfc168009c8682c4f6191d655f3ca10ae9f21 (patch) | |
tree | cf8419a06e193c08622ead5e6854b995a5eeba77 /app/src/test/kotlin/com | |
parent | 83fb36f666fbb934b74b5f763b8ffb2e56ca7761 (diff) | |
parent | ddfc310fde5f50ba52ef930287449c2e08faaca8 (diff) | |
download | frost-8e3bfc168009c8682c4f6191d655f3ca10ae9f21.tar.gz frost-8e3bfc168009c8682c4f6191d655f3ca10ae9f21.tar.bz2 frost-8e3bfc168009c8682c4f6191d655f3ca10ae9f21.zip |
Merge pull request #1334 from AllanWang/fix/offline-crash
Fix/offline crash
Diffstat (limited to 'app/src/test/kotlin/com')
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() +// } + } + } } |