[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,9 @@
MODULE main
CLASS InnerTakesCapturedFromOuterKt.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.*
val sb = StringBuilder()
fun box(): String {
var previous: Any? = null
for (i in 0 .. 2) {
class Outer {
inner class Inner {
override fun toString() = i.toString()
}
override fun toString() = Inner().toString()
}
if (previous != null) sb.appendLine(previous.toString())
previous = Outer()
}
assertEquals("""
0
1
""".trimIndent(), sb.toString())
return "OK"
}
@@ -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.
*/
// KT-66105: SyntaxError: Identifier 'box' has already been declared
// IGNORE_BACKEND: WASM
// WITH_STDLIB
import kotlin.test.*
fun box(s: String): String {
class Local {
open inner class Inner() {
open fun result() = s
}
}
return Local().Inner().result()
}
fun box(): String {
return box("OK")
}
@@ -0,0 +1,22 @@
/*
* 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.*
fun box(): String {
var x = 1
fun local1() {
x++
}
class A {
fun bar() {
local1()
}
}
A().bar()
return "OK"
}
@@ -0,0 +1,29 @@
/*
* 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.*
fun box(): String {
var x = 0
class A {
fun bar() {
fun local() {
class B {
fun baz() {
fun local2() {
x++
}
local2()
}
}
B().baz()
}
local()
}
}
A().bar()
return "OK"
}
@@ -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.*
fun foo(s: String): String {
open class Local {
fun f() = s
}
open class Derived: Local() {
fun g() = f()
}
return Derived().g()
}
fun box(): String {
return foo("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.
*/
// KT-66105: SyntaxError: Identifier 'box' has already been declared
// IGNORE_BACKEND: WASM
// WITH_STDLIB
import kotlin.test.*
fun box(s: String): String {
class Local {
constructor(x: Int) {
this.x = x
}
constructor(z: String) {
x = z.length
}
val x: Int
fun result() = s
}
return Local(42).result() + Local("zzz").result()
}
fun box(): String {
assertEquals("OKOK", box("OK"))
return "OK"
}
@@ -0,0 +1,29 @@
/*
* 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.*
abstract class Father {
abstract inner class InClass {
abstract fun work(): String
}
}
class Child : Father() {
val ChildInClass : InClass
init {
ChildInClass = object : Father.InClass() {
override fun work(): String {
return "OK"
}
}
}
}
fun box(): String {
return Child().ChildInClass.work()
}
@@ -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.*
abstract class Father {
abstract inner class InClass {
abstract fun work(): String
}
}
class Child : Father() {
val ChildInClass = object : Father.InClass() {
override fun work(): String {
return "OK"
}
}
}
fun box(): String {
return Child().ChildInClass.work()
}
@@ -0,0 +1,9 @@
MODULE main
CLASS TryCatchKt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
+29
View File
@@ -0,0 +1,29 @@
/*
* 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()
private fun foo() {
val local =
object {
fun bar() {
try {
} catch (t: Throwable) {
sb.appendLine(t)
}
}
}
local.bar()
}
fun box(): String {
sb.append("OK")
foo()
return sb.toString()
}
@@ -0,0 +1,29 @@
/*
* 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.*
abstract class WaitFor {
init {
condition()
}
abstract fun condition(): Boolean;
}
fun box(): String {
val local = ""
var result = "fail"
val s = object : WaitFor() {
override fun condition(): Boolean {
result = "OK"
return result.length == 2
}
}
return result;
}