[K/N][Tests] Adjust moved codegen tests to new infra

^KT-61259
This commit is contained in:
Vladimir Sukharev
2023-12-14 20:14:47 +01:00
committed by Space Team
parent 71a834b778
commit 73032213f0
295 changed files with 1362 additions and 1145 deletions
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.escapeAnalysis.negativeArraySize
import kotlin.test.*
const val size = -42
@@ -14,6 +12,8 @@ fun foo() {
for (x in arr) println(x)
}
@Test fun runTest() {
fun box(): String {
assertFailsWith<IllegalArgumentException> { foo() }
return "OK"
}
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.escapeAnalysis.recursion
import kotlin.test.*
class A {
@@ -19,6 +17,8 @@ fun foo(k: Int, a1: A, a2: A): A {
return foo(k - 1, a2, a3)
}
@Test fun runTest() {
fun box(): String {
foo(3, A(), A()).toString()
return "OK"
}
@@ -2,8 +2,8 @@
* Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.escapeAnalysis.stackAllocated
// IGNORE_NATIVE: optimizationMode=DEBUG
// IGNORE_NATIVE: optimizationMode=NO
import kotlin.test.*
import kotlin.native.internal.*
@@ -18,6 +18,8 @@ fun f(x: Int): Int {
return a.f(x)
}
@Test fun runTest() {
fun box(): String {
assertEquals(f(42), 55)
return "OK"
}
@@ -2,13 +2,15 @@
* Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.escapeAnalysis.string
// IGNORE_NATIVE: optimizationMode=DEBUG
// IGNORE_NATIVE: optimizationMode=NO
import kotlin.test.*
import kotlin.native.internal.*
@Test fun runTest() {
fun box(): String {
val s = String()
assertTrue(s.isLocal())
return "OK"
}
@@ -0,0 +1,23 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
// IGNORE_NATIVE: optimizationMode=OPT
import kotlin.test.*
import kotlin.native.internal.*
class A {
fun f(x: Int) = x + 13
}
fun f(x: Int): Int {
val a = A()
assertFalse(a.isLocal())
return a.f(x)
}
fun box(): String {
assertEquals(f(42), 55)
return "OK"
}
@@ -0,0 +1,15 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
// IGNORE_NATIVE: optimizationMode=OPT
import kotlin.test.*
import kotlin.native.internal.*
fun box(): String {
val s = String()
assertFalse(s.isLocal())
return "OK"
}
@@ -3,15 +3,15 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package codegen.escapeAnalysis.stack_array
import kotlin.test.*
@Test fun runTest() {
fun box(): String {
val array = IntArray(2)
array[0] = 1
array[1] = 2
val check = array is IntArray
println(check)
println(array[0] + array[1])
assertTrue(check)
assertEquals(3, array[0] + array[1])
return "OK"
}
@@ -1,2 +0,0 @@
true
3
@@ -2,8 +2,7 @@
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.escapeAnalysis.test1
// TODO: check mentioned debug output of escape analyser
class A(val s: String)
@@ -17,4 +16,4 @@ class A(val s: String)
// Escapes:
fun foo(a: A) = a
fun main() = println(foo(A("zzz")))
fun box(): String = foo(A("OK")).s
@@ -2,8 +2,8 @@
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.escapeAnalysis.test10
// TODO: check mentioned debug output of escape analyser
import kotlin.test.*
class G(val x: Int)
@@ -38,4 +38,7 @@ fun bar(): F {
return u
}
fun main() = println(bar().g.x)
fun box(): String {
assertEquals(42, bar().g.x)
return "OK"
}
@@ -2,8 +2,8 @@
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.escapeAnalysis.test11
// TODO: check mentioned debug output of escape analyser
import kotlin.test.*
class F(val x: Int)
@@ -28,4 +28,7 @@ fun foo(a: A): F {
return a.f
}
fun main() = println(foo(A("zzz")))
fun box(): String {
assertEquals(0, foo(A("zzz")).x)
return "OK"
}
@@ -2,8 +2,7 @@
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.escapeAnalysis.test12
// TODO: check mentioned debug output of escape analyser
class A(val s: String)
@@ -17,4 +16,4 @@ class A(val s: String)
// Escapes:
fun foo(arr: Array<A>) = arr[0]
fun main() = println(foo(arrayOf(A("zzz"))).s)
fun box(): String = foo(arrayOf(A("OK"))).s
@@ -2,8 +2,7 @@
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.escapeAnalysis.test13
import kotlin.test.*
class A {
var f: A? = null
@@ -13,8 +12,10 @@ fun foo(a: A, k: Int): A {
return if (k == 0) a else foo(a.f!!, k - 1)
}
fun main() {
fun box(): String {
val a = A()
a.f = A()
println(foo(a, 1))
val a2 = A()
a.f = a2
assertEquals(a2, foo(a, 1))
return "OK"
}
@@ -2,8 +2,7 @@
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.escapeAnalysis.test2
// TODO: check mentioned debug output of escape analyser
class A(val s: String)
@@ -17,4 +16,4 @@ class A(val s: String)
// Escapes:
fun foo(a: A) = a.s
fun main() = println(foo(A("zzz")))
fun box(): String = foo(A("OK"))
@@ -2,8 +2,7 @@
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.escapeAnalysis.test3
// TODO: check mentioned debug output of escape analyser
class A(val s: String)
class B {
@@ -25,4 +24,4 @@ fun foo(a: A, b: B): String {
return a.s
}
fun main() = println(foo(A("zzz"), B()))
fun box(): String = foo(A("OK"), B())
@@ -2,8 +2,7 @@
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.escapeAnalysis.test4
// TODO: check mentioned debug output of escape analyser
class A(val s: String)
class B {
@@ -27,4 +26,7 @@ fun foo(c1: C, c2: C) {
c1.g.f = c2.g.f
}
fun main() = println(foo(C(), C()))
fun box(): String {
foo(C(), C())
return "OK"
}
@@ -2,12 +2,11 @@
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.escapeAnalysis.test5
// TODO: check mentioned debug output of escape analyser
class A(val s: String)
class B {
var f: A = A("qzz")
var f: A = A("OK")
}
class C {
var g: B = B()
@@ -32,4 +31,4 @@ fun foo(c1: C, c2: C): B {
return b
}
fun main() = println(foo(C(), C()))
fun box(): String = foo(C(), C()).f.s
@@ -2,8 +2,7 @@
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.escapeAnalysis.test6
// TODO: check mentioned debug output of escape analyser
class A(val s: String)
class B {
@@ -37,4 +36,4 @@ fun foo(z: Boolean, c1: C, c2: C, a: A): B {
return v
}
fun main() = println(foo(true, C(), C(), A("zzz")))
fun box(): String = foo(true, C(), C(), A("OK")).f.s
@@ -2,9 +2,9 @@
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
// TODO: check mentioned debug output of escape analyser
package codegen.escapeAnalysis.test7
// Note: intentional infinite mutual recursion with `A(String)` and `C()`. Don't try to execute the code.
class A(val s: String) {
var h: String = ""
var p: C = C()
@@ -49,4 +49,8 @@ fun foo(z: Boolean, c: C, b: B, s: String, d: D) {
u.p = c
}
fun main() = println(foo(true, C(), B(), "zzz", D()))
fun box(): String {
// When uncommented, execution of the following line would fall into infinite recursion
// foo(true, C(), B(), "zzz", D())
return "OK"
}
@@ -2,11 +2,11 @@
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
// TODO: check mentioned debug output of escape analyser
package codegen.escapeAnalysis.test8
// Note: intentional infinite recursion for F(String). Don't try to execute the code.
class F(val s: String) {
var g = F("")
var g = F("OK")
}
class A {
@@ -40,4 +40,8 @@ fun foo(a: A): F {
return a.f.g.g
}
fun main() = println(foo(A()).s)
fun box(): String {
// When uncommented, execution of the following line would fall into infinite recursion
// foo(A()).s
return "OK"
}
@@ -2,11 +2,12 @@
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.escapeAnalysis.test9
// TODO: check mentioned debug output of escape analyser
import kotlin.test.*
class H(val x: Int)
// Note: intentional infinite recursion for F(String). Don't try to execute the code.
class F(val s: String) {
var g = F("")
var h = H(0)
@@ -33,4 +34,8 @@ fun foo(a: A, f: F): H {
return f.g.h
}
fun main() = println(foo(A(), F("zzz")).x)
fun box(): String {
// When uncommented, execution of the following line would fall into infinite recursion
// assertEquals(0, foo(A(), F("zzz")).x)
return "OK"
}
@@ -3,15 +3,13 @@
* that can be found in the LICENSE file.
*/
package codegen.escapeAnalysis.zeroOutObjectOnAlloc
import kotlin.test.*
class A {
var x = 0
}
@Test fun runTest() {
fun box(): String {
var sum1 = 0
var sum2 = 0
for (i in 0 until 10) {
@@ -22,4 +20,6 @@ class A {
}
assertEquals(0, sum1)
assertEquals(45, sum2)
return "OK"
}