Skip to content

Commit

Permalink
[Test-only change] Use TEXT_MATCH mode for StatementSwitchToExpressio…
Browse files Browse the repository at this point in the history
…nSwitch direct conversion unit tests involving comment processing

PiperOrigin-RevId: 654746861
  • Loading branch information
markhbrady authored and Error Prone Team committed Jul 22, 2024
1 parent 053f721 commit df5eec2
Showing 1 changed file with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void switchByEnum_removesRedundantBreak_error() {
"}")
.setArgs(
ImmutableList.of("-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion"))
.doTest();
.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
}

@Test
Expand Down Expand Up @@ -196,7 +196,7 @@ public void switchByEnumWithCompletionAnalsis_removesRedundantBreak_error() {
"}")
.setArgs(
ImmutableList.of("-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion"))
.doTest();
.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
}

@Test
Expand Down Expand Up @@ -282,7 +282,7 @@ public void switchByEnumCard_combinesCaseComments_error() {
"}")
.setArgs(
ImmutableList.of("-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion"))
.doTest();
.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
}

@Test
Expand Down Expand Up @@ -328,6 +328,7 @@ public void switchByEnumCard2_removesRedundantBreaks_error() {
" }",
" ",
" public void foo(Side side) { ",
" // BUG: Diagnostic contains: [StatementSwitchToExpressionSwitch]",
" switch(side) {",
" case HEART:",
" System.out.println(\"heart\");",
Expand Down Expand Up @@ -367,7 +368,7 @@ public void switchByEnumCard2_removesRedundantBreaks_error() {
"}")
.setArgs(
ImmutableList.of("-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion"))
.doTest();
.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
}

@Test
Expand Down Expand Up @@ -604,7 +605,7 @@ public void switchWithDefaultInMiddle_error() {
"}")
.setArgs(
ImmutableList.of("-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion"))
.doTest();
.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
}

@Test
Expand Down Expand Up @@ -1155,7 +1156,7 @@ public void switchByEnum_exampleInDocumentation_error() {
" private void bar() {}",
"}")
.setArgs("-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion")
.doTest();
.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
}

@Test
Expand Down Expand Up @@ -1236,7 +1237,7 @@ public void switchByEnum_caseHasOnlyComments_error() {
" private void bar() {}",
"}")
.setArgs("-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion")
.doTest();
.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
}

@Test
Expand Down Expand Up @@ -1298,12 +1299,13 @@ public void switchByEnum_accumulatedComments_error() {
" enum Suit {HEARTS, CLUBS, SPADES, DIAMONDS};",
" public Test() {}",
" private void foo(Suit suit) {",
" // BUG: Diagnostic contains: [StatementSwitchToExpressionSwitch]",
" switch(suit) {",
" case HEARTS, DIAMONDS, SPADES, CLUBS -> {",
" /* red */",
" // A comment here",
" /* red */",
" // more comments.",
" /* red */",
" // Diamonds comment",
" /* black */",
" // Spades comment",
Expand All @@ -1316,7 +1318,7 @@ public void switchByEnum_accumulatedComments_error() {
" private void bar() {}",
"}")
.setArgs("-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion")
.doTest();
.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
}

@Test
Expand Down Expand Up @@ -1384,7 +1386,6 @@ public void switchByEnum_surroundingBracesCannotRemove_error() {
" // The quick brown fox, jumps over the lazy dog, etc.",
" break;",
" }",
" ",
" default -> ",
" throw new RuntimeException(\"Invalid type.\");",
" ",
Expand All @@ -1393,7 +1394,7 @@ public void switchByEnum_surroundingBracesCannotRemove_error() {
"}")
.setArgs(
ImmutableList.of("-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion"))
.doTest();
.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
}

@Test
Expand Down Expand Up @@ -1466,7 +1467,7 @@ public void switchByEnum_surroundingBracesEmpty_error() {
"}")
.setArgs(
ImmutableList.of("-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion"))
.doTest();
.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
}

@Test
Expand Down Expand Up @@ -1502,8 +1503,7 @@ public void switchByEnum_afterReturnComments_error() {
"Test.java",
"class Test {",
" enum Suit {HEART, SPADE, DIAMOND, CLUB};",
" public Test(int foo) {",
" }",
" public Test(int foo) {}",
" ",
" public int foo(Suit suit) { ",
" // BUG: Diagnostic contains: [StatementSwitchToExpressionSwitch]",
Expand All @@ -1524,7 +1524,9 @@ public void switchByEnum_afterReturnComments_error() {
"class Test {",
" enum Suit {HEART, SPADE, DIAMOND, CLUB};",
" public Test(int foo) {}",
" ",
" public int foo(Suit suit) {",
" // BUG: Diagnostic contains: [StatementSwitchToExpressionSwitch]",
" switch(suit) {",
" case HEART -> {",
" // before return comment",
Expand All @@ -1540,7 +1542,7 @@ public void switchByEnum_afterReturnComments_error() {
" }",
"}")
.setArgs("-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion")
.doTest();
.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
}

/**********************************
Expand Down

0 comments on commit df5eec2

Please sign in to comment.