Skip to content

Commit c9e18c1

Browse files
committed
[test] Update implementations test for TestLocation unicode
1 parent b61d974 commit c9e18c1

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

Sources/SKTestSupport/SKTibsTestWorkspace.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,24 @@ extension Position {
123123
public init(_ loc: TestLocation) {
124124
self.init(line: loc.line - 1, utf16index: loc.utf16Column - 1)
125125
}
126+
127+
/// Incorrectly use the UTF-8 column index in place of the UTF-16 one, to match the incorrect
128+
/// implementation in SourceKitServer when using the index.
129+
public init(badUTF16 loc: TestLocation) {
130+
self.init(line: loc.line - 1, utf16index: loc.utf8Column - 1)
131+
}
126132
}
127133

128134
extension Location {
129135
public init(_ loc: TestLocation) {
130136
self.init(url: loc.url, range: Range(Position(loc)))
131137
}
138+
139+
/// Incorrectly use the UTF-8 column index in place of the UTF-16 one, to match the incorrect
140+
/// implementation in SourceKitServer when using the index.
141+
public init(badUTF16 loc: TestLocation) {
142+
self.init(url: loc.url, range: Range(Position(badUTF16: loc)))
143+
}
132144
}
133145

134146
extension TibsToolchain {

Tests/SourceKitTests/ImplementationTests.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class ImplementationTests: XCTestCase {
3434
ws.testLoc(name)
3535
}
3636
func loc(_ name: String) -> Location {
37-
Location(ws.testLoc(name))
37+
Location(badUTF16: ws.testLoc(name))
3838
}
3939

4040
try XCTAssertEqual(impls(at: testLoc("Protocol")), [loc("StructConformance")])
@@ -54,8 +54,7 @@ final class ImplementationTests: XCTestCase {
5454
try XCTAssertEqual(impls(at: testLoc("Trematothoracinae")), [])
5555

5656
try XCTAssertEqual(impls(at: testLoc("Prozaiczne")), [loc("MurkwiaConformance2"), loc("SepulkaConformance1")])
57-
// FIXME: For some reason we get a location in the middle of a symbol for PćmaŁagodnaConformance
58-
// try XCTAssertEqual(impls(at: testLoc("Sepulkowate")), [loc("MurkwiaConformance1"), loc("SepulkaConformance2"), loc("PćmaŁagodnaConformance"), loc("PćmaZwyczajnaConformance")])
57+
try XCTAssertEqual(impls(at: testLoc("Sepulkowate")), [loc("MurkwiaConformance1"), loc("SepulkaConformance2"), loc("PćmaŁagodnaConformance"), loc("PćmaZwyczajnaConformance")])
5958
// FIXME: sourcekit returns wrong locations for the function (subclasses that don't override it, and extensions that don't implement it)
6059
// try XCTAssertEqual(impls(at: testLoc("rozpocznijSepulenie")), [loc("MurkwiaFunc"), loc("SepulkaFunc"), loc("PćmaŁagodnaFunc"), loc("PćmaZwyczajnaFunc")])
6160
try XCTAssertEqual(impls(at: testLoc("Murkwia")), [])
@@ -64,4 +63,4 @@ final class ImplementationTests: XCTestCase {
6463
try XCTAssertEqual(impls(at: testLoc("SepulkaVar")), [loc("SepulkaDwuusznaVar"), loc("SepulkaPrzechylnaVar")])
6564
try XCTAssertEqual(impls(at: testLoc("SepulkaFunc")), [])
6665
}
67-
}
66+
}

0 commit comments

Comments
 (0)