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