mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-11 08:31:30 +00:00
Migrate boxWithJava tests to multi-file framework
This commit is contained in:
@@ -1,3 +1,19 @@
|
||||
// FILE: J.java
|
||||
|
||||
@Anno("J")
|
||||
public class J {
|
||||
@Anno("foo")
|
||||
public static int foo = 42;
|
||||
|
||||
@Anno("bar")
|
||||
public static void bar() {}
|
||||
|
||||
@Anno("constructor")
|
||||
public J() {}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
annotation class Anno(val value: String)
|
||||
@@ -1,11 +0,0 @@
|
||||
@Anno("J")
|
||||
public class J {
|
||||
@Anno("foo")
|
||||
public static int foo = 42;
|
||||
|
||||
@Anno("bar")
|
||||
public static void bar() {}
|
||||
|
||||
@Anno("constructor")
|
||||
public J() {}
|
||||
}
|
||||
@@ -1,3 +1,19 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
private final int param;
|
||||
|
||||
public J(int param) {
|
||||
this.param = param;
|
||||
}
|
||||
|
||||
public String foo(int[] arr, Object[] arr2, Integer y) {
|
||||
return "" + param + arr[0] + arr2[0] + y;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.reflect.jvm.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
public class J {
|
||||
private final int param;
|
||||
|
||||
public J(int param) {
|
||||
this.param = param;
|
||||
}
|
||||
|
||||
public String foo(int[] arr, Object[] arr2, Integer y) {
|
||||
return "" + param + arr[0] + arr2[0] + y;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,19 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
private final String result;
|
||||
|
||||
private J(String result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
private String getResult() {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.reflect.*
|
||||
import kotlin.reflect.jvm.*
|
||||
import kotlin.test.*
|
||||
@@ -1,11 +0,0 @@
|
||||
public class J {
|
||||
private final String result;
|
||||
|
||||
private J(String result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
private String getResult() {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,13 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
public static String foo(int x, int[] arr, Object[] arr2) {
|
||||
return "" + x + arr[0] + arr2[0];
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.reflect.jvm.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
public class J {
|
||||
public static String foo(int x, int[] arr, Object[] arr2) {
|
||||
return "" + x + arr[0] + arr2[0];
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,14 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
public void publicMemberJ() {}
|
||||
private void privateMemberJ() {}
|
||||
public static void publicStaticJ() {}
|
||||
private static void privateStaticJ() {}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.reflect.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
public class J {
|
||||
public void publicMemberJ() {}
|
||||
private void privateMemberJ() {}
|
||||
public static void publicStaticJ() {}
|
||||
private static void privateStaticJ() {}
|
||||
}
|
||||
@@ -1,3 +1,14 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
public String publicMemberJ;
|
||||
private String privateMemberJ;
|
||||
public static String publicStaticJ;
|
||||
private static String privateStaticJ;
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.reflect.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
public class J {
|
||||
public String publicMemberJ;
|
||||
private String privateMemberJ;
|
||||
public static String publicStaticJ;
|
||||
private static String privateStaticJ;
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
// FILE: J.java
|
||||
|
||||
import kotlin.jvm.functions.Function2;
|
||||
import kotlin.reflect.KFunction;
|
||||
|
||||
@@ -8,3 +10,19 @@ public class J {
|
||||
return (String) result;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
class K {
|
||||
fun reverse(s: String): String {
|
||||
return s.reversed()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getRef() = K::reverse
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return J.go()
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
class K {
|
||||
fun reverse(s: String): String {
|
||||
return s.reversed()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getRef() = K::reverse
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return J.go()
|
||||
}
|
||||
@@ -1,3 +1,18 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
public J() {
|
||||
}
|
||||
|
||||
public void member(String s) {
|
||||
}
|
||||
|
||||
public static void staticMethod(int x) {
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.reflect.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
public class J {
|
||||
public J() {
|
||||
}
|
||||
|
||||
public void member(String s) {
|
||||
}
|
||||
|
||||
public static void staticMethod(int x) {
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
// FILE: J.java
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class J {
|
||||
@@ -23,3 +25,23 @@ public class J {
|
||||
List<? extends Number> l, List<? super Cloneable> m
|
||||
) {}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.reflect.KFunction
|
||||
|
||||
// Initiate descriptor computation in reflection to ensure that nothing fails
|
||||
fun test(f: KFunction<*>) {
|
||||
f.parameters
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
test(J::simple)
|
||||
test(J::objectTypes)
|
||||
test(J::primitives)
|
||||
test(J::primitiveArrays)
|
||||
test(J::multiDimensionalArrays)
|
||||
test(J::wildcards)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import kotlin.reflect.KFunction
|
||||
|
||||
// Initiate descriptor computation in reflection to ensure that nothing fails
|
||||
fun test(f: KFunction<*>) {
|
||||
f.parameters
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
test(J::simple)
|
||||
test(J::objectTypes)
|
||||
test(J::primitives)
|
||||
test(J::primitiveArrays)
|
||||
test(J::multiDimensionalArrays)
|
||||
test(J::wildcards)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
public String result = null;
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
class K : J()
|
||||
|
||||
fun box(): String {
|
||||
@@ -1,3 +0,0 @@
|
||||
public class J {
|
||||
public String result = null;
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
static String x;
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun box(): String {
|
||||
@@ -1,3 +0,0 @@
|
||||
public class J {
|
||||
static String x;
|
||||
}
|
||||
@@ -1,3 +1,10 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J extends K {
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.reflect.*
|
||||
import kotlin.reflect.jvm.*
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
public class J extends K {
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
private String result = "Fail";
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.reflect.*
|
||||
import kotlin.reflect.jvm.*
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
public class J {
|
||||
private String result = "Fail";
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
private static String result = "Fail";
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.reflect.*
|
||||
import kotlin.reflect.jvm.*
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
public class J {
|
||||
private static String result = "Fail";
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
public class Inner {}
|
||||
|
||||
@@ -8,3 +10,13 @@ public class J {
|
||||
// This anonymous class should not appear in 'nestedClasses'
|
||||
private final Object o = new Object() {};
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(listOf("Inner", "Nested", "PrivateNested"), J::class.nestedClasses.map { it.simpleName!! }.sorted())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(listOf("Inner", "Nested", "PrivateNested"), J::class.nestedClasses.map { it.simpleName!! }.sorted())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
public String foo = "";
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class K : J() {
|
||||
@@ -1,3 +0,0 @@
|
||||
public class J {
|
||||
public String foo = "";
|
||||
}
|
||||
@@ -1,3 +1,13 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
void foo(String s, int i) {}
|
||||
|
||||
static void bar(J j) {}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun box(): String {
|
||||
@@ -1,5 +0,0 @@
|
||||
public class J {
|
||||
void foo(String s, int i) {}
|
||||
|
||||
static void bar(J j) {}
|
||||
}
|
||||
@@ -1,3 +1,13 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
public static String foo() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.test.assertNotEquals
|
||||
|
||||
fun nonNullString(): String = ""
|
||||
@@ -1,5 +0,0 @@
|
||||
public class J {
|
||||
public static String foo() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,19 @@
|
||||
// FILE: J.java
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class J {
|
||||
public static String string() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public static List<Object> list() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun box(): String {
|
||||
@@ -1,11 +0,0 @@
|
||||
import java.util.List;
|
||||
|
||||
public class J {
|
||||
public static String string() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public static List<Object> list() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J extends K {
|
||||
public final int value = 42;
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
open class K
|
||||
|
||||
fun box(): String {
|
||||
@@ -1,3 +0,0 @@
|
||||
public class J extends K {
|
||||
public final int value = 42;
|
||||
}
|
||||
Reference in New Issue
Block a user