1 // Copyright (C) 2015 André Bargull. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
5 description: B.1.4 is not applied for Unicode RegExp - Identity escape with basic latin characters
7 The compatibility extensions defined in B.1.4 Regular Expressions Patterns
8 are not applied for Unicode RegExps.
9 Tested extension: "IdentityEscape[U] :: [~U] SourceCharacter but not c"
13 function isSyntaxCharacter(c) {
35 function isAlphaDigit(c) {
36 return ("0" <= c && c <= "9") || ("A" <= c && c <= "Z") || ("a" <= c && c <= "z");
40 // IdentityEscape in AtomEscape.
42 // AtomEscape[U] :: CharacterEscape[?U]
43 // CharacterEscape[U] :: IdentityEscape[?U]
44 for (var cu = 0x00; cu <= 0x7f; ++cu) {
45 var s = String.fromCharCode(cu);
46 if (!isAlphaDigit(s) && !isSyntaxCharacter(s) && s !== "/") {
47 assert.throws(SyntaxError, function() {
48 RegExp("\\" + s, "u");
49 }, "Invalid IdentityEscape in AtomEscape: '\\" + s + "'");
54 // IdentityEscape in ClassEscape.
56 // ClassEscape[U] :: CharacterEscape[?U]
57 // CharacterEscape[U] :: IdentityEscape[?U]
58 for (var cu = 0x00; cu <= 0x7f; ++cu) {
59 var s = String.fromCharCode(cu);
60 if (!isAlphaDigit(s) && !isSyntaxCharacter(s) && s !== "/" && s !== "-") {
61 assert.throws(SyntaxError, function() {
62 RegExp("[\\" + s + "]", "u");
63 }, "Invalid IdentityEscape in ClassEscape: '\\" + s + "'");