Skip to content

Commit 1d01285

Browse files
committed
Add validation that all syntax collections end with ListSyntax
1 parent 680942e commit 1d01285

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,33 @@ class ValidateSyntaxNodes: XCTestCase {
129129
)
130130
}
131131

132+
func testSyntaxCollectionsShouldEndWithList() {
133+
var failures: [ValidationFailure] = []
134+
135+
for node in SYNTAX_NODES.compactMap(\.collectionNode) {
136+
if !node.kind.syntaxType.description.hasSuffix("ListSyntax") {
137+
failures.append(
138+
ValidationFailure(
139+
node: node.kind,
140+
message: "is a collection but does not end with ListSyntax"
141+
)
142+
)
143+
}
144+
}
145+
146+
assertFailuresMatchXFails(
147+
failures,
148+
expectedFailures: [
149+
ValidationFailure(node: .documentationAttributeArguments, message: "is a collection but does not end with ListSyntax"),
150+
ValidationFailure(node: .unexpectedNodes, message: "is a collection but does not end with ListSyntax"),
151+
ValidationFailure(node: .effectsArguments, message: "is a collection but does not end with ListSyntax"),
152+
ValidationFailure(node: .importPath, message: "is a collection but does not end with ListSyntax"),
153+
ValidationFailure(node: .objCSelector, message: "is a collection but does not end with ListSyntax"),
154+
ValidationFailure(node: .stringLiteralSegments, message: "is a collection but does not end with ListSyntax"),
155+
]
156+
)
157+
}
158+
132159
/// Implementation detail of `testSingleTokenChoiceChildNaming`, validating a single child.
133160
///
134161
/// - Returns: A failure message if validation failed, otherwise `nil`

0 commit comments

Comments
 (0)