diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/annotatedEnumEntry.kt b/native/native.tests/testData/klibContents/builtinsSerializer/annotatedEnumEntry.kt new file mode 100644 index 00000000000..68698caec13 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/annotatedEnumEntry.kt @@ -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, +} diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/annotatedEnumEntry.txt b/native/native.tests/testData/klibContents/builtinsSerializer/annotatedEnumEntry.txt new file mode 100644 index 00000000000..74d66a30149 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/annotatedEnumEntry.txt @@ -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 { + @Anno enum entry Entry1 + enum entry Entry2 + @Anno(value = "3") @Bnno enum entry Entry3 + @Anno(value = "4", x = 4) enum entry Entry4 + } \ No newline at end of file diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/annotation.kt b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/annotation.kt new file mode 100644 index 00000000000..09c7b752245 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/annotation.kt @@ -0,0 +1,14 @@ +package test + +annotation class Empty + +annotation class JustAnnotation(val annotation: Empty) + +annotation class AnnotationArray(val annotationArray: Array) + +@JustAnnotation(Empty()) +@AnnotationArray(arrayOf()) +class C1 + +@AnnotationArray(arrayOf(JustAnnotation(Empty()), JustAnnotation(Empty()))) +class C2 diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/annotation.txt b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/annotation.txt new file mode 100644 index 00000000000..d4026429c46 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/annotation.txt @@ -0,0 +1,9 @@ + annotation class AnnotationArray constructor(annotationArray: Array) : Annotation { + val annotationArray: Array + } + @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 + } \ No newline at end of file diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/enum.kt b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/enum.kt new file mode 100644 index 00000000000..d3ab2c9dcc0 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/enum.kt @@ -0,0 +1,18 @@ +package test + +enum class Weapon { + ROCK, + PAPER, + SCISSORS +} + +annotation class JustEnum(val weapon: Weapon) + +annotation class EnumArray(val enumArray: Array) + +@JustEnum(Weapon.SCISSORS) +@EnumArray(arrayOf()) +class C1 + +@EnumArray(arrayOf(Weapon.PAPER, Weapon.ROCK)) +class C2 diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/enum.txt b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/enum.txt new file mode 100644 index 00000000000..4e4d081bf9a --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/enum.txt @@ -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) : Annotation { + val enumArray: Array + } + annotation class JustEnum constructor(weapon: Weapon) : Annotation { + val weapon: Weapon + } + enum class Weapon private constructor() : Enum { + enum entry ROCK + enum entry PAPER + enum entry SCISSORS + } \ No newline at end of file diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/primitiveArrays.kt b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/primitiveArrays.kt new file mode 100644 index 00000000000..48ca87933c5 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/primitiveArrays.kt @@ -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 diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/primitiveArrays.txt b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/primitiveArrays.txt new file mode 100644 index 00000000000..7eea622ca3d --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/primitiveArrays.txt @@ -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 + } \ No newline at end of file diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/primitives.kt b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/primitives.kt new file mode 100644 index 00000000000..76dcbde09e4 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/primitives.kt @@ -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 diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/primitives.txt b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/primitives.txt new file mode 100644 index 00000000000..1552cbcedad --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/primitives.txt @@ -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 + } \ No newline at end of file diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/string.kt b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/string.kt new file mode 100644 index 00000000000..92860cd716a --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/string.kt @@ -0,0 +1,12 @@ +package test + +annotation class JustString(val string: String) + +annotation class StringArray(val stringArray: Array) + +@JustString("kotlin") +@StringArray(arrayOf()) +class C1 + +@StringArray(arrayOf("java", "")) +class C2 diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/string.txt b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/string.txt new file mode 100644 index 00000000000..62df3fbdd69 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/string.txt @@ -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) : Annotation { + val stringArray: Array + } \ No newline at end of file diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/varargs.kt b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/varargs.kt new file mode 100644 index 00000000000..726828d9a88 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/varargs.kt @@ -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 diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/varargs.txt b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/varargs.txt new file mode 100644 index 00000000000..9cc17b69cf7 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/varargs.txt @@ -0,0 +1,9 @@ + enum class My private constructor() : Enum { + enum entry ALPHA + enum entry BETA + enum entry OMEGA + } + annotation class ann constructor(vararg m: My) : Annotation { + val m: Array + } + @ann(m = {My.ALPHA, My.BETA}) annotation class annotated constructor() : Annotation \ No newline at end of file diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/annotationTargets.kt b/native/native.tests/testData/klibContents/builtinsSerializer/annotationTargets.kt new file mode 100644 index 00000000000..61278bee3a6 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/annotationTargets.kt @@ -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 {} +} diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/annotationTargets.txt b/native/native.tests/testData/klibContents/builtinsSerializer/annotationTargets.txt new file mode 100644 index 00000000000..7d10277f41a --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/annotationTargets.txt @@ -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 \ No newline at end of file diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/binaryRetainedAnnotation.kt b/native/native.tests/testData/klibContents/builtinsSerializer/binaryRetainedAnnotation.kt new file mode 100644 index 00000000000..99796764d56 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/binaryRetainedAnnotation.kt @@ -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 +} diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/binaryRetainedAnnotation.txt b/native/native.tests/testData/klibContents/builtinsSerializer/binaryRetainedAnnotation.txt new file mode 100644 index 00000000000..335e202bd51 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/binaryRetainedAnnotation.txt @@ -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 { + @A enum entry ENTRY + } + @A class Klass @A constructor() + @A fun <@A T> function(@A param: Unit) + @A val property: Unit \ No newline at end of file diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/compileTimeConstants.kt b/native/native.tests/testData/klibContents/builtinsSerializer/compileTimeConstants.kt new file mode 100644 index 00000000000..d38cbb55376 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/compileTimeConstants.kt @@ -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 +} + diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/compileTimeConstants.txt b/native/native.tests/testData/klibContents/builtinsSerializer/compileTimeConstants.txt new file mode 100644 index 00000000000..f2b3abb1629 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/compileTimeConstants.txt @@ -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 { + 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" \ No newline at end of file diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/nestedClassesAndObjects.kt b/native/native.tests/testData/klibContents/builtinsSerializer/nestedClassesAndObjects.kt new file mode 100644 index 00000000000..bbe8ebc0462 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/nestedClassesAndObjects.kt @@ -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 + } +} diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/nestedClassesAndObjects.txt b/native/native.tests/testData/klibContents/builtinsSerializer/nestedClassesAndObjects.txt new file mode 100644 index 00000000000..e6b2e12cbcc --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/nestedClassesAndObjects.txt @@ -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 + } + } \ No newline at end of file diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/propertyAccessorAnnotations.kt b/native/native.tests/testData/klibContents/builtinsSerializer/propertyAccessorAnnotations.kt new file mode 100644 index 00000000000..7715a293ffa --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/propertyAccessorAnnotations.kt @@ -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) { + } diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/propertyAccessorAnnotations.txt b/native/native.tests/testData/klibContents/builtinsSerializer/propertyAccessorAnnotations.txt new file mode 100644 index 00000000000..130b60d8b50 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/propertyAccessorAnnotations.txt @@ -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 \ No newline at end of file diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/simple.kt b/native/native.tests/testData/klibContents/builtinsSerializer/simple.kt new file mode 100644 index 00000000000..36b8496c363 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/simple.kt @@ -0,0 +1,11 @@ +package test + +class Class { + fun member() = null +} + +fun function(int: Int, string: String = "default"): Class = Class() + +fun T.extension(): T? = null + +val property: Unit = Unit diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/simple.txt b/native/native.tests/testData/klibContents/builtinsSerializer/simple.txt new file mode 100644 index 00000000000..b2220221083 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/simple.txt @@ -0,0 +1,6 @@ + class Class constructor() { + fun member(): Nothing? + } + fun T.extension(): T? + fun function(int: Int, string: String = ...): Class + val property: Unit \ No newline at end of file diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/sourceRetainedAnnotation.kt b/native/native.tests/testData/klibContents/builtinsSerializer/sourceRetainedAnnotation.kt new file mode 100644 index 00000000000..24564a1c2ca --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/sourceRetainedAnnotation.kt @@ -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 +} diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/sourceRetainedAnnotation.txt b/native/native.tests/testData/klibContents/builtinsSerializer/sourceRetainedAnnotation.txt new file mode 100644 index 00000000000..2f76428318c --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/sourceRetainedAnnotation.txt @@ -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 entry ENTRY + } + class Klass constructor() + fun function(param: Unit) + val property: Unit \ No newline at end of file diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/typeParameterAnnotation.kt b/native/native.tests/testData/klibContents/builtinsSerializer/typeParameterAnnotation.kt new file mode 100644 index 00000000000..4d6f25bb8c9 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/typeParameterAnnotation.kt @@ -0,0 +1,6 @@ +package test + +@Retention(AnnotationRetention.BINARY) +@Target(AnnotationTarget.TYPE_PARAMETER) +annotation class Ann(val value: String) +inline fun foo() {} diff --git a/native/native.tests/testData/klibContents/builtinsSerializer/typeParameterAnnotation.txt b/native/native.tests/testData/klibContents/builtinsSerializer/typeParameterAnnotation.txt new file mode 100644 index 00000000000..a322c2e5c81 --- /dev/null +++ b/native/native.tests/testData/klibContents/builtinsSerializer/typeParameterAnnotation.txt @@ -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 foo() \ No newline at end of file diff --git a/native/native.tests/testData/klibContents/klib/fieldAnnotations.kt b/native/native.tests/testData/klibContents/klib/fieldAnnotations.kt new file mode 100644 index 00000000000..a0492ca8725 --- /dev/null +++ b/native/native.tests/testData/klibContents/klib/fieldAnnotations.kt @@ -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 +} diff --git a/native/native.tests/testData/klibContents/klib/fieldAnnotations.txt b/native/native.tests/testData/klibContents/klib/fieldAnnotations.txt new file mode 100644 index 00000000000..41631032534 --- /dev/null +++ b/native/native.tests/testData/klibContents/klib/fieldAnnotations.txt @@ -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 \ No newline at end of file diff --git a/native/native.tests/testData/klibContents/klib/receiverAnnotations.kt b/native/native.tests/testData/klibContents/klib/receiverAnnotations.kt new file mode 100644 index 00000000000..4034273fff3 --- /dev/null +++ b/native/native.tests/testData/klibContents/klib/receiverAnnotations.kt @@ -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 +} \ No newline at end of file diff --git a/native/native.tests/testData/klibContents/klib/receiverAnnotations.txt b/native/native.tests/testData/klibContents/klib/receiverAnnotations.txt new file mode 100644 index 00000000000..deb434eff9d --- /dev/null +++ b/native/native.tests/testData/klibContents/klib/receiverAnnotations.txt @@ -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 \ No newline at end of file diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeK1LibContentsTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeK1LibContentsTestGenerated.java index eea8e2d94c1..0341df9242c 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeK1LibContentsTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeK1LibContentsTestGenerated.java @@ -21,7 +21,7 @@ import java.util.regex.Pattern; public class NativeK1LibContentsTestGenerated extends AbstractNativeKlibContentsTest { @Test public void testAllFilesPresentInKlibContents() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/klibContents"), Pattern.compile("^([^_](.+)).kt$"), null, false); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/klibContents"), Pattern.compile("^([^_](.+)).kt$"), null, true); } @Test @@ -53,4 +53,136 @@ public class NativeK1LibContentsTestGenerated extends AbstractNativeKlibContents public void testType_annotations() throws Exception { runTest("native/native.tests/testData/klibContents/type_annotations.kt"); } + + @Nested + @TestMetadata("native/native.tests/testData/klibContents/builtinsSerializer") + @TestDataPath("$PROJECT_ROOT") + public class BuiltinsSerializer { + @Test + public void testAllFilesPresentInBuiltinsSerializer() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/klibContents/builtinsSerializer"), Pattern.compile("^([^_](.+)).kt$"), null, true); + } + + @Test + @TestMetadata("annotatedEnumEntry.kt") + public void testAnnotatedEnumEntry() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/annotatedEnumEntry.kt"); + } + + @Test + @TestMetadata("annotationTargets.kt") + public void testAnnotationTargets() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/annotationTargets.kt"); + } + + @Test + @TestMetadata("binaryRetainedAnnotation.kt") + public void testBinaryRetainedAnnotation() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/binaryRetainedAnnotation.kt"); + } + + @Test + @TestMetadata("compileTimeConstants.kt") + public void testCompileTimeConstants() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/compileTimeConstants.kt"); + } + + @Test + @TestMetadata("nestedClassesAndObjects.kt") + public void testNestedClassesAndObjects() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/nestedClassesAndObjects.kt"); + } + + @Test + @TestMetadata("propertyAccessorAnnotations.kt") + public void testPropertyAccessorAnnotations() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/propertyAccessorAnnotations.kt"); + } + + @Test + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/simple.kt"); + } + + @Test + @TestMetadata("sourceRetainedAnnotation.kt") + public void testSourceRetainedAnnotation() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/sourceRetainedAnnotation.kt"); + } + + @Test + @TestMetadata("typeParameterAnnotation.kt") + public void testTypeParameterAnnotation() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/typeParameterAnnotation.kt"); + } + + @Nested + @TestMetadata("native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments") + @TestDataPath("$PROJECT_ROOT") + public class AnnotationArguments { + @Test + public void testAllFilesPresentInAnnotationArguments() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments"), Pattern.compile("^([^_](.+)).kt$"), null, true); + } + + @Test + @TestMetadata("annotation.kt") + public void testAnnotation() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/annotation.kt"); + } + + @Test + @TestMetadata("enum.kt") + public void testEnum() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/enum.kt"); + } + + @Test + @TestMetadata("primitiveArrays.kt") + public void testPrimitiveArrays() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/primitiveArrays.kt"); + } + + @Test + @TestMetadata("primitives.kt") + public void testPrimitives() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/primitives.kt"); + } + + @Test + @TestMetadata("string.kt") + public void testString() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/string.kt"); + } + + @Test + @TestMetadata("varargs.kt") + public void testVarargs() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/varargs.kt"); + } + } + } + + @Nested + @TestMetadata("native/native.tests/testData/klibContents/klib") + @TestDataPath("$PROJECT_ROOT") + public class Klib { + @Test + public void testAllFilesPresentInKlib() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/klibContents/klib"), Pattern.compile("^([^_](.+)).kt$"), null, true); + } + + @Test + @TestMetadata("fieldAnnotations.kt") + public void testFieldAnnotations() throws Exception { + runTest("native/native.tests/testData/klibContents/klib/fieldAnnotations.kt"); + } + + @Test + @TestMetadata("receiverAnnotations.kt") + public void testReceiverAnnotations() throws Exception { + runTest("native/native.tests/testData/klibContents/klib/receiverAnnotations.kt"); + } + } } diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeK2LibContentsTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeK2LibContentsTestGenerated.java index 4ce0c70cfa0..a2ad4196788 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeK2LibContentsTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeK2LibContentsTestGenerated.java @@ -23,7 +23,7 @@ import java.util.regex.Pattern; public class NativeK2LibContentsTestGenerated extends AbstractNativeKlibContentsTest { @Test public void testAllFilesPresentInKlibContents() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/klibContents"), Pattern.compile("^([^_](.+)).kt$"), null, false); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/klibContents"), Pattern.compile("^([^_](.+)).kt$"), null, true); } @Test @@ -55,4 +55,139 @@ public class NativeK2LibContentsTestGenerated extends AbstractNativeKlibContents public void testType_annotations() throws Exception { runTest("native/native.tests/testData/klibContents/type_annotations.kt"); } + + @Nested + @TestMetadata("native/native.tests/testData/klibContents/builtinsSerializer") + @TestDataPath("$PROJECT_ROOT") + @K2Pipeline() + public class BuiltinsSerializer { + @Test + public void testAllFilesPresentInBuiltinsSerializer() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/klibContents/builtinsSerializer"), Pattern.compile("^([^_](.+)).kt$"), null, true); + } + + @Test + @TestMetadata("annotatedEnumEntry.kt") + public void testAnnotatedEnumEntry() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/annotatedEnumEntry.kt"); + } + + @Test + @TestMetadata("annotationTargets.kt") + public void testAnnotationTargets() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/annotationTargets.kt"); + } + + @Test + @TestMetadata("binaryRetainedAnnotation.kt") + public void testBinaryRetainedAnnotation() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/binaryRetainedAnnotation.kt"); + } + + @Test + @TestMetadata("compileTimeConstants.kt") + public void testCompileTimeConstants() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/compileTimeConstants.kt"); + } + + @Test + @TestMetadata("nestedClassesAndObjects.kt") + public void testNestedClassesAndObjects() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/nestedClassesAndObjects.kt"); + } + + @Test + @TestMetadata("propertyAccessorAnnotations.kt") + public void testPropertyAccessorAnnotations() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/propertyAccessorAnnotations.kt"); + } + + @Test + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/simple.kt"); + } + + @Test + @TestMetadata("sourceRetainedAnnotation.kt") + public void testSourceRetainedAnnotation() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/sourceRetainedAnnotation.kt"); + } + + @Test + @TestMetadata("typeParameterAnnotation.kt") + public void testTypeParameterAnnotation() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/typeParameterAnnotation.kt"); + } + + @Nested + @TestMetadata("native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments") + @TestDataPath("$PROJECT_ROOT") + @K2Pipeline() + public class AnnotationArguments { + @Test + public void testAllFilesPresentInAnnotationArguments() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments"), Pattern.compile("^([^_](.+)).kt$"), null, true); + } + + @Test + @TestMetadata("annotation.kt") + public void testAnnotation() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/annotation.kt"); + } + + @Test + @TestMetadata("enum.kt") + public void testEnum() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/enum.kt"); + } + + @Test + @TestMetadata("primitiveArrays.kt") + public void testPrimitiveArrays() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/primitiveArrays.kt"); + } + + @Test + @TestMetadata("primitives.kt") + public void testPrimitives() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/primitives.kt"); + } + + @Test + @TestMetadata("string.kt") + public void testString() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/string.kt"); + } + + @Test + @TestMetadata("varargs.kt") + public void testVarargs() throws Exception { + runTest("native/native.tests/testData/klibContents/builtinsSerializer/annotationArguments/varargs.kt"); + } + } + } + + @Nested + @TestMetadata("native/native.tests/testData/klibContents/klib") + @TestDataPath("$PROJECT_ROOT") + @K2Pipeline() + public class Klib { + @Test + public void testAllFilesPresentInKlib() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/klibContents/klib"), Pattern.compile("^([^_](.+)).kt$"), null, true); + } + + @Test + @TestMetadata("fieldAnnotations.kt") + public void testFieldAnnotations() throws Exception { + runTest("native/native.tests/testData/klibContents/klib/fieldAnnotations.kt"); + } + + @Test + @TestMetadata("receiverAnnotations.kt") + public void testReceiverAnnotations() throws Exception { + runTest("native/native.tests/testData/klibContents/klib/receiverAnnotations.kt"); + } + } } diff --git a/native/native.tests/tests/org/jetbrains/kotlin/generators/tests/GenerateNativeTests.kt b/native/native.tests/tests/org/jetbrains/kotlin/generators/tests/GenerateNativeTests.kt index d2750fded7d..99e60d366e3 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/generators/tests/GenerateNativeTests.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/generators/tests/GenerateNativeTests.kt @@ -105,7 +105,7 @@ fun main() { testClass( suiteTestClassName = "NativeK1LibContentsTestGenerated" ) { - model("klibContents", pattern = "^([^_](.+)).kt$", recursive = false) + model("klibContents", pattern = "^([^_](.+)).kt$", recursive = true) } } testGroup("native/native.tests/tests-gen", "native/native.tests/testData") { @@ -113,7 +113,7 @@ fun main() { suiteTestClassName = "NativeK2LibContentsTestGenerated", annotations = listOf(provider()) ) { - model("klibContents", pattern = "^([^_](.+)).kt$", recursive = false) + model("klibContents", pattern = "^([^_](.+)).kt$", recursive = true) } } diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/AbstractNativeKlibContentsTest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/AbstractNativeKlibContentsTest.kt index 033b59fb3c9..2d3ba5bf2a4 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/AbstractNativeKlibContentsTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/AbstractNativeKlibContentsTest.kt @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.runner.* import org.jetbrains.kotlin.konan.blackboxtest.support.settings.* import org.jetbrains.kotlin.konan.blackboxtest.support.util.* import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertEquals +import org.junit.jupiter.api.Assumptions import org.junit.jupiter.api.Tag import java.io.File @@ -23,6 +24,7 @@ abstract class AbstractNativeKlibContentsTest : AbstractNativeSimpleTest() { protected fun runTest(@TestDataFile testPath: String) { val testPathFull = getAbsoluteFile(testPath) + muteTestIfNecessary(testPathFull) val testCase: TestCase = generateTestCaseWithSingleSource(testPathFull, listOf()) val testCompilationResult: TestCompilationResult.Success = compileToLibrary(testCase) diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/NativeSimpleTestUtils.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/NativeSimpleTestUtils.kt index ddc6de472cc..1ee6dc0e7bd 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/NativeSimpleTestUtils.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/NativeSimpleTestUtils.kt @@ -5,10 +5,12 @@ package org.jetbrains.kotlin.konan.blackboxtest +import com.intellij.openapi.util.io.FileUtil import org.jetbrains.kotlin.konan.blackboxtest.support.PackageName import org.jetbrains.kotlin.konan.blackboxtest.support.TestCase import org.jetbrains.kotlin.konan.blackboxtest.support.TestCaseId import org.jetbrains.kotlin.konan.blackboxtest.support.TestCompilerArgs +import org.jetbrains.kotlin.konan.blackboxtest.support.TestDirectives import org.jetbrains.kotlin.konan.blackboxtest.support.TestFile import org.jetbrains.kotlin.konan.blackboxtest.support.TestKind import org.jetbrains.kotlin.konan.blackboxtest.support.TestModule @@ -23,9 +25,12 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilati import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationResult.Companion.assertSuccess import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestRunChecks import org.jetbrains.kotlin.konan.blackboxtest.support.settings.KotlinNativeTargets +import org.jetbrains.kotlin.konan.blackboxtest.support.settings.PipelineType import org.jetbrains.kotlin.konan.blackboxtest.support.settings.SimpleTestDirectories import org.jetbrains.kotlin.konan.blackboxtest.support.settings.Timeouts import org.jetbrains.kotlin.konan.blackboxtest.support.util.LAUNCHER_MODULE_NAME +import org.jetbrains.kotlin.test.InTextDirectivesUtils +import org.junit.jupiter.api.Assumptions import java.io.File private val DEFAULT_EXTRAS = TestCase.WithTestRunnerExtras(TestRunnerType.DEFAULT) @@ -125,3 +130,17 @@ private fun getLibraryArtifact(testCase: TestCase, dir: File) = private fun AbstractNativeSimpleTest.getExecutableArtifact() = TestCompilationArtifact.Executable(buildDir.resolve("app." + testRunSettings.get().testTarget.family.exeSuffix)) + +private fun directiveValues(testDataFileContents: String, directive: String) = + InTextDirectivesUtils.findListWithPrefixes(testDataFileContents, "// $directive: ") + +internal fun AbstractNativeSimpleTest.muteTestIfNecessary(testDataFile: File) = muteTestIfNecessary(FileUtil.loadFile(testDataFile)) +internal fun AbstractNativeSimpleTest.muteTestIfNecessary(testDataFileContents: String) { + val pipelineType = testRunSettings.get() + val mutedWhenValues = directiveValues(testDataFileContents, TestDirectives.MUTED_WHEN.name) + Assumptions.assumeFalse(mutedWhenValues.any { it == pipelineType.mutedOption.name }) +} + +internal fun AbstractNativeSimpleTest.freeCompilerArgs(testDataFile: File) = freeCompilerArgs(FileUtil.loadFile(testDataFile)) +internal fun AbstractNativeSimpleTest.freeCompilerArgs(testDataFileContents: String) = + directiveValues(testDataFileContents, TestDirectives.FREE_COMPILER_ARGS.name) diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/TestDirectives.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/TestDirectives.kt index f34469f4a98..21cbdb82faf 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/TestDirectives.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/TestDirectives.kt @@ -133,6 +133,13 @@ internal object TestDirectives : SimpleDirectivesContainer() { Specify a filename containing the LLDB commands and the patterns that the output should match""".trimIndent(), ) + + // TODO "MUTED_WHEN" directive should be supported not only in AbstractNativeSimpleTest, but also in other hierarchies + val MUTED_WHEN by enumDirective( + description = """ + Usage: // MUTED_WHEN: [K1, K2] + In native simple tests, specify the pipeline types to mute the test""".trimIndent(), + ) } internal enum class TestKind { @@ -148,6 +155,11 @@ internal enum class TestRunnerType { NO_EXIT } +internal enum class MutedOption { + K1, + K2 +} + internal class TestCompilerArgs(val compilerArgs: List) { private val uniqueCompilerArgs = compilerArgs.toSet() override fun hashCode() = uniqueCompilerArgs.hashCode() diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/settings/TestProcessSettings.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/settings/TestProcessSettings.kt index 737de1d461c..2be873c8223 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/settings/TestProcessSettings.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/settings/TestProcessSettings.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.konan.blackboxtest.support.settings +import org.jetbrains.kotlin.konan.blackboxtest.support.MutedOption import org.jetbrains.kotlin.konan.blackboxtest.support.TestKind import org.jetbrains.kotlin.konan.blackboxtest.support.runner.LocalTestRunner import org.jetbrains.kotlin.konan.blackboxtest.support.runner.NoopTestRunner @@ -239,9 +240,9 @@ internal sealed interface CacheMode { } } -internal enum class PipelineType(val compilerFlags: List) { - K1(emptyList()), - K2(listOf("-language-version", "2.0")); +internal enum class PipelineType(val mutedOption: MutedOption, val compilerFlags: List) { + K1(MutedOption.K1, emptyList()), + K2(MutedOption.K2, listOf("-language-version", "2.0")); override fun toString() = if (compilerFlags.isEmpty()) "" else compilerFlags.joinToString(prefix = "(", postfix = ")", separator = " ") }