Skip to content

Commit c561c13

Browse files
authored
Fix validation test for Java 21 (#1422)
1 parent 461ebf3 commit c561c13

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

org.jacoco.core.test.validation.java20/src/org/jacoco/core/test/validation/java20/RecordPatternsTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
*******************************************************************************/
1313
package org.jacoco.core.test.validation.java20;
1414

15+
import org.jacoco.core.test.validation.JavaVersion;
16+
import org.jacoco.core.test.validation.Source.Line;
1517
import org.jacoco.core.test.validation.ValidationTestBase;
1618
import org.jacoco.core.test.validation.java20.targets.RecordPatternsTarget;
1719

@@ -24,4 +26,22 @@ public RecordPatternsTest() {
2426
super(RecordPatternsTarget.class);
2527
}
2628

29+
public void assertSwitchStatementCase(Line line) {
30+
if (JavaVersion.current().isBefore("21")) {
31+
assertFullyCovered(line);
32+
} else {
33+
// https://github.com/openjdk/jdk/commit/138cdc9283ae8f3367e51f0fe7e27833118dd7cb
34+
assertPartlyCovered(line);
35+
}
36+
}
37+
38+
public void assertSwitchStatementDefault(Line line) {
39+
if (JavaVersion.current().isBefore("21")) {
40+
assertPartlyCovered(line);
41+
} else {
42+
// https://github.com/openjdk/jdk/commit/138cdc9283ae8f3367e51f0fe7e27833118dd7cb
43+
assertFullyCovered(line);
44+
}
45+
}
46+
2747
}

org.jacoco.core.test.validation.java20/src/org/jacoco/core/test/validation/java20/targets/RecordPatternsTarget.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ private static void instanceofOperator(Object o) {
3131

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

0 commit comments

Comments
 (0)