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 letters
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"
11 Forbidden extension (16.1):
12 The RegExp pattern grammars in 21.2.1 and B.1.4 must not be extended to recognize any of the
13 source characters A-Z or a-z as IdentityEscape[U] when the U grammar parameter is present.
17 function isValidAlphaEscapeInAtom(s) {
19 // Assertion [U] :: \b
21 // Assertion [U] :: \B
23 // ControlEscape :: one of f n r t v
29 // CharacterClassEscape :: one of d D s S w W
42 function isValidAlphaEscapeInClass(s) {
44 // ClassEscape[U] :: b
46 // ControlEscape :: one of f n r t v
52 // CharacterClassEscape :: one of d D s S w W
65 // IdentityEscape in AtomEscape
66 for (var cu = 0x41 /* A */; cu <= 0x5a /* Z */; ++cu) {
67 var s = String.fromCharCode(cu);
68 if (!isValidAlphaEscapeInAtom(s)) {
69 assert.throws(SyntaxError, function() {
70 RegExp("\\" + s, "u");
71 }, "IdentityEscape in AtomEscape: '" + s + "'");
74 for (var cu = 0x61 /* a */; cu <= 0x7a /* z */; ++cu) {
75 var s = String.fromCharCode(cu);
76 if (!isValidAlphaEscapeInAtom(s)) {
77 assert.throws(SyntaxError, function() {
78 RegExp("\\" + s, "u");
79 }, "IdentityEscape in AtomEscape: '" + s + "'");
84 // IdentityEscape in ClassEscape
85 for (var cu = 0x41 /* A */; cu <= 0x5a /* Z */; ++cu) {
86 var s = String.fromCharCode(cu);
87 if (!isValidAlphaEscapeInClass(s)) {
88 assert.throws(SyntaxError, function() {
89 RegExp("[\\" + s + "]", "u");
90 }, "IdentityEscape in ClassEscape: '" + s + "'");
93 for (var cu = 0x61 /* a */; cu <= 0x7a /* z */; ++cu) {
94 var s = String.fromCharCode(cu);
95 if (!isValidAlphaEscapeInClass(s)) {
96 assert.throws(SyntaxError, function() {
97 RegExp("[\\" + s + "]", "u");
98 }, "IdentityEscape in ClassEscape: '" + s + "'");