Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix validation test for Java 21 #1422

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*******************************************************************************/
package org.jacoco.core.test.validation.java20;

import org.jacoco.core.test.validation.JavaVersion;
import org.jacoco.core.test.validation.Source.Line;
import org.jacoco.core.test.validation.ValidationTestBase;
import org.jacoco.core.test.validation.java20.targets.RecordPatternsTarget;

Expand All @@ -24,4 +26,22 @@ public RecordPatternsTest() {
super(RecordPatternsTarget.class);
}

public void assertSwitchStatementCase(Line line) {
if (JavaVersion.current().isBefore("21")) {
assertFullyCovered(line);
} else {
// https://github.com/openjdk/jdk/commit/138cdc9283ae8f3367e51f0fe7e27833118dd7cb
assertPartlyCovered(line);
}
}

public void assertSwitchStatementDefault(Line line) {
if (JavaVersion.current().isBefore("21")) {
assertPartlyCovered(line);
} else {
// https://github.com/openjdk/jdk/commit/138cdc9283ae8f3367e51f0fe7e27833118dd7cb
assertFullyCovered(line);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ private static void instanceofOperator(Object o) {

private static void switchStatement(Object p) {
switch (p) { // assertFullyCovered(0, 2)
case Point(int x, int y) -> nop(x + y); // assertFullyCovered()
default -> nop(); // assertPartlyCovered()
case Point(int x, int y) -> nop(x + y); // assertSwitchStatementCase()
default -> nop(); // assertSwitchStatementDefault()
} // assertEmpty()
}

Expand Down