@@ -26,29 +26,35 @@ class RegexDSLTests: XCTestCase {
26
26
let regex = content ( )
27
27
for (input, maybeExpectedCaptures) in tests {
28
28
let maybeMatch = input. wholeMatch ( of: regex)
29
- if let expectedCaptures = maybeExpectedCaptures,
30
- let match = maybeMatch
31
- {
32
- if xfail {
33
- XCTFail ( " Unexpectedly matched " , file: file, line: line)
34
- continue
29
+ guard let match = maybeMatch else {
30
+ if !xfail, maybeExpectedCaptures != nil {
31
+ XCTFail ( " Failed to match ' \( input) ' " , file: file, line: line)
35
32
}
36
- XCTAssertTrue (
37
- type ( of: regex) . RegexOutput. self == MatchType . self,
38
- """
39
- Expected match type: \( MatchType . self)
40
- Actual match type: \( type ( of: regex) . RegexOutput. self)
41
- """ )
42
- let captures = try XCTUnwrap ( match. output as? MatchType , file: file, line: line)
43
- XCTAssertTrue (
44
- equivalence ( captures, expectedCaptures) ,
45
- " ' \( captures) ' is not equal to the expected ' \( expectedCaptures) '. " ,
46
- file: file, line: line)
47
- } else {
33
+ continue
34
+ }
35
+ guard let expectedCaptures = maybeExpectedCaptures else {
48
36
if !xfail {
49
- XCTAssertNil ( maybeMatch, file: file, line: line)
37
+ XCTFail (
38
+ " Unexpectedly matched ' \( match) ' for ' \( input) ' " ,
39
+ file: file, line: line)
50
40
}
41
+ continue
42
+ }
43
+ if xfail {
44
+ XCTFail ( " Unexpectedly matched " , file: file, line: line)
45
+ continue
51
46
}
47
+ XCTAssertTrue (
48
+ type ( of: regex) . RegexOutput. self == MatchType . self,
49
+ """
50
+ Expected match type: \( MatchType . self)
51
+ Actual match type: \( type ( of: regex) . RegexOutput. self)
52
+ """ )
53
+ let captures = try XCTUnwrap ( match. output as? MatchType , file: file, line: line)
54
+ XCTAssertTrue (
55
+ equivalence ( captures, expectedCaptures) ,
56
+ " ' \( captures) ' is not equal to the expected ' \( expectedCaptures) '. " ,
57
+ file: file, line: line)
52
58
}
53
59
}
54
60
0 commit comments