Skip to content

Commit e507abc

Browse files
committed
Update tests for syntax classification of identifiers as 'Identifier' classification
Requires this change on the swift side: swiftlang/swift#25925
1 parent aa56781 commit e507abc

File tree

7 files changed

+212
-208
lines changed

7 files changed

+212
-208
lines changed

Sources/lit-test-helper/ClassifiedSyntaxTreePrinter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extension SyntaxClassification {
1818
switch self {
1919
case .none: return ""
2020
case .keyword: return "kw"
21-
case .identifier: return ""
21+
case .identifier: return "id"
2222
case .typeIdentifier: return "type"
2323
case .dollarIdentifier: return "dollar"
2424
case .integerLiteral: return "int"

Tests/SwiftSyntaxTest/ClassificationTests.swift

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ public class ClassificationTests: XCTestCase {
1212
let tree = try! SyntaxParser.parse(source: source)
1313
do {
1414
let classif = Array(tree.classifications)
15-
XCTAssertEqual(classif.count, 7)
16-
guard classif.count == 7 else {
15+
XCTAssertEqual(classif.count, 8)
16+
guard classif.count == 8 else {
1717
return
1818
}
1919
XCTAssertEqual(classif[0].kind, .lineComment)
@@ -23,18 +23,20 @@ public class ClassificationTests: XCTestCase {
2323
XCTAssertEqual(classif[2].kind, .keyword)
2424
XCTAssertEqual(classif[2].range, ByteSourceRange(offset: 9, length: 3))
2525
XCTAssertEqual(classif[3].kind, .none)
26-
XCTAssertEqual(classif[3].range, ByteSourceRange(offset: 12, length: 2))
27-
XCTAssertEqual(classif[4].kind, .blockComment)
28-
XCTAssertEqual(classif[4].range, ByteSourceRange(offset: 14, length: 6))
29-
XCTAssertEqual(classif[5].kind, .none)
30-
XCTAssertEqual(classif[5].range, ByteSourceRange(offset: 20, length: 3))
31-
XCTAssertEqual(classif[6].kind, .integerLiteral)
32-
XCTAssertEqual(classif[6].range, ByteSourceRange(offset: 23, length: 1))
26+
XCTAssertEqual(classif[3].range, ByteSourceRange(offset: 12, length: 1))
27+
XCTAssertEqual(classif[4].kind, .identifier)
28+
XCTAssertEqual(classif[4].range, ByteSourceRange(offset: 13, length: 1))
29+
XCTAssertEqual(classif[5].kind, .blockComment)
30+
XCTAssertEqual(classif[5].range, ByteSourceRange(offset: 14, length: 6))
31+
XCTAssertEqual(classif[6].kind, .none)
32+
XCTAssertEqual(classif[6].range, ByteSourceRange(offset: 20, length: 3))
33+
XCTAssertEqual(classif[7].kind, .integerLiteral)
34+
XCTAssertEqual(classif[7].range, ByteSourceRange(offset: 23, length: 1))
3335
}
3436
do {
3537
let classif = Array(tree.classifications(in: ByteSourceRange(offset: 7, length: 8)))
36-
XCTAssertEqual(classif.count, 5)
37-
guard classif.count == 5 else {
38+
XCTAssertEqual(classif.count, 6)
39+
guard classif.count == 6 else {
3840
return
3941
}
4042
XCTAssertEqual(classif[0].kind, .lineComment)
@@ -44,9 +46,11 @@ public class ClassificationTests: XCTestCase {
4446
XCTAssertEqual(classif[2].kind, .keyword)
4547
XCTAssertEqual(classif[2].range, ByteSourceRange(offset: 9, length: 3))
4648
XCTAssertEqual(classif[3].kind, .none)
47-
XCTAssertEqual(classif[3].range, ByteSourceRange(offset: 12, length: 2))
48-
XCTAssertEqual(classif[4].kind, .blockComment)
49-
XCTAssertEqual(classif[4].range, ByteSourceRange(offset: 14, length: 6))
49+
XCTAssertEqual(classif[3].range, ByteSourceRange(offset: 12, length: 1))
50+
XCTAssertEqual(classif[4].kind, .identifier)
51+
XCTAssertEqual(classif[4].range, ByteSourceRange(offset: 13, length: 1))
52+
XCTAssertEqual(classif[5].kind, .blockComment)
53+
XCTAssertEqual(classif[5].range, ByteSourceRange(offset: 14, length: 6))
5054
}
5155
do {
5256
let classif = Array(tree.classifications(in: ByteSourceRange(offset: 21, length: 1)))
@@ -106,7 +110,7 @@ public class ClassificationTests: XCTestCase {
106110
let classif = tokens.map { $0.tokenClassification }
107111
XCTAssertEqual(classif[0].kind, .keyword)
108112
XCTAssertEqual(classif[0].range, ByteSourceRange(offset: 0, length: 3))
109-
XCTAssertEqual(classif[1].kind, .none)
113+
XCTAssertEqual(classif[1].kind, .identifier)
110114
XCTAssertEqual(classif[1].range, ByteSourceRange(offset: 4, length: 1))
111115
XCTAssertEqual(classif[2].kind, .none)
112116
XCTAssertEqual(classif[2].range, ByteSourceRange(offset: 5, length: 1))

0 commit comments

Comments
 (0)