Skip to content

[5.7] Fix _testDSLCaptures #556

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
Jul 6, 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
44 changes: 25 additions & 19 deletions Tests/RegexBuilderTests/RegexDSLTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,35 @@ class RegexDSLTests: XCTestCase {
let regex = content()
for (input, maybeExpectedCaptures) in tests {
let maybeMatch = input.wholeMatch(of: regex)
if let expectedCaptures = maybeExpectedCaptures,
let match = maybeMatch
{
if xfail {
XCTFail("Unexpectedly matched", file: file, line: line)
continue
guard let match = maybeMatch else {
if !xfail, maybeExpectedCaptures != nil {
XCTFail("Failed to match '\(input)'", file: file, line: line)
}
XCTAssertTrue(
type(of: regex).RegexOutput.self == MatchType.self,
"""
Expected match type: \(MatchType.self)
Actual match type: \(type(of: regex).RegexOutput.self)
""")
let captures = try XCTUnwrap(match.output as? MatchType, file: file, line: line)
XCTAssertTrue(
equivalence(captures, expectedCaptures),
"'\(captures)' is not equal to the expected '\(expectedCaptures)'.",
file: file, line: line)
} else {
continue
}
guard let expectedCaptures = maybeExpectedCaptures else {
if !xfail {
XCTAssertNil(maybeMatch, file: file, line: line)
XCTFail(
"Unexpectedly matched '\(match)' for '\(input)'",
file: file, line: line)
}
continue
}
if xfail {
XCTFail("Unexpectedly matched", file: file, line: line)
continue
}
XCTAssertTrue(
type(of: regex).RegexOutput.self == MatchType.self,
"""
Expected match type: \(MatchType.self)
Actual match type: \(type(of: regex).RegexOutput.self)
""")
let captures = try XCTUnwrap(match.output as? MatchType, file: file, line: line)
XCTAssertTrue(
equivalence(captures, expectedCaptures),
"'\(captures)' is not equal to the expected '\(expectedCaptures)'.",
file: file, line: line)
}
}

Expand Down