[K/N][Tests] Adjust moved tests interfaceCallsNCasts..vector to new infra

^KT-61259
This commit is contained in:
Vladimir Sukharev
2023-12-16 23:54:04 +01:00
committed by Space Team
parent 93642020ff
commit bb8a7b6795
163 changed files with 841 additions and 672 deletions
@@ -0,0 +1,46 @@
/*
* Copyright 2010-2023 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-64460: When producing cache, anonymous objects are not extracted from inline functions to module scope, so the following happens
// kotlin.AssertionError: Expected <class codegen.kclass.kclass0.MainKt$1>, actual <class codegen.kclass.kclass0.box$$inlined$getHasFoo$1>.
// IGNORE_NATIVE: cacheMode=STATIC_EVERYWHERE
// IGNORE_NATIVE: cacheMode=STATIC_PER_FILE_EVERYWHERE
package codegen.kclass.kclass0
import kotlin.test.*
import kotlin.reflect.KClass
interface HasFoo {
fun foo(): String
}
private inline fun getHasFoo(s: String) = object : HasFoo {
override fun foo(): String = s
}
fun box(): String {
val hasFoo = getHasFoo("zzz")
checkClass(
hasFoo::class,
expectedQualifiedName = null,
expectedSimpleName = null, // KT-64460: simpleName is explicitly prohibited in NATIVE backend
expectedToStringName = "class codegen.kclass.kclass0.MainKt\$1",
expectedInstance = hasFoo,
expectedNotInstance = Any()
)
return "OK"
}
private fun checkClass(
clazz: KClass<*>,
expectedQualifiedName: String?, expectedSimpleName: String?, expectedToStringName: String,
expectedInstance: Any, expectedNotInstance: Any?
) {
assertEquals(expectedQualifiedName, clazz.qualifiedName)
assertEquals(expectedSimpleName, clazz.simpleName)
assertEquals(expectedToStringName, clazz.toString())
assertTrue(clazz.isInstance(expectedInstance))
if (expectedNotInstance != null) assertTrue(!clazz.isInstance(expectedNotInstance))
}
@@ -0,0 +1,46 @@
/*
* Copyright 2010-2023 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-64460: When not producing cache, anonymous objects are extracted from inline functions to module scope, so the following happens
// kotlin.AssertionError: Expected <class codegen.kclass.kclass0.checkAnonymousObjects$$inlined$getHasFoo$1>, actual <class codegen.kclass.kclass0.MainKt$1>.
// IGNORE_NATIVE: cacheMode=NO
// IGNORE_NATIVE: cacheMode=STATIC_ONLY_DIST
package codegen.kclass.kclass0
import kotlin.test.*
import kotlin.reflect.KClass
interface HasFoo {
fun foo(): String
}
private inline fun getHasFoo(s: String) = object : HasFoo {
override fun foo(): String = s
}
fun box(): String {
val hasFoo = getHasFoo("zzz")
checkClass(
hasFoo::class,
expectedQualifiedName = null,
expectedSimpleName = null, // KT-64460: simpleName is explicitly prohibited in NATIVE backend
expectedToStringName = "class codegen.kclass.kclass0.box\$\$inlined\$getHasFoo\$1",
expectedInstance = hasFoo,
expectedNotInstance = Any()
)
return "OK"
}
private fun checkClass(
clazz: KClass<*>,
expectedQualifiedName: String?, expectedSimpleName: String?, expectedToStringName: String,
expectedInstance: Any, expectedNotInstance: Any?
) {
assertEquals(expectedQualifiedName, clazz.qualifiedName)
assertEquals(expectedSimpleName, clazz.simpleName)
assertEquals(expectedToStringName, clazz.toString())
assertTrue(clazz.isInstance(expectedInstance))
if (expectedNotInstance != null) assertTrue(!clazz.isInstance(expectedNotInstance))
}
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.kclass.kClassEnumArgument
import kotlin.test.*
import kotlin.reflect.KClass
@@ -13,6 +11,8 @@ enum class E(val arg: KClass<*>?) {
B(String::class);
}
@Test fun runTest() {
println(E.B.arg?.simpleName)
fun box(): String {
assertEquals("String", E.B.arg?.simpleName)
return "OK"
}
@@ -1 +0,0 @@
String
+2 -21
View File
@@ -2,15 +2,14 @@
* 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.
*/
package codegen.kclass.kclass0
import kotlin.test.*
import kotlin.coroutines.*
import kotlin.reflect.KClass
@Test fun runTest() {
fun box(): String {
main(emptyArray<String>())
return "OK"
}
fun main(args: Array<String>) {
@@ -211,14 +210,6 @@ private fun checkLocalClasses(args: Array<String>) {
::suspendFunWithLocalClass.runCoroutine()
}
interface HasFoo {
fun foo(): String
}
private inline fun getHasFoo(s: String) = object : HasFoo {
override fun foo(): String = s
}
private fun checkAnonymousObjects(args: Array<String>) {
// Anonymous object.
with(object : Any() {
@@ -378,16 +369,6 @@ private fun checkAnonymousObjects(args: Array<String>) {
}
}
::suspendFunWithAnonymousObject.runCoroutine()
val hasFoo = getHasFoo("zzz")
checkClass(
hasFoo::class,
expectedQualifiedName = null,
expectedSimpleName = null,
expectedToStringName = "class codegen.kclass.kclass0.Kclass0Kt$1",
expectedInstance = hasFoo,
expectedNotInstance = Any()
)
}
private fun checkAnonymousObjectsAssignedToProperty(args: Array<String>) {
+6 -6
View File
@@ -7,12 +7,12 @@ package codegen.kclass.kclass1
import kotlin.test.*
// FILE: main.kt
@Test fun runTest() {
App(testQualified = true)
}
val sb = StringBuilder()
// FILE: app.kt
fun box(): String {
App(testQualified = true)
return sb.toString()
}
// Taken from:
// https://github.com/SalomonBrys/kmffkn/blob/master/shared/main/kotlin/com/github/salomonbrys/kmffkn/app.kt
@@ -55,6 +55,6 @@ class App(testQualified: Boolean) {
assert(TestClass()::class == TestClass()::class)
assert(TestClass()::class == TestClass::class)
println("OK :D")
sb.append("OK")
}
}
@@ -1 +0,0 @@
OK :D