tests: Update external tests (1.1.2-dev-393)
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
class C {
|
||||
companion object {
|
||||
@JvmStatic @kotlin.jvm.JvmOverloads public fun foo(o: String, k: String = "K"): String {
|
||||
return o + k
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val m = C::class.java.getMethod("foo", String::class.java)
|
||||
return m.invoke(null, "O") as String
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
class C {
|
||||
@kotlin.jvm.JvmOverloads public fun foo(o: String = "O", i1: Int, k: String = "K", i2: Int): String {
|
||||
return o + k
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val c = C()
|
||||
val m = c.javaClass.getMethod("foo", Int::class.java, Int::class.java)
|
||||
return m.invoke(c, 1, 2) as String
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
class C {
|
||||
@kotlin.jvm.JvmOverloads public fun foo(d1: Double, d2: Double, status: String = "OK"): String {
|
||||
return if (d1 + d2 == 3.0) status else "fail"
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val c = C()
|
||||
val m = c.javaClass.getMethod("foo", Double::class.java, Double::class.java)
|
||||
return m.invoke(c, 1.0, 2.0) as String
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
class C {
|
||||
}
|
||||
|
||||
@kotlin.jvm.JvmOverloads fun C.foo(o: String, k: String = "K"): String {
|
||||
return o + k
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val m = C::class.java.getClassLoader().loadClass("ExtensionMethodKt").getMethod("foo", C::class.java, String::class.java)
|
||||
return m.invoke(null, C(), "O") as String
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_RUNTIME
|
||||
// FILE: Test.java
|
||||
|
||||
public class Test {
|
||||
public static String invokeMethodWithOverloads() {
|
||||
C<String> c = new C<String>();
|
||||
return c.foo("O");
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: generics.kt
|
||||
|
||||
class C<T> {
|
||||
@kotlin.jvm.JvmOverloads public fun foo(o: T, k: String = "K"): String = o.toString() + k
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Test.invokeMethodWithOverloads()
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
class Outer {
|
||||
inner class Inner @JvmOverloads constructor(val s1: String, val s2: String = "OK") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val outer = Outer()
|
||||
val c = (Outer.Inner::class.java.getConstructor(Outer::class.java, String::class.java).newInstance(outer, "shazam"))
|
||||
return c.s2
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
class C {
|
||||
@kotlin.jvm.JvmOverloads public fun foo(o: String = "O", k: String = "K"): String {
|
||||
return o + k
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val c = C()
|
||||
val m = c.javaClass.getMethod("foo")
|
||||
return m.invoke(c) as String
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// FULL_JDK
|
||||
// FILE: test.kt
|
||||
|
||||
@JvmOverloads
|
||||
fun foo(id: Int, vararg pairs: String = emptyArray()): String {
|
||||
return "$id: ${java.util.Arrays.toString(pairs)}"
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun foo2(id: Int, s: Int = 56, vararg pairs: String): String {
|
||||
return "$id, $s: ${java.util.Arrays.toString(pairs)}"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (A.bar1() != "1: []") return "fail 1"
|
||||
if (A.bar2() != "2: [OK]") return "fail 2"
|
||||
if (A.bar3() != "3, 56: []") return "fail 3"
|
||||
if (A.bar4() != "4, 56: [OK]") return "fail 4"
|
||||
if (A.bar5() != "5, 1491: [OK]") return "fail 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// FILE: A.java
|
||||
|
||||
public class A {
|
||||
public static String bar1() {
|
||||
return TestKt.foo(1);
|
||||
}
|
||||
|
||||
public static String bar2() {
|
||||
return TestKt.foo(2, "OK");
|
||||
}
|
||||
|
||||
public static String bar3() {
|
||||
return TestKt.foo2(3);
|
||||
}
|
||||
|
||||
public static String bar4() {
|
||||
return TestKt.foo2(4, "OK");
|
||||
}
|
||||
|
||||
public static String bar5() {
|
||||
return TestKt.foo2(5, 1491, "OK");
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
class C {
|
||||
@kotlin.jvm.JvmOverloads public fun foo(o: String, k: String = "K"): String {
|
||||
return o + k
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val c = C()
|
||||
val m = c.javaClass.getMethod("foo", String::class.java)
|
||||
return m.invoke(c, "O") as String
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
class C @kotlin.jvm.JvmOverloads constructor(s1: String, s2: String = "K") {
|
||||
public val status: String = s1 + s2
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val c = (C::class.java.getConstructor(String::class.java).newInstance("O"))
|
||||
return c.status
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
private data class C(val status: String = "OK")
|
||||
|
||||
fun box(): String {
|
||||
val c = (C::class.java.getConstructor().newInstance())
|
||||
return c.status
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
class C(val i: Int) {
|
||||
var status = "fail"
|
||||
|
||||
@kotlin.jvm.JvmOverloads constructor(o: String, k: String = "K"): this(-1) {
|
||||
status = o + k
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val c = (C::class.java.getConstructor(String::class.java).newInstance("O"))
|
||||
return c.status
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
class C {
|
||||
@kotlin.jvm.JvmOverloads public fun foo(s: String = "OK"): String {
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val c = C()
|
||||
val m = c.javaClass.getMethod("foo")
|
||||
return m.invoke(c) as String
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_RUNTIME
|
||||
// FILE: Test.java
|
||||
|
||||
public class Test {
|
||||
public static String invokeMethodWithOverloads() {
|
||||
C c = new C();
|
||||
return c.foo();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: simple.kt
|
||||
|
||||
class C {
|
||||
@kotlin.jvm.JvmOverloads public fun foo(o: String = "O", k: String = "K"): String = o + k
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Test.invokeMethodWithOverloads()
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
class C {
|
||||
@JvmOverloads
|
||||
fun foo(bar: Int = 0, vararg status: String) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val c = C()
|
||||
val m = c.javaClass.getMethod("foo", Array<String>::class.java)
|
||||
return if (m.isVarArgs) "OK" else "fail"
|
||||
}
|
||||
Reference in New Issue
Block a user