Skip to content

Commit d6a6e22

Browse files
committed
Allow matching tests to specify semantic level
1 parent 65178f9 commit d6a6e22

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Tests/RegexTests/MatchTests.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ func _firstMatch(
2424
_ regexStr: String,
2525
input: String,
2626
validateOptimizations: Bool,
27+
semanticLevel: RegexSemanticLevel = .graphemeCluster,
2728
syntax: SyntaxOptions = .traditional
2829
) throws -> (String, [String?]) {
29-
var regex = try Regex(regexStr, syntax: syntax)
30+
var regex = try Regex(regexStr, syntax: syntax).matchingSemantics(semanticLevel)
3031
guard let result = try regex.firstMatch(in: input) else {
3132
throw MatchError("match not found for \(regexStr) in \(input)")
3233
}
@@ -54,6 +55,7 @@ func flatCaptureTest(
5455
dumpAST: Bool = false,
5556
xfail: Bool = false,
5657
validateOptimizations: Bool = true,
58+
semanticLevel: RegexSemanticLevel = .graphemeCluster,
5759
file: StaticString = #file,
5860
line: UInt = #line
5961
) {
@@ -63,6 +65,7 @@ func flatCaptureTest(
6365
regex,
6466
input: test,
6567
validateOptimizations: validateOptimizations,
68+
semanticLevel: semanticLevel,
6669
syntax: syntax
6770
) else {
6871
if expect == nil {
@@ -113,6 +116,7 @@ func matchTest(
113116
dumpAST: Bool = false,
114117
xfail: Bool = false,
115118
validateOptimizations: Bool = true,
119+
semanticLevel: RegexSemanticLevel = .graphemeCluster,
116120
file: StaticString = #file,
117121
line: UInt = #line
118122
) {
@@ -126,6 +130,7 @@ func matchTest(
126130
dumpAST: dumpAST,
127131
xfail: xfail,
128132
validateOptimizations: validateOptimizations,
133+
semanticLevel: semanticLevel,
129134
file: file,
130135
line: line)
131136
}
@@ -143,6 +148,7 @@ func firstMatchTest(
143148
dumpAST: Bool = false,
144149
xfail: Bool = false,
145150
validateOptimizations: Bool = true,
151+
semanticLevel: RegexSemanticLevel = .graphemeCluster,
146152
file: StaticString = #filePath,
147153
line: UInt = #line
148154
) {
@@ -151,6 +157,7 @@ func firstMatchTest(
151157
regex,
152158
input: input,
153159
validateOptimizations: validateOptimizations,
160+
semanticLevel: semanticLevel,
154161
syntax: syntax)
155162

156163
if xfail {

0 commit comments

Comments
 (0)