File: character_classes_1.9.rb

package info (click to toggle)
jruby 1.7.26-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 84,572 kB
  • sloc: ruby: 669,910; java: 253,056; xml: 35,152; ansic: 9,187; yacc: 7,267; cpp: 5,244; sh: 1,036; makefile: 345; jsp: 48; tcl: 40
file content (499 lines) | stat: -rw-r--r-- 16,079 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
# -*- encoding: utf-8 -*-
# The examples below are based on the definitions in
# http://unicode.org/reports/tr18/ , which was deemed authoritative in
# http://redmine.ruby-lang.org/issues/show/1889 .

it "matches ASCII characters with [[:ascii:]]" do
  "\x00".match(/[[:ascii:]]/).to_a.should == ["\x00"]
  "\x7F".match(/[[:ascii:]]/).to_a.should == ["\x7F"]
end

it "doesn't match non-ASCII characters with [[:ascii:]]" do
  ('/[[:ascii:]]/').match("\u{80}").should be_nil
  ('/[[:ascii:]]/').match("\u{9898}").should be_nil
end

it "matches Unicode letter characters with [[:alnum:]]" do
  "à".match(/[[:alnum:]]/).to_a.should == ["à"]
end

it "matches Unicode digits with [[:alnum:]]" do
  "\u{0660}".match(/[[:alnum:]]/).to_a.should == ["\u{0660}"]
end

it "doesn't matches Unicode marks with [[:alnum:]]" do
  "\u{36F}".match(/[[:alnum:]]/).should be_nil
end

it "doesn't match Unicode control characters with [[:alnum:]]" do
  "\u{16}".match(/[[:alnum:]]/).to_a.should == []
end

it "doesn't match Unicode punctuation characters with [[:alnum:]]" do
  "\u{3F}".match(/[[:alnum:]]/).to_a.should == []
end

it "matches Unicode letter characters with [[:alpha:]]" do
  "à".match(/[[:alpha:]]/).to_a.should == ["à"]
end

it "doesn't match Unicode digits with [[:alpha:]]" do
  "\u{0660}".match(/[[:alpha:]]/).to_a.should == []
end

it "doesn't matches Unicode marks with [[:alpha:]]" do
  "\u{36F}".match(/[[:alpha:]]/).should be_nil
end

it "doesn't match Unicode control characters with [[:alpha:]]" do
  "\u{16}".match(/[[:alpha:]]/).to_a.should == []
end

it "doesn't match Unicode punctuation characters with [[:alpha:]]" do
  "\u{3F}".match(/[[:alpha:]]/).to_a.should == []
end

it "matches Unicode space characters with [[:blank:]]" do
  "\u{180E}".match(/[[:blank:]]/).to_a.should == ["\u{180E}"]
  "\u{1680}".match(/[[:blank:]]/).to_a.should == ["\u{1680}"]
end

it "doesn't match Unicode control characters with [[:blank:]]" do
  "\u{16}".match(/[[:blank:]]/).should be_nil
end

it "doesn't match Unicode punctuation characters with [[:blank:]]" do
  "\u{3F}".match(/[[:blank:]]/).should be_nil
end

it "doesn't match Unicode letter characters with [[:blank:]]" do
  "à".match(/[[:blank:]]/).should be_nil
end

it "doesn't match Unicode digits with [[:blank:]]" do
  "\u{0660}".match(/[[:blank:]]/).should be_nil
end

it "doesn't match Unicode marks with [[:blank:]]" do
  "\u{36F}".match(/[[:blank:]]/).should be_nil
end

it "doesn't match Unicode control characters with [[:blank:]]" do
  "\u{16}".match(/[[:blank:]]/).should be_nil
end

it "doesn't Unicode letter characters with [[:cntrl:]]" do
  "à".match(/[[:cntrl:]]/).should be_nil
end

it "doesn't match Unicode digits with [[:cntrl:]]" do
  "\u{0660}".match(/[[:cntrl:]]/).should be_nil
end

it "doesn't match Unicode marks with [[:cntrl:]]" do
  "\u{36F}".match(/[[:cntrl:]]/).should be_nil
end

it "doesn't match Unicode punctuation characters with [[:cntrl:]]" do
  "\u{3F}".match(/[[:cntrl:]]/).should be_nil
end

it "matches Unicode control characters with [[:cntrl:]]" do
  "\u{16}".match(/[[:cntrl:]]/).to_a.should == ["\u{16}"]
end

it "doesn't match Unicode format characters with [[:cntrl:]]" do
  "\u{2060}".match(/[[:cntrl:]]/).should be_nil
end

it "doesn't match Unicode private-use characters with [[:cntrl:]]" do
  "\u{E001}".match(/[[:cntrl:]]/).should be_nil
end

it "doesn't match Unicode letter characters with [[:digit:]]" do
  "à".match(/[[:digit:]]/).should be_nil
end

it "matches Unicode digits with [[:digit:]]" do
  "\u{0660}".match(/[[:digit:]]/).to_a.should == ["\u{0660}"]
  "\u{FF12}".match(/[[:digit:]]/).to_a.should == ["\u{FF12}"]
end

it "doesn't match Unicode marks with [[:digit:]]" do
  "\u{36F}".match(/[[:digit:]]/).should be_nil
end

it "doesn't match Unicode punctuation characters with [[:digit:]]" do
  "\u{3F}".match(/[[:digit:]]/).should be_nil
end

it "doesn't match Unicode control characters with [[:digit:]]" do
  "\u{16}".match(/[[:digit:]]/).should be_nil
end

it "doesn't match Unicode format characters with [[:digit:]]" do
  "\u{2060}".match(/[[:digit:]]/).should be_nil
end

it "doesn't match Unicode private-use characters with [[:digit:]]" do
  "\u{E001}".match(/[[:digit:]]/).should be_nil
end

it "matches Unicode letter characters with [[:graph:]]" do
    "à".match(/[[:graph:]]/).to_a.should == ["à"]
end

it "matches Unicode digits with [[:graph:]]" do
  "\u{0660}".match(/[[:graph:]]/).to_a.should == ["\u{0660}"]
  "\u{FF12}".match(/[[:graph:]]/).to_a.should == ["\u{FF12}"]
end

it "matches Unicode marks with [[:graph:]]" do
  "\u{36F}".match(/[[:graph:]]/).to_a.should ==["\u{36F}"]
end

it "matches Unicode punctuation characters with [[:graph:]]" do
  "\u{3F}".match(/[[:graph:]]/).to_a.should == ["\u{3F}"]
end

it "doesn't match Unicode control characters with [[:graph:]]" do
  "\u{16}".match(/[[:graph:]]/).should be_nil
end

it "match Unicode format characters with [[:graph:]]" do
  "\u{2060}".match(/[[:graph:]]/).to_a.should == ["\u2060"]
end

it "match Unicode private-use characters with [[:graph:]]" do
  "\u{E001}".match(/[[:graph:]]/).to_a.should == ["\u{E001}"]
end

it "matches Unicode lowercase letter characters with [[:lower:]]" do
  "\u{FF41}".match(/[[:lower:]]/).to_a.should == ["\u{FF41}"]
  "\u{1D484}".match(/[[:lower:]]/).to_a.should == ["\u{1D484}"]
  "\u{E8}".match(/[[:lower:]]/).to_a.should == ["\u{E8}"]
end

it "doesn't match Unicode uppercase letter characters with [[:lower:]]" do
  "\u{100}".match(/[[:lower:]]/).should be_nil
  "\u{130}".match(/[[:lower:]]/).should be_nil
  "\u{405}".match(/[[:lower:]]/).should be_nil
end

it "doesn't match Unicode title-case characters with [[:lower:]]" do
  "\u{1F88}".match(/[[:lower:]]/).should be_nil
  "\u{1FAD}".match(/[[:lower:]]/).should be_nil
  "\u{01C5}".match(/[[:lower:]]/).should be_nil
end

it "doesn't match Unicode digits with [[:lower:]]" do
  "\u{0660}".match(/[[:lower:]]/).should be_nil
  "\u{FF12}".match(/[[:lower:]]/).should be_nil
end

it "doesn't match Unicode marks with [[:lower:]]" do
  "\u{36F}".match(/[[:lower:]]/).should be_nil
end

it "doesn't match Unicode punctuation characters with [[:lower:]]" do
  "\u{3F}".match(/[[:lower:]]/).should be_nil
end

it "doesn't match Unicode control characters with [[:lower:]]" do
  "\u{16}".match(/[[:lower:]]/).should be_nil
end

it "doesn't match Unicode format characters with [[:lower:]]" do
  "\u{2060}".match(/[[:lower:]]/).should be_nil
end

it "doesn't match Unicode private-use characters with [[:lower:]]" do
  "\u{E001}".match(/[[:lower:]]/).should be_nil
end

it "matches Unicode lowercase letter characters with [[:print:]]" do
  "\u{FF41}".match(/[[:print:]]/).to_a.should == ["\u{FF41}"]
  "\u{1D484}".match(/[[:print:]]/).to_a.should == ["\u{1D484}"]
  "\u{E8}".match(/[[:print:]]/).to_a.should == ["\u{E8}"]
end

it "matches Unicode uppercase letter characters with [[:print:]]" do
  "\u{100}".match(/[[:print:]]/).to_a.should == ["\u{100}"]
  "\u{130}".match(/[[:print:]]/).to_a.should == ["\u{130}"]
  "\u{405}".match(/[[:print:]]/).to_a.should == ["\u{405}"]
end

it "matches Unicode title-case characters with [[:print:]]" do
  "\u{1F88}".match(/[[:print:]]/).to_a.should == ["\u{1F88}"]
  "\u{1FAD}".match(/[[:print:]]/).to_a.should == ["\u{1FAD}"]
  "\u{01C5}".match(/[[:print:]]/).to_a.should == ["\u{01C5}"]
end

it "matches Unicode digits with [[:print:]]" do
  "\u{0660}".match(/[[:print:]]/).to_a.should == ["\u{0660}"]
  "\u{FF12}".match(/[[:print:]]/).to_a.should == ["\u{FF12}"]
end

it "matches Unicode marks with [[:print:]]" do
  "\u{36F}".match(/[[:print:]]/).to_a.should == ["\u{36F}"]
end

it "matches Unicode punctuation characters with [[:print:]]" do
  "\u{3F}".match(/[[:print:]]/).to_a.should == ["\u{3F}"]
end

it "doesn't match Unicode control characters with [[:print:]]" do
  "\u{16}".match(/[[:print:]]/).should be_nil
end

it "match Unicode format characters with [[:print:]]" do
  "\u{2060}".match(/[[:print:]]/).to_a.should == ["\u{2060}"]
end

it "match Unicode private-use characters with [[:print:]]" do
  "\u{E001}".match(/[[:print:]]/).to_a.should == ["\u{E001}"]
end


it "doesn't match Unicode lowercase letter characters with [[:punct:]]" do
  "\u{FF41}".match(/[[:punct:]]/).should be_nil
  "\u{1D484}".match(/[[:punct:]]/).should be_nil
  "\u{E8}".match(/[[:punct:]]/).should be_nil
end

it "doesn't match Unicode uppercase letter characters with [[:punct:]]" do
  "\u{100}".match(/[[:punct:]]/).should be_nil
  "\u{130}".match(/[[:punct:]]/).should be_nil
  "\u{405}".match(/[[:punct:]]/).should be_nil
end

it "doesn't match Unicode title-case characters with [[:punct:]]" do
  "\u{1F88}".match(/[[:punct:]]/).should be_nil
  "\u{1FAD}".match(/[[:punct:]]/).should be_nil
  "\u{01C5}".match(/[[:punct:]]/).should be_nil
end

it "doesn't match Unicode digits with [[:punct:]]" do
  "\u{0660}".match(/[[:punct:]]/).should be_nil
  "\u{FF12}".match(/[[:punct:]]/).should be_nil
end

it "doesn't match Unicode marks with [[:punct:]]" do
  "\u{36F}".match(/[[:punct:]]/).should be_nil
end

it "matches Unicode Pc characters with [[:punct:]]" do
  "\u{203F}".match(/[[:punct:]]/).to_a.should == ["\u{203F}"]
end

it "matches Unicode Pd characters with [[:punct:]]" do
  "\u{2E17}".match(/[[:punct:]]/).to_a.should == ["\u{2E17}"]
end

it "matches Unicode Ps characters with [[:punct:]]" do
  "\u{0F3A}".match(/[[:punct:]]/).to_a.should == ["\u{0F3A}"]
end

it "matches Unicode Pe characters with [[:punct:]]" do
  "\u{2046}".match(/[[:punct:]]/).to_a.should == ["\u{2046}"]
end

it "matches Unicode Pi characters with [[:punct:]]" do
  "\u{00AB}".match(/[[:punct:]]/).to_a.should == ["\u{00AB}"]
end

it "matches Unicode Pf characters with [[:punct:]]" do
  "\u{201D}".match(/[[:punct:]]/).to_a.should == ["\u{201D}"]
end

it "matches Unicode Pf characters with [[:punct:]]" do
  "\u{00BB}".match(/[[:punct:]]/).to_a.should == ["\u{00BB}"]
end

it "matches Unicode Po characters with [[:punct:]]" do
  "\u{00BF}".match(/[[:punct:]]/).to_a.should == ["\u{00BF}"]
end

it "doesn't match Unicode format characters with [[:punct:]]" do
  "\u{2060}".match(/[[:punct:]]/).should be_nil
end

it "doesn't match Unicode private-use characters with [[:punct:]]" do
  "\u{E001}".match(/[[:punct:]]/).should be_nil
end

it "doesn't match Unicode lowercase letter characters with [[:space:]]" do
  "\u{FF41}".match(/[[:space:]]/).should be_nil
  "\u{1D484}".match(/[[:space:]]/).should be_nil
  "\u{E8}".match(/[[:space:]]/).should be_nil
end

it "doesn't match Unicode uppercase letter characters with [[:space:]]" do
  "\u{100}".match(/[[:space:]]/).should be_nil
  "\u{130}".match(/[[:space:]]/).should be_nil
  "\u{405}".match(/[[:space:]]/).should be_nil
end

it "doesn't match Unicode title-case characters with [[:space:]]" do
  "\u{1F88}".match(/[[:space:]]/).should be_nil
  "\u{1FAD}".match(/[[:space:]]/).should be_nil
  "\u{01C5}".match(/[[:space:]]/).should be_nil
end

it "doesn't match Unicode digits with [[:space:]]" do
  "\u{0660}".match(/[[:space:]]/).should be_nil
  "\u{FF12}".match(/[[:space:]]/).should be_nil
end

it "doesn't match Unicode marks with [[:space:]]" do
  "\u{36F}".match(/[[:space:]]/).should be_nil
end

it "matches Unicode Zs characters with [[:space:]]" do
  "\u{205F}".match(/[[:space:]]/).to_a.should == ["\u{205F}"]
end

it "matches Unicode Zl characters with [[:space:]]" do
  "\u{2028}".match(/[[:space:]]/).to_a.should == ["\u{2028}"]
end

it "matches Unicode Zp characters with [[:space:]]" do
  "\u{2029}".match(/[[:space:]]/).to_a.should == ["\u{2029}"]
end

it "doesn't match Unicode format characters with [[:space:]]" do
  "\u{2060}".match(/[[:space:]]/).should be_nil
end

it "doesn't match Unicode private-use characters with [[:space:]]" do
  "\u{E001}".match(/[[:space:]]/).should be_nil
end

it "doesn't match Unicode lowercase characters with [[:upper:]]" do
  "\u{FF41}".match(/[[:upper:]]/).should be_nil
  "\u{1D484}".match(/[[:upper:]]/).should be_nil
  "\u{E8}".match(/[[:upper:]]/).should be_nil
end

it "matches Unicode uppercase characters with [[:upper:]]" do
  "\u{100}".match(/[[:upper:]]/).to_a.should == ["\u{100}"]
  "\u{130}".match(/[[:upper:]]/).to_a.should == ["\u{130}"]
  "\u{405}".match(/[[:upper:]]/).to_a.should == ["\u{405}"]
end

it "doesn't match Unicode title-case characters with [[:upper:]]" do
  "\u{1F88}".match(/[[:upper:]]/).should be_nil
  "\u{1FAD}".match(/[[:upper:]]/).should be_nil
  "\u{01C5}".match(/[[:upper:]]/).should be_nil
end

it "doesn't match Unicode digits with [[:upper:]]" do
  "\u{0660}".match(/[[:upper:]]/).should be_nil
  "\u{FF12}".match(/[[:upper:]]/).should be_nil
end

it "doesn't match Unicode marks with [[:upper:]]" do
  "\u{36F}".match(/[[:upper:]]/).should be_nil
end

it "doesn't match Unicode punctuation characters with [[:upper:]]" do
  "\u{3F}".match(/[[:upper:]]/).should be_nil
end

it "doesn't match Unicode control characters with [[:upper:]]" do
  "\u{16}".match(/[[:upper:]]/).should be_nil
end

it "doesn't match Unicode format characters with [[:upper:]]" do
  "\u{2060}".match(/[[:upper:]]/).should be_nil
end

it "doesn't match Unicode private-use characters with [[:upper:]]" do
  "\u{E001}".match(/[[:upper:]]/).should be_nil
end

it "doesn't match Unicode letter characters [^a-fA-F] with [[:xdigit:]]" do
  "à".match(/[[:xdigit:]]/).should be_nil
  "g".match(/[[:xdigit:]]/).should be_nil
  "X".match(/[[:xdigit:]]/).should be_nil
end

it "matches Unicode letter characters [a-fA-F] with [[:xdigit:]]" do
  "a".match(/[[:xdigit:]]/).to_a.should == ["a"]
  "F".match(/[[:xdigit:]]/).to_a.should == ["F"]
end

it "doesn't match Unicode digits [^0-9] with [[:xdigit:]]" do
  "\u{0660}".match(/[[:xdigit:]]/).should be_nil
  "\u{FF12}".match(/[[:xdigit:]]/).should be_nil
end

it "doesn't match Unicode marks with [[:xdigit:]]" do
  "\u{36F}".match(/[[:xdigit:]]/).should be_nil
end

it "doesn't match Unicode punctuation characters with [[:xdigit:]]" do
  "\u{3F}".match(/[[:xdigit:]]/).should be_nil
end

it "doesn't match Unicode control characters with [[:xdigit:]]" do
  "\u{16}".match(/[[:xdigit:]]/).should be_nil
end

it "doesn't match Unicode format characters with [[:xdigit:]]" do
  "\u{2060}".match(/[[:xdigit:]]/).should be_nil
end

it "doesn't match Unicode private-use characters with [[:xdigit:]]" do
  "\u{E001}".match(/[[:xdigit:]]/).should be_nil
end

it "matches Unicode lowercase characters with [[:word:]]" do
  "\u{FF41}".match(/[[:word:]]/).to_a.should == ["\u{FF41}"]
  "\u{1D484}".match(/[[:word:]]/).to_a.should == ["\u{1D484}"]
  "\u{E8}".match(/[[:word:]]/).to_a.should == ["\u{E8}"]
end

it "matches Unicode uppercase characters with [[:word:]]" do
  "\u{100}".match(/[[:word:]]/).to_a.should == ["\u{100}"]
  "\u{130}".match(/[[:word:]]/).to_a.should == ["\u{130}"]
  "\u{405}".match(/[[:word:]]/).to_a.should == ["\u{405}"]
end

it "matches Unicode title-case characters with [[:word:]]" do
  "\u{1F88}".match(/[[:word:]]/).to_a.should == ["\u{1F88}"]
  "\u{1FAD}".match(/[[:word:]]/).to_a.should == ["\u{1FAD}"]
  "\u{01C5}".match(/[[:word:]]/).to_a.should == ["\u{01C5}"]
end

it "matches Unicode decimal digits with [[:word:]]" do
  "\u{FF10}".match(/[[:word:]]/).to_a.should == ["\u{FF10}"]
  "\u{096C}".match(/[[:word:]]/).to_a.should == ["\u{096C}"]
end

it "matches Unicode marks with [[:word:]]" do
  "\u{36F}".match(/[[:word:]]/).to_a.should == ["\u{36F}"]
end

it "match Unicode Nl characters with [[:word:]]" do
  "\u{16EE}".match(/[[:word:]]/).to_a.should == ["\u{16EE}"]
end

it "doesn't match Unicode No characters with [[:word:]]" do
  "\u{17F0}".match(/[[:word:]]/).should be_nil
end
it "doesn't match Unicode punctuation characters with [[:word:]]" do
  "\u{3F}".match(/[[:word:]]/).should be_nil
end

it "doesn't match Unicode control characters with [[:word:]]" do
  "\u{16}".match(/[[:word:]]/).should be_nil
end

it "doesn't match Unicode format characters with [[:word:]]" do
  "\u{2060}".match(/[[:word:]]/).should be_nil
end

it "doesn't match Unicode private-use characters with [[:word:]]" do
  "\u{E001}".match(/[[:word:]]/).should be_nil
end