| 1 |
# NOTE: We define a number of tests where the *match* kind is 'leftmost-first' |
| 2 |
# but the *search* kind is 'overlapping'. This is a somewhat nonsensical |
| 3 |
# combination and can produce odd results. Nevertheless, those results should |
| 4 |
# be consistent so we test them here. (At the time of writing this note, I |
| 5 |
# hadn't yet decided whether to make 'leftmost-first' with 'overlapping' result |
| 6 |
# in unspecified behavior.) |
| 7 |
|
| 8 |
# This demonstrates how a full overlapping search is obvious quadratic. This |
| 9 |
# regex reports a match for every substring in the haystack. |
| 10 |
[[test]] |
| 11 |
name = "ungreedy-dotstar-matches-everything-100" |
| 12 |
regex = [".*?"] |
| 13 |
haystack = "zzz" |
| 14 |
matches = [ |
| 15 |
{ id = 0, span = [0, 0] }, |
| 16 |
{ id = 0, span = [1, 1] }, |
| 17 |
{ id = 0, span = [0, 1] }, |
| 18 |
{ id = 0, span = [2, 2] }, |
| 19 |
{ id = 0, span = [1, 2] }, |
| 20 |
{ id = 0, span = [0, 2] }, |
| 21 |
{ id = 0, span = [3, 3] }, |
| 22 |
{ id = 0, span = [2, 3] }, |
| 23 |
{ id = 0, span = [1, 3] }, |
| 24 |
{ id = 0, span = [0, 3] }, |
| 25 |
] |
| 26 |
match-kind = "all" |
| 27 |
search-kind = "overlapping" |
| 28 |
|
| 29 |
[[test]] |
| 30 |
name = "greedy-dotstar-matches-everything-100" |
| 31 |
regex = [".*"] |
| 32 |
haystack = "zzz" |
| 33 |
matches = [ |
| 34 |
{ id = 0, span = [0, 0] }, |
| 35 |
{ id = 0, span = [1, 1] }, |
| 36 |
{ id = 0, span = [0, 1] }, |
| 37 |
{ id = 0, span = [2, 2] }, |
| 38 |
{ id = 0, span = [1, 2] }, |
| 39 |
{ id = 0, span = [0, 2] }, |
| 40 |
{ id = 0, span = [3, 3] }, |
| 41 |
{ id = 0, span = [2, 3] }, |
| 42 |
{ id = 0, span = [1, 3] }, |
| 43 |
{ id = 0, span = [0, 3] }, |
| 44 |
] |
| 45 |
match-kind = "all" |
| 46 |
search-kind = "overlapping" |
| 47 |
|
| 48 |
[[test]] |
| 49 |
name = "repetition-plus-leftmost-first-100" |
| 50 |
regex = 'a+' |
| 51 |
haystack = "aaa" |
| 52 |
matches = [[0, 1], [1, 2], [0, 2], [2, 3], [1, 3], [0, 3]] |
| 53 |
match-kind = "leftmost-first" |
| 54 |
search-kind = "overlapping" |
| 55 |
|
| 56 |
[[test]] |
| 57 |
name = "repetition-plus-leftmost-first-110" |
| 58 |
regex = '☃+' |
| 59 |
haystack = "☃☃☃" |
| 60 |
matches = [[0, 3], [3, 6], [0, 6], [6, 9], [3, 9], [0, 9]] |
| 61 |
match-kind = "leftmost-first" |
| 62 |
search-kind = "overlapping" |
| 63 |
|
| 64 |
[[test]] |
| 65 |
name = "repetition-plus-all-100" |
| 66 |
regex = 'a+' |
| 67 |
haystack = "aaa" |
| 68 |
matches = [[0, 1], [1, 2], [0, 2], [2, 3], [1, 3], [0, 3]] |
| 69 |
match-kind = "all" |
| 70 |
search-kind = "overlapping" |
| 71 |
|
| 72 |
[[test]] |
| 73 |
name = "repetition-plus-all-110" |
| 74 |
regex = '☃+' |
| 75 |
haystack = "☃☃☃" |
| 76 |
matches = [[0, 3], [3, 6], [0, 6], [6, 9], [3, 9], [0, 9]] |
| 77 |
match-kind = "all" |
| 78 |
search-kind = "overlapping" |
| 79 |
|
| 80 |
[[test]] |
| 81 |
name = "repetition-plus-leftmost-first-200" |
| 82 |
regex = '(abc)+' |
| 83 |
haystack = "zzabcabczzabc" |
| 84 |
matches = [ |
| 85 |
[[2, 5], [2, 5]], |
| 86 |
[[5, 8], [5, 8]], |
| 87 |
[[2, 8], [5, 8]], |
| 88 |
] |
| 89 |
match-kind = "leftmost-first" |
| 90 |
search-kind = "overlapping" |
| 91 |
|
| 92 |
[[test]] |
| 93 |
name = "repetition-plus-all-200" |
| 94 |
regex = '(abc)+' |
| 95 |
haystack = "zzabcabczzabc" |
| 96 |
matches = [ |
| 97 |
[[2, 5], [2, 5]], |
| 98 |
[[5, 8], [5, 8]], |
| 99 |
[[2, 8], [5, 8]], |
| 100 |
[[10, 13], [10, 13]], |
| 101 |
] |
| 102 |
match-kind = "all" |
| 103 |
search-kind = "overlapping" |
| 104 |
|
| 105 |
[[test]] |
| 106 |
name = "repetition-star-leftmost-first-100" |
| 107 |
regex = 'a*' |
| 108 |
haystack = "aaa" |
| 109 |
matches = [ |
| 110 |
[0, 0], |
| 111 |
[1, 1], |
| 112 |
[0, 1], |
| 113 |
[2, 2], |
| 114 |
[1, 2], |
| 115 |
[0, 2], |
| 116 |
[3, 3], |
| 117 |
[2, 3], |
| 118 |
[1, 3], |
| 119 |
[0, 3], |
| 120 |
] |
| 121 |
match-kind = "leftmost-first" |
| 122 |
search-kind = "overlapping" |
| 123 |
|
| 124 |
[[test]] |
| 125 |
name = "repetition-star-all-100" |
| 126 |
regex = 'a*' |
| 127 |
haystack = "aaa" |
| 128 |
matches = [ |
| 129 |
[0, 0], |
| 130 |
[1, 1], |
| 131 |
[0, 1], |
| 132 |
[2, 2], |
| 133 |
[1, 2], |
| 134 |
[0, 2], |
| 135 |
[3, 3], |
| 136 |
[2, 3], |
| 137 |
[1, 3], |
| 138 |
[0, 3], |
| 139 |
] |
| 140 |
match-kind = "all" |
| 141 |
search-kind = "overlapping" |
| 142 |
|
| 143 |
[[test]] |
| 144 |
name = "repetition-star-leftmost-first-200" |
| 145 |
regex = '(abc)*' |
| 146 |
haystack = "zzabcabczzabc" |
| 147 |
matches = [ |
| 148 |
[[0, 0], []], |
| 149 |
] |
| 150 |
match-kind = "leftmost-first" |
| 151 |
search-kind = "overlapping" |
| 152 |
|
| 153 |
[[test]] |
| 154 |
name = "repetition-star-all-200" |
| 155 |
regex = '(abc)*' |
| 156 |
haystack = "zzabcabczzabc" |
| 157 |
matches = [ |
| 158 |
[[0, 0], []], |
| 159 |
[[1, 1], []], |
| 160 |
[[2, 2], []], |
| 161 |
[[3, 3], []], |
| 162 |
[[4, 4], []], |
| 163 |
[[5, 5], []], |
| 164 |
[[2, 5], [2, 5]], |
| 165 |
[[6, 6], []], |
| 166 |
[[7, 7], []], |
| 167 |
[[8, 8], []], |
| 168 |
[[5, 8], [5, 8]], |
| 169 |
[[2, 8], [5, 8]], |
| 170 |
[[9, 9], []], |
| 171 |
[[10, 10], []], |
| 172 |
[[11, 11], []], |
| 173 |
[[12, 12], []], |
| 174 |
[[13, 13], []], |
| 175 |
[[10, 13], [10, 13]], |
| 176 |
] |
| 177 |
match-kind = "all" |
| 178 |
search-kind = "overlapping" |
| 179 |
|
| 180 |
[[test]] |
| 181 |
name = "start-end-rep-leftmost-first" |
| 182 |
regex = '(^$)*' |
| 183 |
haystack = "abc" |
| 184 |
matches = [ |
| 185 |
[[0, 0], []], |
| 186 |
] |
| 187 |
match-kind = "leftmost-first" |
| 188 |
search-kind = "overlapping" |
| 189 |
|
| 190 |
[[test]] |
| 191 |
name = "start-end-rep-all" |
| 192 |
regex = '(^$)*' |
| 193 |
haystack = "abc" |
| 194 |
matches = [ |
| 195 |
[[0, 0], []], |
| 196 |
[[1, 1], []], |
| 197 |
[[2, 2], []], |
| 198 |
[[3, 3], []], |
| 199 |
] |
| 200 |
match-kind = "all" |
| 201 |
search-kind = "overlapping" |
| 202 |
|
| 203 |
[[test]] |
| 204 |
name = "alt-leftmost-first-100" |
| 205 |
regex = 'abc|a' |
| 206 |
haystack = "zzabcazzaabc" |
| 207 |
matches = [[2, 3], [2, 5]] |
| 208 |
match-kind = "leftmost-first" |
| 209 |
search-kind = "overlapping" |
| 210 |
|
| 211 |
[[test]] |
| 212 |
name = "alt-all-100" |
| 213 |
regex = 'abc|a' |
| 214 |
haystack = "zzabcazzaabc" |
| 215 |
matches = [[2, 3], [2, 5], [5, 6], [8, 9], [9, 10], [9, 12]] |
| 216 |
match-kind = "all" |
| 217 |
search-kind = "overlapping" |
| 218 |
|
| 219 |
[[test]] |
| 220 |
name = "empty-000" |
| 221 |
regex = "" |
| 222 |
haystack = "abc" |
| 223 |
matches = [[0, 0], [1, 1], [2, 2], [3, 3]] |
| 224 |
match-kind = "all" |
| 225 |
search-kind = "overlapping" |
| 226 |
|
| 227 |
[[test]] |
| 228 |
name = "empty-alt-000" |
| 229 |
regex = "|b" |
| 230 |
haystack = "abc" |
| 231 |
matches = [[0, 0], [1, 1], [2, 2], [1, 2], [3, 3]] |
| 232 |
match-kind = "all" |
| 233 |
search-kind = "overlapping" |
| 234 |
|
| 235 |
[[test]] |
| 236 |
name = "empty-alt-010" |
| 237 |
regex = "b|" |
| 238 |
haystack = "abc" |
| 239 |
matches = [[0, 0], [1, 1], [2, 2], [1, 2], [3, 3]] |
| 240 |
match-kind = "all" |
| 241 |
search-kind = "overlapping" |
| 242 |
|
| 243 |
[[test]] |
| 244 |
# See: https://github.com/rust-lang/regex/issues/484 |
| 245 |
name = "iter1-bytes" |
| 246 |
regex = '' |
| 247 |
haystack = "☃" |
| 248 |
matches = [[0, 0], [1, 1], [2, 2], [3, 3]] |
| 249 |
utf8 = false |
| 250 |
match-kind = "all" |
| 251 |
search-kind = "overlapping" |
| 252 |
|
| 253 |
[[test]] |
| 254 |
# See: https://github.com/rust-lang/regex/issues/484 |
| 255 |
name = "iter1-utf8" |
| 256 |
regex = '' |
| 257 |
haystack = "☃" |
| 258 |
matches = [[0, 0], [3, 3]] |
| 259 |
match-kind = "all" |
| 260 |
search-kind = "overlapping" |
| 261 |
|
| 262 |
[[test]] |
| 263 |
name = "iter1-incomplete-utf8" |
| 264 |
regex = '' |
| 265 |
haystack = '\xE2\x98' # incomplete snowman |
| 266 |
matches = [[0, 0], [1, 1], [2, 2]] |
| 267 |
match-kind = "all" |
| 268 |
search-kind = "overlapping" |
| 269 |
unescape = true |
| 270 |
utf8 = false |
| 271 |
|
| 272 |
[[test]] |
| 273 |
name = "scratch" |
| 274 |
regex = ['sam', 'samwise'] |
| 275 |
haystack = "samwise" |
| 276 |
matches = [ |
| 277 |
{ id = 0, span = [0, 3] }, |
| 278 |
] |
| 279 |
match-kind = "leftmost-first" |
| 280 |
search-kind = "overlapping" |