Skip to content

Commit cee9597

Browse files
JakeWhartonevant
authored andcommitted
Add support for WASM target
1 parent f64f07d commit cee9597

File tree

15 files changed

+112
-8
lines changed

15 files changed

+112
-8
lines changed

assertk/build.gradle.kts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
2+
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.common
3+
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.wasm
4+
15
plugins {
26
id("assertk.multiplatform")
37
id("assertk.publish")
@@ -25,11 +29,9 @@ kotlin {
2529
}
2630
kotlin.srcDir(compileTemplates)
2731
}
28-
commonTest {
32+
val commonTest by getting {
2933
dependencies {
3034
implementation(kotlin("test"))
31-
implementation(libs.kotlinx.coroutines)
32-
implementation(libs.kotlinx.coroutines.test)
3335
}
3436
kotlin.srcDir(compileTestTemplates)
3537
}
@@ -43,5 +45,21 @@ kotlin {
4345
implementation(kotlin("reflect"))
4446
}
4547
}
48+
49+
val coroutinesTest by creating {
50+
dependsOn(commonTest)
51+
dependencies {
52+
implementation(libs.kotlinx.coroutines)
53+
implementation(libs.kotlinx.coroutines.test)
54+
}
55+
}
56+
}
57+
58+
targets.configureEach {
59+
if (platformType != common && platformType != wasm) {
60+
compilations.getByName("test")
61+
.defaultSourceSet
62+
.dependsOn(sourceSets.getByName("coroutinesTest"))
63+
}
4664
}
47-
}
65+
}

assertk/src/commonTest/kotlin/test/assertk/AssertFailureTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import assertk.assertions.isEqualTo
55
import assertk.assertions.isInstanceOf
66
import assertk.assertions.message
77
import com.willowtreeapps.opentest4k.AssertionFailedError
8-
import kotlinx.coroutines.test.runTest
98
import test.assertk.assertions.valueOrFail
109
import kotlin.coroutines.resume
1110
import kotlin.coroutines.resumeWithException

assertk/src/commonTest/kotlin/test/assertk/AssertLambdaTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import assertk.assertions.isSuccess
88
import test.assertk.assertions.valueOrFail
99
import kotlin.test.Test
1010
import kotlin.test.assertEquals
11-
import kotlinx.coroutines.test.runTest
1211

1312
@Suppress("DEPRECATION_ERROR")
1413
class AssertLambdaTest {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package test.assertk
2+
3+
/**
4+
* A quick shim for common, coroutine-based tests since the coroutines library
5+
* does not yet support WASM target.
6+
*/
7+
expect fun runTest(block: suspend () -> Unit)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package test.assertk
2+
3+
actual fun runTest(block: suspend () -> Unit) {
4+
kotlinx.coroutines.test.runTest { block() }
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package assertk
2+
3+
actual annotation class PlatformName(actual val name: String)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package assertk
2+
3+
/*
4+
* Copyright (C) 2018 Touchlab, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
actual open class ThreadLocalRef<T> actual constructor(initial: () -> T) {
19+
private var localValue: T = initial()
20+
21+
actual fun get(): T = localValue
22+
23+
actual fun set(value: T) {
24+
localValue = value
25+
}
26+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package assertk.assertions.support
2+
3+
internal actual fun displayPlatformSpecific(value: Any?): String {
4+
return value.toString()
5+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@file:Suppress("NOTHING_TO_INLINE")
2+
3+
package assertk
4+
5+
internal actual inline fun failWithNotInStacktrace(error: Throwable): Nothing {
6+
throw error
7+
}
8+
9+
internal actual inline fun Throwable.addSuppressed(error: Throwable) {
10+
// ignore
11+
}
12+
13+
internal actual inline fun Throwable.isOutOfMemory(): Boolean = false
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package assertk
2+
3+
import assertk.assertions.support.show
4+
5+
internal actual fun showError(e: Throwable) = show(e)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy