Debian Codegraph @

.cargo/vendor/regex/testdata/set.toml

raw
1 # Basic multi-regex tests.
2
3 [[test]]
4 name = "basic10"
5 regex = ["a", "a"]
6 haystack = "a"
7 matches = [
8 { id = 0, span = [0, 1] },
9 { id = 1, span = [0, 1] },
10 ]
11 match-kind = "all"
12 search-kind = "overlapping"
13
14 [[test]]
15 name = "basic10-leftmost-first"
16 regex = ["a", "a"]
17 haystack = "a"
18 matches = [
19 { id = 0, span = [0, 1] },
20 ]
21 match-kind = "leftmost-first"
22 search-kind = "leftmost"
23
24 [[test]]
25 name = "basic20"
26 regex = ["a", "a"]
27 haystack = "ba"
28 matches = [
29 { id = 0, span = [1, 2] },
30 { id = 1, span = [1, 2] },
31 ]
32 match-kind = "all"
33 search-kind = "overlapping"
34
35 [[test]]
36 name = "basic30"
37 regex = ["a", "b"]
38 haystack = "a"
39 matches = [
40 { id = 0, span = [0, 1] },
41 ]
42 match-kind = "all"
43 search-kind = "overlapping"
44
45 [[test]]
46 name = "basic40"
47 regex = ["a", "b"]
48 haystack = "b"
49 matches = [
50 { id = 1, span = [0, 1] },
51 ]
52 match-kind = "all"
53 search-kind = "overlapping"
54
55 [[test]]
56 name = "basic50"
57 regex = ["a|b", "b|a"]
58 haystack = "b"
59 matches = [
60 { id = 0, span = [0, 1] },
61 { id = 1, span = [0, 1] },
62 ]
63 match-kind = "all"
64 search-kind = "overlapping"
65
66 [[test]]
67 name = "basic60"
68 regex = ["foo", "oo"]
69 haystack = "foo"
70 matches = [
71 { id = 0, span = [0, 3] },
72 { id = 1, span = [1, 3] },
73 ]
74 match-kind = "all"
75 search-kind = "overlapping"
76
77 [[test]]
78 name = "basic60-leftmost-first"
79 regex = ["foo", "oo"]
80 haystack = "foo"
81 matches = [
82 { id = 0, span = [0, 3] },
83 ]
84 match-kind = "leftmost-first"
85 search-kind = "leftmost"
86
87 [[test]]
88 name = "basic61"
89 regex = ["oo", "foo"]
90 haystack = "foo"
91 matches = [
92 { id = 1, span = [0, 3] },
93 { id = 0, span = [1, 3] },
94 ]
95 match-kind = "all"
96 search-kind = "overlapping"
97
98 [[test]]
99 name = "basic61-leftmost-first"
100 regex = ["oo", "foo"]
101 haystack = "foo"
102 matches = [
103 { id = 1, span = [0, 3] },
104 ]
105 match-kind = "leftmost-first"
106 search-kind = "leftmost"
107
108 [[test]]
109 name = "basic70"
110 regex = ["abcd", "bcd", "cd", "d"]
111 haystack = "abcd"
112 matches = [
113 { id = 0, span = [0, 4] },
114 { id = 1, span = [1, 4] },
115 { id = 2, span = [2, 4] },
116 { id = 3, span = [3, 4] },
117 ]
118 match-kind = "all"
119 search-kind = "overlapping"
120
121 [[test]]
122 name = "basic71"
123 regex = ["bcd", "cd", "d", "abcd"]
124 haystack = "abcd"
125 matches = [
126 { id = 3, span = [0, 4] },
127 ]
128 match-kind = "leftmost-first"
129 search-kind = "leftmost"
130
131 [[test]]
132 name = "basic80"
133 regex = ["^foo", "bar$"]
134 haystack = "foo"
135 matches = [
136 { id = 0, span = [0, 3] },
137 ]
138 match-kind = "all"
139 search-kind = "overlapping"
140
141 [[test]]
142 name = "basic81"
143 regex = ["^foo", "bar$"]
144 haystack = "foo bar"
145 matches = [
146 { id = 0, span = [0, 3] },
147 { id = 1, span = [4, 7] },
148 ]
149 match-kind = "all"
150 search-kind = "overlapping"
151
152 [[test]]
153 name = "basic82"
154 regex = ["^foo", "bar$"]
155 haystack = "bar"
156 matches = [
157 { id = 1, span = [0, 3] },
158 ]
159 match-kind = "all"
160 search-kind = "overlapping"
161
162 [[test]]
163 name = "basic90"
164 regex = ["[a-z]+$", "foo"]
165 haystack = "01234 foo"
166 matches = [
167 { id = 0, span = [8, 9] },
168 { id = 0, span = [7, 9] },
169 { id = 0, span = [6, 9] },
170 { id = 1, span = [6, 9] },
171 ]
172 match-kind = "all"
173 search-kind = "overlapping"
174
175 [[test]]
176 name = "basic91"
177 regex = ["[a-z]+$", "foo"]
178 haystack = "foo 01234"
179 matches = [
180 { id = 1, span = [0, 3] },
181 ]
182 match-kind = "all"
183 search-kind = "overlapping"
184
185 [[test]]
186 name = "basic100"
187 regex = [".*?", "a"]
188 haystack = "zzza"
189 matches = [
190 { id = 0, span = [0, 0] },
191 { id = 0, span = [1, 1] },
192 { id = 0, span = [0, 1] },
193 { id = 0, span = [2, 2] },
194 { id = 0, span = [1, 2] },
195 { id = 0, span = [0, 2] },
196 { id = 0, span = [3, 3] },
197 { id = 0, span = [2, 3] },
198 { id = 0, span = [1, 3] },
199 { id = 0, span = [0, 3] },
200 { id = 0, span = [4, 4] },
201 { id = 0, span = [3, 4] },
202 { id = 0, span = [2, 4] },
203 { id = 0, span = [1, 4] },
204 { id = 0, span = [0, 4] },
205 { id = 1, span = [3, 4] },
206 ]
207 match-kind = "all"
208 search-kind = "overlapping"
209
210 [[test]]
211 name = "basic101"
212 regex = [".*", "a"]
213 haystack = "zzza"
214 matches = [
215 { id = 0, span = [0, 0] },
216 { id = 0, span = [1, 1] },
217 { id = 0, span = [0, 1] },
218 { id = 0, span = [2, 2] },
219 { id = 0, span = [1, 2] },
220 { id = 0, span = [0, 2] },
221 { id = 0, span = [3, 3] },
222 { id = 0, span = [2, 3] },
223 { id = 0, span = [1, 3] },
224 { id = 0, span = [0, 3] },
225 { id = 0, span = [4, 4] },
226 { id = 0, span = [3, 4] },
227 { id = 0, span = [2, 4] },
228 { id = 0, span = [1, 4] },
229 { id = 0, span = [0, 4] },
230 { id = 1, span = [3, 4] },
231 ]
232 match-kind = "all"
233 search-kind = "overlapping"
234
235 [[test]]
236 name = "basic102"
237 regex = [".*", "a"]
238 haystack = "zzz"
239 matches = [
240 { id = 0, span = [0, 0] },
241 { id = 0, span = [1, 1] },
242 { id = 0, span = [0, 1] },
243 { id = 0, span = [2, 2] },
244 { id = 0, span = [1, 2] },
245 { id = 0, span = [0, 2] },
246 { id = 0, span = [3, 3] },
247 { id = 0, span = [2, 3] },
248 { id = 0, span = [1, 3] },
249 { id = 0, span = [0, 3] },
250 ]
251 match-kind = "all"
252 search-kind = "overlapping"
253
254 [[test]]
255 name = "basic110"
256 regex = ['\ba\b']
257 haystack = "hello a bye"
258 matches = [
259 { id = 0, span = [6, 7] },
260 ]
261 match-kind = "all"
262 search-kind = "overlapping"
263
264 [[test]]
265 name = "basic111"
266 regex = ['\ba\b', '\be\b']
267 haystack = "hello a bye e"
268 matches = [
269 { id = 0, span = [6, 7] },
270 { id = 1, span = [12, 13] },
271 ]
272 match-kind = "all"
273 search-kind = "overlapping"
274
275 [[test]]
276 name = "basic120"
277 regex = ["a"]
278 haystack = "a"
279 matches = [
280 { id = 0, span = [0, 1] },
281 ]
282 match-kind = "all"
283 search-kind = "overlapping"
284
285 [[test]]
286 name = "basic121"
287 regex = [".*a"]
288 haystack = "a"
289 matches = [
290 { id = 0, span = [0, 1] },
291 ]
292 match-kind = "all"
293 search-kind = "overlapping"
294
295 [[test]]
296 name = "basic122"
297 regex = [".*a", "β"]
298 haystack = "β"
299 matches = [
300 { id = 1, span = [0, 2] },
301 ]
302 match-kind = "all"
303 search-kind = "overlapping"
304
305 [[test]]
306 name = "basic130"
307 regex = ["ab", "b"]
308 haystack = "ba"
309 matches = [
310 { id = 1, span = [0, 1] },
311 ]
312 match-kind = "all"
313 search-kind = "overlapping"
314
315 # These test cases where one of the regexes matches the empty string.
316
317 [[test]]
318 name = "empty10"
319 regex = ["", "a"]
320 haystack = "abc"
321 matches = [
322 { id = 0, span = [0, 0] },
323 { id = 1, span = [0, 1] },
324 { id = 0, span = [1, 1] },
325 { id = 0, span = [2, 2] },
326 { id = 0, span = [3, 3] },
327 ]
328 match-kind = "all"
329 search-kind = "overlapping"
330
331 [[test]]
332 name = "empty10-leftmost-first"
333 regex = ["", "a"]
334 haystack = "abc"
335 matches = [
336 { id = 0, span = [0, 0] },
337 { id = 0, span = [1, 1] },
338 { id = 0, span = [2, 2] },
339 { id = 0, span = [3, 3] },
340 ]
341 match-kind = "leftmost-first"
342 search-kind = "leftmost"
343
344 [[test]]
345 name = "empty11"
346 regex = ["a", ""]
347 haystack = "abc"
348 matches = [
349 { id = 1, span = [0, 0] },
350 { id = 0, span = [0, 1] },
351 { id = 1, span = [1, 1] },
352 { id = 1, span = [2, 2] },
353 { id = 1, span = [3, 3] },
354 ]
355 match-kind = "all"
356 search-kind = "overlapping"
357
358 [[test]]
359 name = "empty11-leftmost-first"
360 regex = ["a", ""]
361 haystack = "abc"
362 matches = [
363 { id = 0, span = [0, 1] },
364 { id = 1, span = [2, 2] },
365 { id = 1, span = [3, 3] },
366 ]
367 match-kind = "leftmost-first"
368 search-kind = "leftmost"
369
370 [[test]]
371 name = "empty20"
372 regex = ["", "b"]
373 haystack = "abc"
374 matches = [
375 { id = 0, span = [0, 0] },
376 { id = 0, span = [1, 1] },
377 { id = 1, span = [1, 2] },
378 { id = 0, span = [2, 2] },
379 { id = 0, span = [3, 3] },
380 ]
381 match-kind = "all"
382 search-kind = "overlapping"
383
384 [[test]]
385 name = "empty20-leftmost-first"
386 regex = ["", "b"]
387 haystack = "abc"
388 matches = [
389 { id = 0, span = [0, 0] },
390 { id = 0, span = [1, 1] },
391 { id = 0, span = [2, 2] },
392 { id = 0, span = [3, 3] },
393 ]
394 match-kind = "leftmost-first"
395 search-kind = "leftmost"
396
397 [[test]]
398 name = "empty21"
399 regex = ["b", ""]
400 haystack = "abc"
401 matches = [
402 { id = 1, span = [0, 0] },
403 { id = 1, span = [1, 1] },
404 { id = 0, span = [1, 2] },
405 { id = 1, span = [2, 2] },
406 { id = 1, span = [3, 3] },
407 ]
408 match-kind = "all"
409 search-kind = "overlapping"
410
411 [[test]]
412 name = "empty21-leftmost-first"
413 regex = ["b", ""]
414 haystack = "abc"
415 matches = [
416 { id = 1, span = [0, 0] },
417 { id = 0, span = [1, 2] },
418 { id = 1, span = [3, 3] },
419 ]
420 match-kind = "leftmost-first"
421 search-kind = "leftmost"
422
423 [[test]]
424 name = "empty22"
425 regex = ["(?:)", "b"]
426 haystack = "abc"
427 matches = [
428 { id = 0, span = [0, 0] },
429 { id = 0, span = [1, 1] },
430 { id = 1, span = [1, 2] },
431 { id = 0, span = [2, 2] },
432 { id = 0, span = [3, 3] },
433 ]
434 match-kind = "all"
435 search-kind = "overlapping"
436
437 [[test]]
438 name = "empty23"
439 regex = ["b", "(?:)"]
440 haystack = "abc"
441 matches = [
442 { id = 1, span = [0, 0] },
443 { id = 1, span = [1, 1] },
444 { id = 0, span = [1, 2] },
445 { id = 1, span = [2, 2] },
446 { id = 1, span = [3, 3] },
447 ]
448 match-kind = "all"
449 search-kind = "overlapping"
450
451 [[test]]
452 name = "empty30"
453 regex = ["", "z"]
454 haystack = "abc"
455 matches = [
456 { id = 0, span = [0, 0] },
457 { id = 0, span = [1, 1] },
458 { id = 0, span = [2, 2] },
459 { id = 0, span = [3, 3] },
460 ]
461 match-kind = "all"
462 search-kind = "overlapping"
463
464 [[test]]
465 name = "empty30-leftmost-first"
466 regex = ["", "z"]
467 haystack = "abc"
468 matches = [
469 { id = 0, span = [0, 0] },
470 { id = 0, span = [1, 1] },
471 { id = 0, span = [2, 2] },
472 { id = 0, span = [3, 3] },
473 ]
474 match-kind = "leftmost-first"
475 search-kind = "leftmost"
476
477 [[test]]
478 name = "empty31"
479 regex = ["z", ""]
480 haystack = "abc"
481 matches = [
482 { id = 1, span = [0, 0] },
483 { id = 1, span = [1, 1] },
484 { id = 1, span = [2, 2] },
485 { id = 1, span = [3, 3] },
486 ]
487 match-kind = "all"
488 search-kind = "overlapping"
489
490 [[test]]
491 name = "empty31-leftmost-first"
492 regex = ["z", ""]
493 haystack = "abc"
494 matches = [
495 { id = 1, span = [0, 0] },
496 { id = 1, span = [1, 1] },
497 { id = 1, span = [2, 2] },
498 { id = 1, span = [3, 3] },
499 ]
500 match-kind = "leftmost-first"
501 search-kind = "leftmost"
502
503 [[test]]
504 name = "empty40"
505 regex = ["c(?:)", "b"]
506 haystack = "abc"
507 matches = [
508 { id = 1, span = [1, 2] },
509 { id = 0, span = [2, 3] },
510 ]
511 match-kind = "all"
512 search-kind = "overlapping"
513
514 [[test]]
515 name = "empty40-leftmost-first"
516 regex = ["c(?:)", "b"]
517 haystack = "abc"
518 matches = [
519 { id = 1, span = [1, 2] },
520 { id = 0, span = [2, 3] },
521 ]
522 match-kind = "leftmost-first"
523 search-kind = "leftmost"
524
525 # These test cases where there are no matches.
526
527 [[test]]
528 name = "nomatch10"
529 regex = ["a", "a"]
530 haystack = "b"
531 matches = []
532 match-kind = "all"
533 search-kind = "overlapping"
534
535 [[test]]
536 name = "nomatch20"
537 regex = ["^foo", "bar$"]
538 haystack = "bar foo"
539 matches = []
540 match-kind = "all"
541 search-kind = "overlapping"
542
543 [[test]]
544 name = "nomatch30"
545 regex = []
546 haystack = "a"
547 matches = []
548 match-kind = "all"
549 search-kind = "overlapping"
550
551 [[test]]
552 name = "nomatch40"
553 regex = ["^rooted$", '\.log$']
554 haystack = "notrooted"
555 matches = []
556 match-kind = "all"
557 search-kind = "overlapping"
558
559 # These test multi-regex searches with capture groups.
560 #
561 # NOTE: I wrote these tests in the course of developing a first class API for
562 # overlapping capturing group matches, but ultimately removed that API because
563 # the semantics for overlapping matches aren't totally clear. However, I've
564 # left the tests because I believe the semantics for these patterns are clear
565 # and because we can still test our "which patterns matched" APIs with them.
566
567 [[test]]
568 name = "caps-010"
569 regex = ['^(\w+) (\w+)$', '^(\S+) (\S+)$']
570 haystack = "Bruce Springsteen"
571 matches = [
572 { id = 0, spans = [[0, 17], [0, 5], [6, 17]] },
573 { id = 1, spans = [[0, 17], [0, 5], [6, 17]] },
574 ]
575 match-kind = "all"
576 search-kind = "overlapping"
577 unicode = false
578 utf8 = false
579
580 [[test]]
581 name = "caps-020"
582 regex = ['^(\w+) (\w+)$', '^[A-Z](\S+) [A-Z](\S+)$']
583 haystack = "Bruce Springsteen"
584 matches = [
585 { id = 0, spans = [[0, 17], [0, 5], [6, 17]] },
586 { id = 1, spans = [[0, 17], [1, 5], [7, 17]] },
587 ]
588 match-kind = "all"
589 search-kind = "overlapping"
590 unicode = false
591 utf8 = false
592
593 [[test]]
594 name = "caps-030"
595 regex = ['^(\w+) (\w+)$', '^([A-Z])(\S+) ([A-Z])(\S+)$']
596 haystack = "Bruce Springsteen"
597 matches = [
598 { id = 0, spans = [[0, 17], [0, 5], [6, 17]] },
599 { id = 1, spans = [[0, 17], [0, 1], [1, 5], [6, 7], [7, 17]] },
600 ]
601 match-kind = "all"
602 search-kind = "overlapping"
603 unicode = false
604 utf8 = false
605
606 [[test]]
607 name = "caps-110"
608 regex = ['(\w+) (\w+)', '(\S+) (\S+)']
609 haystack = "Bruce Springsteen"
610 matches = [
611 { id = 0, spans = [[0, 17], [0, 5], [6, 17]] },
612 ]
613 match-kind = "leftmost-first"
614 search-kind = "leftmost"
615 unicode = false
616 utf8 = false
617
618 [[test]]
619 name = "caps-120"
620 regex = ['(\w+) (\w+)', '(\S+) (\S+)']
621 haystack = "&ruce $pringsteen"
622 matches = [
623 { id = 1, spans = [[0, 17], [0, 5], [6, 17]] },
624 ]
625 match-kind = "leftmost-first"
626 search-kind = "leftmost"
627 unicode = false
628 utf8 = false
629
630 [[test]]
631 name = "caps-121"
632 regex = ['(\w+) (\w+)', '(\S+) (\S+)']
633 haystack = "&ruce $pringsteen Foo Bar"
634 matches = [
635 { id = 1, spans = [[0, 17], [0, 5], [6, 17]] },
636 { id = 0, spans = [[18, 25], [18, 21], [22, 25]] },
637 ]
638 match-kind = "leftmost-first"
639 search-kind = "leftmost"
640 unicode = false
641 utf8 = false