[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,31 @@
// WITH_STDLIB
// MODULE: lib
// FILE: lib.kt
package zzz
open class B {
val z by lazy { "qzz" }
val x = 117
val zzz = "zzz"
}
// MODULE: main(lib)
// FILE: main.kt
import zzz.*
import kotlin.test.*
class C : B() {
val a = "qxx"
}
fun box(): String {
val c = C()
assertEquals("qxx", c.a)
assertEquals(117, c.x)
assertEquals("zzz", c.zzz)
assertEquals("qzz", c.z)
return "OK"
}
@@ -0,0 +1,9 @@
MODULE lib
CLASS a/LibKt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
@@ -0,0 +1,62 @@
// JVM_ABI_K1_K2_DIFF: KT-63864
// WITH_STDLIB
// MODULE: lib
// FILE: lib.kt
package a
import kotlin.reflect.KProperty
public val sb = StringBuilder()
open class A {
open val x = 42
}
class Delegate {
val f = 117
operator fun getValue(receiver: Any?, p: KProperty<*>): Int {
sb.appendLine(p.name)
return f
}
}
open class B: A() {
override val x: Int by Delegate()
fun bar() {
sb.appendLine(super<A>.x)
}
}
// MODULE: main(lib)
// FILE: main.kt
import a.*
import kotlin.test.*
open class C: B() {
override val x: Int = 156
fun foo() {
sb.appendLine(x)
sb.appendLine(super<B>.x)
bar()
}
}
fun box(): String {
val c = C()
c.foo()
assertEquals("""
156
x
117
42
""".trimIndent(), sb.toString())
return "OK"
}
@@ -0,0 +1,9 @@
MODULE main
CLASS LazyKt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
+28
View File
@@ -0,0 +1,28 @@
/*
* 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-63864
// WITH_STDLIB
import kotlin.test.*
val sb = StringBuilder()
val lazyValue: String by lazy {
sb.appendLine("computed!")
"Hello"
}
fun box(): String {
sb.appendLine(lazyValue)
sb.appendLine(lazyValue)
assertEquals("""
computed!
Hello
Hello
""".trimIndent(), sb.toString())
return "OK"
}
@@ -0,0 +1,9 @@
MODULE main
CLASS LocalKt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
@@ -0,0 +1,35 @@
/*
* 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-63864
// WITH_STDLIB
import kotlin.test.*
import kotlin.reflect.KProperty
val sb = StringBuilder()
fun foo(): Int {
class Delegate {
operator fun getValue(receiver: Any?, p: KProperty<*>): Int {
sb.appendLine(p.name)
return 42
}
}
val x: Int by Delegate()
return x
}
fun box(): String {
sb.appendLine(foo())
assertEquals("""
x
42
""".trimIndent(), sb.toString())
return "OK"
}
+23
View File
@@ -0,0 +1,23 @@
/*
* 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.*
class User(val map: Map<String, Any?>) {
val name: String by map
val age: Int by map
}
fun box(): String {
val user = User(mapOf(
"name" to "John Doe",
"age" to 25
))
assertEquals("John Doe", user.name)
assertEquals(25, user.age)
return "OK"
}
@@ -0,0 +1,9 @@
MODULE main
CLASS ObservableKt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
@@ -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.
*/
// JVM_ABI_K1_K2_DIFF: KT-63864
// WITH_STDLIB
import kotlin.test.*
import kotlin.properties.Delegates
val sb = StringBuilder()
class User {
var name: String by Delegates.observable("<no name>") {
prop, old, new ->
sb.appendLine("$old -> $new")
}
}
fun box(): String {
val user = User()
user.name = "first"
user.name = "second"
assertEquals("""
<no name> -> first
first -> second
""".trimIndent(), sb.toString())
return "OK"
}
@@ -0,0 +1,9 @@
MODULE main
CLASS PackageLevelKt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
@@ -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.
*/
// JVM_ABI_K1_K2_DIFF: KT-63864
// WITH_STDLIB
import kotlin.test.*
import kotlin.reflect.KProperty
val sb = StringBuilder()
class Delegate {
operator fun getValue(receiver: Any?, p: KProperty<*>): Int {
sb.appendLine(p.name)
return 42
}
}
val x: Int by Delegate()
fun box(): String {
sb.appendLine(x)
assertEquals("""
x
42
""".trimIndent(), sb.toString())
return "OK"
}
@@ -0,0 +1,9 @@
MODULE main
CLASS SimpleValKt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
@@ -0,0 +1,34 @@
/*
* 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-63864
// WITH_STDLIB
import kotlin.test.*
import kotlin.reflect.KProperty
val sb = StringBuilder()
class Delegate {
operator fun getValue(receiver: Any?, p: KProperty<*>): Int {
sb.appendLine(p.name)
return 42
}
}
class C {
val x: Int by Delegate()
}
fun box(): String {
sb.appendLine(C().x)
assertEquals("""
x
42
""".trimIndent(), sb.toString())
return "OK"
}
@@ -0,0 +1,9 @@
MODULE main
CLASS SimpleVarKt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
@@ -0,0 +1,47 @@
/*
* 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-63864
// WITH_STDLIB
import kotlin.test.*
import kotlin.reflect.KProperty
val sb = StringBuilder()
class Delegate {
var f: Int = 42
operator fun getValue(receiver: Any?, p: KProperty<*>): Int {
sb.appendLine("get ${p.name}")
return f
}
operator fun setValue(receiver: Any?, p: KProperty<*>, value: Int) {
sb.appendLine("set ${p.name}")
f = value
}
}
class C {
var x: Int by Delegate()
}
fun box(): String {
val c = C()
sb.appendLine(c.x)
c.x = 117
sb.appendLine(c.x)
assertEquals("""
get x
42
set x
get x
117
""".trimIndent(), sb.toString())
return "OK"
}