diff --git a/native/native.tests/testData/codegen/cycles/cycle.kt b/native/native.tests/testData/codegen/cycles/cycle.kt index 1c4d68e3bd7..15ebc599f31 100644 --- a/native/native.tests/testData/codegen/cycles/cycle.kt +++ b/native/native.tests/testData/codegen/cycles/cycle.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.cycles.cycle - import kotlin.test.* fun cycle(cnt: Int): Int { @@ -15,7 +13,9 @@ fun cycle(cnt: Int): Int { return sum } -@Test fun runTest() { - if (cycle(1) != 2) throw Error() - if (cycle(0) != 1) throw Error() +fun box(): String { + assertEquals(2, cycle(1)) + assertEquals(1, cycle(0)) + + return "OK" } diff --git a/native/native.tests/testData/codegen/cycles/cycle_do.kt b/native/native.tests/testData/codegen/cycles/cycle_do.kt index 59094cb94a0..0dd4ca08f80 100644 --- a/native/native.tests/testData/codegen/cycles/cycle_do.kt +++ b/native/native.tests/testData/codegen/cycles/cycle_do.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.cycles.cycle_do - import kotlin.test.* fun cycle_do(cnt: Int): Int { @@ -15,7 +13,9 @@ fun cycle_do(cnt: Int): Int { return sum } -@Test fun runTest() { - if (cycle_do(3) != 5) throw Error() - if (cycle_do(0) != 3) throw Error() +fun box(): String { + assertEquals(5, cycle_do(3)) + assertEquals(3, cycle_do(0)) + + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/cycles/cycle_for.kt b/native/native.tests/testData/codegen/cycles/cycle_for.kt index 493ae570b38..07b2b8675e6 100644 --- a/native/native.tests/testData/codegen/cycles/cycle_for.kt +++ b/native/native.tests/testData/codegen/cycles/cycle_for.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.cycles.cycle_for - import kotlin.test.* fun cycle_for(arr: Array) : Int { @@ -15,6 +13,8 @@ fun cycle_for(arr: Array) : Int { return sum } -@Test fun runTest() { - if (cycle_for(Array(4, init = { it })) != 6) throw Error() +fun box(): String { + assertEquals(6, cycle_for(Array(4, init = { it }))) + + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/dataflow/scope1.kt b/native/native.tests/testData/codegen/dataflow/scope1.kt index 9191d2354e7..fa7f81dba49 100644 --- a/native/native.tests/testData/codegen/dataflow/scope1.kt +++ b/native/native.tests/testData/codegen/dataflow/scope1.kt @@ -3,16 +3,15 @@ * that can be found in the LICENSE file. */ -package codegen.dataflow.scope1 - import kotlin.test.* var b = true -@Test fun runTest() { +fun box(): String { var x = 1 if (b) { var x = 2 } - println(x) + assertEquals(1, x) + return "OK" } diff --git a/native/native.tests/testData/codegen/dataflow/scope1.out b/native/native.tests/testData/codegen/dataflow/scope1.out deleted file mode 100644 index d00491fd7e5..00000000000 --- a/native/native.tests/testData/codegen/dataflow/scope1.out +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/native/native.tests/testData/codegen/dataflow/uninitialized_val.kt b/native/native.tests/testData/codegen/dataflow/uninitialized_val.kt index 579111abc59..24722d6b951 100644 --- a/native/native.tests/testData/codegen/dataflow/uninitialized_val.kt +++ b/native/native.tests/testData/codegen/dataflow/uninitialized_val.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.dataflow.uninitialized_val - import kotlin.test.* fun foo(b: Boolean): Int { @@ -18,9 +16,11 @@ fun foo(b: Boolean): Int { return x } -@Test fun runTest() { +fun box(): String { val uninitializedUnused: Int - println(foo(true)) - println(foo(false)) + assertEquals(1, foo(true)) + assertEquals(2, foo(false)) + + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/dataflow/uninitialized_val.out b/native/native.tests/testData/codegen/dataflow/uninitialized_val.out deleted file mode 100644 index 1191247b6d9..00000000000 --- a/native/native.tests/testData/codegen/dataflow/uninitialized_val.out +++ /dev/null @@ -1,2 +0,0 @@ -1 -2 diff --git a/native/native.tests/testData/codegen/delegatedProperty/lazy.kt b/native/native.tests/testData/codegen/delegatedProperty/lazy.kt index d48e70fb587..8c4b278e6c4 100644 --- a/native/native.tests/testData/codegen/delegatedProperty/lazy.kt +++ b/native/native.tests/testData/codegen/delegatedProperty/lazy.kt @@ -3,16 +3,24 @@ * that can be found in the LICENSE file. */ -package codegen.delegatedProperty.lazy - import kotlin.test.* +val sb = StringBuilder() + val lazyValue: String by lazy { - println("computed!") + sb.appendLine("computed!") "Hello" } -@Test fun runTest() { - println(lazyValue) - println(lazyValue) +fun box(): String { + sb.appendLine(lazyValue) + sb.appendLine(lazyValue) + + assertEquals(""" + computed! + Hello + Hello + + """.trimIndent(), sb.toString()) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/delegatedProperty/lazy.out b/native/native.tests/testData/codegen/delegatedProperty/lazy.out deleted file mode 100644 index 6208f6d40ab..00000000000 --- a/native/native.tests/testData/codegen/delegatedProperty/lazy.out +++ /dev/null @@ -1,3 +0,0 @@ -computed! -Hello -Hello diff --git a/native/native.tests/testData/codegen/delegatedProperty/local.kt b/native/native.tests/testData/codegen/delegatedProperty/local.kt index fca85a5a3d3..2beeaeb11de 100644 --- a/native/native.tests/testData/codegen/delegatedProperty/local.kt +++ b/native/native.tests/testData/codegen/delegatedProperty/local.kt @@ -3,16 +3,15 @@ * that can be found in the LICENSE file. */ -package codegen.delegatedProperty.local - import kotlin.test.* - import kotlin.reflect.KProperty +val sb = StringBuilder() + fun foo(): Int { class Delegate { operator fun getValue(receiver: Any?, p: KProperty<*>): Int { - println(p.name) + sb.appendLine(p.name) return 42 } } @@ -22,6 +21,13 @@ fun foo(): Int { return x } -@Test fun runTest() { - println(foo()) +fun box(): String { + sb.appendLine(foo()) + + assertEquals(""" + x + 42 + + """.trimIndent(), sb.toString()) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/delegatedProperty/local.out b/native/native.tests/testData/codegen/delegatedProperty/local.out deleted file mode 100644 index c91a42733d9..00000000000 --- a/native/native.tests/testData/codegen/delegatedProperty/local.out +++ /dev/null @@ -1,2 +0,0 @@ -x -42 diff --git a/native/native.tests/testData/codegen/delegatedProperty/map.kt b/native/native.tests/testData/codegen/delegatedProperty/map.kt index 598ce40aa06..a0c2e008a74 100644 --- a/native/native.tests/testData/codegen/delegatedProperty/map.kt +++ b/native/native.tests/testData/codegen/delegatedProperty/map.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.delegatedProperty.map - import kotlin.test.* class User(val map: Map) { @@ -12,11 +10,13 @@ class User(val map: Map) { val age: Int by map } -@Test fun runTest() { +fun box(): String { val user = User(mapOf( "name" to "John Doe", "age" to 25 )) - println(user.name) // Prints "John Doe" - println(user.age) // Prints 25 + assertEquals("John Doe", user.name) + assertEquals(25, user.age) + + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/delegatedProperty/map.out b/native/native.tests/testData/codegen/delegatedProperty/map.out deleted file mode 100644 index 4dcbcb19aad..00000000000 --- a/native/native.tests/testData/codegen/delegatedProperty/map.out +++ /dev/null @@ -1,2 +0,0 @@ -John Doe -25 diff --git a/native/native.tests/testData/codegen/delegatedProperty/observable.kt b/native/native.tests/testData/codegen/delegatedProperty/observable.kt index 583a16b4d00..96e8683ce7e 100644 --- a/native/native.tests/testData/codegen/delegatedProperty/observable.kt +++ b/native/native.tests/testData/codegen/delegatedProperty/observable.kt @@ -3,21 +3,28 @@ * that can be found in the LICENSE file. */ -package codegen.delegatedProperty.observable - import kotlin.test.* import kotlin.properties.Delegates +val sb = StringBuilder() + class User { var name: String by Delegates.observable("") { prop, old, new -> - println("$old -> $new") + sb.appendLine("$old -> $new") } } -@Test fun runTest() { +fun box(): String { val user = User() user.name = "first" user.name = "second" + + assertEquals(""" + -> first + first -> second + + """.trimIndent(), sb.toString()) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/delegatedProperty/observable.out b/native/native.tests/testData/codegen/delegatedProperty/observable.out deleted file mode 100644 index 2487ebcd7be..00000000000 --- a/native/native.tests/testData/codegen/delegatedProperty/observable.out +++ /dev/null @@ -1,2 +0,0 @@ - -> first -first -> second diff --git a/native/native.tests/testData/codegen/delegatedProperty/packageLevel.kt b/native/native.tests/testData/codegen/delegatedProperty/packageLevel.kt index 1092b490cb9..14fef11310b 100644 --- a/native/native.tests/testData/codegen/delegatedProperty/packageLevel.kt +++ b/native/native.tests/testData/codegen/delegatedProperty/packageLevel.kt @@ -3,21 +3,28 @@ * that can be found in the LICENSE file. */ -package codegen.delegatedProperty.packageLevel - import kotlin.test.* import kotlin.reflect.KProperty +val sb = StringBuilder() + class Delegate { operator fun getValue(receiver: Any?, p: KProperty<*>): Int { - println(p.name) + sb.appendLine(p.name) return 42 } } val x: Int by Delegate() -@Test fun runTest() { - println(x) +fun box(): String { + sb.appendLine(x) + + assertEquals(""" + x + 42 + + """.trimIndent(), sb.toString()) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/delegatedProperty/packageLevel.out b/native/native.tests/testData/codegen/delegatedProperty/packageLevel.out deleted file mode 100644 index c91a42733d9..00000000000 --- a/native/native.tests/testData/codegen/delegatedProperty/packageLevel.out +++ /dev/null @@ -1,2 +0,0 @@ -x -42 diff --git a/native/native.tests/testData/codegen/delegatedProperty/simpleVal.kt b/native/native.tests/testData/codegen/delegatedProperty/simpleVal.kt index 73f36b93d6f..5a33b091636 100644 --- a/native/native.tests/testData/codegen/delegatedProperty/simpleVal.kt +++ b/native/native.tests/testData/codegen/delegatedProperty/simpleVal.kt @@ -3,15 +3,15 @@ * that can be found in the LICENSE file. */ -package codegen.delegatedProperty.simpleVal - import kotlin.test.* import kotlin.reflect.KProperty +val sb = StringBuilder() + class Delegate { operator fun getValue(receiver: Any?, p: KProperty<*>): Int { - println(p.name) + sb.appendLine(p.name) return 42 } } @@ -20,6 +20,13 @@ class C { val x: Int by Delegate() } -@Test fun runTest() { - println(C().x) +fun box(): String { + sb.appendLine(C().x) + + assertEquals(""" + x + 42 + + """.trimIndent(), sb.toString()) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/delegatedProperty/simpleVal.out b/native/native.tests/testData/codegen/delegatedProperty/simpleVal.out deleted file mode 100644 index c91a42733d9..00000000000 --- a/native/native.tests/testData/codegen/delegatedProperty/simpleVal.out +++ /dev/null @@ -1,2 +0,0 @@ -x -42 diff --git a/native/native.tests/testData/codegen/delegatedProperty/simpleVar.kt b/native/native.tests/testData/codegen/delegatedProperty/simpleVar.kt index ed4e19a5b0f..9191bf74f43 100644 --- a/native/native.tests/testData/codegen/delegatedProperty/simpleVar.kt +++ b/native/native.tests/testData/codegen/delegatedProperty/simpleVar.kt @@ -3,22 +3,22 @@ * that can be found in the LICENSE file. */ -package codegen.delegatedProperty.simpleVar - import kotlin.test.* import kotlin.reflect.KProperty +val sb = StringBuilder() + class Delegate { var f: Int = 42 operator fun getValue(receiver: Any?, p: KProperty<*>): Int { - println("get ${p.name}") + sb.appendLine("get ${p.name}") return f } operator fun setValue(receiver: Any?, p: KProperty<*>, value: Int) { - println("set ${p.name}") + sb.appendLine("set ${p.name}") f = value } } @@ -27,9 +27,19 @@ class C { var x: Int by Delegate() } -@Test fun runTest() { +fun box(): String { val c = C() - println(c.x) + sb.appendLine(c.x) c.x = 117 - println(c.x) + sb.appendLine(c.x) + + assertEquals(""" + get x + 42 + set x + get x + 117 + + """.trimIndent(), sb.toString()) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/delegatedProperty/simpleVar.out b/native/native.tests/testData/codegen/delegatedProperty/simpleVar.out deleted file mode 100644 index 06f0023c3c4..00000000000 --- a/native/native.tests/testData/codegen/delegatedProperty/simpleVar.out +++ /dev/null @@ -1,5 +0,0 @@ -get x -42 -set x -get x -117 diff --git a/native/native.tests/testData/codegen/devirtualization/anonymousObject.kt b/native/native.tests/testData/codegen/devirtualization/anonymousObject.kt index 9eb9165d014..7ca2ca23331 100644 --- a/native/native.tests/testData/codegen/devirtualization/anonymousObject.kt +++ b/native/native.tests/testData/codegen/devirtualization/anonymousObject.kt @@ -3,13 +3,17 @@ * that can be found in the LICENSE file. */ +import kotlin.test.* + +val sb = StringBuilder() + interface I { fun foo() } fun test() { val impl = object : I { - override fun foo() { println("zzz") } + override fun foo() { sb.append("zzz") } } val delegating = object: I by impl { } @@ -17,6 +21,9 @@ fun test() { delegating.foo() } -fun main() { +fun box(): String { test() + assertEquals("zzz", sb.toString()) + + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/devirtualization/anonymousObject.out b/native/native.tests/testData/codegen/devirtualization/anonymousObject.out deleted file mode 100644 index b1a17ba1369..00000000000 --- a/native/native.tests/testData/codegen/devirtualization/anonymousObject.out +++ /dev/null @@ -1 +0,0 @@ -zzz diff --git a/native/native.tests/testData/codegen/devirtualization/getter_looking_as_box_function.kt b/native/native.tests/testData/codegen/devirtualization/getter_looking_as_box_function.kt index f379eb56e16..c802a3aabb6 100644 --- a/native/native.tests/testData/codegen/devirtualization/getter_looking_as_box_function.kt +++ b/native/native.tests/testData/codegen/devirtualization/getter_looking_as_box_function.kt @@ -1,5 +1,5 @@ -class Foo(val box: String = "box") +class Foo(val box: String = "OK") -fun main() { - println(Foo().box) +fun box(): String { + return Foo().box } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/devirtualization/getter_looking_as_box_function.out b/native/native.tests/testData/codegen/devirtualization/getter_looking_as_box_function.out deleted file mode 100644 index d591a2710eb..00000000000 --- a/native/native.tests/testData/codegen/devirtualization/getter_looking_as_box_function.out +++ /dev/null @@ -1 +0,0 @@ -box diff --git a/native/native.tests/testData/codegen/devirtualization/inline_getter.kt b/native/native.tests/testData/codegen/devirtualization/inline_getter.kt index 6f4f37969a8..e96bd17dfda 100644 --- a/native/native.tests/testData/codegen/devirtualization/inline_getter.kt +++ b/native/native.tests/testData/codegen/devirtualization/inline_getter.kt @@ -1,3 +1,5 @@ +import kotlin.test.* + interface Base { val id: Int } inline class Child(override val id: Int = 1) : Base @@ -5,9 +7,11 @@ inline class Child(override val id: Int = 1) : Base interface Base2 { val prop: Base } class Child2(override val prop: Child) : Base2 -fun main() { +fun box(): String { val x : Base = Child(5) - println(x.id) + assertEquals(5, x.id) val y : Base2 = Child2(Child(5)) - println(y.prop) + assertEquals("Child(id=5)", y.prop.toString()) + + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/devirtualization/inline_getter.out b/native/native.tests/testData/codegen/devirtualization/inline_getter.out deleted file mode 100644 index ddafff7f120..00000000000 --- a/native/native.tests/testData/codegen/devirtualization/inline_getter.out +++ /dev/null @@ -1,2 +0,0 @@ -5 -Child(id=5) diff --git a/native/native.tests/testData/codegen/devirtualization/lateinitInterface.kt b/native/native.tests/testData/codegen/devirtualization/lateinitInterface.kt index 1bb5bd22980..f9d97fd15ed 100644 --- a/native/native.tests/testData/codegen/devirtualization/lateinitInterface.kt +++ b/native/native.tests/testData/codegen/devirtualization/lateinitInterface.kt @@ -1,3 +1,4 @@ +import kotlin.test.* interface I { fun foo(): Int } @@ -10,5 +11,10 @@ fun main(args: Array) { lateinit var a: I if (args.size == 0) a = A() - println(a.foo()) -} \ No newline at end of file + assertEquals(42, a.foo()) +} + +fun box(): String { + main(emptyArray()) + return "OK" +} diff --git a/native/native.tests/testData/codegen/devirtualization/lateinitInterface.out b/native/native.tests/testData/codegen/devirtualization/lateinitInterface.out deleted file mode 100644 index d81cc0710eb..00000000000 --- a/native/native.tests/testData/codegen/devirtualization/lateinitInterface.out +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/native/native.tests/testData/codegen/enum/companionObject.kt b/native/native.tests/testData/codegen/enum/companionObject.kt index c4581f24c58..bf6ac0236bd 100644 --- a/native/native.tests/testData/codegen/enum/companionObject.kt +++ b/native/native.tests/testData/codegen/enum/companionObject.kt @@ -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()) \ No newline at end of file diff --git a/native/native.tests/testData/codegen/enum/companionObject.out b/native/native.tests/testData/codegen/enum/companionObject.out deleted file mode 100644 index d86bac9de59..00000000000 --- a/native/native.tests/testData/codegen/enum/companionObject.out +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/native/native.tests/testData/codegen/enum/interfaceCallNoEntryClass.kt b/native/native.tests/testData/codegen/enum/interfaceCallNoEntryClass.kt index cb8fe06685c..09bd1de3639 100644 --- a/native/native.tests/testData/codegen/enum/interfaceCallNoEntryClass.kt +++ b/native/native.tests/testData/codegen/enum/interfaceCallNoEntryClass.kt @@ -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" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/enum/interfaceCallNoEntryClass.out b/native/native.tests/testData/codegen/enum/interfaceCallNoEntryClass.out deleted file mode 100644 index fdaa745843e..00000000000 --- a/native/native.tests/testData/codegen/enum/interfaceCallNoEntryClass.out +++ /dev/null @@ -1,2 +0,0 @@ -('z3', 3) -('z3', 3) diff --git a/native/native.tests/testData/codegen/enum/interfaceCallWithEntryClass.kt b/native/native.tests/testData/codegen/enum/interfaceCallWithEntryClass.kt index bab52500843..30e8b2d2629 100644 --- a/native/native.tests/testData/codegen/enum/interfaceCallWithEntryClass.kt +++ b/native/native.tests/testData/codegen/enum/interfaceCallWithEntryClass.kt @@ -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" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/enum/interfaceCallWithEntryClass.out b/native/native.tests/testData/codegen/enum/interfaceCallWithEntryClass.out deleted file mode 100644 index 2b4991e4674..00000000000 --- a/native/native.tests/testData/codegen/enum/interfaceCallWithEntryClass.out +++ /dev/null @@ -1,2 +0,0 @@ -z1z2 -z1z2 diff --git a/native/native.tests/testData/codegen/enum/isFrozen.kt b/native/native.tests/testData/codegen/enum/isFrozen.kt index b79747d68aa..d34d7d0c1d7 100644 --- a/native/native.tests/testData/codegen/enum/isFrozen.kt +++ b/native/native.tests/testData/codegen/enum/isFrozen.kt @@ -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 { @@ -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" } diff --git a/native/native.tests/testData/codegen/enum/kt38540.kt b/native/native.tests/testData/codegen/enum/kt38540.kt index ec2e8d43570..bba7163e5c6 100644 --- a/native/native.tests/testData/codegen/enum/kt38540.kt +++ b/native/native.tests/testData/codegen/enum/kt38540.kt @@ -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" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/enum/lambdaInDefault.kt b/native/native.tests/testData/codegen/enum/lambdaInDefault.kt index 1d497d74144..eba56668eb3 100644 --- a/native/native.tests/testData/codegen/enum/lambdaInDefault.kt +++ b/native/native.tests/testData/codegen/enum/lambdaInDefault.kt @@ -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" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/enum/lambdaInDefault.out b/native/native.tests/testData/codegen/enum/lambdaInDefault.out deleted file mode 100644 index 73c52c3e3cf..00000000000 --- a/native/native.tests/testData/codegen/enum/lambdaInDefault.out +++ /dev/null @@ -1 +0,0 @@ -Q diff --git a/native/native.tests/testData/codegen/enum/loop.kt b/native/native.tests/testData/codegen/enum/loop.kt index 326c81353c5..634a8c0ba38 100644 --- a/native/native.tests/testData/codegen/enum/loop.kt +++ b/native/native.tests/testData/codegen/enum/loop.kt @@ -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" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/enum/loop.out b/native/native.tests/testData/codegen/enum/loop.out deleted file mode 100644 index b0b80f3442f..00000000000 --- a/native/native.tests/testData/codegen/enum/loop.out +++ /dev/null @@ -1,2 +0,0 @@ -Z -Z diff --git a/native/native.tests/testData/codegen/enum/nested.kt b/native/native.tests/testData/codegen/enum/nested.kt index eb938a04096..08a7640af23 100644 --- a/native/native.tests/testData/codegen/enum/nested.kt +++ b/native/native.tests/testData/codegen/enum/nested.kt @@ -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" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/enum/nested.out b/native/native.tests/testData/codegen/enum/nested.out deleted file mode 100644 index 8ec30d8fdd0..00000000000 --- a/native/native.tests/testData/codegen/enum/nested.out +++ /dev/null @@ -1,2 +0,0 @@ -A -C diff --git a/native/native.tests/testData/codegen/enum/reorderedArguments.kt b/native/native.tests/testData/codegen/enum/reorderedArguments.kt index 21a8a8d5e04..993df522757 100644 --- a/native/native.tests/testData/codegen/enum/reorderedArguments.kt +++ b/native/native.tests/testData/codegen/enum/reorderedArguments.kt @@ -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 { 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 { assertEquals(Bar.E.value.b, 1) assertEquals(Bar.E.value.c, 1) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/enum/switchLowering.kt b/native/native.tests/testData/codegen/enum/switchLowering.kt index 8db7d17328f..fba4b0924ef 100644 --- a/native/native.tests/testData/codegen/enum/switchLowering.kt +++ b/native/native.tests/testData/codegen/enum/switchLowering.kt @@ -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" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/enum/switchLowering.out b/native/native.tests/testData/codegen/enum/switchLowering.out deleted file mode 100644 index 6888baa877d..00000000000 --- a/native/native.tests/testData/codegen/enum/switchLowering.out +++ /dev/null @@ -1,6 +0,0 @@ -EnumA.A -ok -ok -ok -ok -ok diff --git a/native/native.tests/testData/codegen/enum/test0.kt b/native/native.tests/testData/codegen/enum/test0.kt index 6cccc68431f..e29979ae53a 100644 --- a/native/native.tests/testData/codegen/enum/test0.kt +++ b/native/native.tests/testData/codegen/enum/test0.kt @@ -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" } diff --git a/native/native.tests/testData/codegen/enum/test0.out b/native/native.tests/testData/codegen/enum/test0.out deleted file mode 100644 index 2dfe6a37a0f..00000000000 --- a/native/native.tests/testData/codegen/enum/test0.out +++ /dev/null @@ -1 +0,0 @@ -VALUE diff --git a/native/native.tests/testData/codegen/enum/test1.kt b/native/native.tests/testData/codegen/enum/test1.kt index 3fda72ea328..b500d4a31f1 100644 --- a/native/native.tests/testData/codegen/enum/test1.kt +++ b/native/native.tests/testData/codegen/enum/test1.kt @@ -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" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/enum/test1.out b/native/native.tests/testData/codegen/enum/test1.out deleted file mode 100644 index 2269bb980a6..00000000000 --- a/native/native.tests/testData/codegen/enum/test1.out +++ /dev/null @@ -1 +0,0 @@ -z12 diff --git a/native/native.tests/testData/codegen/enum/vCallNoEntryClass.kt b/native/native.tests/testData/codegen/enum/vCallNoEntryClass.kt index ea2007085f5..ccdd2ca2808 100644 --- a/native/native.tests/testData/codegen/enum/vCallNoEntryClass.kt +++ b/native/native.tests/testData/codegen/enum/vCallNoEntryClass.kt @@ -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" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/enum/vCallNoEntryClass.out b/native/native.tests/testData/codegen/enum/vCallNoEntryClass.out deleted file mode 100644 index 1e2b9f77427..00000000000 --- a/native/native.tests/testData/codegen/enum/vCallNoEntryClass.out +++ /dev/null @@ -1 +0,0 @@ -('z3', 3) diff --git a/native/native.tests/testData/codegen/enum/vCallWithEntryClass.kt b/native/native.tests/testData/codegen/enum/vCallWithEntryClass.kt index 5bc8a08c1da..e8acf1a7741 100644 --- a/native/native.tests/testData/codegen/enum/vCallWithEntryClass.kt +++ b/native/native.tests/testData/codegen/enum/vCallWithEntryClass.kt @@ -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" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/enum/vCallWithEntryClass.out b/native/native.tests/testData/codegen/enum/vCallWithEntryClass.out deleted file mode 100644 index 254c7c0c883..00000000000 --- a/native/native.tests/testData/codegen/enum/vCallWithEntryClass.out +++ /dev/null @@ -1 +0,0 @@ -z1z2 diff --git a/native/native.tests/testData/codegen/enum/valueOf.kt b/native/native.tests/testData/codegen/enum/valueOf.kt index 002e4f6a645..278120546ee 100644 --- a/native/native.tests/testData/codegen/enum/valueOf.kt +++ b/native/native.tests/testData/codegen/enum/valueOf.kt @@ -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("E1").toString()) - println(enumValueOf("E2").toString()) - println(enumValueOf("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("E1").toString()) + assertEquals("E2", enumValueOf("E2").toString()) + assertEquals("E3", enumValueOf("E3").toString()) + + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/enum/valueOf.out b/native/native.tests/testData/codegen/enum/valueOf.out deleted file mode 100644 index d768aee29a7..00000000000 --- a/native/native.tests/testData/codegen/enum/valueOf.out +++ /dev/null @@ -1,6 +0,0 @@ -E1 -E2 -E3 -E1 -E2 -E3 diff --git a/native/native.tests/testData/codegen/enum/values.kt b/native/native.tests/testData/codegen/enum/values.kt index 0e27ebc2ab5..cdac2fa5d4a 100644 --- a/native/native.tests/testData/codegen/enum/values.kt +++ b/native/native.tests/testData/codegen/enum/values.kt @@ -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()[0].toString()) - println(enumValues()[1].toString()) - println(enumValues()[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()[0].toString()) + assertEquals("E1", enumValues()[1].toString()) + assertEquals("E2", enumValues()[2].toString()) + + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/enum/values.out b/native/native.tests/testData/codegen/enum/values.out deleted file mode 100644 index 3faa62b18e2..00000000000 --- a/native/native.tests/testData/codegen/enum/values.out +++ /dev/null @@ -1,6 +0,0 @@ -E3 -E1 -E2 -E3 -E1 -E2 diff --git a/native/native.tests/testData/codegen/enum/varargParam.kt b/native/native.tests/testData/codegen/enum/varargParam.kt index 99a637868f5..07633de87c1 100644 --- a/native/native.tests/testData/codegen/enum/varargParam.kt +++ b/native/native.tests/testData/codegen/enum/varargParam.kt @@ -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" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/enum/varargParam.out b/native/native.tests/testData/codegen/enum/varargParam.out deleted file mode 100644 index 00750edc07d..00000000000 --- a/native/native.tests/testData/codegen/enum/varargParam.out +++ /dev/null @@ -1 +0,0 @@ -3 diff --git a/native/native.tests/testData/codegen/escapeAnalysis/negativeArraySize.kt b/native/native.tests/testData/codegen/escapeAnalysis/negativeArraySize.kt index 526839dee3d..ea788464a45 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/negativeArraySize.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/negativeArraySize.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.escapeAnalysis.negativeArraySize - import kotlin.test.* const val size = -42 @@ -14,6 +12,8 @@ fun foo() { for (x in arr) println(x) } -@Test fun runTest() { +fun box(): String { assertFailsWith { foo() } + + return "OK" } diff --git a/native/native.tests/testData/codegen/escapeAnalysis/recursion.kt b/native/native.tests/testData/codegen/escapeAnalysis/recursion.kt index 08015939f1f..09498d03db3 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/recursion.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/recursion.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.escapeAnalysis.recursion - import kotlin.test.* class A { @@ -19,6 +17,8 @@ fun foo(k: Int, a1: A, a2: A): A { return foo(k - 1, a2, a3) } -@Test fun runTest() { +fun box(): String { foo(3, A(), A()).toString() + + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/escapeAnalysis/stackAllocated.kt b/native/native.tests/testData/codegen/escapeAnalysis/stackAllocated.kt index 1faeb8d0776..b207372b805 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/stackAllocated.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/stackAllocated.kt @@ -2,8 +2,8 @@ * Copyright 2010-2021 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.escapeAnalysis.stackAllocated +// IGNORE_NATIVE: optimizationMode=DEBUG +// IGNORE_NATIVE: optimizationMode=NO import kotlin.test.* import kotlin.native.internal.* @@ -18,6 +18,8 @@ fun f(x: Int): Int { return a.f(x) } -@Test fun runTest() { +fun box(): String { assertEquals(f(42), 55) + + return "OK" } diff --git a/native/native.tests/testData/codegen/escapeAnalysis/string.kt b/native/native.tests/testData/codegen/escapeAnalysis/stackAllocatedString.kt similarity index 69% rename from native/native.tests/testData/codegen/escapeAnalysis/string.kt rename to native/native.tests/testData/codegen/escapeAnalysis/stackAllocatedString.kt index f542ce8eeb6..beef86ebd77 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/string.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/stackAllocatedString.kt @@ -2,13 +2,15 @@ * Copyright 2010-2021 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.escapeAnalysis.string +// IGNORE_NATIVE: optimizationMode=DEBUG +// IGNORE_NATIVE: optimizationMode=NO import kotlin.test.* import kotlin.native.internal.* -@Test fun runTest() { +fun box(): String { val s = String() assertTrue(s.isLocal()) + + return "OK" } diff --git a/native/native.tests/testData/codegen/escapeAnalysis/stackNotAllocated.kt b/native/native.tests/testData/codegen/escapeAnalysis/stackNotAllocated.kt new file mode 100644 index 00000000000..162b821b884 --- /dev/null +++ b/native/native.tests/testData/codegen/escapeAnalysis/stackNotAllocated.kt @@ -0,0 +1,23 @@ +/* + * 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. + */ +// IGNORE_NATIVE: optimizationMode=OPT + +import kotlin.test.* +import kotlin.native.internal.* + +class A { + fun f(x: Int) = x + 13 +} + +fun f(x: Int): Int { + val a = A() + assertFalse(a.isLocal()) + return a.f(x) +} + +fun box(): String { + assertEquals(f(42), 55) + return "OK" +} diff --git a/native/native.tests/testData/codegen/escapeAnalysis/stackNotAllocatedString.kt b/native/native.tests/testData/codegen/escapeAnalysis/stackNotAllocatedString.kt new file mode 100644 index 00000000000..905da3125e1 --- /dev/null +++ b/native/native.tests/testData/codegen/escapeAnalysis/stackNotAllocatedString.kt @@ -0,0 +1,15 @@ +/* + * 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. + */ +// IGNORE_NATIVE: optimizationMode=OPT + +import kotlin.test.* +import kotlin.native.internal.* + +fun box(): String { + val s = String() + assertFalse(s.isLocal()) + + return "OK" +} \ No newline at end of file diff --git a/native/native.tests/testData/codegen/escapeAnalysis/stack_array.kt b/native/native.tests/testData/codegen/escapeAnalysis/stack_array.kt index a4e66c92f50..61fa1428ad9 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/stack_array.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/stack_array.kt @@ -3,15 +3,15 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package codegen.escapeAnalysis.stack_array - import kotlin.test.* -@Test fun runTest() { +fun box(): String { val array = IntArray(2) array[0] = 1 array[1] = 2 val check = array is IntArray - println(check) - println(array[0] + array[1]) + assertTrue(check) + assertEquals(3, array[0] + array[1]) + + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/escapeAnalysis/stack_array.out b/native/native.tests/testData/codegen/escapeAnalysis/stack_array.out deleted file mode 100644 index d65bc6d6ad1..00000000000 --- a/native/native.tests/testData/codegen/escapeAnalysis/stack_array.out +++ /dev/null @@ -1,2 +0,0 @@ -true -3 diff --git a/native/native.tests/testData/codegen/escapeAnalysis/test1.kt b/native/native.tests/testData/codegen/escapeAnalysis/test1.kt index 99284436de1..9413c9992f6 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/test1.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/test1.kt @@ -2,8 +2,7 @@ * Copyright 2010-2020 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.escapeAnalysis.test1 +// TODO: check mentioned debug output of escape analyser class A(val s: String) @@ -17,4 +16,4 @@ class A(val s: String) // Escapes: fun foo(a: A) = a -fun main() = println(foo(A("zzz"))) \ No newline at end of file +fun box(): String = foo(A("OK")).s \ No newline at end of file diff --git a/native/native.tests/testData/codegen/escapeAnalysis/test10.kt b/native/native.tests/testData/codegen/escapeAnalysis/test10.kt index a1ddef9774f..b3fa2d19caf 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/test10.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/test10.kt @@ -2,8 +2,8 @@ * Copyright 2010-2020 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.escapeAnalysis.test10 +// TODO: check mentioned debug output of escape analyser +import kotlin.test.* class G(val x: Int) @@ -38,4 +38,7 @@ fun bar(): F { return u } -fun main() = println(bar().g.x) \ No newline at end of file +fun box(): String { + assertEquals(42, bar().g.x) + return "OK" +} \ No newline at end of file diff --git a/native/native.tests/testData/codegen/escapeAnalysis/test11.kt b/native/native.tests/testData/codegen/escapeAnalysis/test11.kt index 1e8730a8db5..0db101cef78 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/test11.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/test11.kt @@ -2,8 +2,8 @@ * Copyright 2010-2020 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.escapeAnalysis.test11 +// TODO: check mentioned debug output of escape analyser +import kotlin.test.* class F(val x: Int) @@ -28,4 +28,7 @@ fun foo(a: A): F { return a.f } -fun main() = println(foo(A("zzz"))) \ No newline at end of file +fun box(): String { + assertEquals(0, foo(A("zzz")).x) + return "OK" +} diff --git a/native/native.tests/testData/codegen/escapeAnalysis/test12.kt b/native/native.tests/testData/codegen/escapeAnalysis/test12.kt index 44785fb24e2..d5d9180a92a 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/test12.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/test12.kt @@ -2,8 +2,7 @@ * Copyright 2010-2020 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.escapeAnalysis.test12 +// TODO: check mentioned debug output of escape analyser class A(val s: String) @@ -17,4 +16,4 @@ class A(val s: String) // Escapes: fun foo(arr: Array) = arr[0] -fun main() = println(foo(arrayOf(A("zzz"))).s) \ No newline at end of file +fun box(): String = foo(arrayOf(A("OK"))).s \ No newline at end of file diff --git a/native/native.tests/testData/codegen/escapeAnalysis/test13.kt b/native/native.tests/testData/codegen/escapeAnalysis/test13.kt index e07456a3333..718e2fcd2b5 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/test13.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/test13.kt @@ -2,8 +2,7 @@ * Copyright 2010-2020 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.escapeAnalysis.test13 +import kotlin.test.* class A { var f: A? = null @@ -13,8 +12,10 @@ fun foo(a: A, k: Int): A { return if (k == 0) a else foo(a.f!!, k - 1) } -fun main() { +fun box(): String { val a = A() - a.f = A() - println(foo(a, 1)) + val a2 = A() + a.f = a2 + assertEquals(a2, foo(a, 1)) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/escapeAnalysis/test2.kt b/native/native.tests/testData/codegen/escapeAnalysis/test2.kt index d9068afb897..e8775e2e305 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/test2.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/test2.kt @@ -2,8 +2,7 @@ * Copyright 2010-2020 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.escapeAnalysis.test2 +// TODO: check mentioned debug output of escape analyser class A(val s: String) @@ -17,4 +16,4 @@ class A(val s: String) // Escapes: fun foo(a: A) = a.s -fun main() = println(foo(A("zzz"))) \ No newline at end of file +fun box(): String = foo(A("OK")) \ No newline at end of file diff --git a/native/native.tests/testData/codegen/escapeAnalysis/test3.kt b/native/native.tests/testData/codegen/escapeAnalysis/test3.kt index 85ceb956100..45b2cde7ba3 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/test3.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/test3.kt @@ -2,8 +2,7 @@ * Copyright 2010-2020 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.escapeAnalysis.test3 +// TODO: check mentioned debug output of escape analyser class A(val s: String) class B { @@ -25,4 +24,4 @@ fun foo(a: A, b: B): String { return a.s } -fun main() = println(foo(A("zzz"), B())) \ No newline at end of file +fun box(): String = foo(A("OK"), B()) \ No newline at end of file diff --git a/native/native.tests/testData/codegen/escapeAnalysis/test4.kt b/native/native.tests/testData/codegen/escapeAnalysis/test4.kt index 34eee09a3a8..e4aac17d839 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/test4.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/test4.kt @@ -2,8 +2,7 @@ * Copyright 2010-2020 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.escapeAnalysis.test4 +// TODO: check mentioned debug output of escape analyser class A(val s: String) class B { @@ -27,4 +26,7 @@ fun foo(c1: C, c2: C) { c1.g.f = c2.g.f } -fun main() = println(foo(C(), C())) \ No newline at end of file +fun box(): String { + foo(C(), C()) + return "OK" +} diff --git a/native/native.tests/testData/codegen/escapeAnalysis/test5.kt b/native/native.tests/testData/codegen/escapeAnalysis/test5.kt index d86bc22fac4..322df8d8445 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/test5.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/test5.kt @@ -2,12 +2,11 @@ * Copyright 2010-2020 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.escapeAnalysis.test5 +// TODO: check mentioned debug output of escape analyser class A(val s: String) class B { - var f: A = A("qzz") + var f: A = A("OK") } class C { var g: B = B() @@ -32,4 +31,4 @@ fun foo(c1: C, c2: C): B { return b } -fun main() = println(foo(C(), C())) \ No newline at end of file +fun box(): String = foo(C(), C()).f.s \ No newline at end of file diff --git a/native/native.tests/testData/codegen/escapeAnalysis/test6.kt b/native/native.tests/testData/codegen/escapeAnalysis/test6.kt index 4d6798f48ef..a298fb334b2 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/test6.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/test6.kt @@ -2,8 +2,7 @@ * Copyright 2010-2020 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.escapeAnalysis.test6 +// TODO: check mentioned debug output of escape analyser class A(val s: String) class B { @@ -37,4 +36,4 @@ fun foo(z: Boolean, c1: C, c2: C, a: A): B { return v } -fun main() = println(foo(true, C(), C(), A("zzz"))) \ No newline at end of file +fun box(): String = foo(true, C(), C(), A("OK")).f.s \ No newline at end of file diff --git a/native/native.tests/testData/codegen/escapeAnalysis/test7.kt b/native/native.tests/testData/codegen/escapeAnalysis/test7.kt index f0952125e3a..408a9080d48 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/test7.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/test7.kt @@ -2,9 +2,9 @@ * Copyright 2010-2020 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. */ +// TODO: check mentioned debug output of escape analyser -package codegen.escapeAnalysis.test7 - +// Note: intentional infinite mutual recursion with `A(String)` and `C()`. Don't try to execute the code. class A(val s: String) { var h: String = "" var p: C = C() @@ -49,4 +49,8 @@ fun foo(z: Boolean, c: C, b: B, s: String, d: D) { u.p = c } -fun main() = println(foo(true, C(), B(), "zzz", D())) \ No newline at end of file +fun box(): String { + // When uncommented, execution of the following line would fall into infinite recursion + // foo(true, C(), B(), "zzz", D()) + return "OK" +} diff --git a/native/native.tests/testData/codegen/escapeAnalysis/test8.kt b/native/native.tests/testData/codegen/escapeAnalysis/test8.kt index 5b95b1c4059..2f935d72e3c 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/test8.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/test8.kt @@ -2,11 +2,11 @@ * Copyright 2010-2020 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. */ +// TODO: check mentioned debug output of escape analyser -package codegen.escapeAnalysis.test8 - +// Note: intentional infinite recursion for F(String). Don't try to execute the code. class F(val s: String) { - var g = F("") + var g = F("OK") } class A { @@ -40,4 +40,8 @@ fun foo(a: A): F { return a.f.g.g } -fun main() = println(foo(A()).s) \ No newline at end of file +fun box(): String { + // When uncommented, execution of the following line would fall into infinite recursion + // foo(A()).s + return "OK" +} \ No newline at end of file diff --git a/native/native.tests/testData/codegen/escapeAnalysis/test9.kt b/native/native.tests/testData/codegen/escapeAnalysis/test9.kt index ccbc9097872..b40665017e9 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/test9.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/test9.kt @@ -2,11 +2,12 @@ * Copyright 2010-2020 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.escapeAnalysis.test9 +// TODO: check mentioned debug output of escape analyser +import kotlin.test.* class H(val x: Int) +// Note: intentional infinite recursion for F(String). Don't try to execute the code. class F(val s: String) { var g = F("") var h = H(0) @@ -33,4 +34,8 @@ fun foo(a: A, f: F): H { return f.g.h } -fun main() = println(foo(A(), F("zzz")).x) \ No newline at end of file +fun box(): String { + // When uncommented, execution of the following line would fall into infinite recursion + // assertEquals(0, foo(A(), F("zzz")).x) + return "OK" +} \ No newline at end of file diff --git a/native/native.tests/testData/codegen/escapeAnalysis/zeroOutObjectOnAlloc.kt b/native/native.tests/testData/codegen/escapeAnalysis/zeroOutObjectOnAlloc.kt index b1a25997e3e..f2f2b317a55 100644 --- a/native/native.tests/testData/codegen/escapeAnalysis/zeroOutObjectOnAlloc.kt +++ b/native/native.tests/testData/codegen/escapeAnalysis/zeroOutObjectOnAlloc.kt @@ -3,15 +3,13 @@ * that can be found in the LICENSE file. */ -package codegen.escapeAnalysis.zeroOutObjectOnAlloc - import kotlin.test.* class A { var x = 0 } -@Test fun runTest() { +fun box(): String { var sum1 = 0 var sum2 = 0 for (i in 0 until 10) { @@ -22,4 +20,6 @@ class A { } assertEquals(0, sum1) assertEquals(45, sum2) + + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/funInterface/implIsNotFunction.kt b/native/native.tests/testData/codegen/funInterface/implIsNotFunction.kt index 64a41058e31..b24bc2ec983 100644 --- a/native/native.tests/testData/codegen/funInterface/implIsNotFunction.kt +++ b/native/native.tests/testData/codegen/funInterface/implIsNotFunction.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.funInterface.implIsNotFunction - import kotlin.test.* fun interface Foo { @@ -13,7 +11,7 @@ fun interface Foo { fun foo(f: Foo) = f is Function<*> -@Test -fun test() { +fun box(): String { assertFalse(foo { "zzz" }) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/funInterface/kt43887.kt b/native/native.tests/testData/codegen/funInterface/kt43887.kt index 3565bc145f2..757178a16df 100644 --- a/native/native.tests/testData/codegen/funInterface/kt43887.kt +++ b/native/native.tests/testData/codegen/funInterface/kt43887.kt @@ -3,7 +3,6 @@ * that can be found in the LICENSE file. */ @file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) -package codegen.funInterface.kt43887 import kotlin.test.* @@ -27,12 +26,14 @@ inline fun CPointer?.free(ptr: CPointer<*>?): Boolean { return heap_free(this, ptr)?.pointed?.value ?: false } -@Test -fun runTest(): Unit = memScoped { +fun box(): String { + memScoped { val heap = Heap(1024) heap.use { ptr -> ptr.pointed.value = 40 //println("PTR ${ptr.pointed}") } + } + return "OK" } diff --git a/native/native.tests/testData/codegen/funInterface/kt49384.kt b/native/native.tests/testData/codegen/funInterface/kt49384.kt index 15d46218f90..2b9600fca98 100644 --- a/native/native.tests/testData/codegen/funInterface/kt49384.kt +++ b/native/native.tests/testData/codegen/funInterface/kt49384.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.funInterface.kt49384 - import kotlin.test.* interface A @@ -17,20 +15,9 @@ class B { } } -@Test -fun test1() { +fun box(): String { val b = B() assertEquals(b, b) // Just to ensure B is not deleted by DCE -} -fun interface Foo { - fun same(obj: T): T -} - -fun getSame(obj: A, foo: Foo>) = foo.same(obj) - -@Test -fun test2() { - val obj = object : A {} - assertSame(obj, getSame(obj) { it }) + return "OK" } diff --git a/native/native.tests/testData/codegen/funInterface/kt49384_getSame.kt b/native/native.tests/testData/codegen/funInterface/kt49384_getSame.kt new file mode 100644 index 00000000000..d4c42588100 --- /dev/null +++ b/native/native.tests/testData/codegen/funInterface/kt49384_getSame.kt @@ -0,0 +1,22 @@ +/* + * Copyright 2010-2021 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. + */ + +import kotlin.test.* + +interface A + +// https://youtrack.jetbrains.com/issue/KT-49384 +fun interface Foo { + fun same(obj: T): T +} + +fun getSame(obj: A, foo: Foo>) = foo.same(obj) + +fun box(): String { + val obj = object : A {} + assertSame(obj, getSame(obj) { it }) + + return "OK" +} diff --git a/native/native.tests/testData/codegen/funInterface/nonTrivialProjectionInSuperType.kt b/native/native.tests/testData/codegen/funInterface/nonTrivialProjectionInSuperType.kt index 29b97a9874f..03e19d3883c 100644 --- a/native/native.tests/testData/codegen/funInterface/nonTrivialProjectionInSuperType.kt +++ b/native/native.tests/testData/codegen/funInterface/nonTrivialProjectionInSuperType.kt @@ -3,15 +3,13 @@ * that can be found in the LICENSE file. */ -package codegen.funInterface.nonTrivialProjectionInSuperType - import kotlin.test.* fun foo(comparator: kotlin.Comparator, a: T, b: T) = comparator.compare(a, b) fun bar(x: Int, y: Int) = foo ({ a, b -> a - b}, x, y) -@Test -fun test() { +fun box(): String { assertTrue(bar(42, 117) < 0) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/arithmetic.kt b/native/native.tests/testData/codegen/function/arithmetic.kt index 7c6b2fb5825..184ec0538ea 100644 --- a/native/native.tests/testData/codegen/function/arithmetic.kt +++ b/native/native.tests/testData/codegen/function/arithmetic.kt @@ -3,20 +3,18 @@ * that can be found in the LICENSE file. */ -package codegen.function.arithmetic - -import kotlin.test.* - fun square(a:Int):Int = a * a fun sumOfSquares(a:Int, b:Int):Int = square(a) + square(b) fun diffOfSquares(a:Int, b:Int):Int = square(a) - square(b) fun mod(a:Int,b:Int):Int = a / b fun remainder(a:Int, b:Int):Int = a % b -@Test fun runTest() { +fun box(): String { if (square(2) != 4) throw Error() if (sumOfSquares(2, 4) != 20) throw Error() if (diffOfSquares(2, 4) != -12) throw Error() if (mod(5, 2) != 2) throw Error() if (remainder(5, 2) != 1) throw Error() + + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/boolean.kt b/native/native.tests/testData/codegen/function/boolean.kt index 0cf3bf62500..879e00a3073 100644 --- a/native/native.tests/testData/codegen/function/boolean.kt +++ b/native/native.tests/testData/codegen/function/boolean.kt @@ -3,12 +3,10 @@ * that can be found in the LICENSE file. */ -package codegen.function.boolean - -import kotlin.test.* - fun bool_yes(): Boolean = true -@Test fun runTest() { - if (!bool_yes()) throw Error() +fun box(): String { + if (!bool_yes()) return "FAIL !bool_yes()" + + return "OK" } diff --git a/native/native.tests/testData/codegen/function/defaults.kt b/native/native.tests/testData/codegen/function/defaults.kt index 4dcc1b96a6b..796cbffa45b 100644 --- a/native/native.tests/testData/codegen/function/defaults.kt +++ b/native/native.tests/testData/codegen/function/defaults.kt @@ -3,10 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.function.defaults - -import kotlin.test.* - /** * Created by minamoto on 12/26/16. */ @@ -48,7 +44,7 @@ fun foo(a: A = A.magic, b:Int = 0xdeadbeef.toInt()) = a.a fun bar(a:A, inc:Int = 0) = A(a.a + inc) -@Test fun runTest() { +fun box(): String { // if: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ // arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ @@ -98,5 +94,5 @@ fun bar(a:A, inc:Int = 0) = A(a.a + inc) println("A one + 1 failed") throw Error() } - println("all tests passed") + return "OK" } diff --git a/native/native.tests/testData/codegen/function/defaults1.kt b/native/native.tests/testData/codegen/function/defaults1.kt index d37e43de7a3..1e353168f4b 100644 --- a/native/native.tests/testData/codegen/function/defaults1.kt +++ b/native/native.tests/testData/codegen/function/defaults1.kt @@ -3,16 +3,15 @@ * that can be found in the LICENSE file. */ -package codegen.function.defaults1 - import kotlin.test.* fun foo(x:Int = 0, y:Int = x + 1, z:Int = x + y + 1) = x + y + z -@Test fun runTest() { +fun box(): String { val v = foo() if (v != 3) { println("test failed $v expected 3") throw Error() } + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/defaults10.kt b/native/native.tests/testData/codegen/function/defaults10.kt index 5e51f847493..ba89ba77fa6 100644 --- a/native/native.tests/testData/codegen/function/defaults10.kt +++ b/native/native.tests/testData/codegen/function/defaults10.kt @@ -3,14 +3,13 @@ * that can be found in the LICENSE file. */ -package codegen.function.defaults10 - import kotlin.test.* enum class A(one: Int, val two: Int = one) { FOO(42) } -@Test fun runTest() { - println(A.FOO.two) +fun box(): String { + assertEquals(42, (A.FOO.two)) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/defaults10.out b/native/native.tests/testData/codegen/function/defaults10.out deleted file mode 100644 index d81cc0710eb..00000000000 --- a/native/native.tests/testData/codegen/function/defaults10.out +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/native/native.tests/testData/codegen/function/defaults2.kt b/native/native.tests/testData/codegen/function/defaults2.kt index 36ece284eef..4962d701e1f 100644 --- a/native/native.tests/testData/codegen/function/defaults2.kt +++ b/native/native.tests/testData/codegen/function/defaults2.kt @@ -3,17 +3,16 @@ * that can be found in the LICENSE file. */ -package codegen.function.defaults2 - import kotlin.test.* fun Int.foo(inc0:Int, inc:Int = 0) = this + inc0 + inc -@Test fun runTest() { +fun box(): String { val v = 42.foo(0) if (v != 42) { println("test failed v:$v expected:42") throw Error() } + return "OK" } diff --git a/native/native.tests/testData/codegen/function/defaults3.kt b/native/native.tests/testData/codegen/function/defaults3.kt index 4b82f762f3f..03fff874e14 100644 --- a/native/native.tests/testData/codegen/function/defaults3.kt +++ b/native/native.tests/testData/codegen/function/defaults3.kt @@ -3,14 +3,10 @@ * that can be found in the LICENSE file. */ -package codegen.function.defaults3 - -import kotlin.test.* - fun foo(a:Int = 2, b:String = "Hello", c:Int = 4):String = "$b-$c$a" fun foo(a:Int = 3, b:Int = a + 1, c:Int = a + b) = a + b + c -@Test fun runTest() { +fun box(): String { val a = foo(b="Universe") if (a != "Universe-42") throw Error() @@ -18,4 +14,6 @@ fun foo(a:Int = 3, b:Int = a + 1, c:Int = a + b) = a + b + c val b = foo(b = 5) if (b != (/* a = */ 3 + /* b = */ 5 + /* c = */ (3 + 5))) throw Error() + + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/defaults4.kt b/native/native.tests/testData/codegen/function/defaults4.kt index 6b1a02c5909..a41e9b45d7b 100644 --- a/native/native.tests/testData/codegen/function/defaults4.kt +++ b/native/native.tests/testData/codegen/function/defaults4.kt @@ -3,20 +3,23 @@ * that can be found in the LICENSE file. */ -package codegen.function.defaults4 - import kotlin.test.* +val sb = StringBuilder() + open class A { - open fun foo(x: Int = 42) = println(x) + open fun foo(x: Int = 42) = sb.append(x) } open class B : A() class C : B() { - override fun foo(x: Int) = println(x + 1) + override fun foo(x: Int) = sb.append(x + 1) } -@Test fun runTest() { +fun box(): String { C().foo() + + assertEquals("43", sb.toString()) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/defaults4.out b/native/native.tests/testData/codegen/function/defaults4.out deleted file mode 100644 index 920a1396648..00000000000 --- a/native/native.tests/testData/codegen/function/defaults4.out +++ /dev/null @@ -1 +0,0 @@ -43 diff --git a/native/native.tests/testData/codegen/function/defaults5.kt b/native/native.tests/testData/codegen/function/defaults5.kt index 3c079c00d08..d1801220f62 100644 --- a/native/native.tests/testData/codegen/function/defaults5.kt +++ b/native/native.tests/testData/codegen/function/defaults5.kt @@ -3,21 +3,24 @@ * that can be found in the LICENSE file. */ -package codegen.function.defaults5 - import kotlin.test.* +val sb = StringBuilder() + class TestClass(val x: Int) { fun foo(y: Int = x) { - println(y) + sb.appendLine(y) } } fun TestClass.bar(y: Int = x) { - println(y) + sb.appendLine(y) } -@Test fun runTest() { +fun box(): String { TestClass(5).foo() TestClass(6).bar() + + assertEquals("5\n6\n", sb.toString()) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/defaults5.out b/native/native.tests/testData/codegen/function/defaults5.out deleted file mode 100644 index 6613b568867..00000000000 --- a/native/native.tests/testData/codegen/function/defaults5.out +++ /dev/null @@ -1,2 +0,0 @@ -5 -6 diff --git a/native/native.tests/testData/codegen/function/defaults6.kt b/native/native.tests/testData/codegen/function/defaults6.kt index 8edbb145bda..66b10eaa563 100644 --- a/native/native.tests/testData/codegen/function/defaults6.kt +++ b/native/native.tests/testData/codegen/function/defaults6.kt @@ -3,13 +3,12 @@ * that can be found in the LICENSE file. */ -package codegen.function.defaults6 - import kotlin.test.* open class Foo(val x: Int = 42) class Bar : Foo() -@Test fun runTest() { - println(Bar().x) +fun box(): String { + assertEquals(42, Bar().x) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/defaults6.out b/native/native.tests/testData/codegen/function/defaults6.out deleted file mode 100644 index d81cc0710eb..00000000000 --- a/native/native.tests/testData/codegen/function/defaults6.out +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/native/native.tests/testData/codegen/function/defaults7.kt b/native/native.tests/testData/codegen/function/defaults7.kt index d8dd0c6c4d4..670aea1d360 100644 --- a/native/native.tests/testData/codegen/function/defaults7.kt +++ b/native/native.tests/testData/codegen/function/defaults7.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.function.defaults7 - import kotlin.test.* /** @@ -16,10 +14,15 @@ import kotlin.test.* * to label %label_1 unwind label %cleanup_landingpad */ +val sb = StringBuilder() + fun foo(a : T, b : Int = 42){ - println(b) + sb.append(b) } -@Test fun runTest() { +fun box(): String { foo(1) + + assertEquals("42", sb.toString()) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/defaults7.out b/native/native.tests/testData/codegen/function/defaults7.out deleted file mode 100644 index d81cc0710eb..00000000000 --- a/native/native.tests/testData/codegen/function/defaults7.out +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/native/native.tests/testData/codegen/function/defaults8.kt b/native/native.tests/testData/codegen/function/defaults8.kt index 7067196511f..a6fba1b57f5 100644 --- a/native/native.tests/testData/codegen/function/defaults8.kt +++ b/native/native.tests/testData/codegen/function/defaults8.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.function.defaults8 - import kotlin.test.* class Foo { @@ -15,6 +13,8 @@ class Bar { fun test(x: Int = 2) = x } -@Test fun runTest() { - println(Bar().test()) +fun box(): String { + assertEquals(2, Bar().test()) + + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/defaults8.out b/native/native.tests/testData/codegen/function/defaults8.out deleted file mode 100644 index 0cfbf08886f..00000000000 --- a/native/native.tests/testData/codegen/function/defaults8.out +++ /dev/null @@ -1 +0,0 @@ -2 diff --git a/native/native.tests/testData/codegen/function/defaults9.kt b/native/native.tests/testData/codegen/function/defaults9.kt index 4253e740a27..9f3909bfcb0 100644 --- a/native/native.tests/testData/codegen/function/defaults9.kt +++ b/native/native.tests/testData/codegen/function/defaults9.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.function.defaults9 - import kotlin.test.* class Foo { @@ -13,4 +11,7 @@ class Foo { } } -@Test fun runTest() = println(Foo().Bar().y) +fun box(): String { + assertEquals(1, Foo().Bar().y) + return "OK" +} \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/defaults9.out b/native/native.tests/testData/codegen/function/defaults9.out deleted file mode 100644 index d00491fd7e5..00000000000 --- a/native/native.tests/testData/codegen/function/defaults9.out +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/native/native.tests/testData/codegen/function/defaultsFromFakeOverride.kt b/native/native.tests/testData/codegen/function/defaultsFromFakeOverride.kt index f79e3bb25cc..0bada866ba3 100644 --- a/native/native.tests/testData/codegen/function/defaultsFromFakeOverride.kt +++ b/native/native.tests/testData/codegen/function/defaultsFromFakeOverride.kt @@ -3,12 +3,10 @@ * that can be found in the LICENSE file. */ -package codegen.function.defaultsFromFakeOverride - import kotlin.test.* interface I { - fun f(x: String = "42"): String + fun f(x: String = "OK"): String } open class A { @@ -17,7 +15,7 @@ open class A { class B : A(), I -@Test fun runTest() { +fun box(): String { val b = B() - println(b.f()) + return b.f() } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/defaultsFromFakeOverride.out b/native/native.tests/testData/codegen/function/defaultsFromFakeOverride.out deleted file mode 100644 index d81cc0710eb..00000000000 --- a/native/native.tests/testData/codegen/function/defaultsFromFakeOverride.out +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/native/native.tests/testData/codegen/function/defaultsWithInlineClasses.kt b/native/native.tests/testData/codegen/function/defaultsWithInlineClasses.kt index 6a21b2a1915..4db56e01602 100644 --- a/native/native.tests/testData/codegen/function/defaultsWithInlineClasses.kt +++ b/native/native.tests/testData/codegen/function/defaultsWithInlineClasses.kt @@ -3,14 +3,14 @@ * that can be found in the LICENSE file. */ -package codegen.function.defaultsWithInlineClasses - import kotlin.test.* inline class Foo(val value: Int) fun foo(x: Foo = Foo(42)) = x.value -@Test fun runTest() { +fun box(): String { assertEquals(foo(), 42) assertEquals(foo(Foo(17)), 17) + + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/defaultsWithVarArg1.kt b/native/native.tests/testData/codegen/function/defaultsWithVarArg1.kt index 6cbefc1e0a3..954bd824917 100644 --- a/native/native.tests/testData/codegen/function/defaultsWithVarArg1.kt +++ b/native/native.tests/testData/codegen/function/defaultsWithVarArg1.kt @@ -3,24 +3,32 @@ * that can be found in the LICENSE file. */ -package codegen.function.defaultsWithVarArg1 - import kotlin.test.* +val sb = StringBuilder() + fun foo(s: String = "", vararg args: Any) { if (args == null) { - println("Failed!") + sb.appendLine("Failed!") } else { - print("$s ") + sb.append("$s ") args.forEach { - print("$it") + sb.append("$it") } - println(", Correct!") + sb.appendLine(", Correct!") } } -@Test fun runTest() { +fun box(): String { foo("Hello") foo("Hello", "World") foo() + + assertEquals(""" + Hello , Correct! + Hello World, Correct! + , Correct! + + """.trimIndent(), sb.toString()) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/defaultsWithVarArg1.out b/native/native.tests/testData/codegen/function/defaultsWithVarArg1.out deleted file mode 100644 index bb168e691f7..00000000000 --- a/native/native.tests/testData/codegen/function/defaultsWithVarArg1.out +++ /dev/null @@ -1,3 +0,0 @@ -Hello , Correct! -Hello World, Correct! - , Correct! diff --git a/native/native.tests/testData/codegen/function/defaultsWithVarArg2.kt b/native/native.tests/testData/codegen/function/defaultsWithVarArg2.kt index 6962fda8b86..a44f0398358 100644 --- a/native/native.tests/testData/codegen/function/defaultsWithVarArg2.kt +++ b/native/native.tests/testData/codegen/function/defaultsWithVarArg2.kt @@ -3,15 +3,23 @@ * that can be found in the LICENSE file. */ -package codegen.function.defaultsWithVarArg2 - import kotlin.test.* +val sb = StringBuilder() + fun foo(vararg arr: Int = intArrayOf(1, 2)) { - arr.forEach { println(it) } + arr.forEach { sb.appendLine(it) } } -@Test fun runTest() { +fun box(): String { foo() foo(42) + + assertEquals(""" + 1 + 2 + 42 + + """.trimIndent(), sb.toString()) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/defaultsWithVarArg2.out b/native/native.tests/testData/codegen/function/defaultsWithVarArg2.out deleted file mode 100644 index 730baf6de6d..00000000000 --- a/native/native.tests/testData/codegen/function/defaultsWithVarArg2.out +++ /dev/null @@ -1,3 +0,0 @@ -1 -2 -42 diff --git a/native/native.tests/testData/codegen/function/eqeq.kt b/native/native.tests/testData/codegen/function/eqeq.kt index 65bcb6f7008..14e9dde8c5b 100644 --- a/native/native.tests/testData/codegen/function/eqeq.kt +++ b/native/native.tests/testData/codegen/function/eqeq.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.function.eqeq - import kotlin.test.* fun eqeqB (a:Byte, b:Byte ) = a == b @@ -35,7 +33,7 @@ fun neF (a:Float, b:Float ) = a != b fun helloString() = "Hello" fun goodbyeString() = "Goodbye" -@Test fun runTest() { +fun box(): String { if (!eqeqB(3 , 3 )) throw Error() if (!eqeqS(3 , 3 )) throw Error() if (!eqeqI(3 , 3 )) throw Error() @@ -61,4 +59,6 @@ fun goodbyeString() = "Goodbye" if (geF (2.0f , 3.0f )) throw Error() if (leF (3.0f , 2.0f )) throw Error() if (neF (2.0f , 2.0f )) throw Error() + + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/extension.kt b/native/native.tests/testData/codegen/function/extension.kt index 33ff3db55b8..38fc547660b 100644 --- a/native/native.tests/testData/codegen/function/extension.kt +++ b/native/native.tests/testData/codegen/function/extension.kt @@ -3,6 +3,13 @@ * that can be found in the LICENSE file. */ +import kotlin.test.* + class B(val a: Int) -fun B.foo() = this.a \ No newline at end of file +fun B.foo() = this.a + +fun box(): String { + assertEquals(42, B(42).foo()) + return "OK" +} \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/intrinsic.kt b/native/native.tests/testData/codegen/function/intrinsic.kt index 2f507b8fd6b..ca89cdef067 100644 --- a/native/native.tests/testData/codegen/function/intrinsic.kt +++ b/native/native.tests/testData/codegen/function/intrinsic.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.function.intrinsic - import kotlin.test.* // This code fails to link when bultins are taken from the @@ -18,6 +16,7 @@ fun intrinsic(b: Int): Int { return sum } -@Test fun runTest() { - if (intrinsic(3) != 4) throw Error() +fun box(): String { + assertEquals(4, intrinsic(3)) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/localFunction.kt b/native/native.tests/testData/codegen/function/localFunction.kt index 406a05e2346..ebe34abe418 100644 --- a/native/native.tests/testData/codegen/function/localFunction.kt +++ b/native/native.tests/testData/codegen/function/localFunction.kt @@ -3,13 +3,13 @@ * that can be found in the LICENSE file. */ -package codegen.function.localFunction - import kotlin.test.* -@Test fun runTest() { +val sb = StringBuilder() + +fun box(): String { val x = 1 - fun local0() = println(x) + fun local0() = sb.appendLine(x) fun local1() { fun local2() { local1() @@ -28,5 +28,6 @@ import kotlin.test.* } } - println("OK") + assertEquals("", sb.toString()) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/localFunction.out b/native/native.tests/testData/codegen/function/localFunction.out deleted file mode 100644 index d86bac9de59..00000000000 --- a/native/native.tests/testData/codegen/function/localFunction.out +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/native/native.tests/testData/codegen/function/localFunction2.kt b/native/native.tests/testData/codegen/function/localFunction2.kt index 0f7ca113cc2..83673d53a4c 100644 --- a/native/native.tests/testData/codegen/function/localFunction2.kt +++ b/native/native.tests/testData/codegen/function/localFunction2.kt @@ -3,11 +3,9 @@ * that can be found in the LICENSE file. */ -package codegen.function.localFunction2 - import kotlin.test.* -@Test fun runTest() { +fun box(): String { var a = 0 fun local() { class A { @@ -21,5 +19,5 @@ import kotlin.test.* return A() } } - println("OK") + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/localFunction2.out b/native/native.tests/testData/codegen/function/localFunction2.out deleted file mode 100644 index d86bac9de59..00000000000 --- a/native/native.tests/testData/codegen/function/localFunction2.out +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/native/native.tests/testData/codegen/function/localFunction3.kt b/native/native.tests/testData/codegen/function/localFunction3.kt index 80cc882c9d9..db02d02f5bb 100644 --- a/native/native.tests/testData/codegen/function/localFunction3.kt +++ b/native/native.tests/testData/codegen/function/localFunction3.kt @@ -3,11 +3,9 @@ * that can be found in the LICENSE file. */ -package codegen.function.localFunction3 - import kotlin.test.* -@Test fun runTest() { +fun box(): String { fun bar() { fun local1() { bar() @@ -21,5 +19,5 @@ import kotlin.test.* } local2() } - println("OK") + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/localFunction3.out b/native/native.tests/testData/codegen/function/localFunction3.out deleted file mode 100644 index d86bac9de59..00000000000 --- a/native/native.tests/testData/codegen/function/localFunction3.out +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/native/native.tests/testData/codegen/function/minus_eq.kt b/native/native.tests/testData/codegen/function/minus_eq.kt index 986e3d9e525..1dbb75bbc0d 100644 --- a/native/native.tests/testData/codegen/function/minus_eq.kt +++ b/native/native.tests/testData/codegen/function/minus_eq.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.function.minus_eq - import kotlin.test.* fun minus_eq(a: Int): Int { @@ -13,6 +11,7 @@ fun minus_eq(a: Int): Int { return b } -@Test fun runTest() { - if (minus_eq(23) != -12) throw Error() +fun box(): String { + assertEquals (-12, minus_eq(23)) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/named.kt b/native/native.tests/testData/codegen/function/named.kt index fe0b9aaf3cc..af495531eb0 100644 --- a/native/native.tests/testData/codegen/function/named.kt +++ b/native/native.tests/testData/codegen/function/named.kt @@ -3,13 +3,11 @@ * that can be found in the LICENSE file. */ -package codegen.function.named - import kotlin.test.* fun foo(a:Int, b:Int) = a - b -@Test fun runTest() { - if (foo(b = 24, a = 42) != 18) - throw Error() +fun box(): String { + assertEquals(18, foo(b = 24, a = 42)) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/nothingNReturningSafeCall.kt b/native/native.tests/testData/codegen/function/nothingNReturningSafeCall.kt index bf2636c34df..484559d4ccd 100644 --- a/native/native.tests/testData/codegen/function/nothingNReturningSafeCall.kt +++ b/native/native.tests/testData/codegen/function/nothingNReturningSafeCall.kt @@ -3,8 +3,6 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package codegen.function.nothingN_returning_safe_call - import kotlin.test.* fun Any.nothing(): Nothing { @@ -34,7 +32,7 @@ fun testLambda2() { block(null) } -fun main() { +fun box(): String { testFunction1(null) testFunction2(null) testFunction3(null) @@ -43,4 +41,6 @@ fun main() { testLambda1() testLambda2() + + return "OK" } diff --git a/native/native.tests/testData/codegen/function/plus_eq.kt b/native/native.tests/testData/codegen/function/plus_eq.kt index b17daa93ffa..2a2d4ec38fe 100644 --- a/native/native.tests/testData/codegen/function/plus_eq.kt +++ b/native/native.tests/testData/codegen/function/plus_eq.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.function.plus_eq - import kotlin.test.* fun plus_eq(a: Int): Int { @@ -13,6 +11,7 @@ fun plus_eq(a: Int): Int { return b } -@Test fun runTest() { - if (plus_eq(3) != 14) throw Error() +fun box(): String { + assertEquals(14, plus_eq(3)) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/referenceBigArity.kt b/native/native.tests/testData/codegen/function/referenceBigArity.kt index 0490124f03c..3cdbbc98956 100644 --- a/native/native.tests/testData/codegen/function/referenceBigArity.kt +++ b/native/native.tests/testData/codegen/function/referenceBigArity.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.function.referenceBigArity - import kotlin.test.* fun фу(а: Int, б: Int, в: Int, г: Int, д: Int, е: Int, ё: Int, ж: Int, з: Int, и: Int, й: Int, к: Int, @@ -14,8 +12,9 @@ fun фу(а: Int, б: Int, в: Int, г: Int, д: Int, е: Int, ё: Int, ж: Int, п + р + с + т + у + ф + х + ц + ч + ш + щ + ъ + ы + ь + э + ю + я } -@Test fun runTest() { +fun box(): String { val ref = ::фу - println(ref(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + assertEquals(528, ref(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32)) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/referenceBigArity.out b/native/native.tests/testData/codegen/function/referenceBigArity.out deleted file mode 100644 index 9dbddfafab5..00000000000 --- a/native/native.tests/testData/codegen/function/referenceBigArity.out +++ /dev/null @@ -1 +0,0 @@ -528 diff --git a/native/native.tests/testData/codegen/function/sum.kt b/native/native.tests/testData/codegen/function/sum.kt index 2c1fade5980..c34e87ad572 100644 --- a/native/native.tests/testData/codegen/function/sum.kt +++ b/native/native.tests/testData/codegen/function/sum.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.function.sum - import kotlin.test.* fun sumIB(a:Int, b:Byte ) = a + b @@ -16,7 +14,7 @@ fun sumID(a:Int, b:Double) = a + b fun modID(a:Int, b:Double) = a % b -@Test fun runTest() { +fun box(): String { if (sumIB(2, 3) != 5) throw Error() if (sumIS(2, 3) != 5) throw Error() if (sumII(2, 3) != 5) throw Error() @@ -24,4 +22,6 @@ fun modID(a:Int, b:Double) = a % b if (sumIF(2, 3.0f) != 5.0f) throw Error() if (sumID(2, 3.0) != 5.0) throw Error() if (modID(5, 3.0) != 2.0) throw Error() + + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/sum_3const.kt b/native/native.tests/testData/codegen/function/sum_3const.kt index 10a746a23b4..f72e64a1ac2 100644 --- a/native/native.tests/testData/codegen/function/sum_3const.kt +++ b/native/native.tests/testData/codegen/function/sum_3const.kt @@ -3,13 +3,12 @@ * that can be found in the LICENSE file. */ -package codegen.function.sum_3const - import kotlin.test.* fun sum3():Int = sum(1, 2, 33) fun sum(a:Int, b:Int, c:Int): Int = a + b + c -@Test fun runTest() { - if (sum3() != 36) throw Error() +fun box(): String { + assertEquals(36, sum3()) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/sum_foo_bar.kt b/native/native.tests/testData/codegen/function/sum_foo_bar.kt index 7fe24b3f84a..cc9813a4aed 100644 --- a/native/native.tests/testData/codegen/function/sum_foo_bar.kt +++ b/native/native.tests/testData/codegen/function/sum_foo_bar.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.function.sum_foo_bar - import kotlin.test.* fun foo(a:Int):Int = a @@ -12,6 +10,7 @@ fun bar(a:Int):Int = a fun sumFooBar(a:Int, b:Int):Int = foo(a) + bar(b) -@Test fun runTest() { - if (sumFooBar(2, 3) != 5) throw Error() +fun box(): String { + assertEquals(5, sumFooBar(2, 3)) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/sum_func.kt b/native/native.tests/testData/codegen/function/sum_func.kt index 9b1cf07d08d..31eb15fcb8a 100644 --- a/native/native.tests/testData/codegen/function/sum_func.kt +++ b/native/native.tests/testData/codegen/function/sum_func.kt @@ -3,12 +3,13 @@ * that can be found in the LICENSE file. */ -package codegen.function.sum_func - import kotlin.test.* fun foo():Int = 1 -//fun bar():Int = 2 -//fun sum():Int = foo() + bar() +fun bar():Int = 2 +fun sum():Int = foo() + bar() -// FIXME: has no checks \ No newline at end of file +fun box(): String { + assertEquals(3, sum()) + return "OK" +} diff --git a/native/native.tests/testData/codegen/function/sum_imm.kt b/native/native.tests/testData/codegen/function/sum_imm.kt index 0386c2a6e21..2970e5f36e9 100644 --- a/native/native.tests/testData/codegen/function/sum_imm.kt +++ b/native/native.tests/testData/codegen/function/sum_imm.kt @@ -3,12 +3,11 @@ * that can be found in the LICENSE file. */ -package codegen.function.sum_imm - import kotlin.test.* fun sum(a:Int): Int = a + 33 -@Test fun runTest() { - if (sum(2) != 35) throw Error() +fun box(): String { + assertEquals(35, sum(2)) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/function/sum_mixed.kt b/native/native.tests/testData/codegen/function/sum_mixed.kt index 9a259e37351..bd3620e9359 100644 --- a/native/native.tests/testData/codegen/function/sum_mixed.kt +++ b/native/native.tests/testData/codegen/function/sum_mixed.kt @@ -3,9 +3,11 @@ * that can be found in the LICENSE file. */ -package codegen.function.sum_mixed - import kotlin.test.* -// FIXME: has no checks -fun sum(a:Float, b:Int) = a + b \ No newline at end of file +fun sum(a:Float, b:Int) = a + b + +fun box(): String { + assertEquals(3.0F, sum(1.0F, 2)) + return "OK" +} diff --git a/native/native.tests/testData/codegen/function/sum_silly.kt b/native/native.tests/testData/codegen/function/sum_silly.kt index f979af5d5c4..920971834cb 100644 --- a/native/native.tests/testData/codegen/function/sum_silly.kt +++ b/native/native.tests/testData/codegen/function/sum_silly.kt @@ -3,14 +3,15 @@ * that can be found in the LICENSE file. */ -package codegen.function.sum_silly - import kotlin.test.* -// FIXME: has no checks - fun sum(a:Int, b:Int):Int { var c:Int c = a + b return c -} \ No newline at end of file +} + +fun box(): String { + assertEquals(50, sum(42, 8)) + return "OK" +} diff --git a/native/native.tests/testData/codegen/function/unreachableStatementAfterReturn.kt b/native/native.tests/testData/codegen/function/unreachableStatementAfterReturn.kt index aecc633e216..a998fd598a9 100644 --- a/native/native.tests/testData/codegen/function/unreachableStatementAfterReturn.kt +++ b/native/native.tests/testData/codegen/function/unreachableStatementAfterReturn.kt @@ -3,8 +3,8 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package codegen.function.unreachable_statement_after_return import kotlin.coroutines.* +import kotlin.test.* fun test1(): Any? { return 1 @@ -53,15 +53,17 @@ private fun (suspend () -> T).runCoroutine() : T { return result as T } -fun main() { - println(test1()) - println(test2()) - println(test3()) - println(test4()) +fun box(): String { + assertEquals(1, test1()) + assertEquals(2, test2()) + assertEquals(3, test3()) + assertEquals(4, test4()) - println(::test5.runCoroutine()) - println(::test6.runCoroutine()) - println(::test7.runCoroutine()) - println(::test8.runCoroutine()) + assertEquals(5, ::test5.runCoroutine()) + assertEquals(6, ::test6.runCoroutine()) + assertEquals(7, ::test7.runCoroutine()) + assertEquals(8, ::test8.runCoroutine()) + + return "OK" } diff --git a/native/native.tests/testData/codegen/function/unreachableStatementAfterReturn.out b/native/native.tests/testData/codegen/function/unreachableStatementAfterReturn.out deleted file mode 100644 index 535d2b01d33..00000000000 --- a/native/native.tests/testData/codegen/function/unreachableStatementAfterReturn.out +++ /dev/null @@ -1,8 +0,0 @@ -1 -2 -3 -4 -5 -6 -7 -8 diff --git a/native/native.tests/testData/codegen/initializers/correctOrder1.kt b/native/native.tests/testData/codegen/initializers/correctOrder1.kt index 68121d41048..981bb20f75b 100644 --- a/native/native.tests/testData/codegen/initializers/correctOrder1.kt +++ b/native/native.tests/testData/codegen/initializers/correctOrder1.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.initializers.correctOrder1 - import kotlin.test.* class TestClass { @@ -17,6 +15,7 @@ class TestClass { val y = x } -@Test fun runTest() { - println(TestClass().y) +fun box(): String { + assertEquals(42, TestClass().y) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/initializers/correctOrder1.out b/native/native.tests/testData/codegen/initializers/correctOrder1.out deleted file mode 100644 index d81cc0710eb..00000000000 --- a/native/native.tests/testData/codegen/initializers/correctOrder1.out +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/native/native.tests/testData/codegen/initializers/correctOrder2.kt b/native/native.tests/testData/codegen/initializers/correctOrder2.kt index 4cdfe3c99a2..c100c7b6b39 100644 --- a/native/native.tests/testData/codegen/initializers/correctOrder2.kt +++ b/native/native.tests/testData/codegen/initializers/correctOrder2.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.initializers.correctOrder2 - import kotlin.test.* class TestClass { @@ -17,6 +15,7 @@ class TestClass { } } -@Test fun runTest() { - println(TestClass().x) +fun box(): String { + assertEquals(42, TestClass().x) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/initializers/correctOrder2.out b/native/native.tests/testData/codegen/initializers/correctOrder2.out deleted file mode 100644 index d81cc0710eb..00000000000 --- a/native/native.tests/testData/codegen/initializers/correctOrder2.out +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/native/native.tests/testData/codegen/initializers/correctOrder3.kt b/native/native.tests/testData/codegen/initializers/correctOrder3.kt index af1714c4c4e..e99c7780c81 100644 --- a/native/native.tests/testData/codegen/initializers/correctOrder3.kt +++ b/native/native.tests/testData/codegen/initializers/correctOrder3.kt @@ -14,6 +14,9 @@ class Z(val x: Int) val z2 = Z(x.s.length) // FILE: main.kt -fun main() { - println(z2.x) +import kotlin.test.* + +fun box(): String { + assertEquals(3, z2.x) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/initializers/correctOrder3.out b/native/native.tests/testData/codegen/initializers/correctOrder3.out deleted file mode 100644 index 00750edc07d..00000000000 --- a/native/native.tests/testData/codegen/initializers/correctOrder3.out +++ /dev/null @@ -1 +0,0 @@ -3 diff --git a/native/native.tests/testData/codegen/initializers/eagerInitializationGlobal1.kt b/native/native.tests/testData/codegen/initializers/eagerInitializationGlobal1.kt index 608a5128c03..652e188a400 100644 --- a/native/native.tests/testData/codegen/initializers/eagerInitializationGlobal1.kt +++ b/native/native.tests/testData/codegen/initializers/eagerInitializationGlobal1.kt @@ -2,6 +2,8 @@ * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ +// KT-64408: when undisabled (by removing next line), the compiled .kexe wrongly contains no tests +// DISABLE_NATIVE: cacheMode=STATIC_PER_FILE_EVERYWHERE // FILE: lib.kt var z1 = false @@ -25,7 +27,9 @@ val y = run { z2 = true; 117 } // FILE: main.kt import kotlin.test.* -fun main() { +fun box(): String { assertTrue(z1) assertTrue(z2) + + return "OK" } diff --git a/native/native.tests/testData/codegen/initializers/eagerInitializationGlobal2.kt b/native/native.tests/testData/codegen/initializers/eagerInitializationGlobal2.kt index 6c3554171d0..43cd96ae08d 100644 --- a/native/native.tests/testData/codegen/initializers/eagerInitializationGlobal2.kt +++ b/native/native.tests/testData/codegen/initializers/eagerInitializationGlobal2.kt @@ -2,6 +2,8 @@ * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ +// KT-64408: when undisabled (by removing next line), the compiled .kexe wrongly contains no tests +// DISABLE_NATIVE: cacheMode=STATIC_PER_FILE_EVERYWHERE // FILE: lib.kt var z1 = false @@ -20,7 +22,9 @@ val y = run { z2 = true; 117 } // FILE: main.kt import kotlin.test.* -fun main() { +fun box(): String { assertTrue(z1) assertFalse(z2) + + return "OK" } diff --git a/native/native.tests/testData/codegen/initializers/eagerInitializationThreadLocal1.kt b/native/native.tests/testData/codegen/initializers/eagerInitializationThreadLocal1.kt index a672fc0e59d..f4bd0179e54 100644 --- a/native/native.tests/testData/codegen/initializers/eagerInitializationThreadLocal1.kt +++ b/native/native.tests/testData/codegen/initializers/eagerInitializationThreadLocal1.kt @@ -2,6 +2,8 @@ * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ +// KT-64408: when undisabled (by removing next line), the compiled .kexe wrongly contains no tests +// DISABLE_NATIVE: cacheMode=STATIC_PER_FILE_EVERYWHERE // FILE: lib.kt @ThreadLocal @@ -32,8 +34,10 @@ val y2 = run { z3 = true; 117 } // FILE: main.kt import kotlin.test.* -fun main() { +fun box(): String { assertTrue(z1) assertTrue(z2) assertTrue(z3) + + return "OK" } diff --git a/native/native.tests/testData/codegen/initializers/eagerInitializationThreadLocal2.kt b/native/native.tests/testData/codegen/initializers/eagerInitializationThreadLocal2.kt index 617a8a83dc4..dd48d1e6ff1 100644 --- a/native/native.tests/testData/codegen/initializers/eagerInitializationThreadLocal2.kt +++ b/native/native.tests/testData/codegen/initializers/eagerInitializationThreadLocal2.kt @@ -2,6 +2,8 @@ * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ +// KT-64408: when undisabled (by removing next line), the compiled .kexe wrongly contains no tests +// DISABLE_NATIVE: cacheMode=STATIC_PER_FILE_EVERYWHERE // FILE: lib.kt @ThreadLocal @@ -27,8 +29,10 @@ val y2 = run { z3 = true; 117 } // FILE: main.kt import kotlin.test.* -fun main() { +fun box(): String { assertTrue(z1) assertFalse(z2) assertFalse(z3) + + return "OK" } diff --git a/native/native.tests/testData/codegen/initializers/globalInitedAfterAccessingFile.kt b/native/native.tests/testData/codegen/initializers/globalInitedAfterAccessingFile.kt index 02d0507fc40..bc936676816 100644 --- a/native/native.tests/testData/codegen/initializers/globalInitedAfterAccessingFile.kt +++ b/native/native.tests/testData/codegen/initializers/globalInitedAfterAccessingFile.kt @@ -21,7 +21,9 @@ fun bar() = 117 // FILE: main.kt import kotlin.test.* -fun main() { +fun box(): String { bar() assertTrue(z) + + return "OK" } diff --git a/native/native.tests/testData/codegen/initializers/globalInitedBeforeThreadLocal.kt b/native/native.tests/testData/codegen/initializers/globalInitedBeforeThreadLocal.kt index e15ba86ee34..23036bf3919 100644 --- a/native/native.tests/testData/codegen/initializers/globalInitedBeforeThreadLocal.kt +++ b/native/native.tests/testData/codegen/initializers/globalInitedBeforeThreadLocal.kt @@ -21,6 +21,7 @@ private fun bar(): Int { // FILE: main.kt import kotlin.test.* -fun main() { +fun box(): String { assertEquals(y, 117) + return "OK" } diff --git a/native/native.tests/testData/codegen/initializers/globalNotInitedAfterAccessingClassInternals.kt b/native/native.tests/testData/codegen/initializers/globalNotInitedAfterAccessingClassInternals.kt index 2bbab4a4a5b..878ff1d1e9a 100644 --- a/native/native.tests/testData/codegen/initializers/globalNotInitedAfterAccessingClassInternals.kt +++ b/native/native.tests/testData/codegen/initializers/globalNotInitedAfterAccessingClassInternals.kt @@ -23,7 +23,9 @@ class C { // FILE: main.kt import kotlin.test.* -fun main() { +fun box(): String { C().bar() assertFalse(z) + + return "OK" } diff --git a/native/native.tests/testData/codegen/initializers/object.kt b/native/native.tests/testData/codegen/initializers/object.kt index b723cfcd03f..d56283f3508 100644 --- a/native/native.tests/testData/codegen/initializers/object.kt +++ b/native/native.tests/testData/codegen/initializers/object.kt @@ -22,9 +22,11 @@ object Z { // FILE: main.kt import kotlin.test.* -fun main() { +fun box(): String { Z.bar() assertFalse(z) assertEquals(42, Z.baz()) assertTrue(z) + + return "OK" } diff --git a/native/native.tests/testData/codegen/initializers/return1.kt b/native/native.tests/testData/codegen/initializers/return1.kt index cbaca6eb96e..b2918f05e6b 100644 --- a/native/native.tests/testData/codegen/initializers/return1.kt +++ b/native/native.tests/testData/codegen/initializers/return1.kt @@ -11,12 +11,15 @@ private fun getY() = 42 fun bar(x: Int) = x == 0 // FILE: main.kt +import kotlin.test.* + fun foo(x: Int) { if (x <= 0) return bar(x) } -fun main() { +fun box(): String { foo(0) - println(y) + assertEquals(42, y) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/initializers/return1.out b/native/native.tests/testData/codegen/initializers/return1.out deleted file mode 100644 index d81cc0710eb..00000000000 --- a/native/native.tests/testData/codegen/initializers/return1.out +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/native/native.tests/testData/codegen/initializers/return2.kt b/native/native.tests/testData/codegen/initializers/return2.kt index 222040ac716..52b7d788d7a 100644 --- a/native/native.tests/testData/codegen/initializers/return2.kt +++ b/native/native.tests/testData/codegen/initializers/return2.kt @@ -11,12 +11,15 @@ private fun getY() = 42 fun bar(x: Int) = x == 0 // FILE: main.kt +import kotlin.test.* + inline fun foo(x: Int) { if (x <= 0) return bar(x) } -fun main() { +fun box(): String { foo(0) - println(y) + assertEquals(42, y) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/initializers/return2.out b/native/native.tests/testData/codegen/initializers/return2.out deleted file mode 100644 index d81cc0710eb..00000000000 --- a/native/native.tests/testData/codegen/initializers/return2.out +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/native/native.tests/testData/codegen/initializers/static.kt b/native/native.tests/testData/codegen/initializers/static.kt deleted file mode 100644 index 0576c4187f5..00000000000 --- a/native/native.tests/testData/codegen/initializers/static.kt +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ -@file:OptIn(kotlin.ExperimentalStdlibApi::class, kotlin.experimental.ExperimentalNativeApi::class) - -package codegen.initializers.static - -import kotlin.test.* -import kotlin.native.internal.* -import kotlin.reflect.* -import kotlin.native.Platform -import kotlin.native.OsFamily - -class Delegate { - operator fun getValue(thisRef: Any?, property: KProperty<*>) : String { - assertTrue(property.isPermanent()); - assertTrue(property.returnType.isPermanent()) - return property.name - } -} - -class A { - val z by Delegate() -} - -fun f() = 5 - -@Test fun testPermanent() { - val x = typeOf>() - assertTrue(x.isPermanent()) - val a = A() - assertTrue(a.z.isPermanent()) - assertEquals("z", a.z) - val t = ::f - assertTrue(t.isPermanent()) - assertEquals(5, t()) - val z = { 6 } - assertTrue(z.isPermanent()) - assertEquals(6, z()) -} - -@Test fun testVarargChange() { - fun varargGetter(position:Int, vararg x: Int): Int { - x[position] *= 5; - return x[position] - } - - repeat(3) { - assertEquals(10, varargGetter(0, 2, 3, 4)) - assertEquals(10, varargGetter(0, 2, 3, 4)) - assertEquals(15, varargGetter(1, 2, 3, 4)) - assertEquals(15, varargGetter(1, 2, 3, 4)) - assertEquals(20, varargGetter(2, 2, 3, 4)) - assertEquals(20, varargGetter(2, 2, 3, 4)) - if (Platform.osFamily != OsFamily.WASM) { - assertFailsWith { varargGetter(3, 2, 3, 4) } - } - } -} - -@Test fun testArrays() { - assertEquals("1, 2, 3", intArrayOf(1, 2, 3).joinToString()) - assertEquals("4, 5, 6", longArrayOf(4.toLong(), 5.toLong(), 6.toLong()).joinToString()) - assertEquals("7, 8, 9", shortArrayOf(7.toShort(), 8.toShort(), 9.toShort()).joinToString()) - assertEquals("10, 11, 12", byteArrayOf(10.toByte(), 11.toByte(), 12.toByte()).joinToString()) - assertEquals("abc", charArrayOf('a', 'b', 'c').joinToString("")) - assertEquals("1.5, 2.5, -3.5", floatArrayOf(1.5f, 2.5f, -3.5f).joinToString()) - assertEquals("4.5, 5.5, -6.5", doubleArrayOf(4.5, 5.5, -6.5).joinToString()) - assertEquals("13, 14, 4294967295", uintArrayOf(13u, 14u, 4294967295u).joinToString()) - assertEquals("15, 16, 17", ulongArrayOf(15.toULong(), 16.toULong(), 17.toULong()).joinToString()) - assertEquals("18, 19, 40000", ushortArrayOf(18.toUShort(), 19.toUShort(), 40000.toUShort()).joinToString()) - assertEquals("20, 21, 200", ubyteArrayOf(20.toUByte(), 21.toUByte(), 200.toUByte()).joinToString()) - - assertEquals("abc, def, ghi", arrayOf("abc", "def", "ghi").joinToString()) - assertEquals("1, 2, 3", arrayOf(1, 2, 3).joinToString()) - assertEquals("4, 5, 6", arrayOf(4.toLong(), 5.toLong(), 6.toLong()).joinToString()) - assertEquals("7, 8, 9", arrayOf(7.toShort(), 8.toShort(), 9.toShort()).joinToString()) - assertEquals("10, 11, 12", arrayOf(10.toByte(), 11.toByte(), 12.toByte()).joinToString()) - assertEquals("abc", arrayOf('a', 'b', 'c').joinToString("")) - assertEquals("1.5, 2.5, -3.5", arrayOf(1.5f, 2.5f, -3.5f).joinToString()) - assertEquals("4.5, 5.5, -6.5", arrayOf(4.5, 5.5, -6.5).joinToString()) - assertEquals("13, 14, 4294967295", arrayOf(13u, 14u, 4294967295u).joinToString()) - assertEquals("15, 16, 17", arrayOf(15.toULong(), 16.toULong(), 17.toULong()).joinToString()) - assertEquals("18, 19, 40000", arrayOf(18.toUShort(), 19.toUShort(), 40000.toUShort()).joinToString()) - assertEquals("20, 21, 200", arrayOf(20.toUByte(), 21.toUByte(), 200.toUByte()).joinToString()) - - assertEquals("abc, 1, 2, 3, 4, a, 1.5, 2.5, 5, 6, 7, 8", - arrayOf("abc", 1, 2.toLong(), 3.toShort(), 4.toByte(), 'a', 1.5f, 2.5, 5u, 6.toULong(), 7.toUShort(), 8.toUByte()).joinToString()) -} - -@Test fun testList() { - assertEquals("abc, def, ghi", listOf("abc", "def", "ghi").joinToString()) - assertEquals("1, 2, 3", listOf(1, 2, 3).joinToString()) - assertEquals("4, 5, 6", listOf(4.toLong(), 5.toLong(), 6.toLong()).joinToString()) - assertEquals("7, 8, 9", listOf(7.toShort(), 8.toShort(), 9.toShort()).joinToString()) - assertEquals("10, 11, 12", listOf(10.toByte(), 11.toByte(), 12.toByte()).joinToString()) - assertEquals("abc", listOf('a', 'b', 'c').joinToString("")) - assertEquals("1.5, 2.5, -3.5", listOf(1.5f, 2.5f, -3.5f).joinToString()) - assertEquals("4.5, 5.5, -6.5", listOf(4.5, 5.5, -6.5).joinToString()) - assertEquals("13, 14, 4294967295", listOf(13u, 14u, 4294967295u).joinToString()) - assertEquals("15, 16, 17", listOf(15.toULong(), 16.toULong(), 17.toULong()).joinToString()) - assertEquals("18, 19, 40000", listOf(18.toUShort(), 19.toUShort(), 40000.toUShort()).joinToString()) - assertEquals("20, 21, 200", listOf(20.toUByte(), 21.toUByte(), 200.toUByte()).joinToString()) - - assertEquals("abc, 1, 2, 3, 4, a, 1.5, 2.5, 5, 6, 7, 8", - listOf("abc", 1, 2.toLong(), 3.toShort(), 4.toByte(), 'a', 1.5f, 2.5, 5u, 6.toULong(), 7.toUShort(), 8.toUByte()).joinToString()) -} - -@Test fun testKType() { - val ktype = typeOf>?>() - assertTrue(ktype.isPermanent()) - assertEquals("Map", (ktype.classifier as? KClass<*>)?.simpleName) - assertSame(Map::class, ktype.classifier) - assertTrue(ktype.isMarkedNullable) - assertTrue(ktype.arguments.isPermanent()) - assertEquals(2, ktype.arguments.size) - assertSame(KVariance.IN, ktype.arguments[0].variance) - assertSame(KVariance.OUT, ktype.arguments[1].variance) - - val arg0type = ktype.arguments[0].type!! - assertTrue(arg0type.isPermanent()) - assertEquals("String", (arg0type.classifier as? KClass<*>)?.simpleName) - assertSame(String::class, arg0type.classifier) - assertTrue(arg0type.isMarkedNullable) - assertTrue(arg0type.arguments.isPermanent()) - assertTrue(arg0type.arguments.isEmpty()) - - val arg1type = ktype.arguments[1].type!! - assertTrue(arg1type.isPermanent()) - assertEquals("List", (arg1type.classifier as? KClass<*>)?.simpleName) - assertSame(List::class, arg1type.classifier) - assertFalse(arg1type.isMarkedNullable) - assertTrue(arg1type.arguments.isPermanent()) - assertTrue(arg1type.arguments.size == 1) - assertSame(null, arg1type.arguments[0].variance) - assertSame(null, arg1type.arguments[0].type) -} -class R -interface S - -@Test fun testReifiedKType() { - - inline fun kTypeOf() where V : List, V : S, U : T = typeOf>() - - class XX(val x:List) : List by x, S - - val type = kTypeOf, ArrayList, XX>() - assertEquals("codegen.initializers.static.R, in U, out V, *>", type.toString()) - assertEquals("[T]", (type.arguments[1].type!!.classifier as KTypeParameter).upperBounds.toString()) - assertEquals("[kotlin.collections.List, codegen.initializers.static.S]", - (type.arguments[2].type!!.classifier as KTypeParameter).upperBounds.toString()) -} - -inline fun invokeAndReturnKClass(block: ()->Boolean) : KClass<*> { - try { - if (block()) { - return Double::class - } - } catch (e: Exception) { - return String::class - } finally { - return Int::class - } -} - -@Test fun testConstantObjectInFinally() { - for (i in 0..2) { - val clazz = invokeAndReturnKClass { - when (i) { - 0 -> true - 1 -> false - else -> TODO("test") - } - } - assertTrue(clazz.isPermanent()) - assertEquals("kotlin.Int", clazz.qualifiedName) - } -} - -@Test fun testSmallIntIdentity() { - val xBool = true - val xBoolStatic : Any = false - val xBoolDyanmic : Any = !xBool - assertSame(xBoolStatic, xBoolDyanmic) - - val xByte = 1.toByte() - val xByteStatic : Any = 2.toByte() - val xByteDyanmic : Any = (xByte + xByte).toByte() - assertSame(xByteStatic, xByteDyanmic) - - val xShort = 1.toShort() - val xShortStatic : Any = 2.toShort() - val xShortDyanmic : Any = (xShort + xShort).toShort() - assertSame(xShortStatic, xShortDyanmic) - - val xInt = 1.toInt() - val xIntStatic : Any = 2.toInt() - val xIntDyanmic : Any = xInt + xInt - assertSame(xIntStatic, xIntDyanmic) - - val xChar = 1.toChar() - val xCharStatic : Any = 2.toChar() - val xCharDyanmic : Any = (xChar.code + xChar.code).toChar() - assertSame(xCharStatic, xCharDyanmic) - - val xLong = 1.toLong() - val xLongStatic = 2.toLong() - val xLongDyanmic = xLong + xLong - assertSame(xLongStatic, xLongDyanmic) -} \ No newline at end of file diff --git a/native/native.tests/testData/codegen/initializers/static_arrays.kt b/native/native.tests/testData/codegen/initializers/static_arrays.kt new file mode 100644 index 00000000000..86d549b8d2a --- /dev/null +++ b/native/native.tests/testData/codegen/initializers/static_arrays.kt @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +import kotlin.test.* + +fun box(): String { + assertEquals("1, 2, 3", intArrayOf(1, 2, 3).joinToString()) + assertEquals("4, 5, 6", longArrayOf(4.toLong(), 5.toLong(), 6.toLong()).joinToString()) + assertEquals("7, 8, 9", shortArrayOf(7.toShort(), 8.toShort(), 9.toShort()).joinToString()) + assertEquals("10, 11, 12", byteArrayOf(10.toByte(), 11.toByte(), 12.toByte()).joinToString()) + assertEquals("abc", charArrayOf('a', 'b', 'c').joinToString("")) + assertEquals("1.5, 2.5, -3.5", floatArrayOf(1.5f, 2.5f, -3.5f).joinToString()) + assertEquals("4.5, 5.5, -6.5", doubleArrayOf(4.5, 5.5, -6.5).joinToString()) + assertEquals("13, 14, 4294967295", uintArrayOf(13u, 14u, 4294967295u).joinToString()) + assertEquals("15, 16, 17", ulongArrayOf(15.toULong(), 16.toULong(), 17.toULong()).joinToString()) + assertEquals("18, 19, 40000", ushortArrayOf(18.toUShort(), 19.toUShort(), 40000.toUShort()).joinToString()) + assertEquals("20, 21, 200", ubyteArrayOf(20.toUByte(), 21.toUByte(), 200.toUByte()).joinToString()) + + assertEquals("abc, def, ghi", arrayOf("abc", "def", "ghi").joinToString()) + assertEquals("1, 2, 3", arrayOf(1, 2, 3).joinToString()) + assertEquals("4, 5, 6", arrayOf(4.toLong(), 5.toLong(), 6.toLong()).joinToString()) + assertEquals("7, 8, 9", arrayOf(7.toShort(), 8.toShort(), 9.toShort()).joinToString()) + assertEquals("10, 11, 12", arrayOf(10.toByte(), 11.toByte(), 12.toByte()).joinToString()) + assertEquals("abc", arrayOf('a', 'b', 'c').joinToString("")) + assertEquals("1.5, 2.5, -3.5", arrayOf(1.5f, 2.5f, -3.5f).joinToString()) + assertEquals("4.5, 5.5, -6.5", arrayOf(4.5, 5.5, -6.5).joinToString()) + assertEquals("13, 14, 4294967295", arrayOf(13u, 14u, 4294967295u).joinToString()) + assertEquals("15, 16, 17", arrayOf(15.toULong(), 16.toULong(), 17.toULong()).joinToString()) + assertEquals("18, 19, 40000", arrayOf(18.toUShort(), 19.toUShort(), 40000.toUShort()).joinToString()) + assertEquals("20, 21, 200", arrayOf(20.toUByte(), 21.toUByte(), 200.toUByte()).joinToString()) + + assertEquals("abc, 1, 2, 3, 4, a, 1.5, 2.5, 5, 6, 7, 8", + arrayOf("abc", 1, 2.toLong(), 3.toShort(), 4.toByte(), 'a', 1.5f, 2.5, 5u, 6.toULong(), 7.toUShort(), 8.toUByte()).joinToString()) + + return "OK" +} diff --git a/native/native.tests/testData/codegen/initializers/static_constantObjectInFinally.kt b/native/native.tests/testData/codegen/initializers/static_constantObjectInFinally.kt new file mode 100644 index 00000000000..616cc24b36e --- /dev/null +++ b/native/native.tests/testData/codegen/initializers/static_constantObjectInFinally.kt @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +import kotlin.test.* +import kotlin.native.internal.* +import kotlin.reflect.* + +inline fun invokeAndReturnKClass(block: ()->Boolean) : KClass<*> { + try { + if (block()) { + return Double::class + } + } catch (e: Exception) { + return String::class + } finally { + return Int::class + } +} + +fun box(): String { + for (i in 0..2) { + val clazz = invokeAndReturnKClass { + when (i) { + 0 -> true + 1 -> false + else -> TODO("test") + } + } + assertTrue(clazz.isPermanent()) + assertEquals("kotlin.Int", clazz.qualifiedName) + } + + return "OK" +} diff --git a/native/native.tests/testData/codegen/initializers/static_kType.kt b/native/native.tests/testData/codegen/initializers/static_kType.kt new file mode 100644 index 00000000000..c644cc62ce5 --- /dev/null +++ b/native/native.tests/testData/codegen/initializers/static_kType.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +import kotlin.test.* +import kotlin.native.internal.* +import kotlin.reflect.* + +fun box(): String { + val ktype = typeOf>?>() + assertTrue(ktype.isPermanent()) + assertEquals("Map", (ktype.classifier as? KClass<*>)?.simpleName) + assertSame(Map::class, ktype.classifier) + assertTrue(ktype.isMarkedNullable) + assertTrue(ktype.arguments.isPermanent()) + assertEquals(2, ktype.arguments.size) + assertSame(KVariance.IN, ktype.arguments[0].variance) + assertSame(KVariance.OUT, ktype.arguments[1].variance) + + val arg0type = ktype.arguments[0].type!! + assertTrue(arg0type.isPermanent()) + assertEquals("String", (arg0type.classifier as? KClass<*>)?.simpleName) + assertSame(String::class, arg0type.classifier) + assertTrue(arg0type.isMarkedNullable) + assertTrue(arg0type.arguments.isPermanent()) + assertTrue(arg0type.arguments.isEmpty()) + + val arg1type = ktype.arguments[1].type!! + assertTrue(arg1type.isPermanent()) + assertEquals("List", (arg1type.classifier as? KClass<*>)?.simpleName) + assertSame(List::class, arg1type.classifier) + assertFalse(arg1type.isMarkedNullable) + assertTrue(arg1type.arguments.isPermanent()) + assertTrue(arg1type.arguments.size == 1) + assertSame(null, arg1type.arguments[0].variance) + assertSame(null, arg1type.arguments[0].type) + + return "OK" +} diff --git a/native/native.tests/testData/codegen/initializers/static_list.kt b/native/native.tests/testData/codegen/initializers/static_list.kt new file mode 100644 index 00000000000..60529af9d23 --- /dev/null +++ b/native/native.tests/testData/codegen/initializers/static_list.kt @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +import kotlin.test.* + +fun box(): String { + assertEquals("abc, def, ghi", listOf("abc", "def", "ghi").joinToString()) + assertEquals("1, 2, 3", listOf(1, 2, 3).joinToString()) + assertEquals("4, 5, 6", listOf(4.toLong(), 5.toLong(), 6.toLong()).joinToString()) + assertEquals("7, 8, 9", listOf(7.toShort(), 8.toShort(), 9.toShort()).joinToString()) + assertEquals("10, 11, 12", listOf(10.toByte(), 11.toByte(), 12.toByte()).joinToString()) + assertEquals("abc", listOf('a', 'b', 'c').joinToString("")) + assertEquals("1.5, 2.5, -3.5", listOf(1.5f, 2.5f, -3.5f).joinToString()) + assertEquals("4.5, 5.5, -6.5", listOf(4.5, 5.5, -6.5).joinToString()) + assertEquals("13, 14, 4294967295", listOf(13u, 14u, 4294967295u).joinToString()) + assertEquals("15, 16, 17", listOf(15.toULong(), 16.toULong(), 17.toULong()).joinToString()) + assertEquals("18, 19, 40000", listOf(18.toUShort(), 19.toUShort(), 40000.toUShort()).joinToString()) + assertEquals("20, 21, 200", listOf(20.toUByte(), 21.toUByte(), 200.toUByte()).joinToString()) + + assertEquals("abc, 1, 2, 3, 4, a, 1.5, 2.5, 5, 6, 7, 8", + listOf("abc", 1, 2.toLong(), 3.toShort(), 4.toByte(), 'a', 1.5f, 2.5, 5u, 6.toULong(), 7.toUShort(), 8.toUByte()).joinToString()) + + return "OK" +} diff --git a/native/native.tests/testData/codegen/initializers/static_permanent.kt b/native/native.tests/testData/codegen/initializers/static_permanent.kt new file mode 100644 index 00000000000..181be29254b --- /dev/null +++ b/native/native.tests/testData/codegen/initializers/static_permanent.kt @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +import kotlin.test.* +import kotlin.native.internal.* +import kotlin.reflect.* + +class Delegate { + operator fun getValue(thisRef: Any?, property: KProperty<*>) : String { + assertTrue(property.isPermanent()); + assertTrue(property.returnType.isPermanent()) + return property.name + } +} + +class A { + val z by Delegate() +} + +fun f() = 5 + +fun box(): String { + val x = typeOf>() + assertTrue(x.isPermanent()) + val a = A() + assertTrue(a.z.isPermanent()) + assertEquals("z", a.z) + val t = ::f + assertTrue(t.isPermanent()) + assertEquals(5, t()) + val z = { 6 } + assertTrue(z.isPermanent()) + assertEquals(6, z()) + + return "OK" +} diff --git a/native/native.tests/testData/codegen/initializers/static_reifiedKType.kt b/native/native.tests/testData/codegen/initializers/static_reifiedKType.kt new file mode 100644 index 00000000000..0195787fbd1 --- /dev/null +++ b/native/native.tests/testData/codegen/initializers/static_reifiedKType.kt @@ -0,0 +1,24 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +import kotlin.test.* +import kotlin.reflect.* + +class R +interface S + +fun box(): String { + inline fun kTypeOf() where V : List, V : S, U : T = typeOf>() + + class XX(val x:List) : List by x, S + + val type = kTypeOf, ArrayList, XX>() + assertEquals("R, in U, out V, *>", type.toString()) + assertEquals("[T]", (type.arguments[1].type!!.classifier as KTypeParameter).upperBounds.toString()) + assertEquals("[kotlin.collections.List, S]", + (type.arguments[2].type!!.classifier as KTypeParameter).upperBounds.toString()) + + return "OK" +} diff --git a/native/native.tests/testData/codegen/initializers/static_smallIntIdentity.kt b/native/native.tests/testData/codegen/initializers/static_smallIntIdentity.kt new file mode 100644 index 00000000000..f2bc77b1206 --- /dev/null +++ b/native/native.tests/testData/codegen/initializers/static_smallIntIdentity.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +import kotlin.test.* + +fun box(): String { + val xBool = true + val xBoolStatic : Any = false + val xBoolDyanmic : Any = !xBool + assertSame(xBoolStatic, xBoolDyanmic) + + val xByte = 1.toByte() + val xByteStatic : Any = 2.toByte() + val xByteDyanmic : Any = (xByte + xByte).toByte() + assertSame(xByteStatic, xByteDyanmic) + + val xShort = 1.toShort() + val xShortStatic : Any = 2.toShort() + val xShortDyanmic : Any = (xShort + xShort).toShort() + assertSame(xShortStatic, xShortDyanmic) + + val xInt = 1.toInt() + val xIntStatic : Any = 2.toInt() + val xIntDyanmic : Any = xInt + xInt + assertSame(xIntStatic, xIntDyanmic) + + val xChar = 1.toChar() + val xCharStatic : Any = 2.toChar() + val xCharDyanmic : Any = (xChar.code + xChar.code).toChar() + assertSame(xCharStatic, xCharDyanmic) + + val xLong = 1.toLong() + val xLongStatic = 2.toLong() + val xLongDyanmic = xLong + xLong + assertSame(xLongStatic, xLongDyanmic) + + return "OK" +} \ No newline at end of file diff --git a/native/native.tests/testData/codegen/initializers/static_varargChange.kt b/native/native.tests/testData/codegen/initializers/static_varargChange.kt new file mode 100644 index 00000000000..08bf3931e09 --- /dev/null +++ b/native/native.tests/testData/codegen/initializers/static_varargChange.kt @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +import kotlin.test.* + +fun box(): String { + fun varargGetter(position:Int, vararg x: Int): Int { + x[position] *= 5; + return x[position] + } + + repeat(3) { + assertEquals(10, varargGetter(0, 2, 3, 4)) + assertEquals(10, varargGetter(0, 2, 3, 4)) + assertEquals(15, varargGetter(1, 2, 3, 4)) + assertEquals(15, varargGetter(1, 2, 3, 4)) + assertEquals(20, varargGetter(2, 2, 3, 4)) + assertEquals(20, varargGetter(2, 2, 3, 4)) + // the following assert might fail on Kotlin/WASM + assertFailsWith { varargGetter(3, 2, 3, 4) } + } + + return "OK" +} diff --git a/native/native.tests/testData/codegen/initializers/throw1.kt b/native/native.tests/testData/codegen/initializers/throw1.kt index 41b3bdbbbb8..0a19fbdd63c 100644 --- a/native/native.tests/testData/codegen/initializers/throw1.kt +++ b/native/native.tests/testData/codegen/initializers/throw1.kt @@ -13,6 +13,8 @@ fun baz1() { } fun baz2() { } // FILE: main.kt +import kotlin.test.* + fun bar(x: Int) = if (x == 0) error("") else x fun foo(x: Int) { @@ -22,7 +24,8 @@ fun foo(x: Int) { } catch (t: Throwable) { } } -fun main() { +fun box(): String { foo(0) - println(x) + assertEquals(42, x) + return "OK" } diff --git a/native/native.tests/testData/codegen/initializers/throw1.out b/native/native.tests/testData/codegen/initializers/throw1.out deleted file mode 100644 index d81cc0710eb..00000000000 --- a/native/native.tests/testData/codegen/initializers/throw1.out +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/native/native.tests/testData/codegen/initializers/throw2.kt b/native/native.tests/testData/codegen/initializers/throw2.kt index 95e17192df8..fa22f68b5e3 100644 --- a/native/native.tests/testData/codegen/initializers/throw2.kt +++ b/native/native.tests/testData/codegen/initializers/throw2.kt @@ -13,17 +13,24 @@ fun baz1() { } fun baz2() { } // FILE: main.kt +import kotlin.test.* + fun bar(x: Int) = if (x == 0) error("") else x +val sb = StringBuilder() + fun foo(x: Int) { try { bar(x) baz1() } catch (t: Throwable) { - println(y) + sb.appendLine(y) } } -fun main() { +fun box(): String { foo(0) + + assertEquals("42\n", sb.toString()) + return "OK" } diff --git a/native/native.tests/testData/codegen/initializers/throw2.out b/native/native.tests/testData/codegen/initializers/throw2.out deleted file mode 100644 index d81cc0710eb..00000000000 --- a/native/native.tests/testData/codegen/initializers/throw2.out +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/native/native.tests/testData/codegen/initializers/when1.kt b/native/native.tests/testData/codegen/initializers/when1.kt index bb1939c0178..8457af85f1d 100644 --- a/native/native.tests/testData/codegen/initializers/when1.kt +++ b/native/native.tests/testData/codegen/initializers/when1.kt @@ -11,13 +11,16 @@ private fun getY() = 42 fun bar(x: Int) = x == 0 // FILE: main.kt +import kotlin.test.* + fun foo(x: Int) = when { x > 0 -> 42 bar(x) -> 117 else -> -1 } -fun main() { +fun box(): String { foo(123) - println(y) + assertEquals(42, y) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/initializers/when1.out b/native/native.tests/testData/codegen/initializers/when1.out deleted file mode 100644 index d81cc0710eb..00000000000 --- a/native/native.tests/testData/codegen/initializers/when1.out +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/native/native.tests/testData/codegen/initializers/when2.kt b/native/native.tests/testData/codegen/initializers/when2.kt index 98776f9fb12..c2222d2c195 100644 --- a/native/native.tests/testData/codegen/initializers/when2.kt +++ b/native/native.tests/testData/codegen/initializers/when2.kt @@ -11,11 +11,14 @@ private fun getY() = 42 fun bar(x: Int) = x == 0 // FILE: main.kt +import kotlin.test.* + fun foo(x: Int) { if (x > 0) bar(x) } -fun main() { +fun box(): String { foo(-1) - println(y) + assertEquals(42, y) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/initializers/when2.out b/native/native.tests/testData/codegen/initializers/when2.out deleted file mode 100644 index d81cc0710eb..00000000000 --- a/native/native.tests/testData/codegen/initializers/when2.out +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/native/native.tests/testData/codegen/initializers/while1.kt b/native/native.tests/testData/codegen/initializers/while1.kt index d231e337232..5aec41eaffc 100644 --- a/native/native.tests/testData/codegen/initializers/while1.kt +++ b/native/native.tests/testData/codegen/initializers/while1.kt @@ -11,6 +11,8 @@ private fun getY() = 42 fun bar(x: Int) = x == 0 // FILE: main.kt +import kotlin.test.* + fun foo(x: Int) { var i = 0 while (i < x) { @@ -19,7 +21,8 @@ fun foo(x: Int) { } } -fun main() { +fun box(): String { foo(0) - println(y) + assertEquals(42, y) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/initializers/while1.out b/native/native.tests/testData/codegen/initializers/while1.out deleted file mode 100644 index d81cc0710eb..00000000000 --- a/native/native.tests/testData/codegen/initializers/while1.out +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/native/native.tests/testData/codegen/initializers/while2.kt b/native/native.tests/testData/codegen/initializers/while2.kt index b3e03ceed06..0a41556f1b2 100644 --- a/native/native.tests/testData/codegen/initializers/while2.kt +++ b/native/native.tests/testData/codegen/initializers/while2.kt @@ -11,6 +11,8 @@ private fun getY() = 42 fun bar(x: Int) = x == 0 // FILE: main.kt +import kotlin.test.* + fun foo(x: Int) { var i = 0 do { @@ -19,7 +21,8 @@ fun foo(x: Int) { } while (bar(i)) } -fun main() { +fun box(): String { foo(0) - println(y) + assertEquals(42, y) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/initializers/while2.out b/native/native.tests/testData/codegen/initializers/while2.out deleted file mode 100644 index d81cc0710eb..00000000000 --- a/native/native.tests/testData/codegen/initializers/while2.out +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/native/native.tests/testData/codegen/initializers/while3.kt b/native/native.tests/testData/codegen/initializers/while3.kt index ea6916ef7c6..3176124e250 100644 --- a/native/native.tests/testData/codegen/initializers/while3.kt +++ b/native/native.tests/testData/codegen/initializers/while3.kt @@ -11,6 +11,8 @@ private fun getY() = 42 fun bar(x: Int) = x == 0 // FILE: main.kt +import kotlin.test.* + fun foo(x: Int) { var i = 0 do { @@ -20,7 +22,8 @@ fun foo(x: Int) { } while (i < x) } -fun main() { +fun box(): String { foo(0) - println(y) + assertEquals(42, y) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/initializers/while3.out b/native/native.tests/testData/codegen/initializers/while3.out deleted file mode 100644 index d81cc0710eb..00000000000 --- a/native/native.tests/testData/codegen/initializers/while3.out +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/native/native.tests/testData/codegen/initializers/workers1.kt b/native/native.tests/testData/codegen/initializers/workers1.kt index 368b15c0713..0faf2ec0652 100644 --- a/native/native.tests/testData/codegen/initializers/workers1.kt +++ b/native/native.tests/testData/codegen/initializers/workers1.kt @@ -21,15 +21,25 @@ val z2 = Z(x.s.length) // FILE: main.kt @file:OptIn(ObsoleteWorkersApi::class) import kotlin.native.concurrent.* +import kotlin.test.* + +val sb = StringBuilder() fun foo() { val worker = Worker.start() worker.execute(TransferMode.SAFE, { -> }, { - it -> println(z1.x) + it -> sb.appendLine(z1.x) }).consume { } } -fun main() { +fun box(): String { foo() - println(z2.x) + sb.appendLine(z2.x) + + assertEquals(""" + 42 + 3 + + """.trimIndent(), sb.toString()) + return "OK" } diff --git a/native/native.tests/testData/codegen/initializers/workers1.out b/native/native.tests/testData/codegen/initializers/workers1.out deleted file mode 100644 index 72350c3f031..00000000000 --- a/native/native.tests/testData/codegen/initializers/workers1.out +++ /dev/null @@ -1,2 +0,0 @@ -42 -3 diff --git a/native/native.tests/testData/codegen/initializers/workers2.kt b/native/native.tests/testData/codegen/initializers/workers2.kt index 32f3b1f7787..359979101d0 100644 --- a/native/native.tests/testData/codegen/initializers/workers2.kt +++ b/native/native.tests/testData/codegen/initializers/workers2.kt @@ -14,11 +14,21 @@ val z = Z(42) // FILE: main.kt @file:OptIn(ObsoleteWorkersApi::class) import kotlin.native.concurrent.* +import kotlin.test.* -fun main() { - println(z.x) +val sb = StringBuilder() + +fun box(): String { + sb.appendLine(z.x) val worker = Worker.start() worker.execute(TransferMode.SAFE, { -> }, { - it -> println(z.x) + it -> sb.appendLine(z.x) }).consume { } + + assertEquals(""" + 42 + 42 + + """.trimIndent(), sb.toString()) + return "OK" } diff --git a/native/native.tests/testData/codegen/initializers/workers2.out b/native/native.tests/testData/codegen/initializers/workers2.out deleted file mode 100644 index daaac9e3030..00000000000 --- a/native/native.tests/testData/codegen/initializers/workers2.out +++ /dev/null @@ -1,2 +0,0 @@ -42 -42 diff --git a/native/native.tests/testData/codegen/inline/changingCapturedLocal.kt b/native/native.tests/testData/codegen/inline/changingCapturedLocal.kt index 81f70318bb4..2cb7cab0a91 100644 --- a/native/native.tests/testData/codegen/inline/changingCapturedLocal.kt +++ b/native/native.tests/testData/codegen/inline/changingCapturedLocal.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.changingCapturedLocal - import kotlin.test.* var log = "" @@ -24,7 +22,3 @@ fun box(): String { return "OK" } - -@Test fun runTest() { - println(box()) -} \ No newline at end of file diff --git a/native/native.tests/testData/codegen/inline/changingCapturedLocal.out b/native/native.tests/testData/codegen/inline/changingCapturedLocal.out deleted file mode 100644 index d86bac9de59..00000000000 --- a/native/native.tests/testData/codegen/inline/changingCapturedLocal.out +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/native/native.tests/testData/codegen/inline/classDeclarationInsideInline.kt b/native/native.tests/testData/codegen/inline/classDeclarationInsideInline.kt index f4a8593709f..eb2dbc35eb5 100644 --- a/native/native.tests/testData/codegen/inline/classDeclarationInsideInline.kt +++ b/native/native.tests/testData/codegen/inline/classDeclarationInsideInline.kt @@ -3,11 +3,9 @@ * that can be found in the LICENSE file. */ -package codegen.inline.classDeclarationInsideInline - import kotlin.test.* -fun f() { +fun box(): String { run { class Test1(val x: T, val y: G) { override fun toString() = "test1: ${x.toDouble()}" @@ -18,12 +16,9 @@ fun f() { } val v = Test2(Test1(1, Test2(Test1(1, 3)))) - println(v.a) - println(v.a.x) - println(v.a.y) + assertEquals("test1: 1.0", v.a.toString()) + assertEquals("1", v.a.x.toString()) + assertEquals("test2", v.a.y.toString()) } -} - -@Test fun test() { - f() + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/classDeclarationInsideInline.out b/native/native.tests/testData/codegen/inline/classDeclarationInsideInline.out deleted file mode 100644 index e3f9ff3d26c..00000000000 --- a/native/native.tests/testData/codegen/inline/classDeclarationInsideInline.out +++ /dev/null @@ -1,3 +0,0 @@ -test1: 1.0 -1 -test2 diff --git a/native/native.tests/testData/codegen/inline/coercionToUnit.kt b/native/native.tests/testData/codegen/inline/coercionToUnit.kt index 58f8700156d..937b4b94427 100644 --- a/native/native.tests/testData/codegen/inline/coercionToUnit.kt +++ b/native/native.tests/testData/codegen/inline/coercionToUnit.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.coercionToUnit - import kotlin.test.* fun myRun(action: () -> T): T = action() @@ -17,6 +15,7 @@ fun foo(n: Number, b: Boolean) { } } -@Test fun runTest() { - println(foo(42, false)) +fun box(): String { + assertEquals(Unit, foo(42, false)) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/coercionToUnit.out b/native/native.tests/testData/codegen/inline/coercionToUnit.out deleted file mode 100644 index 0fd40fc5055..00000000000 --- a/native/native.tests/testData/codegen/inline/coercionToUnit.out +++ /dev/null @@ -1 +0,0 @@ -kotlin.Unit diff --git a/native/native.tests/testData/codegen/inline/correctOrderFunctionReference.kt b/native/native.tests/testData/codegen/inline/correctOrderFunctionReference.kt index bd99d731e0b..53fa656ee03 100644 --- a/native/native.tests/testData/codegen/inline/correctOrderFunctionReference.kt +++ b/native/native.tests/testData/codegen/inline/correctOrderFunctionReference.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.correctOrderFunctionReference - import kotlin.test.* class Foo(val a: String) { @@ -34,7 +32,3 @@ fun box(): String { return if (result == "ABCEF") "OK" else "fail 2: $result" } - -@Test fun runTest() { - println(box()) -} \ No newline at end of file diff --git a/native/native.tests/testData/codegen/inline/correctOrderFunctionReference.out b/native/native.tests/testData/codegen/inline/correctOrderFunctionReference.out deleted file mode 100644 index d86bac9de59..00000000000 --- a/native/native.tests/testData/codegen/inline/correctOrderFunctionReference.out +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/native/native.tests/testData/codegen/inline/defaultArgs.kt b/native/native.tests/testData/codegen/inline/defaultArgs.kt index 9dd0fd07f4f..2395010ab43 100644 --- a/native/native.tests/testData/codegen/inline/defaultArgs.kt +++ b/native/native.tests/testData/codegen/inline/defaultArgs.kt @@ -3,17 +3,19 @@ * that can be found in the LICENSE file. */ -package codegen.inline.defaultArgs - import kotlin.test.* +val sb = StringBuilder() + class Z inline fun Z.foo(x: Int = 42, y: Int = x) { - println(y) + sb.appendLine(y) } -@Test fun runTest() { +fun box(): String { val z = Z() z.foo() + assertEquals("42\n", sb.toString()) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/inline/defaultArgs.out b/native/native.tests/testData/codegen/inline/defaultArgs.out deleted file mode 100644 index d81cc0710eb..00000000000 --- a/native/native.tests/testData/codegen/inline/defaultArgs.out +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/native/native.tests/testData/codegen/inline/genericFunctionReference.kt b/native/native.tests/testData/codegen/inline/genericFunctionReference.kt index 70ec4e151b0..239484c3bf4 100644 --- a/native/native.tests/testData/codegen/inline/genericFunctionReference.kt +++ b/native/native.tests/testData/codegen/inline/genericFunctionReference.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.genericFunctionReference - import kotlin.test.* class Z(val x: T) @@ -13,7 +11,8 @@ inline fun foo(x: T, f: (T) -> R): R { return f(x) } -@Test fun runTest() { +fun box(): String { val arr = Array(1) { foo(it, ::Z) } - println(arr[0].x) + assertEquals(0, arr[0].x) + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/inline/genericFunctionReference.out b/native/native.tests/testData/codegen/inline/genericFunctionReference.out deleted file mode 100644 index 573541ac970..00000000000 --- a/native/native.tests/testData/codegen/inline/genericFunctionReference.out +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/native/native.tests/testData/codegen/inline/getClass.kt b/native/native.tests/testData/codegen/inline/getClass.kt index e2fad509b1a..cddf4b48f53 100644 --- a/native/native.tests/testData/codegen/inline/getClass.kt +++ b/native/native.tests/testData/codegen/inline/getClass.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.getClass - import kotlin.test.* fun foo() { @@ -18,6 +16,7 @@ fun foo() { } } -@Test fun runTest() { - println("OK") +fun box(): String { + foo() + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/getClass.out b/native/native.tests/testData/codegen/inline/getClass.out deleted file mode 100644 index d86bac9de59..00000000000 --- a/native/native.tests/testData/codegen/inline/getClass.out +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/native/native.tests/testData/codegen/inline/inline0.kt b/native/native.tests/testData/codegen/inline/inline0.kt index d90b7766d7b..356224e8364 100644 --- a/native/native.tests/testData/codegen/inline/inline0.kt +++ b/native/native.tests/testData/codegen/inline/inline0.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline0 - import kotlin.test.* @Suppress("NOTHING_TO_INLINE") @@ -16,7 +14,8 @@ fun bar(i: Int, j: Int): Int { return i + foo(i, j) } -@Test fun runTest() { - println(bar(41, 2).toString()) +fun box(): String { + assertEquals(84, bar(41, 2)) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline0.out b/native/native.tests/testData/codegen/inline/inline0.out deleted file mode 100644 index 871727de1fd..00000000000 --- a/native/native.tests/testData/codegen/inline/inline0.out +++ /dev/null @@ -1 +0,0 @@ -84 diff --git a/native/native.tests/testData/codegen/inline/inline1.kt b/native/native.tests/testData/codegen/inline/inline1.kt index 86ac21dea9f..3106cdc8cdd 100644 --- a/native/native.tests/testData/codegen/inline/inline1.kt +++ b/native/native.tests/testData/codegen/inline/inline1.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline1 - import kotlin.test.* @Suppress("NOTHING_TO_INLINE") @@ -16,8 +14,9 @@ fun bar(s1: String, s2: String, s3: String): String { return s1 + foo(s2, s3) } -@Test fun runTest() { - println(bar("Hello ", "wor", "ld")) +fun box(): String { + assertEquals("Hello world", bar("Hello ", "wor", "ld")) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline1.out b/native/native.tests/testData/codegen/inline/inline1.out deleted file mode 100644 index 802992c4220..00000000000 --- a/native/native.tests/testData/codegen/inline/inline1.out +++ /dev/null @@ -1 +0,0 @@ -Hello world diff --git a/native/native.tests/testData/codegen/inline/inline10.kt b/native/native.tests/testData/codegen/inline/inline10.kt index de24425676e..c9ad8376889 100644 --- a/native/native.tests/testData/codegen/inline/inline10.kt +++ b/native/native.tests/testData/codegen/inline/inline10.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline10 - import kotlin.test.* @Suppress("NOTHING_TO_INLINE") @@ -16,6 +14,7 @@ fun bar(i1: Int): Int { return foo(i1) { 1 } } -@Test fun runTest() { - println(bar(1).toString()) +fun box(): String { + assertEquals(2, bar(1)) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline10.out b/native/native.tests/testData/codegen/inline/inline10.out deleted file mode 100644 index 0cfbf08886f..00000000000 --- a/native/native.tests/testData/codegen/inline/inline10.out +++ /dev/null @@ -1 +0,0 @@ -2 diff --git a/native/native.tests/testData/codegen/inline/inline11.kt b/native/native.tests/testData/codegen/inline/inline11.kt index 76c87f91bb0..60c5f9284e6 100644 --- a/native/native.tests/testData/codegen/inline/inline11.kt +++ b/native/native.tests/testData/codegen/inline/inline11.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline11 - import kotlin.test.* @Suppress("NOTHING_TO_INLINE") @@ -16,6 +14,7 @@ fun bar(i1: Int): Boolean { return foo(i1) } -@Test fun runTest() { - println(bar(1).toString()) +fun box(): String { + assertFalse(bar(1)) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline12.kt b/native/native.tests/testData/codegen/inline/inline12.kt index 2ad95d86140..948c8799a1b 100644 --- a/native/native.tests/testData/codegen/inline/inline12.kt +++ b/native/native.tests/testData/codegen/inline/inline12.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline12 - import kotlin.test.* @Suppress("NOTHING_TO_INLINE") @@ -16,6 +14,7 @@ fun bar(i1: Int): Boolean { return foo() } -@Test fun runTest() { - println(bar(1).toString()) +fun box(): String { + assertTrue(bar(1)) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline13.kt b/native/native.tests/testData/codegen/inline/inline13.kt index 9c8b5842299..a7493aff5b8 100644 --- a/native/native.tests/testData/codegen/inline/inline13.kt +++ b/native/native.tests/testData/codegen/inline/inline13.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline13 - import kotlin.test.* open class A() @@ -19,6 +17,7 @@ fun bar(): Boolean { return foo>(B()) } -@Test fun runTest() { - println(bar().toString()) +fun box(): String { + assertTrue(bar()) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline13.out b/native/native.tests/testData/codegen/inline/inline13.out deleted file mode 100644 index 27ba77ddaf6..00000000000 --- a/native/native.tests/testData/codegen/inline/inline13.out +++ /dev/null @@ -1 +0,0 @@ -true diff --git a/native/native.tests/testData/codegen/inline/inline14.kt b/native/native.tests/testData/codegen/inline/inline14.kt index 0c53e64df7e..75d15351509 100644 --- a/native/native.tests/testData/codegen/inline/inline14.kt +++ b/native/native.tests/testData/codegen/inline/inline14.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline14 - import kotlin.test.* @Suppress("NOTHING_TO_INLINE") @@ -26,6 +24,7 @@ fun bar(i0: Int): Int { return foo1(i0) + foo3(i0) } -@Test fun runTest() { - println(bar(2).toString()) +fun box(): String { + assertEquals(9, bar(2)) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline14.out b/native/native.tests/testData/codegen/inline/inline14.out deleted file mode 100644 index ec635144f60..00000000000 --- a/native/native.tests/testData/codegen/inline/inline14.out +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/native/native.tests/testData/codegen/inline/inline15.kt b/native/native.tests/testData/codegen/inline/inline15.kt index 8c0ccfc781c..4bf4ce77b5f 100644 --- a/native/native.tests/testData/codegen/inline/inline15.kt +++ b/native/native.tests/testData/codegen/inline/inline15.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline15 - import kotlin.test.* @Suppress("NOTHING_TO_INLINE") @@ -21,6 +19,7 @@ fun bar(i0: Int): Int { return foo1(i0) { foo2(it) + 1 } } -@Test fun runTest() { - println(bar(2).toString()) +fun box(): String { + assertEquals(4, bar(2)) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline15.out b/native/native.tests/testData/codegen/inline/inline15.out deleted file mode 100644 index b8626c4cff2..00000000000 --- a/native/native.tests/testData/codegen/inline/inline15.out +++ /dev/null @@ -1 +0,0 @@ -4 diff --git a/native/native.tests/testData/codegen/inline/inline16.kt b/native/native.tests/testData/codegen/inline/inline16.kt index a012bdedd09..910ca498404 100644 --- a/native/native.tests/testData/codegen/inline/inline16.kt +++ b/native/native.tests/testData/codegen/inline/inline16.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline16 - import kotlin.test.* @Suppress("NOTHING_TO_INLINE") @@ -21,6 +19,7 @@ fun bar(): Boolean { return result.isEmpty() } -@Test fun runTest() { - println(bar().toString()) +fun box(): String { + assertFalse(bar()) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline16.out b/native/native.tests/testData/codegen/inline/inline16.out deleted file mode 100644 index c508d5366f7..00000000000 --- a/native/native.tests/testData/codegen/inline/inline16.out +++ /dev/null @@ -1 +0,0 @@ -false diff --git a/native/native.tests/testData/codegen/inline/inline17.kt b/native/native.tests/testData/codegen/inline/inline17.kt index 2b495048141..ff214cfe191 100644 --- a/native/native.tests/testData/codegen/inline/inline17.kt +++ b/native/native.tests/testData/codegen/inline/inline17.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline17 - import kotlin.test.* @Suppress("NOTHING_TO_INLINE") @@ -18,6 +16,7 @@ fun bar(): List { return foo (1, 2) } -@Test fun runTest() { - println(bar().toString()) +fun box(): String { + assertEquals("[1, 2]", bar().toString()) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline17.out b/native/native.tests/testData/codegen/inline/inline17.out deleted file mode 100644 index 44e2ace7e54..00000000000 --- a/native/native.tests/testData/codegen/inline/inline17.out +++ /dev/null @@ -1 +0,0 @@ -[1, 2] diff --git a/native/native.tests/testData/codegen/inline/inline18.kt b/native/native.tests/testData/codegen/inline/inline18.kt index 33370f84983..f20da931217 100644 --- a/native/native.tests/testData/codegen/inline/inline18.kt +++ b/native/native.tests/testData/codegen/inline/inline18.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline18 - import kotlin.test.* @Suppress("NOTHING_TO_INLINE") @@ -22,6 +20,7 @@ fun bar(): Boolean { return result } -@Test fun runTest() { - println(bar().toString()) +fun box(): String { + assertTrue(bar()) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline18.out b/native/native.tests/testData/codegen/inline/inline18.out deleted file mode 100644 index 27ba77ddaf6..00000000000 --- a/native/native.tests/testData/codegen/inline/inline18.out +++ /dev/null @@ -1 +0,0 @@ -true diff --git a/native/native.tests/testData/codegen/inline/inline19.kt b/native/native.tests/testData/codegen/inline/inline19.kt index f5bb1377a88..a1aee654762 100644 --- a/native/native.tests/testData/codegen/inline/inline19.kt +++ b/native/native.tests/testData/codegen/inline/inline19.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline19 - import kotlin.test.* @Suppress("NOTHING_TO_INLINE") @@ -17,7 +15,8 @@ fun bar(): Int { return foo(1) + foo(2) } -@Test fun runTest() { - println(bar().toString()) +fun box(): String { + assertEquals(6, bar()) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline19.out b/native/native.tests/testData/codegen/inline/inline19.out deleted file mode 100644 index 1e8b3149621..00000000000 --- a/native/native.tests/testData/codegen/inline/inline19.out +++ /dev/null @@ -1 +0,0 @@ -6 diff --git a/native/native.tests/testData/codegen/inline/inline2.kt b/native/native.tests/testData/codegen/inline/inline2.kt index 4b0c31e8099..b584caeca4e 100644 --- a/native/native.tests/testData/codegen/inline/inline2.kt +++ b/native/native.tests/testData/codegen/inline/inline2.kt @@ -3,19 +3,22 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline2 - import kotlin.test.* +val sb = StringBuilder() + @Suppress("NOTHING_TO_INLINE") inline fun foo(i4: Int, i5: Int) { - println("hello $i4 $i5") + sb.appendLine("hello $i4 $i5") } fun bar(i1: Int, i2: Int) { foo(i1, i2) } -@Test fun runTest() { +fun box(): String { bar(1, 8) + + assertEquals("hello 1 8\n", sb.toString()) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline2.out b/native/native.tests/testData/codegen/inline/inline2.out deleted file mode 100644 index 49080c6fcad..00000000000 --- a/native/native.tests/testData/codegen/inline/inline2.out +++ /dev/null @@ -1 +0,0 @@ -hello 1 8 diff --git a/native/native.tests/testData/codegen/inline/inline20.kt b/native/native.tests/testData/codegen/inline/inline20.kt index 68cc6e21f1d..c1c74eb7a71 100644 --- a/native/native.tests/testData/codegen/inline/inline20.kt +++ b/native/native.tests/testData/codegen/inline/inline20.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline20 - import kotlin.test.* @Suppress("NOTHING_TO_INLINE") @@ -13,9 +11,9 @@ inline fun bar(block: () -> String) : String { } fun bar2() : String { - return bar { return "def" } + return bar { return "OK" } } -@Test fun runTest() { - println(bar2()) +fun box(): String { + return bar2() } diff --git a/native/native.tests/testData/codegen/inline/inline20.out b/native/native.tests/testData/codegen/inline/inline20.out deleted file mode 100644 index 24c5735c3e8..00000000000 --- a/native/native.tests/testData/codegen/inline/inline20.out +++ /dev/null @@ -1 +0,0 @@ -def diff --git a/native/native.tests/testData/codegen/inline/inline21.kt b/native/native.tests/testData/codegen/inline/inline21.kt index cf0ec4e5a9d..a8556e28a43 100644 --- a/native/native.tests/testData/codegen/inline/inline21.kt +++ b/native/native.tests/testData/codegen/inline/inline21.kt @@ -3,25 +3,34 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline21 - import kotlin.test.* +val sb = StringBuilder() + inline fun foo2(block2: () -> Int) : Int { - println("foo2") + sb.appendLine("foo2") return block2() } inline fun foo1(block1: () -> Int) : Int { - println("foo1") + sb.appendLine("foo1") return foo2(block1) } fun bar(block: () -> Int) : Int { - println("bar") + sb.appendLine("bar") return foo1(block) } -@Test fun runTest() { - println(bar { 33 }) +fun box(): String { + sb.appendLine(bar { 33 }) + + assertEquals(""" + bar + foo1 + foo2 + 33 + + """.trimIndent(), sb.toString()) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline21.out b/native/native.tests/testData/codegen/inline/inline21.out deleted file mode 100644 index a4c2f6a3f74..00000000000 --- a/native/native.tests/testData/codegen/inline/inline21.out +++ /dev/null @@ -1,4 +0,0 @@ -bar -foo1 -foo2 -33 diff --git a/native/native.tests/testData/codegen/inline/inline22.kt b/native/native.tests/testData/codegen/inline/inline22.kt index ff016b849be..a9c4bfd2187 100644 --- a/native/native.tests/testData/codegen/inline/inline22.kt +++ b/native/native.tests/testData/codegen/inline/inline22.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline22 - import kotlin.test.* inline fun foo2(i2: Int): Int { @@ -19,6 +17,7 @@ fun bar(): Int { return foo1(11) } -@Test fun runTest() { - println(bar().toString()) +fun box(): String { + assertEquals(14, bar()) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline22.out b/native/native.tests/testData/codegen/inline/inline22.out deleted file mode 100644 index 8351c19397f..00000000000 --- a/native/native.tests/testData/codegen/inline/inline22.out +++ /dev/null @@ -1 +0,0 @@ -14 diff --git a/native/native.tests/testData/codegen/inline/inline23.kt b/native/native.tests/testData/codegen/inline/inline23.kt index 8ddbd638b74..25b9b897123 100644 --- a/native/native.tests/testData/codegen/inline/inline23.kt +++ b/native/native.tests/testData/codegen/inline/inline23.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline23 - import kotlin.test.* inline fun foo(i2: Any): T { @@ -15,6 +13,7 @@ fun bar(i1: Int): Int { return foo(i1) } -@Test fun runTest() { - println(bar(33)) +fun box(): String { + assertEquals(33, bar(33)) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline23.out b/native/native.tests/testData/codegen/inline/inline23.out deleted file mode 100644 index bb95160cb6e..00000000000 --- a/native/native.tests/testData/codegen/inline/inline23.out +++ /dev/null @@ -1 +0,0 @@ -33 diff --git a/native/native.tests/testData/codegen/inline/inline24.kt b/native/native.tests/testData/codegen/inline/inline24.kt index 43117aaf984..10fc034bc3a 100644 --- a/native/native.tests/testData/codegen/inline/inline24.kt +++ b/native/native.tests/testData/codegen/inline/inline24.kt @@ -3,15 +3,25 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline24 - import kotlin.test.* -fun foo() = println("foo") -fun bar() = println("bar") +val sb = StringBuilder() +fun myPrintln(s: String): Unit { + sb.appendLine(s) +} + +fun foo() = myPrintln("foo") +fun bar() = myPrintln("bar") inline fun baz(x: Unit = foo(), y: Unit) {} -@Test fun runTest() { +fun box(): String { baz(y = bar()) + + assertEquals(""" + bar + foo + + """.trimIndent(), sb.toString()) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline24.out b/native/native.tests/testData/codegen/inline/inline24.out deleted file mode 100644 index 128976523b6..00000000000 --- a/native/native.tests/testData/codegen/inline/inline24.out +++ /dev/null @@ -1,2 +0,0 @@ -bar -foo diff --git a/native/native.tests/testData/codegen/inline/inline25.kt b/native/native.tests/testData/codegen/inline/inline25.kt index bb312a4d6d2..e27ad283c85 100644 --- a/native/native.tests/testData/codegen/inline/inline25.kt +++ b/native/native.tests/testData/codegen/inline/inline25.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline25 - import kotlin.test.* inline fun foo(block: String.() -> Unit) { @@ -19,12 +17,14 @@ inline fun baz(block: String.() -> Unit) { block("Ok") } -@Test fun runTest() { +fun box(): String { bar { - println(it) + assertEquals("Ok", it) } baz { - println(this) + assertEquals("Ok", this) } + + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline25.out b/native/native.tests/testData/codegen/inline/inline25.out deleted file mode 100644 index 541dab48def..00000000000 --- a/native/native.tests/testData/codegen/inline/inline25.out +++ /dev/null @@ -1,2 +0,0 @@ -Ok -Ok diff --git a/native/native.tests/testData/codegen/inline/inline26.kt b/native/native.tests/testData/codegen/inline/inline26.kt index cdc22a1faa5..6963b6ad2e4 100644 --- a/native/native.tests/testData/codegen/inline/inline26.kt +++ b/native/native.tests/testData/codegen/inline/inline26.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline26 - import kotlin.test.* inline fun call(block1: () -> Unit, noinline block2: () -> Int): Int { @@ -12,7 +10,9 @@ inline fun call(block1: () -> Unit, noinline block2: () -> Int): Int { return block2() } -@Test fun runTest() { +fun box(): String { var x = 5 - println(call({ x = 7 }, x::toInt)) + assertEquals(5, call({ x = 7 }, x::toInt)) + + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline26.out b/native/native.tests/testData/codegen/inline/inline26.out deleted file mode 100644 index 7ed6ff82de6..00000000000 --- a/native/native.tests/testData/codegen/inline/inline26.out +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/native/native.tests/testData/codegen/inline/inline3.kt b/native/native.tests/testData/codegen/inline/inline3.kt index 44078dbdd99..f9e6b82c85b 100644 --- a/native/native.tests/testData/codegen/inline/inline3.kt +++ b/native/native.tests/testData/codegen/inline/inline3.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline3 - import kotlin.test.* @Suppress("NOTHING_TO_INLINE") @@ -20,6 +18,7 @@ fun bar(i1: Int, i2: Int, i3: Int): Int { return i1 + foo(i2, i3) } -@Test fun runTest() { - println(bar(1, 8, 2).toString()) +fun box(): String { + assertEquals(5, bar(1, 8, 2)) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline3.out b/native/native.tests/testData/codegen/inline/inline3.out deleted file mode 100644 index 7ed6ff82de6..00000000000 --- a/native/native.tests/testData/codegen/inline/inline3.out +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/native/native.tests/testData/codegen/inline/inline4.kt b/native/native.tests/testData/codegen/inline/inline4.kt index b04b86c9e60..52d5b18585f 100644 --- a/native/native.tests/testData/codegen/inline/inline4.kt +++ b/native/native.tests/testData/codegen/inline/inline4.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline4 - import kotlin.test.* @Suppress("NOTHING_TO_INLINE") @@ -17,6 +15,7 @@ fun bar(i1: Int, i2: Int): Int { return foo(i1, i2) } -@Test fun runTest() { - println(bar(3, 8).toString()) +fun box(): String { + assertEquals(3, bar(3, 8)) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline4.out b/native/native.tests/testData/codegen/inline/inline4.out deleted file mode 100644 index 00750edc07d..00000000000 --- a/native/native.tests/testData/codegen/inline/inline4.out +++ /dev/null @@ -1 +0,0 @@ -3 diff --git a/native/native.tests/testData/codegen/inline/inline5.kt b/native/native.tests/testData/codegen/inline/inline5.kt index 1e53d894c47..918f2a9b167 100644 --- a/native/native.tests/testData/codegen/inline/inline5.kt +++ b/native/native.tests/testData/codegen/inline/inline5.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline5 - import kotlin.test.* @Suppress("NOTHING_TO_INLINE") @@ -16,7 +14,8 @@ fun bar(i1: Int): Int { return foo(i1) { return 33 } } -@Test fun runTest() { - println(bar(1).toString()) +fun box(): String { + assertEquals(33, bar(1)) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline5.out b/native/native.tests/testData/codegen/inline/inline5.out deleted file mode 100644 index bb95160cb6e..00000000000 --- a/native/native.tests/testData/codegen/inline/inline5.out +++ /dev/null @@ -1 +0,0 @@ -33 diff --git a/native/native.tests/testData/codegen/inline/inline6.kt b/native/native.tests/testData/codegen/inline/inline6.kt index 2a518ccc075..0bdd4f1a6a3 100644 --- a/native/native.tests/testData/codegen/inline/inline6.kt +++ b/native/native.tests/testData/codegen/inline/inline6.kt @@ -3,24 +3,33 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline6 - import kotlin.test.* +val sb = StringBuilder() + @Suppress("NOTHING_TO_INLINE") inline fun foo(body: () -> Unit) { - println("hello1") + sb.appendLine("hello1") body() - println("hello4") + sb.appendLine("hello4") } fun bar() { foo { - println("hello2") - println("hello3") + sb.appendLine("hello2") + sb.appendLine("hello3") } } -@Test fun runTest() { +fun box(): String { bar() + + assertEquals(""" + hello1 + hello2 + hello3 + hello4 + + """.trimIndent(), sb.toString()) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline6.out b/native/native.tests/testData/codegen/inline/inline6.out deleted file mode 100644 index b2af0be1b69..00000000000 --- a/native/native.tests/testData/codegen/inline/inline6.out +++ /dev/null @@ -1,4 +0,0 @@ -hello1 -hello2 -hello3 -hello4 diff --git a/native/native.tests/testData/codegen/inline/inline7.kt b/native/native.tests/testData/codegen/inline/inline7.kt index 1f1423a3fa0..d76abc960d8 100644 --- a/native/native.tests/testData/codegen/inline/inline7.kt +++ b/native/native.tests/testData/codegen/inline/inline7.kt @@ -3,14 +3,14 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline7 - import kotlin.test.* +val sb = StringBuilder() + @Suppress("NOTHING_TO_INLINE") inline fun foo(vararg args: Int) { for (a in args) { - println(a.toString()) + sb.appendLine(a.toString()) } } @@ -18,6 +18,14 @@ fun bar() { foo(1, 2, 3) } -@Test fun runTest() { +fun box(): String { bar() + + assertEquals(""" + 1 + 2 + 3 + + """.trimIndent(), sb.toString()) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline7.out b/native/native.tests/testData/codegen/inline/inline7.out deleted file mode 100644 index 01e79c32a8c..00000000000 --- a/native/native.tests/testData/codegen/inline/inline7.out +++ /dev/null @@ -1,3 +0,0 @@ -1 -2 -3 diff --git a/native/native.tests/testData/codegen/inline/inline8.kt b/native/native.tests/testData/codegen/inline/inline8.kt index c47e535e783..e81980a5be7 100644 --- a/native/native.tests/testData/codegen/inline/inline8.kt +++ b/native/native.tests/testData/codegen/inline/inline8.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline8 - import kotlin.test.* @Suppress("NOTHING_TO_INLINE") @@ -16,6 +14,7 @@ fun bar(i1: Int, i2: Int) : Int { return foo(i1 + i2, 2) } -@Test fun runTest() { - println(bar(1, 2).toString()) +fun box(): String { + assertEquals(8, bar(1, 2)) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline8.out b/native/native.tests/testData/codegen/inline/inline8.out deleted file mode 100644 index 45a4fb75db8..00000000000 --- a/native/native.tests/testData/codegen/inline/inline8.out +++ /dev/null @@ -1 +0,0 @@ -8 diff --git a/native/native.tests/testData/codegen/inline/inline9.kt b/native/native.tests/testData/codegen/inline/inline9.kt index f5fb36286ad..ce584aed05d 100644 --- a/native/native.tests/testData/codegen/inline/inline9.kt +++ b/native/native.tests/testData/codegen/inline/inline9.kt @@ -3,17 +3,17 @@ * that can be found in the LICENSE file. */ -package codegen.inline.inline9 - import kotlin.test.* +val sb = StringBuilder() + @Suppress("NOTHING_TO_INLINE") inline fun foo(i3: Int, i4: Int): Int { return i3 + i3 + i4 } fun quiz(i: Int) : Int { - println("hello") + sb.appendLine("hello") return i + 1 } @@ -21,6 +21,13 @@ fun bar(i1: Int, i2: Int): Int { return foo(quiz(i1), i2) } -@Test fun runTest() { - println(bar(1, 2).toString()) +fun box(): String { + sb.appendLine(bar(1, 2).toString()) + + assertEquals(""" + hello + 6 + + """.trimIndent(), sb.toString()) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/inline9.out b/native/native.tests/testData/codegen/inline/inline9.out deleted file mode 100644 index 67d1adb3ff3..00000000000 --- a/native/native.tests/testData/codegen/inline/inline9.out +++ /dev/null @@ -1,2 +0,0 @@ -hello -6 diff --git a/native/native.tests/testData/codegen/inline/lambdaAsAny.kt b/native/native.tests/testData/codegen/inline/lambdaAsAny.kt index 7e99a5286e7..ff70eec1d7c 100644 --- a/native/native.tests/testData/codegen/inline/lambdaAsAny.kt +++ b/native/native.tests/testData/codegen/inline/lambdaAsAny.kt @@ -3,14 +3,16 @@ * that can be found in the LICENSE file. */ -package codegen.inline.lambdaAsAny - import kotlin.test.* +val sb = StringBuilder() + inline fun foo(x: Any) { - println(if (x === x) "Ok" else "Fail") + sb.append(if (x === x) "OK" else "FAIL") } -@Test fun runTest() { +fun box(): String { foo { 42 } + + return sb.toString() } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/inline/lambdaAsAny.out b/native/native.tests/testData/codegen/inline/lambdaAsAny.out deleted file mode 100644 index 7326d960397..00000000000 --- a/native/native.tests/testData/codegen/inline/lambdaAsAny.out +++ /dev/null @@ -1 +0,0 @@ -Ok diff --git a/native/native.tests/testData/codegen/inline/lambdaInDefaultValue.kt b/native/native.tests/testData/codegen/inline/lambdaInDefaultValue.kt index e9530a314f2..6cebbd9027f 100644 --- a/native/native.tests/testData/codegen/inline/lambdaInDefaultValue.kt +++ b/native/native.tests/testData/codegen/inline/lambdaInDefaultValue.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.lambdaInDefaultValue - import kotlin.test.* inline fun inlineFun(param: String, lambda: (String) -> String = { it }): String { @@ -14,7 +12,3 @@ inline fun inlineFun(param: String, lambda: (String) -> String = { it }): String fun box(): String { return inlineFun("OK") } - -@Test fun runTest() { - println(box()) -} \ No newline at end of file diff --git a/native/native.tests/testData/codegen/inline/lambdaInDefaultValue.out b/native/native.tests/testData/codegen/inline/lambdaInDefaultValue.out deleted file mode 100644 index d86bac9de59..00000000000 --- a/native/native.tests/testData/codegen/inline/lambdaInDefaultValue.out +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/native/native.tests/testData/codegen/inline/localFunctionInInitializerBlock.kt b/native/native.tests/testData/codegen/inline/localFunctionInInitializerBlock.kt index c6f531fd938..0990b27fca7 100644 --- a/native/native.tests/testData/codegen/inline/localFunctionInInitializerBlock.kt +++ b/native/native.tests/testData/codegen/inline/localFunctionInInitializerBlock.kt @@ -3,10 +3,10 @@ * that can be found in the LICENSE file. */ -package codegen.inline.localFunctionInInitializerBlock - import kotlin.test.* +val sb = StringBuilder() + class Foo { init { bar() @@ -14,9 +14,10 @@ class Foo { } inline fun bar() { - println({ "Ok" }()) + sb.append({ "OK" }()) } -@Test fun runTest() { +fun box(): String { Foo() + return sb.toString() } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/inline/localFunctionInInitializerBlock.out b/native/native.tests/testData/codegen/inline/localFunctionInInitializerBlock.out deleted file mode 100644 index 7326d960397..00000000000 --- a/native/native.tests/testData/codegen/inline/localFunctionInInitializerBlock.out +++ /dev/null @@ -1 +0,0 @@ -Ok diff --git a/native/native.tests/testData/codegen/inline/localObjectReturnedFromWhen.kt b/native/native.tests/testData/codegen/inline/localObjectReturnedFromWhen.kt index ec7266de504..874896242f8 100644 --- a/native/native.tests/testData/codegen/inline/localObjectReturnedFromWhen.kt +++ b/native/native.tests/testData/codegen/inline/localObjectReturnedFromWhen.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.localObjectReturnedFromWhen - import kotlin.test.* fun foo() { @@ -15,7 +13,7 @@ fun foo() { } } -@Test fun runTest() { +fun box(): String { foo() - println("Ok") + return "OK" } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/inline/localObjectReturnedFromWhen.out b/native/native.tests/testData/codegen/inline/localObjectReturnedFromWhen.out deleted file mode 100644 index 7326d960397..00000000000 --- a/native/native.tests/testData/codegen/inline/localObjectReturnedFromWhen.out +++ /dev/null @@ -1 +0,0 @@ -Ok diff --git a/native/native.tests/testData/codegen/inline/propertyAccessorInline.kt b/native/native.tests/testData/codegen/inline/propertyAccessorInline.kt index 49030854b19..a9ef3205f78 100644 --- a/native/native.tests/testData/codegen/inline/propertyAccessorInline.kt +++ b/native/native.tests/testData/codegen/inline/propertyAccessorInline.kt @@ -3,20 +3,27 @@ * that can be found in the LICENSE file. */ -package codegen.inline.propertyAccessorInline - import kotlin.test.* +val sb = StringBuilder() + object C { const val x = 42 } fun getC(): C { - println(123) + sb.appendLine(123) return C } -@Test fun runTest() { - println(getC().x) +fun box(): String { + sb.appendLine(getC().x) + + assertEquals(""" + 123 + 42 + + """.trimIndent(), sb.toString()) + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/propertyAccessorInline.out b/native/native.tests/testData/codegen/inline/propertyAccessorInline.out deleted file mode 100644 index 7ee4383e424..00000000000 --- a/native/native.tests/testData/codegen/inline/propertyAccessorInline.out +++ /dev/null @@ -1,2 +0,0 @@ -123 -42 diff --git a/native/native.tests/testData/codegen/inline/redundantCoercionsCleaner.kt b/native/native.tests/testData/codegen/inline/redundantCoercionsCleaner.kt index d7101d67593..c49c1f39d81 100644 --- a/native/native.tests/testData/codegen/inline/redundantCoercionsCleaner.kt +++ b/native/native.tests/testData/codegen/inline/redundantCoercionsCleaner.kt @@ -1,5 +1,3 @@ -package codegen.inline.redundantCoercionsCleaner - import kotlin.test.* inline fun runAndThrow(action: () -> Unit): Nothing { @@ -11,39 +9,9 @@ inline fun foo(): Int = runAndThrow { return 1 } -@Test fun runTest() { +fun box(): String { val result: Any = foo() assertEquals(1, result) + + return "OK" } - -// The test below is inspired by https://youtrack.jetbrains.com/issue/KT-48876. - -fun bar2(): Any { - return foo2() -} - -inline fun foo2(): Int { - return try { - throw Throwable() - } catch (e: Throwable) { - return 2 - } -} - -@Test fun runTest2() { - assertEquals(2, bar2()) -} - -// Test for https://youtrack.jetbrains.com/issue/KT-49356. - -inline fun foo3(): Int { - return (return 3) -} - -fun bar3(): Any { - return foo3() -} - -@Test fun runTest3() { - assertEquals(3, bar3()) -} \ No newline at end of file diff --git a/native/native.tests/testData/codegen/inline/redundantCoercionsCleanerKT48876.kt b/native/native.tests/testData/codegen/inline/redundantCoercionsCleanerKT48876.kt new file mode 100644 index 00000000000..7f717cf4217 --- /dev/null +++ b/native/native.tests/testData/codegen/inline/redundantCoercionsCleanerKT48876.kt @@ -0,0 +1,20 @@ +import kotlin.test.* + +// The test below is inspired by https://youtrack.jetbrains.com/issue/KT-48876. + +fun bar2(): Any { + return foo2() +} + +inline fun foo2(): Int { + return try { + throw Throwable() + } catch (e: Throwable) { + return 2 + } +} + +fun box(): String { + assertEquals(2, bar2()) + return "OK" +} diff --git a/native/native.tests/testData/codegen/inline/redundantCoercionsCleanerKT49356.kt b/native/native.tests/testData/codegen/inline/redundantCoercionsCleanerKT49356.kt new file mode 100644 index 00000000000..94cd654a7f2 --- /dev/null +++ b/native/native.tests/testData/codegen/inline/redundantCoercionsCleanerKT49356.kt @@ -0,0 +1,16 @@ +import kotlin.test.* + +// Test for https://youtrack.jetbrains.com/issue/KT-49356. + +inline fun foo3(): Int { + return (return 3) +} + +fun bar3(): Any { + return foo3() +} + +fun box(): String { + assertEquals(3, bar3()) + return "OK" +} diff --git a/native/native.tests/testData/codegen/inline/returnLocalClassFromBlock.kt b/native/native.tests/testData/codegen/inline/returnLocalClassFromBlock.kt index f8c90fa05dd..ce7c2518670 100644 --- a/native/native.tests/testData/codegen/inline/returnLocalClassFromBlock.kt +++ b/native/native.tests/testData/codegen/inline/returnLocalClassFromBlock.kt @@ -3,18 +3,19 @@ * that can be found in the LICENSE file. */ -package codegen.inline.returnLocalClassFromBlock - import kotlin.test.* +val sb = StringBuilder() + inline fun call(block: ()->R): R { try { return block() } finally { - println("Zzz") + sb.append("OK") } } -@Test fun runTest() { +fun box(): String { call { class Z(); Z() } + return sb.toString() } diff --git a/native/native.tests/testData/codegen/inline/returnLocalClassFromBlock.out b/native/native.tests/testData/codegen/inline/returnLocalClassFromBlock.out deleted file mode 100644 index a7bfde6f0ec..00000000000 --- a/native/native.tests/testData/codegen/inline/returnLocalClassFromBlock.out +++ /dev/null @@ -1 +0,0 @@ -Zzz diff --git a/native/native.tests/testData/codegen/inline/statementAsLastExprInBlock.kt b/native/native.tests/testData/codegen/inline/statementAsLastExprInBlock.kt index 91ab477ae6f..6a60073130a 100644 --- a/native/native.tests/testData/codegen/inline/statementAsLastExprInBlock.kt +++ b/native/native.tests/testData/codegen/inline/statementAsLastExprInBlock.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.statementAsLastExprInBlock - import kotlin.test.* fun foo() { @@ -18,6 +16,7 @@ fun foo() { } } -@Test fun runTest() { - println("OK") +fun box(): String { + foo() + return "OK" } diff --git a/native/native.tests/testData/codegen/inline/statementAsLastExprInBlock.out b/native/native.tests/testData/codegen/inline/statementAsLastExprInBlock.out deleted file mode 100644 index d86bac9de59..00000000000 --- a/native/native.tests/testData/codegen/inline/statementAsLastExprInBlock.out +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/native/native.tests/testData/codegen/inline/twiceInlinedObject.kt b/native/native.tests/testData/codegen/inline/twiceInlinedObject.kt index f84ea764905..4d9c2c153d9 100644 --- a/native/native.tests/testData/codegen/inline/twiceInlinedObject.kt +++ b/native/native.tests/testData/codegen/inline/twiceInlinedObject.kt @@ -3,26 +3,28 @@ * that can be found in the LICENSE file. */ -package codegen.inline.twiceInlinedObject - import kotlin.test.* +val sb = StringBuilder() + inline fun exec(f: () -> Unit) = f() inline fun test2() { val obj = object { - fun sayOk() = println("Ok") + fun sayOk() = sb.append("OK") } obj.sayOk() } inline fun noExec(f: () -> Unit) { } -@Test fun runTest() { +fun box(): String { exec { test2() } noExec { test2() } + + return sb.toString() } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/inline/twiceInlinedObject.out b/native/native.tests/testData/codegen/inline/twiceInlinedObject.out deleted file mode 100644 index 7326d960397..00000000000 --- a/native/native.tests/testData/codegen/inline/twiceInlinedObject.out +++ /dev/null @@ -1 +0,0 @@ -Ok diff --git a/native/native.tests/testData/codegen/inline/typeSubstitutionInFakeOverride.kt b/native/native.tests/testData/codegen/inline/typeSubstitutionInFakeOverride.kt index e21719860ca..54deb1c941f 100644 --- a/native/native.tests/testData/codegen/inline/typeSubstitutionInFakeOverride.kt +++ b/native/native.tests/testData/codegen/inline/typeSubstitutionInFakeOverride.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inline.typeSubstitutionInFakeOverride - import kotlin.test.* abstract class A { @@ -21,6 +19,6 @@ class B : A() { class OK -@Test fun runTest() { - println(B().bar()) +fun box(): String { + return B().bar() } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/inline/typeSubstitutionInFakeOverride.out b/native/native.tests/testData/codegen/inline/typeSubstitutionInFakeOverride.out deleted file mode 100644 index d86bac9de59..00000000000 --- a/native/native.tests/testData/codegen/inline/typeSubstitutionInFakeOverride.out +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/native/native.tests/testData/codegen/inlineClass/customEquals.kt b/native/native.tests/testData/codegen/inlineClass/customEquals.kt index 0c22415e72b..032d5f2849c 100644 --- a/native/native.tests/testData/codegen/inlineClass/customEquals.kt +++ b/native/native.tests/testData/codegen/inlineClass/customEquals.kt @@ -3,7 +3,6 @@ * that can be found in the LICENSE file. */ @file:Suppress("RESERVED_MEMBER_INSIDE_VALUE_CLASS") -package codegen.inlineClass.customEquals import kotlin.test.* @@ -11,6 +10,7 @@ private inline class Z(val data: Int) { override fun equals(other: Any?) = other is Z && data % 256 == other.data % 256 } -@Test fun runTest() { +fun box(): String { assertTrue(Z(0) == Z(256)) + return "OK" } diff --git a/native/native.tests/testData/codegen/inlineClass/defaultEquals.kt b/native/native.tests/testData/codegen/inlineClass/defaultEquals.kt index 8fa1792eb29..bbdee7e7903 100644 --- a/native/native.tests/testData/codegen/inlineClass/defaultEquals.kt +++ b/native/native.tests/testData/codegen/inlineClass/defaultEquals.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inlineClass.defaultEquals - import kotlin.test.* inline class A(val x: Int) @@ -12,7 +10,7 @@ inline class B(val a: A) inline class C(val s: String) inline class D(val c: C) -@Test fun runTest() { +fun box(): String { val a = A(42) val b = B(a) val c = C("zzz") @@ -21,4 +19,6 @@ inline class D(val c: C) assertTrue(b.equals(b)) assertTrue(c.equals(c)) assertTrue(d.equals(d)) + + return "OK" } diff --git a/native/native.tests/testData/codegen/inlineClass/inlineClass0.kt b/native/native.tests/testData/codegen/inlineClass/inlineClass0.kt index d4204320bc2..3181a0e308a 100644 --- a/native/native.tests/testData/codegen/inlineClass/inlineClass0.kt +++ b/native/native.tests/testData/codegen/inlineClass/inlineClass0.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inlineClass.inlineClass0 - import kotlin.test.* // Based on KT-27225. @@ -15,6 +13,7 @@ inline class Second(val value: First) { constructor(c: Int) : this(First(c)) } -@Test fun runTest() { +fun box(): String { assertEquals(Second(42).value.value, 42) + return "OK" } diff --git a/native/native.tests/testData/codegen/inlineClass/nestedInlineClasses.kt b/native/native.tests/testData/codegen/inlineClass/nestedInlineClasses.kt index e343f838724..f9bfa07a42a 100644 --- a/native/native.tests/testData/codegen/inlineClass/nestedInlineClasses.kt +++ b/native/native.tests/testData/codegen/inlineClass/nestedInlineClasses.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inlineClass.nestedInlineClasses - import kotlin.test.* interface I { @@ -15,7 +13,9 @@ interface I2 { inline class IC(val x: Int) } -@Test fun runTest() { +fun box(): String { assertEquals(42, I.IC(42).x) assertEquals(117, I2.IC(117).x) + + return "OK" } diff --git a/native/native.tests/testData/codegen/inlineClass/secondaryConstructorWithGenerics.kt b/native/native.tests/testData/codegen/inlineClass/secondaryConstructorWithGenerics.kt index 8bef556cfab..ae840128069 100644 --- a/native/native.tests/testData/codegen/inlineClass/secondaryConstructorWithGenerics.kt +++ b/native/native.tests/testData/codegen/inlineClass/secondaryConstructorWithGenerics.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inlineClass.secondaryConstructorWithGenerics - import kotlin.test.* // Based on KT-42649. @@ -12,7 +10,8 @@ inline class IC(val value: List) { constructor(value: T) : this(listOf(value)) } -@Test -fun runTest() { +fun box(): String { assertEquals("abc", IC("abc").value.singleOrNull()) + + return "OK" } diff --git a/native/native.tests/testData/codegen/inlineClass/valueClass0.kt b/native/native.tests/testData/codegen/inlineClass/valueClass0.kt index 0c3e6580096..3fe381e9daf 100644 --- a/native/native.tests/testData/codegen/inlineClass/valueClass0.kt +++ b/native/native.tests/testData/codegen/inlineClass/valueClass0.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.inlineClass.valueClass0 - import kotlin.test.* // Based on KT-27225. @@ -15,6 +13,7 @@ value class Second(val value: First) { constructor(c: Int) : this(First(c)) } -@Test fun runTest() { +fun box(): String { assertEquals(Second(42).value.value, 42) + return "OK" } diff --git a/native/native.tests/testData/codegen/innerClass/doubleInner.kt b/native/native.tests/testData/codegen/innerClass/doubleInner.kt index 8d82723a579..3b7e904f052 100644 --- a/native/native.tests/testData/codegen/innerClass/doubleInner.kt +++ b/native/native.tests/testData/codegen/innerClass/doubleInner.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.innerClass.doubleInner - import kotlin.test.* open class Father(val param: String) { @@ -24,7 +22,3 @@ open class Father(val param: String) { fun box(): String { return Father("fail").Child("OK").Child2().work() } - -@Test fun runTest() { - println(box()) -} \ No newline at end of file diff --git a/native/native.tests/testData/codegen/innerClass/doubleInner.out b/native/native.tests/testData/codegen/innerClass/doubleInner.out deleted file mode 100644 index d86bac9de59..00000000000 --- a/native/native.tests/testData/codegen/innerClass/doubleInner.out +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/native/native.tests/testData/codegen/innerClass/generic.kt b/native/native.tests/testData/codegen/innerClass/generic.kt index 19a0adb1dde..3f2e49784b8 100644 --- a/native/native.tests/testData/codegen/innerClass/generic.kt +++ b/native/native.tests/testData/codegen/innerClass/generic.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.innerClass.generic - import kotlin.test.* class Outer { @@ -18,7 +16,3 @@ fun box(): String { val x: Outer.Inner = Outer().Inner("OK") return x.box() } - -@Test fun runTest() { - println(box()) -} \ No newline at end of file diff --git a/native/native.tests/testData/codegen/innerClass/generic.out b/native/native.tests/testData/codegen/innerClass/generic.out deleted file mode 100644 index d86bac9de59..00000000000 --- a/native/native.tests/testData/codegen/innerClass/generic.out +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/native/native.tests/testData/codegen/innerClass/getOuterVal.kt b/native/native.tests/testData/codegen/innerClass/getOuterVal.kt index 0932a35a0a3..b419213f730 100644 --- a/native/native.tests/testData/codegen/innerClass/getOuterVal.kt +++ b/native/native.tests/testData/codegen/innerClass/getOuterVal.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.innerClass.getOuterVal - import kotlin.test.* class Outer(val s: String) { @@ -14,8 +12,3 @@ class Outer(val s: String) { } fun box() = Outer("OK").Inner().box() - -@Test fun runTest() -{ - println(box()) -} \ No newline at end of file diff --git a/native/native.tests/testData/codegen/innerClass/getOuterVal.out b/native/native.tests/testData/codegen/innerClass/getOuterVal.out deleted file mode 100644 index d86bac9de59..00000000000 --- a/native/native.tests/testData/codegen/innerClass/getOuterVal.out +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/native/native.tests/testData/codegen/innerClass/noPrimaryConstructor.kt b/native/native.tests/testData/codegen/innerClass/noPrimaryConstructor.kt index 9e7e7ea2ec3..b6275fcfe68 100644 --- a/native/native.tests/testData/codegen/innerClass/noPrimaryConstructor.kt +++ b/native/native.tests/testData/codegen/innerClass/noPrimaryConstructor.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.innerClass.noPrimaryConstructor - import kotlin.test.* class Outer(val s: String) { @@ -24,7 +22,7 @@ class Outer(val s: String) { } -@Test fun runTest() { - println(Outer("OK").Inner(42).foo()) - println(Outer("OK").Inner("zzz").foo()) +fun box(): String { + assertEquals("OK", Outer("OK").Inner(42).foo()) + return Outer("OK").Inner("zzz").foo() } \ No newline at end of file diff --git a/native/native.tests/testData/codegen/innerClass/noPrimaryConstructor.out b/native/native.tests/testData/codegen/innerClass/noPrimaryConstructor.out deleted file mode 100644 index 2c94e483710..00000000000 --- a/native/native.tests/testData/codegen/innerClass/noPrimaryConstructor.out +++ /dev/null @@ -1,2 +0,0 @@ -OK -OK diff --git a/native/native.tests/testData/codegen/innerClass/qualifiedThis.kt b/native/native.tests/testData/codegen/innerClass/qualifiedThis.kt index c3faf9f9b60..c595d88870a 100644 --- a/native/native.tests/testData/codegen/innerClass/qualifiedThis.kt +++ b/native/native.tests/testData/codegen/innerClass/qualifiedThis.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.innerClass.qualifiedThis - import kotlin.test.* open class ABase @@ -49,7 +47,3 @@ class A: ABase() { // implicit label @A } fun box() = A().B().bar(D()) - -@Test fun runTest() { - println(box()) -} diff --git a/native/native.tests/testData/codegen/innerClass/qualifiedThis.out b/native/native.tests/testData/codegen/innerClass/qualifiedThis.out deleted file mode 100644 index d86bac9de59..00000000000 --- a/native/native.tests/testData/codegen/innerClass/qualifiedThis.out +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/native/native.tests/testData/codegen/innerClass/secondaryConstructor.kt b/native/native.tests/testData/codegen/innerClass/secondaryConstructor.kt index 59b8eae9c59..1019d8f8fc2 100644 --- a/native/native.tests/testData/codegen/innerClass/secondaryConstructor.kt +++ b/native/native.tests/testData/codegen/innerClass/secondaryConstructor.kt @@ -3,16 +3,16 @@ * that can be found in the LICENSE file. */ -package codegen.innerClass.secondaryConstructor - import kotlin.test.* +val sb = StringBuilder() + class Outer(val x: Int) { inner class Inner() { inner class InnerInner() { init { - println(x) + sb.appendLine(x) } lateinit var s: String @@ -24,6 +24,9 @@ class Outer(val x: Int) { } } -@Test fun runTest() { +fun box(): String { Outer(42).Inner().InnerInner("zzz") + + assertEquals("42\n", sb.toString()) + return "OK" } diff --git a/native/native.tests/testData/codegen/innerClass/secondaryConstructor.out b/native/native.tests/testData/codegen/innerClass/secondaryConstructor.out deleted file mode 100644 index d81cc0710eb..00000000000 --- a/native/native.tests/testData/codegen/innerClass/secondaryConstructor.out +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/native/native.tests/testData/codegen/innerClass/simple.kt b/native/native.tests/testData/codegen/innerClass/simple.kt index 9dad4c94dd2..3c82688fb08 100644 --- a/native/native.tests/testData/codegen/innerClass/simple.kt +++ b/native/native.tests/testData/codegen/innerClass/simple.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.innerClass.simple - import kotlin.test.* class Outer { @@ -14,8 +12,3 @@ class Outer { } fun box() = Outer().Inner().box() - -@Test fun runTest() -{ - println(box()) -} \ No newline at end of file diff --git a/native/native.tests/testData/codegen/innerClass/simple.out b/native/native.tests/testData/codegen/innerClass/simple.out deleted file mode 100644 index d86bac9de59..00000000000 --- a/native/native.tests/testData/codegen/innerClass/simple.out +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/native/native.tests/testData/codegen/innerClass/superOuter.kt b/native/native.tests/testData/codegen/innerClass/superOuter.kt index 71863a2fe40..0a62da7a6ec 100644 --- a/native/native.tests/testData/codegen/innerClass/superOuter.kt +++ b/native/native.tests/testData/codegen/innerClass/superOuter.kt @@ -3,8 +3,6 @@ * that can be found in the LICENSE file. */ -package codegen.innerClass.superOuter - import kotlin.test.* open class Outer(val outer: String) { @@ -16,7 +14,3 @@ open class Outer(val outer: String) { } fun box() = Outer("Fail").value() - -@Test fun runTest() { - println(box()) -} \ No newline at end of file diff --git a/native/native.tests/testData/codegen/innerClass/superOuter.out b/native/native.tests/testData/codegen/innerClass/superOuter.out deleted file mode 100644 index d86bac9de59..00000000000 --- a/native/native.tests/testData/codegen/innerClass/superOuter.out +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenLocalTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenLocalTestGenerated.java index 0e383baa6a9..f405b57c0ea 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenLocalTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenLocalTestGenerated.java @@ -1549,15 +1549,27 @@ public class FirNativeCodegenLocalTestGenerated extends AbstractNativeCodegenBox } @Test - @TestMetadata("stack_array.kt") - public void testStack_array() throws Exception { - runTest("native/native.tests/testData/codegen/escapeAnalysis/stack_array.kt"); + @TestMetadata("stackAllocatedString.kt") + public void testStackAllocatedString() throws Exception { + runTest("native/native.tests/testData/codegen/escapeAnalysis/stackAllocatedString.kt"); } @Test - @TestMetadata("string.kt") - public void testString() throws Exception { - runTest("native/native.tests/testData/codegen/escapeAnalysis/string.kt"); + @TestMetadata("stackNotAllocated.kt") + public void testStackNotAllocated() throws Exception { + runTest("native/native.tests/testData/codegen/escapeAnalysis/stackNotAllocated.kt"); + } + + @Test + @TestMetadata("stackNotAllocatedString.kt") + public void testStackNotAllocatedString() throws Exception { + runTest("native/native.tests/testData/codegen/escapeAnalysis/stackNotAllocatedString.kt"); + } + + @Test + @TestMetadata("stack_array.kt") + public void testStack_array() throws Exception { + runTest("native/native.tests/testData/codegen/escapeAnalysis/stack_array.kt"); } @Test @@ -1675,6 +1687,12 @@ public class FirNativeCodegenLocalTestGenerated extends AbstractNativeCodegenBox runTest("native/native.tests/testData/codegen/funInterface/kt49384.kt"); } + @Test + @TestMetadata("kt49384_getSame.kt") + public void testKt49384_getSame() throws Exception { + runTest("native/native.tests/testData/codegen/funInterface/kt49384_getSame.kt"); + } + @Test @TestMetadata("nonTrivialProjectionInSuperType.kt") public void testNonTrivialProjectionInSuperType() throws Exception { @@ -2002,15 +2020,51 @@ public class FirNativeCodegenLocalTestGenerated extends AbstractNativeCodegenBox } @Test - @TestMetadata("static.kt") - public void testStatic() throws Exception { - runTest("native/native.tests/testData/codegen/initializers/static.kt"); + @TestMetadata("static_arrays.kt") + public void testStatic_arrays() throws Exception { + runTest("native/native.tests/testData/codegen/initializers/static_arrays.kt"); } @Test - @TestMetadata("testInfrastructure.kt") - public void testTestInfrastructure() throws Exception { - runTest("native/native.tests/testData/codegen/initializers/testInfrastructure.kt"); + @TestMetadata("static_constantObjectInFinally.kt") + public void testStatic_constantObjectInFinally() throws Exception { + runTest("native/native.tests/testData/codegen/initializers/static_constantObjectInFinally.kt"); + } + + @Test + @TestMetadata("static_kType.kt") + public void testStatic_kType() throws Exception { + runTest("native/native.tests/testData/codegen/initializers/static_kType.kt"); + } + + @Test + @TestMetadata("static_list.kt") + public void testStatic_list() throws Exception { + runTest("native/native.tests/testData/codegen/initializers/static_list.kt"); + } + + @Test + @TestMetadata("static_permanent.kt") + public void testStatic_permanent() throws Exception { + runTest("native/native.tests/testData/codegen/initializers/static_permanent.kt"); + } + + @Test + @TestMetadata("static_reifiedKType.kt") + public void testStatic_reifiedKType() throws Exception { + runTest("native/native.tests/testData/codegen/initializers/static_reifiedKType.kt"); + } + + @Test + @TestMetadata("static_smallIntIdentity.kt") + public void testStatic_smallIntIdentity() throws Exception { + runTest("native/native.tests/testData/codegen/initializers/static_smallIntIdentity.kt"); + } + + @Test + @TestMetadata("static_varargChange.kt") + public void testStatic_varargChange() throws Exception { + runTest("native/native.tests/testData/codegen/initializers/static_varargChange.kt"); } @Test @@ -2320,6 +2374,18 @@ public class FirNativeCodegenLocalTestGenerated extends AbstractNativeCodegenBox runTest("native/native.tests/testData/codegen/inline/redundantCoercionsCleaner.kt"); } + @Test + @TestMetadata("redundantCoercionsCleanerKT48876.kt") + public void testRedundantCoercionsCleanerKT48876() throws Exception { + runTest("native/native.tests/testData/codegen/inline/redundantCoercionsCleanerKT48876.kt"); + } + + @Test + @TestMetadata("redundantCoercionsCleanerKT49356.kt") + public void testRedundantCoercionsCleanerKT49356() throws Exception { + runTest("native/native.tests/testData/codegen/inline/redundantCoercionsCleanerKT49356.kt"); + } + @Test @TestMetadata("returnLocalClassFromBlock.kt") public void testReturnLocalClassFromBlock() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenLocalTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenLocalTestGenerated.java index 363e6566d05..121b274c084 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenLocalTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenLocalTestGenerated.java @@ -1509,15 +1509,27 @@ public class NativeCodegenLocalTestGenerated extends AbstractNativeCodegenBoxTes } @Test - @TestMetadata("stack_array.kt") - public void testStack_array() throws Exception { - runTest("native/native.tests/testData/codegen/escapeAnalysis/stack_array.kt"); + @TestMetadata("stackAllocatedString.kt") + public void testStackAllocatedString() throws Exception { + runTest("native/native.tests/testData/codegen/escapeAnalysis/stackAllocatedString.kt"); } @Test - @TestMetadata("string.kt") - public void testString() throws Exception { - runTest("native/native.tests/testData/codegen/escapeAnalysis/string.kt"); + @TestMetadata("stackNotAllocated.kt") + public void testStackNotAllocated() throws Exception { + runTest("native/native.tests/testData/codegen/escapeAnalysis/stackNotAllocated.kt"); + } + + @Test + @TestMetadata("stackNotAllocatedString.kt") + public void testStackNotAllocatedString() throws Exception { + runTest("native/native.tests/testData/codegen/escapeAnalysis/stackNotAllocatedString.kt"); + } + + @Test + @TestMetadata("stack_array.kt") + public void testStack_array() throws Exception { + runTest("native/native.tests/testData/codegen/escapeAnalysis/stack_array.kt"); } @Test @@ -1633,6 +1645,12 @@ public class NativeCodegenLocalTestGenerated extends AbstractNativeCodegenBoxTes runTest("native/native.tests/testData/codegen/funInterface/kt49384.kt"); } + @Test + @TestMetadata("kt49384_getSame.kt") + public void testKt49384_getSame() throws Exception { + runTest("native/native.tests/testData/codegen/funInterface/kt49384_getSame.kt"); + } + @Test @TestMetadata("nonTrivialProjectionInSuperType.kt") public void testNonTrivialProjectionInSuperType() throws Exception { @@ -1956,15 +1974,51 @@ public class NativeCodegenLocalTestGenerated extends AbstractNativeCodegenBoxTes } @Test - @TestMetadata("static.kt") - public void testStatic() throws Exception { - runTest("native/native.tests/testData/codegen/initializers/static.kt"); + @TestMetadata("static_arrays.kt") + public void testStatic_arrays() throws Exception { + runTest("native/native.tests/testData/codegen/initializers/static_arrays.kt"); } @Test - @TestMetadata("testInfrastructure.kt") - public void testTestInfrastructure() throws Exception { - runTest("native/native.tests/testData/codegen/initializers/testInfrastructure.kt"); + @TestMetadata("static_constantObjectInFinally.kt") + public void testStatic_constantObjectInFinally() throws Exception { + runTest("native/native.tests/testData/codegen/initializers/static_constantObjectInFinally.kt"); + } + + @Test + @TestMetadata("static_kType.kt") + public void testStatic_kType() throws Exception { + runTest("native/native.tests/testData/codegen/initializers/static_kType.kt"); + } + + @Test + @TestMetadata("static_list.kt") + public void testStatic_list() throws Exception { + runTest("native/native.tests/testData/codegen/initializers/static_list.kt"); + } + + @Test + @TestMetadata("static_permanent.kt") + public void testStatic_permanent() throws Exception { + runTest("native/native.tests/testData/codegen/initializers/static_permanent.kt"); + } + + @Test + @TestMetadata("static_reifiedKType.kt") + public void testStatic_reifiedKType() throws Exception { + runTest("native/native.tests/testData/codegen/initializers/static_reifiedKType.kt"); + } + + @Test + @TestMetadata("static_smallIntIdentity.kt") + public void testStatic_smallIntIdentity() throws Exception { + runTest("native/native.tests/testData/codegen/initializers/static_smallIntIdentity.kt"); + } + + @Test + @TestMetadata("static_varargChange.kt") + public void testStatic_varargChange() throws Exception { + runTest("native/native.tests/testData/codegen/initializers/static_varargChange.kt"); } @Test @@ -2272,6 +2326,18 @@ public class NativeCodegenLocalTestGenerated extends AbstractNativeCodegenBoxTes runTest("native/native.tests/testData/codegen/inline/redundantCoercionsCleaner.kt"); } + @Test + @TestMetadata("redundantCoercionsCleanerKT48876.kt") + public void testRedundantCoercionsCleanerKT48876() throws Exception { + runTest("native/native.tests/testData/codegen/inline/redundantCoercionsCleanerKT48876.kt"); + } + + @Test + @TestMetadata("redundantCoercionsCleanerKT49356.kt") + public void testRedundantCoercionsCleanerKT49356() throws Exception { + runTest("native/native.tests/testData/codegen/inline/redundantCoercionsCleanerKT49356.kt"); + } + @Test @TestMetadata("returnLocalClassFromBlock.kt") public void testReturnLocalClassFromBlock() throws Exception { diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/ExtTestCaseGroupProvider.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/ExtTestCaseGroupProvider.kt index 56ac89c356f..681591b87e2 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/ExtTestCaseGroupProvider.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/group/ExtTestCaseGroupProvider.kt @@ -168,6 +168,7 @@ private class ExtTestDataFile( val args = mutableListOf() testDataFileSettings.languageSettings.sorted().mapTo(args) { "-XXLanguage:$it" } testDataFileSettings.optInsForCompiler.sorted().mapTo(args) { "-opt-in=$it" } + args += "-opt-in=kotlin.native.internal.InternalForKotlinNative" // for `Any.isPermanent()` and `Any.isLocal()` args += "-opt-in=kotlin.native.internal.InternalForKotlinNativeTests" // for ReflectionPackageName val freeCInteropArgs = structure.directives.listValues(FREE_CINTEROP_ARGS.name) ?.flatMap { it.split(" ") }