Skip to content

Commit dfd917b

Browse files
committed
Document possessive quantification issues
1 parent ebd1297 commit dfd917b

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

Tests/RegexTests/MatchTests.swift

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ func firstMatchTest(
169169
XCTAssertEqual(found, match, file: file, line: line)
170170
}
171171
} catch {
172+
// FIXME: This allows non-matches to succeed even when xfail'd
173+
// When xfail == true, this should report failure for match == nil
172174
if !xfail && match != nil {
173175
XCTFail("\(error)", file: file, line: line)
174176
}
@@ -182,7 +184,9 @@ func firstMatchTests(
182184
syntax: SyntaxOptions = .traditional,
183185
enableTracing: Bool = false,
184186
dumpAST: Bool = false,
185-
xfail: Bool = false
187+
xfail: Bool = false,
188+
file: StaticString = #filePath,
189+
line: UInt = #line
186190
) {
187191
for (input, match) in tests {
188192
firstMatchTest(
@@ -192,7 +196,9 @@ func firstMatchTests(
192196
syntax: syntax,
193197
enableTracing: enableTracing,
194198
dumpAST: dumpAST,
195-
xfail: xfail)
199+
xfail: xfail,
200+
file: file,
201+
line: line)
196202
}
197203
}
198204

@@ -483,6 +489,24 @@ extension RegexTests {
483489
("baaaaaaaabc", nil),
484490
("bb", nil))
485491

492+
// XFAIL'd possessive tests
493+
firstMatchTests(
494+
"a?+a",
495+
("a", nil),
496+
xfail: true)
497+
firstMatchTests(
498+
"(a|a)?+a",
499+
("a", nil),
500+
xfail: true)
501+
firstMatchTests(
502+
"(a|a){2,4}+a",
503+
("a", nil),
504+
("aa", nil))
505+
firstMatchTests(
506+
"(a|a){2,4}+a",
507+
("aaa", nil),
508+
("aaaa", nil),
509+
xfail: true)
486510

487511
firstMatchTests(
488512
"(?:a{2,4}?b)+",

0 commit comments

Comments
 (0)