Debian Codegraph @

.cargo/vendor/regex/testdata/anchored.toml

raw
1 # These tests are specifically geared toward searches with 'anchored = true'.
2 # While they are interesting in their own right, they are particularly
3 # important for testing the one-pass DFA since the one-pass DFA can't work in
4 # unanchored contexts.
5 #
6 # Note that "anchored" in this context does not mean "^". Anchored searches are
7 # searches whose matches must begin at the start of the search, which may not
8 # be at the start of the haystack. That's why anchored searches---and there are
9 # some examples below---can still report multiple matches. This occurs when the
10 # matches are adjacent to one another.
11
12 [[test]]
13 name = "greedy"
14 regex = '(abc)+'
15 haystack = "abcabcabc"
16 matches = [
17 [[0, 9], [6, 9]],
18 ]
19 anchored = true
20
21 # When a "earliest" search is used, greediness doesn't really exist because
22 # matches are reported as soon as they are known.
23 [[test]]
24 name = "greedy-earliest"
25 regex = '(abc)+'
26 haystack = "abcabcabc"
27 matches = [
28 [[0, 3], [0, 3]],
29 [[3, 6], [3, 6]],
30 [[6, 9], [6, 9]],
31 ]
32 anchored = true
33 search-kind = "earliest"
34
35 [[test]]
36 name = "nongreedy"
37 regex = '(abc)+?'
38 haystack = "abcabcabc"
39 matches = [
40 [[0, 3], [0, 3]],
41 [[3, 6], [3, 6]],
42 [[6, 9], [6, 9]],
43 ]
44 anchored = true
45
46 # When "all" semantics are used, non-greediness doesn't exist since the longest
47 # possible match is always taken.
48 [[test]]
49 name = "nongreedy-all"
50 regex = '(abc)+?'
51 haystack = "abcabcabc"
52 matches = [
53 [[0, 9], [6, 9]],
54 ]
55 anchored = true
56 match-kind = "all"
57
58 [[test]]
59 name = "word-boundary-unicode-01"
60 regex = '\b\w+\b'
61 haystack = 'βββ☃'
62 matches = [[0, 6]]
63 anchored = true
64
65 [[test]]
66 name = "word-boundary-nounicode-01"
67 regex = '\b\w+\b'
68 haystack = 'abcβ'
69 matches = [[0, 3]]
70 anchored = true
71 unicode = false
72
73 # Tests that '.c' doesn't match 'abc' when performing an anchored search from
74 # the beginning of the haystack. This test found two different bugs in the
75 # PikeVM and the meta engine.
76 [[test]]
77 name = "no-match-at-start"
78 regex = '.c'
79 haystack = 'abc'
80 matches = []
81 anchored = true
82
83 # Like above, but at a non-zero start offset.
84 [[test]]
85 name = "no-match-at-start-bounds"
86 regex = '.c'
87 haystack = 'aabc'
88 bounds = [1, 4]
89 matches = []
90 anchored = true
91
92 # This is like no-match-at-start, but hits the "reverse inner" optimization
93 # inside the meta engine. (no-match-at-start hits the "reverse suffix"
94 # optimization.)
95 [[test]]
96 name = "no-match-at-start-reverse-inner"
97 regex = '.c[a-z]'
98 haystack = 'abcz'
99 matches = []
100 anchored = true
101
102 # Like above, but at a non-zero start offset.
103 [[test]]
104 name = "no-match-at-start-reverse-inner-bounds"
105 regex = '.c[a-z]'
106 haystack = 'aabcz'
107 bounds = [1, 5]
108 matches = []
109 anchored = true
110
111 # Same as no-match-at-start, but applies to the meta engine's "reverse
112 # anchored" optimization.
113 [[test]]
114 name = "no-match-at-start-reverse-anchored"
115 regex = '.c[a-z]$'
116 haystack = 'abcz'
117 matches = []
118 anchored = true
119
120 # Like above, but at a non-zero start offset.
121 [[test]]
122 name = "no-match-at-start-reverse-anchored-bounds"
123 regex = '.c[a-z]$'
124 haystack = 'aabcz'
125 bounds = [1, 5]
126 matches = []
127 anchored = true