-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathunicodejs.characterclass.test.js
54 lines (49 loc) · 1.36 KB
/
unicodejs.characterclass.test.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
/*!
* UnicodeJS character class module tests
*
* @copyright 2015 UnicodeJS team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
QUnit.module( 'unicodeJS.characterclass' );
QUnit.test( 'patterns', ( assert ) => {
// eslint-disable-next-line security/detect-non-literal-regexp
var wordGlobalRegex = new RegExp( unicodeJS.characterclass.patterns.word, 'g' );
var wordChars = [
// Basic Latin letter
'a',
// Basic Latin number
'1',
// Underscore (Punctuation, connector)
'_',
// Latin-1 Supplement letter
'é',
// Latin Extended-A letter
'ŵ',
// Mark (combining accent)
'x', '\u0301',
// Han character
'中',
// Full-width punctuation connector
'︴',
// SMP Han character U+282E2
'𨋢',
// Combining mark and ZWNJ
'क', '\u094d', '\u200C', 'ष',
// SMP math letter U+1D538
'𝔸'
];
var nonWordChars = [
// Basic Latin punctuation
'$', '-', '.', '!', ' ', '"', '\'', '(', ')', '[', ']', '{', '}',
// Other punctuation
'“', '”', '‘', '’', '「', '」',
// Space
' ', '\r', '\n', '\t', '\u3000',
// Non-Basic-Latin digit U+0668 and U+1D7E0
'٨',
// SMP emoticon U+1F607 and digit U+1D7E0
'😇', '𝟠'
];
assert.deepEqual( wordChars.join( '' ).match( wordGlobalRegex ), wordChars );
assert.strictEqual( nonWordChars.join( '' ).match( wordGlobalRegex ), null );
} );