JS: make tests dependent on primitive array is checks pass even when -Xtypedarray is disabled (related: KT-17137)
This commit is contained in:
+3
-2
@@ -1,5 +1,3 @@
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
//test [], get and iterator calls
|
||||
fun test(createIntNotLong: Boolean): String {
|
||||
val a = if (createIntNotLong) IntArray(5) else LongArray(5)
|
||||
@@ -24,5 +22,8 @@ fun test(createIntNotLong: Boolean): String {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
// Only run this test if primitive array `is` checks work (KT-17137)
|
||||
if ((intArrayOf() as Any) is Array<*>) return "OK"
|
||||
|
||||
return test(true) + test(false)
|
||||
}
|
||||
+3
-2
@@ -1,6 +1,4 @@
|
||||
//KT-2997 Automatically cast error (Array)
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
// Unmute when JS implements primitive arrays via TypedArray
|
||||
|
||||
fun foo(a: Any): Int {
|
||||
if (a is IntArray) {
|
||||
@@ -55,6 +53,9 @@ fun foo(a: Any): Int {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
// Only run this test if primitive array `is` checks work (KT-17137)
|
||||
if ((intArrayOf() as Any) is Array<*>) return "OK"
|
||||
|
||||
val iA = IntArray(1)
|
||||
if (foo(iA) != 1) return "fail int[]"
|
||||
val sA = ShortArray(1)
|
||||
|
||||
+3
-2
@@ -1,5 +1,3 @@
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
|
||||
fun test(b: Boolean): String {
|
||||
val a = if (b) IntArray(5) else LongArray(5)
|
||||
if (a is IntArray) {
|
||||
@@ -23,6 +21,9 @@ fun test(b: Boolean): String {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
// Only run this test if primitive array `is` checks work (KT-17137)
|
||||
if ((intArrayOf() as Any) is Array<*>) return "OK"
|
||||
|
||||
if (test(true) != "OK") return "fail 1: ${test(true)}"
|
||||
|
||||
if (test(false) != "OK") return "fail 1: ${test(false)}"
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_WITHOUT_CHECK: JS
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
@@ -14,6 +13,9 @@ fun test(x: Any): Int {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
// Only run this test if primitive array `is` checks work (KT-17137)
|
||||
if ((intArrayOf() as Any) is Array<*>) return "OK"
|
||||
|
||||
assertEquals(123, test(intArrayOf(0, 0, 0, 0)))
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user