/
regex-unicode-CaseInsensitive.js
78 lines (66 loc) · 3.05 KB
/
regex-unicode-CaseInsensitive.js
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
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
function assertMatches(re, codepoint, str) {
let passed = re.test(str);
if (!passed) {
console.log("FAILED -- regex: " + re.toString() + " should match codepoint: " + codepoint.toString(16));
}
}
function assertDoesNotMatch(re, codepoint, str) {
let passed = re.test(str);
if (passed) {
console.log("FAILED -- regex: " + re.toString() + " should not match codepoint: " + codepoint.toString(16));
}
}
// Detect regressions in the CaseInsensitive table
// 01BA != 01BB under /i.
assertDoesNotMatch(/\u{01ba}/iu, 0x01bb, "\u01bb");
assertDoesNotMatch(/\u{01bb}/iu, 0x01ba, "\u01ba");
// 01F0 doesn't match anything
assertDoesNotMatch(/\u{01f0}/iu, 0x01f1, "\u01f1");
assertDoesNotMatch(/\u{01f1}/iu, 0x01f0, "\u01f0");
// 01F4-5 match (G with ACUTE)
assertMatches(/\u{01f4}/iu, 0x01f5, "\u01f5");
assertMatches(/\u{01f5}/iu, 0x01f4, "\u01f4");
//
// Latin ligature triples DZ WITH CARON, LJ, NJ (01C4-01CC); DZ (01F1-3)
//
assertMatches(/\u{01c4}/iu, 0x01c4, '\u{01c4}');
assertMatches(/\u{01c4}/iu, 0x01c5, '\u{01c5}');
assertMatches(/\u{01c4}/iu, 0x01c6, '\u{01c6}');
assertMatches(/\u{01c5}/iu, 0x01c4, '\u{01c4}');
assertMatches(/\u{01c5}/iu, 0x01c5, '\u{01c5}');
assertMatches(/\u{01c5}/iu, 0x01c6, '\u{01c6}');
assertMatches(/\u{01c6}/iu, 0x01c4, '\u{01c4}');
assertMatches(/\u{01c6}/iu, 0x01c5, '\u{01c5}');
assertMatches(/\u{01c6}/iu, 0x01c6, '\u{01c6}');
assertMatches(/\u{01c7}/iu, 0x01c7, '\u{01c7}');
assertMatches(/\u{01c7}/iu, 0x01c8, '\u{01c8}');
assertMatches(/\u{01c7}/iu, 0x01c9, '\u{01c9}');
assertMatches(/\u{01c9}/iu, 0x01c7, '\u{01c7}');
assertMatches(/\u{01c9}/iu, 0x01c8, '\u{01c8}');
assertMatches(/\u{01c9}/iu, 0x01c9, '\u{01c9}');
assertMatches(/\u{01c8}/iu, 0x01c7, '\u{01c7}');
assertMatches(/\u{01c8}/iu, 0x01c8, '\u{01c8}');
assertMatches(/\u{01c8}/iu, 0x01c9, '\u{01c9}');
assertMatches(/\u{01ca}/iu, 0x01ca, '\u{01ca}');
assertMatches(/\u{01ca}/iu, 0x01cb, '\u{01cb}');
assertMatches(/\u{01ca}/iu, 0x01cc, '\u{01cc}');
assertMatches(/\u{01cb}/iu, 0x01ca, '\u{01ca}');
assertMatches(/\u{01cb}/iu, 0x01cb, '\u{01cb}');
assertMatches(/\u{01cb}/iu, 0x01cc, '\u{01cc}');
assertMatches(/\u{01cc}/iu, 0x01ca, '\u{01ca}');
assertMatches(/\u{01cc}/iu, 0x01cb, '\u{01cb}');
assertMatches(/\u{01cc}/iu, 0x01cc, '\u{01cc}');
assertMatches(/\u{01f1}/iu, 0x01f1, '\u{01f1}');
assertMatches(/\u{01f1}/iu, 0x01f2, '\u{01f2}');
assertMatches(/\u{01f1}/iu, 0x01f3, '\u{01f3}');
assertMatches(/\u{01f2}/iu, 0x01f2, '\u{01f2}');
assertMatches(/\u{01f2}/iu, 0x01f1, '\u{01f1}');
assertMatches(/\u{01f2}/iu, 0x01f3, '\u{01f3}');
assertMatches(/\u{01f3}/iu, 0x01f1, '\u{01f1}');
assertMatches(/\u{01f3}/iu, 0x01f2, '\u{01f2}');
assertMatches(/\u{01f3}/iu, 0x01f3, '\u{01f3}');
console.log("PASS");