[K/N][Tests] Adjust moved codegen tests to new infra

^KT-61259
This commit is contained in:
Vladimir Sukharev
2023-12-14 20:14:47 +01:00
committed by Space Team
parent 71a834b778
commit 73032213f0
295 changed files with 1362 additions and 1145 deletions
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.enum.companionObject
import kotlin.test.*
enum class Game {
@@ -29,5 +27,3 @@ fun box(): String {
if (Game.scissors != Game.SCISSORS) return "Fail 6"
return "OK"
}
@Test fun runTest() = println(box())
@@ -1 +0,0 @@
OK
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.enum.interfaceCallNoEntryClass
import kotlin.test.*
interface A {
@@ -21,8 +19,9 @@ enum class Zzz(val zzz: String, val x: Int) : A {
}
}
@Test fun runTest() {
println(Zzz.Z3.foo())
fun box(): String {
assertEquals("('z3', 3)", Zzz.Z3.foo())
val a: A = Zzz.Z3
println(a.foo())
assertEquals("('z3', 3)", a.foo())
return "OK"
}
@@ -1,2 +0,0 @@
('z3', 3)
('z3', 3)
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.enum.interfaceCallWithEntryClass
import kotlin.test.*
interface A {
@@ -23,9 +21,11 @@ enum class Zzz: A {
override fun f() = ""
}
@Test fun runTest() {
println(Zzz.Z1.f() + Zzz.Z2.f())
fun box(): String {
assertEquals("z1z2", Zzz.Z1.f() + Zzz.Z2.f())
val a1: A = Zzz.Z1
val a2: A = Zzz.Z2
println(a1.f() + a2.f())
assertEquals("z1z2", a1.f() + a2.f())
return "OK"
}
@@ -1,2 +0,0 @@
z1z2
z1z2
+3 -2
View File
@@ -3,7 +3,6 @@
* that can be found in the LICENSE file.
*/
@file:OptIn(FreezingIsDeprecated::class, kotlin.experimental.ExperimentalNativeApi::class)
package codegen.enum.isFrozen
import kotlin.test.*
import kotlin.native.concurrent.*
@@ -13,7 +12,7 @@ enum class Zzz(val zzz: String, var value: Int = 0) {
Z2("z2")
}
@Test fun runTest() {
fun box(): String {
if (Platform.memoryModel == MemoryModel.STRICT) {
assertTrue(Zzz.Z1.isFrozen)
assertFailsWith<InvalidMutabilityException> {
@@ -25,4 +24,6 @@ enum class Zzz(val zzz: String, var value: Int = 0) {
Zzz.Z1.value = 42
assertEquals(42, Zzz.Z1.value)
}
return "OK"
}
+3 -4
View File
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.enum.kt38540
import kotlin.test.*
public enum class Node(
@@ -99,9 +97,10 @@ public enum class Node(
)
}
@Test
fun runTest() {
fun box(): String {
assertTrue(Node.FIELD_REPORT.dependsOn.contains(Node.AG))
assertTrue(Node.FIELD_REPORT.dependsOn.contains(Node.O))
assertTrue(Node.FIELD_REPORT.dependsOn.contains(Node.J))
return "OK"
}
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.enum.lambdaInDefault
import kotlin.test.*
enum class Zzz(val value: String.() -> Int = {
@@ -13,6 +11,7 @@ enum class Zzz(val value: String.() -> Int = {
Q()
}
@Test fun runTest() {
println(Zzz.Q)
fun box(): String {
assertEquals("Q", Zzz.Q.toString())
return "OK"
}
@@ -1 +0,0 @@
Q
+12 -5
View File
@@ -3,18 +3,25 @@
* that can be found in the LICENSE file.
*/
package codegen.enum.loop
import kotlin.test.*
val sb = StringBuilder()
enum class Zzz {
Z {
init {
println(Z.name)
sb.appendLine(Z.name)
}
}
}
@Test fun runTest() {
println(Zzz.Z)
fun box(): String {
sb.appendLine(Zzz.Z)
assertEquals("""
Z
Z
""".trimIndent(), sb.toString())
return "OK"
}
-2
View File
@@ -1,2 +0,0 @@
Z
Z
+5 -5
View File
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.enum.nested
import kotlin.test.*
enum class Foo {
@@ -12,7 +10,9 @@ enum class Foo {
enum class Bar { C }
}
@Test fun runTest() {
println(Foo.A)
println(Foo.Bar.C)
fun box(): String {
assertEquals("A", Foo.A.toString())
assertEquals("C", Foo.Bar.C.toString())
return "OK"
}
-2
View File
@@ -1,2 +0,0 @@
A
C
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.enum.reorderedArguments
import kotlin.test.*
// Regression test for https://github.com/JetBrains/kotlin-native/issues/1779
@@ -28,7 +26,7 @@ enum class Bar(override val value: Foo) : Base<Foo> {
E(Foo.E)
}
@Test fun runTest() {
fun box(): String {
assertEquals(Foo.A.a, 1)
assertEquals(Foo.A.b, 0)
@@ -70,4 +68,5 @@ enum class Bar(override val value: Foo) : Base<Foo> {
assertEquals(Bar.E.value.b, 1)
assertEquals(Bar.E.value.c, 1)
return "OK"
}
+26 -14
View File
@@ -2,11 +2,12 @@
* 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.enum.switchLowering
// !LANGUAGE:-ProhibitComparisonOfIncompatibleEnums
import kotlin.test.*
val sb = StringBuilder()
enum class EnumA {
A, B, C
}
@@ -23,7 +24,7 @@ fun produceEntry() = EnumA.A
// Check that we fail on comparison of different enum types.
fun differentEnums() {
println(when (produceEntry()) {
sb.appendLine(when (produceEntry()) {
EnumB.A -> "EnumB.A"
EnumA.A -> "EnumA.A"
EnumA.B -> "EnumA.B"
@@ -35,8 +36,8 @@ fun differentEnums() {
fun nullable() {
val x: EnumA? = null
when(x) {
EnumA.A -> println("fail")
else -> println("ok")
EnumA.A -> sb.appendLine("fail")
else -> sb.appendLine("ok")
}
}
@@ -46,23 +47,23 @@ fun operatorOverloading() {
val y = E.ONE
when(y) {
in E.ONE -> println("Should not reach here")
else -> println("ok")
in E.ONE -> sb.appendLine("Should not reach here")
else -> sb.appendLine("ok")
}
}
fun smoke1() {
when (produceEntry()) {
EnumA.B -> println("error")
EnumA.A -> println("ok")
EnumA.C -> println("error")
EnumA.B -> sb.appendLine("error")
EnumA.A -> sb.appendLine("ok")
EnumA.C -> sb.appendLine("error")
}
}
fun smoke2() {
when (produceEntry()) {
EnumA.B -> println("error")
else -> println("ok")
EnumA.B -> sb.appendLine("error")
else -> sb.appendLine("ok")
}
}
@@ -72,7 +73,7 @@ fun eB() = EnumA.B
fun nestedWhen() {
println(when (eA()) {
sb.appendLine(when (eA()) {
EnumA.A, EnumA.C -> when (eB()) {
EnumA.B -> "ok"
else -> "nope"
@@ -81,11 +82,22 @@ fun nestedWhen() {
})
}
fun main() {
fun box(): String {
differentEnums()
nullable()
operatorOverloading()
smoke1()
smoke2()
nestedWhen()
assertEquals("""
EnumA.A
ok
ok
ok
ok
ok
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,6 +0,0 @@
EnumA.A
ok
ok
ok
ok
ok
+4 -4
View File
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.enum.test0
import kotlin.test.*
val TOP_LEVEL = 5
@@ -13,6 +11,8 @@ enum class MyEnum(value: Int) {
VALUE(TOP_LEVEL)
}
@Test fun runTest() {
println(MyEnum.VALUE.toString())
fun box(): String {
assertEquals("VALUE", MyEnum.VALUE.toString())
return "OK"
}
-1
View File
@@ -1 +0,0 @@
VALUE
+4 -4
View File
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.enum.test1
import kotlin.test.*
enum class Zzz(val zzz: String, val x: Int) {
@@ -12,6 +10,8 @@ enum class Zzz(val zzz: String, val x: Int) {
Z2("z2", 2)
}
@Test fun runTest() {
println(Zzz.Z1.zzz + Zzz.Z2.x)
fun box(): String {
assertEquals("z12", Zzz.Z1.zzz + Zzz.Z2.x)
return "OK"
}
-1
View File
@@ -1 +0,0 @@
z12
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.enum.vCallNoEntryClass
import kotlin.test.*
enum class Zzz(val zzz: String, val x: Int) {
@@ -17,6 +15,7 @@ enum class Zzz(val zzz: String, val x: Int) {
}
}
@Test fun runTest() {
println(Zzz.Z3.toString())
fun box(): String {
assertEquals("('z3', 3)", Zzz.Z3.toString())
return "OK"
}
@@ -1 +0,0 @@
('z3', 3)
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.enum.vCallWithEntryClass
import kotlin.test.*
enum class Zzz {
@@ -19,6 +17,8 @@ enum class Zzz {
open fun f() = ""
}
@Test fun runTest() {
println(Zzz.Z1.f() + Zzz.Z2.f())
fun box(): String {
assertEquals("z1z2", Zzz.Z1.f() + Zzz.Z2.f())
return "OK"
}
@@ -1 +0,0 @@
z1z2
+9 -9
View File
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.enum.valueOf
import kotlin.test.*
enum class E {
@@ -13,11 +11,13 @@ enum class E {
E2
}
@Test fun runTest() {
println(E.valueOf("E1").toString())
println(E.valueOf("E2").toString())
println(E.valueOf("E3").toString())
println(enumValueOf<E>("E1").toString())
println(enumValueOf<E>("E2").toString())
println(enumValueOf<E>("E3").toString())
fun box(): String {
assertEquals("E1", E.valueOf("E1").toString())
assertEquals("E2", E.valueOf("E2").toString())
assertEquals("E3", E.valueOf("E3").toString())
assertEquals("E1", enumValueOf<E>("E1").toString())
assertEquals("E2", enumValueOf<E>("E2").toString())
assertEquals("E3", enumValueOf<E>("E3").toString())
return "OK"
}
-6
View File
@@ -1,6 +0,0 @@
E1
E2
E3
E1
E2
E3
+9 -9
View File
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.enum.values
import kotlin.test.*
enum class E {
@@ -13,11 +11,13 @@ enum class E {
E2
}
@Test fun runTest() {
println(E.values()[0].toString())
println(E.values()[1].toString())
println(E.values()[2].toString())
println(enumValues<E>()[0].toString())
println(enumValues<E>()[1].toString())
println(enumValues<E>()[2].toString())
fun box(): String {
assertEquals("E3", E.values()[0].toString())
assertEquals("E1", E.values()[1].toString())
assertEquals("E2", E.values()[2].toString())
assertEquals("E3", enumValues<E>()[0].toString())
assertEquals("E1", enumValues<E>()[1].toString())
assertEquals("E2", enumValues<E>()[2].toString())
return "OK"
}
-6
View File
@@ -1,6 +0,0 @@
E3
E1
E2
E3
E1
E2
+3 -4
View File
@@ -3,14 +3,13 @@
* that can be found in the LICENSE file.
*/
package codegen.enum.varargParam
import kotlin.test.*
enum class Piece(vararg val states: Int) {
I(3, 4, 5)
}
@Test fun runTest() {
println(Piece.I.states[0])
fun box(): String {
assertEquals(3, Piece.I.states[0])
return "OK"
}
@@ -1 +0,0 @@
3