[K2/N] Rewrite mpp tests from old native infra to new

^KT-58543

Merge-request: KT-MR-10065
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
This commit is contained in:
Vladimir Sukharev
2023-05-16 08:41:39 +00:00
committed by Space Team
parent 2b913d7c47
commit bbe1e708f9
35 changed files with 2067 additions and 823 deletions
@@ -1,21 +0,0 @@
/*
* 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.
*/
expect class C {
constructor(arg: Any?)
}
actual data class C actual constructor(val arg: Any?) {
}
expect class T
actual typealias T = C
expect fun f(arg: Int): Int
actual fun f(arg: Int) = arg
expect var p: String
actual var p: String = "p"
@@ -1,36 +0,0 @@
/*
* 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.mpp.mpp1
import kotlin.test.*
fun box() {
assertEquals(A().B().fourtyTwo(), 42)
assertEquals(seventeen(), 17)
}
expect class A {
constructor()
inner class B {
fun fourtyTwo(): Int
constructor()
}
}
actual class A {
actual inner class B actual constructor() {
actual fun fourtyTwo() = 42
}
}
actual fun seventeen() = 17
expect fun seventeen(): Int
@Test fun runTest() {
box()
}
@@ -1,13 +0,0 @@
/*
* 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.
*/
fun main(args: Array<String>) {
println(C(42))
println(C(42) is T)
println(f(1))
p = "h"
println(p)
}
@@ -1,4 +0,0 @@
C(arg=42)
true
1
h
@@ -1,75 +0,0 @@
/*
* 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.mpp.mpp_default_args
import kotlin.test.*
@Test fun runTest() {
box()
}
fun box() {
assertEquals(test1(), 42)
assertEquals(test2(17), 34)
assertEquals(test3(), -1)
Test4().test()
Test5().Inner().test()
42.test6()
assertEquals(inlineFunction("OK"), "OK,0,null")
}
expect fun test1(x: Int = 42): Int
actual fun test1(x: Int) = x
expect fun test2(x: Int, y: Int = x): Int
actual fun test2(x: Int, y: Int) = x + y
expect fun test3(x: Int = 42, y: Int = x + 1): Int
actual fun test3(x: Int, y: Int) = x - y
expect class Test4 {
fun test(arg: Any = this)
}
actual class Test4 {
actual fun test(arg: Any) {
assertEquals(arg, this)
}
}
expect class Test5 {
inner class Inner {
constructor(arg: Any = this@Test5)
fun test(arg1: Any = this@Test5, arg2: Any = this@Inner)
}
}
actual class Test5 {
actual inner class Inner {
actual constructor(arg: Any) {
assertEquals(arg, this@Test5)
}
actual fun test(arg1: Any, arg2: Any) {
assertEquals(arg1, this@Test5)
assertEquals(arg2, this@Inner)
}
}
}
expect fun Int.test6(arg: Int = this)
actual fun Int.test6(arg: Int) {
assertEquals(arg, this)
}
// Default parameter in inline function.
expect inline fun inlineFunction(a: String, b: Int = 0, c: () -> Double? = { null }): String
actual inline fun inlineFunction(a: String, b: Int, c: () -> Double?): String = a + "," + b + "," + c()
@@ -1,17 +0,0 @@
@file:Suppress("OPT_IN_USAGE_ERROR")
import kotlin.js.*
@OptionalExpectation
expect annotation class Optional()
@Optional
fun foo() { println(42) }
@JsName("jsBar")
fun bar() { println(43) }
fun main(args: Array<String>) {
foo()
bar()
}
@@ -1,11 +0,0 @@
expect class Foo {
val p: Int
fun bar(r: () -> Int = this::p): Int
}
actual class Foo {
actual val p = 42
actual fun bar(r: () -> Int) = r()
}
fun main() {
println(Foo().bar())
}