Black box update

This commit is contained in:
Mikhael Bogdanov
2017-03-17 10:18:07 +01:00
committed by Dmitry Jemerov
parent 40574d31ac
commit 496a21254b
14 changed files with 156 additions and 94 deletions
@@ -25,8 +25,10 @@ fun box(): String {
// Java class without nested classes
assertEquals(emptyList<String>(), nestedNames(Error::class))
// Java interface with nested classes
assertEquals(listOf("Entry"), nestedNames(java.util.Map::class))
// Java class with nested classes
assertEquals(listOf("State", "UncaughtExceptionHandler"), nestedNames(Thread::class))
assertEquals(listOf("SimpleEntry", "SimpleImmutableEntry"), nestedNames(java.util.AbstractMap::class))
// Built-ins
assertEquals(emptyList<String>(), nestedNames(Array<Any>::class))
@@ -1,10 +1,12 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// IGNORE_BACKEND: JS, NATIVE, JVM
// WITH_REFLECT
// FULL_JDK
// See KT-11258 Incorrect resolution sequence for Java field
//SHOULD BE enabled after KT-16616 fix
import java.util.*
fun box(): String {
+5 -5
View File
@@ -16,10 +16,10 @@ open class TypeLiteral<T> {
inline fun <reified T> typeLiteral(): TypeLiteral<T> = object : TypeLiteral<T>() {}
fun box(): String {
assertEquals("class java.lang.String", typeLiteral<String>().type.toString())
assertEquals("java.lang.String", (typeLiteral<String>().type as Class<*>).canonicalName)
assertEquals("java.util.List<?>", typeLiteral<List<*>>().type.toString())
assertEquals("java.lang.String[]", typeLiteral<Array<String>>().type.toString())
assertEquals("java.lang.Integer[]", typeLiteral<Array<Int>>().type.toString())
assertEquals("java.lang.String[][]", typeLiteral<Array<Array<String>>>().type.toString())
assertEquals("java.lang.String[]", (typeLiteral<Array<String>>().type as Class<*>).canonicalName)
assertEquals("java.lang.Integer[]", (typeLiteral<Array<Int>>().type as Class<*>).canonicalName)
assertEquals("java.lang.String[][]", (typeLiteral<Array<Array<String>>>().type as Class<*>).canonicalName)
return "OK"
}
}
@@ -0,0 +1,26 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_REFLECT
// FULL_JDK
// See KT-11258 Incorrect resolution sequence for Java field
//SHOULD BE deleted after KT-16616 fix
import java.util.*
fun box(): String {
listOf(
ArrayList::class,
LinkedList::class,
AbstractList::class,
HashSet::class,
TreeSet::class,
HashMap::class,
TreeMap::class,
AbstractMap::class,
AbstractMap.SimpleEntry::class
).map {
it.members.map(Any::toString)
}
return "OK"
}
@@ -0,0 +1,53 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// FULL_JDK
// WITH_RUNTIME
interface ImmutableCollection<out E> : Collection<E> {
fun add(element: @UnsafeVariance E): ImmutableCollection<E>
fun addAll(elements: Collection<@UnsafeVariance E>): ImmutableCollection<E>
fun remove(element: @UnsafeVariance E): ImmutableCollection<E>
}
class ImmutableCollectionmpl<E> : ImmutableCollection<E> {
override val size: Int
get() = throw UnsupportedOperationException()
override fun contains(element: E): Boolean {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun containsAll(elements: Collection<E>): Boolean {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun isEmpty(): Boolean {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun iterator(): Iterator<E> {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun add(element: E): ImmutableCollection<E> = this
override fun addAll(elements: Collection<E>): ImmutableCollection<E> = this
override fun remove(element: E): ImmutableCollection<E> = this
}
fun box(): String {
val c = ImmutableCollectionmpl<String>()
if (c.remove("") !== c) return "fail 1"
if (c.add("") !== c) return "fail 2"
if (c.addAll(java.util.ArrayList()) !== c) return "fail 3"
val method = c.javaClass.methods.single { it.name == "remove" && it.returnType == Boolean::class.javaPrimitiveType }
try {
method.invoke(c, "")
return "fail 4"
} catch (e: java.lang.reflect.InvocationTargetException) {
if (e.cause!!.message != "Operation is not supported for read-only collection") return "fail 5: ${e.cause!!.message}"
}
return "OK"
}
@@ -0,0 +1,22 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_REFLECT
// 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 {
assertEquals(listOf(null, "arg0", "arg1"), J::foo.parameters.map { it.name })
assertEquals(listOf("arg0"), J::bar.parameters.map { it.name })
return "OK"
}
@@ -1,33 +0,0 @@
@kotlin.Metadata
public interface ImmutableCollection {
public abstract @org.jetbrains.annotations.NotNull method add(p0: java.lang.Object): ImmutableCollection
public abstract @org.jetbrains.annotations.NotNull method addAll(@org.jetbrains.annotations.NotNull p0: java.util.Collection): ImmutableCollection
public abstract @org.jetbrains.annotations.NotNull method remove(p0: java.lang.Object): ImmutableCollection
}
@kotlin.Metadata
public final class ImmutableCollectionmpl {
public method <init>(): void
public @org.jetbrains.annotations.NotNull method add(p0: java.lang.Object): ImmutableCollection
public method add(p0: java.lang.Object): boolean
public @org.jetbrains.annotations.NotNull method addAll(@org.jetbrains.annotations.NotNull p0: java.util.Collection): ImmutableCollection
public method addAll(p0: java.util.Collection): boolean
public method clear(): void
public method contains(p0: java.lang.Object): boolean
public method containsAll(@org.jetbrains.annotations.NotNull p0: java.util.Collection): boolean
public method getSize(): int
public method isEmpty(): boolean
public @org.jetbrains.annotations.NotNull method iterator(): java.util.Iterator
public @org.jetbrains.annotations.NotNull method remove(p0: java.lang.Object): ImmutableCollection
public method remove(p0: java.lang.Object): boolean
public method removeAll(p0: java.util.Collection): boolean
public method retainAll(p0: java.util.Collection): boolean
public final method size(): int
public method toArray(): java.lang.Object[]
public method toArray(p0: java.lang.Object[]): java.lang.Object[]
}
@kotlin.Metadata
public final class ImmutableRemoveKt {
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
}
@@ -1,4 +0,0 @@
@kotlin.Metadata
public final class KKt {
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
}
@@ -1379,12 +1379,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
doTest(fileName);
}
@TestMetadata("immutableRemove.kt")
public void testImmutableRemove() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/builtinStubMethods/immutableRemove.kt");
doTest(fileName);
}
@TestMetadata("implementationInTrait.kt")
public void testImplementationInTrait() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/builtinStubMethods/implementationInTrait.kt");
@@ -14932,12 +14926,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
doTest(fileName);
}
@TestMetadata("javaParametersHaveNoNames.kt")
public void testJavaParametersHaveNoNames() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/parameters/javaParametersHaveNoNames.kt");
doTest(fileName);
}
@TestMetadata("kinds.kt")
public void testKinds() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/parameters/kinds.kt");
@@ -15283,7 +15271,13 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
@TestMetadata("getMembersOfStandardJavaClasses.kt")
public void testGetMembersOfStandardJavaClasses() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/specialBuiltIns/getMembersOfStandardJavaClasses.kt");
doTest(fileName);
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
}
@@ -138,6 +138,21 @@ public class BlackBoxWithJava8CodegenTestGenerated extends AbstractBlackBoxCodeg
doTest(fileName);
}
@TestMetadata("compiler/testData/codegen/java8/box/builtinStubMethods")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class BuiltinStubMethods extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInBuiltinStubMethods() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/java8/box/builtinStubMethods"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("immutableRemove.kt")
public void testImmutableRemove() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/builtinStubMethods/immutableRemove.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/java8/box/delegationBy")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -592,5 +607,20 @@ public class BlackBoxWithJava8CodegenTestGenerated extends AbstractBlackBoxCodeg
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/reflection/synthesizedParameterNames.kt");
doTest(fileName);
}
@TestMetadata("compiler/testData/codegen/java8/box/reflection/parameters")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Parameters extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInParameters() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/java8/box/reflection/parameters"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("javaParametersHaveDefaultNames.kt")
public void testJavaParametersHaveDefaultNames() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/reflection/parameters/javaParametersHaveDefaultNames.kt");
doTest(fileName);
}
}
}
}
@@ -1379,12 +1379,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("immutableRemove.kt")
public void testImmutableRemove() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/builtinStubMethods/immutableRemove.kt");
doTest(fileName);
}
@TestMetadata("implementationInTrait.kt")
public void testImplementationInTrait() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/builtinStubMethods/implementationInTrait.kt");
@@ -14932,12 +14926,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("javaParametersHaveNoNames.kt")
public void testJavaParametersHaveNoNames() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/parameters/javaParametersHaveNoNames.kt");
doTest(fileName);
}
@TestMetadata("kinds.kt")
public void testKinds() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/parameters/kinds.kt");
@@ -15283,7 +15271,13 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
@TestMetadata("getMembersOfStandardJavaClasses.kt")
public void testGetMembersOfStandardJavaClasses() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/specialBuiltIns/getMembersOfStandardJavaClasses.kt");
doTest(fileName);
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
}
@@ -1613,18 +1613,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
doTest(fileName);
}
@TestMetadata("immutableRemove.kt")
public void testImmutableRemove() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/builtinStubMethods/immutableRemove.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
@TestMetadata("implementationInTrait.kt")
public void testImplementationInTrait() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/builtinStubMethods/implementationInTrait.kt");
@@ -18150,18 +18138,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
@TestMetadata("javaParametersHaveNoNames.kt")
public void testJavaParametersHaveNoNames() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/parameters/javaParametersHaveNoNames.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
@TestMetadata("kinds.kt")
public void testKinds() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/parameters/kinds.kt");