Add validation test for Kotlin empty when - #2248
Open
Eljees wants to merge 1 commit into
Open
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2039
Adds a validation test for empty
when.Kotlin in this module is 2.4.10, i.e. after KT-82844,
so the subject of an empty
whenis evaluated. The test pins down three distinct cases:when (a++) {}IINC 1 1assertFullyCovered()when (a) {}NOPassertFullyCovered()when {}(no subject)assertEmpty()The second row is the non-obvious one: even when the subject has no side effect, the
compiler still emits a single
NOPattributed to that line, so the line is reported ascovered rather than empty.
Bytecode of the two subject cases (
javap-style dump produced by the validation harness):when {}produces no line number entry at all, henceassertEmpty().Verification
The naive expectation — that an empty
whenexecutes nothing — fails on two of the threelines, which is what makes the test worth having:
With the assertions as committed:
Tests run: 6, Failures: 0.Full module run for regressions:
Tests run: 293, Failures: 0, Errors: 0, Skipped: 0(
mvn -pl org.jacoco.core.test.validation.kotlin test -Djdk.version=21 -Dbytecode.version=21,Temurin 21.0.11, Maven 3.9.16 — same version as
.mvn/wrapper).spotless:applyleaves both new files unchanged.