Skip to content

Commit 9ae6f30

Browse files
committed
Add tests
1 parent d9c94f4 commit 9ae6f30

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

Tests/SwiftParserTest/DeclarationTests.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,29 @@ final class DeclarationTests: ParserTestCase {
12531253
)
12541254
}
12551255

1256+
func testYields() {
1257+
assertParse(
1258+
"func test() yields(Int) -> Int { }"
1259+
)
1260+
1261+
assertParse(
1262+
"func test() yields(inout Int) -> Int { }"
1263+
)
1264+
1265+
assertParse(
1266+
"func test() throws(MyError) yields(inout Int) -> Int { }"
1267+
)
1268+
1269+
assertParse(
1270+
"func test() yields(inout Int) 1️⃣throws(MyError) -> Int { }",
1271+
diagnostics: [
1272+
DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected code 'throws(MyError) -> Int' in function")
1273+
]
1274+
// TODO: Enable after fixits would be added
1275+
// fixedSource: "func test() throws(MyError) yields(inout Int) -> Int { }"
1276+
)
1277+
}
1278+
12561279
func testExtraneousRightBraceRecovery() {
12571280
assertParse(
12581281
"""

Tests/SwiftParserTest/TypeTests.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,30 @@ final class TypeTests: ParserTestCase {
772772
"""
773773
)
774774
}
775+
776+
func testYields() {
777+
assertParse(
778+
"""
779+
{ () yields(Int) -> Void in }
780+
"""
781+
)
782+
783+
assertParse(
784+
"typealias T = () yields(Int) -> Void"
785+
)
786+
787+
assertParse(
788+
"""
789+
{ () yields(inout Int) -> Void in }
790+
"""
791+
)
792+
793+
assertParse(
794+
"""
795+
{ () yields(inout Int) -> Int in }
796+
"""
797+
)
798+
}
775799
}
776800

777801
final class InlineArrayTypeTests: ParserTestCase {

0 commit comments

Comments
 (0)