[WASM] Add command line option to enable/disable assertions

This commit is contained in:
Igor Laevsky
2022-04-21 19:57:59 +03:00
committed by teamcity
parent c38985c93e
commit 3de1235fda
9 changed files with 25 additions and 9 deletions
+1 -1
View File
@@ -143,7 +143,7 @@ val compileTestKotlinWasm by tasks.existing(KotlinCompile::class) {
}
tasks.named<KotlinJsIrLink>("compileTestDevelopmentExecutableKotlinWasm") {
(this as KotlinCompile<*>).kotlinOptions.freeCompilerArgs += "-Xwasm-enable-array-range-checks"
(this as KotlinCompile<*>).kotlinOptions.freeCompilerArgs += listOf("-Xwasm-enable-array-range-checks", "-Xwasm-enable-asserts")
}
val runtimeElements by configurations.creating {}
@@ -5,13 +5,11 @@
package kotlin
// TODO: Make this dependant on the compiler flag (like -ea on JVM)
/**
* Throws an [AssertionError] if the [value] is false.
*/
@kotlin.internal.InlineOnly
public inline fun assert(value: Boolean) {
public fun assert(value: Boolean) {
assert(value) { "Assertion failed" }
}
@@ -19,7 +17,7 @@ public inline fun assert(value: Boolean) {
* Throws an [AssertionError] calculated by [lazyMessage] if the [value] is false.
*/
@kotlin.internal.InlineOnly
public inline fun assert(value: Boolean, lazyMessage: () -> Any) {
public fun assert(value: Boolean, lazyMessage: () -> Any) {
if (!value) {
val message = lazyMessage()
throw AssertionError(message)