Add ClassBuilderMode.KAPT3 tests

This commit is contained in:
Yan Zhulanow
2017-02-17 16:15:02 +03:00
parent e25e19c4d6
commit 7a5f94129c
17 changed files with 290 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
data class User(val name: String, val age: Int)
+15
View File
@@ -0,0 +1,15 @@
@kotlin.Metadata
public final class User {
private final field age: int
private final @org.jetbrains.annotations.NotNull field name: java.lang.String
public method <init>(@org.jetbrains.annotations.NotNull p0: java.lang.String, p1: int): void
public final @org.jetbrains.annotations.NotNull method component1(): java.lang.String
public final method component2(): int
public synthetic static @org.jetbrains.annotations.NotNull method copy$default(p0: User, p1: java.lang.String, p2: int, p3: int, p4: java.lang.Object): User
public final @org.jetbrains.annotations.NotNull method copy(@org.jetbrains.annotations.NotNull p0: java.lang.String, p1: int): User
public method equals(p0: java.lang.Object): boolean
public final method getAge(): int
public final @org.jetbrains.annotations.NotNull method getName(): java.lang.String
public method hashCode(): int
public method toString(): java.lang.String
}
+4
View File
@@ -0,0 +1,4 @@
@Suppress("UNRESOLVED_REFERENCE")
class A {
val a: ABC = null
}
+7
View File
@@ -0,0 +1,7 @@
@kotlin.Metadata
@kotlin.Suppress
public final class A {
private final @org.jetbrains.annotations.NotNull field a: error.NonExistentClass
public method <init>(): void
public final @org.jetbrains.annotations.NotNull method getA(): error.NonExistentClass
}
+26
View File
@@ -0,0 +1,26 @@
// WITH_RUNTIME
package test
class TopLevel {
companion object {
fun a() {}
@JvmStatic
val q = "A"
}
fun b() {}
val x: String
val y = 5
class NestedClass {
inner class NestedInnerClass
}
object InnerObject
interface InnerInterface
}
+52
View File
@@ -0,0 +1,52 @@
@kotlin.Metadata
public final class test/TopLevel {
public final static field Companion: test.TopLevel.Companion
private final static @org.jetbrains.annotations.NotNull field q: java.lang.String
private final @org.jetbrains.annotations.NotNull field x: java.lang.String
private final field y: int
inner class test/TopLevel/Companion
inner class test/TopLevel/InnerInterface
inner class test/TopLevel/InnerObject
inner class test/TopLevel/NestedClass
public method <init>(): void
public final method b(): void
public final static @org.jetbrains.annotations.NotNull method getQ(): java.lang.String
public final @org.jetbrains.annotations.NotNull method getX(): java.lang.String
public final method getY(): int
}
@kotlin.Metadata
public final class test/TopLevel/Companion {
inner class test/TopLevel/Companion
private method <init>(): void
public final method a(): void
public final @org.jetbrains.annotations.NotNull method getQ(): java.lang.String
public synthetic deprecated static @kotlin.jvm.JvmStatic method q$annotations(): void
}
@kotlin.Metadata
public interface test/TopLevel/InnerInterface {
inner class test/TopLevel/InnerInterface
}
@kotlin.Metadata
public final class test/TopLevel/InnerObject {
public final static field INSTANCE: test.TopLevel.InnerObject
inner class test/TopLevel/InnerObject
private method <init>(): void
}
@kotlin.Metadata
public final class test/TopLevel/NestedClass {
inner class test/TopLevel/NestedClass
inner class test/TopLevel/NestedClass/NestedInnerClass
public method <init>(): void
}
@kotlin.Metadata
public final class test/TopLevel/NestedClass/NestedInnerClass {
synthetic final field this$0: test.TopLevel.NestedClass
inner class test/TopLevel/NestedClass
inner class test/TopLevel/NestedClass/NestedInnerClass
public method <init>(p0: test.TopLevel.NestedClass): void
}
+8
View File
@@ -0,0 +1,8 @@
interface A {
fun a() {}
fun b()
}
interface B {
fun b()
}
+17
View File
@@ -0,0 +1,17 @@
@kotlin.Metadata
public interface A {
inner class A/DefaultImpls
public abstract method a(): void
public abstract method b(): void
}
@kotlin.Metadata
public final class A/DefaultImpls {
inner class A/DefaultImpls
public static method a(p0: A): void
}
@kotlin.Metadata
public interface B {
public abstract method b(): void
}
+6
View File
@@ -0,0 +1,6 @@
// WITH_RUNTIME
class Test {
@JvmOverloads
fun b(s: String = "A", i: Int = 5, c: Char = 'c') {}
}
+9
View File
@@ -0,0 +1,9 @@
@kotlin.Metadata
public final class Test {
public method <init>(): void
public synthetic static @kotlin.jvm.JvmOverloads method b$default(p0: Test, p1: java.lang.String, p2: int, p3: char, p4: int, p5: java.lang.Object): void
public final @kotlin.jvm.JvmOverloads @synthetic.kotlin.jvm.GeneratedByJvmOverloads method b(): void
public final @kotlin.jvm.JvmOverloads @synthetic.kotlin.jvm.GeneratedByJvmOverloads method b(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
public final @kotlin.jvm.JvmOverloads @synthetic.kotlin.jvm.GeneratedByJvmOverloads method b(@org.jetbrains.annotations.NotNull p0: java.lang.String, p1: int): void
public final @kotlin.jvm.JvmOverloads method b(@org.jetbrains.annotations.NotNull p0: java.lang.String, p1: int, p2: char): void
}
+5
View File
@@ -0,0 +1,5 @@
fun a() = run {
""
}
fun <R> run(block: () -> R): R = block()
+5
View File
@@ -0,0 +1,5 @@
@kotlin.Metadata
public final class LambdasKt {
public final static @org.jetbrains.annotations.NotNull method a(): java.lang.String
public final static method run(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.Object
}
+1
View File
@@ -0,0 +1 @@
class Simple
+4
View File
@@ -0,0 +1,4 @@
@kotlin.Metadata
public final class Simple {
public method <init>(): void
}
@@ -0,0 +1,46 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* 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.
*/
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
import org.jetbrains.kotlin.resolve.jvm.extensions.PartialAnalysisHandlerExtension
import org.jetbrains.kotlin.test.KotlinTestUtils
import java.io.File
abstract class AbstractKapt3BuilderModeBytecodeShapeTest : CodegenTestCase() {
private companion object {
var TEST_LIGHT_ANALYSIS: ClassBuilderFactory = object : ClassBuilderFactories.TestClassBuilderFactory(false) {
override fun getClassBuilderMode() = ClassBuilderMode.KAPT3
}
}
override fun doMultiFileTest(wholeFile: File, files: MutableList<TestFile>, javaFilesDir: File?) {
val txtFile = File(wholeFile.parentFile, wholeFile.nameWithoutExtension + ".txt")
KotlinTestUtils.assertEqualsToFile(txtFile, compile(files, javaFilesDir))
}
private fun compile(files: List<TestFile>, javaFilesDir: File?): String {
val classFileFactory = AbstractBytecodeListingTest.compileClasses(
testRootDisposable, files, javaFilesDir,
TEST_LIGHT_ANALYSIS,
setupEnvironment = { env -> AnalysisHandlerExtension.registerExtension(env.project, PartialAnalysisHandlerExtension()) }
)
return BytecodeListingTextCollectingVisitor.getText(classFileFactory)
}
}
@@ -0,0 +1,80 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* 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.
*/
package org.jetbrains.kotlin.codegen;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/codegen/kapt")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class Kapt3BuilderModeBytecodeShapeTestGenerated extends AbstractKapt3BuilderModeBytecodeShapeTest {
public void testAllFilesPresentInKapt() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/kapt"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("dataClass.kt")
public void testDataClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/kapt/dataClass.kt");
doTest(fileName);
}
@TestMetadata("errorTypes.kt")
public void testErrorTypes() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/kapt/errorTypes.kt");
doTest(fileName);
}
@TestMetadata("innerClasses.kt")
public void testInnerClasses() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/kapt/innerClasses.kt");
doTest(fileName);
}
@TestMetadata("interfaceImpls.kt")
public void testInterfaceImpls() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/kapt/interfaceImpls.kt");
doTest(fileName);
}
@TestMetadata("jvmOverloads.kt")
public void testJvmOverloads() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/kapt/jvmOverloads.kt");
doTest(fileName);
}
@TestMetadata("lambdas.kt")
public void testLambdas() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/kapt/lambdas.kt");
doTest(fileName);
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/kapt/simple.kt");
doTest(fileName);
}
}
@@ -242,6 +242,10 @@ fun main(args: Array<String>) {
model("codegen/box", targetBackend = TargetBackend.JVM)
}
testClass<AbstractKapt3BuilderModeBytecodeShapeTest> {
model("codegen/kapt", targetBackend = TargetBackend.JVM)
}
testClass<AbstractIrBlackBoxCodegenTest>("IrOnlyBoxCodegenTestGenerated") {
model("ir/box", targetBackend = TargetBackend.JVM)
}