-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filter down to a single non-data class to check for THROW_CCE code
- Loading branch information
1 parent
670d584
commit 32e6999
Showing
1 changed file
with
15 additions
and
6 deletions.
There are no files selected for viewing
21 changes: 15 additions & 6 deletions
21
poko-tests/performance/src/test/kotlin/JsPerformanceTest.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 |
---|---|---|
@@ -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() | ||
} | ||
} | ||
} |