[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
@@ -0,0 +1,25 @@
/*
* Copyright 2010-2018 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.
*/
// WITH_STDLIB
import kotlin.test.*
open class Content() {
override fun toString() = "OK"
}
interface Box<E> {
fun get(): E
}
interface ContentBox<T : Content> : Box<T>
object Impl : ContentBox<Content> {
override fun get(): Content = Content()
}
class ContentBoxDelegate<T : Content>() : ContentBox<T> by (Impl as ContentBox<T>)
fun box() = ContentBoxDelegate<Content>().get().toString()
+27
View File
@@ -0,0 +1,27 @@
/*
* Copyright 2010-2018 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.
*/
// WITH_STDLIB
import kotlin.test.*
interface A<T> {
fun foo(): T
}
class B : A<String> {
override fun foo() = "OK"
}
class C(a: A<String>) : A<String> by a
fun box(): String {
val c = C(B())
val a: A<String> = c
val cfoo = c.foo()
if (cfoo != "OK") return "FAIL cfoo: $cfoo"
val afoo = a.foo()
if (afoo != "OK") return "FAIL afoo: $afoo"
return "OK"
}
@@ -0,0 +1,40 @@
// WITH_STDLIB
// MODULE: lib
// FILE: lib.kt
package zzz
interface I {
fun foo(): Int
}
open class A : I {
override fun foo() = 42
}
open class B : I by A() {
val x = 117
val y = "zzz"
}
// MODULE: main(lib)
// FILE: main.kt
import zzz.*
import kotlin.test.*
class C : B() {
val a = "qxx"
val b = 123
}
fun box(): String {
val c = C()
assertEquals("qxx", c.a)
assertEquals(123, c.b)
assertEquals(42, c.foo())
assertEquals(117, c.x)
assertEquals("zzz", c.y)
return "OK"
}
@@ -0,0 +1,11 @@
MODULE main
CLASS Q.class
CLASS METADATA
K1
getX()I
K2
---
K1
---
K2
x
@@ -0,0 +1,26 @@
/*
* Copyright 2010-2018 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.
*/
// JVM_ABI_K1_K2_DIFF: KT-63828
// WITH_STDLIB
import kotlin.test.*
interface A {
val x: Int
}
class C: A {
override val x: Int = 42
}
class Q(a: A): A by a
fun box(): String {
val q = Q(C())
val a: A = q
if (q.x != 42) return "FAIL q.x=${q.x}"
if (a.x != 42) return "FAIL a.x=${a.x}"
return "OK"
}
@@ -0,0 +1,32 @@
/*
* Copyright 2010-2018 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.
*/
// WITH_STDLIB
import kotlin.test.*
interface A<T> {
fun foo(t: T): String
}
interface B {
fun foo(t: Int) = "B"
}
class Z : B
class Z1 : A<Int>, B by Z()
fun box(): String {
val z1 = Z1()
val z1a: A<Int> = z1
val z1b: B = z1
return when {
z1.foo( 0) != "B" -> "Fail #1"
z1a.foo( 0) != "B" -> "Fail #2"
z1b.foo( 0) != "B" -> "Fail #3"
else -> "OK"
}
}