@@ -25,6 +25,7 @@ public class SyntaxFactoryAPITestCase: XCTestCase {
2525 ( " testWithOptionalChild " , testWithOptionalChild) ,
2626 ( " testUnknownSyntax " , testUnknownSyntax) ,
2727 ( " testMakeStringLiteralExpr " , testMakeStringLiteralExpr) ,
28+ ( " testMakeBinaryOperator " , testMakeBinaryOperator) ,
2829 ]
2930
3031 public func testGenerated( ) {
@@ -173,4 +174,23 @@ public class SyntaxFactoryAPITestCase: XCTestCase {
173174"""
174175 XCTAssertEqual ( expr. description, expected)
175176 }
177+
178+ public func testMakeBinaryOperator( ) {
179+ let first = IntegerLiteralExprSyntax {
180+ $0. useDigits ( SyntaxFactory . makeIntegerLiteral ( " 1 " , trailingTrivia: . spaces( 1 ) ) )
181+ }
182+ let second = IntegerLiteralExprSyntax {
183+ $0. useDigits ( SyntaxFactory . makeIntegerLiteral ( " 1 " ) )
184+ }
185+ let operatorNames = [ " == " , " != " , " + " , " - " , " * " , " / " , " < " , " > " , " <= " , " >= " ]
186+ operatorNames. forEach { operatorName in
187+ let operatorToken = SyntaxFactory . makeBinaryOperator ( operatorName, trailingTrivia: . spaces( 1 ) )
188+ let operatorExpr = BinaryOperatorExprSyntax {
189+ $0. useOperatorToken ( operatorToken)
190+ }
191+ let exprList = SyntaxFactory . makeExprList ( [ first, operatorExpr, second] )
192+
193+ XCTAssertEqual ( " \( exprList) " , " 1 \( operatorName) 1 " )
194+ }
195+ }
176196}
0 commit comments