Debian Codegraph @

tests/yaml/multipass-vs-match.yaml

raw symbols SCIP
1 #!tools/lou_checkyaml
2 #
3 # Comparison of match and multi-pass opcodes
4 # ::::::::::::::::::::::::::::::::::::::::::
5 #
6 # Copyright © 2019 by Bert Frees
7 #
8 # Copying and distribution of this file, with or without modification,
9 # are permitted in any medium without royalty provided the copyright
10 # notice and this notice are preserved. This file is offered as-is,
11 # without any warranty.
12 # ..............................................................................................
13
14 display: tables/unicode-without-blank.dis
15
16 # multipass-vs-match_common.uti:
17 # include tables/latinLetterDef8Dots.uti
18 # include tables/loweredDigits6Dots.uti
19 # space \s 0
20 # letter ç 4-14
21 # punctuation ! 2346
22 # punctuation . 46
23 # punctuation - 36
24 # sign % 146
25 # sign _ 145
26 # math + 346
27
28 # ..............................................................................................
29
30 # simple match replace
31 table: |
32 include multipass-vs-match_common.uti
33 noback context "abc" @123
34 table : |
35 include multipass-vs-match_common.uti
36 noback context ["abc"] @123
37 table: |
38 include multipass-vs-match_common.uti
39 match - abc - 123
40 tests:
41 - - "abc"
42 - "⠇"
43
44 # lookbehind
45 table: |
46 include multipass-vs-match_common.uti
47 always x 456
48 noback context _"x"["abc"] @123
49 table: |
50 include multipass-vs-match_common.uti
51 always x 456
52 match x abc - 123
53 tests:
54 - - "xabc"
55 - "⠸⠇"
56
57 # without the _ it is not a true lookbehind
58 table: |
59 include multipass-vs-match_common.uti
60 always x 456
61 noback context "x"["abc"] @123
62 tests:
63 - - "xabc"
64 - "⠸⠁⠃⠉"
65
66 # lookahead
67 table: |
68 include multipass-vs-match_common.uti
69 always x 456
70 noback context ["abc"]"x" @123
71 table: |
72 include multipass-vs-match_common.uti
73 always x 456
74 match - abc x 123
75 tests:
76 - - "abcx"
77 - "⠇⠸"
78
79 # zero-length match (insert)
80 # cursor advances at least one so that a zero-length match does not result in an endless loop
81
82 # with lookahead
83 table: |
84 include multipass-vs-match_common.uti
85 always x 456
86 noback context []"xx" @123
87 tests:
88 - - "xxx"
89 - "⠇⠸⠇⠸⠸"
90
91 # with lookbehind
92 table: |
93 include multipass-vs-match_common.uti
94 always x 456
95 noback context "x"[] @123
96 tests:
97 - - "xxx"
98 - "⠭⠇⠭⠇⠭⠇"
99 - xfail: got ⠇⠸⠇
100 table: |
101 include multipass-vs-match_common.uti
102 always x 456
103 noback context "xx"[] @123
104 tests:
105 - - "xxx"
106 - "⠭⠭⠇⠭⠇"
107 - xfail: got ⠭⠭⠇⠸
108
109 # error: characters, dots, attributes, or class swap not found in test part
110 # table: |
111 # include multipass-vs-match_common.uti
112 # noback context _"x"[] @123
113 # tests:
114 # - - "xxx"
115 # - "⠇⠭⠇⠭⠇⠭"
116
117 # beginning of string
118 table: |
119 include multipass-vs-match_common.uti
120 noback context `["abc"] @123
121 table: |
122 include multipass-vs-match_common.uti
123 noback context `"abc" @123
124 table: |
125 include multipass-vs-match_common.uti
126 match ^ abc - 123
127 table: |
128 include multipass-vs-match_common.uti
129 match $ abc - 123
130 tests:
131 - - "xabc"
132 - "⠭⠁⠃⠉"
133 - - "abc"
134 - "⠇"
135
136 # end of string
137 table: |
138 include multipass-vs-match_common.uti
139 noback context ["abc"]~ @123
140 table: |
141 include multipass-vs-match_common.uti
142 noback context "abc"~ @123
143 table: |
144 include multipass-vs-match_common.uti
145 match - abc $ 123
146 table: |
147 include multipass-vs-match_common.uti
148 match - abc ^ 123
149 tests:
150 - - "abcx"
151 - "⠁⠃⠉⠭"
152 - - "abc"
153 - "⠇"
154
155 # wildcard
156 table: |
157 include multipass-vs-match_common.uti
158 noback context ["abc"]$a"x" @123
159 table: |
160 include multipass-vs-match_common.uti
161 match - abc .x 123
162 tests:
163 - - "abcdx"
164 - "⠇⠙⠭"
165 - - "abc!x"
166 - "⠇⠮⠭"
167
168 # character classes
169 table: |
170 include multipass-vs-match_common.uti
171 noback context ["abc"]$U @123@1 # uppercase letter
172 noback context ["abc"]$u @123@2 # lowercase letter
173 noback context ["abc"]$l @123@3 # letter
174 noback context ["abc"]$p @123@4 # punctuation
175 noback context ["abc"]$d @123@5 # digit
176 noback context ["abc"]$s @123@6 # space
177 noback context ["abc"]$S @123@7 # sign
178 noback context ["abc"]$m @123@8 # math
179 noback context ["def"]$sp @456 # space or punctuation
180 table: |
181 include multipass-vs-match_common.uti
182 match - abc %u 123-1 # uppercase letter
183 match - abc %l 123-2 # lowercase letter
184 match - abc %a 123-3 # letter
185 match - abc %. 123-4 # punctuation
186 match - abc %# 123-5 # digit
187 match - abc %_ 123-6 # space
188 match - abc %$ 123-7 # sign
189 match - abc %m 123-8 # math
190 match - def %[_.] 456 # space or punctuation
191 tests:
192 - - "abcX"
193 - "⠇⠁⡭"
194 - - "abcx"
195 - "⠇⠂⠭"
196 - - "abcç"
197 - "⠇⠄⠈⠉"
198 - - "abc!"
199 - "⠇⠈⠮"
200 - - "abc1"
201 - "⠇⠐⠂"
202 - - "abc "
203 - "⠇⠠ "
204 - - "abc%"
205 - "⠇⡀⠩"
206 - - "abc+"
207 - "⠇⢀⠬"
208 - - "def!"
209 - "⠸⠮"
210 - - "def "
211 - "⠸ "
212 - - "defx"
213 - "⠙⠑⠋⠭"
214
215 # character sets / custom character classes
216 table: |
217 include multipass-vs-match_common.uti
218 attribute xy xy
219 noback context ["abc"]%xy @123
220 table: |
221 include multipass-vs-match_common.uti
222 attribute xy xy
223 noback context ["abc"]$w @123
224 table: |
225 include multipass-vs-match_common.uti
226 match - abc [xy] 123
227 table: |
228 include multipass-vs-match_common.uti
229 match - abc x|y 123
230 table: |
231 include multipass-vs-match_common.uti
232 match - abc (x|y) 123
233 table: |
234 include multipass-vs-match_common.uti
235 attribute 0 xy
236 match - abc %0 123
237 tests:
238 - - "abcx"
239 - "⠇⠭"
240 - - "abcy"
241 - "⠇⠽"
242 - - "abcz"
243 - "⠁⠃⠉⠵"
244
245 # alternation
246 table: |
247 include multipass-vs-match_common.uti
248 match - abc xy|z 123
249 table: |
250 include multipass-vs-match_common.uti
251 noback context ["abc"]"xy" @123
252 noback context ["abc"]"z" @123
253 tests:
254 - - "abcx"
255 - "⠁⠃⠉⠭"
256 - - "abcxy"
257 - "⠇⠭⠽"
258 - - "abcz"
259 - "⠇⠵"
260
261 # repitition
262
263 # single character
264 table: |
265 include multipass-vs-match_common.uti
266 match - abc x+y 123
267 table: |
268 include multipass-vs-match_common.uti
269 attribute x x
270 noback context ["abc"]%x."y" @123
271 tests:
272 - - "abcy"
273 - "⠁⠃⠉⠽"
274 - - "abcxy"
275 - "⠇⠭⠽"
276 - - "abcxxy"
277 - "⠇⠭⠭⠽"
278
279 # character set/class
280 table: |
281 include multipass-vs-match_common.uti
282 match - abc [xy]+z 123
283 table: |
284 include multipass-vs-match_common.uti
285 match - abc (x|y)+z 123
286 table: |
287 include multipass-vs-match_common.uti
288 attribute xy xy
289 noback context ["abc"]%xy."z" @123
290 tests:
291 - - "abcxz"
292 - "⠇⠭⠵"
293 - - "abcxyz"
294 - "⠇⠭⠽⠵"
295 - - "abcyyxz"
296 - "⠇⠽⠽⠭⠵"
297
298 # group of characters
299 table: |
300 include multipass-vs-match_common.uti
301 match - abc (xy)+z 123
302 tests:
303 - - "abcxyz"
304 - "⠇⠭⠽⠵"
305 - - "abcxyxz"
306 - "⠁⠃⠉⠭⠽⠭⠵"
307 - - "abcxyxyz"
308 - "⠇⠭⠽⠭⠽⠵"
309
310 # zero or more
311 table: |
312 include multipass-vs-match_common.uti
313 match - abc x*y 123
314 table: |
315 include multipass-vs-match_common.uti
316 attribute x x
317 noback context ["abc"]"y" @123
318 noback context ["abc"]%x."y" @123
319 tests:
320 - - "abcy"
321 - "⠇⠽"
322 - - "abcxy"
323 - "⠇⠭⠽"
324 - - "abcxxy"
325 - "⠇⠭⠭⠽"
326
327 # optional
328 table: |
329 include multipass-vs-match_common.uti
330 match - abc x?y 123
331 table: |
332 include multipass-vs-match_common.uti
333 noback context ["abc"]"y" @123
334 noback context ["abc"]"xy" @123
335 tests:
336 - - "abcy"
337 - "⠇⠽"
338 - - "abcxy"
339 - "⠇⠭⠽"
340 - - "abcxxy"
341 - "⠁⠃⠉⠭⠭⠽"
342
343 # limiting repitition (not more than two)
344 table: |
345 include multipass-vs-match_common.uti
346 attribute x x
347 noback context ["abc"]%x1-2"y" @123
348 tests:
349 - - "abcy"
350 - "⠁⠃⠉⠽"
351 - - "abcxy"
352 - "⠇⠭⠽"
353 - - "abcxxy"
354 - "⠇⠭⠭⠽"
355 - - "abcxxxy"
356 - "⠁⠃⠉⠭⠭⠭⠽"
357
358 # exact repitition
359 table: |
360 include multipass-vs-match_common.uti
361 attribute x x
362 noback context ["abc"]%x2"y" @123
363 tests:
364 - - "abcxy"
365 - "⠁⠃⠉⠭⠽"
366 - - "abcxxy"
367 - "⠇⠭⠭⠽"
368 - - "abcxxxy"
369 - "⠁⠃⠉⠭⠭⠭⠽"
370
371 # three or more
372 table: |
373 include multipass-vs-match_common.uti
374 attribute x x
375 noback context ["abc"]%x2%x."y" @123
376 tests:
377 - - "abcxxy"
378 - "⠁⠃⠉⠭⠭⠽"
379 - - "abcxxxy"
380 - "⠇⠭⠭⠭⠽"
381 - - "abcxxxxy"
382 - "⠇⠭⠭⠭⠭⠽"
383
384 # negation
385 table: |
386 include multipass-vs-match_common.uti
387 match - abc !x 123
388 table: |
389 include multipass-vs-match_common.uti
390 noback context ["abc"]!"x" @123
391 table: |
392 include multipass-vs-match_common.uti
393 attribute x x
394 noback context ["abc"]!%x @123
395 tests:
396 - - "abcx"
397 - "⠁⠃⠉⠭"
398 - - "abcy"
399 - "⠇⠽"
400 - - "abc"
401 - "⠁⠃⠉"
402
403 # negated group
404 table: |
405 include multipass-vs-match_common.uti
406 match - abc !(xy) 123
407 tests:
408 - - "abcx"
409 - "⠁⠃⠉⠭"
410 - - "abcxy"
411 - "⠁⠃⠉⠭⠽"
412
413 # replace with nothing
414 table: |
415 include multipass-vs-match_common.uti
416 noback context "abc" ?
417 tests:
418 - - "xabcx"
419 - "⠭⠭"
420
421 # character classes in match
422 table: |
423 include multipass-vs-match_common.uti
424 attribute xy xy
425 noback context $s @1
426 noback context $d. @3
427 noback context %xy @2
428 tests:
429 - - " "
430 - "⠁"
431 - - "y"
432 - "⠂"
433 - - "12345"
434 - "⠄"