Skip to content

Commit 1c6e1c7

Browse files
committed
Add validation that all syntax collections end with ListSyntax
1 parent 0c41fe6 commit 1c6e1c7

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
@@ -138,6 +138,33 @@ class ValidateSyntaxNodes: XCTestCase {
138138
)
139139
}
140140

141+
func testSyntaxCollectionsShouldEndWithList() {
142+
var failures: [ValidationFailure] = []
143+
144+
for node in SYNTAX_NODES.compactMap(\.collectionNode) {
145+
if !node.kind.syntaxType.description.hasSuffix("ListSyntax") {
146+
failures.append(
147+
ValidationFailure(
148+
node: node.kind,
149+
message: "is a collection but does not end with ListSyntax"
150+
)
151+
)
152+
}
153+
}
154+
155+
assertFailuresMatchXFails(
156+
failures,
157+
expectedFailures: [
158+
ValidationFailure(node: .documentationAttributeArguments, message: "is a collection but does not end with ListSyntax"),
159+
ValidationFailure(node: .unexpectedNodes, message: "is a collection but does not end with ListSyntax"),
160+
ValidationFailure(node: .effectsArguments, message: "is a collection but does not end with ListSyntax"),
161+
ValidationFailure(node: .importPath, message: "is a collection but does not end with ListSyntax"),
162+
ValidationFailure(node: .objCSelector, message: "is a collection but does not end with ListSyntax"),
163+
ValidationFailure(node: .stringLiteralSegments, message: "is a collection but does not end with ListSyntax"),
164+
]
165+
)
166+
}
167+
141168
/// Implementation detail of `testSingleTokenChoiceChildNaming`, validating a single child.
142169
///
143170
/// - Returns: A failure message if validation failed, otherwise `nil`

0 commit comments

Comments
 (0)