[Wasm] stdlib API: make kotlin.assert internal

Being disabled by default
 and not well-documented, these functions cause confusion among early
 adopters as to why their code don't work properly.

Assert APIs need a proper design across Kotlin platforms.
 Since APIs are not available in common code and K/JS, it is premature
  to have such a general feature in a new experimental platform.

Compiler tests:
* Mute tests that rely on assert.
* Replace JVM-specific assert calls with require calls and unmute passed K/JS tests.

Merge-request: KT-MR-8636
Merged-by: Svyatoslav Kuzmich <svyatoslav.kuzmich@jetbrains.com>
This commit is contained in:
Svyatoslav Kuzmich
2023-02-02 07:06:12 +00:00
committed by Space Team
parent a8f547d080
commit abf70a586c
15 changed files with 36 additions and 61 deletions
+2 -2
View File
@@ -40,11 +40,11 @@ abstract class TestFnBase(val type: String) {
abstract fun testBad(x: Any)
protected fun assertIs(x: Any, condition: Boolean) {
assert(condition) { "x is $type: failed for $x" }
require(condition) { "x is $type: failed for $x" }
}
protected fun assertIsNot(x: Any, condition: Boolean) {
assert(condition) { "x !is $type: failed for $x" }
require(condition) { "x !is $type: failed for $x" }
}
}
@@ -43,7 +43,7 @@ inline fun <reified T> assertReifiedIs(x: Any, type: String) {
catch (e: Throwable) {
throw AssertionError("$x is $type: should not throw exceptions, got $e")
}
assert(answer) { "$x is $type: failed" }
require(answer) { "$x is $type: failed" }
}
inline fun <reified T> assertReifiedIsNot(x: Any, type: String) {
@@ -54,7 +54,7 @@ inline fun <reified T> assertReifiedIsNot(x: Any, type: String) {
catch (e: Throwable) {
throw AssertionError("$x !is $type: should not throw exceptions, got $e")
}
assert(answer) { "$x !is $type: failed" }
require(answer) { "$x !is $type: failed" }
}
abstract class TestFnBase(val type: String) {
@@ -16,7 +16,7 @@ inline fun <reified T> assertReifiedIs(x: Any, type: String) {
catch (e: Throwable) {
throw AssertionError("$x is $type: should not throw exceptions, got $e")
}
assert(answer) { "$x is $type: failed" }
require(answer) { "$x is $type: failed" }
}
inline fun <reified T> assertReifiedIsNot(x: Any, type: String) {
@@ -27,7 +27,7 @@ inline fun <reified T> assertReifiedIsNot(x: Any, type: String) {
catch (e: Throwable) {
throw AssertionError("$x !is $type: should not throw exceptions, got $e")
}
assert(answer) { "$x !is $type: failed" }
require(answer) { "$x !is $type: failed" }
}
fun box(): String {
@@ -38,7 +38,7 @@ val fns = arrayOf<Any>(::fn0, ::fn1, ::fn2, ::fn3, ::fn4, ::fn5, ::fn6, ::fn7, :
inline fun safeAsReturnsNull(operation: String, cast: () -> Any?) {
try {
val x = cast()
assert(x == null) { "$operation: should return null, got $x" }
require(x == null) { "$operation: should return null, got $x" }
}
catch (e: Throwable) {
throw AssertionError("$operation: should not throw exceptions, got $e")
@@ -48,7 +48,7 @@ inline fun safeAsReturnsNull(operation: String, cast: () -> Any?) {
inline fun safeAsReturnsNonNull(operation: String, cast: () -> Any?) {
try {
val x = cast()
assert(x != null) { "$operation: should return non-null" }
require(x != null) { "$operation: should return non-null" }
}
catch (e: Throwable) {
throw AssertionError("$operation: should not throw exceptions, got $e")
@@ -11,7 +11,7 @@ fun fn1(x: Any) {}
inline fun safeAsReturnsNull(operation: String, cast: () -> Any?) {
try {
val x = cast()
assert(x == null) { "$operation: should return null, got $x" }
require(x == null) { "$operation: should return null, got $x" }
}
catch (e: Throwable) {
throw AssertionError("$operation: should not throw exceptions, got $e")
@@ -21,7 +21,7 @@ inline fun safeAsReturnsNull(operation: String, cast: () -> Any?) {
inline fun safeAsReturnsNonNull(operation: String, cast: () -> Any?) {
try {
val x = cast()
assert(x != null) { "$operation: should return non-null" }
require(x != null) { "$operation: should return non-null" }
}
catch (e: Throwable) {
throw AssertionError("$operation: should not throw exceptions, got $e")