[KLIB tool] Migrate 'dump-metadata' tests to K/N test infra

This commit is contained in:
Dmitriy Dolovov
2023-10-23 22:18:21 +02:00
committed by Space Team
parent 57e004e2b0
commit aa9b901926
63 changed files with 570 additions and 730 deletions
@@ -0,0 +1,26 @@
package custom.pkg
annotation class A
class Foo {
val simple = 0
private val privateSimple = 0
protected val protectedSimple = 0
var privateSetter = 0
private set
@A val annotated = 0
val annotatedGetter = 0
@A get
var annotatedSetter = 0
@A set
var annotatedAccessors = 0
@A set
@A get
}
@@ -0,0 +1,17 @@
package custom.pkg {
annotation class A constructor() : Annotation
class Foo constructor() {
@A val annotated: Int = 0
var annotatedAccessors: Int
@A get
@A set
val annotatedGetter: Int = 0
@A get
var annotatedSetter: Int
@A set
var privateSetter: Int
private set
protected val protectedSimple: Int = 0
val simple: Int = 0
}
}
@@ -0,0 +1,52 @@
class A {
fun aFun() {}
val aVal = 0
var aVar = ""
inner class B {
fun bFun() {}
val bVal = 0
var bVar = ""
inner class C {
fun cFun() {}
val cVal = 0
var cVar = ""
}
private inner class D {
fun dFun() {}
val dVal = 0
var dVar = ""
}
}
class E {
fun eFun() {}
val eVal = 0
var eVar = ""
}
}
data class F(val fVal: Int, var fVar: String) {
fun fFun() {}
}
interface Interface {
fun iFun()
val iVal: Int
var iVar: String
}
open class OpenImpl: Interface {
override fun iFun() {}
override val iVal = 0
override var iVar = ""
}
class FinalImpl: OpenImpl() {
override fun iFun() {}
override val iVal = 0
override var iVar = ""
}
@@ -0,0 +1,48 @@
package <root> {
class A constructor() {
val aVal: Int = 0
var aVar: String
fun aFun()
inner class B constructor() {
val bVal: Int = 0
var bVar: String
fun bFun()
inner class C constructor() {
val cVal: Int = 0
var cVar: String
fun cFun()
}
}
class E constructor() {
val eVal: Int = 0
var eVar: String
fun eFun()
}
}
data class F constructor(fVal: Int, fVar: String) {
val fVal: Int
var fVar: String
operator fun component1(): Int
operator fun component2(): String
fun copy(fVal: Int = ..., fVar: String = ...): F
override fun equals(other: Any?): Boolean
fun fFun()
override fun hashCode(): Int
override fun toString(): String
}
class FinalImpl constructor() : OpenImpl {
override val iVal: Int = 0
override var iVar: String
override fun iFun()
}
interface Interface {
val iVal: Int
var iVar: String
fun iFun()
}
open class OpenImpl constructor() : Interface {
override val iVal: Int = 0
override var iVar: String
override fun iFun()
}
}
@@ -0,0 +1,27 @@
@file:Suppress("UNUSED_PARAMETER")
annotation class A
class Foo(x: Int) {
constructor(): this(0)
constructor(x: Double): this(x.toInt())
constructor(x: Double, y: Int): this(y)
private constructor(x: Long): this(0)
protected constructor(x: String): this(0)
@A constructor(x: Foo) : this(0)
}
class Bar @A constructor(x: Int)
class Baz private constructor(x: Int)
class Qux protected constructor(x: Int)
class Typed<T>(x: Int) {
constructor(): this(0)
constructor(x: Double): this(x.toInt())
constructor(x: Double, y: Int): this(y)
private constructor(x: Long): this(0)
protected constructor(x: String): this(0)
@A constructor(x: Foo) : this(0)
}
@@ -0,0 +1,20 @@
package <root> {
annotation class A constructor() : Annotation
class Bar @A constructor(x: Int)
class Baz private constructor(x: Int)
class Foo constructor(x: Int) {
constructor()
constructor(x: Double)
constructor(x: Double, y: Int)
protected constructor(x: String)
@A constructor(x: Foo)
}
class Qux protected constructor(x: Int)
class Typed<T> constructor(x: Int) {
constructor()
constructor(x: Double)
constructor(x: Double, y: Int)
protected constructor(x: String)
@A constructor(x: Foo)
}
}
+11
View File
@@ -0,0 +1,11 @@
enum class E(val x: Int = 0) {
A,
B,
C(1) {
override fun enumFun() = 42
};
open fun enumFun(): Int = 0
val enumVal = 0
var enumVar = ""
}
@@ -0,0 +1,11 @@
package <root> {
enum class E private constructor(x: Int = ...) : Enum<E> {
enum entry A
enum entry B
enum entry C
val enumVal: Int = 0
var enumVar: String
val x: Int
open fun enumFun(): Int
}
}
@@ -0,0 +1,8 @@
class Foo {
fun f1() {}
infix fun f2(x: Int) {}
suspend fun f3() {}
operator fun plus(x: Int) {}
tailrec fun f4() {}
fun f5(vararg x: Int) {}
}
@@ -0,0 +1,10 @@
package <root> {
class Foo constructor() {
fun f1()
infix fun f2(x: Int)
suspend fun f3()
tailrec fun f4()
fun f5(vararg x: Int)
operator fun plus(x: Int)
}
}
@@ -0,0 +1,20 @@
interface Interface {
fun interfaceFun()
}
abstract class AbstractClass: Interface {
override fun interfaceFun() {}
abstract fun abstractFun()
}
open class OpenClass: AbstractClass() {
override fun abstractFun() {}
open fun openFun1() {}
open fun openFun2() {}
fun finalFun() {}
}
class FinalClass: OpenClass() {
override fun openFun1() {}
final override fun openFun2() {}
}
@@ -0,0 +1,19 @@
package <root> {
abstract class AbstractClass constructor() : Interface {
abstract fun abstractFun()
override fun interfaceFun()
}
class FinalClass constructor() : OpenClass {
override fun openFun1()
final override fun openFun2()
}
interface Interface {
fun interfaceFun()
}
open class OpenClass constructor() : AbstractClass {
override fun abstractFun()
fun finalFun()
open fun openFun1()
open fun openFun2()
}
}
@@ -0,0 +1,21 @@
// B.Companion and B.C are serialized in a different order in K1 and K2
// MUTED_WHEN: K1
object A {
fun a() {}
}
class B {
companion object {
fun b() {}
}
object C {
fun c() {}
}
}
class D {
companion object E {
fun e() {}
}
}
@@ -0,0 +1,18 @@
package <root> {
object A {
fun a()
}
class B constructor() {
companion object {
fun b()
}
object C {
fun c()
}
}
class D constructor() {
companion object E {
fun e()
}
}
}
@@ -0,0 +1,33 @@
@file:Suppress("UNUSED_PARAMETER")
annotation class A
annotation class B
class Foo
fun f1(x: Foo): Unit {}
fun f2(x: Foo, y: Foo) = 0
// inline
inline fun i1(block: () -> Foo) {}
inline fun i2(noinline block: () -> Foo) {}
inline fun i3(crossinline block: () -> Foo) {}
// callable args
fun i4(block: (Foo) -> Int) {}
fun i5(block: (Foo, Foo) -> Int) {}
fun i6(block: Foo.() -> Int) {}
fun i7(block: Foo.(Foo) -> Int) {}
// type parameters
fun <T> t1(x: Foo) {}
fun <T> t2(x: T) {}
fun <T, F> t3(x: T, y: F) {}
inline fun <reified T> t4(x: T) {}
fun <T: Number> t5(x: T) {}
// extension
fun Foo.e() {}
// annotations
@A @B fun a() {}
@@ -0,0 +1,21 @@
package <root> {
annotation class A constructor() : Annotation
annotation class B constructor() : Annotation
class Foo constructor()
@A @B fun a()
fun Foo.e()
fun f1(x: Foo)
fun f2(x: Foo, y: Foo): Int
inline fun i1(block: () -> Foo)
inline fun i2(noinline block: () -> Foo)
inline fun i3(crossinline block: () -> Foo)
fun i4(block: (Foo) -> Int)
fun i5(block: (Foo, Foo) -> Int)
fun i6(block: Foo.() -> Int)
fun i7(block: Foo.(Foo) -> Int)
fun <T> t1(x: Foo)
fun <T> t2(x: T)
fun <T, F> t3(x: T, y: F)
inline fun <reified T> t4(x: T)
fun <T : Number> t5(x: T)
}
@@ -0,0 +1,12 @@
@file:Suppress("UNUSED_PARAMETER")
package custom.pkg
typealias MyTransformer = (String) -> Int
// top-level properties
val v1 = 1
val v2 = "hello"
val v3: (String) -> Int = { it.length }
val v4: MyTransformer = v3
@@ -0,0 +1,7 @@
package custom.pkg {
typealias MyTransformer = (String) -> Int
val v1: Int = 1
val v2: String = "hello"
val v3: (String) -> Int
val v4: MyTransformer /* = (String) -> Int */
}
@@ -0,0 +1,10 @@
@file:Suppress("UNUSED_PARAMETER")
typealias MyTransformer = (String) -> Int
// top-level properties
val v1 = 1
val v2 = "hello"
val v3: (String) -> Int = { it.length }
val v4: MyTransformer = v3
@@ -0,0 +1,7 @@
package <root> {
typealias MyTransformer = (String) -> Int
val v1: Int = 1
val v2: String = "hello"
val v3: (String) -> Int
val v4: MyTransformer /* = (String) -> Int */
}
@@ -0,0 +1,15 @@
@file:Suppress("UNUSED_PARAMETER")
package custom.pkg
class Foo
typealias MyTransformer = (String) -> Int
// top-level properties
val v1 = 1
val v2 = "hello"
val v3: (String) -> Int = { it.length }
val v4: MyTransformer = v3
object Bar
@@ -0,0 +1,9 @@
package custom.pkg {
object Bar
class Foo constructor()
typealias MyTransformer = (String) -> Int
val v1: Int = 1
val v2: String = "hello"
val v3: (String) -> Int
val v4: MyTransformer /* = (String) -> Int */
}
@@ -0,0 +1,13 @@
@file:Suppress("UNUSED_PARAMETER")
class Foo
typealias MyTransformer = (String) -> Int
// top-level properties
val v1 = 1
val v2 = "hello"
val v3: (String) -> Int = { it.length }
val v4: MyTransformer = v3
object Bar
@@ -0,0 +1,9 @@
package <root> {
object Bar
class Foo constructor()
typealias MyTransformer = (String) -> Int
val v1: Int = 1
val v2: String = "hello"
val v3: (String) -> Int
val v4: MyTransformer /* = (String) -> Int */
}
@@ -1,3 +1,4 @@
package test {
annotation class AnnoBackingField constructor() : Annotation
annotation class AnnoClass constructor() : Annotation
@Target(allowedTargets = {AnnotationTarget.TYPE_PARAMETER}) annotation class AnnoClassTypeParameter constructor() : Annotation
@@ -28,3 +29,4 @@
@AnnoPropertyExtensionReceiver val Foo.extProp: Int
@AnnoFunction fun @receiver:AnnoFunctionExtensionReceiver Foo.extfun(@AnnoFunctionParam x: Int)
fun <@AnnoFunctionTypeParameter T> f(x: B<@AnnoClassUsageTypeParameter Int>)
}
@@ -1,3 +1,4 @@
package test {
@Retention(value = AnnotationRetention.SOURCE) annotation class AnnoBackingField constructor() : Annotation
@Retention(value = AnnotationRetention.SOURCE) annotation class AnnoClass constructor() : Annotation
@Retention(value = AnnotationRetention.SOURCE) annotation class AnnoConstructor constructor() : Annotation
@@ -20,3 +21,4 @@
}
val Foo.extProp: Int
fun Foo.extfun(x: Int)
}
@@ -1,3 +1,4 @@
package test {
annotation class Anno constructor(value: String = ..., x: Int = ...) : Annotation {
val value: String
val x: Int
@@ -8,4 +9,5 @@
enum entry Entry2
@Anno(value = "3") @Bnno enum entry Entry3
@Anno(value = "4", x = 4) enum entry Entry4
}
}
}
@@ -1,3 +1,4 @@
package test {
annotation class AnnotationArray constructor(annotationArray: Array<JustAnnotation>) : Annotation {
val annotationArray: Array<JustAnnotation>
}
@@ -6,4 +7,5 @@
annotation class Empty constructor() : Annotation
annotation class JustAnnotation constructor(annotation: Empty) : Annotation {
val annotation: Empty
}
}
}
@@ -1,3 +1,4 @@
package test {
@JustEnum(weapon = Weapon.SCISSORS) @EnumArray(enumArray = {}) class C1 constructor()
@EnumArray(enumArray = {Weapon.PAPER, Weapon.ROCK}) class C2 constructor()
annotation class EnumArray constructor(enumArray: Array<Weapon>) : Annotation {
@@ -10,4 +11,5 @@
enum entry ROCK
enum entry PAPER
enum entry SCISSORS
}
}
}
@@ -1,3 +1,4 @@
package test {
@PrimitiveArrays(booleanArray = {true, false, true}, byteArray = {-7.toByte(), 7.toByte()}, charArray = {\u0025 ('%'), \u007A ('z')}, doubleArray = {-3.14.toDouble()}, floatArray = {2.72.toFloat(), 0.0.toFloat()}, intArray = {239017, -1}, longArray = {123456789123456789.toLong()}, shortArray = {239.toShort()}) class C1 constructor()
@PrimitiveArrays(booleanArray = {}, byteArray = {}, charArray = {}, doubleArray = {}, floatArray = {}, intArray = {}, longArray = {}, shortArray = {}) class C2 constructor()
annotation class PrimitiveArrays constructor(byteArray: ByteArray, charArray: CharArray, shortArray: ShortArray, intArray: IntArray, longArray: LongArray, floatArray: FloatArray, doubleArray: DoubleArray, booleanArray: BooleanArray) : Annotation {
@@ -10,3 +11,4 @@
val longArray: LongArray
val shortArray: ShortArray
}
}
@@ -1,3 +1,4 @@
package test {
@Primitives(boolean = true, byte = 7.toByte(), char = \u0025 ('%'), double = -3.14.toDouble(), float = 2.72.toFloat(), int = 239017, long = 123456789123456789.toLong(), short = 239.toShort()) class C constructor()
annotation class Primitives constructor(byte: Byte, char: Char, short: Short, int: Int, long: Long, float: Float, double: Double, boolean: Boolean) : Annotation {
val boolean: Boolean
@@ -9,3 +10,4 @@
val long: Long
val short: Short
}
}
@@ -1,3 +1,4 @@
package test {
@JustString(string = "kotlin") @StringArray(stringArray = {}) class C1 constructor()
@StringArray(stringArray = {"java", ""}) class C2 constructor()
annotation class JustString constructor(string: String) : Annotation {
@@ -5,4 +6,5 @@
}
annotation class StringArray constructor(stringArray: Array<String>) : Annotation {
val stringArray: Array<String>
}
}
}
@@ -1,3 +1,4 @@
package test {
enum class My private constructor() : Enum<My> {
enum entry ALPHA
enum entry BETA
@@ -6,4 +7,5 @@
annotation class ann constructor(vararg m: My) : Annotation {
val m: Array<out My>
}
@ann(m = {My.ALPHA, My.BETA}) annotation class annotated constructor() : Annotation
@ann(m = {My.ALPHA, My.BETA}) annotation class annotated constructor() : Annotation
}
@@ -1,3 +1,4 @@
package test {
@anno(x = "top level class") class C1 @anno(x = "constructor") constructor() {
@anno(x = "member property") val p3: Nothing?
@anno(x = "member extension property") val Int.v4: Int
@@ -12,4 +13,5 @@
@anno(x = "top level function") fun f1(@anno(x = "top level function parameter") p: Int)
@anno(x = "extension function") fun Long.f2(@anno(x = "extension function parameter") p: Int)
@anno(x = "top level property") val p1: Nothing?
@anno(x = "extension property") val Double.p2: Double
@anno(x = "extension property") val Double.p2: Double
}
@@ -1,7 +1,9 @@
package test {
@Retention(value = AnnotationRetention.BINARY) @Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER}) annotation class A constructor() : Annotation
enum class Enum private constructor() : Enum<Enum> {
@A enum entry ENTRY
}
@A class Klass @A constructor()
@A fun <@A T> function(@A param: Unit)
@A val property: Unit
@A val property: Unit
}
@@ -1,3 +1,4 @@
package test {
class Class constructor() {
val arrayConst: Any = {1.toByte(), 2.toByte()}
val booleanConst: Boolean = true
@@ -27,3 +28,4 @@
val longConst: Long = 40.toLong()
val shortConst: Short = 20.toShort()
val stringConst: String = "abcd"
}
@@ -1,3 +1,4 @@
package test {
class ClassA constructor() {
class classB constructor() {
fun memberFromB(): Int
@@ -25,3 +26,4 @@
val memberFromObjA: Int = 300
}
}
}
@@ -1,7 +1,9 @@
package test {
annotation class Anno constructor(value: String) : Annotation {
val value: String
}
@Anno(value = "property") val v1: String = ""
var v2: String
@Anno(value = "getter") get
@Anno(value = "setter") set
@Anno(value = "setter") set
}
@@ -1,6 +1,8 @@
package test {
class Class constructor() {
fun member(): Nothing?
}
fun <T> T.extension(): T?
fun function(int: Int, string: String = ...): Class
val property: Unit
val property: Unit
}
@@ -1,7 +1,9 @@
package test {
@Retention(value = AnnotationRetention.SOURCE) @Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER}) annotation class A constructor() : Annotation
enum class Enum private constructor() : Enum<Enum> {
enum entry ENTRY
}
class Klass constructor()
fun <T> function(param: Unit)
val property: Unit
val property: Unit
}
@@ -3,4 +3,5 @@ package <root> {
object Obj {
const val O: String = "O"
val concat: String = "OK"
}
}
}
@@ -1,4 +1,6 @@
package test {
@Retention(value = AnnotationRetention.BINARY) @Target(allowedTargets = {AnnotationTarget.TYPE_PARAMETER}) annotation class Ann constructor(value: String) : Annotation {
val value: String
}
inline fun <reified @Ann(value = "abc") T> foo()
inline fun <reified @Ann(value = "abc") T> foo()
}
@@ -1,3 +1,4 @@
package test {
data class DataClass constructor(intProp: Int, stringProp: String) {
val intProp: Int
val nonConstructorProp: Int = 0
@@ -13,4 +14,5 @@
override fun equals(other: Any?): Boolean
override fun hashCode(): Int
override fun toString(): String
}
}
}
@@ -1,7 +1,9 @@
package test {
class A constructor() {
@field:Ann var x: Int
@delegate:Ann var y: Int
}
annotation class Ann constructor() : Annotation
@field:Ann var x: Int
@delegate:Ann var y: Int
@delegate:Ann var y: Int
}
@@ -1,7 +1,9 @@
package test {
class A constructor() {
@Ann val @receiver:Ann Int.bar: Int
@Ann fun @receiver:Ann Int.foo(@Ann arg: Int): Int
}
annotation class Ann constructor() : Annotation
@Ann val @receiver:Ann Int.bar: Int
@Ann fun @receiver:Ann Int.foo(@Ann arg: Int): Int
@Ann fun @receiver:Ann Int.foo(@Ann arg: Int): Int
}
@@ -1,2 +1,4 @@
package test {
class C constructor()
fun C.builder(c: C.() -> Unit)
fun C.builder(c: C.() -> Unit)
}
@@ -1,2 +1,4 @@
package test {
annotation class Annotation constructor() : Annotation
fun foo(@Annotation arg: Int)
fun foo(@Annotation arg: Int)
}
@@ -1,4 +1,5 @@
abstract class A constructor() {
package test {
abstract class A constructor() {
abstract val a: Int
abstract var b: Int
protected set
@@ -13,3 +14,4 @@ abstract class A constructor() {
open var l: Int
protected set
}
}
@@ -1,6 +1,8 @@
package test {
@Retention(value = AnnotationRetention.BINARY) @Target(allowedTargets = {AnnotationTarget.TYPE}) annotation class AnnoBinary constructor() : Annotation
@Retention(value = AnnotationRetention.RUNTIME) @Target(allowedTargets = {AnnotationTarget.TYPE}) annotation class AnnoRuntime constructor() : Annotation
@Retention(value = AnnotationRetention.SOURCE) @Target(allowedTargets = {AnnotationTarget.TYPE}) annotation class AnnoSource constructor() : Annotation
fun withBinaryAnnotation(id: @AnnoBinary Int)
fun withRuntimeAnnotation(id: @AnnoRuntime Int)
fun withSourceAnnotation(id: Int)
fun withSourceAnnotation(id: Int)
}