From 6e0d62c004d98b7890b07db37047c2eb7cb78c28 Mon Sep 17 00:00:00 2001 From: Asger F Date: Thu, 30 Jul 2026 10:06:52 +0200 Subject: [PATCH] unified: Generate corpus output --- .../switch-case-item-where-clauses.output | 222 ++++++++++++++++++ .../catch-where-clauses.output | 207 ++++++++++++++++ 2 files changed, 429 insertions(+) create mode 100644 unified/extractor/tests/corpus/swift/control-flow/switch-case-item-where-clauses.output create mode 100644 unified/extractor/tests/corpus/swift/optionals-and-errors/catch-where-clauses.output diff --git a/unified/extractor/tests/corpus/swift/control-flow/switch-case-item-where-clauses.output b/unified/extractor/tests/corpus/swift/control-flow/switch-case-item-where-clauses.output new file mode 100644 index 00000000000..9d2041aa2ad --- /dev/null +++ b/unified/extractor/tests/corpus/swift/control-flow/switch-case-item-where-clauses.output @@ -0,0 +1,222 @@ +switch n { +case let x where x > 0: + print("positive") +case let y where y < 0, 0: + print("non-positive") +default: + print("other") +} + +--- + +sourceFile + endOfFileToken: endOfFile + statements: + codeBlockItem + item: + expressionStmt + expression: + switchExpr + leftBrace: { + rightBrace: } + cases: + switchCase + label: + switchCaseLabel + colon: : + caseKeyword: case + caseItems: + switchCaseItem + pattern: + valueBindingPattern + pattern: + identifierPattern + identifier: identifier "x" + bindingSpecifier: let + whereClause: + whereClause + condition: + infixOperatorExpr + operator: + binaryOperatorExpr + operator: binaryOperator ">" + leftOperand: + declReferenceExpr + baseName: identifier "x" + rightOperand: + integerLiteralExpr + literal: integerLiteral "0" + whereKeyword: where + statements: + codeBlockItem + item: + functionCallExpr + leftParen: ( + rightParen: ) + arguments: + labeledExpr + expression: + stringLiteralExpr + closingQuote: " + openingQuote: " + segments: + stringSegment + content: stringSegment "positive" + additionalTrailingClosures: + calledExpression: + declReferenceExpr + baseName: identifier "print" + switchCase + label: + switchCaseLabel + colon: : + caseKeyword: case + caseItems: + switchCaseItem + trailingComma: , + pattern: + valueBindingPattern + pattern: + identifierPattern + identifier: identifier "y" + bindingSpecifier: let + whereClause: + whereClause + condition: + infixOperatorExpr + operator: + binaryOperatorExpr + operator: binaryOperator "<" + leftOperand: + declReferenceExpr + baseName: identifier "y" + rightOperand: + integerLiteralExpr + literal: integerLiteral "0" + whereKeyword: where + switchCaseItem + pattern: + expressionPattern + expression: + integerLiteralExpr + literal: integerLiteral "0" + statements: + codeBlockItem + item: + functionCallExpr + leftParen: ( + rightParen: ) + arguments: + labeledExpr + expression: + stringLiteralExpr + closingQuote: " + openingQuote: " + segments: + stringSegment + content: stringSegment "non-positive" + additionalTrailingClosures: + calledExpression: + declReferenceExpr + baseName: identifier "print" + switchCase + label: + switchDefaultLabel + colon: : + defaultKeyword: default + statements: + codeBlockItem + item: + functionCallExpr + leftParen: ( + rightParen: ) + arguments: + labeledExpr + expression: + stringLiteralExpr + closingQuote: " + openingQuote: " + segments: + stringSegment + content: stringSegment "other" + additionalTrailingClosures: + calledExpression: + declReferenceExpr + baseName: identifier "print" + subject: + declReferenceExpr + baseName: identifier "n" + switchKeyword: switch + +--- + +top_level + body: + block + stmt: + switch_expr + value: + name_expr + identifier: identifier "n" + case: + switch_case + pattern: + conditional_pattern + condition: + binary_expr + left: + name_expr + identifier: identifier "x" + operator: infix_operator ">" + right: int_literal "0" + pattern: + name_pattern + identifier: identifier "x" + body: + block + stmt: + call_expr + callee: + name_expr + identifier: identifier "print" + argument: + argument + value: string_literal "\"positive\"" + switch_case + pattern: + or_pattern + pattern: + conditional_pattern + condition: + binary_expr + left: + name_expr + identifier: identifier "y" + operator: infix_operator "<" + right: int_literal "0" + pattern: + name_pattern + identifier: identifier "y" + expr_equality_pattern + expr: int_literal "0" + body: + block + stmt: + call_expr + callee: + name_expr + identifier: identifier "print" + argument: + argument + value: string_literal "\"non-positive\"" + switch_case + body: + block + stmt: + call_expr + callee: + name_expr + identifier: identifier "print" + argument: + argument + value: string_literal "\"other\"" diff --git a/unified/extractor/tests/corpus/swift/optionals-and-errors/catch-where-clauses.output b/unified/extractor/tests/corpus/swift/optionals-and-errors/catch-where-clauses.output new file mode 100644 index 00000000000..79b7879d35f --- /dev/null +++ b/unified/extractor/tests/corpus/swift/optionals-and-errors/catch-where-clauses.output @@ -0,0 +1,207 @@ +do { + try foo() +} catch let e where isNetworkError(e), let f where isTimeout(f) { + print("retry") +} catch { + print("fallback") +} + +--- + +sourceFile + endOfFileToken: endOfFile + statements: + codeBlockItem + item: + doStmt + body: + codeBlock + leftBrace: { + rightBrace: } + statements: + codeBlockItem + item: + tryExpr + expression: + functionCallExpr + leftParen: ( + rightParen: ) + arguments: + additionalTrailingClosures: + calledExpression: + declReferenceExpr + baseName: identifier "foo" + tryKeyword: try + catchClauses: + catchClause + body: + codeBlock + leftBrace: { + rightBrace: } + statements: + codeBlockItem + item: + functionCallExpr + leftParen: ( + rightParen: ) + arguments: + labeledExpr + expression: + stringLiteralExpr + closingQuote: " + openingQuote: " + segments: + stringSegment + content: stringSegment "retry" + additionalTrailingClosures: + calledExpression: + declReferenceExpr + baseName: identifier "print" + catchItems: + catchItem + trailingComma: , + pattern: + valueBindingPattern + pattern: + identifierPattern + identifier: identifier "e" + bindingSpecifier: let + whereClause: + whereClause + condition: + functionCallExpr + leftParen: ( + rightParen: ) + arguments: + labeledExpr + expression: + declReferenceExpr + baseName: identifier "e" + additionalTrailingClosures: + calledExpression: + declReferenceExpr + baseName: identifier "isNetworkError" + whereKeyword: where + catchItem + pattern: + valueBindingPattern + pattern: + identifierPattern + identifier: identifier "f" + bindingSpecifier: let + whereClause: + whereClause + condition: + functionCallExpr + leftParen: ( + rightParen: ) + arguments: + labeledExpr + expression: + declReferenceExpr + baseName: identifier "f" + additionalTrailingClosures: + calledExpression: + declReferenceExpr + baseName: identifier "isTimeout" + whereKeyword: where + catchKeyword: catch + catchClause + body: + codeBlock + leftBrace: { + rightBrace: } + statements: + codeBlockItem + item: + functionCallExpr + leftParen: ( + rightParen: ) + arguments: + labeledExpr + expression: + stringLiteralExpr + closingQuote: " + openingQuote: " + segments: + stringSegment + content: stringSegment "fallback" + additionalTrailingClosures: + calledExpression: + declReferenceExpr + baseName: identifier "print" + catchItems: + catchKeyword: catch + doKeyword: do + +--- + +top_level + body: + block + stmt: + try_expr + body: + block + stmt: + unary_expr + operand: + call_expr + callee: + name_expr + identifier: identifier "foo" + operator: prefix_operator "try" + catch_clause: + catch_clause + pattern: + or_pattern + pattern: + conditional_pattern + condition: + call_expr + callee: + name_expr + identifier: identifier "isNetworkError" + argument: + argument + value: + name_expr + identifier: identifier "e" + pattern: + name_pattern + identifier: identifier "e" + conditional_pattern + condition: + call_expr + callee: + name_expr + identifier: identifier "isTimeout" + argument: + argument + value: + name_expr + identifier: identifier "f" + pattern: + name_pattern + identifier: identifier "f" + body: + block + stmt: + call_expr + callee: + name_expr + identifier: identifier "print" + argument: + argument + value: string_literal "\"retry\"" + catch_clause + body: + block + stmt: + call_expr + callee: + name_expr + identifier: identifier "print" + argument: + argument + value: string_literal "\"fallback\""