[K/N][Tests] Adjust moved codegen tests to new infra
^KT-61259
This commit is contained in:
committed by
Space Team
parent
a5f3d5b737
commit
e15068c62f
@@ -3,7 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
package codegen.bridges.nativePointed
|
||||
|
||||
import kotlinx.cinterop.*
|
||||
import kotlin.test.*
|
||||
@@ -16,8 +15,10 @@ class CImpl : C() {
|
||||
override fun foo(x: Int) = null
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val c: C = CImpl()
|
||||
assertNull(c.foo(42))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.signature
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class A { }
|
||||
@@ -29,6 +27,8 @@ abstract class AbstractClass(): ExtendsInterface<C> {
|
||||
public override fun parse(source: A): C = C()
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val array = object : AbstractClass() { }.parse(B())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+9
-14
@@ -3,7 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.special
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@@ -28,19 +27,15 @@ private object NotEmptyMap : MutableMap<Any, Int> {
|
||||
fun box(): String {
|
||||
val n = NotEmptyMap as MutableMap<Any?, Any?>
|
||||
|
||||
if (n.get(null) != null) return "fail 1"
|
||||
if (n.containsKey(null)) return "fail 2"
|
||||
if (n.containsValue(null)) return "fail 3"
|
||||
if (n.remove(null) != null) return "fail 4"
|
||||
if (n.get(null) != null) return "FAIL 1: $n"
|
||||
if (n.containsKey(null)) return "FAIL 2: $n"
|
||||
if (n.containsValue(null)) return "FAIL 3: $n"
|
||||
if (n.remove(null) != null) return "FAIL 4: $n"
|
||||
|
||||
if (n.get(1) == null) return "fail 5"
|
||||
if (!n.containsKey("")) return "fail 6"
|
||||
if (!n.containsValue(3)) return "fail 7"
|
||||
if (n.remove("") == null) return "fail 8"
|
||||
if (n.get(1) == null) return "FAIL 5: $n"
|
||||
if (!n.containsKey("")) return "FAIL 6: $n"
|
||||
if (!n.containsValue(3)) return "FAIL 7: $n"
|
||||
if (n.remove("") == null) return "FAIL 8: $n"
|
||||
|
||||
return "Ok"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(box())
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
Ok
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.specialGeneric
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
interface Element {
|
||||
@@ -35,10 +33,11 @@ internal class MySet<E : Element> : Set<E> {
|
||||
|
||||
fun set(): Set<Any> = MySet<Element>()
|
||||
|
||||
@Test
|
||||
fun testMySet() {
|
||||
fun box(): String {
|
||||
val set = set()
|
||||
assertFalse(set.contains(Any()))
|
||||
assertFalse(set.contains(NotContainedElement))
|
||||
assertTrue(set.contains(ContainedElement))
|
||||
if (set.contains(Any())) return "FAIL 1: $set"
|
||||
if (set.contains(NotContainedElement)) return "FAIL 2: $set"
|
||||
if (!set.contains(ContainedElement)) return "FAIL 3: $set"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+7
-5
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test0
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// vtable call
|
||||
@@ -16,9 +14,13 @@ open class C : A() {
|
||||
override fun foo(): Int = 42
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val c = C()
|
||||
val a: A = c
|
||||
println(c.foo().toString())
|
||||
println(a.foo().toString())
|
||||
val res1 = c.foo().toString()
|
||||
if (res1 != "42") return "FAIL 1: $res1"
|
||||
val res2 = a.foo().toString()
|
||||
if (res2 != "42") return "FAIL 2: $res2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
42
|
||||
42
|
||||
+5
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test1
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// interface call, bridge overridden
|
||||
@@ -20,8 +18,11 @@ open class B : A() {
|
||||
override fun foo(x: Int) : Int = 42
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val z1: A = B()
|
||||
println((z1.foo(1) + 1000).toString())
|
||||
val res = (z1.foo(1) + 1000).toString()
|
||||
if (res != "1042") return "FAIL: $res"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
1042
|
||||
+8
-5
@@ -3,13 +3,13 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test10
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
open class A<T> {
|
||||
open fun foo(x: T) {
|
||||
println(x.toString())
|
||||
sb.appendLine(x.toString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,10 +28,13 @@ fun zzz(a: A<Int>) {
|
||||
a.foo(42)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
zzz(b)
|
||||
val a = A<Int>()
|
||||
zzz(a)
|
||||
println(b.z)
|
||||
sb.appendLine(b.z.toString())
|
||||
|
||||
assertEquals("42\n42\n", sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
42
|
||||
42
|
||||
+10
-4
@@ -3,10 +3,10 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test11
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
interface I {
|
||||
fun foo(x: Int)
|
||||
}
|
||||
@@ -16,14 +16,20 @@ abstract class A<T> {
|
||||
}
|
||||
|
||||
class B : A<Int>(), I {
|
||||
override fun foo(x: Int) = println(x)
|
||||
override fun foo(x: Int) {
|
||||
sb.appendLine(x)
|
||||
Unit
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
val a: A<Int> = b
|
||||
val c: I = b
|
||||
b.foo(42)
|
||||
a.foo(42)
|
||||
c.foo(42)
|
||||
|
||||
assertEquals("42\n42\n42\n", sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
42
|
||||
42
|
||||
42
|
||||
+8
-5
@@ -3,23 +3,23 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test12
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
abstract class A<in T> {
|
||||
abstract fun foo(x: T)
|
||||
}
|
||||
|
||||
class B : A<Int>() {
|
||||
override fun foo(x: Int) {
|
||||
println("B: $x")
|
||||
sb.appendLine("B: $x")
|
||||
}
|
||||
}
|
||||
|
||||
class C : A<Any>() {
|
||||
override fun foo(x: Any) {
|
||||
println("C: $x")
|
||||
sb.appendLine("C: $x")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,10 @@ fun foo(arg: A<Int>) {
|
||||
arg.foo(42)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
foo(B())
|
||||
foo(C())
|
||||
|
||||
assertEquals("B: 42\nC: 42\n", sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
B: 42
|
||||
C: 42
|
||||
+8
-5
@@ -3,13 +3,13 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test13
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
open class A<T> {
|
||||
open fun T.foo() {
|
||||
println(this.toString())
|
||||
sb.appendLine(this.toString())
|
||||
}
|
||||
|
||||
fun bar(x: T) {
|
||||
@@ -19,13 +19,16 @@ open class A<T> {
|
||||
|
||||
open class B: A<Int>() {
|
||||
override fun Int.foo() {
|
||||
println(this)
|
||||
sb.appendLine(this.toString())
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
val a = A<Int>()
|
||||
b.bar(42)
|
||||
a.bar(42)
|
||||
|
||||
assertEquals("42\n42\n", sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
42
|
||||
42
|
||||
+24
-11
@@ -3,14 +3,14 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test14
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
open class A<T, U> {
|
||||
open fun foo(x: T, y: U) {
|
||||
println(x.toString())
|
||||
println(y.toString())
|
||||
sb.appendLine(x.toString())
|
||||
sb.appendLine(y.toString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,19 +35,32 @@ fun zzz(a: A<Int, Int>) {
|
||||
a.foo(42, 56)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
zzz(b)
|
||||
val a = A<Int, Int>()
|
||||
zzz(a)
|
||||
println(b.z)
|
||||
println(b.q)
|
||||
sb.appendLine(b.z.toString())
|
||||
sb.appendLine(b.q.toString())
|
||||
val i1: I1<Int> = b
|
||||
i1.foo(56, 42)
|
||||
println(b.z)
|
||||
println(b.q)
|
||||
sb.appendLine(b.z.toString())
|
||||
sb.appendLine(b.q.toString())
|
||||
val i2: I2<Int> = b
|
||||
i2.foo(156, 142)
|
||||
println(b.z)
|
||||
println(b.q)
|
||||
sb.appendLine(b.z.toString())
|
||||
sb.appendLine(b.q.toString())
|
||||
|
||||
assertEquals("""
|
||||
42
|
||||
56
|
||||
42
|
||||
56
|
||||
56
|
||||
42
|
||||
156
|
||||
142
|
||||
|
||||
""".trimIndent(), sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
42
|
||||
56
|
||||
42
|
||||
56
|
||||
56
|
||||
42
|
||||
156
|
||||
142
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test15
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// non-generic interface, generic impl, vtable call + interface call
|
||||
@@ -38,7 +36,3 @@ fun box(): String {
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(box())
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
OK
|
||||
+8
-5
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test16
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
interface A {
|
||||
@@ -21,9 +19,14 @@ open class B: C() {
|
||||
|
||||
fun bar(c: C) = c.foo()
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
val c: C = b
|
||||
println(bar(b))
|
||||
println(bar(c))
|
||||
val barb = bar(b)
|
||||
if (barb != "OK") return "FAIL b: $barb"
|
||||
|
||||
val barc = bar(c)
|
||||
if (barc != "OK") return "FAIL c: $barc"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
OK
|
||||
OK
|
||||
+11
-7
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test17
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// abstract bridge
|
||||
@@ -22,13 +20,19 @@ class D: C() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val d = D()
|
||||
val c: C = d
|
||||
val b: B<Int> = d
|
||||
val a: A<Int> = d
|
||||
println(d.foo())
|
||||
println(c.foo())
|
||||
println(b.foo())
|
||||
println(a.foo())
|
||||
val foo0 = d.foo()
|
||||
if (foo0 != 42) return "FAIL d: $foo0"
|
||||
val foo1 = c.foo()
|
||||
if (foo1 != 42) return "FAIL c: $foo1"
|
||||
val foo2 = b.foo()
|
||||
if (foo2 != 42) return "FAIL b: $foo2"
|
||||
val foo3 = a.foo()
|
||||
if (foo3 != 42) return "FAIL a: $foo3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
42
|
||||
42
|
||||
42
|
||||
42
|
||||
+4
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test18
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// overriden function returns Unit
|
||||
@@ -16,7 +14,9 @@ open class B: A() {
|
||||
override fun foo(): Unit { }
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val a: A = B()
|
||||
println(a.foo())
|
||||
val afoo = a.foo()
|
||||
if (afoo != Unit) return "FAIL $afoo"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
kotlin.Unit
|
||||
+7
-5
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test2
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// vtable call, bridge inherited
|
||||
@@ -18,9 +16,13 @@ open class C : A() {
|
||||
|
||||
open class D: C()
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val c = D()
|
||||
val a: A = c
|
||||
println(c.foo().toString())
|
||||
println(a.foo().toString())
|
||||
val res1 = c.foo().toString()
|
||||
if (res1 != "42") return "FAIL 1: $res1"
|
||||
val res2 = a.foo().toString()
|
||||
if (res2 != "42") return "FAIL 2: $res2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
42
|
||||
42
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test3
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// non-generic interface, generic impl, non-virtual call + interface call
|
||||
@@ -33,7 +31,3 @@ fun box(): String {
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(box())
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
OK
|
||||
+7
-5
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test4
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// vtable call + interface call
|
||||
@@ -22,9 +20,13 @@ open class A {
|
||||
|
||||
open class B: A(), Z, Y
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val z: Z = B()
|
||||
val y: Y = z as Y
|
||||
println(z.foo().toString())
|
||||
println(y.foo().toString())
|
||||
val res1 = z.foo().toString()
|
||||
if (res1 != "42") return "FAIL 1: $res1"
|
||||
val res2 = y.foo().toString()
|
||||
if (res2 != "42") return "FAIL 2: $res2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
42
|
||||
42
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test5
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// non-generic interface, generic impl, vtable call + interface call
|
||||
@@ -33,7 +31,3 @@ fun box(): String {
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(box())
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
OK
|
||||
+8
-8
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test6
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// vtable call + interface call
|
||||
@@ -26,15 +24,17 @@ open class C : A() {
|
||||
|
||||
open class D: C(), Y, Z
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val d = D()
|
||||
val y: Y = d
|
||||
val z: Z = d
|
||||
val c: C = d
|
||||
val a: A = d
|
||||
println(d.foo().toString())
|
||||
println(y.foo().toString())
|
||||
println(z.foo().toString())
|
||||
println(c.foo().toString())
|
||||
println(a.foo().toString())
|
||||
if (d.foo().toString() != "42") return "FAIL 1"
|
||||
if (y.foo().toString() != "42") return "FAIL 2"
|
||||
if (z.foo().toString() != "42") return "FAIL 3"
|
||||
if (c.foo().toString() != "42") return "FAIL 4"
|
||||
if (a.foo().toString() != "42") return "FAIL 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
42
|
||||
42
|
||||
42
|
||||
42
|
||||
42
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test7
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// generic interface, non-generic impl, vtable call + interface call
|
||||
@@ -33,7 +31,3 @@ fun box(): String {
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(box())
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
OK
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test8
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// generic interface, non-generic impl, non-virtual call + interface call
|
||||
@@ -33,7 +31,3 @@ fun box(): String {
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(box())
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
OK
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.bridges.test9
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// abstract class vtable call
|
||||
@@ -30,7 +28,3 @@ fun box(): String {
|
||||
else -> "OK"
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(box())
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
OK
|
||||
Reference in New Issue
Block a user