JVM_IR KT-29822 KT-48669 loop over unsigned array, indices, withIndex

This commit is contained in:
Dmitry Petrov
2021-09-21 19:35:21 +03:00
committed by TeamCityServer
parent 2cc6b589f3
commit be28b3c74d
28 changed files with 819 additions and 8 deletions
@@ -0,0 +1,17 @@
// WITH_RUNTIME
// IGNORE_BACKEND: WASM
fun test(uis: UIntArray): String {
var s = ""
for (ui in uis) {
s += ui
}
return s
}
fun box(): String {
val test = test(uintArrayOf(1U, 2U, 3U))
if (test != "123") return "Failed: $test"
return "OK"
}
@@ -0,0 +1,17 @@
// WITH_RUNTIME
// IGNORE_BACKEND: WASM
fun test(uis: UIntArray): String {
var s = ""
for (i in uis.indices) {
s += "$i:${uis[i]};"
}
return s
}
fun box(): String {
val test = test(uintArrayOf(1U, 2U, 3U))
if (test != "0:1;1:2;2:3;") return "Failed: $test"
return "OK"
}
@@ -0,0 +1,17 @@
// WITH_RUNTIME
// IGNORE_BACKEND: WASM
fun test(uis: UIntArray): String {
var s = ""
for (i in uis.indices.reversed()) {
s += "$i:${uis[i]};"
}
return s
}
fun box(): String {
val test = test(uintArrayOf(1U, 2U, 3U))
if (test != "2:3;1:2;0:1;") return "Failed: $test"
return "OK"
}
@@ -0,0 +1,17 @@
// WITH_RUNTIME
// IGNORE_BACKEND: WASM
fun test(uis: UIntArray): String {
var s = ""
for (ui in uis.reversed()) {
s += ui
}
return s
}
fun box(): String {
val test = test(uintArrayOf(1U, 2U, 3U))
if (test != "321") return "Failed: $test"
return "OK"
}
@@ -0,0 +1,17 @@
// WITH_RUNTIME
// IGNORE_BACKEND: WASM
fun test(uis: UIntArray): String {
var s = ""
for ((i, ui) in uis.withIndex()) {
s += "$i:$ui;"
}
return s
}
fun box(): String {
val test = test(uintArrayOf(1U, 2U, 3U))
if (test != "0:1;1:2;2:3;") return "Failed: $test"
return "OK"
}
@@ -0,0 +1,17 @@
// WITH_RUNTIME
// IGNORE_BACKEND: WASM
fun test(uis: UIntArray): String {
var s = ""
for ((i, _) in uis.withIndex()) {
s += "$i:${uis[i]};"
}
return s
}
fun box(): String {
val test = test(uintArrayOf(1U, 2U, 3U))
if (test != "0:1;1:2;2:3;") return "Failed: $test"
return "OK"
}
@@ -0,0 +1,17 @@
// WITH_RUNTIME
// IGNORE_BACKEND: WASM
fun test(uis: UIntArray): String {
var s = ""
for ((_, ui) in uis.withIndex()) {
s += ui
}
return s
}
fun box(): String {
val test = test(uintArrayOf(1U, 2U, 3U))
if (test != "123") return "Failed: $test"
return "OK"
}
@@ -0,0 +1,17 @@
// WITH_RUNTIME
// IGNORE_BACKEND: WASM
fun test(uis: UIntArray): String {
var s = ""
for ((i, ui) in uis.withIndex().reversed()) {
s += "$i:$ui;"
}
return s
}
fun box(): String {
val test = test(uintArrayOf(1U, 2U, 3U))
if (test != "2:3;1:2;0:1;") return "Failed: $test"
return "OK"
}
@@ -47,7 +47,9 @@ fun testLong() {
s += i
if (t > 2) throw Exception("too many iterations: $t")
}
if (s != "-9223372036854775807-9223372036854775808") throw Exception(s)
if (s != "-9223372036854775807-9223372036854775808" &&
s != "-9223372036854776000-9223372036854776000" // JS
) throw Exception(s)
}
fun testChar() {