2 * Check that builtin character classes within ranges produce syntax
5 * Note that, per the extension in bug 351463, SpiderMonkey permits hyphens
6 * adjacent to character class escapes in character classes, treating them as a
7 * hyphen pattern character. Therefore /[\d-\s]/ is okay
9 * Note: /\b/ is the backspace escape, which is a single pattern character,
10 * though it looks deceptively like a character class.
13 function isRegExpSyntaxError(pattern) {
15 var re = new RegExp(pattern);
17 if (e instanceof SyntaxError)
23 assertEq(isRegExpSyntaxError('[C-\\s]'), true);
24 assertEq(isRegExpSyntaxError('[C-\\d]'), true);
25 assertEq(isRegExpSyntaxError('[C-\\W]'), true);
26 assertEq(isRegExpSyntaxError('[C-]'), false);
27 assertEq(isRegExpSyntaxError('[-C]'), false);
28 assertEq(isRegExpSyntaxError('[C-C]'), false);
29 assertEq(isRegExpSyntaxError('[C-C]'), false);
30 assertEq(isRegExpSyntaxError('[\\b-\\b]'), false);
31 assertEq(isRegExpSyntaxError('[\\B-\\B]'), false);
32 assertEq(isRegExpSyntaxError('[\\b-\\B]'), false);
33 assertEq(isRegExpSyntaxError('[\\B-\\b]'), true);
34 assertEq(isRegExpSyntaxError('[\\b-\\w]'), true);
35 assertEq(isRegExpSyntaxError('[\\B-\\w]'), true);
38 assertEq(isRegExpSyntaxError('[\\s-\\s]'), false);
39 assertEq(isRegExpSyntaxError('[\\W-\\s]'), false);
40 assertEq(isRegExpSyntaxError('[\\s-\\W]'), false);
41 assertEq(isRegExpSyntaxError('[\\W-C]'), false);
42 assertEq(isRegExpSyntaxError('[\\d-C]'), false);
43 assertEq(isRegExpSyntaxError('[\\s-C]'), false);
44 assertEq(isRegExpSyntaxError('[\\w-\\b]'), false);
45 assertEq(isRegExpSyntaxError('[\\w-\\B]'), false);