Skip to content

Commit

Permalink
Add test case for a constant true guard
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Pine committed Apr 7, 2024
1 parent 1ba6ecf commit 2d426f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,16 @@ public void testSimpleSealedHierarchyExhaustive() throws Exception {
assertEquals(2, paths.size());
}

@Test
public void testConstantGuardExhaustive() throws Exception {
ControlFlowGraph graph = testMethod("enhancedSwitchExhaustiveConstantTrueGuard", true, null, null, null);
graph.simplify();
ControlFlowPathHelper pathHelper = new ControlFlowPathHelper();
ControlFlowNode entryNode = graph.findNodesOfKind(BEGIN).get(0);
List<List<ControlFlowNode>> paths = pathHelper.paths(entryNode);
assertEquals(2, paths.size());
}

@Test
public void testComplexSealedHierarchyExhaustive() throws Exception {
ControlFlowGraph graph = testMethod("enhancedSwitchMultilevelSealedExhaustive", true, null, null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,13 @@ static int enhancedSwitchSealedExhaustive(I i) {
};
}

static int enhancedSwitchExhaustiveConstantTrueGuard(I i) {
switch (i) {
case A a when 1 < 2 -> {}
case R r -> {}
};
}

static int enhancedSwitchMultilevelSealedExhaustive(I i) {
switch (i) {
case B b -> {}
Expand Down

0 comments on commit 2d426f4

Please sign in to comment.