Skip to content

Commit 0d19d7d

Browse files
authored
Merge pull request #420 from benlangmuir/skip-tests-5.5
[test] Update tests to pass with 5.5 toolchain
2 parents 7c9ccf2 + fd01df3 commit 0d19d7d

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

Tests/SourceKitLSPTests/InlayHintsTests.swift

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ final class InlayHintsTests: XCTestCase {
4242
))
4343
}
4444

45-
func performInlayHintsRequest(text: String, range: Range<Position>? = nil) -> [InlayHint] {
45+
func performInlayHintsRequest(text: String, range: Range<Position>? = nil) throws -> [InlayHint] {
4646
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
4747

4848
sk.send(DidOpenTextDocumentNotification(textDocument: TextDocumentItem(
@@ -53,21 +53,26 @@ final class InlayHintsTests: XCTestCase {
5353
)))
5454

5555
let request = InlayHintsRequest(textDocument: TextDocumentIdentifier(url), range: range)
56-
return try! sk.sendSync(request)
56+
57+
do {
58+
return try sk.sendSync(request)
59+
} catch let error as ResponseError where error.message.contains("unknown request: source.request.variable.type") {
60+
throw XCTSkip("toolchain does not support variable.type request")
61+
}
5762
}
5863

59-
func testEmpty() {
64+
func testEmpty() throws {
6065
let text = ""
61-
let hints = performInlayHintsRequest(text: text)
66+
let hints = try performInlayHintsRequest(text: text)
6267
XCTAssertEqual(hints, [])
6368
}
6469

65-
func testBindings() {
70+
func testBindings() throws {
6671
let text = """
6772
let x = 4
6873
var y = "test" + "123"
6974
"""
70-
let hints = performInlayHintsRequest(text: text)
75+
let hints = try performInlayHintsRequest(text: text)
7176
XCTAssertEqual(hints, [
7277
InlayHint(
7378
position: Position(line: 0, utf16index: 5),
@@ -82,7 +87,7 @@ final class InlayHintsTests: XCTestCase {
8287
])
8388
}
8489

85-
func testRanged() {
90+
func testRanged() throws {
8691
let text = """
8792
func square(_ x: Double) -> Double {
8893
let result = x * x
@@ -96,7 +101,7 @@ final class InlayHintsTests: XCTestCase {
96101
}
97102
"""
98103
let range = Position(line: 6, utf16index: 0)..<Position(line: 9, utf16index: 0)
99-
let hints = performInlayHintsRequest(text: text, range: range)
104+
let hints = try performInlayHintsRequest(text: text, range: range)
100105
XCTAssertEqual(hints, [
101106
InlayHint(
102107
position: Position(line: 6, utf16index: 10),
@@ -111,7 +116,7 @@ final class InlayHintsTests: XCTestCase {
111116
])
112117
}
113118

114-
func testFields() {
119+
func testFields() throws {
115120
let text = """
116121
class X {
117122
let instanceMember = 3
@@ -127,7 +132,7 @@ final class InlayHintsTests: XCTestCase {
127132
static let staticMember = 3.0
128133
}
129134
"""
130-
let hints = performInlayHintsRequest(text: text)
135+
let hints = try performInlayHintsRequest(text: text)
131136
XCTAssertEqual(hints, [
132137
InlayHint(
133138
position: Position(line: 1, utf16index: 20),
@@ -157,19 +162,19 @@ final class InlayHintsTests: XCTestCase {
157162
])
158163
}
159164

160-
func testExplicitTypeAnnotation() {
165+
func testExplicitTypeAnnotation() throws {
161166
let text = """
162167
let x: String = "abc"
163168
164169
struct X {
165170
var y: Int = 34
166171
}
167172
"""
168-
let hints = performInlayHintsRequest(text: text)
173+
let hints = try performInlayHintsRequest(text: text)
169174
XCTAssertEqual(hints, [])
170175
}
171176

172-
func testClosureParams() {
177+
func testClosureParams() throws {
173178
let text = """
174179
func f(x: Int) {}
175180
@@ -179,7 +184,7 @@ final class InlayHintsTests: XCTestCase {
179184
x + y
180185
}
181186
"""
182-
let hints = performInlayHintsRequest(text: text)
187+
let hints = try performInlayHintsRequest(text: text)
183188
XCTAssertEqual(hints, [
184189
InlayHint(
185190
position: Position(line: 2, utf16index: 5),

0 commit comments

Comments
 (0)