File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,13 @@ import XCTest
1313@testable import _MatchingEngine
1414@testable import _StringProcessing
1515
16+ struct MatchError : Error {
17+ var message : String
18+ init ( _ message: String ) {
19+ self . message = message
20+ }
21+ }
22+
1623extension Executor {
1724 func _firstMatch(
1825 _ regex: String , input: String ,
@@ -31,7 +38,7 @@ extension Executor {
3138 let caps = result. rawCaptures. slices ( from: input)
3239 return ( input [ result. range] , caps)
3340 } else if start == input. endIndex {
34- throw " match not found for \( regex) in \( input) "
41+ throw MatchError ( " match not found for \( regex) in \( input) " )
3542 } else {
3643 input. formIndex ( after: & start)
3744 }
@@ -76,27 +83,29 @@ func flatCaptureTest(
7683 if expect == nil {
7784 continue
7885 } else {
79- throw " Match failed "
86+ throw MatchError ( " Match failed " )
8087 }
8188 }
8289 guard let expect = expect else {
83- throw " Match of \( test) succeeded where failure expected in \( regex) "
90+ throw MatchError ( """
91+ Match of \( test) succeeded where failure expected in \( regex)
92+ """ )
8493 }
8594 let capStrs = caps. map { $0 == nil ? nil : String ( $0!) }
8695 guard expect. count == capStrs. count else {
87- throw """
96+ throw MatchError ( """
8897 Capture count mismatch:
8998 \( expect)
9099 \( capStrs)
91- """
100+ """ )
92101 }
93102
94103 guard expect. elementsEqual ( capStrs) else {
95- throw """
104+ throw MatchError ( """
96105 Capture mismatch:
97106 \( expect)
98107 \( capStrs)
99- """
108+ """ )
100109 }
101110 } catch {
102111 if !xfail {
You can’t perform that action at this time.
0 commit comments