backend/tests: Add blackbox tests from Kotlin JVM
Added tests from testData/codegen/box directory. There are blackbox tests in other directories and they are to be added.
This commit is contained in:
+51
@@ -0,0 +1,51 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
// WITH_RUNTIME
|
||||
// FILE: JavaClass.java
|
||||
|
||||
public class JavaClass {
|
||||
|
||||
public static class C extends B {
|
||||
public OutPair<String, Integer> foo() {
|
||||
return super.foo();
|
||||
}
|
||||
|
||||
public In<Object> bar() {
|
||||
return super.bar();
|
||||
}
|
||||
}
|
||||
|
||||
public static String test() {
|
||||
A a = new C();
|
||||
|
||||
if (!a.foo().getX().equals("OK")) return "fail 1";
|
||||
if (!a.foo().getY().equals(123)) return "fail 2";
|
||||
|
||||
if (!a.bar().make("123").equals("123")) return "fail 3";
|
||||
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
class OutPair<out X, out Y>(val x: X, val y: Y)
|
||||
class In<in Z> {
|
||||
fun make(x: Z): String = x.toString()
|
||||
}
|
||||
|
||||
@JvmSuppressWildcards(suppress = false)
|
||||
interface A {
|
||||
fun foo(): OutPair<CharSequence, Number>
|
||||
fun bar(): In<String>
|
||||
}
|
||||
|
||||
abstract class B : A {
|
||||
override fun foo(): OutPair<String, Int> = OutPair("OK", 123)
|
||||
override fun bar(): In<Any> = In()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return JavaClass.test();
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
// WITH_RUNTIME
|
||||
// FILE: JavaClass.java
|
||||
|
||||
public class JavaClass {
|
||||
|
||||
public static class C extends B {
|
||||
public OutPair<String, Integer> foo() {
|
||||
return super.foo();
|
||||
}
|
||||
|
||||
public In<Object> bar() {
|
||||
return super.bar();
|
||||
}
|
||||
}
|
||||
|
||||
public static String test() {
|
||||
A a = new C();
|
||||
|
||||
if (!a.foo().getX().equals("OK")) return "fail 1";
|
||||
if (!a.foo().getY().equals(123)) return "fail 2";
|
||||
|
||||
if (!a.bar().make("123").equals("123")) return "fail 3";
|
||||
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
class OutPair<out X, out Y>(val x: X, val y: Y)
|
||||
class In<in Z> {
|
||||
fun make(x: Z): String = x.toString()
|
||||
}
|
||||
|
||||
interface A {
|
||||
fun foo(): OutPair<@JvmWildcard CharSequence, @JvmSuppressWildcards(false) Number>
|
||||
fun bar(): In<@JvmWildcard String>
|
||||
}
|
||||
|
||||
abstract class B : A {
|
||||
override fun foo(): OutPair<String, Int> = OutPair("OK", 123)
|
||||
override fun bar(): In<Any> = In()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return JavaClass.test();
|
||||
}
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
// FILE: JavaClass.java
|
||||
|
||||
public class JavaClass {
|
||||
public static String test() {
|
||||
return MainKt.bar(MainKt.foo());
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
class Pair<out X, out Y>(val x: X, val y: Y)
|
||||
|
||||
class Inv<T>(val x: T)
|
||||
|
||||
fun foo(): Inv<Pair<CharSequence, CharSequence>> = Inv(Pair("O", "K"))
|
||||
|
||||
fun bar(inv: Inv<Pair<CharSequence, CharSequence>>) = inv.x.x.toString() + inv.x.y
|
||||
|
||||
fun box(): String {
|
||||
return JavaClass.test();
|
||||
}
|
||||
Reference in New Issue
Block a user