Skip to content

Commit 87dfafb

Browse files
committed
Update inlay hint tests and add case with explicit type annotations
1 parent b19330e commit 87dfafb

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

Tests/SourceKitLSPTests/InlayHintsTests.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ final class InlayHintsTests: XCTestCase {
6767
let x = 4
6868
var y = "test" + "123"
6969
"""
70+
// FIXME: These type hints should ideally be displayed after the variable name
71+
// rather than after the expression. Once the implementation is updated (e.g.
72+
// by using a new SourceKit request), these tests should be updated too.
7073
let hints = performInlayHintsRequest(text: text)
7174
XCTAssertEqual(hints, [
7275
InlayHint(
@@ -156,4 +159,30 @@ final class InlayHintsTests: XCTestCase {
156159
),
157160
])
158161
}
162+
163+
func testExplicitTypeAnnotation() {
164+
let text = """
165+
let x: String = "abc"
166+
167+
struct X {
168+
var y: Int = 34
169+
}
170+
"""
171+
let hints = performInlayHintsRequest(text: text)
172+
// FIXME: Explicitly type-annotated variable bindings shouldn't have
173+
// an inlay hint. Once we move to the new SourceKit request (as detailed
174+
// in the other comment above), we should receive the empty array here.
175+
XCTAssertEqual(hints, [
176+
InlayHint(
177+
position: Position(line: 0, utf16index: 21),
178+
category: .type,
179+
label: "String"
180+
),
181+
InlayHint(
182+
position: Position(line: 3, utf16index: 17),
183+
category: .type,
184+
label: "Int"
185+
)
186+
])
187+
}
159188
}

Tests/SourceKitLSPTests/XCTestManifests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ extension InlayHintsTests {
9696
static let __allTests__InlayHintsTests = [
9797
("testBindings", testBindings),
9898
("testEmpty", testEmpty),
99+
("testExplicitTypeAnnotation", testExplicitTypeAnnotation),
99100
("testFields", testFields),
100101
("testRanged", testRanged),
101102
]

0 commit comments

Comments
 (0)