[Wasm] Run unit tests for the wasm stdlib (fail on verifier for now)
This commit is contained in:
@@ -53,10 +53,32 @@ val commonMainSources by task<Sync> {
|
||||
into("$buildDir/commonMainSources")
|
||||
}
|
||||
|
||||
val commonTestSources by task<Sync> {
|
||||
val sources = listOf(
|
||||
"libraries/stdlib/test/",
|
||||
"libraries/stdlib/common/test/"
|
||||
)
|
||||
|
||||
sources.forEach { path ->
|
||||
from("$rootDir/$path") {
|
||||
into(path.dropLastWhile { it != '/' })
|
||||
}
|
||||
}
|
||||
|
||||
into("$buildDir/commonTestSources")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
wasm {
|
||||
nodejs()
|
||||
nodejs {
|
||||
testTask {
|
||||
useMocha {
|
||||
timeout = "10s"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val wasmMain by getting {
|
||||
kotlin.srcDirs("builtins", "internal", "runtime", "src", "stubs")
|
||||
@@ -67,6 +89,20 @@ kotlin {
|
||||
val commonMain by getting {
|
||||
kotlin.srcDirs(files(commonMainSources.map { it.destinationDir }))
|
||||
}
|
||||
|
||||
val commonTest by getting {
|
||||
dependencies {
|
||||
api(project(":kotlin-test:kotlin-test-wasm"))
|
||||
}
|
||||
kotlin.srcDir(files(commonTestSources.map { it.destinationDir }))
|
||||
}
|
||||
|
||||
val wasmTest by getting {
|
||||
dependencies {
|
||||
api(project(":kotlin-test:kotlin-test-wasm"))
|
||||
}
|
||||
kotlin.srcDir("$rootDir/libraries/stdlib/wasm/test/")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +126,15 @@ tasks.named("compileKotlinWasm") {
|
||||
dependsOn(builtInsSources)
|
||||
}
|
||||
|
||||
val compileTestKotlinWasm by tasks.existing(KotlinCompile::class) {
|
||||
val sources: FileCollection = kotlin.sourceSets["commonTest"].kotlin
|
||||
doFirst {
|
||||
// Note: common test sources are copied to the actual source directory by commonMainSources task,
|
||||
// so can't do this at configuration time:
|
||||
kotlinOptions.freeCompilerArgs += listOf("-Xcommon-sources=${sources.joinToString(",")}")
|
||||
}
|
||||
}
|
||||
|
||||
val runtimeElements by configurations.creating {}
|
||||
val apiElements by configurations.creating {}
|
||||
|
||||
|
||||
@@ -1493,6 +1493,18 @@ public class Float private constructor(public val value: Float) : Number(), Comp
|
||||
*/
|
||||
@Suppress("DIVISION_BY_ZERO")
|
||||
public val NaN: Float = 0.0f / 0.0f
|
||||
|
||||
/**
|
||||
* The number of bytes used to represent an instance of Float in a binary form.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
public const val SIZE_BYTES: Int = 4
|
||||
|
||||
/**
|
||||
* The number of bits used to represent an instance of Float in a binary form.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
public const val SIZE_BITS: Int = 32
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1801,6 +1813,18 @@ public class Double private constructor(public val value: Double) : Number(), Co
|
||||
*/
|
||||
@Suppress("DIVISION_BY_ZERO")
|
||||
public val NaN: Double = 0.0 / 0.0
|
||||
|
||||
/**
|
||||
* The number of bytes used to represent an instance of Double in a binary form.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
public const val SIZE_BYTES: Int = 8
|
||||
|
||||
/**
|
||||
* The number of bits used to represent an instance of Double in a binary form.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
public const val SIZE_BITS: Int = 64
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package test.collections.js
|
||||
|
||||
public actual fun <V> stringMapOf(vararg pairs: Pair<String, V>): HashMap<String, V> = hashMapOf<String, V>(*pairs)
|
||||
public actual fun <V> linkedStringMapOf(vararg pairs: Pair<String, V>): LinkedHashMap<String, V> = linkedMapOf(*pairs)
|
||||
public actual fun stringSetOf(vararg elements: String): HashSet<String> = hashSetOf(*elements)
|
||||
public actual fun linkedStringSetOf(vararg elements: String): LinkedHashSet<String> = linkedSetOf(*elements)
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package test.text
|
||||
|
||||
// TODO: Fix this once we implement kotlin.text
|
||||
internal actual val surrogateCodePointDecoding: String = "�"
|
||||
|
||||
internal actual val surrogateCharEncoding: ByteArray = byteArrayOf(0x3F)
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package test
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
public actual fun assertTypeEquals(expected: Any?, actual: Any?) {
|
||||
TODO("Implement class references")
|
||||
//assertEquals(expected?.let { it::class.js }, actual?.let { it::class.js })
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
internal actual inline fun String.removeLeadingPlusOnJava6(): String = this
|
||||
|
||||
internal actual inline fun testOnNonJvm6And7(f: () -> Unit) {
|
||||
f()
|
||||
}
|
||||
|
||||
|
||||
public actual fun testOnJvm(action: () -> Unit) { }
|
||||
public actual fun testOnJs(action: () -> Unit) { }
|
||||
|
||||
// TODO: See KT-24975
|
||||
public actual val isFloat32RangeEnforced: Boolean = false
|
||||
|
||||
// TODO: We need to implement this on wasm
|
||||
actual val supportsSuppressedExceptions: Boolean get() = false
|
||||
|
||||
// TODO: implement named group reference in replacement expression
|
||||
public actual val supportsNamedCapturingGroup: Boolean get() = false
|
||||
Reference in New Issue
Block a user