Merge pull request #393 from anba/non-browser

Improve compatibility for engines without support for Annex B and non-standard features
This commit is contained in:
Rick Waldron 2015-09-07 15:32:03 -04:00
commit 5ddb903e98
41 changed files with 235 additions and 207 deletions

View File

@ -4,6 +4,7 @@
/*---
info: "CharacterEscape :: c ControlLetter"
es5id: 15.10.2.10_A2.1_T3
es6id: B.1.4
description: "ControlLetter :: RUSSIAN ALPHABET is incorrect"
---*/

View File

@ -7,6 +7,7 @@ info: >
evaluates by evaluating ClassRanges to obtain a CharSet and returning
that CharSet and the boolean false
es5id: 15.10.2.13_A1_T16
es6id: B.1.4
description: >
Execute /[\d][\12-\14]{1,}[^\d]/.exec("line1\n\n\n\n\nline2") and
check results

View File

@ -7,6 +7,7 @@ info: >
matches the result of the nth set of capturing parentheses (see
15.10.2.11)
es5id: 15.10.2.9_A1_T4
es6id: B.1.4
description: >
Execute /\b(\w+) \2\b/.test("do you listen the the band") and
check results

View File

@ -0,0 +1,29 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
RegularExpressionFirstChar :: BackslashSequence :: \NonTerminator,
RegularExpressionChars :: [empty], RegularExpressionFlags :: [empty]
es5id: 7.8.5_A1.4_T2
es6id: 11.8.5
description: Complex test with eval, using syntax pattern
---*/
for (var cu = 0; cu <= 0xffff; ++cu) {
var Elimination =
((cu === 0x002A) || (cu === 0x002F) || (cu === 0x005C) || (cu === 0x002B) ||
(cu === 0x003F) || (cu === 0x0028) || (cu === 0x0029) ||
(cu === 0x005B) || (cu === 0x005D) || (cu === 0x007B) || (cu === 0x007D));
/*
* \u002A / \u002F \ \u005C + \u002B
? \u003F ( \u0028 ) \u0029
[ \u005B ] \u005D { \u007B } \u007D
*/
var LineTerminator = ((cu === 0x000A) || (cu === 0x000D) || (cu === 0x2028) || (cu === 0x2029));
if ((Elimination || LineTerminator ) === false) {
var xx = "\\" + String.fromCharCode(cu);
var pattern = eval("/" + xx + "/");
assert.sameValue(pattern.source, xx, "Code unit: " + cu.toString(16));
}
}

View File

@ -0,0 +1,14 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
RegularExpressionFirstChar :: BackslashSequence :: \NonTerminator,
RegularExpressionChars :: [empty], RegularExpressionFlags :: [empty]
es5id: 7.8.5_A1.4_T1
es6id: 11.8.5
description: Check similar to (/\1/.source === "\\1")
---*/
assert.sameValue(/\1/.source, "\\1");
assert.sameValue(/\a/.source, "\\a");

View File

@ -0,0 +1,29 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
RegularExpressionChar :: BackslashSequence :: \NonTerminator,
RegularExpressionFlags :: [empty]
es5id: 7.8.5_A2.4_T2
es6id: 11.8.5
description: Complex test with eval, using syntax pattern
---*/
for (var cu = 0; cu <= 0xffff; ++cu) {
var Elimination =
((cu === 0x002A) || (cu === 0x002F) || (cu === 0x005C) || (cu === 0x002B) ||
(cu === 0x003F) || (cu === 0x0028) || (cu === 0x0029) ||
(cu === 0x005B) || (cu === 0x005D) || (cu === 0x007B) || (cu === 0x007D));
/*
* \u002A / \u002F \ \u005C + \u002B
? \u003F ( \u0028 ) \u0029
[ \u005B ] \u005D { \u007B } \u007D
*/
var LineTerminator = ((cu === 0x000A) || (cu === 0x000D) || (cu === 0x2028) || (cu === 0x2029));
if ((Elimination || LineTerminator ) === false) {
var xx = "a\\" + String.fromCharCode(cu);
var pattern = eval("/" + xx + "/");
assert.sameValue(pattern.source, xx, "Code unit: " + cu.toString(16));
}
}

View File

@ -0,0 +1,14 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
RegularExpressionChar :: BackslashSequence :: \NonTerminator,
RegularExpressionFlags :: [empty]
es5id: 7.8.5_A2.4_T1
es6id: 11.8.5
description: Check similar to (/a\1/.source === "a\\1")
---*/
assert.sameValue(/a\1/.source, "a\\1");
assert.sameValue(/a\a/.source, "a\\a");

View File

@ -3,10 +3,10 @@
/*---
es5id: 12.14-2
es6id: B.3.5
description: >
catch doesn't change declaration scope - var initializer in catch
with same name as catch parameter changes parameter
features: [AnnexB]
---*/
function capturedFoo() {return foo};

View File

@ -3,10 +3,10 @@
/*---
es5id: 12.14-1
es6id: B.3.5
description: >
catch doesn't change declaration scope - var initializer in catch
with same name as catch parameter changes parameter
features: [AnnexB]
---*/
foo = "prior to throw";

View File

@ -7,6 +7,7 @@ description: >
Strict mode - checking access to non-strict function caller from
non-strict function (eval includes strict directive prologue)
flags: [noStrict]
features: [caller]
---*/
eval("\"use strict\";\ngNonStrict();");

View File

@ -8,6 +8,7 @@ description: >
non-strict function (indirect eval includes strict directive
prologue)
flags: [noStrict]
features: [caller]
---*/
var my_eval = eval;

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict function declaration)
flags: [noStrict]
features: [caller]
---*/
function f() { return gNonStrict();};

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict eval)
flags: [noStrict]
features: [caller]
---*/
function f() { return gNonStrict();};

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict Function constructor)
flags: [noStrict]
features: [caller]
---*/
function f() {return gNonStrict();};

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict new'ed Function constructor)
flags: [noStrict]
features: [caller]
---*/
function f() { return gNonStrict();};

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict Function.prototype.apply())
flags: [noStrict]
features: [caller]
---*/
function f() { return gNonStrict();};

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict Function.prototype.apply(null))
flags: [noStrict]
features: [caller]
---*/
function f() { return gNonStrict();};

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict Function.prototype.apply(undefined))
flags: [noStrict]
features: [caller]
---*/
function f() { return gNonStrict();};

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict Function.prototype.apply(someObject))
flags: [noStrict]
features: [caller]
---*/
function f() { return gNonStrict();};

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict Function.prototype.apply(globalObject))
flags: [noStrict]
features: [caller]
includes: [fnGlobalObject.js]
---*/

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict Function.prototype.call())
flags: [noStrict]
features: [caller]
---*/
function f() { return gNonStrict();};

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict Function.prototype.call(null))
flags: [noStrict]
features: [caller]
---*/
function f() { return gNonStrict();};

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict Function.prototype.call(undefined))
flags: [noStrict]
features: [caller]
---*/
function f() { return gNonStrict();};

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict Function.prototype.call(someObject))
flags: [noStrict]
features: [caller]
---*/
function f() { return gNonStrict();};

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict Function.prototype.call(globalObject))
flags: [noStrict]
features: [caller]
includes: [fnGlobalObject.js]
---*/

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict Function.prototype.bind()())
flags: [noStrict]
features: [caller]
---*/
function f() { return gNonStrict();};

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict Function.prototype.bind(null)())
flags: [noStrict]
features: [caller]
---*/
function f() { return gNonStrict();};

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict Function.prototype.bind(undefined)())
flags: [noStrict]
features: [caller]
---*/
function f() { return gNonStrict();};

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict Function.prototype.bind(someObject)())
flags: [noStrict]
features: [caller]
---*/
function f() { return gNonStrict();};

View File

@ -8,6 +8,7 @@ description: >
non-strict function (non-strict function declaration called by
strict Function.prototype.bind(globalObject)())
flags: [noStrict]
features: [caller]
includes: [fnGlobalObject.js]
---*/

View File

@ -11,12 +11,8 @@ description: "Tested string is \"~`!@#$%^&*()-+={[}]|\\\\:;'<,>./?\" + '\"'"
//CHECK#1
var non_ident = "~`!@#$%^&*()-+={[}]|\\:;'<,>./?" + '"';
var k = -1;
do {
k++;
var arr = new RegExp("\\" + non_ident[k], "g").exec(non_ident);
} while ((arr !== null) && (arr[0] === non_ident[k]))
if (non_ident.length !== k) {
$ERROR('#1: IdentityEscapeSequence :: SourceCharacter but not IdentifierPart');
for (var k = 0; k < non_ident.length; ++k) {
var arr = new RegExp("\\" + non_ident[k], "g").exec(non_ident);
assert.notSameValue(null, "No match for character: " + non_ident[k]);
assert.sameValue(arr[0], non_ident[k]);
}

View File

@ -7,13 +7,34 @@ info: >
AssertionTester closure that takes a State argument x and performs the ...
es5id: 15.10.2.6_A4_T7
description: >
Execute /\B\[^z]{4}\B/.test("devil arise\tforzzx\nevils") and
Execute /\B[^z]{4}\B/.exec("devil arise\tforzzx\nevils") and
check results
---*/
var __executed = /\B\[^z]{4}\B/.test("devil arise\tforzzx\nevils");
var __executed = /\B[^z]{4}\B/.exec("devil arise\tforzzx\nevils");
var __expected = ["il a"];
__expected.index = 3;
__expected.input = "devil arise\tforzzx\nevils";
//CHECK#1
if (__executed) {
$ERROR('#1: /\\B\\[^z]{4}\\B/.test("devil arise\\tforzzx\\nevils") === false');
if (__executed.length !== __expected.length) {
$ERROR('#1: __executed = /\B[^z]{4}\B/.exec("devil arise\\tforzzx\\nevils"); __executed.length === ' + __expected.length + '. Actual: ' + __executed.length);
}
//CHECK#2
if (__executed.index !== __expected.index) {
$ERROR('#2: __executed = /\B[^z]{4}\B/.exec("devil arise\\tforzzx\\nevils"); __executed.index === ' + __expected.index + '. Actual: ' + __executed.index);
}
//CHECK#3
if (__executed.input !== __expected.input) {
$ERROR('#3: __executed = /\B[^z]{4}\B/.exec("devil arise\\tforzzx\\nevils"); __executed.input === ' + __expected.input + '. Actual: ' + __executed.input);
}
//CHECK#4
for(var index=0; index<__expected.length; index++) {
if (__executed[index] !== __expected[index]) {
$ERROR('#4: __executed = /\B[^z]{4}\B/.exec("devil arise\\tforzzx\\nevils"); __executed[' + index + '] === ' + __expected[index] + '. Actual: ' + __executed[index]);
}
}

View File

@ -20,20 +20,20 @@ var TextSE = "[^<]+";
var UntilHyphen = "[^-]*-";
var Until2Hyphens = UntilHyphen + "([^-]" + UntilHyphen + ")*-";
var CommentCE = Until2Hyphens + ">?";
var UntilRSBs = "[^]]*]([^]]+])*]+";
var CDATA_CE = UntilRSBs + "([^]>]" + UntilRSBs + ")*>";
var UntilRSBs = "[^\\]]*\\]([^\\]]+\\])*\\]+";
var CDATA_CE = UntilRSBs + "([^\\]>]" + UntilRSBs + ")*>";
var S = "[ \\n\\t\\r]+";
var NameStrt = "[A-Za-z_:]|[^\\x00-\\x7F]";
var NameChar = "[A-Za-z0-9_:.-]|[^\\x00-\\x7F]";
var Name = "(" + NameStrt + ")(" + NameChar + ")*";
var QuoteSE = '"[^"]' + "*" + '"' + "|'[^']*'";
var DT_IdentSE = S + Name + "(" + S + "(" + Name + "|" + QuoteSE + "))*";
var MarkupDeclCE = "([^]\"'><]+|" + QuoteSE + ")*>";
var MarkupDeclCE = "([^\\]\"'><]+|" + QuoteSE + ")*>";
var S1 = "[\\n\\r\\t ]";
var UntilQMs = "[^?]*\\?+";
var PI_Tail = "\\?>|" + S1 + UntilQMs + "([^>?]" + UntilQMs + ")*>";
var DT_ItemSE = "<(!(--" + Until2Hyphens + ">|[^-]" + MarkupDeclCE + ")|\\?" + Name + "(" + PI_Tail + "))|%" + Name + ";|" + S;
var DocTypeCE = DT_IdentSE + "(" + S + ")?(\\[(" + DT_ItemSE + ")*](" + S + ")?)?>?";
var DocTypeCE = DT_IdentSE + "(" + S + ")?(\\[(" + DT_ItemSE + ")*\\](" + S + ")?)?>?";
var DeclCE = "--(" + CommentCE + ")?|\\[CDATA\\[(" + CDATA_CE + ")?|DOCTYPE(" + DocTypeCE + ")?";
var PI_CE = Name + "(" + PI_Tail + ")?";
var EndTagCE = Name + "(" + S + ")?>?";

View File

@ -5,6 +5,7 @@
es5id: 10.6-13-a-2
description: A direct call to arguments.callee.caller should work
flags: [noStrict]
features: [caller]
---*/
var called = false;

View File

@ -5,6 +5,7 @@
es5id: 10.6-13-a-3
description: An indirect call to arguments.callee.caller should work
flags: [noStrict]
features: [caller]
---*/
var called = false;

View File

@ -9,46 +9,20 @@ es5id: 7.8.5_A1.1_T2
description: Complex test with eval, using syntax pattern
---*/
//CHECK
var errorCount = 0;
var count = 0;
var hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];
for (var i1 = 0; i1 < 16; i1++) {
for (var i2 = 0; i2 < 16; i2++) {
for (var i3 = 0; i3 < 16; i3++) {
for (var i4 = 0; i4 < 16; i4++) {
try {
var uu = hex[i1] + hex[i2] + hex[i3] + hex[i4];
var Elimination =
((uu === "002A") || (uu === "002F") || (uu === "005C") || (uu === "002B") ||
(uu === "003F") || (uu === "0028") || (uu === "0029") ||
(uu === "005B") || (uu === "005D") || (uu === "007B") || (uu === "007D"));
/*
* \u002A / \u002F \ \u005C + \u002B
? \u003F ( \u0028 ) \u0029
[ \u005B ] \u005D { \u007B } \u007D
*/
var LineTerminator = ((uu === "000A") || (uu === "000D") || (uu === "2028") || (uu === "2029"));
if ((Elimination || LineTerminator ) === false) {
var xx = String.fromCharCode("0x" + uu);
var pattern = eval("/" + xx + "/");
if (pattern.source !== xx) {
$ERROR('#' + uu + ' ');
errorCount++;
}
} else {
count--;
}
} catch (e) {
$ERROR('#' + uu + ' ');
errorCount++;
}
count++;
}
}
for (var cu = 0; cu <= 0xffff; ++cu) {
var Elimination =
((cu === 0x002A) || (cu === 0x002F) || (cu === 0x005C) || (cu === 0x002B) ||
(cu === 0x003F) || (cu === 0x0028) || (cu === 0x0029) ||
(cu === 0x005B) || (cu === 0x005D) || (cu === 0x007B) || (cu === 0x007D));
/*
* \u002A / \u002F \ \u005C + \u002B
? \u003F ( \u0028 ) \u0029
[ \u005B ] \u005D { \u007B } \u007D
*/
var LineTerminator = ((cu === 0x000A) || (cu === 0x000D) || (cu === 0x2028) || (cu === 0x2029));
if ((Elimination || LineTerminator ) === false) {
var xx = String.fromCharCode(cu);
var pattern = eval("/" + xx + "/");
assert.sameValue(pattern.source, xx, "Code unit: " + cu.toString(16));
}
}
if (errorCount > 0) {
$ERROR('Total error: ' + errorCount + ' bad Regular Expression First Char in ' + count);
}

View File

@ -6,25 +6,15 @@ info: >
RegularExpressionFirstChar :: BackslashSequence :: \NonTerminator,
RegularExpressionChars :: [empty], RegularExpressionFlags :: [empty]
es5id: 7.8.5_A1.4_T1
description: Check similar to (/\1/.source === "\\1")
description: Check similar to (/\;/.source === "\\;")
---*/
//CHECK#1
if (/\1/.source !== "\\1") {
$ERROR('#1: /\\1/');
}
if (/\;/.source !== "\\;") {
$ERROR('#1: /\\;/');
}
//CHECK#2
if (/\a/.source !== "\\a") {
$ERROR('#2: /\\a/');
}
//CHECK#3
if (/\;/.source !== "\\;") {
$ERROR('#3: /\\;/');
}
//CHECK#4
if (/\ /.source !== "\\ ") {
$ERROR('#4: /\\ /');
$ERROR('#2: /\\ /');
}

View File

@ -9,46 +9,32 @@ es5id: 7.8.5_A1.4_T2
description: Complex test with eval, using syntax pattern
---*/
//CHECK
var errorCount = 0;
var count = 0;
var hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];
for (var i1 = 0; i1 < 16; i1++) {
for (var i2 = 0; i2 < 16; i2++) {
for (var i3 = 0; i3 < 16; i3++) {
for (var i4 = 0; i4 < 16; i4++) {
for (var cu = 0; cu <= 0xffff; ++cu) {
var Elimination =
((cu === 0x002A) || (cu === 0x002F) || (cu === 0x005C) || (cu === 0x002B) ||
(cu === 0x003F) || (cu === 0x0028) || (cu === 0x0029) ||
(cu === 0x005B) || (cu === 0x005D) || (cu === 0x007B) || (cu === 0x007D));
/*
* \u002A / \u002F \ \u005C + \u002B
? \u003F ( \u0028 ) \u0029
[ \u005B ] \u005D { \u007B } \u007D
*/
var LineTerminator = ((cu === 0x000A) || (cu === 0x000D) || (cu === 0x2028) || (cu === 0x2029));
if ((Elimination || LineTerminator ) === false) {
var xx = "\\" + String.fromCharCode(cu);
try {
var pattern = eval("/" + xx + "/");
} catch (e) {
var identifierPartNotUnicodeIDContinue = ((cu === 0x0024) || (cu === 0x200C) || (cu === 0x200D));
if (e instanceof SyntaxError && !identifierPartNotUnicodeIDContinue) {
// Use eval with var-declaration to check if `cu` is in UnicodeIDContinue.
try {
var uu = hex[i1] + hex[i2] + hex[i3] + hex[i4];
var Elimination =
((uu === "002A") || (uu === "002F") || (uu === "005C") || (uu === "002B") ||
(uu === "003F") || (uu === "0028") || (uu === "0029") ||
(uu === "005B") || (uu === "005D") || (uu === "007B") || (uu === "007D"));
/*
* \u002A / \u002F \ \u005C + \u002B
? \u003F ( \u0028 ) \u0029
[ \u005B ] \u005D { \u007B } \u007D
*/
var LineTerminator = ((uu === "000A") || (uu === "000D") || (uu === "2028") || (uu === "2029"));
if ((Elimination || LineTerminator ) === false) {
var xx = "\\" + String.fromCharCode("0x" + uu);
var pattern = eval("/" + xx + "/");
if (pattern.source !== xx) {
$ERROR('#' + uu + ' ');
errorCount++;
}
} else {
count--;
}
} catch (e) {
$ERROR('#' + uu + ' ');
errorCount++;
}
count++;
eval("var _" + String.fromCharCode(cu));
continue;
} catch (ignore) { }
}
throw e;
}
assert.sameValue(pattern.source, xx, "Code unit: " + cu.toString(16));
}
}
if (errorCount > 0) {
$ERROR('Total error: ' + errorCount + ' bad Regular Expression First Char in ' + count);
}

View File

@ -9,47 +9,20 @@ es5id: 7.8.5_A2.1_T2
description: Complex test with eval, using syntax pattern
---*/
//CHECK
var errorCount = 0;
var count = 0;
var hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];
for (var i1 = 0; i1 < 16; i1++) {
for (var i2 = 0; i2 < 16; i2++) {
for (var i3 = 0; i3 < 16; i3++) {
for (var i4 = 0; i4 < 16; i4++) {
try {
var uu = hex[i1] + hex[i2] + hex[i3] + hex[i4];
var Elimination =
((uu === "002A") || (uu === "002F") || (uu === "005C") || (uu === "002B") ||
(uu === "003F") || (uu === "0028") || (uu === "0029") ||
(uu === "005B") || (uu === "005D") || (uu === "007B") || (uu === "007D"));
/*
* \u002A / \u002F \ \u005C + \u002B
? \u003F ( \u0028 ) \u0029
[ \u005B ] \u005D { \u007B } \u007D
*/
var LineTerminator = ((uu === "000A") || (uu === "000D") || (uu === "2028") || (uu === "2029"));
if ((Elimination || LineTerminator ) === false) {
var xx = "nnnn" + String.fromCharCode("0x" + uu);
var pattern = eval("/" + xx + "/");
if (pattern.source !== xx) {
$ERROR('#' + uu + ' ');
errorCount++;
}
} else {
count--;
}
} catch (e) {
$ERROR('#' + uu + ' ');
errorCount++;
}
count++;
}
}
for (var cu = 0; cu <= 0xffff; ++cu) {
var Elimination =
((cu === 0x002A) || (cu === 0x002F) || (cu === 0x005C) || (cu === 0x002B) ||
(cu === 0x003F) || (cu === 0x0028) || (cu === 0x0029) ||
(cu === 0x005B) || (cu === 0x005D) || (cu === 0x007B) || (cu === 0x007D));
/*
* \u002A / \u002F \ \u005C + \u002B
? \u003F ( \u0028 ) \u0029
[ \u005B ] \u005D { \u007B } \u007D
*/
var LineTerminator = ((cu === 0x000A) || (cu === 0x000D) || (cu === 0x2028) || (cu === 0x2029));
if ((Elimination || LineTerminator ) === false) {
var xx = "nnnn" + String.fromCharCode(cu);
var pattern = eval("/" + xx + "/");
assert.sameValue(pattern.source, xx, "Code unit: " + cu.toString(16));
}
}
if (errorCount > 0) {
$ERROR('Total error: ' + errorCount + ' bad Regular Expression First Char in ' + count);
}

View File

@ -6,25 +6,15 @@ info: >
RegularExpressionChar :: BackslashSequence :: \NonTerminator,
RegularExpressionFlags :: [empty]
es5id: 7.8.5_A2.4_T1
description: Check similar to (/a\1/.source === "a\\1")
description: Check similar to (/,\;/.source === ",\\;")
---*/
//CHECK#1
if (/a\1/.source !== "a\\1") {
$ERROR('#1: /a\\1/');
}
if (/,\;/.source !== ",\\;") {
$ERROR('#1: /,\\;/');
}
//CHECK#2
if (/a\a/.source !== "a\\a") {
$ERROR('#2: /a\\a/');
}
//CHECK#3
if (/,\;/.source !== ",\\;") {
$ERROR('#3: /,\\;/');
}
//CHECK#4
if (/ \ /.source !== " \\ ") {
$ERROR('#4: / \\ /');
$ERROR('#2: / \\ /');
}

View File

@ -9,46 +9,32 @@ es5id: 7.8.5_A2.4_T2
description: Complex test with eval, using syntax pattern
---*/
//CHECK
var errorCount = 0;
var count = 0;
var hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];
for (var i1 = 0; i1 < 16; i1++) {
for (var i2 = 0; i2 < 16; i2++) {
for (var i3 = 0; i3 < 16; i3++) {
for (var i4 = 0; i4 < 16; i4++) {
for (var cu = 0; cu <= 0xffff; ++cu) {
var Elimination =
((cu === 0x002A) || (cu === 0x002F) || (cu === 0x005C) || (cu === 0x002B) ||
(cu === 0x003F) || (cu === 0x0028) || (cu === 0x0029) ||
(cu === 0x005B) || (cu === 0x005D) || (cu === 0x007B) || (cu === 0x007D));
/*
* \u002A / \u002F \ \u005C + \u002B
? \u003F ( \u0028 ) \u0029
[ \u005B ] \u005D { \u007B } \u007D
*/
var LineTerminator = ((cu === 0x000A) || (cu === 0x000D) || (cu === 0x2028) || (cu === 0x2029));
if ((Elimination || LineTerminator ) === false) {
var xx = "a\\" + String.fromCharCode(cu);
try {
var pattern = eval("/" + xx + "/");
} catch (e) {
var identifierPartNotUnicodeIDContinue = ((cu === 0x0024) || (cu === 0x200C) || (cu === 0x200D));
if (e instanceof SyntaxError && !identifierPartNotUnicodeIDContinue) {
// Use eval with var-declaration to check if `cu` is in UnicodeIDContinue.
try {
var uu = hex[i1] + hex[i2] + hex[i3] + hex[i4];
var Elimination =
((uu === "002A") || (uu === "002F") || (uu === "005C") || (uu === "002B") ||
(uu === "003F") || (uu === "0028") || (uu === "0029") ||
(uu === "005B") || (uu === "005D") || (uu === "007B") || (uu === "007D"));
/*
* \u002A / \u002F \ \u005C + \u002B
? \u003F ( \u0028 ) \u0029
[ \u005B ] \u005D { \u007B } \u007D
*/
var LineTerminator = ((uu === "000A") || (uu === "000D") || (uu === "2028") || (uu === "2029"));
if ((Elimination || LineTerminator ) === false) {
var xx = "a\\" + String.fromCharCode("0x" + uu);
var pattern = eval("/" + xx + "/");
if (pattern.source !== xx) {
$ERROR('#' + uu + ' ');
errorCount++;
}
} else {
count--;
}
} catch (e) {
$ERROR('#' + uu + ' ');
errorCount++;
}
count++;
eval("var _" + String.fromCharCode(cu));
continue;
} catch (ignore) { }
}
throw e;
}
assert.sameValue(pattern.source, xx, "Code unit: " + cu.toString(16));
}
}
if (errorCount > 0) {
$ERROR('Total error: ' + errorCount + ' bad Regular Expression First Char in ' + count);
}