Skip to content

Commit bbf0023

Browse files
committed
Add test to verify borrow (msg) is a function call
1 parent a700b4d commit bbf0023

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift

+5-7
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,6 @@ class ValidateSyntaxNodes: XCTestCase {
317317
),
318318

319319
// MARK: Tokens that contain underscores
320-
ValidationFailure(
321-
node: .borrowExpr,
322-
message:
323-
"child 'borrowKeyword' has a single keyword as its only token choice and should thus be named '_borrowKeyword'"
324-
// _borrow is underscored and thus BorrowKeyword is the correct spelling
325-
),
326320
ValidationFailure(
327321
node: .conventionWitnessMethodAttributeArguments,
328322
message:
@@ -410,7 +404,11 @@ class ValidateSyntaxNodes: XCTestCase {
410404
message: "child 'consumeKeyword' only has keywords as its token choices and should thus end with 'Specifier'"
411405
// ConsumeKeyword can be 'consume' or '_move' and '_move' is deprecated
412406
),
413-
407+
ValidationFailure(
408+
node: .borrowExpr,
409+
message: "child 'borrowKeyword' only has keywords as its token choices and should thus end with 'Specifier'"
410+
// BorrowKeyword can be 'borrow' or '_borrow', eventually '_borrow' will be deprecated
411+
),
414412
// MARK: Conceptually a value, not a specifier
415413
ValidationFailure(
416414
node: .booleanLiteralExpr,

Tests/SwiftParserTest/ExpressionTests.swift

+32
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,38 @@ final class ExpressionTests: ParserTestCase {
12101210
assertParse("use(_borrow msg)")
12111211
assertParse("_borrow msg")
12121212
assertParse("let b = (_borrow self).buffer")
1213+
assertParse("borrow msg")
1214+
assertParse("use(borrow msg)")
1215+
assertParse("borrow(msg)")
1216+
assertParse("borrow (msg)")
1217+
}
1218+
1219+
func testBorrowNameFunctionCallStructure1() {
1220+
assertParse(
1221+
"""
1222+
borrow(msg)
1223+
""",
1224+
substructure: FunctionCallExprSyntax(
1225+
calledExpression: DeclReferenceExprSyntax(baseName: .identifier("borrow")),
1226+
leftParen: .leftParenToken(),
1227+
arguments: LabeledExprListSyntax([LabeledExprSyntax(expression: ExprSyntax("msg"))]),
1228+
rightParen: .rightParenToken()
1229+
)
1230+
)
1231+
}
1232+
1233+
func testBorrowNameFunctionCallStructure2() {
1234+
assertParse(
1235+
"""
1236+
borrow (msg)
1237+
""",
1238+
substructure: FunctionCallExprSyntax(
1239+
calledExpression: DeclReferenceExprSyntax(baseName: .identifier("borrow")),
1240+
leftParen: .leftParenToken(),
1241+
arguments: LabeledExprListSyntax([LabeledExprSyntax(expression: ExprSyntax("msg"))]),
1242+
rightParen: .rightParenToken()
1243+
)
1244+
)
12131245
}
12141246

12151247
func testCodeCompletionExpressions() {

0 commit comments

Comments
 (0)