[Java. Code Formatting] Add new tests to JavaFormatterNewLineAfterLBraceTest

IDEA-165216

GitOrigin-RevId: 313a43a7c081c604ca96be3b68f231a18d998650
This commit is contained in:
Georgii Ustinov
2024-07-29 15:18:41 +03:00
committed by intellij-monorepo-bot
parent 59fc2e4a19
commit c9243c5975
11 changed files with 112 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
import java.time.LocalDateTime;
import java.time.Month;
public class Main {
private static final LocalDateTime localDateTime = LocalDateTime.of(2017, Month.NOVEMBER, 1, 2, 3);
public void foo(int longArgument1, int longArgument2, int longArgument3, int short4, int receiver1) {
}
}

View File

@@ -0,0 +1,19 @@
import java.time.LocalDateTime;
import java.time.Month;
public class Main {
private static final LocalDateTime localDateTime = LocalDateTime.of(
2017,
Month.NOVEMBER,
1,
2,
3);
public void foo(
int longArgument1,
int longArgument2,
int longArgument3,
int short4,
int receiver1) {
}
}

View File

@@ -0,0 +1,9 @@
import java.time.LocalDateTime;
import java.time.Month;
public class Main {
private static final LocalDateTime localDateTime = LocalDateTime.of(2017, Month.NOVEMBER, 1, 2, 3);
public void foo(int longArgument1, int longArgument2, int longArgument3, int short4, int receiver1, int receiver3) {
}
}

View File

@@ -0,0 +1,20 @@
import java.time.LocalDateTime;
import java.time.Month;
public class Main {
private static final LocalDateTime localDateTime = LocalDateTime.of(
2017,
Month.NOVEMBER,
1,
2,
3);
public void foo(
int longArgument1,
int longArgument2,
int longArgument3,
int short4,
int receiver1,
int receiver3) {
}
}

View File

@@ -2,4 +2,7 @@ public class Test {
public void foo1(int... args) {
foo1(100000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000);
}
public void foo(int longArgument1, byte longArgument2, short short1, double double1, float float1, long long1, Short short2) {
}
}

View File

@@ -4,4 +4,9 @@ public class Test {
100000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000,
10000);
}
public void foo(
int longArgument1, byte longArgument2, short short1, double double1, float float1,
long long1, Short short2) {
}
}

View File

@@ -0,0 +1,8 @@
public class Test {
public void foo1(int... args) {
foo1(100000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000);
}
public void foo(int longArgument1, byte longArgument2, short short1, double double1, float float1, long long1, Short short2) {
}
}

View File

@@ -0,0 +1,12 @@
public class Test {
public void foo1(int... args) {
foo1(
100000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000,
10000);
}
public void foo(
int longArgument1, byte longArgument2, short short1, double double1, float float1,
long long1, Short short2) {
}
}

View File

@@ -14,6 +14,8 @@ class JavaFormatterNewLineAfterLBraceTest : JavaFormatterTestCase() {
super.setUp()
commonSettings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE = true
commonSettings.METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE = true
commonSettings.ALIGN_MULTILINE_PARAMETERS = false
commonSettings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = false
commonSettings.RIGHT_MARGIN = 100
}
@@ -44,21 +46,44 @@ class JavaFormatterNewLineAfterLBraceTest : JavaFormatterTestCase() {
}
fun testWrapAsNeedMultipleLines() {
commonSettings.CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED
setupWrapType(CommonCodeStyleSettings.WRAP_AS_NEEDED)
doIdempotentTest()
}
fun testMultipleCalls() {
fun testMultipleEntities() {
setupWrapType(CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM)
doIdempotentTest()
}
fun testWrapAlwaysRespectAlignWhenMultiline() {
setupWrapType(CommonCodeStyleSettings.WRAP_ALWAYS)
setupAlignWhenMultiline()
doIdempotentTest()
}
fun testWrapAsNeededRespectAlignWhenMultiline() {
setupWrapType(CommonCodeStyleSettings.WRAP_AS_NEEDED)
setupAlignWhenMultiline()
doIdempotentTest()
}
fun testChopDownIfLongRespectAlignWhenMultiline() {
setupWrapType(CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM)
setupAlignWhenMultiline()
doIdempotentTest()
}
private fun doIdempotentTest() {
val testName = getTestName(false)
doTest(testName, "${testName}_after")
doTest("${testName}_after", "${testName}_after")
}
private fun setupAlignWhenMultiline() {
commonSettings.ALIGN_MULTILINE_PARAMETERS = true
commonSettings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true
}
private fun setupWrapType(wrapType: Int) {
commonSettings.CALL_PARAMETERS_WRAP = wrapType
commonSettings.METHOD_PARAMETERS_WRAP = wrapType