File tree Expand file tree Collapse file tree 4 files changed +51
-2
lines changed
SwiftSyntaxBuilderGeneration/gyb_generated
Tests/SwiftSyntaxBuilderTest Expand file tree Collapse file tree 4 files changed +51
-2
lines changed Original file line number Diff line number Diff line change @@ -1488,18 +1488,26 @@ public extension ExpressibleAsAvailabilityCondition {
1488
1488
return createAvailabilityCondition ( )
1489
1489
}
1490
1490
}
1491
- public protocol ExpressibleAsMatchingPatternCondition : ExpressibleAsSyntaxBuildable {
1491
+ public protocol ExpressibleAsMatchingPatternCondition : ExpressibleAsConditionElement {
1492
1492
func createMatchingPatternCondition( ) -> MatchingPatternCondition
1493
1493
}
1494
1494
public extension ExpressibleAsMatchingPatternCondition {
1495
+ /// Conformance to ExpressibleAsConditionElement
1496
+ func createConditionElement( ) -> ConditionElement {
1497
+ return ConditionElement ( condition: self )
1498
+ }
1495
1499
func createSyntaxBuildable( ) -> SyntaxBuildable {
1496
1500
return createMatchingPatternCondition ( )
1497
1501
}
1498
1502
}
1499
- public protocol ExpressibleAsOptionalBindingCondition : ExpressibleAsSyntaxBuildable {
1503
+ public protocol ExpressibleAsOptionalBindingCondition : ExpressibleAsConditionElement {
1500
1504
func createOptionalBindingCondition( ) -> OptionalBindingCondition
1501
1505
}
1502
1506
public extension ExpressibleAsOptionalBindingCondition {
1507
+ /// Conformance to ExpressibleAsConditionElement
1508
+ func createConditionElement( ) -> ConditionElement {
1509
+ return ConditionElement ( condition: self )
1510
+ }
1503
1511
func createSyntaxBuildable( ) -> SyntaxBuildable {
1504
1512
return createOptionalBindingCondition ( )
1505
1513
}
Original file line number Diff line number Diff line change 22
22
'ExprList' : [
23
23
'ConditionElement'
24
24
],
25
+ 'MatchingPatternCondition' : [
26
+ 'ConditionElement'
27
+ ],
25
28
'MemberDeclList' : [
26
29
'MemberDeclBlock'
27
30
],
31
+ 'OptionalBindingCondition' : [
32
+ 'ConditionElement'
33
+ ],
28
34
'SequenceExpr' : [
29
35
'CodeBlockItem' ,
30
36
'TupleExprElement'
Original file line number Diff line number Diff line change @@ -36,9 +36,15 @@ let SYNTAX_BUILDABLE_EXPRESSIBLE_AS_CONFORMANCES: [String: [String]] = [
36
36
" ExprList " : [
37
37
" ConditionElement " ,
38
38
] ,
39
+ " MatchingPatternCondition " : [
40
+ " ConditionElement " ,
41
+ ] ,
39
42
" MemberDeclList " : [
40
43
" MemberDeclBlock " ,
41
44
] ,
45
+ " OptionalBindingCondition " : [
46
+ " ConditionElement " ,
47
+ ] ,
42
48
" SequenceExpr " : [
43
49
" CodeBlockItem " ,
44
50
" TupleExprElement " ,
Original file line number Diff line number Diff line change @@ -36,4 +36,33 @@ final class IfStmtTests: XCTestCase {
36
36
}
37
37
""" )
38
38
}
39
+
40
+ func testIfLetStmt( ) {
41
+ let buildable = IfStmt (
42
+ conditions: OptionalBindingCondition (
43
+ letOrVarKeyword: . let,
44
+ pattern: " x " ,
45
+ initializer: InitializerClause ( value: " y " )
46
+ )
47
+ ) { }
48
+ let syntax = buildable. buildSyntax ( format: Format ( ) )
49
+ XCTAssertEqual ( syntax. description, """
50
+ if let x = y {
51
+ }
52
+ """ )
53
+ }
54
+
55
+ func testIfCaseStmt( ) {
56
+ let buildable = IfStmt (
57
+ conditions: MatchingPatternCondition (
58
+ pattern: ExpressionPattern ( expression: MemberAccessExpr ( name: " x " ) ) ,
59
+ initializer: InitializerClause ( value: " y " )
60
+ )
61
+ ) { }
62
+ let syntax = buildable. buildSyntax ( format: Format ( ) )
63
+ XCTAssertEqual ( syntax. description, """
64
+ if case .x = y {
65
+ }
66
+ """ )
67
+ }
39
68
}
You can’t perform that action at this time.
0 commit comments