Skip to content

Commit 18f2d61

Browse files
authored
Merge pull request #471 from rxwei/test-267
Add additional capture transform tests.
2 parents 4665622 + 17d8362 commit 18f2d61

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Tests/RegexBuilderTests/RegexDSLTests.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,29 @@ class RegexDSLTests: XCTestCase {
525525
*/
526526
}
527527

528+
func testCaptureTransform() throws {
529+
try _testDSLCaptures(
530+
("aaaa1", ("aaaa1", "aaa")),
531+
matchType: (Substring, Substring).self, ==)
532+
{
533+
Capture {
534+
OneOrMore("a")
535+
} transform: {
536+
$0.dropFirst()
537+
}
538+
One(.digit)
539+
}
540+
try _testDSLCaptures(
541+
("aaaa1", ("aaaa1", "a")),
542+
matchType: (Substring, Substring??).self, ==)
543+
{
544+
ZeroOrMore {
545+
Capture("a", transform: { Optional.some($0) })
546+
}
547+
One(.digit)
548+
}
549+
}
550+
528551
func testCapturelessQuantification() throws {
529552
// This test is to make sure that a captureless quantification, when used
530553
// straight out of the quantifier (without being wrapped in a builder), is

0 commit comments

Comments
 (0)