diff --git a/poko-compiler-plugin/build.gradle.kts b/poko-compiler-plugin/build.gradle.kts index 733056aa..6bc03d82 100644 --- a/poko-compiler-plugin/build.gradle.kts +++ b/poko-compiler-plugin/build.gradle.kts @@ -23,7 +23,6 @@ dependencies { testImplementation(libs.kotlin.compileTesting) testImplementation(libs.junit) testImplementation(libs.assertk) - testImplementation(libs.asm.util) testImplementation(libs.testParameterInjector) } diff --git a/poko-compiler-plugin/src/test/kotlin/dev/drewhamilton/poko/PokoCompilerPluginTest.kt b/poko-compiler-plugin/src/test/kotlin/dev/drewhamilton/poko/PokoCompilerPluginTest.kt index 56a75496..61db88d9 100644 --- a/poko-compiler-plugin/src/test/kotlin/dev/drewhamilton/poko/PokoCompilerPluginTest.kt +++ b/poko-compiler-plugin/src/test/kotlin/dev/drewhamilton/poko/PokoCompilerPluginTest.kt @@ -130,21 +130,6 @@ class PokoCompilerPluginTest( } //endregion - //region Performance optimizations - @Test fun `int property does not emit hashCode method invocation`() { - testCompilation( - "api/Primitives", - ) { - val classFile = it.generatedFiles.single { it.name.endsWith(".class") } - val bytecode = bytecodeToText(classFile.readBytes()) - assertThat(bytecode).all { - contains("java/lang/Long.hashCode") - doesNotContain("java/lang/Integer.hashCode") - } - } - } - //endregion - private inline fun testCompilation( vararg sourceFileNames: String, pokoAnnotationName: String = "dev/drewhamilton/poko/Poko", diff --git a/poko-tests/performance/build.gradle.kts b/poko-tests/performance/build.gradle.kts new file mode 100644 index 00000000..49ca9552 --- /dev/null +++ b/poko-tests/performance/build.gradle.kts @@ -0,0 +1,13 @@ +plugins { + alias(libs.plugins.kotlin.jvm) +} + +dependencies { + testImplementation(libs.junit) + testImplementation(libs.assertk) + testImplementation(libs.asm.util) +} + +tasks.named("test") { + dependsOn(":poko-tests:compileKotlinJvm") +} diff --git a/poko-tests/performance/src/test/kotlin/JvmPerformanceTest.kt b/poko-tests/performance/src/test/kotlin/JvmPerformanceTest.kt new file mode 100644 index 00000000..2b370bc2 --- /dev/null +++ b/poko-tests/performance/src/test/kotlin/JvmPerformanceTest.kt @@ -0,0 +1,16 @@ +import assertk.all +import assertk.assertThat +import assertk.assertions.contains +import assertk.assertions.doesNotContain +import org.junit.Test + +class JvmPerformanceTest { + @Test fun `int property does not emit hashCode method invocation`() { + val classfile = jvmOutput("performance/IntAndLong.class") + val bytecode = bytecodeToText(classfile.readBytes()) + assertThat(bytecode).all { + contains("java/lang/Long.hashCode") + doesNotContain("java/lang/Integer.hashCode") + } + } +} diff --git a/poko-compiler-plugin/src/test/kotlin/dev/drewhamilton/poko/asm.kt b/poko-tests/performance/src/test/kotlin/asm.kt similarity index 93% rename from poko-compiler-plugin/src/test/kotlin/dev/drewhamilton/poko/asm.kt rename to poko-tests/performance/src/test/kotlin/asm.kt index 2b1824e6..773bc14e 100644 --- a/poko-compiler-plugin/src/test/kotlin/dev/drewhamilton/poko/asm.kt +++ b/poko-tests/performance/src/test/kotlin/asm.kt @@ -1,5 +1,3 @@ -package dev.drewhamilton.poko - import java.io.PrintWriter import java.io.StringWriter import org.objectweb.asm.ClassReader diff --git a/poko-tests/performance/src/test/kotlin/sources.kt b/poko-tests/performance/src/test/kotlin/sources.kt new file mode 100644 index 00000000..a4942a54 --- /dev/null +++ b/poko-tests/performance/src/test/kotlin/sources.kt @@ -0,0 +1,3 @@ +import java.io.File + +fun jvmOutput(relativePath: String) = File("../build/classes/kotlin/jvm/main", relativePath) diff --git a/poko-tests/src/commonMain/kotlin/performance/IntAndLong.kt b/poko-tests/src/commonMain/kotlin/performance/IntAndLong.kt new file mode 100644 index 00000000..c54f2c29 --- /dev/null +++ b/poko-tests/src/commonMain/kotlin/performance/IntAndLong.kt @@ -0,0 +1,9 @@ +package performance + +import dev.drewhamilton.poko.Poko + +@Suppress("unused") +@Poko class IntAndLong( + val int: Int, + val long: Long, +) diff --git a/settings.gradle.kts b/settings.gradle.kts index 43489085..44471528 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -20,4 +20,5 @@ include( ":poko-annotations", ":poko-gradle-plugin", ":poko-tests", + ":poko-tests:performance", )