Skip to content

Commit

Permalink
Fix some tests to be compatible with K2 (#3086)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmishenev committed Jul 26, 2023
1 parent 900fbcc commit 2c01749
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class ContentForAnnotationsTest : BaseAbstractTest() {
|
|@MustBeDocumented
|@Retention(AnnotationRetention.SOURCE)
|@Target(AnnotationTarget.FIELD)
|@Target(AnnotationTarget.PROPERTY)
|annotation class BugReport(
| val assignedTo: String = "[none]",
| val testCase: KClass<ABC> = ABC::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class KotlinDeprecatedTest : BaseAbstractTest() {
testInline(
"""
|/src/main/kotlin/kotlin/KotlinFile.kt
|package kotlin
|package deprecated
|
|@Deprecated(
| message = "Fancy message"
Expand All @@ -44,7 +44,7 @@ class KotlinDeprecatedTest : BaseAbstractTest() {
) {
documentablesTransformationStage = { module ->
val deprecatedFunction = module.children
.single { it.name == "kotlin" }.children
.single { it.name == "deprecated" }.children
.single { it.name == "simpleFunction" }

val isDeprecated = (deprecatedFunction as WithExtraProperties<out Documentable>).isDeprecated()
Expand All @@ -65,7 +65,7 @@ class KotlinDeprecatedTest : BaseAbstractTest() {
testInline(
"""
|/src/main/kotlin/kotlin/DeprecatedKotlin.kt
|package kotlin
|package deprecated
|
|/**
| * Average function description
Expand All @@ -84,7 +84,7 @@ class KotlinDeprecatedTest : BaseAbstractTest() {
) {
pagesTransformationStage = { module ->
val functionWithDeprecatedFunction = module.children
.single { it.name == "kotlin" }.children
.single { it.name == "deprecated" }.children
.single { it.name == "oldLegacyFunction" } as ContentPage

functionWithDeprecatedFunction.content.assertNode {
Expand Down Expand Up @@ -130,7 +130,7 @@ class KotlinDeprecatedTest : BaseAbstractTest() {
testInline(
"""
|/src/main/kotlin/kotlin/DeprecatedKotlin.kt
|package kotlin
|package deprecated
|
|/**
| * Average function description
Expand All @@ -156,7 +156,7 @@ class KotlinDeprecatedTest : BaseAbstractTest() {
) {
pagesTransformationStage = { module ->
val functionWithDeprecatedFunction = module.children
.single { it.name == "kotlin" }.children
.single { it.name == "deprecated" }.children
.single { it.name == "oldLegacyFunction" } as ContentPage

functionWithDeprecatedFunction.content.assertNode {
Expand Down Expand Up @@ -217,7 +217,7 @@ class KotlinDeprecatedTest : BaseAbstractTest() {
testInline(
"""
|/src/main/kotlin/kotlin/DeprecatedKotlin.kt
|package kotlin
|package deprecated
|
|/**
| * Average function description
Expand All @@ -240,7 +240,7 @@ class KotlinDeprecatedTest : BaseAbstractTest() {
) {
pagesTransformationStage = { module ->
val functionWithDeprecatedFunction = module.children
.single { it.name == "kotlin" }.children
.single { it.name == "deprecated" }.children
.single { it.name == "oldLegacyFunction" } as ContentPage

functionWithDeprecatedFunction.content.assertNode {
Expand Down Expand Up @@ -298,7 +298,7 @@ class KotlinDeprecatedTest : BaseAbstractTest() {
testInline(
"""
|/src/main/kotlin/kotlin/DeprecatedKotlin.kt
|package kotlin
|package deprecated
|
|/**
| * Average function description
Expand Down Expand Up @@ -330,7 +330,7 @@ class KotlinDeprecatedTest : BaseAbstractTest() {
) {
pagesTransformationStage = { module ->
val functionWithDeprecatedFunction = module.children
.single { it.name == "kotlin" }.children
.single { it.name == "deprecated" }.children
.single { it.name == "oldLegacyFunction" } as ContentPage

functionWithDeprecatedFunction.content.assertNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ class KotlinArrayDocumentableReplacerTest : BaseAbstractTest() {
}
}
}

// Unreal case: Upper bound of a type parameter cannot be an array
@Test
fun `generic fun and class`() {
testInline(
Expand All @@ -138,7 +140,7 @@ class KotlinArrayDocumentableReplacerTest : BaseAbstractTest() {
|package example
|
|fun<T : Array<Int>> testFunction() { }
|class<T : Array<Int>> myTestClass{ }
|class myTestClass<T : Array<Int>>{ }
|
|
""".trimMargin(),
Expand Down
11 changes: 6 additions & 5 deletions plugins/base/src/test/kotlin/model/ClassesTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,12 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
| value class InlineTest(val x: String)
""".trimMargin()
) {
val classlike = packages.flatMap { it.classlikes }.first() as DClass
classlike.name equals "X"
classlike.properties.first().name equals "example"
classlike.extra[AdditionalModifiers]?.content?.values?.firstOrNull()
?.firstOrNull() equals ExtraModifiers.KotlinOnlyModifiers.Inline
with((this / "classes" / "X").cast<DClass>()) {
name equals "X"
properties.first().name equals "example"
extra[AdditionalModifiers]?.content?.values?.firstOrNull()
?.firstOrNull() equals ExtraModifiers.KotlinOnlyModifiers.Inline
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ val soapXml = node("soap-env:Envelope", soapAttrs,
)
assertEquals(
testSuite.additionalModifiers,
extra[AdditionalModifiers]?.content?.values?.single(),
extra[AdditionalModifiers]?.content?.values?.single() ?: emptySet<ExtraModifiers>(),
"Test for class ${classlike.name} with property $name failed"
)
}
Expand All @@ -213,7 +213,7 @@ val soapXml = node("soap-env:Envelope", soapAttrs,
)
assertEquals(
testSuite.additionalModifiers,
extra[AdditionalModifiers]?.content?.values?.single(),
extra[AdditionalModifiers]?.content?.values?.single() ?: emptySet<ExtraModifiers>(),
"Test for class ${classlike.name} with function $name failed"
)
}
Expand Down

0 comments on commit 2c01749

Please sign in to comment.