Skip to content

Commit 3907c80

Browse files
authored
Merge pull request #930 from ahoppen/ahoppen/remove-semantic-todos
Remove semantic todos in various test files
2 parents 87fc5ab + d2e2e0a commit 3907c80

File tree

5 files changed

+129
-57
lines changed

5 files changed

+129
-57
lines changed

Tests/SwiftParserTest/translated/OperatorsTests.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,7 @@ final class OperatorsTests: XCTestCase {
208208
var _ : Man = TheDevil() ^ God()
209209
var _ : Man = God()^ ^ ^TheDevil()
210210
let _ = God()^TheDevil()
211-
""",
212-
diagnostics: [
213-
// TODO: Old parser expected error on line 5: operator argument #2 must precede operator argument #1, Fix-It replacements: 9 - 9 = 'TheDevil()', 14 - 25 = ''
214-
]
211+
"""
215212
)
216213
}
217214

Tests/SwiftParserTest/translated/OptionalTests.swift

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// This test file has been translated from swift/test/Parse/optional.swift
22

3+
import SwiftSyntax
34
import XCTest
45

56
final class OptionalTests: XCTestCase {
@@ -20,22 +21,31 @@ final class OptionalTests: XCTestCase {
2021
var b : A 1️⃣?
2122
""",
2223
diagnostics: [
23-
// TODO: Old parser expected error on line 2: consecutive statements on a line, Fix-It replacements: 10 - 10 = ';'
24-
// TODO: Old parser expected error on line 2: expected expression
2524
DiagnosticSpec(message: "extraneous code '?' at top level"),
2625
]
2726
)
2827
}
2928

30-
func testOptional3() {
29+
func testOptional3a() {
3130
AssertParse(
3231
"""
3332
var c = a?
34-
var d : ()? = a?.foo()
3533
""",
36-
diagnostics: [
37-
// TODO: Old parser expected error on line 1: '?' must be followed by a call, member lookup, or subscript
38-
]
34+
substructure: Syntax(OptionalChainingExprSyntax(
35+
expression: ExprSyntax(IdentifierExprSyntax(
36+
identifier: .identifier("a"),
37+
declNameArguments: nil
38+
)),
39+
questionMark: .postfixQuestionMarkToken()
40+
))
41+
)
42+
}
43+
44+
func testOptional3b() {
45+
AssertParse(
46+
"""
47+
var d : ()? = a?.foo()
48+
"""
3949
)
4050
}
4151

Tests/SwiftParserTest/translated/PatternWithoutVariablesTests.swift

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ final class PatternWithoutVariablesTests: XCTestCase {
77
AssertParse(
88
"""
99
let _ = 1
10-
""",
11-
diagnostics: [
12-
// TODO: Old parser expected error on line 1: global variable declaration does not bind any variables
13-
]
10+
"""
1411
)
1512
}
1613

@@ -34,11 +31,7 @@ final class PatternWithoutVariablesTests: XCTestCase {
3431
let _ = 1 // OK
3532
}
3633
}
37-
""",
38-
diagnostics: [
39-
// TODO: Old parser expected error on line 2: property declaration does not bind any variables
40-
// TODO: Old parser expected error on line 3: property declaration does not bind any variables
41-
]
34+
"""
4235
)
4336
}
4437

@@ -69,12 +62,7 @@ final class PatternWithoutVariablesTests: XCTestCase {
6962
}
7063
if case let _ = "str" {}
7164
}
72-
"""#,
73-
diagnostics: [
74-
// TODO: Old parser expected warning on line 3: 'let' pattern has no effect; sub-pattern didn't bind any variables, Fix-It replacements: 8 - 12 = ''
75-
// TODO: Old parser expected warning on line 9: 'let' pattern has no effect; sub-pattern didn't bind any variables, Fix-It replacements: 8 - 12 = ''
76-
// TODO: Old parser expected warning on line 14: 'let' pattern has no effect; sub-pattern didn't bind any variables, Fix-It replacements: 11 - 15 = ''
77-
]
65+
"""#
7866
)
7967
}
8068

@@ -85,10 +73,7 @@ final class PatternWithoutVariablesTests: XCTestCase {
8573
class C_53293 {
8674
static var _: Int { 0 }
8775
}
88-
""",
89-
diagnostics: [
90-
// TODO: Old parser expected error on line 3: getter/setter can only be defined for a single variable
91-
]
76+
"""
9277
)
9378
}
9479

Tests/SwiftParserTest/translated/PoundAssertTests.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,15 @@ final class PoundAssertTests: XCTestCase {
77
AssertParse(
88
"""
99
#assert(true, 123)
10-
""",
11-
diagnostics: [
12-
// TODO: Old parser expected error on line 1: expected a string literal
13-
]
10+
"""
1411
)
1512
}
1613

1714
func testPoundAssert2() {
1815
AssertParse(
1916
#"""
2017
#assert(true, "error \(1) message")
21-
"""#,
22-
diagnostics: [
23-
// TODO: Old parser expected error on line 1: '#assert' message cannot be an interpolated string literal
24-
]
18+
"""#
2519
)
2620
}
2721

@@ -42,7 +36,6 @@ final class PoundAssertTests: XCTestCase {
4236
#assert(1️⃣, "error message")
4337
"""#,
4438
diagnostics: [
45-
// TODO: Old parser expected error on line 1: expected a condition expression
4639
DiagnosticSpec(message: "expected condition in '#assert' directive"),
4740
]
4841
)

Tests/SwiftParserTest/translated/SuperTests.swift

Lines changed: 105 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// This test file has been translated from swift/test/Parse/super.swift
22

3+
import SwiftSyntax
34
import XCTest
45

56
final class SuperTests: XCTestCase {
@@ -20,54 +21,140 @@ final class SuperTests: XCTestCase {
2021
)
2122
}
2223

23-
func testSuper2() {
24+
func testSuper2a() {
2425
AssertParse(
2526
#"""
2627
class D : B {
2728
override init() {
2829
super.init()
2930
super.init(42)
3031
}
32+
}
33+
"""#
34+
)
35+
}
36+
37+
func testSuper2b() {
38+
AssertParse(
39+
#"""
40+
class D : B {
3141
override init(x:Int) {
32-
let _: () -> B = super.init
42+
let _: () -> B = super.init
3343
}
44+
}
45+
"""#
46+
)
47+
}
48+
49+
func testSuper2c() {
50+
AssertParse(
51+
#"""
52+
class D : B {
3453
convenience init(y:Int) {
35-
let _: () -> D = self.init
54+
let _: () -> D = self.init
3655
}
56+
}
57+
"""#
58+
)
59+
}
60+
61+
func testSuper2d() {
62+
AssertParse(
63+
#"""
64+
class D : B {
3765
init(z: Int) {
3866
super
3967
.init(x: z)
4068
}
69+
}
70+
"""#
71+
)
72+
}
73+
74+
func testSuper2e() {
75+
AssertParse(
76+
#"""
77+
class D : B {
4178
func super_calls() {
42-
super.foo
43-
super.foo.bar
44-
super.bar
79+
super.foo
80+
super.foo.bar
81+
super.bar
4582
super.bar()
4683
// FIXME: should also say "'super.init' cannot be referenced outside of an initializer"
47-
super.init
48-
super.init()
49-
super.init(0)
50-
super[0]
84+
super.init
85+
super.init()
86+
super.init(0)
87+
super[0]
5188
super
5289
.bar()
5390
}
91+
}
92+
"""#
93+
)
94+
}
95+
96+
func testSuper2f() {
97+
AssertParse(
98+
#"""
99+
class D : B {
54100
func bad_super_1() {
55-
super.1️⃣$0
101+
super.1️⃣$0
56102
}
103+
}
104+
"""#,
105+
diagnostics: [
106+
DiagnosticSpec(message: "expected identifier in member access"),
107+
]
108+
)
109+
}
110+
111+
func testSuper2g() {
112+
AssertParse(
113+
#"""
114+
class D : B {
57115
func bad_super_2() {
58-
super(0)
116+
super(0)
59117
}
118+
}
119+
"""#,
120+
substructure: Syntax(FunctionCallExprSyntax(
121+
calledExpression: ExprSyntax(SuperRefExprSyntax(superKeyword: .superKeyword())),
122+
leftParen: .leftParenToken(),
123+
argumentList: TupleExprElementListSyntax([
124+
TupleExprElementSyntax(
125+
label: nil,
126+
colon: nil,
127+
expression: ExprSyntax(IntegerLiteralExprSyntax(digits: .integerLiteral("0"))),
128+
trailingComma: nil
129+
)
130+
]),
131+
rightParen: .rightParenToken(),
132+
trailingClosure: nil,
133+
additionalTrailingClosures: nil
134+
))
135+
)
136+
}
137+
138+
func testSuper2h() {
139+
AssertParse(
140+
#"""
141+
class D : B {
60142
func bad_super_3() {
61-
super
143+
super
62144
[1]
63145
}
64146
}
65147
"""#,
66-
diagnostics: [
67-
DiagnosticSpec(message: "expected identifier in member access"),
68-
// TODO: Old parser expected error on line 33: expected '.' or '[' after 'super'
69-
// TODO: Old parser expected error on line 36: expected '.' or '[' after 'super'
70-
]
148+
substructure: Syntax(ArrayExprSyntax(
149+
leftSquare: .leftSquareBracketToken(),
150+
elements: ArrayElementListSyntax([
151+
ArrayElementSyntax(
152+
expression: ExprSyntax(IntegerLiteralExprSyntax(digits: .integerLiteral("1"))),
153+
trailingComma: nil
154+
)
155+
]),
156+
rightSquare: .rightSquareBracketToken()
157+
))
71158
)
72159
}
73160

0 commit comments

Comments
 (0)