Skip to content

Commit 50bb56c

Browse files
authored
Merge pull request swiftlang#136 from benlangmuir/testloc-unicode
[test] Update for TestLocation utf8/16 change
2 parents c0d2ad0 + c9e18c1 commit 50bb56c

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

Sources/SKTestSupport/SKTibsTestWorkspace.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,26 @@ extension TestLocation {
121121

122122
extension Position {
123123
public init(_ loc: TestLocation) {
124-
// FIXME: utf16 vfs utf8 column
125-
self.init(line: loc.line - 1, utf16index: loc.column - 1)
124+
self.init(line: loc.line - 1, utf16index: loc.utf16Column - 1)
125+
}
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)
126131
}
127132
}
128133

129134
extension Location {
130135
public init(_ loc: TestLocation) {
131136
self.init(url: loc.url, range: Range(Position(loc)))
132137
}
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+
}
133144
}
134145

135146
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)