Skip to content

Commit

Permalink
Fix validation test for Java 21 (#1422)
Browse files Browse the repository at this point in the history
  • Loading branch information
Godin committed Mar 31, 2023
1 parent 461ebf3 commit c561c13
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
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

0 comments on commit c561c13

Please sign in to comment.