Skip to content

Commit 1eaa18c

Browse files
authored
Merge pull request #965 from ahoppen/ahoppen/audit-tests
Audit GenericDisambiguationTests.swift and ForeachTests.swift
2 parents 81fb4ff + 3682d1f commit 1eaa18c

File tree

3 files changed

+76
-29
lines changed

3 files changed

+76
-29
lines changed

Tests/SwiftParserTest/translated/ForeachAsyncTests.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,7 @@ final class ForeachAsyncTests: XCTestCase {
6868
}
6969
""",
7070
diagnostics: [
71-
// TODO: Old parser expected error on line 21: found an unexpected second identifier in constant declaration
72-
// TODO: Old parser expected note on line 21: join the identifiers together
73-
// TODO: Old parser expected note on line 21: join the identifiers together with camel-case
74-
// TODO: Old parser expected error on line 21: expected 'in' after for-each pattern
75-
// TODO: Old parser expected error on line 21: expected Sequence expression for for-each loop
7671
DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'in' in 'for' statement"),
77-
// TODO: Old parser expected error on line 23: expected '{' to start the body of for-each loop
7872
DiagnosticSpec(locationMarker: "2️⃣", message: "expected '{' in 'for' statement"),
7973
DiagnosticSpec(locationMarker: "3️⃣", message: "expected '}' to end 'for' statement"),
8074
]

Tests/SwiftParserTest/translated/ForeachTests.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,7 @@ final class ForeachTests: XCTestCase {
4545
}
4646
""",
4747
diagnostics: [
48-
// TODO: Old parser expected error on line 21: found an unexpected second identifier in constant declaration
49-
// TODO: Old parser expected note on line 21: join the identifiers together
50-
// TODO: Old parser expected note on line 21: join the identifiers together with camel-case
51-
// TODO: Old parser expected error on line 21: expected 'in' after for-each pattern
52-
// TODO: Old parser expected error on line 21: expected Sequence expression for for-each loop
5348
DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'in' in 'for' statement"),
54-
// TODO: Old parser expected error on line 23: expected '{' to start the body of for-each loop
5549
DiagnosticSpec(locationMarker: "2️⃣", message: "expected '{' in 'for' statement"),
5650
DiagnosticSpec(locationMarker: "3️⃣", message: "expected '}' to end 'for' statement"),
5751
]

Tests/SwiftParserTest/translated/GenericDisambiguationTests.swift

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

3+
import SwiftSyntax
4+
35
import XCTest
46

57
final class GenericDisambiguationTests: XCTestCase {
@@ -54,36 +56,93 @@ final class GenericDisambiguationTests: XCTestCase {
5456
)
5557
}
5658

57-
func testGenericDisambiguation6() {
59+
func testGenericDisambiguation6a() {
5860
AssertParse(
5961
"""
6062
_ = a < b
63+
"""
64+
)
65+
}
66+
67+
func testGenericDisambiguation6b() {
68+
AssertParse(
69+
"""
6170
_ = (a < b, c > d)
62-
// Parses as generic because of lparen after '>'
63-
(a < b, c > (d))
64-
// Parses as generic because of lparen after '>'
65-
(a<b, c>(d))
71+
"""
72+
)
73+
}
74+
75+
func testGenericDisambiguation6c() {
76+
// Parses as generic because of lparen after '>'
77+
AssertParse(
78+
"""
79+
(a < b, c > (d))
80+
""",
81+
substructure: Syntax(GenericArgumentListSyntax([
82+
GenericArgumentSyntax(
83+
argumentType: TypeSyntax(SimpleTypeIdentifierSyntax(
84+
name: .identifier("b"),
85+
genericArgumentClause: nil
86+
)),
87+
trailingComma: .commaToken()
88+
),
89+
GenericArgumentSyntax(
90+
argumentType: TypeSyntax(SimpleTypeIdentifierSyntax(
91+
name: .identifier("c"),
92+
genericArgumentClause: nil
93+
)),
94+
trailingComma: nil
95+
)
96+
]))
97+
)
98+
}
99+
100+
func testGenericDisambiguation6d() {
101+
// Parses as generic because of lparen after '>'
102+
AssertParse(
103+
"""
104+
(a<b, c>(d))
105+
""",
106+
substructure: Syntax(GenericArgumentListSyntax([
107+
GenericArgumentSyntax(
108+
argumentType: TypeSyntax(SimpleTypeIdentifierSyntax(
109+
name: .identifier("b"),
110+
genericArgumentClause: nil
111+
)),
112+
trailingComma: .commaToken()
113+
),
114+
GenericArgumentSyntax(
115+
argumentType: TypeSyntax(SimpleTypeIdentifierSyntax(
116+
name: .identifier("c"),
117+
genericArgumentClause: nil
118+
)),
119+
trailingComma: nil
120+
)
121+
]))
122+
)
123+
}
124+
125+
func testGenericDisambiguation6e() {
126+
AssertParse(
127+
"""
66128
_ = a>(b)
129+
"""
130+
)
131+
}
132+
133+
func testGenericDisambiguation6f() {
134+
AssertParse(
135+
"""
67136
_ = a > (b)
68-
""",
69-
diagnostics: [
70-
// TODO: Old parser expected error on line 4: cannot specialize a non-generic definition
71-
// TODO: Old parser expected note on line 4: while parsing this '<' as a type parameter bracket
72-
// TODO: Old parser expected error on line 6: cannot specialize a non-generic definition
73-
// TODO: Old parser expected note on line 6: while parsing this '<' as a type parameter bracket
74-
]
137+
"""
75138
)
76139
}
77140

78141
func testGenericDisambiguation7() {
79142
AssertParse(
80143
"""
81144
generic<Int>(0)
82-
""",
83-
diagnostics: [
84-
// TODO: Old parser expected error on line 1: cannot explicitly specialize a generic function
85-
// TODO: Old parser expected note on line 1: while parsing this '<' as a type parameter bracket
86-
]
145+
"""
87146
)
88147
}
89148

0 commit comments

Comments
 (0)