Skip to content

Commit b4e38c1

Browse files
committed
Audit GenericDisambiguationTests
1 parent 8d5a984 commit b4e38c1

File tree

1 file changed

+76
-17
lines changed

1 file changed

+76
-17
lines changed

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)