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
|
use std
use "testmatch.use"
const main = {
asciiclass()
set()
/*
unicodeclass()
negasciiclass()
negasciirange()
negset()
*/
}
const asciiclass = {
/* \D success */
testmatch("\\D", "x", `std.Some [][:])
testmatch("\\D+", "xa!#^cs", `std.Some [][:])
/* \D fail: end of ranges chars */
testmatch("\\D", "0", `std.None)
testmatch("\\D", "9", `std.None)
testmatch("\\D+", "a35x", `std.None)
testmatch("\\D+", "13688", `std.None)
/* \X success */
testmatch("\\X", "Z", `std.Some [][:])
testmatch("\\X\\X", "gg", `std.Some [][:])
/* \X fail */
testmatch("\\X", "a", `std.None)
testmatch("\\X+", "zz13b8cDEf", `std.None)
/* \S success */
testmatch("\\S", "a", `std.Some [][:])
testmatch("\\S\\S", "i%", `std.Some [][:])
testmatch("\\S+", "alskd690!#!!", `std.Some [][:])
/* \S fail */
testmatch("\\S", " ", `std.None)
testmatch("\\S\\S", "\t\n", `std.None)
testmatch("\\S+", "\t \nkait", `std.None)
/* word success */
testmatch("\\W+", "!%!^^@@!^", `std.Some [][:])
/* word fail */
testmatch("\\W+", "a^#$bcABC0123_", `std.None)
/* \H success */
testmatch("\\H", "\n", `std.Some [][:])
testmatch("\\H\\H", "\n\r", `std.Some [][:])
/* \H fail */
testmatch("\\H+", "\t \t.", `std.None)
testmatch("\\H\\H", "\t ", `std.None)
testmatch("\\H+", "\ta35 \t ", `std.None)
}
const set = {
/* ranges: should succeed */
testmatch("[^a-z]*", "ABCD", `std.Some [][:])
testmatch("[^a-zA-Z]*", "1234", `std.Some [][:])
testmatch("[^a-zA-Z0-9_]*", "-^^-", `std.Some [][:])
testmatch("[^abc]*", "d6d", `std.Some [][:])
testmatch("[^a-zABC]*", "!^!!))#", `std.Some [][:])
/* ranges: should fail */
testmatch("[^a-z]*", "abcd", `std.None)
testmatch("[^a-zA-Z]*", "abCD", `std.None)
testmatch("[^a-zA-Z0-9_]*", "_abCD018", `std.None)
testmatch("[^abc]*", "abba", `std.None)
testmatch("[^a-zABC]*", "abBa", `std.None)
}
|