Skip to content

Commit 3411f31

Browse files
committed
Add test case for closure parameters
1 parent a6891c3 commit 3411f31

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

Tests/SourceKitLSPTests/InlayHintsTests.swift

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,5 +169,33 @@ final class InlayHintsTests: XCTestCase {
169169
XCTAssertEqual(hints, [])
170170
}
171171

172-
// TODO: Add test for closure parameters
172+
func testClosureParams() {
173+
let text = """
174+
func f(x: Int) {}
175+
176+
let g = { (x: Int) in }
177+
let h: (String) -> String = { x in x }
178+
let i: (Double, Double) -> Double = { (x, y) in
179+
x + y
180+
}
181+
"""
182+
let hints = performInlayHintsRequest(text: text)
183+
XCTAssertEqual(hints, [
184+
InlayHint(
185+
position: Position(line: 3, utf16index: 31),
186+
category: .type,
187+
label: "String"
188+
),
189+
InlayHint(
190+
position: Position(line: 4, utf16index: 40),
191+
category: .type,
192+
label: "Double"
193+
),
194+
InlayHint(
195+
position: Position(line: 4, utf16index: 43),
196+
category: .type,
197+
label: "Double"
198+
)
199+
])
200+
}
173201
}

Tests/SourceKitLSPTests/XCTestManifests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ extension InlayHintsTests {
9595
// to regenerate.
9696
static let __allTests__InlayHintsTests = [
9797
("testBindings", testBindings),
98+
("testClosureParams", testClosureParams),
9899
("testEmpty", testEmpty),
99100
("testExplicitTypeAnnotation", testExplicitTypeAnnotation),
100101
("testFields", testFields),

0 commit comments

Comments
 (0)