[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
+9
View File
@@ -0,0 +1,9 @@
MODULE main
CLASS Catch3Kt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
+30
View File
@@ -0,0 +1,30 @@
/*
* 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 {
try {
sb.appendLine("Before")
throw Error("Error happens")
sb.appendLine("After")
} catch (e: Throwable) {
sb.appendLine("Caught Throwable")
}
sb.appendLine("Done")
assertEquals("""
Before
Caught Throwable
Done
""".trimIndent(), sb.toString())
return "OK"
}
+9
View File
@@ -0,0 +1,9 @@
MODULE main
CLASS Catch4Kt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
+34
View File
@@ -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.*
val sb = StringBuilder()
fun box(): String {
try {
sb.appendLine("Before")
throw Error("Error happens")
sb.appendLine("After")
} catch (e: Exception) {
sb.appendLine("Caught Exception")
} catch (e: Error) {
sb.appendLine("Caught Error")
} catch (e: Throwable) {
sb.appendLine("Caught Throwable")
}
sb.appendLine("Done")
assertEquals("""
Before
Caught Error
Done
""".trimIndent(), sb.toString())
return "OK"
}
+9
View File
@@ -0,0 +1,9 @@
MODULE main
CLASS Catch5Kt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
+44
View File
@@ -0,0 +1,44 @@
/*
* 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 {
try {
try {
sb.appendLine("Before")
foo()
sb.appendLine("After")
} catch (e: Exception) {
sb.appendLine("Caught Exception")
}
sb.appendLine("After nested try")
} catch (e: Error) {
sb.appendLine("Caught Error")
} catch (e: Throwable) {
sb.appendLine("Caught Throwable")
}
sb.appendLine("Done")
assertEquals("""
Before
Caught Error
Done
""".trimIndent(), sb.toString())
return "OK"
}
fun foo() {
throw Error("Error happens")
sb.appendLine("After in foo()")
}
+9
View File
@@ -0,0 +1,9 @@
MODULE main
CLASS Catch6Kt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
+40
View File
@@ -0,0 +1,40 @@
/*
* 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 {
try {
sb.appendLine("Before")
foo()
sb.appendLine("After")
} catch (e: Exception) {
sb.appendLine("Caught Exception")
} catch (e: Error) {
sb.appendLine("Caught Error")
}
sb.appendLine("Done")
assertEquals("""
Before
Caught Error
Done
""".trimIndent(), sb.toString())
return "OK"
}
fun foo() {
try {
throw Error("Error happens")
} catch (e: Exception) {
sb.appendLine("Caught Exception")
}
}
+9
View File
@@ -0,0 +1,9 @@
MODULE main
CLASS Catch8Kt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
+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.
*/
// JVM_ABI_K1_K2_DIFF: KT-63864
// WITH_STDLIB
import kotlin.test.*
val sb = StringBuilder()
fun box(): String {
try {
throw Error("Error happens")
} catch (e: Throwable) {
val message = e.message
if (message != null) {
sb.appendLine(message)
}
}
assertEquals("""
Error happens
""".trimIndent(), sb.toString())
return "OK"
}
@@ -0,0 +1,9 @@
MODULE main
CLASS Finally1Kt.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()
fun box(): String {
try {
sb.appendLine("Try")
} finally {
sb.appendLine("Finally")
}
sb.appendLine("Done")
assertEquals("""
Try
Finally
Done
""".trimIndent(), sb.toString())
return "OK"
}
@@ -0,0 +1,9 @@
MODULE main
CLASS Finally10Kt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
+30
View File
@@ -0,0 +1,30 @@
/*
* 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 {
while (true) {
try {
continue
} finally {
sb.appendLine("Finally")
break
}
}
sb.appendLine("After")
assertEquals("""
Finally
After
""".trimIndent(), sb.toString())
return "OK"
}
@@ -0,0 +1,9 @@
MODULE main
CLASS Finally11Kt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
+39
View File
@@ -0,0 +1,39 @@
/*
* 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 {
test()
assertEquals("""
Finally
Catch 2
Done
""".trimIndent(), sb.toString())
return "OK"
}
fun test() {
try {
try {
return
} catch (e: Error) {
sb.appendLine("Catch 1")
} finally {
sb.appendLine("Finally")
throw Error()
}
} catch (e: Error) {
sb.appendLine("Catch 2")
}
sb.appendLine("Done")
}
@@ -0,0 +1,9 @@
MODULE main
CLASS Finally2Kt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
+34
View File
@@ -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.*
val sb = StringBuilder()
fun box(): String {
try {
sb.appendLine("Try")
throw Error("Error happens")
sb.appendLine("After throw")
} catch (e: Error) {
sb.appendLine("Caught Error")
} finally {
sb.appendLine("Finally")
}
sb.appendLine("Done")
assertEquals("""
Try
Caught Error
Finally
Done
""".trimIndent(), sb.toString())
return "OK"
}
@@ -0,0 +1,9 @@
MODULE main
CLASS Finally3Kt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
+39
View File
@@ -0,0 +1,39 @@
/*
* 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 {
try {
try {
sb.appendLine("Try")
throw Error("Error happens")
sb.appendLine("After throw")
} finally {
sb.appendLine("Finally")
}
sb.appendLine("After nested try")
} catch (e: Error) {
sb.appendLine("Caught Error")
}
sb.appendLine("Done")
assertEquals("""
Try
Finally
Caught Error
Done
""".trimIndent(), sb.toString())
return "OK"
}
@@ -0,0 +1,9 @@
MODULE main
CLASS Finally4Kt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
+46
View File
@@ -0,0 +1,46 @@
/*
* 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 {
try {
try {
sb.appendLine("Try")
throw Error("Error happens")
sb.appendLine("After throw")
} catch (e: Error) {
sb.appendLine("Catch")
throw Exception()
sb.appendLine("After throw")
} finally {
sb.appendLine("Finally")
}
sb.appendLine("After nested try")
} catch (e: Error) {
sb.appendLine("Caught Error")
} catch (e: Exception) {
sb.appendLine("Caught Exception")
}
sb.appendLine("Done")
assertEquals("""
Try
Catch
Finally
Caught Exception
Done
""".trimIndent(), sb.toString())
return "OK"
}
@@ -0,0 +1,9 @@
MODULE main
CLASS Finally5Kt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
+34
View File
@@ -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.*
val sb = StringBuilder()
fun box(): String {
sb.appendLine(foo())
assertEquals("""
Done
Finally
0
""".trimIndent(), sb.toString())
return "OK"
}
fun foo(): Int {
try {
sb.appendLine("Done")
return 0
} finally {
sb.appendLine("Finally")
}
sb.appendLine("After")
return 1
}
@@ -0,0 +1,9 @@
MODULE main
CLASS Finally6Kt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
+35
View File
@@ -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.*
val sb = StringBuilder()
fun box(): String {
sb.appendLine(foo())
assertEquals("""
Done
Finally
1
""".trimIndent(), sb.toString())
return "OK"
}
fun foo(): Int {
try {
sb.appendLine("Done")
return 0
} finally {
sb.appendLine("Finally")
return 1
}
sb.appendLine("After")
return 2
}
@@ -0,0 +1,9 @@
MODULE main
CLASS Finally7Kt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
+34
View File
@@ -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.*
val sb = StringBuilder()
fun box(): String {
sb.appendLine(foo())
assertEquals("""
Done
Finally
1
""".trimIndent(), sb.toString())
return "OK"
}
fun foo(): Int {
try {
sb.appendLine("Done")
throw Error()
} finally {
sb.appendLine("Finally")
return 1
}
sb.appendLine("After")
return 2
}
@@ -0,0 +1,9 @@
MODULE main
CLASS Finally8Kt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
+37
View File
@@ -0,0 +1,37 @@
/*
* 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 {
sb.appendLine(foo())
assertEquals("""
Finally 1
Finally 2
42
""".trimIndent(), sb.toString())
return "OK"
}
fun foo(): Int {
try {
try {
return 42
} finally {
sb.appendLine("Finally 1")
}
} finally {
sb.appendLine("Finally 2")
}
sb.appendLine("After")
return 2
}
@@ -0,0 +1,9 @@
MODULE main
CLASS Finally9Kt.class
PACKAGE METADATA
PROPERTY getSb()Ljava/lang/StringBuilder;
Property: class.metadata.property.returnType
K1
java/lang/StringBuilder /* = kotlin/text/StringBuilder^ */
K2
java/lang/StringBuilder
+40
View File
@@ -0,0 +1,40 @@
/*
* 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 {
do {
try {
break
} finally {
sb.appendLine("Finally 1")
}
} while (false)
var stop = false
while (!stop) {
try {
stop = true
continue
} finally {
sb.appendLine("Finally 2")
}
}
sb.appendLine("After")
assertEquals("""
Finally 1
Finally 2
After
""".trimIndent(), sb.toString())
return "OK"
}
@@ -0,0 +1,9 @@
MODULE main
CLASS ReturnsDifferentTypesKt.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,42 @@
/*
* 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()
class ReceiveChannel<out E>
inline fun <E, R> ReceiveChannel<E>.consume(block: ReceiveChannel<E>.() -> R): R {
try {
return block()
}
finally {
sb.appendLine("zzz")
}
}
inline fun <E> ReceiveChannel<E>.elementAtOrElse(index: Int, defaultValue: (Int) -> E): E =
consume {
if (index < 0)
return defaultValue(index)
return 42 as E
}
fun <E> ReceiveChannel<E>.elementAt(index: Int): E =
elementAtOrElse(index) { throw IndexOutOfBoundsException("qxx") }
fun box(): String {
sb.appendLine(ReceiveChannel<Int>().elementAt(0))
assertEquals("""
zzz
42
""".trimIndent(), sb.toString())
return "OK"
}
+18
View File
@@ -0,0 +1,18 @@
/*
* 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 {
val x = try {
5
} catch (e: Throwable) {
6
}
assertEquals(5, x)
return "OK"
}
+19
View File
@@ -0,0 +1,19 @@
/*
* 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 {
val x = try {
throw Error()
5
} catch (e: Throwable) {
6
}
assertEquals(6, x)
return "OK"
}
+18
View File
@@ -0,0 +1,18 @@
/*
* 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 {
val x = try {
throw Error()
} catch (e: Throwable) {
6
}
assertEquals(6, x)
return "OK"
}
+9
View File
@@ -0,0 +1,9 @@
MODULE main
CLASS Try4Kt.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()
fun box(): String {
val x = try {
sb.appendLine("Try")
5
} catch (e: Throwable) {
throw e
}
sb.appendLine(x)
assertEquals("""
Try
5
""".trimIndent(), sb.toString())
return "OK"
}