Skip to content
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
54 changes: 31 additions & 23 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 Expand Up @@ -270,10 +276,11 @@ class RegexDSLTests: XCTestCase {
}
.ignoresCase(false)
}


// FIXME: Re-enable this test
try _testDSLCaptures(
("can't stop won't stop", ("can't stop won't stop", "can't", "won't")),
matchType: (Substring, Substring, Substring).self, ==) {
matchType: (Substring, Substring, Substring).self, ==, xfail: true) {
Capture {
OneOrMore(.word)
Anchor.wordBoundary
Expand All @@ -289,10 +296,11 @@ class RegexDSLTests: XCTestCase {
OneOrMore(.any, .reluctant)
"stop"
}


// FIXME: Re-enable this test
try _testDSLCaptures(
("can't stop won't stop", ("can't stop won't stop", "can", "won")),
matchType: (Substring, Substring, Substring).self, ==) {
matchType: (Substring, Substring, Substring).self, ==, xfail: true) {
Capture {
OneOrMore(.word)
Anchor.wordBoundary
Expand Down