]> gitweb.factorcode.org Git - factor.git/blob - basis/regexp/regexp-tests.factor
Uncommenting most remaining regexp unit tests
[factor.git] / basis / regexp / regexp-tests.factor
1 ! Copyright (C) 2008, 2009 Doug Coleman, Daniel Ehrenberg
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: regexp tools.test kernel sequences regexp.parser regexp.private
4 eval strings multiline accessors ;
5 IN: regexp-tests
6
7 \ <regexp> must-infer
8 \ compile-regexp must-infer
9 \ matches? must-infer
10
11 [ f ] [ "b" "a*" <regexp> matches? ] unit-test
12 [ t ] [ "" "a*" <regexp> matches? ] unit-test
13 [ t ] [ "a" "a*" <regexp> matches? ] unit-test
14 [ t ] [ "aaaaaaa" "a*"  <regexp> matches? ] unit-test
15 [ f ] [ "ab" "a*" <regexp> matches? ] unit-test
16
17 [ t ] [ "abc" "abc" <regexp> matches? ] unit-test
18 [ t ] [ "a" "a|b|c" <regexp> matches? ] unit-test
19 [ t ] [ "b" "a|b|c" <regexp> matches? ] unit-test
20 [ t ] [ "c" "a|b|c" <regexp> matches? ] unit-test
21 [ f ] [ "c" "d|e|f" <regexp> matches? ] unit-test
22
23 [ t ] [ "b" "|b" <regexp> matches? ] unit-test
24 [ t ] [ "b" "b|" <regexp> matches? ] unit-test
25 [ t ] [ "" "b|" <regexp> matches? ] unit-test
26 [ t ] [ "" "b|" <regexp> matches? ] unit-test
27 [ t ] [ "" "|" <regexp> matches? ] unit-test
28 [ t ] [ "" "|||||||" <regexp> matches? ] unit-test
29
30 [ f ] [ "aa" "a|b|c" <regexp> matches? ] unit-test
31 [ f ] [ "bb" "a|b|c" <regexp> matches? ] unit-test
32 [ f ] [ "cc" "a|b|c" <regexp> matches? ] unit-test
33 [ f ] [ "cc" "d|e|f" <regexp> matches? ] unit-test
34
35 [ f ] [ "" "a+" <regexp> matches? ] unit-test
36 [ t ] [ "a" "a+" <regexp> matches? ] unit-test
37 [ t ] [ "aa" "a+" <regexp> matches? ] unit-test
38
39 [ t ] [ "" "a?" <regexp> matches? ] unit-test
40 [ t ] [ "a" "a?" <regexp> matches? ] unit-test
41 [ f ] [ "aa" "a?" <regexp> matches? ] unit-test
42
43 [ f ] [ "" "." <regexp> matches? ] unit-test
44 [ t ] [ "a" "." <regexp> matches? ] unit-test
45 [ t ] [ "." "." <regexp> matches? ] unit-test
46
47 ! Dotall mode -- when on, . matches newlines.
48 ! Off by default.
49 [ f ] [ "\n" "." <regexp> matches? ] unit-test
50 [ t ] [ "\n" "(?s:.)" <regexp> matches? ] unit-test
51 [ t ] [ "\n" R/ ./s matches? ] unit-test
52 [ f ] [ "\n\n" "(?s:.)." <regexp> matches? ] unit-test
53
54 [ f ] [ "" ".+" <regexp> matches? ] unit-test
55 [ t ] [ "a" ".+" <regexp> matches? ] unit-test
56 [ t ] [ "ab" ".+" <regexp> matches? ] unit-test
57
58 [ t ] [ " " "[\\s]" <regexp> matches? ] unit-test
59 [ f ] [ "a" "[\\s]" <regexp> matches? ] unit-test
60 [ f ] [ " " "[\\S]" <regexp> matches? ] unit-test
61 [ t ] [ "a" "[\\S]" <regexp> matches? ] unit-test
62 [ f ] [ " " "[\\w]" <regexp> matches? ] unit-test
63 [ t ] [ "a" "[\\w]" <regexp> matches? ] unit-test
64 [ t ] [ " " "[\\W]" <regexp> matches? ] unit-test
65 [ f ] [ "a" "[\\W]" <regexp> matches? ] unit-test
66
67 [ t ] [ "/" "\\/" <regexp> matches? ] unit-test
68
69 [ t ] [ "a" R' a'i matches? ] unit-test
70
71 [ t ] [ "" "a|b*|c+|d?" <regexp> matches? ] unit-test
72 [ t ] [ "a" "a|b*|c+|d?" <regexp> matches? ] unit-test
73 [ t ] [ "c" "a|b*|c+|d?" <regexp> matches? ] unit-test
74 [ t ] [ "cc" "a|b*|c+|d?" <regexp> matches? ] unit-test
75 [ f ] [ "ccd" "a|b*|c+|d?" <regexp> matches? ] unit-test
76 [ t ] [ "d" "a|b*|c+|d?" <regexp> matches? ] unit-test
77
78 [ t ] [ "foo" "foo|bar" <regexp> matches? ] unit-test
79 [ t ] [ "bar" "foo|bar" <regexp> matches? ] unit-test
80 [ f ] [ "foobar" "foo|bar" <regexp> matches? ] unit-test
81
82 [ f ] [ "" "(a)" <regexp> matches? ] unit-test
83 [ t ] [ "a" "(a)" <regexp> matches? ] unit-test
84 [ f ] [ "aa" "(a)" <regexp> matches? ] unit-test
85 [ t ] [ "aa" "(a*)" <regexp> matches? ] unit-test
86
87 [ f ] [ "aababaaabbac" "(a|b)+" <regexp> matches? ] unit-test
88 [ t ] [ "ababaaabba" "(a|b)+" <regexp> matches? ] unit-test
89
90 [ f ] [ "" "a{1}" <regexp> matches? ] unit-test
91 [ t ] [ "a" "a{1}" <regexp> matches? ] unit-test
92 [ f ] [ "aa" "a{1}" <regexp> matches? ] unit-test
93
94 [ f ] [ "a" "a{2,}" <regexp> matches? ] unit-test
95 [ t ] [ "aaa" "a{2,}" <regexp> matches? ] unit-test
96 [ t ] [ "aaaa" "a{2,}" <regexp> matches? ] unit-test
97 [ t ] [ "aaaaa" "a{2,}" <regexp> matches? ] unit-test
98
99 [ t ] [ "" "a{,2}" <regexp> matches? ] unit-test
100 [ t ] [ "a" "a{,2}" <regexp> matches? ] unit-test
101 [ t ] [ "aa" "a{,2}" <regexp> matches? ] unit-test
102 [ f ] [ "aaa" "a{,2}" <regexp> matches? ] unit-test
103 [ f ] [ "aaaa" "a{,2}" <regexp> matches? ] unit-test
104 [ f ] [ "aaaaa" "a{,2}" <regexp> matches? ] unit-test
105
106 [ f ] [ "" "a{1,3}" <regexp> matches? ] unit-test
107 [ t ] [ "a" "a{1,3}" <regexp> matches? ] unit-test
108 [ t ] [ "aa" "a{1,3}" <regexp> matches? ] unit-test
109 [ t ] [ "aaa" "a{1,3}" <regexp> matches? ] unit-test
110 [ f ] [ "aaaa" "a{1,3}" <regexp> matches? ] unit-test
111
112 [ f ] [ "" "[a]" <regexp> matches? ] unit-test
113 [ t ] [ "a" "[a]" <regexp> matches? ] unit-test
114 [ t ] [ "a" "[abc]" <regexp> matches? ] unit-test
115 [ f ] [ "b" "[a]" <regexp> matches? ] unit-test
116 [ f ] [ "d" "[abc]" <regexp> matches? ] unit-test
117 [ t ] [ "ab" "[abc]{1,2}" <regexp> matches? ] unit-test
118 [ f ] [ "abc" "[abc]{1,2}" <regexp> matches? ] unit-test
119
120 [ f ] [ "" "[^a]" <regexp> matches? ] unit-test
121 [ f ] [ "a" "[^a]" <regexp> matches? ] unit-test
122 [ f ] [ "a" "[^abc]" <regexp> matches? ] unit-test
123 [ t ] [ "b" "[^a]" <regexp> matches? ] unit-test
124 [ t ] [ "d" "[^abc]" <regexp> matches? ] unit-test
125 [ f ] [ "ab" "[^abc]{1,2}" <regexp> matches? ] unit-test
126 [ f ] [ "abc" "[^abc]{1,2}" <regexp> matches? ] unit-test
127
128 [ t ] [ "]" "[]]" <regexp> matches? ] unit-test
129 [ f ] [ "]" "[^]]" <regexp> matches? ] unit-test
130 [ t ] [ "a" "[^]]" <regexp> matches? ] unit-test
131
132 [ "^" "[^]" <regexp> matches? ] must-fail
133 [ t ] [ "^" "[]^]" <regexp> matches? ] unit-test
134 [ t ] [ "]" "[]^]" <regexp> matches? ] unit-test
135
136 [ t ] [ "[" "[[]" <regexp> matches? ] unit-test
137 [ f ] [ "^" "[^^]" <regexp> matches? ] unit-test
138 [ t ] [ "a" "[^^]" <regexp> matches? ] unit-test
139
140 [ t ] [ "-" "[-]" <regexp> matches? ] unit-test
141 [ f ] [ "a" "[-]" <regexp> matches? ] unit-test
142 [ f ] [ "-" "[^-]" <regexp> matches? ] unit-test
143 [ t ] [ "a" "[^-]" <regexp> matches? ] unit-test
144
145 [ t ] [ "-" "[-a]" <regexp> matches? ] unit-test
146 [ t ] [ "a" "[-a]" <regexp> matches? ] unit-test
147 [ t ] [ "-" "[a-]" <regexp> matches? ] unit-test
148 [ t ] [ "a" "[a-]" <regexp> matches? ] unit-test
149 [ f ] [ "b" "[a-]" <regexp> matches? ] unit-test
150 [ f ] [ "-" "[^-]" <regexp> matches? ] unit-test
151 [ t ] [ "a" "[^-]" <regexp> matches? ] unit-test
152
153 [ f ] [ "-" "[a-c]" <regexp> matches? ] unit-test
154 [ t ] [ "-" "[^a-c]" <regexp> matches? ] unit-test
155 [ t ] [ "b" "[a-c]" <regexp> matches? ] unit-test
156 [ f ] [ "b" "[^a-c]" <regexp> matches? ] unit-test
157
158 [ t ] [ "-" "[a-c-]" <regexp> matches? ] unit-test
159 [ f ] [ "-" "[^a-c-]" <regexp> matches? ] unit-test
160
161 [ t ] [ "\\" "[\\\\]" <regexp> matches? ] unit-test
162 [ f ] [ "a" "[\\\\]" <regexp> matches? ] unit-test
163 [ f ] [ "\\" "[^\\\\]" <regexp> matches? ] unit-test
164 [ t ] [ "a" "[^\\\\]" <regexp> matches? ] unit-test
165
166 [ t ] [ "0" "[\\d]" <regexp> matches? ] unit-test
167 [ f ] [ "a" "[\\d]" <regexp> matches? ] unit-test
168 [ f ] [ "0" "[^\\d]" <regexp> matches? ] unit-test
169 [ t ] [ "a" "[^\\d]" <regexp> matches? ] unit-test
170
171 [ t ] [ "a" "[a-z]{1,}|[A-Z]{2,4}|b*|c|(f|g)*" <regexp> matches? ] unit-test
172 [ t ] [ "a" "[a-z]{1,2}|[A-Z]{3,3}|b*|c|(f|g)*" <regexp> matches? ] unit-test
173 [ t ] [ "a" "[a-z]{1,2}|[A-Z]{3,3}" <regexp> matches? ] unit-test
174
175 [ t ] [ "1000" "\\d{4,6}" <regexp> matches? ] unit-test
176 [ t ] [ "1000" "[0-9]{4,6}" <regexp> matches? ] unit-test
177
178 [ t ] [ "abc" "\\p{Lower}{3}" <regexp> matches? ] unit-test
179 [ f ] [ "ABC" "\\p{Lower}{3}" <regexp> matches? ] unit-test
180 [ t ] [ "ABC" "\\p{Upper}{3}" <regexp> matches? ] unit-test
181 [ f ] [ "abc" "\\p{Upper}{3}" <regexp> matches? ] unit-test
182 [ f ] [ "abc" "[\\p{Upper}]{3}" <regexp> matches? ] unit-test
183 [ t ] [ "ABC" "[\\p{Upper}]{3}" <regexp> matches? ] unit-test
184
185 [ t ] [ "" "\\Q\\E" <regexp> matches? ] unit-test
186 [ f ] [ "a" "\\Q\\E" <regexp> matches? ] unit-test
187 [ t ] [ "|*+" "\\Q|*+\\E" <regexp> matches? ] unit-test
188 [ f ] [ "abc" "\\Q|*+\\E" <regexp> matches? ] unit-test
189 [ t ] [ "s" "\\Qs\\E" <regexp> matches? ] unit-test
190
191 [ t ] [ "S" "\\0123" <regexp> matches? ] unit-test
192 [ t ] [ "SXY" "\\0123XY" <regexp> matches? ] unit-test
193 [ t ] [ "x" "\\x78" <regexp> matches? ] unit-test
194 [ f ] [ "y" "\\x78" <regexp> matches? ] unit-test
195 [ t ] [ "x" "\\u0078" <regexp> matches? ] unit-test
196 [ f ] [ "y" "\\u0078" <regexp> matches? ] unit-test
197
198 [ t ] [ "ab" "a+b" <regexp> matches? ] unit-test
199 [ f ] [ "b" "a+b" <regexp> matches? ] unit-test
200 [ t ] [ "aab" "a+b" <regexp> matches? ] unit-test
201 [ f ] [ "abb" "a+b" <regexp> matches? ] unit-test
202
203 [ t ] [ "abbbb" "ab*" <regexp> matches? ] unit-test
204 [ t ] [ "a" "ab*" <regexp> matches? ] unit-test
205 [ f ] [ "abab" "ab*" <regexp> matches? ] unit-test
206
207 [ f ] [ "x" "\\." <regexp> matches? ] unit-test
208 [ t ] [ "." "\\." <regexp> matches? ] unit-test
209
210 [ t ] [ "aaaab" "a+ab" <regexp> matches? ] unit-test
211 [ f ] [ "aaaxb" "a+ab" <regexp> matches? ] unit-test
212 [ t ] [ "aaacb" "a+cb" <regexp> matches? ] unit-test
213
214 [ "aaa" ] [ "aaacb" "a*" <regexp> first-match >string ] unit-test
215 [ "aa" ] [ "aaacb" "aa?" <regexp> first-match >string ] unit-test
216
217 [ t ] [ "aaa" R/ AAA/i matches? ] unit-test
218 [ f ] [ "aax" R/ AAA/i matches? ] unit-test
219 [ t ] [ "aaa" R/ A*/i matches? ] unit-test
220 [ f ] [ "aaba" R/ A*/i matches? ] unit-test
221 [ t ] [ "b" R/ [AB]/i matches? ] unit-test
222 [ f ] [ "c" R/ [AB]/i matches? ] unit-test
223 [ t ] [ "c" R/ [A-Z]/i matches? ] unit-test
224 [ f ] [ "3" R/ [A-Z]/i matches? ] unit-test
225
226 [ t ] [ "a" "(?i:a)" <regexp> matches? ] unit-test
227 [ t ] [ "a" "(?i:a)" <regexp> matches? ] unit-test
228 [ t ] [ "A" "(?i:a)" <regexp> matches? ] unit-test
229 [ t ] [ "A" "(?i:a)" <regexp> matches? ] unit-test
230
231 [ t ] [ "a" R/ (?-i:a)/i matches? ] unit-test
232 [ t ] [ "a" R/ (?-i:a)/i matches? ] unit-test
233 [ f ] [ "A" R/ (?-i:a)/i matches? ] unit-test
234 [ f ] [ "A" R/ (?-i:a)/i matches? ] unit-test
235
236 [ f ] [ "A" "[a-z]" <regexp> matches? ] unit-test
237 [ t ] [ "A" R/ [a-z]/i matches? ] unit-test
238
239 [ f ] [ "A" "\\p{Lower}" <regexp> matches? ] unit-test
240 [ t ] [ "A" R/ \p{Lower}/i matches? ] unit-test
241
242 [ t ] [ "abc" R/ abc/r matches? ] unit-test
243 [ t ] [ "abc" R/ a[bB][cC]/r matches? ] unit-test
244
245 [ t ] [ 3 "xabc" R/ abc/r match-index-from >boolean ] unit-test
246 [ t ] [ 3 "xabc" R/ a[bB][cC]/r match-index-from >boolean ] unit-test
247
248 [ t ] [ "s@f" "[a-z.-]@[a-z]" <regexp> matches? ] unit-test
249 [ f ] [ "a" "[a-z.-]@[a-z]" <regexp> matches? ] unit-test
250 [ t ] [ ".o" "\\.[a-z]" <regexp> matches? ] unit-test
251
252 [ t ] [ "abc*" "[^\\*]*\\*" <regexp> matches? ] unit-test
253 [ t ] [ "bca" "[^a]*a" <regexp> matches? ] unit-test
254
255 [ ] [
256     "(0[lL]?|[1-9]\\d{0,9}(\\d{0,9}[lL])?|0[xX]\\p{XDigit}{1,8}(\\p{XDigit}{0,8}[lL])?|0[0-7]{1,11}([0-7]{0,11}[lL])?|([0-9]+\\.[0-9]*|\\.[0-9]+)([eE][+-]?[0-9]+)?[fFdD]?|[0-9]+([eE][+-]?[0-9]+[fFdD]?|([eE][+-]?[0-9]+)?[fFdD]))"
257     <regexp> drop
258 ] unit-test
259
260 [ ] [ "(\\$[\\p{XDigit}]|[\\p{Digit}])" <regexp> drop ] unit-test
261
262 ! Comment inside a regular expression
263 [ t ] [ "ac" "a(?#boo)c" <regexp> matches? ] unit-test
264
265 [ ] [ "USING: regexp kernel ; R' -{3}[+]{1,6}(?:!!)?\\s' drop" eval ] unit-test
266
267 [ ] [ "USING: regexp kernel ; R' (ftp|http|https)://(\\w+:?\\w*@)?(\\S+)(:[0-9]+)?(/|/([\\w#!:.?+=&%@!\\-/]))?' drop" eval ] unit-test
268
269 [ ] [ "USING: regexp kernel ; R' \\*[^\s*][^*]*\\*' drop" eval ] unit-test
270
271 [ "ab" ] [ "ab" "(a|ab)(bc)?" <regexp> first-match >string ] unit-test
272 [ "abc" ] [ "abc" "(a|ab)(bc)?" <regexp> first-match >string ] unit-test
273
274 [ "ab" ] [ "ab" "(ab|a)(bc)?" <regexp> first-match >string ] unit-test
275 [ "abc" ] [ "abc" "(ab|a)(bc)?" <regexp> first-match >string ] unit-test
276
277 [ "b" ] [ "aaaaaaaaaaaaaaaaaaaaaaab" "((a*)*b)*b" <regexp> first-match >string ] unit-test
278
279 [ { "1" "2" "3" "4" } ]
280 [ "1ABC2DEF3GHI4" R/ [A-Z]+/ re-split [ >string ] map ] unit-test
281
282 [ { "1" "2" "3" "4" "" } ]
283 [ "1ABC2DEF3GHI4JK" R/ [A-Z]+/ re-split [ >string ] map ] unit-test
284
285 [ { "" } ] [ "" R/ =/ re-split [ >string ] map ] unit-test
286
287 [ { "a" "" } ] [ "a=" R/ =/ re-split [ >string ] map ] unit-test
288
289 [ { "ABC" "DEF" "GHI" } ]
290 [ "1ABC2DEF3GHI4" R/ [A-Z]+/ all-matches [ >string ] map ] unit-test
291
292 [ 3 ]
293 [ "1ABC2DEF3GHI4" R/ [A-Z]+/ count-matches ] unit-test
294
295 [ 0 ]
296 [ "123" R/ [A-Z]+/ count-matches ] unit-test
297
298 [ "1.2.3.4." ]
299 [ "1ABC2DEF3GHI4JK" R/ [A-Z]+/ "." re-replace ] unit-test
300   
301 [ "-- title --" ] [ "== title ==" R/ =/ "-" re-replace ] unit-test
302
303 [ "" ] [ "ab" "a(?!b)" <regexp> first-match >string ] unit-test
304 [ "a" ] [ "ac" "a(?!b)" <regexp> first-match >string ] unit-test
305 [ t ] [ "fxxbar" ".{3}(?!foo)bar" <regexp> matches? ] unit-test
306 [ t ] [ "foobar" ".{3}(?!foo)bar" <regexp> matches? ] unit-test
307 [ t ] [ "fxxbar" "(?!foo).{3}bar" <regexp> matches? ] unit-test
308 [ f ] [ "foobar" "(?!foo).{3}bar" <regexp> matches? ] unit-test
309 [ "a" ] [ "ab" "a(?=b)(?=b)" <regexp> first-match >string ] unit-test
310 [ "a" ] [ "ba" "(?<=b)(?<=b)a" <regexp> first-match >string ] unit-test
311 [ "a" ] [ "cab" "(?<=c)a(?=b)" <regexp> first-match >string ] unit-test
312
313 [ 3 ] [ "foobar" "foo(?=bar)" <regexp> first-match length ] unit-test
314 [ f ] [ "foobxr" "foo(?=bar)" <regexp> first-match ] unit-test
315
316 ! Bug in parsing word
317 [ t ] [ "a" R' a' matches? ] unit-test
318
319 ! Testing negation
320 [ f ] [ "a" R/ (?~a)/ matches? ] unit-test
321 [ t ] [ "aa" R/ (?~a)/ matches? ] unit-test
322 [ t ] [ "bb" R/ (?~a)/ matches? ] unit-test
323 [ t ] [ "" R/ (?~a)/ matches? ] unit-test
324
325 [ f ] [ "a" R/ (?~a+|b)/ matches? ] unit-test
326 [ f ] [ "aa" R/ (?~a+|b)/ matches? ] unit-test
327 [ t ] [ "bb" R/ (?~a+|b)/ matches? ] unit-test
328 [ f ] [ "b" R/ (?~a+|b)/ matches? ] unit-test
329 [ t ] [ "" R/ (?~a+|b)/ matches? ] unit-test
330
331 ! Intersecting classes
332 [ t ] [ "ab" R/ ac|\p{Lower}b/ matches? ] unit-test
333 [ t ] [ "ab" R/ ac|[a-z]b/ matches? ] unit-test
334 [ t ] [ "ac" R/ ac|\p{Lower}b/ matches? ] unit-test
335 [ t ] [ "ac" R/ ac|[a-z]b/ matches? ] unit-test
336 [ t ] [ "ac" R/ [a-zA-Z]c|\p{Lower}b/ matches? ] unit-test
337 [ t ] [ "ab" R/ [a-zA-Z]c|\p{Lower}b/ matches? ] unit-test
338 [ t ] [ "πb" R/ [a-zA-Z]c|\p{Lower}b/ matches? ] unit-test
339 [ f ] [ "πc" R/ [a-zA-Z]c|\p{Lower}b/ matches? ] unit-test
340 [ f ] [ "Ab" R/ [a-zA-Z]c|\p{Lower}b/ matches? ] unit-test
341
342 [ t ] [ "aaaa" R/ .*a./ matches? ] unit-test
343
344 [ f ] [ "ab" R/ (?~ac|\p{Lower}b)/ matches? ] unit-test
345 [ f ] [ "ab" R/ (?~ac|[a-z]b)/ matches? ] unit-test
346 [ f ] [ "ac" R/ (?~ac|\p{Lower}b)/ matches? ] unit-test
347 [ f ] [ "ac" R/ (?~ac|[a-z]b)/ matches? ] unit-test
348 [ f ] [ "ac" R/ (?~[a-zA-Z]c|\p{Lower}b)/ matches? ] unit-test
349 [ f ] [ "ab" R/ (?~[a-zA-Z]c|\p{Lower}b)/ matches? ] unit-test
350 [ f ] [ "πb" R/ (?~[a-zA-Z]c|\p{Lower}b)/ matches? ] unit-test
351 [ t ] [ "πc" R/ (?~[a-zA-Z]c|\p{Lower}b)/ matches? ] unit-test
352 [ t ] [ "Ab" R/ (?~[a-zA-Z]c|\p{Lower}b)/ matches? ] unit-test
353
354 ! DFA is compiled when needed, or when literal
355 [ regexp-initial-word ] [ "foo" <regexp> dfa>> ] unit-test
356 [ f ] [ R/ foo/ dfa>> \ regexp-initial-word = ] unit-test
357
358 [ t ] [ "a" R/ ^a/ matches? ] unit-test
359 [ f ] [ "\na" R/ ^a/ matches? ] unit-test
360 [ f ] [ "\r\na" R/ ^a/ matches? ] unit-test
361 [ f ] [ "\ra" R/ ^a/ matches? ] unit-test
362
363 [ 1 ] [ "a" R/ ^a/ count-matches ] unit-test
364 [ 0 ] [ "\na" R/ ^a/ count-matches ] unit-test
365 [ 0 ] [ "\r\na" R/ ^a/ count-matches ] unit-test
366 [ 0 ] [ "\ra" R/ ^a/ count-matches ] unit-test
367
368 [ t ] [ "a" R/ a$/ matches? ] unit-test
369 [ f ] [ "a\n" R/ a$/ matches? ] unit-test
370 [ f ] [ "a\r" R/ a$/ matches? ] unit-test
371 [ f ] [ "a\r\n" R/ a$/ matches? ] unit-test
372
373 [ 1 ] [ "a" R/ a$/ count-matches ] unit-test
374 [ 0 ] [ "a\n" R/ a$/ count-matches ] unit-test
375 [ 0 ] [ "a\r" R/ a$/ count-matches ] unit-test
376 [ 0 ] [ "a\r\n" R/ a$/ count-matches ] unit-test
377
378 [ t ] [ "a" R/ a$|b$/ matches? ] unit-test
379 [ t ] [ "b" R/ a$|b$/ matches? ] unit-test
380 [ f ] [ "ab" R/ a$|b$/ matches? ] unit-test
381 [ t ] [ "ba" R/ ba$|b$/ matches? ] unit-test
382
383 [ t ] [ "a" R/ \Aa/ matches? ] unit-test
384 [ f ] [ "\na" R/ \Aaa/ matches? ] unit-test
385 [ f ] [ "\r\na" R/ \Aa/ matches? ] unit-test
386 [ f ] [ "\ra" R/ \Aa/ matches? ] unit-test
387
388 [ t ] [ "a" R/ \Aa/m matches? ] unit-test
389 [ f ] [ "\na" R/ \Aaa/m matches? ] unit-test
390 [ f ] [ "\r\na" R/ \Aa/m matches? ] unit-test
391 [ f ] [ "\ra" R/ \Aa/m matches? ] unit-test
392 [ 0 ] [ "\ra" R/ \Aa/m count-matches ] unit-test
393
394 [ f ] [ "\r\n\n\n\nam" R/ ^am/m matches? ] unit-test
395 [ 1 ] [ "\r\n\n\n\nam" R/ ^am/m count-matches ] unit-test
396
397 [ t ] [ "a" R/ \Aa\z/m matches? ] unit-test
398 [ f ] [ "a\n" R/ \Aa\z/m matches? ] unit-test
399
400 [ f ] [ "a\r\n" R/ \Aa\Z/m matches? ] unit-test
401 [ f ] [ "a\n" R/ \Aa\Z/m matches? ] unit-test
402 [ 1 ] [ "a\r\n" R/ \Aa\Z/m count-matches ] unit-test
403 [ 1 ] [ "a\n" R/ \Aa\Z/m count-matches ] unit-test
404
405 [ t ] [ "a" R/ \Aa\Z/m matches? ] unit-test
406 [ f ] [ "\na" R/ \Aaa\Z/m matches? ] unit-test
407 [ f ] [ "\r\na" R/ \Aa\Z/m matches? ] unit-test
408 [ f ] [ "\ra" R/ \Aa\Z/m matches? ] unit-test
409
410 [ 1 ] [ "a" R/ \Aa\Z/m count-matches ] unit-test
411 [ 0 ] [ "\na" R/ \Aaa\Z/m count-matches ] unit-test
412 [ 0 ] [ "\r\na" R/ \Aa\Z/m count-matches ] unit-test
413 [ 0 ] [ "\ra" R/ \Aa\Z/m count-matches ] unit-test
414
415 [ t ] [ "a" R/ ^a/m matches? ] unit-test
416 [ f ] [ "\na" R/ ^a/m matches? ] unit-test
417 [ 1 ] [ "\na" R/ ^a/m count-matches ] unit-test
418 [ 1 ] [ "\r\na" R/ ^a/m count-matches ] unit-test
419 [ 1 ] [ "\ra" R/ ^a/m count-matches ] unit-test
420
421 [ t ] [ "a" R/ a$/m matches? ] unit-test
422 [ f ] [ "a\n" R/ a$/m matches? ] unit-test
423 [ 1 ] [ "a\n" R/ a$/m count-matches ] unit-test
424 [ 1 ] [ "a\r" R/ a$/m count-matches ] unit-test
425 [ 1 ] [ "a\r\n" R/ a$/m count-matches ] unit-test
426
427 [ f ] [ "foobxr" "foo\\z" <regexp> first-match ] unit-test
428 [ 3 ] [ "foo" "foo\\z" <regexp> first-match length ] unit-test
429
430 [ t ] [ "a foo b" R/ foo/ re-contains? ] unit-test
431 [ f ] [ "a bar b" R/ foo/ re-contains? ] unit-test
432 [ t ] [ "foo" R/ foo/ re-contains? ] unit-test
433
434 [ { "foo" "fxx" "fab" } ] [ "fab fxx foo" R/ f../r all-matches [ >string ] map ] unit-test
435
436 [ t ] [ "foo" "\\bfoo\\b" <regexp> re-contains? ] unit-test
437 [ t ] [ "afoob" "\\Bfoo\\B" <regexp> re-contains? ] unit-test
438 [ f ] [ "afoob" "\\bfoo\\b" <regexp> re-contains? ] unit-test
439 [ f ] [ "foo" "\\Bfoo\\B" <regexp> re-contains? ] unit-test
440
441 [ 3 ] [ "foo bar" "foo\\b" <regexp> first-match length ] unit-test
442 [ f ] [ "fooxbar" "foo\\b" <regexp> re-contains? ] unit-test
443 [ t ] [ "foo" "foo\\b" <regexp> re-contains? ] unit-test
444 [ t ] [ "foo bar" "foo\\b bar" <regexp> matches? ] unit-test
445 [ f ] [ "fooxbar" "foo\\bxbar" <regexp> matches? ] unit-test
446 [ f ] [ "foo" "foo\\bbar" <regexp> matches? ] unit-test
447
448 [ f ] [ "foo bar" "foo\\B" <regexp> re-contains? ] unit-test
449 [ 3 ] [ "fooxbar" "foo\\B" <regexp> first-match length ] unit-test
450 [ f ] [ "foo" "foo\\B" <regexp> re-contains? ] unit-test
451 [ f ] [ "foo bar" "foo\\B bar" <regexp> matches? ] unit-test
452 [ t ] [ "fooxbar" "foo\\Bxbar" <regexp> matches? ] unit-test
453 [ f ] [ "foo" "foo\\Bbar" <regexp> matches? ] unit-test
454
455 [ t ] [ "ab" "a(?=b*)" <regexp> re-contains? ] unit-test
456 [ t ] [ "abbbbbc" "a(?=b*c)" <regexp> re-contains? ] unit-test
457 [ f ] [ "abbbbb" "a(?=b*c)" <regexp> re-contains? ] unit-test
458 [ t ] [ "ab" "a(?=b*)" <regexp> re-contains? ] unit-test
459
460 [ "az" ] [ "baz" "(?<=b)(az)" <regexp> first-match >string ] unit-test
461 [ f ] [ "chaz" "(?<=b)(az)" <regexp> re-contains? ] unit-test
462 [ "a" ] [ "cbaz" "(?<=b*)a" <regexp> first-match >string ] unit-test
463 [ f ] [ "baz" "a(?<=b)" <regexp> re-contains? ] unit-test
464
465 [ f ] [ "baz" "(?<!b)a" <regexp> re-contains? ] unit-test
466 [ t ] [ "caz" "(?<!b)a" <regexp> re-contains? ] unit-test
467
468 [ "abcd" ] [ "abcdefg" "a(?=bcdefg)bcd" <regexp> first-match >string ] unit-test
469 [ t ] [ "abcdefg" "a(?#bcdefg)bcd" <regexp> re-contains? ] unit-test
470 [ t ] [ "abcdefg" "a(?:bcdefg)" <regexp> matches? ] unit-test
471
472 [ 3 ] [ "caba" "(?<=b)a" <regexp> first-match from>> ] unit-test