[K2/N] Add klib contents serialization tests from old testinfra
Merge-request: KT-MR-8509 Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
8bc2aaa295
commit
debbfa8397
+14
@@ -0,0 +1,14 @@
|
||||
package test
|
||||
|
||||
annotation class Anno(val value: String = "0", val x: Int = 0)
|
||||
annotation class Bnno
|
||||
|
||||
enum class Eee {
|
||||
@Anno()
|
||||
Entry1,
|
||||
Entry2,
|
||||
@Anno("3") @Bnno
|
||||
Entry3,
|
||||
@Anno("4", 4)
|
||||
Entry4,
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
annotation class Anno constructor(value: String = ..., x: Int = ...) : Annotation {
|
||||
val value: String
|
||||
val x: Int
|
||||
}
|
||||
annotation class Bnno constructor() : Annotation
|
||||
enum class Eee private constructor() : Enum<Eee> {
|
||||
@Anno enum entry Entry1
|
||||
enum entry Entry2
|
||||
@Anno(value = "3") @Bnno enum entry Entry3
|
||||
@Anno(value = "4", x = 4) enum entry Entry4
|
||||
}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
package test
|
||||
|
||||
annotation class Empty
|
||||
|
||||
annotation class JustAnnotation(val annotation: Empty)
|
||||
|
||||
annotation class AnnotationArray(val annotationArray: Array<JustAnnotation>)
|
||||
|
||||
@JustAnnotation(Empty())
|
||||
@AnnotationArray(arrayOf())
|
||||
class C1
|
||||
|
||||
@AnnotationArray(arrayOf(JustAnnotation(Empty()), JustAnnotation(Empty())))
|
||||
class C2
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
annotation class AnnotationArray constructor(annotationArray: Array<JustAnnotation>) : Annotation {
|
||||
val annotationArray: Array<JustAnnotation>
|
||||
}
|
||||
@JustAnnotation(annotation = Empty) @AnnotationArray(annotationArray = {}) class C1 constructor()
|
||||
@AnnotationArray(annotationArray = {JustAnnotation(annotation = Empty), JustAnnotation(annotation = Empty)}) class C2 constructor()
|
||||
annotation class Empty constructor() : Annotation
|
||||
annotation class JustAnnotation constructor(annotation: Empty) : Annotation {
|
||||
val annotation: Empty
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package test
|
||||
|
||||
enum class Weapon {
|
||||
ROCK,
|
||||
PAPER,
|
||||
SCISSORS
|
||||
}
|
||||
|
||||
annotation class JustEnum(val weapon: Weapon)
|
||||
|
||||
annotation class EnumArray(val enumArray: Array<Weapon>)
|
||||
|
||||
@JustEnum(Weapon.SCISSORS)
|
||||
@EnumArray(arrayOf())
|
||||
class C1
|
||||
|
||||
@EnumArray(arrayOf(Weapon.PAPER, Weapon.ROCK))
|
||||
class C2
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
@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 {
|
||||
val enumArray: Array<Weapon>
|
||||
}
|
||||
annotation class JustEnum constructor(weapon: Weapon) : Annotation {
|
||||
val weapon: Weapon
|
||||
}
|
||||
enum class Weapon private constructor() : Enum<Weapon> {
|
||||
enum entry ROCK
|
||||
enum entry PAPER
|
||||
enum entry SCISSORS
|
||||
}
|
||||
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
// KT-56189 -3.14 is not constant
|
||||
// MUTED_WHEN: K2
|
||||
package test
|
||||
|
||||
annotation class PrimitiveArrays(
|
||||
val byteArray: ByteArray,
|
||||
val charArray: CharArray,
|
||||
val shortArray: ShortArray,
|
||||
val intArray: IntArray,
|
||||
val longArray: LongArray,
|
||||
val floatArray: FloatArray,
|
||||
val doubleArray: DoubleArray,
|
||||
val booleanArray: BooleanArray
|
||||
)
|
||||
|
||||
@PrimitiveArrays(
|
||||
byteArray = byteArrayOf(-7, 7),
|
||||
charArray = charArrayOf('%', 'z'),
|
||||
shortArray = shortArrayOf(239),
|
||||
intArray = intArrayOf(239017, -1),
|
||||
longArray = longArrayOf(123456789123456789L),
|
||||
floatArray = floatArrayOf(2.72f, 0f),
|
||||
doubleArray = doubleArrayOf(-3.14),
|
||||
booleanArray = booleanArrayOf(true, false, true)
|
||||
)
|
||||
class C1
|
||||
|
||||
@PrimitiveArrays(
|
||||
byteArray = byteArrayOf(),
|
||||
charArray = charArrayOf(),
|
||||
shortArray = shortArrayOf(),
|
||||
intArray = intArrayOf(),
|
||||
longArray = longArrayOf(),
|
||||
floatArray = floatArrayOf(),
|
||||
doubleArray = doubleArrayOf(),
|
||||
booleanArray = booleanArrayOf()
|
||||
)
|
||||
class C2
|
||||
native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/primitiveArrays.txt
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
@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 {
|
||||
val booleanArray: BooleanArray
|
||||
val byteArray: ByteArray
|
||||
val charArray: CharArray
|
||||
val doubleArray: DoubleArray
|
||||
val floatArray: FloatArray
|
||||
val intArray: IntArray
|
||||
val longArray: LongArray
|
||||
val shortArray: ShortArray
|
||||
}
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
// KT-56189 error: an annotation argument must be a compile-time constant
|
||||
// -3.14 is not constant
|
||||
// MUTED_WHEN: K2
|
||||
package test
|
||||
|
||||
annotation class Primitives(
|
||||
val byte: Byte,
|
||||
val char: Char,
|
||||
val short: Short,
|
||||
val int: Int,
|
||||
val long: Long,
|
||||
val float: Float,
|
||||
val double: Double,
|
||||
val boolean: Boolean
|
||||
)
|
||||
|
||||
@Primitives(
|
||||
byte = 7,
|
||||
char = '%',
|
||||
short = 239,
|
||||
int = 239017,
|
||||
long = 123456789123456789L,
|
||||
float = 2.72f,
|
||||
double = -3.14,
|
||||
boolean = true
|
||||
)
|
||||
class C
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
@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
|
||||
val byte: Byte
|
||||
val char: Char
|
||||
val double: Double
|
||||
val float: Float
|
||||
val int: Int
|
||||
val long: Long
|
||||
val short: Short
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package test
|
||||
|
||||
annotation class JustString(val string: String)
|
||||
|
||||
annotation class StringArray(val stringArray: Array<String>)
|
||||
|
||||
@JustString("kotlin")
|
||||
@StringArray(arrayOf())
|
||||
class C1
|
||||
|
||||
@StringArray(arrayOf("java", ""))
|
||||
class C2
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
@JustString(string = "kotlin") @StringArray(stringArray = {}) class C1 constructor()
|
||||
@StringArray(stringArray = {"java", ""}) class C2 constructor()
|
||||
annotation class JustString constructor(string: String) : Annotation {
|
||||
val string: String
|
||||
}
|
||||
annotation class StringArray constructor(stringArray: Array<String>) : Annotation {
|
||||
val stringArray: Array<String>
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
enum class My { ALPHA, BETA, OMEGA }
|
||||
|
||||
annotation class ann(vararg val m: My)
|
||||
|
||||
@ann(My.ALPHA, My.BETA) annotation class annotated
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
enum class My private constructor() : Enum<My> {
|
||||
enum entry ALPHA
|
||||
enum entry BETA
|
||||
enum entry OMEGA
|
||||
}
|
||||
annotation class ann constructor(vararg m: My) : Annotation {
|
||||
val m: Array<out My>
|
||||
}
|
||||
@ann(m = {My.ALPHA, My.BETA}) annotation class annotated constructor() : Annotation
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package test
|
||||
|
||||
annotation class anno(val x: String)
|
||||
|
||||
|
||||
@anno("top level function")
|
||||
fun f1(@anno("top level function parameter") p: Int) {}
|
||||
|
||||
@anno("top level property")
|
||||
val p1 = null
|
||||
|
||||
@anno("extension function")
|
||||
fun Long.f2(@anno("extension function parameter") p: Int) {}
|
||||
|
||||
@anno("extension property")
|
||||
val Double.p2: Double get() = 0.0
|
||||
|
||||
@anno("top level class")
|
||||
class C1 @anno("constructor") constructor() {
|
||||
@anno("member function")
|
||||
fun f3(@anno("member function parameter") p: Int) {}
|
||||
|
||||
@anno("member property")
|
||||
val p3 = null
|
||||
|
||||
@anno("member extension function")
|
||||
fun String.f4() {}
|
||||
|
||||
@anno("member extension property")
|
||||
val Int.v4: Int get() = this
|
||||
|
||||
@anno("nested class")
|
||||
class C2
|
||||
|
||||
@anno("companion object")
|
||||
companion object {}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
@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
|
||||
@anno(x = "member function") fun f3(@anno(x = "member function parameter") p: Int)
|
||||
@anno(x = "member extension function") fun String.f4()
|
||||
@anno(x = "nested class") class C2 constructor()
|
||||
@anno(x = "companion object") companion object
|
||||
}
|
||||
annotation class anno constructor(x: String) : Annotation {
|
||||
val x: String
|
||||
}
|
||||
@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
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package test
|
||||
|
||||
import kotlin.annotation.AnnotationTarget.*
|
||||
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
@Target(CLASS, CONSTRUCTOR, FUNCTION, PROPERTY, VALUE_PARAMETER, TYPE, TYPE_PARAMETER)
|
||||
annotation class A
|
||||
|
||||
@A
|
||||
class Klass @A constructor()
|
||||
|
||||
@A
|
||||
fun <@A T> function(@A param: Unit): @A Unit {}
|
||||
|
||||
@A
|
||||
val property = Unit
|
||||
|
||||
enum class Enum {
|
||||
@A
|
||||
ENTRY
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
@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
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
// KT-56190 K2 does not emit const initializers
|
||||
// MUTED_WHEN: K2
|
||||
package test
|
||||
|
||||
enum class Weapon {
|
||||
ROCK,
|
||||
PAPER,
|
||||
SCISSORS
|
||||
}
|
||||
|
||||
val byteConst: Byte = 10
|
||||
val shortConst: Short = 20
|
||||
val intConst: Int = 30
|
||||
val longConst: Long = 40
|
||||
val charConst: Char = 'A'
|
||||
val stringConst: String = "abcd"
|
||||
val booleanConst: Boolean = true
|
||||
val floatConst: Float = 2.0f
|
||||
val doubleConst: Double = 3.0
|
||||
val enumConst: Weapon? = Weapon.ROCK
|
||||
val arrayConst: Any = byteArrayOf(1,2)
|
||||
|
||||
val a = 10
|
||||
val b = a + 20
|
||||
|
||||
class Class {
|
||||
val byteConst: Byte = 10
|
||||
val shortConst: Short = 20
|
||||
val intConst: Int = 30
|
||||
val longConst: Long = 40
|
||||
val charConst: Char = 'A'
|
||||
val stringConst: String = "abcd"
|
||||
val booleanConst: Boolean = true
|
||||
val floatConst: Float = 2.0f
|
||||
val doubleConst: Double = 3.0
|
||||
val enumConst: Weapon? = Weapon.ROCK
|
||||
val arrayConst: Any = byteArrayOf(1,2)
|
||||
val a = 10
|
||||
val b = a + 20
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
class Class constructor() {
|
||||
val a: Int = 10
|
||||
val arrayConst: Any = {1.toByte(), 2.toByte()}
|
||||
val b: Int = 30
|
||||
val booleanConst: Boolean = true
|
||||
val byteConst: Byte = 10.toByte()
|
||||
val charConst: Char = \u0041 ('A')
|
||||
val doubleConst: Double = 3.0.toDouble()
|
||||
val enumConst: Weapon? = Weapon.ROCK
|
||||
val floatConst: Float = 2.0.toFloat()
|
||||
val intConst: Int = 30
|
||||
val longConst: Long = 40.toLong()
|
||||
val shortConst: Short = 20.toShort()
|
||||
val stringConst: String = "abcd"
|
||||
}
|
||||
enum class Weapon private constructor() : Enum<Weapon> {
|
||||
enum entry ROCK
|
||||
enum entry PAPER
|
||||
enum entry SCISSORS
|
||||
}
|
||||
val a: Int = 10
|
||||
val arrayConst: Any = {1.toByte(), 2.toByte()}
|
||||
val b: Int = 30
|
||||
val booleanConst: Boolean = true
|
||||
val byteConst: Byte = 10.toByte()
|
||||
val charConst: Char = \u0041 ('A')
|
||||
val doubleConst: Double = 3.0.toDouble()
|
||||
val enumConst: Weapon? = Weapon.ROCK
|
||||
val floatConst: Float = 2.0.toFloat()
|
||||
val intConst: Int = 30
|
||||
val longConst: Long = 40.toLong()
|
||||
val shortConst: Short = 20.toShort()
|
||||
val stringConst: String = "abcd"
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
// KT-56190 K2 does not emit const initializers
|
||||
// MUTED_WHEN: K2
|
||||
package test
|
||||
|
||||
class ClassA {
|
||||
class classB {
|
||||
fun memberFromB(): Int = 100
|
||||
|
||||
class BC {
|
||||
val memberFromBB: Int = 150
|
||||
}
|
||||
|
||||
object BO {
|
||||
val memberFromBO: Int = 175
|
||||
}
|
||||
}
|
||||
|
||||
inner class classC {
|
||||
val memberFromC: Int = 200
|
||||
}
|
||||
|
||||
companion object {
|
||||
val stat: Int = 250
|
||||
|
||||
class D {
|
||||
val memberFromD: Int = 275
|
||||
}
|
||||
}
|
||||
|
||||
object ObjA {
|
||||
val memberFromObjA: Int = 300
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
class ClassA constructor() {
|
||||
companion object {
|
||||
val stat: Int = 250
|
||||
class D constructor() {
|
||||
val memberFromD: Int = 275
|
||||
}
|
||||
}
|
||||
object ObjA {
|
||||
val memberFromObjA: Int = 300
|
||||
}
|
||||
class classB constructor() {
|
||||
fun memberFromB(): Int
|
||||
class BC constructor() {
|
||||
val memberFromBB: Int = 150
|
||||
}
|
||||
object BO {
|
||||
val memberFromBO: Int = 175
|
||||
}
|
||||
}
|
||||
inner class classC constructor() {
|
||||
val memberFromC: Int = 200
|
||||
}
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// KT-56190 K2 does not emit const initializers
|
||||
// MUTED_WHEN: K2
|
||||
package test
|
||||
|
||||
annotation class Anno(val value: String)
|
||||
|
||||
@Anno("property") val v1 = ""
|
||||
|
||||
var v2: String
|
||||
@Anno("getter") get() = ""
|
||||
@Anno("setter") set(@Anno("setparam") value) {
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
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
|
||||
@@ -0,0 +1,11 @@
|
||||
package test
|
||||
|
||||
class Class {
|
||||
fun member() = null
|
||||
}
|
||||
|
||||
fun function(int: Int, string: String = "default"): Class = Class()
|
||||
|
||||
fun <T> T.extension(): T? = null
|
||||
|
||||
val property: Unit = Unit
|
||||
@@ -0,0 +1,6 @@
|
||||
class Class constructor() {
|
||||
fun member(): Nothing?
|
||||
}
|
||||
fun <T> T.extension(): T?
|
||||
fun function(int: Int, string: String = ...): Class
|
||||
val property: Unit
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package test
|
||||
|
||||
import kotlin.annotation.AnnotationTarget.*
|
||||
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Target(CLASS, CONSTRUCTOR, FUNCTION, PROPERTY, VALUE_PARAMETER, TYPE, TYPE_PARAMETER)
|
||||
annotation class A
|
||||
|
||||
@A
|
||||
class Klass @A constructor()
|
||||
|
||||
@A
|
||||
fun <@A T> function(@A param: Unit): @A Unit {}
|
||||
|
||||
@A
|
||||
val property = Unit
|
||||
|
||||
enum class Enum {
|
||||
@A
|
||||
ENTRY
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
@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
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package test
|
||||
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
@Target(AnnotationTarget.TYPE_PARAMETER)
|
||||
annotation class Ann(val value: String)
|
||||
inline fun <reified @Ann("abc") T> foo() {}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
@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()
|
||||
@@ -0,0 +1,15 @@
|
||||
package test
|
||||
|
||||
annotation class Ann
|
||||
|
||||
@field:Ann
|
||||
var x: Int = 5
|
||||
@delegate:Ann
|
||||
var y: Int by ::x
|
||||
|
||||
class A {
|
||||
@field:Ann
|
||||
var x: Int = 5
|
||||
@delegate:Ann
|
||||
var y: Int by ::x
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
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
|
||||
@@ -0,0 +1,14 @@
|
||||
// KT-56218: Fix receiver annotations for properties
|
||||
// MUTED_WHEN: K2
|
||||
package test
|
||||
|
||||
annotation class Ann
|
||||
@Ann fun @receiver:Ann Int.foo(@Ann arg: Int) = 10
|
||||
@Ann val @receiver:Ann Int.bar
|
||||
get() = 5
|
||||
|
||||
class A {
|
||||
@Ann fun @receiver:Ann Int.foo(@Ann arg: Int) = 10
|
||||
@Ann val @receiver:Ann Int.bar
|
||||
get() = 5
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
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
|
||||
Reference in New Issue
Block a user