Debian Codegraph @

.cargo/vendor/regex/testdata/regression.toml

raw
1 # See: https://github.com/rust-lang/regex/issues/48
2 [[test]]
3 name = "invalid-regex-no-crash-100"
4 regex = '(*)'
5 haystack = ""
6 matches = []
7 compiles = false
8
9 # See: https://github.com/rust-lang/regex/issues/48
10 [[test]]
11 name = "invalid-regex-no-crash-200"
12 regex = '(?:?)'
13 haystack = ""
14 matches = []
15 compiles = false
16
17 # See: https://github.com/rust-lang/regex/issues/48
18 [[test]]
19 name = "invalid-regex-no-crash-300"
20 regex = '(?)'
21 haystack = ""
22 matches = []
23 compiles = false
24
25 # See: https://github.com/rust-lang/regex/issues/48
26 [[test]]
27 name = "invalid-regex-no-crash-400"
28 regex = '*'
29 haystack = ""
30 matches = []
31 compiles = false
32
33 # See: https://github.com/rust-lang/regex/issues/75
34 [[test]]
35 name = "unsorted-binary-search-100"
36 regex = '(?i-u)[a_]+'
37 haystack = "A_"
38 matches = [[0, 2]]
39
40 # See: https://github.com/rust-lang/regex/issues/75
41 [[test]]
42 name = "unsorted-binary-search-200"
43 regex = '(?i-u)[A_]+'
44 haystack = "a_"
45 matches = [[0, 2]]
46
47 # See: https://github.com/rust-lang/regex/issues/76
48 [[test]]
49 name = "unicode-case-lower-nocase-flag"
50 regex = '(?i)\p{Ll}+'
51 haystack = "ΛΘΓΔα"
52 matches = [[0, 10]]
53
54 # See: https://github.com/rust-lang/regex/issues/99
55 [[test]]
56 name = "negated-char-class-100"
57 regex = '(?i)[^x]'
58 haystack = "x"
59 matches = []
60
61 # See: https://github.com/rust-lang/regex/issues/99
62 [[test]]
63 name = "negated-char-class-200"
64 regex = '(?i)[^x]'
65 haystack = "X"
66 matches = []
67
68 # See: https://github.com/rust-lang/regex/issues/101
69 [[test]]
70 name = "ascii-word-underscore"
71 regex = '[[:word:]]'
72 haystack = "_"
73 matches = [[0, 1]]
74
75 # See: https://github.com/rust-lang/regex/issues/129
76 [[test]]
77 name = "captures-repeat"
78 regex = '([a-f]){2}(?P<foo>[x-z])'
79 haystack = "abx"
80 matches = [
81 [[0, 3], [1, 2], [2, 3]],
82 ]
83
84 # See: https://github.com/rust-lang/regex/issues/153
85 [[test]]
86 name = "alt-in-alt-100"
87 regex = 'ab?|$'
88 haystack = "az"
89 matches = [[0, 1], [2, 2]]
90
91 # See: https://github.com/rust-lang/regex/issues/153
92 [[test]]
93 name = "alt-in-alt-200"
94 regex = '^(?:.*?)(?:\n|\r\n?|$)'
95 haystack = "ab\rcd"
96 matches = [[0, 3]]
97
98 # See: https://github.com/rust-lang/regex/issues/169
99 [[test]]
100 name = "leftmost-first-prefix"
101 regex = 'z*azb'
102 haystack = "azb"
103 matches = [[0, 3]]
104
105 # See: https://github.com/rust-lang/regex/issues/191
106 [[test]]
107 name = "many-alternates"
108 regex = '1|2|3|4|5|6|7|8|9|10|int'
109 haystack = "int"
110 matches = [[0, 3]]
111
112 # See: https://github.com/rust-lang/regex/issues/204
113 [[test]]
114 name = "word-boundary-alone-100"
115 regex = '\b'
116 haystack = "Should this (work?)"
117 matches = [[0, 0], [6, 6], [7, 7], [11, 11], [13, 13], [17, 17]]
118
119 # See: https://github.com/rust-lang/regex/issues/204
120 [[test]]
121 name = "word-boundary-alone-200"
122 regex = '\b'
123 haystack = "a b c"
124 matches = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]
125
126 # See: https://github.com/rust-lang/regex/issues/264
127 [[test]]
128 name = "word-boundary-ascii-no-capture"
129 regex = '\B'
130 haystack = "\U00028F3E"
131 matches = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]
132 unicode = false
133 utf8 = false
134
135 # See: https://github.com/rust-lang/regex/issues/264
136 [[test]]
137 name = "word-boundary-ascii-capture"
138 regex = '(?:\B)'
139 haystack = "\U00028F3E"
140 matches = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]
141 unicode = false
142 utf8 = false
143
144 # See: https://github.com/rust-lang/regex/issues/268
145 [[test]]
146 name = "partial-anchor"
147 regex = '^a|b'
148 haystack = "ba"
149 matches = [[0, 1]]
150
151 # See: https://github.com/rust-lang/regex/issues/271
152 [[test]]
153 name = "endl-or-word-boundary"
154 regex = '(?m:$)|(?-u:\b)'
155 haystack = "\U0006084E"
156 matches = [[4, 4]]
157
158 # See: https://github.com/rust-lang/regex/issues/271
159 [[test]]
160 name = "zero-or-end"
161 regex = '(?i-u:\x00)|$'
162 haystack = "\U000E682F"
163 matches = [[4, 4]]
164
165 # See: https://github.com/rust-lang/regex/issues/271
166 [[test]]
167 name = "y-or-endl"
168 regex = '(?i-u:y)|(?m:$)'
169 haystack = "\U000B4331"
170 matches = [[4, 4]]
171
172 # See: https://github.com/rust-lang/regex/issues/271
173 [[test]]
174 name = "word-boundary-start-x"
175 regex = '(?u:\b)^(?-u:X)'
176 haystack = "X"
177 matches = [[0, 1]]
178
179 # See: https://github.com/rust-lang/regex/issues/271
180 [[test]]
181 name = "word-boundary-ascii-start-x"
182 regex = '(?-u:\b)^(?-u:X)'
183 haystack = "X"
184 matches = [[0, 1]]
185
186 # See: https://github.com/rust-lang/regex/issues/271
187 [[test]]
188 name = "end-not-word-boundary"
189 regex = '$\B'
190 haystack = "\U0005C124\U000B576C"
191 matches = [[8, 8]]
192 unicode = false
193 utf8 = false
194
195 # See: https://github.com/rust-lang/regex/issues/280
196 [[test]]
197 name = "partial-anchor-alternate-begin"
198 regex = '^a|z'
199 haystack = "yyyyya"
200 matches = []
201
202 # See: https://github.com/rust-lang/regex/issues/280
203 [[test]]
204 name = "partial-anchor-alternate-end"
205 regex = 'a$|z'
206 haystack = "ayyyyy"
207 matches = []
208
209 # See: https://github.com/rust-lang/regex/issues/289
210 [[test]]
211 name = "lits-unambiguous-100"
212 regex = '(?:ABC|CDA|BC)X'
213 haystack = "CDAX"
214 matches = [[0, 4]]
215
216 # See: https://github.com/rust-lang/regex/issues/291
217 [[test]]
218 name = "lits-unambiguous-200"
219 regex = '((IMG|CAM|MG|MB2)_|(DSCN|CIMG))(?P<n>[0-9]+)$'
220 haystack = "CIMG2341"
221 matches = [
222 [[0, 8], [0, 4], [], [0, 4], [4, 8]],
223 ]
224
225 # See: https://github.com/rust-lang/regex/issues/303
226 #
227 # 2022-09-19: This has now been "properly" fixed in that empty character
228 # classes are fully supported as something that can never match. This test
229 # used to be marked as 'compiles = false', but now it works.
230 [[test]]
231 name = "negated-full-byte-range"
232 regex = '[^\x00-\xFF]'
233 haystack = ""
234 matches = []
235 compiles = true
236 unicode = false
237 utf8 = false
238
239 # See: https://github.com/rust-lang/regex/issues/321
240 [[test]]
241 name = "strange-anchor-non-complete-prefix"
242 regex = 'a^{2}'
243 haystack = ""
244 matches = []
245
246 # See: https://github.com/rust-lang/regex/issues/321
247 [[test]]
248 name = "strange-anchor-non-complete-suffix"
249 regex = '${2}a'
250 haystack = ""
251 matches = []
252
253 # See: https://github.com/rust-lang/regex/issues/334
254 # See: https://github.com/rust-lang/regex/issues/557
255 [[test]]
256 name = "captures-after-dfa-premature-end-100"
257 regex = 'a(b*(X|$))?'
258 haystack = "abcbX"
259 matches = [
260 [[0, 1], [], []],
261 ]
262
263 # See: https://github.com/rust-lang/regex/issues/334
264 # See: https://github.com/rust-lang/regex/issues/557
265 [[test]]
266 name = "captures-after-dfa-premature-end-200"
267 regex = 'a(bc*(X|$))?'
268 haystack = "abcbX"
269 matches = [
270 [[0, 1], [], []],
271 ]
272
273 # See: https://github.com/rust-lang/regex/issues/334
274 # See: https://github.com/rust-lang/regex/issues/557
275 [[test]]
276 name = "captures-after-dfa-premature-end-300"
277 regex = '(aa$)?'
278 haystack = "aaz"
279 matches = [
280 [[0, 0], []],
281 [[1, 1], []],
282 [[2, 2], []],
283 [[3, 3], []],
284 ]
285
286 # Plucked from "Why aren’t regular expressions a lingua franca? an empirical
287 # study on the re-use and portability of regular expressions", The ACM Joint
288 # European Software Engineering Conference and Symposium on the Foundations of
289 # Software Engineering (ESEC/FSE), 2019.
290 #
291 # Link: https://dl.acm.org/doi/pdf/10.1145/3338906.3338909
292 [[test]]
293 name = "captures-after-dfa-premature-end-400"
294 regex = '(a)\d*\.?\d+\b'
295 haystack = "a0.0c"
296 matches = [
297 [[0, 2], [0, 1]],
298 ]
299
300 # See: https://github.com/rust-lang/regex/issues/437
301 [[test]]
302 name = "literal-panic"
303 regex = 'typename type\-parameter\-[0-9]+\-[0-9]+::.+'
304 haystack = "test"
305 matches = []
306
307 # See: https://github.com/rust-lang/regex/issues/527
308 [[test]]
309 name = "empty-flag-expr"
310 regex = '(?:(?:(?x)))'
311 haystack = ""
312 matches = [[0, 0]]
313
314 # See: https://github.com/rust-lang/regex/issues/533
315 #[[tests]]
316 #name = "blank-matches-nothing-between-space-and-tab"
317 #regex = '[[:blank:]]'
318 #input = '\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F'
319 #match = false
320 #unescape = true
321
322 # See: https://github.com/rust-lang/regex/issues/533
323 #[[tests]]
324 #name = "blank-matches-nothing-between-space-and-tab-inverted"
325 #regex = '^[[:^blank:]]+$'
326 #input = '\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F'
327 #match = true
328 #unescape = true
329
330 # See: https://github.com/rust-lang/regex/issues/555
331 [[test]]
332 name = "invalid-repetition"
333 regex = '(?m){1,1}'
334 haystack = ""
335 matches = []
336 compiles = false
337
338 # See: https://github.com/rust-lang/regex/issues/640
339 [[test]]
340 name = "flags-are-unset"
341 regex = '(?:(?i)foo)|Bar'
342 haystack = "foo Foo bar Bar"
343 matches = [[0, 3], [4, 7], [12, 15]]
344
345 # Note that 'Ј' is not 'j', but cyrillic Je
346 # https://en.wikipedia.org/wiki/Je_(Cyrillic)
347 #
348 # See: https://github.com/rust-lang/regex/issues/659
349 [[test]]
350 name = "empty-group-with-unicode"
351 regex = '(?:)Ј01'
352 haystack = 'zЈ01'
353 matches = [[1, 5]]
354
355 # See: https://github.com/rust-lang/regex/issues/579
356 [[test]]
357 name = "word-boundary-weird"
358 regex = '\b..\b'
359 haystack = "I have 12, he has 2!"
360 matches = [[0, 2], [7, 9], [9, 11], [11, 13], [17, 19]]
361
362 # See: https://github.com/rust-lang/regex/issues/579
363 [[test]]
364 name = "word-boundary-weird-ascii"
365 regex = '\b..\b'
366 haystack = "I have 12, he has 2!"
367 matches = [[0, 2], [7, 9], [9, 11], [11, 13], [17, 19]]
368 unicode = false
369 utf8 = false
370
371 # See: https://github.com/rust-lang/regex/issues/579
372 [[test]]
373 name = "word-boundary-weird-minimal-ascii"
374 regex = '\b..\b'
375 haystack = "az,,b"
376 matches = [[0, 2], [2, 4]]
377 unicode = false
378 utf8 = false
379
380 # See: https://github.com/BurntSushi/ripgrep/issues/1203
381 [[test]]
382 name = "reverse-suffix-100"
383 regex = '[0-4][0-4][0-4]000'
384 haystack = "153.230000"
385 matches = [[4, 10]]
386
387 # See: https://github.com/BurntSushi/ripgrep/issues/1203
388 [[test]]
389 name = "reverse-suffix-200"
390 regex = '[0-9][0-9][0-9]000'
391 haystack = "153.230000\n"
392 matches = [[4, 10]]
393
394 # This is a tricky case for the reverse suffix optimization, because it
395 # finds the 'foobar' match but the reverse scan must fail to find a match by
396 # correctly dealing with the word boundary following the 'foobar' literal when
397 # computing the start state.
398 #
399 # This test exists because I tried to break the following assumption that
400 # is currently in the code: that if a suffix is found and the reverse scan
401 # succeeds, then it's guaranteed that there is an overall match. Namely, the
402 # 'is_match' routine does *not* do another forward scan in this case because of
403 # this assumption.
404 [[test]]
405 name = "reverse-suffix-300"
406 regex = '\w+foobar\b'
407 haystack = "xyzfoobarZ"
408 matches = []
409 unicode = false
410 utf8 = false
411
412 # See: https://github.com/BurntSushi/ripgrep/issues/1247
413 [[test]]
414 name = "stops"
415 regex = '\bs(?:[ab])'
416 haystack = 's\xE4'
417 matches = []
418 unescape = true
419 utf8 = false
420
421 # See: https://github.com/BurntSushi/ripgrep/issues/1247
422 [[test]]
423 name = "stops-ascii"
424 regex = '(?-u:\b)s(?:[ab])'
425 haystack = 's\xE4'
426 matches = []
427 unescape = true
428 utf8 = false
429
430 # See: https://github.com/rust-lang/regex/issues/850
431 [[test]]
432 name = "adjacent-line-boundary-100"
433 regex = '(?m)^(?:[^ ]+?)$'
434 haystack = "line1\nline2"
435 matches = [[0, 5], [6, 11]]
436
437 # Continued.
438 [[test]]
439 name = "adjacent-line-boundary-200"
440 regex = '(?m)^(?:[^ ]+?)$'
441 haystack = "A\nB"
442 matches = [[0, 1], [2, 3]]
443
444 # There is no issue for this bug.
445 [[test]]
446 name = "anchored-prefix-100"
447 regex = '^a[[:^space:]]'
448 haystack = "a "
449 matches = []
450
451 # There is no issue for this bug.
452 [[test]]
453 name = "anchored-prefix-200"
454 regex = '^a[[:^space:]]'
455 haystack = "foo boo a"
456 matches = []
457
458 # There is no issue for this bug.
459 [[test]]
460 name = "anchored-prefix-300"
461 regex = '^-[a-z]'
462 haystack = "r-f"
463 matches = []
464
465 # Tests that a possible Aho-Corasick optimization works correctly. It only
466 # kicks in when we have a lot of literals. By "works correctly," we mean that
467 # leftmost-first match semantics are properly respected. That is, samwise
468 # should match, not sam.
469 #
470 # There is no issue for this bug.
471 [[test]]
472 name = "aho-corasick-100"
473 regex = 'samwise|sam|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z'
474 haystack = "samwise"
475 matches = [[0, 7]]
476
477 # See: https://github.com/rust-lang/regex/issues/921
478 [[test]]
479 name = "interior-anchor-capture"
480 regex = '(a$)b$'
481 haystack = 'ab'
482 matches = []
483
484 # I found this bug in the course of adding some of the regexes that Ruff uses
485 # to rebar. It turns out that the lazy DFA was finding a match that was being
486 # rejected by the one-pass DFA. Yikes. I then minimized the regex and haystack.
487 #
488 # Source: https://github.com/charliermarsh/ruff/blob/a919041ddaa64cdf6f216f90dd0480dab69fd3ba/crates/ruff/src/rules/pycodestyle/rules/whitespace_around_keywords.rs#L52
489 [[test]]
490 name = "ruff-whitespace-around-keywords"
491 regex = '^(a|ab)$'
492 haystack = "ab"
493 anchored = true
494 unicode = false
495 utf8 = true
496 matches = [[[0, 2], [0, 2]]]
497
498 # From: https://github.com/rust-lang/regex/issues/429
499 [[test]]
500 name = "i429-0"
501 regex = '(?:(?-u:\b)|(?u:h))+'
502 haystack = "h"
503 unicode = true
504 utf8 = false
505 matches = [[0, 0], [1, 1]]
506
507 # From: https://github.com/rust-lang/regex/issues/429
508 [[test]]
509 name = "i429-1"
510 regex = '(?u:\B)'
511 haystack = "鋸"
512 unicode = true
513 utf8 = false
514 matches = []
515
516 # From: https://github.com/rust-lang/regex/issues/429
517 [[test]]
518 name = "i429-2"
519 regex = '(?:(?u:\b)|(?s-u:.))+'
520 haystack = "oB"
521 unicode = true
522 utf8 = false
523 matches = [[0, 0], [1, 2]]
524
525 # From: https://github.com/rust-lang/regex/issues/429
526 [[test]]
527 name = "i429-3"
528 regex = '(?:(?-u:\B)|(?su:.))+'
529 haystack = "\U000FEF80"
530 unicode = true
531 utf8 = false
532 matches = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]
533
534 # From: https://github.com/rust-lang/regex/issues/429
535 [[test]]
536 name = "i429-3-utf8"
537 regex = '(?:(?-u:\B)|(?su:.))+'
538 haystack = "\U000FEF80"
539 unicode = true
540 utf8 = true
541 matches = [[0, 0], [4, 4]]
542
543 # From: https://github.com/rust-lang/regex/issues/429
544 [[test]]
545 name = "i429-4"
546 regex = '(?m:$)(?m:^)(?su:.)'
547 haystack = "\n‣"
548 unicode = true
549 utf8 = false
550 matches = [[0, 1]]
551
552 # From: https://github.com/rust-lang/regex/issues/429
553 [[test]]
554 name = "i429-5"
555 regex = '(?m:$)^(?m:^)'
556 haystack = "\n"
557 unicode = true
558 utf8 = false
559 matches = [[0, 0]]
560
561 # From: https://github.com/rust-lang/regex/issues/429
562 [[test]]
563 name = "i429-6"
564 regex = '(?P<kp>(?iu:do)(?m:$))*'
565 haystack = "dodo"
566 unicode = true
567 utf8 = false
568 matches = [
569 [[0, 0], []],
570 [[1, 1], []],
571 [[2, 4], [2, 4]],
572 ]
573
574 # From: https://github.com/rust-lang/regex/issues/429
575 [[test]]
576 name = "i429-7"
577 regex = '(?u:\B)'
578 haystack = "䡁"
579 unicode = true
580 utf8 = false
581 matches = []
582
583 # From: https://github.com/rust-lang/regex/issues/429
584 [[test]]
585 name = "i429-8"
586 regex = '(?:(?-u:\b)|(?u:[\u{0}-W]))+'
587 haystack = "0"
588 unicode = true
589 utf8 = false
590 matches = [[0, 0], [1, 1]]
591
592 # From: https://github.com/rust-lang/regex/issues/429
593 [[test]]
594 name = "i429-9"
595 regex = '((?m:$)(?-u:\B)(?s-u:.)(?-u:\B)$)'
596 haystack = "\n\n"
597 unicode = true
598 utf8 = false
599 matches = [
600 [[1, 2], [1, 2]],
601 ]
602
603 # From: https://github.com/rust-lang/regex/issues/429
604 [[test]]
605 name = "i429-10"
606 regex = '(?m:$)(?m:$)^(?su:.)'
607 haystack = "\n\u0081¨\u200a"
608 unicode = true
609 utf8 = false
610 matches = [[0, 1]]
611
612 # From: https://github.com/rust-lang/regex/issues/429
613 [[test]]
614 name = "i429-11"
615 regex = '(?-u:\B)(?m:^)'
616 haystack = "0\n"
617 unicode = true
618 utf8 = false
619 matches = [[2, 2]]
620
621 # From: https://github.com/rust-lang/regex/issues/429
622 [[test]]
623 name = "i429-12"
624 regex = '(?:(?u:\b)|(?-u:.))+'
625 haystack = "0"
626 unicode = true
627 utf8 = false
628 matches = [[0, 0], [1, 1]]
629
630 # From: https://github.com/rust-lang/regex/issues/969
631 [[test]]
632 name = "i969"
633 regex = 'c.*d\z'
634 haystack = "ababcd"
635 bounds = [4, 6]
636 search-kind = "earliest"
637 matches = [[4, 6]]
638
639 # I found this during the regex-automata migration. This is the fowler basic
640 # 154 test, but without anchored = true and without a match limit.
641 #
642 # This test caught a subtle bug in the hybrid reverse DFA search, where it
643 # would skip over the termination condition if it entered a start state. This
644 # was a double bug. Firstly, the reverse DFA shouldn't have had start states
645 # specialized in the first place, and thus it shouldn't have possible to detect
646 # that the DFA had entered a start state. The second bug was that the start
647 # state handling was incorrect by jumping over the termination condition.
648 [[test]]
649 name = "fowler-basic154-unanchored"
650 regex = '''a([bc]*)c*'''
651 haystack = '''abc'''
652 matches = [[[0, 3], [1, 3]]]
653
654 # From: https://github.com/rust-lang/regex/issues/981
655 #
656 # This was never really a problem in the new architecture because the
657 # regex-automata engines are far more principled about how they deal with
658 # look-around. (This was one of the many reasons I wanted to re-work the
659 # original regex crate engines.)
660 [[test]]
661 name = "word-boundary-interact-poorly-with-literal-optimizations"
662 regex = '(?i:(?:\b|_)win(?:32|64|dows)?(?:\b|_))'
663 haystack = 'ubi-Darwin-x86_64.tar.gz'
664 matches = []
665
666 # This was found during fuzz testing of regex. It provoked a panic in the meta
667 # engine as a result of the reverse suffix optimization. Namely, it hit a case
668 # where a suffix match was found, a corresponding reverse match was found, but
669 # the forward search turned up no match. The forward search should always match
670 # if the suffix and reverse search match.
671 #
672 # This in turn uncovered an inconsistency between the PikeVM and the DFA (lazy
673 # and fully compiled) engines. It was caused by a mishandling of the collection
674 # of NFA state IDs in the generic determinization code (which is why both types
675 # of DFA were impacted). Namely, when a fail state was encountered (that's the
676 # `[^\s\S]` in the pattern below), then it would just stop collecting states.
677 # But that's not correct since a later state could lead to a match.
678 [[test]]
679 name = "impossible-branch"
680 regex = '.*[^\s\S]A|B'
681 haystack = "B"
682 matches = [[0, 1]]
683
684 # This was found during fuzz testing in regex-lite. The regex crate never
685 # suffered from this bug, but it causes regex-lite to incorrectly compile
686 # captures.
687 [[test]]
688 name = "captures-wrong-order"
689 regex = '(a){0}(a)'
690 haystack = 'a'
691 matches = [[[0, 1], [], [0, 1]]]
692
693 # This tests a bug in how quit states are handled in the DFA. At some point
694 # during development, the DFAs were tweaked slightly such that if they hit
695 # a quit state (which means, they hit a byte that the caller configured should
696 # stop the search), then it might not return an error necessarily. Namely, if a
697 # match had already been found, then it would be returned instead of an error.
698 #
699 # But this is actually wrong! Why? Because even though a match had been found,
700 # it wouldn't be fully correct to return it once a quit state has been seen
701 # because you can't determine whether the match offset returned is the correct
702 # greedy/leftmost-first match. Since you can't complete the search as requested
703 # by the caller, the DFA should just stop and return an error.
704 #
705 # Interestingly, this does seem to produce an unavoidable difference between
706 # 'try_is_match().unwrap()' and 'try_find().unwrap().is_some()' for the DFAs.
707 # The former will stop immediately once a match is known to occur and return
708 # 'Ok(true)', where as the latter could find the match but quit with an
709 # 'Err(..)' first.
710 #
711 # Thankfully, I believe this inconsistency between 'is_match()' and 'find()'
712 # cannot be observed in the higher level meta regex API because it specifically
713 # will try another engine that won't fail in the case of a DFA failing.
714 #
715 # This regression happened in the regex crate rewrite, but before anything got
716 # released.
717 [[test]]
718 name = "negated-unicode-word-boundary-dfa-fail"
719 regex = '\B.*'
720 haystack = "!\u02D7"
721 matches = [[0, 3]]
722
723 # This failure was found in the *old* regex crate (prior to regex 1.9), but
724 # I didn't investigate why. My best guess is that it's a literal optimization
725 # bug. It didn't occur in the rewrite.
726 [[test]]
727 name = "missed-match"
728 regex = 'e..+e.ee>'
729 haystack = 'Zeee.eZZZZZZZZeee>eeeeeee>'
730 matches = [[1, 26]]
731
732 # This test came from the 'ignore' crate and tripped a bug in how accelerated
733 # DFA states were handled in an overlapping search.
734 [[test]]
735 name = "regex-to-glob"
736 regex = ['(?-u)^path1/[^/]*$']
737 haystack = "path1/foo"
738 matches = [[0, 9]]
739 utf8 = false
740 match-kind = "all"
741 search-kind = "overlapping"
742
743 # See: https://github.com/rust-lang/regex/issues/1060
744 [[test]]
745 name = "reverse-inner-plus-shorter-than-expected"
746 regex = '(?:(\d+)[:.])?(\d{1,2})[:.](\d{2})'
747 haystack = '102:12:39'
748 matches = [[[0, 9], [0, 3], [4, 6], [7, 9]]]
749
750 # Like reverse-inner-plus-shorter-than-expected, but using a far simpler regex
751 # to demonstrate the extent of the rot. Sigh.
752 #
753 # See: https://github.com/rust-lang/regex/issues/1060
754 [[test]]
755 name = "reverse-inner-short"
756 regex = '(?:([0-9][0-9][0-9]):)?([0-9][0-9]):([0-9][0-9])'
757 haystack = '102:12:39'
758 matches = [[[0, 9], [0, 3], [4, 6], [7, 9]]]
759
760 # This regression test was found via the RegexSet APIs. It triggered a
761 # particular code path where a regex was compiled with 'All' match semantics
762 # (to support overlapping search), but got funneled down into a standard
763 # leftmost search when calling 'is_match'. This is fine on its own, but the
764 # leftmost search will use a prefilter and that's where this went awry.
765 #
766 # Namely, since 'All' semantics were used, the aho-corasick prefilter was
767 # incorrectly compiled with 'Standard' semantics. This was wrong because
768 # 'Standard' immediately attempts to report a match at every position, even if
769 # that would mean reporting a match past the leftmost match before reporting
770 # the leftmost match. This breaks the prefilter contract of never having false
771 # negatives and leads overall to the engine not finding a match.
772 #
773 # See: https://github.com/rust-lang/regex/issues/1070
774 [[test]]
775 name = "prefilter-with-aho-corasick-standard-semantics"
776 regex = '(?m)^ *v [0-9]'
777 haystack = 'v 0'
778 matches = [
779 { id = 0, spans = [[0, 3]] },
780 ]
781 match-kind = "all"
782 search-kind = "overlapping"
783 unicode = true
784 utf8 = true
785
786 # This tests that the PikeVM and the meta regex agree on a particular regex.
787 # This test previously failed when the ad hoc engines inside the meta engine
788 # did not handle quit states correctly. Namely, the Unicode word boundary here
789 # combined with a non-ASCII codepoint provokes the quit state. The ad hoc
790 # engines were previously returning a match even after entering the quit state
791 # if a match had been previously detected, but this is incorrect. The reason
792 # is that if a quit state is found, then the search must give up *immediately*
793 # because it prevents the search from finding the "proper" leftmost-first
794 # match. If it instead returns a match that has been found, it risks reporting
795 # an improper match, as it did in this case.
796 #
797 # See: https://github.com/rust-lang/regex/issues/1046
798 [[test]]
799 name = "non-prefix-literal-quit-state"
800 regex = '.+\b\n'
801 haystack = "β77\n"
802 matches = [[0, 5]]
803
804 # This is a regression test for some errant HIR interval set operations that
805 # were made in the regex-syntax 0.8.0 release and then reverted in 0.8.1. The
806 # issue here is that the HIR produced from the regex had out-of-order ranges.
807 #
808 # See: https://github.com/rust-lang/regex/issues/1103
809 # Ref: https://github.com/rust-lang/regex/pull/1051
810 # Ref: https://github.com/rust-lang/regex/pull/1102
811 [[test]]
812 name = "hir-optimization-out-of-order-class"
813 regex = '^[[:alnum:]./-]+$'
814 haystack = "a-b"
815 matches = [[0, 3]]
816
817 # This is a regression test for an improper reverse suffix optimization. This
818 # occurred when I "broadened" the applicability of the optimization to include
819 # multiple possible literal suffixes instead of only sticking to a non-empty
820 # longest common suffix. It turns out that, at least given how the reverse
821 # suffix optimization works, we need to stick to the longest common suffix for
822 # now.
823 #
824 # See: https://github.com/rust-lang/regex/issues/1110
825 # See also: https://github.com/astral-sh/ruff/pull/7980
826 [[test]]
827 name = 'improper-reverse-suffix-optimization'
828 regex = '(\\N\{[^}]+})|([{}])'
829 haystack = 'hiya \N{snowman} bye'
830 matches = [[[5, 16], [5, 16], []]]