Skip to content

Commit

Permalink
Fix JsPerformanceTest
Browse files Browse the repository at this point in the history
Filter down to a single non-data class to check for THROW_CCE code
  • Loading branch information
drewhamilton committed Jan 30, 2025
1 parent 670d584 commit 32e6999
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions poko-tests/performance/src/test/kotlin/JsPerformanceTest.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import assertk.all

import assertk.assertAll
import assertk.assertThat
import assertk.assertions.contains
import assertk.assertions.doesNotContain
import assertk.assertions.hasSize
import assertk.assertions.isEmpty
import org.junit.Test

class JsPerformanceTest {
@Test fun `equals does not perform redundant instanceof check`() {
val javascript = jsOutput().readText()
assertThat(javascript).all {
contains("other instanceof IntAndLong")
doesNotContain("THROW_CCE")

// Hack to filter out data classes, which do have the `THROW_CCE` code:
val intAndLongLines = javascript.split("\n").filter { it.contains("IntAndLong") }
assertAll {
assertThat(
actual = intAndLongLines.filter { it.contains("other instanceof IntAndLong") },
).hasSize(1)

assertThat(
actual = intAndLongLines.filter { it.contains("THROW_CCE") },
).isEmpty()
}
}
}

0 comments on commit 32e6999

Please sign in to comment.