[Tests] Migrate backend-independent tests from native to compiler/testData.

^KT-65979
This commit is contained in:
Vladimir Sukharev
2024-02-25 18:25:58 +01:00
committed by Space Team
parent dd9332d9e1
commit febac0dd5f
640 changed files with 68168 additions and 6313 deletions
@@ -1,24 +0,0 @@
/*
* 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.
*/
import kotlin.test.*
class A {
var f: A? = null
}
fun foo(k: Int, a1: A, a2: A): A {
val a3 = A()
if (k == 0)
return a1
a3.f = a1
return foo(k - 1, a2, a3)
}
fun box(): String {
foo(3, A(), A()).toString()
return "OK"
}
@@ -1,17 +0,0 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
import kotlin.test.*
fun box(): String {
val array = IntArray(2)
array[0] = 1
array[1] = 2
val check = array is IntArray
assertTrue(check)
assertEquals(3, array[0] + array[1])
return "OK"
}
@@ -1,19 +0,0 @@
/*
* 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
class A(val s: String)
// ----- Agressive -----
// PointsTo:
// RET.v@lue -> P0
// Escapes:
// ----- Passive -----
// PointsTo:
// RET.v@lue -> P0
// Escapes:
fun foo(a: A) = a
fun box(): String = foo(A("OK")).s
@@ -1,44 +0,0 @@
/*
* 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
import kotlin.test.*
class G(val x: Int)
class F(val s: String) {
var g = G(0)
}
class A {
var f = F("")
}
// ----- Agressive -----
// PointsTo:
// P0.f -> D0
// RET.v@lue -> D0
// Escapes:
// ----- Passive -----
// PointsTo:
// P0.f -> D0
// RET.v@lue -> D0
// Escapes: D0
fun foo(a: A): F {
val v = F("zzz")
a.f = v
return v
}
fun bar(): F {
val w = A()
val u = foo(w)
w.f.g = G(42)
return u
}
fun box(): String {
assertEquals(42, bar().g.x)
return "OK"
}
@@ -1,34 +0,0 @@
/*
* 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
import kotlin.test.*
class F(val x: Int)
class A(val s: String) {
var f = F(0)
}
var f: F? = null
// ----- Agressive -----
// PointsTo:
// RET.v@lue -> P0.f
// D0 -> P0.f
// Escapes: D0
// ----- Passive -----
// PointsTo:
// RET.v@lue -> P0.f
// D0 -> P0.f
// Escapes: D0
fun foo(a: A): F {
f = a.f
return a.f
}
fun box(): String {
assertEquals(0, foo(A("zzz")).x)
return "OK"
}
@@ -1,19 +0,0 @@
/*
* 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
class A(val s: String)
// ----- Agressive -----
// PointsTo:
// RET.v@lue -> P0.inte$tines
// Escapes:
// ----- Passive -----
// PointsTo:
// RET.v@lue -> P0.inte$tines
// Escapes:
fun foo(arr: Array<A>) = arr[0]
fun box(): String = foo(arrayOf(A("OK"))).s
@@ -1,21 +0,0 @@
/*
* 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.
*/
import kotlin.test.*
class A {
var f: A? = null
}
fun foo(a: A, k: Int): A {
return if (k == 0) a else foo(a.f!!, k - 1)
}
fun box(): String {
val a = A()
val a2 = A()
a.f = a2
assertEquals(a2, foo(a, 1))
return "OK"
}
@@ -1,19 +0,0 @@
/*
* 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
class A(val s: String)
// ----- Agressive -----
// PointsTo:
// RET.v@lue -> P0.s
// Escapes:
// ----- Passive -----
// PointsTo:
// RET.v@lue -> P0.s
// Escapes:
fun foo(a: A) = a.s
fun box(): String = foo(A("OK"))
@@ -1,27 +0,0 @@
/*
* 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
class A(val s: String)
class B {
var s: String? = null
}
// ----- Agressive -----
// PointsTo:
// P1.s -> P0.s
// RET.v@lue -> P0.s
// Escapes:
// ----- Passive -----
// PointsTo:
// P1.s -> P0.s
// RET.v@lue -> P0.s
// Escapes:
fun foo(a: A, b: B): String {
b.s = a.s
return a.s
}
fun box(): String = foo(A("OK"), B())
@@ -1,32 +0,0 @@
/*
* 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
class A(val s: String)
class B {
var f: A = A("qzz")
}
class C {
var g: B = B()
}
// ----- Agressive -----
// PointsTo:
// P0.g.f -> P1.g.f
// RET.v@lue -> D0
// Escapes: D0
// ----- Passive -----
// PointsTo:
// P0.g.f -> P1.g.f
// RET.v@lue -> D0
// Escapes: D0
fun foo(c1: C, c2: C) {
c1.g.f = c2.g.f
}
fun box(): String {
foo(C(), C())
return "OK"
}
@@ -1,34 +0,0 @@
/*
* 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
class A(val s: String)
class B {
var f: A = A("OK")
}
class C {
var g: B = B()
}
// ----- Agressive -----
// PointsTo:
// RET.v@lue -> D0
// D0.f -> P0.g.f
// Escapes:
// ----- Passive -----
// PointsTo:
// P0.g.f -> D2
// RET.v@lue -> D0
// D0.f -> P0.g.f
// D0.f -> D1
// D1 -> D2
// Escapes: D0 D1
fun foo(c1: C, c2: C): B {
val b = B()
b.f = c1.g.f
return b
}
fun box(): String = foo(C(), C()).f.s
@@ -1,39 +0,0 @@
/*
* 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
class A(val s: String)
class B {
var f: A = A("qzz")
}
class C {
var g: B = B()
}
// ----- Agressive -----
// PointsTo:
// P1.g -> D0
// P2.g -> D0
// RET.v@lue -> P1.g
// RET.v@lue -> P2.g
// RET.v@lue -> D0
// D0.f -> P3
// Escapes:
// ----- Passive -----
// PointsTo:
// P1.g -> D0
// P2.g -> D0
// RET.v@lue -> P1.g
// RET.v@lue -> P2.g
// RET.v@lue -> D0
// D0.f -> P3
// Escapes:
fun foo(z: Boolean, c1: C, c2: C, a: A): B {
val v = if(z) c1.g else c2.g
v.f = a
return v
}
fun box(): String = foo(true, C(), C(), A("OK")).f.s
@@ -1,56 +0,0 @@
/*
* 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
// 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()
}
class B {
var f: A = A("qzz")
}
class C {
var g: A = A("")
}
class D {
var o: A = A("")
}
// ----- Agressive -----
// PointsTo:
// P1.g -> D0
// P2.f -> D0
// P4.o -> P1.g
// P4.o -> P2.f
// P4.o -> D0
// RET.v@lue -> D1
// D0.p -> P1
// D0.h -> P3
// Escapes: D1
// ----- Passive -----
// PointsTo:
// P1.g -> D0
// P2.f -> D0
// P4.o -> P1.g
// P4.o -> P2.f
// P4.o -> D0
// RET.v@lue -> D1
// D0.p -> P1
// D0.h -> P3
// Escapes: D1
fun foo(z: Boolean, c: C, b: B, s: String, d: D) {
val v = if(z) c.g else b.f
v.h = s
d.o = v
val u = v
u.p = c
}
fun box(): String {
// When uncommented, execution of the following line would fall into infinite recursion
// foo(true, C(), B(), "zzz", D())
return "OK"
}
@@ -1,47 +0,0 @@
/*
* 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
// Note: intentional infinite recursion for F(String). Don't try to execute the code.
class F(val s: String) {
var g = F("OK")
}
class A {
var f = F("qzz")
}
// ----- Agressive -----
// PointsTo:
// P0.f -> D0
// RET.v@lue -> P0.f
// RET.v@lue -> D0
// RET.v@lue -> D0.g
// D0.g -> P0.f
// D0.g -> D0
// Escapes:
// ----- Passive -----
// PointsTo:
// P0.f -> D0
// RET.v@lue -> P0.f
// RET.v@lue -> D0
// RET.v@lue -> D0.g
// D0.g -> P0.f
// D0.g -> D0
// D0.g -> D2
// D1 -> D0
// D2 -> D0
// Escapes: D1 D2
fun foo(a: A): F {
a.f = F("zzz")
a.f.g = a.f
return a.f.g.g
}
fun box(): String {
// When uncommented, execution of the following line would fall into infinite recursion
// foo(A()).s
return "OK"
}
@@ -1,41 +0,0 @@
/*
* 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
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)
}
class A {
var f = F("qzz")
}
// ----- Agressive -----
// PointsTo:
// P0.f -> P1.g
// RET.v@lue -> P1.g.h
// Escapes:
// ----- Passive -----
// PointsTo:
// P0.f -> P1.g
// P1.g.h -> D0
// RET.v@lue -> P1.g.h
// Escapes: D0
fun foo(a: A, f: F): H {
a.f = f.g
a.f.h = H(42)
return f.g.h
}
fun box(): String {
// When uncommented, execution of the following line would fall into infinite recursion
// assertEquals(0, foo(A(), F("zzz")).x)
return "OK"
}
@@ -1,25 +0,0 @@
/*
* 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.
*/
import kotlin.test.*
class A {
var x = 0
}
fun box(): String {
var sum1 = 0
var sum2 = 0
for (i in 0 until 10) {
val a = A()
sum1 += a.x
a.x = i
sum2 += a.x
}
assertEquals(0, sum1)
assertEquals(45, sum2)
return "OK"
}