Skip to content

Add additional capture transform tests. #471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Tests/RegexBuilderTests/RegexDSLTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,29 @@ class RegexDSLTests: XCTestCase {
*/
}

func testCaptureTransform() throws {
try _testDSLCaptures(
("aaaa1", ("aaaa1", "aaa")),
matchType: (Substring, Substring).self, ==)
{
Capture {
OneOrMore("a")
} transform: {
$0.dropFirst()
}
One(.digit)
}
try _testDSLCaptures(
("aaaa1", ("aaaa1", "a")),
matchType: (Substring, Substring??).self, ==)
{
ZeroOrMore {
Capture("a", transform: { Optional.some($0) })
}
One(.digit)
}
}

func testCapturelessQuantification() throws {
// This test is to make sure that a captureless quantification, when used
// straight out of the quantifier (without being wrapped in a builder), is
Expand Down