Skip to content

Commit e92455a

Browse files
committed
Add tests for funtion parameter indentation
1 parent 6f552f7 commit e92455a

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

Tests/SwiftSyntaxBuilderTest/FunctionTests.swift

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,34 @@ final class FunctionTests: XCTestCase {
4242
}
4343
AssertBuildResult(buildable, "test(value1, p2: value2, value3, p4: value4, value5)")
4444
}
45-
45+
46+
func testMultilineFunctionParameterList() {
47+
let builder = FunctionDecl("""
48+
func test(
49+
_ p1: Int,
50+
p2: Int,
51+
_ p3: Int,
52+
p4: Int,
53+
_ p5: Int
54+
) -> Int {
55+
return p1 + p2 + p3 + p4 + p5
56+
}
57+
""")
58+
59+
print(builder.formatted().description)
60+
61+
AssertBuildResult(builder, """
62+
func test(
63+
_ p1: Int,
64+
p2: Int,
65+
_ p3: Int,
66+
p4: Int,
67+
_ p5: Int
68+
) -> Int {
69+
return p1 + p2 + p3 + p4 + p5
70+
}
71+
""")
72+
}
4673
func testParensEmittedForNoArgumentsAndNoTrailingClosure() {
4774
let buildable = FunctionCallExpr(callee: ExprSyntax("test"))
4875
AssertBuildResult(buildable, "test()")

Tests/SwiftSyntaxBuilderTest/InitializerDeclTests.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,32 @@ final class InitializerDeclTests: XCTestCase {
3434
}
3535
""")
3636
}
37+
38+
func testMultilineParameterList() {
39+
let builder = InitializerDecl("""
40+
init(
41+
_ p1: Int,
42+
p2: Int,
43+
_ p3: Int,
44+
p4: Int,
45+
_ p5: Int
46+
) {
47+
self.init(p1 + p2 + p3 + p4 + p5)
48+
}
49+
""")
50+
51+
print(builder.formatted().description)
52+
53+
AssertBuildResult(builder, """
54+
init(
55+
_ p1: Int,
56+
p2: Int,
57+
_ p3: Int,
58+
p4: Int,
59+
_ p5: Int
60+
) {
61+
self.init(p1 + p2 + p3 + p4 + p5)
62+
}
63+
""")
64+
}
3765
}

0 commit comments

Comments
 (0)