-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate performacne tests to occur on tests project
This will open up the ability to assert on JS and native which simply isn't possible with the Kotlin Compiler Testing infrastructure.
- Loading branch information
1 parent
83952e6
commit 47b1688
Showing
8 changed files
with
42 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |
16 changes: 16 additions & 0 deletions
16
poko-tests/performance/src/test/kotlin/JvmPerformanceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} | ||
} | ||
} |
2 changes: 0 additions & 2 deletions
2
.../test/kotlin/dev/drewhamilton/poko/asm.kt → ...-tests/performance/src/test/kotlin/asm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import java.io.File | ||
|
||
fun jvmOutput(relativePath: String) = File("../build/classes/kotlin/jvm/main", relativePath) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package performance | ||
|
||
import dev.drewhamilton.poko.Poko | ||
|
||
@Suppress("unused") | ||
@Poko class IntAndLong( | ||
val int: Int, | ||
val long: Long, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,5 @@ include( | |
":poko-annotations", | ||
":poko-gradle-plugin", | ||
":poko-tests", | ||
":poko-tests:performance", | ||
) |