From 3dff225b98302631a46d43b1fa4024023bf29df7 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Fri, 5 Feb 2021 14:12:38 +0100 Subject: [PATCH] Aligh test data with JDK 15 reflection output --- .../box/annotations/syntheticMethodForProperty.kt | 2 +- .../annotations/useTypeParameterAnnotationFromJava.kt | 6 +++--- .../box/annotations/useTypeUseAnnotationFromJava.kt | 10 ++++++---- .../annotations/classLiteralWithVoidDefault.kt | 4 ++-- .../codegen/box/reflection/builtins/enumNameOrdinal.kt | 3 ++- .../codegen/box/reflection/genericSignature/kt11121.kt | 6 ++++-- 6 files changed, 18 insertions(+), 13 deletions(-) diff --git a/compiler/testData/codegen/box/annotations/syntheticMethodForProperty.kt b/compiler/testData/codegen/box/annotations/syntheticMethodForProperty.kt index e61db0ef6ba..925a11aee8c 100644 --- a/compiler/testData/codegen/box/annotations/syntheticMethodForProperty.kt +++ b/compiler/testData/codegen/box/annotations/syntheticMethodForProperty.kt @@ -32,7 +32,7 @@ fun check(clazz: Class<*>, expected: Boolean = true) { assertTrue(Modifier.isStatic(method.modifiers)) assertTrue(Modifier.isPublic(method.modifiers)) val str = method.declaredAnnotations.single().toString() - assertTrue("@test.Anno\\(value=\"?OK\"?\\)".toRegex().matches(str), str) + assertTrue("@test.Anno\\((value=)?\"?OK\"?\\)".toRegex().matches(str), str) return } } diff --git a/compiler/testData/codegen/box/annotations/useTypeParameterAnnotationFromJava.kt b/compiler/testData/codegen/box/annotations/useTypeParameterAnnotationFromJava.kt index 1f656d25d54..9866f803646 100644 --- a/compiler/testData/codegen/box/annotations/useTypeParameterAnnotationFromJava.kt +++ b/compiler/testData/codegen/box/annotations/useTypeParameterAnnotationFromJava.kt @@ -9,14 +9,14 @@ public class A<@Anno(1) T> {} // FILE: Anno.kt -import kotlin.test.assertEquals +import kotlin.test.assertTrue @Target(AnnotationTarget.TYPE_PARAMETER) annotation class Anno(val value: Int = 0) fun box(): String { val typeParameter = A::class.java.typeParameters.single() - assertEquals("[@Anno(value=1)]", typeParameter.annotations.toList().toString()) - + val parametertoString = typeParameter.annotations.toList().toString() + assertTrue("\\[@Anno\\((value=)?1\\)\\]".toRegex().matches(parametertoString), parametertoString) return "OK" } diff --git a/compiler/testData/codegen/box/annotations/useTypeUseAnnotationFromJava.kt b/compiler/testData/codegen/box/annotations/useTypeUseAnnotationFromJava.kt index 800fc34202e..969b298b622 100644 --- a/compiler/testData/codegen/box/annotations/useTypeUseAnnotationFromJava.kt +++ b/compiler/testData/codegen/box/annotations/useTypeUseAnnotationFromJava.kt @@ -14,17 +14,19 @@ public class A { // FILE: Anno.kt import java.lang.reflect.AnnotatedParameterizedType -import kotlin.test.assertEquals +import kotlin.test.assertTrue @Target(AnnotationTarget.TYPE) annotation class Anno(val value: Int = 0) fun box(): String { val method = A::class.java.declaredMethods.single() - assertEquals("[@Anno(value=1)]", method.annotatedReturnType.annotations.toList().toString()) - + val methodToString = method.annotatedReturnType.annotations.toList().toString() + assertTrue("\\[@Anno\\((value=)?1\\)\\]".toRegex().matches(methodToString), methodToString) + val parameterType = method.parameters.single().annotatedType as AnnotatedParameterizedType - assertEquals("[@Anno(value=2)]", parameterType.annotatedActualTypeArguments.single().annotations.toList().toString()) + val parameterToString = parameterType.annotatedActualTypeArguments.single().annotations.toList().toString() + assertTrue("\\[@Anno\\((value=)?2\\)\\]".toRegex().matches(parameterToString), parameterToString) return "OK" } diff --git a/compiler/testData/codegen/box/reflection/annotations/classLiteralWithVoidDefault.kt b/compiler/testData/codegen/box/reflection/annotations/classLiteralWithVoidDefault.kt index f3e631af95d..f918b969953 100644 --- a/compiler/testData/codegen/box/reflection/annotations/classLiteralWithVoidDefault.kt +++ b/compiler/testData/codegen/box/reflection/annotations/classLiteralWithVoidDefault.kt @@ -23,7 +23,7 @@ class C { } fun box(): String { - assertTrue("\\[@Anno\\(value=void(\\.class)?\\)\\]".toRegex().matches(C::f1.annotations.toString())) - assertTrue("\\[@Anno\\(value=(class )?java.lang.Void(\\.class)?\\)\\]".toRegex().matches(C::f2.annotations.toString())) + assertTrue("\\[@Anno\\((value=)?void(\\.class)?\\)\\]".toRegex().matches(C::f1.annotations.toString())) + assertTrue("\\[@Anno\\((value=)?(class )?java.lang.Void(\\.class)?\\)\\]".toRegex().matches(C::f2.annotations.toString())) return "OK" } diff --git a/compiler/testData/codegen/box/reflection/builtins/enumNameOrdinal.kt b/compiler/testData/codegen/box/reflection/builtins/enumNameOrdinal.kt index b9e1340b5dc..e53e8fd6cef 100644 --- a/compiler/testData/codegen/box/reflection/builtins/enumNameOrdinal.kt +++ b/compiler/testData/codegen/box/reflection/builtins/enumNameOrdinal.kt @@ -3,11 +3,12 @@ // WITH_REFLECT import kotlin.test.assertEquals +import kotlin.test.assertTrue enum class E { X, Y, Z } fun box(): String { - assertEquals(11, E::class.members.size) + assertTrue(E::class.members.size in 11..12, "" + E::class.members.size) assertEquals("Y", E::name.call(E.Y)) assertEquals(2, E::ordinal.call(E.Z)) return "OK" diff --git a/compiler/testData/codegen/box/reflection/genericSignature/kt11121.kt b/compiler/testData/codegen/box/reflection/genericSignature/kt11121.kt index 3d12e88a93c..4c677b3f486 100644 --- a/compiler/testData/codegen/box/reflection/genericSignature/kt11121.kt +++ b/compiler/testData/codegen/box/reflection/genericSignature/kt11121.kt @@ -19,10 +19,12 @@ interface A> { fun box(): String { val defaultImpls = Class.forName("test.A\$DefaultImpls") val declaredMethod = defaultImpls.getDeclaredMethod("p", A::class.java, Any::class.java) - if (declaredMethod.toGenericString() != "public static T test.A\$DefaultImpls.p(test.A,T)") return "fail 1: ${declaredMethod.toGenericString()}" + if (declaredMethod.toGenericString() != "public static T test.A\$DefaultImpls.p(test.A,T)" && + declaredMethod.toGenericString() != "public static ,T,L> T test.A\$DefaultImpls.p(test.A,T)") return "fail 1: ${declaredMethod.toGenericString()}" val declaredProperty = defaultImpls.getDeclaredMethod("getZ", A::class.java, Any::class.java) - if (declaredProperty.toGenericString() != "public static T test.A\$DefaultImpls.getZ(test.A,T)") return "fail 2: ${declaredProperty.toGenericString()}" + if (declaredProperty.toGenericString() != "public static T test.A\$DefaultImpls.getZ(test.A,T)" && + declaredProperty.toGenericString() != "public static ,T> T test.A\$DefaultImpls.getZ(test.A,T)") return "fail 2: ${declaredProperty.toGenericString()}" return "OK" }