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

[Test-only change] Use TEXT_MATCH mode for StatementSwitchToExpressionSwitch direct conversion unit tests involving comment processing #4484

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading