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
|
( function ( mw, $ ) {
QUnit.module( 'mediawiki.RegExp' );
QUnit.test( 'escape', 16, function ( assert ) {
var specials, normal;
specials = [
'\\',
'{',
'}',
'(',
')',
'[',
']',
'|',
'.',
'?',
'*',
'+',
'-',
'^',
'$'
];
normal = [
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'abcdefghijklmnopqrstuvwxyz',
'0123456789'
].join( '' );
$.each( specials, function ( i, str ) {
assert.propEqual( str.match( new RegExp( mw.RegExp.escape( str ) ) ), [ str ], 'Match ' + str );
} );
assert.equal( mw.RegExp.escape( normal ), normal, 'Alphanumerals are left alone' );
} );
}( mediaWiki, jQuery ) );
|