Skip to content

Commit

Permalink
rearrange overridee tests into groups
Browse files Browse the repository at this point in the history
  • Loading branch information
neetopia committed Aug 3, 2023
1 parent 5806f0f commit cb01b07
Show file tree
Hide file tree
Showing 15 changed files with 697 additions and 328 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,58 @@ class KSPCompilerPluginTest : AbstractKSPCompilerPluginTest() {
runTest("../test-utils/testData/api/nullableTypes.kt")
}

@TestMetadata("overridee.kt")
@TestMetadata("conflictingOverride.kt")
@Test
fun testOverridee() {
runTest("../test-utils/testData/api/overridee.kt")
fun testConflictingOverride() {
runTest("../test-utils/testData/api/overridee/conflictingOverride.kt")
}

@TestMetadata("javaAccessor.kt")
@Test
fun testJavaAccessor() {
runTest("../test-utils/testData/api/overridee/javaAccessor.kt")
}

@TestMetadata("javaAnno.kt")
@Test
fun testJavaAnno() {
runTest("../test-utils/testData/api/overridee/javaAnno.kt")
}

@TestMetadata("javaOverrideInSource.kt")
@Test
fun testJavaOverrideInSource() {
runTest("../test-utils/testData/api/overridee/javaOverrideInSource.kt")
}

@TestMetadata("noOverride.kt")
@Test
fun testNoOverride() {
runTest("../test-utils/testData/api/overridee/noOverride.kt")
}

@TestMetadata("overrideInLib.kt")
@Test
fun testOverrideInLib() {
runTest("../test-utils/testData/api/overridee/overrideInLib.kt")
}

@TestMetadata("overrideInSource.kt")
@Test
fun testOverrideInSource() {
runTest("../test-utils/testData/api/overridee/overrideInSource.kt")
}

@TestMetadata("overrideOrder.kt")
@Test
fun testOverrideOrder() {
runTest("../test-utils/testData/api/overridee/overrideOrder.kt")
}

@TestMetadata("primaryConstructorOverride.kt")
@Test
fun testPrimaryConstructorOverride() {
runTest("../test-utils/testData/api/overridee/primaryConstructorOverride.kt")
}

@TestMetadata("packageAnnotations.kt")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,59 @@ class KSPAATest : AbstractKSPAATest() {
runTest("../test-utils/testData/api/nullableTypes.kt")
}

@TestMetadata("conflictingOverride.kt")
@Test
fun testConflictingOverride() {
runTest("../test-utils/testData/api/overridee/conflictingOverride.kt")
}

@Disabled
@TestMetadata("overridee.kt")
@TestMetadata("javaAccessor.kt")
@Test
fun testJavaAccessor() {
runTest("../test-utils/testData/api/overridee/javaAccessor.kt")
}

@TestMetadata("javaAnno.kt")
@Test
fun testJavaAnno() {
runTest("testData/overridee/javaAnno.kt")
}

@TestMetadata("javaOverrideInSource.kt")
@Test
fun testJavaOverrideInSource() {
runTest("../test-utils/testData/api/overridee/javaOverrideInSource.kt")
}

@TestMetadata("noOverride.kt")
@Test
fun testNoOverride() {
runTest("../test-utils/testData/api/overridee/noOverride.kt")
}

@TestMetadata("overrideInLib.kt")
@Test
fun testOverrideInLib() {
runTest("../test-utils/testData/api/overridee/overrideInLib.kt")
}

@TestMetadata("overrideInSource.kt")
@Test
fun testOverrideInSource() {
runTest("../test-utils/testData/api/overridee/overrideInSource.kt")
}

@TestMetadata("overrideOrder.kt")
@Test
fun testOverrideOrder() {
runTest("testData/overridee/overrideOrder.kt")
}

@TestMetadata("primaryConstructorOverride.kt")
@Test
fun testOverridee() {
runTest("../test-utils/testData/api/overridee.kt")
fun testPrimaryConstructorOverride() {
runTest("../test-utils/testData/api/overridee/primaryConstructorOverride.kt")
}

@TestMetadata("parameterTypes.kt")
Expand Down
39 changes: 39 additions & 0 deletions kotlin-analysis-api/testData/overridee/javaAnno.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2023 Google LLC
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// WITH_RUNTIME
// TEST PROCESSOR: OverrideeProcessor
// EXPECTED:
// JavaAnno:
// JavaAnno.intParam -> null
// JavaAnnos:
// JavaAnnos.value -> null
// END

// FILE: dummy.kt
class Dummy

// FILE: JavaAnno.java
@java.lang.annotation.Repeatable(JavaAnnos.class)
public @interface JavaAnno {
int intParam();
}

// FILE: JavaAnnos.java
public @interface JavaAnnos {
JavaAnno[] value();
}
47 changes: 47 additions & 0 deletions kotlin-analysis-api/testData/overridee/overrideOrder.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2023 Google LLC
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// WITH_RUNTIME
// TEST PROCESSOR: OverrideeProcessor
// EXPECTED:
// OverrideOrder1:
// OverrideOrder1.foo() -> GrandBaseInterface1.foo()
// OverrideOrder2:
// OverrideOrder2.foo() -> GrandBaseInterface2.foo()
// END

// FILE: overrideOrder.kt
interface GrandBaseInterface1 {
fun foo(): Unit
}

interface GrandBaseInterface2 {
fun foo(): Unit
}

interface BaseInterface1 : GrandBaseInterface1 {
}

interface BaseInterface2 : GrandBaseInterface2 {
}

class OverrideOrder1 : BaseInterface1, GrandBaseInterface2 {
override fun foo() = TODO()
}
class OverrideOrder2 : BaseInterface2, GrandBaseInterface1 {
override fun foo() = TODO()
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class OverrideeProcessor : AbstractTestProcessor() {
}

private fun logSubject(resolver: Resolver, qName: String) {
val subject = resolver.getClassDeclarationByName(qName) ?: return
results.add("$qName:")
val subject = resolver.getClassDeclarationByName(qName)!!
subject.declarations.filterIsInstance<KSClassDeclaration>().forEach {
logClass(it)
}
Expand Down
Loading

0 comments on commit cb01b07

Please sign in to comment.