Skip to content

Commit 464a584

Browse files
test: trailing comma management strategy only add
1 parent 8715815 commit 464a584

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import a.*
2+
3+
fun foo(
4+
paramA: String,
5+
paramB: Int,
6+
anotherParamIsHere: Float,
7+
myLongParamNameIsHere: CustomType,
8+
lastParam: Boolean,
9+
) = Unit
10+
11+
fun bar(
12+
myLongParamNameIsHereButDoesNotWrap: Int,
13+
) = Unit
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import a.*
2+
3+
fun foo(paramA: String,paramB : Int , anotherParamIsHere: Float ,myLongParamNameIsHere: CustomType
4+
,lastParam: Boolean ) = Unit
5+
6+
fun bar(
7+
myLongParamNameIsHereButDoesNotWrap: Int,
8+
) = Unit

testlib/src/test/java/com/diffplug/spotless/kotlin/KtfmtStepTest.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,16 @@ void behaviorWithTrailingCommas() throws Exception {
7070
StepHarness.forStep(step).testResource("kotlin/ktfmt/trailing-commas.dirty", "kotlin/ktfmt/trailing-commas.clean");
7171
}
7272

73-
// TODO: test trailing comma only add
73+
@Test
74+
void behaviorWithTrailingCommaManagementStrategyOnlyAdd() {
75+
KtfmtStep.KtfmtFormattingOptions options = new KtfmtStep.KtfmtFormattingOptions();
76+
options.setTrailingCommaManagementStrategy(KtfmtStep.TrailingCommaManagementStrategy.ONLY_ADD);
77+
FormatterStep step = KtfmtStep.create("0.58", TestProvisioner.mavenCentral(), KtfmtStep.Style.KOTLINLANG, options);
78+
StepHarness.forStep(step).testResource(
79+
"kotlin/ktfmt/trailing-commas-only-add.dirty",
80+
"kotlin/ktfmt/trailing-commas-only-add.clean"
81+
);
82+
}
7483

7584
// TODO: test before 0.57
7685

0 commit comments

Comments
 (0)