Skip to content

Commit 3c8827d

Browse files
committed
Add tests for tuple element indentation
1 parent e92455a commit 3c8827d

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

Tests/SwiftSyntaxBuilderTest/FunctionTests.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,31 @@ final class FunctionTests: XCTestCase {
7070
}
7171
""")
7272
}
73+
74+
func testMultilineFunctionCallExpr() {
75+
let builder = FunctionCallExpr("""
76+
test(
77+
p1: value1,
78+
p2: value2,
79+
p3: value3,
80+
p4: value4,
81+
p5: value5
82+
)
83+
""")
84+
85+
print(builder.formatted().description)
86+
87+
AssertBuildResult(builder, """
88+
test(
89+
p1: value1,
90+
p2: value2,
91+
p3: value3,
92+
p4: value4,
93+
p5: value5
94+
)
95+
""")
96+
}
97+
7398
func testParensEmittedForNoArgumentsAndNoTrailingClosure() {
7499
let buildable = FunctionCallExpr(callee: ExprSyntax("test"))
75100
AssertBuildResult(buildable, "test()")
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2022 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import XCTest
14+
import SwiftSyntax
15+
import SwiftSyntaxBuilder
16+
17+
final class TupleTests: XCTestCase {
18+
func testLabeledElementList() {
19+
let builder = TupleExprSyntax("(p1: value1, p2: value2, p3: value3)")
20+
21+
print(builder.formatted().description)
22+
23+
AssertBuildResult(builder, "(p1: value1, p2: value2, p3: value3)")
24+
}
25+
26+
func testMultilineElementList() {
27+
let builder = TupleExprSyntax("""
28+
(
29+
p1: value1,
30+
p2: value2,
31+
p3: value3,
32+
p4: value4,
33+
p5: value5
34+
)
35+
""")
36+
37+
print(builder.formatted().description)
38+
39+
AssertBuildResult(builder, """
40+
(
41+
p1: value1,
42+
p2: value2,
43+
p3: value3,
44+
p4: value4,
45+
p5: value5
46+
)
47+
""")
48+
}
49+
}

0 commit comments

Comments
 (0)