built-ins/Array/*: make all indentation consistent (depth & character) (#1415)

This commit is contained in:
Rick Waldron 2018-02-15 17:40:02 -05:00 committed by Leo Balter
parent 0bf08dff3d
commit afa24856b4
2146 changed files with 21758 additions and 18321 deletions

View File

@ -6,7 +6,7 @@ es5id: 15.4.5-1
description: Array instances have [[Class]] set to 'Array'
---*/
var a = [];
var s = Object.prototype.toString.call(a);
var a = [];
var s = Object.prototype.toString.call(a);
assert.sameValue(s, '[object Array]', 's');

View File

@ -8,7 +8,7 @@ description: >
element)
---*/
var a =[];
a[4294967295] = "not an array element" ;
var a = [];
a[4294967295] = "not an array element";
assert.sameValue(a[4294967295], "not an array element", 'a[4294967295]');

View File

@ -8,7 +8,7 @@ description: >
length of the array
---*/
var a =[0,1,2];
a[4294967295] = "not an array element" ;
var a = [0, 1, 2];
a[4294967295] = "not an array element";
assert.sameValue(a.length, 3, 'a.length');

View File

@ -12,14 +12,14 @@ description: Array.prototype.toString = Object.prototype.toString
//CHECK#1
Array.prototype.toString = Object.prototype.toString;
var x = Array();
var x = Array();
if (x.toString() !== "[object " + "Array" + "]") {
$ERROR('#1: Array.prototype.toString = Object.prototype.toString; var x = Array(); x.toString() === "[object " + "Array" + "]". Actual: ' + (x.toString()));
}
//CHECK#2
Array.prototype.toString = Object.prototype.toString;
var x = Array(0,1,2);
var x = Array(0, 1, 2);
if (x.toString() !== "[object " + "Array" + "]") {
$ERROR('#2: Array.prototype.toString = Object.prototype.toString; var x = Array(0,1,2); x.toString() === "[object " + "Array" + "]". Actual: ' + (x.toString()));
}

View File

@ -8,14 +8,14 @@ description: Checking use Object.prototype.toString
---*/
//CHECK#1
var x = Array();
var x = Array();
x.getClass = Object.prototype.toString;
if (x.getClass() !== "[object " + "Array" + "]") {
$ERROR('#1: var x = Array(); x.getClass = Object.prototype.toString; x is Array object. Actual: ' + (x.getClass()));
}
//CHECK#2
var x = Array(0,1,2);
var x = Array(0, 1, 2);
x.getClass = Object.prototype.toString;
if (x.getClass() !== "[object " + "Array" + "]") {
$ERROR('#2: var x = Array(0,1,2); x.getClass = Object.prototype.toString; x is Array object. Actual: ' + (x.getClass()));

View File

@ -15,8 +15,8 @@ if (Array().length !== 0) {
}
//CHECK#2
if (Array(0,1,0,1).length !== 4) {
$ERROR('#2: (Array(0,1,0,1).length === 4. Actual: ' + (Array(0,1,0,1).length));
if (Array(0, 1, 0, 1).length !== 4) {
$ERROR('#2: (Array(0,1,0,1).length === 4. Actual: ' + (Array(0, 1, 0, 1).length));
}
//CHECK#3

View File

@ -14,16 +14,16 @@ description: Checking correct work this algorithm
//CHECK#
var x = Array(
0,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,39,
40,41,42,43,44,45,46,47,48,49,
50,51,52,53,54,55,56,57,58,59,
60,61,62,63,64,65,66,67,68,69,
70,71,72,73,74,75,76,77,78,79,
80,81,82,83,84,85,86,87,88,89,
90,91,92,93,94,95,96,97,98,99
0, 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, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99
);
for (var i = 0; i < 100; i++) {

View File

@ -12,7 +12,7 @@ description: Checking use typeof, instanceof
//CHECK#1
if (typeof Array() !== "object") {
$ERROR('#1: typeof Array() === "object". Actual: ' + (typeof Array()));
}
}
//CHECK#2
if ((Array() instanceof Array) !== true) {

View File

@ -14,7 +14,7 @@ description: >
//CHECK#1
Array.prototype.myproperty = 1;
var x = new Array();
var x = new Array();
if (x.myproperty !== 1) {
$ERROR('#1: Array.prototype.myproperty = 1; var x = new Array(); x.myproperty === 1. Actual: ' + (x.myproperty));
}

View File

@ -12,14 +12,14 @@ description: Array.prototype.toString = Object.prototype.toString
//CHECK#1
Array.prototype.toString = Object.prototype.toString;
var x = new Array();
var x = new Array();
if (x.toString() !== "[object " + "Array" + "]") {
$ERROR('#1: Array.prototype.toString = Object.prototype.toString; var x = new Array(); x.toString() === "[object " + "Array" + "]". Actual: ' + (x.toString()));
}
//CHECK#2
Array.prototype.toString = Object.prototype.toString;
var x = new Array(0,1,2);
var x = new Array(0, 1, 2);
if (x.toString() !== "[object " + "Array" + "]") {
$ERROR('#2: Array.prototype.toString = Object.prototype.toString; var x = new Array(0,1,2); x.toString() === "[object " + "Array" + "]". Actual: ' + (x.toString()));
}

View File

@ -8,14 +8,14 @@ description: Checking use Object.prototype.toString
---*/
//CHECK#1
var x = new Array();
var x = new Array();
x.getClass = Object.prototype.toString;
if (x.getClass() !== "[object " + "Array" + "]") {
$ERROR('#1: var x = new Array(); x.getClass = Object.prototype.toString; x is Array object. Actual: ' + (x.getClass()));
}
//CHECK#2
var x = new Array(0,1,2);
var x = new Array(0, 1, 2);
x.getClass = Object.prototype.toString;
if (x.getClass() !== "[object " + "Array" + "]") {
$ERROR('#2: var x = new Array(0,1,2); x.getClass = Object.prototype.toString; x is Array object. Actual: ' + (x.getClass()));

View File

@ -15,8 +15,8 @@ if (new Array().length !== 0) {
}
//CHECK#2
if (new Array(0,1,0,1).length !== 4) {
$ERROR('#2: new Array(0,1,0,1).length === 4. Actual: ' + (new Array(0,1,0,1).length));
if (new Array(0, 1, 0, 1).length !== 4) {
$ERROR('#2: new Array(0,1,0,1).length === 4. Actual: ' + (new Array(0, 1, 0, 1).length));
}
//CHECK#3

View File

@ -14,16 +14,16 @@ description: Checking correct work this algorithm
//CHECK#
var x = new Array(
0,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,39,
40,41,42,43,44,45,46,47,48,49,
50,51,52,53,54,55,56,57,58,59,
60,61,62,63,64,65,66,67,68,69,
70,71,72,73,74,75,76,77,78,79,
80,81,82,83,84,85,86,87,88,89,
90,91,92,93,94,95,96,97,98,99
0, 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, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99
);
for (var i = 0; i < 100; i++) {

View File

@ -13,13 +13,13 @@ description: Checking an inherited property
//CHECK#1
Array.prototype[2] = -1;
var x = [0,1,2];
if (x[2] !== 2) {
$ERROR('#1: Array.prototype[2] = -1; x = [0,1,3]; x[2] === 2. Actual: ' + (x[2]));
var x = [0, 1, 2];
if (x[2] !== 2) {
$ERROR('#1: Array.prototype[2] = -1; x = [0,1,3]; x[2] === 2. Actual: ' + (x[2]));
}
//CHECK#2
x.length = 2;
if (x[2] !== -1) {
$ERROR('#2: Array.prototype[2] = -1; x = [0,1,3]; x.length = 2; x[2] === -1. Actual: ' + (x[2]));
if (x[2] !== -1) {
$ERROR('#2: Array.prototype[2] = -1; x = [0,1,3]; x.length = 2; x[2] === -1. Actual: ' + (x[2]));
}

View File

@ -12,32 +12,32 @@ description: P in [4294967295, -1, true]
//CHECK#1
var x = [];
x[4294967295] = 1;
if (x.length !== 0) {
$ERROR('#1.1: x = []; x[4294967295] = 1; x.length === 0. Actual: ' + (x.length));
if (x.length !== 0) {
$ERROR('#1.1: x = []; x[4294967295] = 1; x.length === 0. Actual: ' + (x.length));
}
if (x[4294967295] !== 1) {
$ERROR('#1.2: x = []; x[4294967295] = 1; x[4294967295] === 1. Actual: ' + (x[4294967295]));
if (x[4294967295] !== 1) {
$ERROR('#1.2: x = []; x[4294967295] = 1; x[4294967295] === 1. Actual: ' + (x[4294967295]));
}
//CHECK#2
x = [];
x[-1] = 1;
if (x.length !== 0) {
$ERROR('#2.1: x = []; x[-1] = 1; x.length === 0. Actual: ' + (x.length));
if (x.length !== 0) {
$ERROR('#2.1: x = []; x[-1] = 1; x.length === 0. Actual: ' + (x.length));
}
if (x[-1] !== 1) {
$ERROR('#2.2: x = []; x[-1] = 1; x[-1] === 1. Actual: ' + (x[-1]));
if (x[-1] !== 1) {
$ERROR('#2.2: x = []; x[-1] = 1; x[-1] === 1. Actual: ' + (x[-1]));
}
//CHECK#3
x = [];
x[true] = 1;
if (x.length !== 0) {
$ERROR('#3.1: x = []; x[true] = 1; x.length === 0. Actual: ' + (x.length));
if (x.length !== 0) {
$ERROR('#3.1: x = []; x[true] = 1; x.length === 0. Actual: ' + (x.length));
}
if (x[true] !== 1) {
$ERROR('#3.2: x = []; x[true] = 1; x[true] === 1. Actual: ' + (x[true]));
if (x[true] !== 1) {
$ERROR('#3.2: x = []; x[true] = 1; x[true] === 1. Actual: ' + (x[true]));
}

View File

@ -12,18 +12,18 @@ description: length === 100, P in [0, 98, 99]
//CHECK#1
var x = Array(100);
x[0] = 1;
if (x.length !== 100) {
$ERROR('#1: x = Array(100); x[0] = 1; x.length === 100. Actual: ' + (x.length));
if (x.length !== 100) {
$ERROR('#1: x = Array(100); x[0] = 1; x.length === 100. Actual: ' + (x.length));
}
//CHECK#2
x[98] = 1;
if (x.length !== 100) {
$ERROR('#2: x = Array(100); x[0] = 1; x[98] = 1; x.length === 100. Actual: ' + (x.length));
if (x.length !== 100) {
$ERROR('#2: x = Array(100); x[0] = 1; x[98] = 1; x.length === 100. Actual: ' + (x.length));
}
//CHECK#3
x[99] = 1;
if (x.length !== 100) {
$ERROR('#3: x = Array(100); x[0] = 1; x[98] = 1; x[99] = 1; x.length === 100. Actual: ' + (x.length));
if (x.length !== 100) {
$ERROR('#3: x = Array(100); x[0] = 1; x[98] = 1; x[99] = 1; x.length === 100. Actual: ' + (x.length));
}

View File

@ -12,12 +12,12 @@ description: length = 100, P in [100, 199]
//CHECK#1
var x = Array(100);
x[100] = 1;
if (x.length !== 101) {
$ERROR('#1: x = Array(100); x[100] = 1; x.length === 101. Actual: ' + (x.length));
if (x.length !== 101) {
$ERROR('#1: x = Array(100); x[100] = 1; x.length === 101. Actual: ' + (x.length));
}
//CHECK#2
x[199] = 1;
if (x.length !== 200) {
$ERROR('#2: x = Array(100); x[100] = 1; x[199] = 1; x.length === 100. Actual: ' + (x.length));
if (x.length !== 200) {
$ERROR('#2: x = Array(100); x[100] = 1; x[199] = 1; x.length === 100. Actual: ' + (x.length));
}

View File

@ -12,30 +12,30 @@ description: Checking boundary points
//CHECK#1
var x = [];
if (x.length !== 0) {
$ERROR('#1: x = []; x.length === 0. Actual: ' + (x.length));
if (x.length !== 0) {
$ERROR('#1: x = []; x.length === 0. Actual: ' + (x.length));
}
//CHECK#2
x[0] = 1;
if (x.length !== 1) {
if (x.length !== 1) {
$ERROR('#2: x = []; x[1] = 1; x.length === 1. Actual: ' + (x.length));
}
//CHECK#3
x[1] = 1;
if (x.length !== 2) {
if (x.length !== 2) {
$ERROR('#3: x = []; x[0] = 1; x[1] = 1; x.length === 2. Actual: ' + (x.length));
}
//CHECK#4
x[2147483648] = 1;
if (x.length !== 2147483649) {
if (x.length !== 2147483649) {
$ERROR('#4: x = []; x[0] = 1; x[1] = 1; x[2147483648] = 1; x.length === 2147483649. Actual: ' + (x.length));
}
//CHECK#5
x[4294967294] = 1;
if (x.length !== 4294967295) {
if (x.length !== 4294967295) {
$ERROR('#5: x = []; x[0] = 1; x[1] = 1; x[2147483648] = 1; x[42949672954] = 1; x.length === 4294967295. Actual: ' + (x.length));
}

View File

@ -13,14 +13,14 @@ description: P = "2^32 - 1" is not index array
//CHECK#1
var x = [];
x[4294967295] = 1;
if (x.length !== 0) {
$ERROR('#1: x = []; x[4294967295] = 1; x.length === 0. Actual: ' + (x.length));
if (x.length !== 0) {
$ERROR('#1: x = []; x[4294967295] = 1; x.length === 0. Actual: ' + (x.length));
}
//CHECK#2
var y =[];
var y = [];
y[1] = 1;
y[4294967295] = 1;
if (y.length !== 2) {
if (y.length !== 2) {
$ERROR('#2: y = []; y[1] = 1; y[4294967295] = 1; y.length === 2. Actual: ' + (y.length));
}

View File

@ -11,24 +11,24 @@ description: Checking length property
//CHECK#1
var x = [];
if (x.length !== 0) {
$ERROR('#1: x = []; x.length === 0. Actual: ' + (x.length));
if (x.length !== 0) {
$ERROR('#1: x = []; x.length === 0. Actual: ' + (x.length));
}
//CHECK#2
x[0] = 1;
if (x.length !== 1) {
if (x.length !== 1) {
$ERROR('#2: x = []; x[1] = 1; x.length === 1. Actual: ' + (x.length));
}
//CHECK#3
x[1] = 1;
if (x.length !== 2) {
if (x.length !== 2) {
$ERROR('#3: x = []; x[0] = 1; x[1] = 1; x.length === 2. Actual: ' + (x.length));
}
//CHECK#4
x[9] = 1;
if (x.length !== 10) {
if (x.length !== 10) {
$ERROR('#4: x = []; x[0] = 1; x[1] = 1; x[9] = 1; x.length === 10. Actual: ' + (x.length));
}

View File

@ -14,18 +14,18 @@ description: >
//CHECK#1
var x = [];
x.length = 1;
if (x.length !== 1) {
$ERROR('#1: x = []; x.length = 1; x.length === 1. Actual: ' + (x.length));
if (x.length !== 1) {
$ERROR('#1: x = []; x.length = 1; x.length === 1. Actual: ' + (x.length));
}
//CHECK#2
x[5] = 1;
x.length = 10;
if (x.length !== 10) {
if (x.length !== 10) {
$ERROR('#2: x = []; x.length = 1; x[5] = 1; x.length = 10; x.length === 10. Actual: ' + (x.length));
}
//CHECK#3
if (x[5] !== 1) {
if (x[5] !== 1) {
$ERROR('#3: x = []; x.length = 1; x[5] = 1; x.length = 10; x[5] = 1');
}

View File

@ -17,34 +17,34 @@ x[1] = 1;
x[3] = 3;
x[5] = 5;
x.length = 4;
if (x.length !== 4) {
$ERROR('#1: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x.length === 4. Actual: ' + (x.length));
if (x.length !== 4) {
$ERROR('#1: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x.length === 4. Actual: ' + (x.length));
}
//CHECK#2
if (x[5] !== undefined) {
if (x[5] !== undefined) {
$ERROR('#2: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x[5] === undefined. Actual: ' + (x[5]));
}
//CHECK#3
if (x[3] !== 3) {
if (x[3] !== 3) {
$ERROR('#3: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x[3] === 3. Actual: ' + (x[3]));
}
//CHECK#4
x.length = new Number(6);
if (x[5] !== undefined) {
if (x[5] !== undefined) {
$ERROR('#4: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x.length = new Number(6); x[5] === undefined. Actual: ' + (x[5]));
}
//CHECK#5
x.length = 0;
if (x[0] !== undefined) {
if (x[0] !== undefined) {
$ERROR('#5: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x.length = new Number(6); x.length = 0; x[0] === undefined. Actual: ' + (x[0]));
}
//CHECK#6
x.length = 1;
if (x[1] !== undefined) {
if (x[1] !== undefined) {
$ERROR('#6: x = []; x[1] = 1; x[3] = 3; x[5] = 5; x.length = 4; x.length = new Number(6); x.length = 0; x.length = 1; x[1] === undefined. Actual: ' + (x[1]));
}

View File

@ -12,8 +12,8 @@ description: "[[Put]] (length, 4294967296)"
//CHECK#1
var x = [];
x.length = 4294967295;
if (x.length !== 4294967295) {
$ERROR('#1: x = []; x.length = 4294967295; x.length === 4294967295');
if (x.length !== 4294967295) {
$ERROR('#1: x = []; x.length = 4294967295; x.length === 4294967295');
}
//CHECK#2
@ -21,8 +21,8 @@ try {
x = [];
x.length = 4294967296;
$ERROR('#2.1: x = []; x.length = 4294967296 throw RangeError. Actual: x.length === ' + (x.length));
} catch(e) {
} catch (e) {
if ((e instanceof RangeError) !== true) {
$ERROR('#2.2: x = []; x.length = 4294967296 throw RangeError. Actual: ' + (e));
}
}
}

View File

@ -14,7 +14,7 @@ var x = [];
var k = 1;
for (var i = 0; i < 32; i++) {
k = k * 2;
x[k - 2] = k;
x[k - 2] = k;
}
k = 1;
@ -22,5 +22,5 @@ for (i = 0; i < 32; i++) {
k = k * 2;
if (x[k - 2] !== k) {
$ERROR('#' + (k - 2) + ': ');
}
}
}

View File

@ -13,12 +13,12 @@ description: Checking for string primitive
var x = [];
x["0"] = 0;
if (x[0] !== 0) {
$ERROR('#1: x = []; x["0"] = 0; x[0] === 0. Actual: ' + (x[0]));
}
$ERROR('#1: x = []; x["0"] = 0; x[0] === 0. Actual: ' + (x[0]));
}
//CHECK#2
var y = [];
y["1"] = 1;
if (y[1] !== 1) {
$ERROR('#2: y = []; y["1"] = 1; y[1] === 1. Actual: ' + (y[1]));
$ERROR('#2: y = []; y["1"] = 1; y[1] === 1. Actual: ' + (y[1]));
}

View File

@ -13,22 +13,22 @@ description: Checking for null and undefined
var x = [];
x[null] = 0;
if (x[0] !== undefined) {
$ERROR('#1: x = []; x[null] = 1; x[0] === undefined. Actual: ' + (x[0]));
$ERROR('#1: x = []; x[null] = 1; x[0] === undefined. Actual: ' + (x[0]));
}
//CHECK#2
if (x["null"] !== 0) {
$ERROR('#2: x = []; x[null] = 1; x["null"] === 0. Actual: ' + (x["null"]));
$ERROR('#2: x = []; x[null] = 1; x["null"] === 0. Actual: ' + (x["null"]));
}
//CHECK#3
var y = [];
y[undefined] = 0;
if (y[0] !== undefined) {
$ERROR('#3: y = []; y[undefined] = 0; y[0] === undefined. Actual: ' + (y[0]));
$ERROR('#3: y = []; y[undefined] = 0; y[0] === undefined. Actual: ' + (y[0]));
}
//CHECK#4
if (y["undefined"] !== 0) {
$ERROR('#4: y = []; y[undefined] = 1; y["undefined"] === 0. Actual: ' + (y["undefined"]));
$ERROR('#4: y = []; y[undefined] = 1; y["undefined"] === 0. Actual: ' + (y["undefined"]));
}

View File

@ -13,21 +13,21 @@ description: Checking for Boolean object
var x = [];
x[new Boolean(true)] = 1;
if (x[1] !== undefined) {
$ERROR('#1: x = []; x[new Boolean(true)] = 1; x[1] === undefined. Actual: ' + (x[1]));
$ERROR('#1: x = []; x[new Boolean(true)] = 1; x[1] === undefined. Actual: ' + (x[1]));
}
//CHECK#2
if (x["true"] !== 1) {
$ERROR('#2: x = []; x[true] = 1; x["true"] === 1. Actual: ' + (x["true"]));
$ERROR('#2: x = []; x[true] = 1; x["true"] === 1. Actual: ' + (x["true"]));
}
//CHECK#3
x[new Boolean(false)] = 0;
if (x[0] !== undefined) {
$ERROR('#3: x = []; x[true] = 1; x[new Boolean(false)] = 0; x[0] === undefined. Actual: ' + (x[0]));
$ERROR('#3: x = []; x[true] = 1; x[new Boolean(false)] = 0; x[0] === undefined. Actual: ' + (x[0]));
}
//CHECK#4
if (x["false"] !== 0) {
$ERROR('#4: x = []; x[false] = 1; x["false"] === 0. Actual: ' + (x["false"]));
$ERROR('#4: x = []; x[false] = 1; x["false"] === 0. Actual: ' + (x["false"]));
}

View File

@ -13,19 +13,19 @@ description: Checking for Number object
var x = [];
x[new Number(0)] = 0;
if (x[0] !== 0) {
$ERROR('#1: x = []; x[new Number(0)] = 0; x[0] === 0. Actual: ' + (x[0]));
}
$ERROR('#1: x = []; x[new Number(0)] = 0; x[0] === 0. Actual: ' + (x[0]));
}
//CHECK#2
var y = [];
y[new Number(1)] = 1;
if (y[1] !== 1) {
$ERROR('#2: y = []; y[new Number(1)] = 1; y[1] === 1. Actual: ' + (y[1]));
$ERROR('#2: y = []; y[new Number(1)] = 1; y[1] === 1. Actual: ' + (y[1]));
}
//CHECK#3
var z = [];
z[new Number(1.1)] = 1;
if (z["1.1"] !== 1) {
$ERROR('#3: z = []; z[new Number(1.1)] = 1; z["1.1"] === 1. Actual: ' + (z["1.1"]));
$ERROR('#3: z = []; z[new Number(1.1)] = 1; z["1.1"] === 1. Actual: ' + (z["1.1"]));
}

View File

@ -13,19 +13,19 @@ description: Checking for Number object
var x = [];
x[new String("0")] = 0;
if (x[0] !== 0) {
$ERROR('#1: x = []; x[new String("0")] = 0; x[0] === 0. Actual: ' + (x[0]));
}
$ERROR('#1: x = []; x[new String("0")] = 0; x[0] === 0. Actual: ' + (x[0]));
}
//CHECK#2
var y = [];
y[new String("1")] = 1;
if (y[1] !== 1) {
$ERROR('#2: y = []; y[new String("1")] = 1; y[1] === 1. Actual: ' + (y[1]));
$ERROR('#2: y = []; y[new String("1")] = 1; y[1] === 1. Actual: ' + (y[1]));
}
//CHECK#3
var z = [];
z[new String("1.1")] = 1;
if (z["1.1"] !== 1) {
$ERROR('#3: z = []; z[new String("1.1")] = 1; z["1.1"] === 1. Actual: ' + (z["1.1"]));
$ERROR('#3: z = []; z[new String("1.1")] = 1; z["1.1"] === 1. Actual: ' + (z["1.1"]));
}

View File

@ -11,7 +11,11 @@ description: If Type(value) is Object, evaluate ToPrimitive(value, String)
//CHECK#1
var x = [];
var object = {valueOf: function() {return 1}};
var object = {
valueOf: function() {
return 1
}
};
x[object] = 0;
if (x["[object Object]"] !== 0) {
$ERROR('#1: x = []; var object = {valueOf: function() {return 1}}; x[object] = 0; x["[object Object]"] === 0. Actual: ' + (x["[object Object]"]));
@ -19,15 +23,29 @@ if (x["[object Object]"] !== 0) {
//CHECK#2
x = [];
var object = {valueOf: function() {return 1}, toString: function() {return 0}};
var object = {
valueOf: function() {
return 1
},
toString: function() {
return 0
}
};
x[object] = 0;
if (x[0] !== 0) {
$ERROR('#2: x = []; var object = {valueOf: function() {return 1}, toString: function() {return 0}}; x[object] = 0; x[0] === 0. Actual: ' + (x[0]));
}
}
//CHECK#3
x = [];
var object = {valueOf: function() {return 1}, toString: function() {return {}}};
var object = {
valueOf: function() {
return 1
},
toString: function() {
return {}
}
};
x[object] = 0;
if (x[1] !== 0) {
$ERROR('#3: x = []; var object = {valueOf: function() {return 1}, toString: function() {return {}}}; x[object] = 0; x[1] === 0. Actual: ' + (x[1]));
@ -35,8 +53,15 @@ if (x[1] !== 0) {
//CHECK#4
try {
x = [];
var object = {valueOf: function() {throw "error"}, toString: function() {return 1}};
x = [];
var object = {
valueOf: function() {
throw "error"
},
toString: function() {
return 1
}
};
x[object] = 0;
if (x[1] !== 0) {
$ERROR('#4.1: x = []; var object = {valueOf: function() {throw "error"}, toString: function() {return 1}}; x[object] = 0; x[1] === 1. Actual: ' + (x[1]));
@ -52,7 +77,11 @@ catch (e) {
//CHECK#5
x = [];
var object = {toString: function() {return 1}};
var object = {
toString: function() {
return 1
}
};
x[object] = 0;
if (x[1] !== 0) {
$ERROR('#5: x = []; var object = {toString: function() {return 1}}; x[object] = 0; x[1] === 0. Actual: ' + (x[1]));
@ -60,7 +89,14 @@ if (x[1] !== 0) {
//CHECK#6
x = [];
var object = {valueOf: function() {return {}}, toString: function() {return 1}}
var object = {
valueOf: function() {
return {}
},
toString: function() {
return 1
}
}
x[object] = 0;
if (x[1] !== 0) {
$ERROR('#6: x = []; var object = {valueOf: function() {return {}}, toString: function() {return 1}}; x[object] = 0; x[1] === 0. Actual: ' + (x[1]));
@ -69,25 +105,39 @@ if (x[1] !== 0) {
//CHECK#7
try {
x = [];
var object = {valueOf: function() {return 1}, toString: function() {throw "error"}};
x[object];
var object = {
valueOf: function() {
return 1
},
toString: function() {
throw "error"
}
};
x[object];
$ERROR('#7.1: x = []; var object = {valueOf: function() {return 1}, toString: function() {throw "error"}}; x[object] throw "error". Actual: ' + (x[object]));
}
}
catch (e) {
if (e !== "error") {
$ERROR('#7.2: x = []; var object = {valueOf: function() {return 1}, toString: function() {throw "error"}}; x[object] throw "error". Actual: ' + (e));
}
}
}
//CHECK#8
try {
x = [];
var object = {valueOf: function() {return {}}, toString: function() {return {}}};
var object = {
valueOf: function() {
return {}
},
toString: function() {
return {}
}
};
x[object];
$ERROR('#8.1: x = []; var object = {valueOf: function() {return {}}, toString: function() {return {}}}; x[object] throw TypeError. Actual: ' + (x[object]));
}
}
catch (e) {
if ((e instanceof TypeError) !== true) {
$ERROR('#8.2: x = []; var object = {valueOf: function() {return {}}, toString: function() {return {}}}; x[object] throw TypeError. Actual: ' + (e));
}
}
}

View File

@ -28,7 +28,9 @@ function MyCollection() {
this.args = arguments;
}
result = Array.from.call(MyCollection, {length: 42});
result = Array.from.call(MyCollection, {
length: 42
});
assert.sameValue(result.args.length, 1);
assert.sameValue(result.args[0], 42);

View File

@ -34,7 +34,7 @@ var list = {
};
var calls = [];
function mapFn (value) {
function mapFn(value) {
calls.push({
args: arguments,
thisArg: this

View File

@ -34,7 +34,7 @@ var list = {
};
var calls = [];
function mapFn (value) {
function mapFn(value) {
calls.push({
args: arguments,
thisArg: this

View File

@ -35,7 +35,7 @@ var list = {
var calls = [];
var thisArg = {};
function mapFn (value) {
function mapFn(value) {
calls.push({
args: arguments,
thisArg: this

View File

@ -10,23 +10,24 @@ es6id: 22.1.2.1
var arrayIndex = -1;
var originalLength = 7;
var obj = {
length: originalLength,
0: 2,
1: 4,
2: 8,
3: 16,
4: 32,
5: 64,
6: 128
length: originalLength,
0: 2,
1: 4,
2: 8,
3: 16,
4: 32,
5: 64,
6: 128
};
var array = [ 2, 4, 8, 16, 32, 64, 128 ];
function mapFn(value, index) {
arrayIndex++;
assert.sameValue(value, obj[arrayIndex], "Value mismatch in mapFn at index " + index + ".");
assert.sameValue(index, arrayIndex, "Index mismatch in mapFn.");
obj[originalLength + arrayIndex] = 2 * arrayIndex + 1;
var array = [2, 4, 8, 16, 32, 64, 128];
return obj[arrayIndex];
function mapFn(value, index) {
arrayIndex++;
assert.sameValue(value, obj[arrayIndex], "Value mismatch in mapFn at index " + index + ".");
assert.sameValue(index, arrayIndex, "Index mismatch in mapFn.");
obj[originalLength + arrayIndex] = 2 * arrayIndex + 1;
return obj[arrayIndex];
}
@ -34,5 +35,5 @@ var a = Array.from(obj, mapFn);
assert.sameValue(a.length, array.length, "Length mismatch.");
for (var j = 0; j < a.length; j++) {
assert.sameValue(a[j], array[j], "Element mismatch for array at index " + j + ".");
assert.sameValue(a[j], array[j], "Element mismatch for array at index " + j + ".");
}

View File

@ -9,17 +9,18 @@ esid: sec-array.from
es6id: 22.1.2.1
---*/
var originalArray = [ 0, 1, -2, 4, -8, 16 ];
var array = [ 0, 1, -2, 4, -8, 16 ];
var originalArray = [0, 1, -2, 4, -8, 16];
var array = [0, 1, -2, 4, -8, 16];
var a = [];
var arrayIndex = -1;
function mapFn(value, index) {
this.arrayIndex++;
assert.sameValue(value, array[this.arrayIndex], "Value mismatch in mapFn at index " + index + ".");
assert.sameValue(index, this.arrayIndex, "Index mismatch in mapFn.");
array.splice(array.length - 1, 1);
return 127;
function mapFn(value, index) {
this.arrayIndex++;
assert.sameValue(value, array[this.arrayIndex], "Value mismatch in mapFn at index " + index + ".");
assert.sameValue(index, this.arrayIndex, "Index mismatch in mapFn.");
array.splice(array.length - 1, 1);
return 127;
}
@ -28,5 +29,5 @@ a = Array.from(array, mapFn, this);
assert.sameValue(a.length, originalArray.length / 2, "Length mismatch. Old array : " + (originalArray.length / 2) + ". array : " + a.length + ".");
for (var j = 0; j < originalArray.length / 2; j++) {
assert.sameValue(a[j], 127, "Element mismatch for mapped array at index " + j + ".");
assert.sameValue(a[j], 127, "Element mismatch for mapped array at index " + j + ".");
}

View File

@ -7,21 +7,22 @@ esid: sec-array.from
es6id: 22.1.2.1
---*/
var array = [ 127, 4, 8, 16, 32, 64, 128 ];
var array = [127, 4, 8, 16, 32, 64, 128];
var arrayIndex = -1;
function mapFn(value, index) {
arrayIndex++;
if (index + 1 < array.length) {
array[index + 1] = 127;
}
assert.sameValue(value, 127, "Value mismatch in mapFn at index " + index + ".");
assert.sameValue(index, arrayIndex, "Index mismatch in mapFn.");
return value;
function mapFn(value, index) {
arrayIndex++;
if (index + 1 < array.length) {
array[index + 1] = 127;
}
assert.sameValue(value, 127, "Value mismatch in mapFn at index " + index + ".");
assert.sameValue(index, arrayIndex, "Index mismatch in mapFn.");
return value;
}
var a = Array.from(array, mapFn);
assert.sameValue(a.length, array.length, "Length mismatch.");
for (var j = 0; j < a.length; j++) {
assert.sameValue(a[j], 127, "Element mismatch for mapped array.");
assert.sameValue(a[j], 127, "Element mismatch for mapped array.");
}

View File

@ -27,7 +27,9 @@ var items = {};
items[Symbol.iterator] = function() {
return {
next: function() {
return { done: true };
return {
done: true
};
}
};
};

View File

@ -26,8 +26,14 @@ features: [Symbol.iterator]
---*/
var args = [];
var firstResult = { done: false, value: {} };
var secondResult = { done: false, value: {} };
var firstResult = {
done: false,
value: {}
};
var secondResult = {
done: false,
value: {}
};
var mapFn = function(value, idx) {
args.push(arguments);
};
@ -40,7 +46,9 @@ items[Symbol.iterator] = function() {
next: function() {
var result = nextResult;
nextResult = nextNextResult;
nextNextResult = { done: true };
nextNextResult = {
done: true
};
return result;
}

View File

@ -25,8 +25,14 @@ features: [Symbol.iterator]
---*/
var thisVals = [];
var nextResult = { done: false, value: {} };
var nextNextResult = { done: false, value: {} };
var nextResult = {
done: false,
value: {}
};
var nextNextResult = {
done: false,
value: {}
};
var firstReturnVal = {};
var secondReturnVal = {};
var mapFn = function(value, idx) {
@ -45,7 +51,9 @@ items[Symbol.iterator] = function() {
next: function() {
var result = nextResult;
nextResult = nextNextResult;
nextNextResult = { done: true };
nextNextResult = {
done: true
};
return result;
}

View File

@ -23,8 +23,14 @@ features: [Symbol.iterator]
---*/
var thisVals = [];
var nextResult = { done: false, value: {} };
var nextNextResult = { done: false, value: {} };
var nextResult = {
done: false,
value: {}
};
var nextNextResult = {
done: false,
value: {}
};
var mapFn = function() {
thisVals.push(this);
};
@ -36,7 +42,9 @@ items[Symbol.iterator] = function() {
next: function() {
var result = nextResult;
nextResult = nextNextResult;
nextNextResult = { done: true };
nextNextResult = {
done: true
};
return result;
}

View File

@ -24,20 +24,30 @@ flags: [noStrict]
---*/
var thisVals = [];
var nextResult = { done: false, value: {} };
var nextNextResult = { done: false, value: {} };
var nextResult = {
done: false,
value: {}
};
var nextNextResult = {
done: false,
value: {}
};
var mapFn = function() {
thisVals.push(this);
};
var items = {};
var global = function() { return this; }();
var global = function() {
return this;
}();
items[Symbol.iterator] = function() {
return {
next: function() {
var result = nextResult;
nextResult = nextNextResult;
nextNextResult = { done: true };
nextNextResult = {
done: true
};
return result;
}

View File

@ -24,8 +24,14 @@ flags: [onlyStrict]
---*/
var thisVals = [];
var nextResult = { done: false, value: {} };
var nextNextResult = { done: false, value: {} };
var nextResult = {
done: false,
value: {}
};
var nextNextResult = {
done: false,
value: {}
};
var mapFn = function() {
thisVals.push(this);
};
@ -36,7 +42,9 @@ items[Symbol.iterator] = function() {
next: function() {
var result = nextResult;
nextResult = nextNextResult;
nextNextResult = { done: true };
nextNextResult = {
done: true
};
return result;
}

View File

@ -18,11 +18,15 @@ features: [Symbol.iterator]
---*/
var C = function() {
Object.defineProperty(this, '0', { configurable: false });
Object.defineProperty(this, '0', {
configurable: false
});
};
var closeCount = 0;
var items = {};
var nextResult = { done: false };
var nextResult = {
done: false
};
items[Symbol.iterator] = function() {
return {
@ -32,7 +36,9 @@ items[Symbol.iterator] = function() {
next: function() {
var result = nextResult;
nextResult = { done: true };
nextResult = {
done: true
};
return result;
}

View File

@ -16,9 +16,18 @@ features: [Symbol.iterator]
---*/
var items = {};
var firstIterResult = { done: false, value: {} };
var secondIterResult = { done: false, value: {} };
var thirdIterResult = { done: true, value: {} };
var firstIterResult = {
done: false,
value: {}
};
var secondIterResult = {
done: false,
value: {}
};
var thirdIterResult = {
done: true,
value: {}
};
var nextIterResult = firstIterResult;
var nextNextIterResult = secondIterResult;
var result;

View File

@ -25,7 +25,11 @@ Object.defineProperty(C.prototype, 'length', {
});
items[Symbol.iterator] = function() {
return {
next: function() { return { done: true }; }
next: function() {
return {
done: true
};
}
};
};

View File

@ -29,13 +29,19 @@ items[Symbol.iterator] = function() {
};
};
nextIterResult = lastIterResult = { done: true };
nextIterResult = lastIterResult = {
done: true
};
result = Array.from(items);
assert.sameValue(result.length, 0);
nextIterResult = { done: false };
lastIterResult = { done: true };
nextIterResult = {
done: false
};
lastIterResult = {
done: true
};
result = Array.from(items);
assert.sameValue(result.length, 1);

View File

@ -7,9 +7,12 @@ esid: sec-array.from
es6id: 22.1.2.1
---*/
var array = [ 2, 4, 8, 16, 32, 64, 128 ];
var array = [2, 4, 8, 16, 32, 64, 128];
function mapFn(value, index, obj) {
throw new Test262Error();
throw new Test262Error();
}
assert.throws(Test262Error, function(){Array.from(array, mapFn);});
assert.throws(Test262Error, function() {
Array.from(array, mapFn);
});

View File

@ -7,14 +7,15 @@ esid: sec-array.from
es6id: 22.1.2.1
---*/
var array = [ Number.MAX_VALUE, Number.MIN_VALUE, Number.NaN, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY ];
var array = [Number.MAX_VALUE, Number.MIN_VALUE, Number.NaN, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY];
var arrayIndex = -1;
function mapFn(value, index) {
this.arrayIndex++;
assert.sameValue(value, array[this.arrayIndex], "Value mismatch in mapFn at index " + index + ".");
assert.sameValue(index, this.arrayIndex, "Index mismatch in mapFn.");
return value;
function mapFn(value, index) {
this.arrayIndex++;
assert.sameValue(value, array[this.arrayIndex], "Value mismatch in mapFn at index " + index + ".");
assert.sameValue(index, this.arrayIndex, "Index mismatch in mapFn.");
return value;
}
var a = Array.from(array, mapFn, this);

View File

@ -8,23 +8,25 @@ es6id: 22.1.2.1
features: [Symbol.iterator]
---*/
var array = [ 2, 4, 8, 16, 32, 64, 128 ];
var array = [2, 4, 8, 16, 32, 64, 128];
var obj = {
[Symbol.iterator]() {
return {
index: 0,
next() {
throw new Test262Error();
},
isDone : false,
get val() {
this.index++;
if (this.index > 7) {
this.isDone = true;
}
return 1 << this.index;
}
};
}
[Symbol.iterator]() {
return {
index: 0,
next() {
throw new Test262Error();
},
isDone: false,
get val() {
this.index++;
if (this.index > 7) {
this.isDone = true;
}
return 1 << this.index;
}
};
}
};
assert.throws(Test262Error, function(){Array.from(obj);});
assert.throws(Test262Error, function() {
Array.from(obj);
});

View File

@ -8,30 +8,30 @@ es6id: 22.1.2.1
features: [Symbol.iterator]
---*/
var array = [ 2, 4, 8, 16, 32, 64, 128 ];
var array = [2, 4, 8, 16, 32, 64, 128];
var obj = {
[Symbol.iterator]() {
[Symbol.iterator]() {
return {
index: 0,
next() {
return {
index: 0,
next() {
return {
value: this.val,
done: this.isDone
};
},
isDone : false,
get val() {
this.index++;
if (this.index > 7) {
this.isDone = true;
}
return 1 << this.index;
}
value: this.val,
done: this.isDone
};
}
},
isDone: false,
get val() {
this.index++;
if (this.index > 7) {
this.isDone = true;
}
return 1 << this.index;
}
};
}
};
var a = Array.from.call(Object, obj);
assert.sameValue(typeof a, typeof {}, "The returned type is expected to be object.");
for (var j = 0; j < a.length; j++) {
assert.sameValue(a[j], array[j], "Elements mismatch at " + j + ".");
assert.sameValue(a[j], array[j], "Elements mismatch at " + j + ".");
}

View File

@ -12,14 +12,14 @@ es6id: 22.1.2.1
var array = [2, 4, 0, 16];
var expectedArray = [2, 4, , 16];
var obj = {
length : 4,
0 : 2,
1 : 4,
2 : 0,
3 : 16
length: 4,
0: 2,
1: 4,
2: 0,
3: 16
};
delete obj[2];
var a = Array.from(obj);
for (var j = 0; j < expectedArray.length; j++) {
assert.sameValue(a[j], expectedArray[j], "Elements mismatch at " + j + ".");
assert.sameValue(a[j], expectedArray[j], "Elements mismatch at " + j + ".");
}

View File

@ -9,14 +9,14 @@ es6id: 22.1.2.1
var array = [2, 4, , 16];
var obj = {
length: 4,
0: 2,
1: 4,
3: 16
length: 4,
0: 2,
1: 4,
3: 16
};
var a = Array.from.call(Object, obj);
assert.sameValue(typeof a, "object", "The returned type is expected to be object.");
for (var j = 0; j < a.length; j++) {
assert.sameValue(a[j], array[j], "Elements mismatch at " + j + ".");
assert.sameValue(a[j], array[j], "Elements mismatch at " + j + ".");
}

View File

@ -8,10 +8,10 @@ es6id: 22.1.2.1
---*/
var obj = {
0: 2,
1: 4,
2: 8,
3: 16
0: 2,
1: 4,
2: 8,
3: 16
}
var a = Array.from(obj);

View File

@ -7,12 +7,12 @@ es5id: 15.4.3.2-0-4
description: Array.isArray return false if its argument is not an Array
---*/
var b_num = Array.isArray(42);
var b_num = Array.isArray(42);
var b_undef = Array.isArray(undefined);
var b_bool = Array.isArray(true);
var b_str = Array.isArray("abc");
var b_obj = Array.isArray({});
var b_null = Array.isArray(null);
var b_bool = Array.isArray(true);
var b_str = Array.isArray("abc");
var b_obj = Array.isArray({});
var b_null = Array.isArray(null);
assert.sameValue(b_num, false, 'b_num');

View File

@ -10,7 +10,7 @@ description: Array.isArray applied to Arguments object
var arg;
(function fun() {
arg = arguments;
arg = arguments;
}(1, 2, 3));
assert.sameValue(Array.isArray(arg), false, 'Array.isArray(arg)');

View File

@ -7,4 +7,4 @@ es5id: 15.4.3.2-1-7
description: Array.isArray applied to Function object
---*/
assert.sameValue(Array.isArray(function () { }), false, 'Array.isArray(function () { })');
assert.sameValue(Array.isArray(function() {}), false, 'Array.isArray(function () { })');

View File

@ -8,7 +8,7 @@ description: Array.isArray applied to an object with an array as the prototype
---*/
var proto = [];
var Con = function () { };
var Con = function() {};
Con.prototype = proto;
var child = new Con();

View File

@ -9,10 +9,10 @@ description: >
prototype
---*/
var proto = Array.prototype;
var Con = function () { };
Con.prototype = proto;
var proto = Array.prototype;
var Con = function() {};
Con.prototype = proto;
var child = new Con();
var child = new Con();
assert.sameValue(Array.isArray(child), false, 'Array.isArray(child)');

View File

@ -9,4 +9,8 @@ description: >
indexed properties
---*/
assert.sameValue(Array.isArray({ 0: 12, 1: 9, length: 2 }), false, 'Array.isArray({ 0: 12, 1: 9, length: 2 })');
assert.sameValue(Array.isArray({
0: 12,
1: 9,
length: 2
}), false, 'Array.isArray({ 0: 12, 1: 9, length: 2 })');

View File

@ -11,5 +11,5 @@ description: >
assert.throws(RangeError, function() {
[].length = 4294967296 ;
[].length = 4294967296;
});

View File

@ -11,5 +11,5 @@ description: >
assert.throws(RangeError, function() {
[].length = 4294967297 ;
[].length = 4294967297;
});

View File

@ -7,7 +7,7 @@ es5id: 15.4.5.1-3.d-3
description: Set array length property to max value 4294967295 (2**32-1,)
---*/
var a =[];
a.length = 4294967295 ;
var a = [];
a.length = 4294967295;
assert.sameValue(a.length, 4294967295, 'a.length');

View File

@ -14,7 +14,7 @@ description: Use try statement. len = -1, 4294967296, 4294967297
try {
new Array(-1);
$ERROR('#1.1: new Array(-1) throw RangeError. Actual: ' + (new Array(-1)));
} catch(e) {
} catch (e) {
if ((e instanceof RangeError) !== true) {
$ERROR('#1.2: new Array(-1) throw RangeError. Actual: ' + (e));
}
@ -24,7 +24,7 @@ try {
try {
new Array(4294967296);
$ERROR('#2.1: new Array(4294967296) throw RangeError. Actual: ' + (new Array(4294967296)));
} catch(e) {
} catch (e) {
if ((e instanceof RangeError) !== true) {
$ERROR('#2.2: new Array(4294967296) throw RangeError. Actual: ' + (e));
}
@ -34,7 +34,7 @@ try {
try {
new Array(4294967297);
$ERROR('#3.1: new Array(4294967297) throw RangeError. Actual: ' + (new Array(4294967297)));
} catch(e) {
} catch (e) {
if ((e instanceof RangeError) !== true) {
$ERROR('#3.2: new Array(4294967297) throw RangeError. Actual: ' + (e));
}

View File

@ -14,7 +14,7 @@ description: Use try statement. len = NaN, +/-Infinity
try {
new Array(NaN);
$ERROR('#1.1: new Array(NaN) throw RangeError. Actual: ' + (new Array(NaN)));
} catch(e) {
} catch (e) {
if ((e instanceof RangeError) !== true) {
$ERROR('#1.2: new Array(NaN) throw RangeError. Actual: ' + (e));
}
@ -24,7 +24,7 @@ try {
try {
new Array(Number.POSITIVE_INFINITY);
$ERROR('#2.1: new Array(Number.POSITIVE_INFINITY) throw RangeError. Actual: ' + (new Array(Number.POSITIVE_INFINITY)));
} catch(e) {
} catch (e) {
if ((e instanceof RangeError) !== true) {
$ERROR('#2.2: new Array(Number.POSITIVE_INFINITY) throw RangeError. Actual: ' + (e));
}
@ -34,7 +34,7 @@ try {
try {
new Array(Number.NEGATIVE_INFINITY);
$ERROR('#3.1: new Array(Number.NEGATIVE_INFINITY) throw RangeError. Actual: ' + (new Array(Number.NEGATIVE_INFINITY)));
} catch(e) {
} catch (e) {
if ((e instanceof RangeError) !== true) {
$ERROR('#3.2: new Array(Number.NEGATIVE_INFINITY) throw RangeError. Actual: ' + (e));
}

View File

@ -14,7 +14,7 @@ description: Use try statement. len = 1.5, Number.MAX_VALUE, Number.MIN_VALUE
try {
new Array(1.5);
$ERROR('#1.1: new Array(1.5) throw RangeError. Actual: ' + (new Array(1.5)));
} catch(e) {
} catch (e) {
if ((e instanceof RangeError) !== true) {
$ERROR('#1.2: new Array(1.5) throw RangeError. Actual: ' + (e));
}
@ -24,7 +24,7 @@ try {
try {
new Array(Number.MAX_VALUE);
$ERROR('#2.1: new Array(Number.MAX_VALUE) throw RangeError. Actual: ' + (new Array(Number.MAX_VALUE)));
} catch(e) {
} catch (e) {
if ((e instanceof RangeError) !== true) {
$ERROR('#2.2: new Array(Number.MAX_VALUE) throw RangeError. Actual: ' + (e));
}
@ -34,7 +34,7 @@ try {
try {
new Array(Number.MIN_VALUE);
$ERROR('#3.1: new Array(Number.MIN_VALUE) throw RangeError. Actual: ' + (new Array(Number.MIN_VALUE)));
} catch(e) {
} catch (e) {
if ((e instanceof RangeError) !== true) {
$ERROR('#3.2: new Array(Number.MIN_VALUE) throw RangeError. Actual: ' + (e));
}

View File

@ -13,7 +13,7 @@ try {
var x = [];
x.length = 4294967296;
$ERROR('#1.1: x = []; x.length = 4294967296 throw RangeError. Actual: x.length === ' + (x.length));
} catch(e) {
} catch (e) {
if ((e instanceof RangeError) !== true) {
$ERROR('#1.2: x = []; x.length = 4294967296 throw RangeError. Actual: ' + (e));
}
@ -24,7 +24,7 @@ try {
x = [];
x.length = -1;
$ERROR('#2.1: x = []; x.length = -1 throw RangeError. Actual: x.length === ' + (x.length));
} catch(e) {
} catch (e) {
if ((e instanceof RangeError) !== true) {
$ERROR('#2.2: x = []; x.length = -1 throw RangeError. Actual: ' + (e));
}
@ -35,7 +35,7 @@ try {
x = [];
x.length = 1.5;
$ERROR('#3.1: x = []; x.length = 1.5 throw RangeError. Actual: x.length === ' + (x.length));
} catch(e) {
} catch (e) {
if ((e instanceof RangeError) !== true) {
$ERROR('#3.2: x = []; x.length = 1.5 throw RangeError. Actual: ' + (e));
}

View File

@ -13,7 +13,7 @@ try {
var x = [];
x.length = NaN;
$ERROR('#1.1: x = []; x.length = NaN throw RangeError. Actual: x.length === ' + (x.length));
} catch(e) {
} catch (e) {
if ((e instanceof RangeError) !== true) {
$ERROR('#1.2: x = []; x.length = NaN throw RangeError. Actual: ' + (e));
}
@ -24,7 +24,7 @@ try {
x = [];
x.length = Number.POSITIVE_INFINITY;
$ERROR('#2.1: x = []; x.length = Number.POSITIVE_INFINITY throw RangeError. Actual: x.length === ' + (x.length));
} catch(e) {
} catch (e) {
if ((e instanceof RangeError) !== true) {
$ERROR('#2.2: x = []; x.length = Number.POSITIVE_INFINITY throw RangeError. Actual: ' + (e));
}
@ -35,7 +35,7 @@ try {
x = [];
x.length = Number.NEGATIVE_INFINITY;
$ERROR('#3.1: x = []; x.length = Number.NEGATIVE_INFINITY throw RangeError. Actual: x.length === ' + (x.length));
} catch(e) {
} catch (e) {
if ((e instanceof RangeError) !== true) {
$ERROR('#3.2: x = []; x.length = Number.NEGATIVE_INFINITY throw RangeError. Actual: ' + (e));
}
@ -46,7 +46,7 @@ try {
x = [];
x.length = undefined;
$ERROR('#4.1: x = []; x.length = undefined throw RangeError. Actual: x.length === ' + (x.length));
} catch(e) {
} catch (e) {
if ((e instanceof RangeError) !== true) {
$ERROR('#4.2: x = []; x.length = undefined throw RangeError. Actual: ' + (e));
}

View File

@ -13,7 +13,7 @@ description: Change length of array
---*/
//CHECK#1
var x = [0,,2,,4];
var x = [0, , 2, , 4];
x.length = 4;
if (x[4] !== undefined) {
$ERROR('#1: x = [0,,2,,4]; x.length = 4; x[4] === undefined. Actual: ' + (x[4]));

View File

@ -14,7 +14,7 @@ description: Checking an inherited property
//CHECK#1
Array.prototype[2] = 2;
var x = [0,1];
var x = [0, 1];
x.length = 3;
if (x.hasOwnProperty('2') !== false) {
$ERROR('#1: Array.prototype[2] = 2; x = [0,1]; x.length = 3; x.hasOwnProperty(\'2\') === false. Actual: ' + (x.hasOwnProperty('2')));

View File

@ -10,21 +10,39 @@ description: Uint32 use ToNumber and ToPrimitve
//CHECK#1
var x = [];
x.length = {valueOf: function() {return 2}};
x.length = {
valueOf: function() {
return 2
}
};
if (x.length !== 2) {
$ERROR('#1: x = []; x.length = {valueOf: function() {return 2}}; x.length === 2. Actual: ' + (x.length));
}
//CHECK#2
x = [];
x.length = {valueOf: function() {return 2}, toString: function() {return 1}};
x.length = {
valueOf: function() {
return 2
},
toString: function() {
return 1
}
};
if (x.length !== 2) {
$ERROR('#0: x = []; x.length = {valueOf: function() {return 2}, toString: function() {return 1}}; x.length === 2. Actual: ' + (x.length));
}
//CHECK#3
x = [];
x.length = {valueOf: function() {return 2}, toString: function() {return {}}};
x.length = {
valueOf: function() {
return 2
},
toString: function() {
return {}
}
};
if (x.length !== 2) {
$ERROR('#3: x = []; x.length = {valueOf: function() {return 2}, toString: function() {return {}}}; x.length === 2. Actual: ' + (x.length));
}
@ -32,7 +50,14 @@ if (x.length !== 2) {
//CHECK#4
try {
x = [];
x.length = {valueOf: function() {return 2}, toString: function() {throw "error"}};
x.length = {
valueOf: function() {
return 2
},
toString: function() {
throw "error"
}
};
if (x.length !== 2) {
$ERROR('#4.1: x = []; x.length = {valueOf: function() {return 2}, toString: function() {throw "error"}}; x.length === ",". Actual: ' + (x.length));
}
@ -47,14 +72,25 @@ catch (e) {
//CHECK#5
x = [];
x.length = {toString: function() {return 1}};
x.length = {
toString: function() {
return 1
}
};
if (x.length !== 1) {
$ERROR('#5: x = []; x.length = {toString: function() {return 1}}; x.length === 1. Actual: ' + (x.length));
}
//CHECK#6
x = [];
x.length = {valueOf: function() {return {}}, toString: function() {return 1}}
x.length = {
valueOf: function() {
return {}
},
toString: function() {
return 1
}
}
if (x.length !== 1) {
$ERROR('#6: x = []; x.length = {valueOf: function() {return {}}, toString: function() {return 1}}; x.length === 1. Actual: ' + (x.length));
}
@ -62,7 +98,14 @@ if (x.length !== 1) {
//CHECK#7
try {
x = [];
x.length = {valueOf: function() {throw "error"}, toString: function() {return 1}};
x.length = {
valueOf: function() {
throw "error"
},
toString: function() {
return 1
}
};
x.length;
$ERROR('#7.1: x = []; x.length = {valueOf: function() {throw "error"}, toString: function() {return 1}}; x.length throw "error". Actual: ' + (x.length));
}
@ -75,7 +118,14 @@ catch (e) {
//CHECK#8
try {
x = [];
x.length = {valueOf: function() {return {}}, toString: function() {return {}}};
x.length = {
valueOf: function() {
return {}
},
toString: function() {
return {}
}
};
x.length;
$ERROR('#8.1: x = []; x.length = {valueOf: function() {return {}}, toString: function() {return {}}} x.length throw TypeError. Actual: ' + (x.length));
}

View File

@ -13,7 +13,7 @@ description: >
---*/
//CHECK#1
var x = [0,1,2];
var x = [0, 1, 2];
x[4294967294] = 4294967294;
x.length = 2;

View File

@ -9,33 +9,33 @@ description: >
(read-only) exists in Array.prototype (Step 5.b.iii.3.b)
---*/
Object.defineProperty(Array.prototype, "0", {
value: 100,
writable: false,
configurable: true
});
Object.defineProperty(Array.prototype, "0", {
value: 100,
writable: false,
configurable: true
});
var oldArr = [101];
var oldArr = [101];
var newArr = Array.prototype.concat.call(oldArr);
var newArr = Array.prototype.concat.call(oldArr);
var verifyValue = false;
verifyValue = newArr[0] === 101;
var verifyValue = false;
verifyValue = newArr[0] === 101;
var verifyEnumerable = false;
for (var p in newArr) {
if (p === "0" && newArr.hasOwnProperty("0")) {
verifyEnumerable = true;
}
}
var verifyEnumerable = false;
for (var p in newArr) {
if (p === "0" && newArr.hasOwnProperty("0")) {
verifyEnumerable = true;
}
}
var verifyWritable = false;
newArr[0] = 12;
verifyWritable = newArr[0] === 12;
var verifyWritable = false;
newArr[0] = 12;
verifyWritable = newArr[0] === 12;
var verifyConfigurable = false;
delete newArr[0];
verifyConfigurable = newArr.hasOwnProperty("0");
var verifyConfigurable = false;
delete newArr[0];
verifyConfigurable = newArr.hasOwnProperty("0");
assert(verifyValue, 'verifyValue !== true');
assert.sameValue(verifyConfigurable, false, 'verifyConfigurable');

View File

@ -9,35 +9,35 @@ description: >
(read-only) exists in Array.prototype (Step 5.c.i)
---*/
Object.defineProperty(Array.prototype, "0", {
value: 100,
writable: false,
configurable: true
});
Object.defineProperty(Array.prototype, "0", {
value: 100,
writable: false,
configurable: true
});
var newArr = Array.prototype.concat.call(101);
var newArr = Array.prototype.concat.call(101);
var hasProperty = newArr.hasOwnProperty("0");
var hasProperty = newArr.hasOwnProperty("0");
var instanceOfVerify = typeof newArr[0]==="object";
var instanceOfVerify = typeof newArr[0] === "object";
var verifyValue = false;
verifyValue = newArr[0] == 101;
var verifyValue = false;
verifyValue = newArr[0] == 101;
var verifyEnumerable = false;
for (var p in newArr) {
if (p === "0" && newArr.hasOwnProperty("0")) {
verifyEnumerable = true;
}
}
var verifyEnumerable = false;
for (var p in newArr) {
if (p === "0" && newArr.hasOwnProperty("0")) {
verifyEnumerable = true;
}
}
var verifyWritable = false;
newArr[0] = 12;
verifyWritable = newArr[0] === 12;
var verifyWritable = false;
newArr[0] = 12;
verifyWritable = newArr[0] === 12;
var verifyConfigurable = false;
delete newArr[0];
verifyConfigurable = newArr.hasOwnProperty("0");
var verifyConfigurable = false;
delete newArr[0];
verifyConfigurable = newArr.hasOwnProperty("0");
assert(hasProperty, 'hasProperty !== true');
assert(instanceOfVerify, 'instanceOfVerify !== true');

View File

@ -10,9 +10,11 @@ features: [Symbol.isConcatSpreadable]
---*/
function MyError() {}
var obj = {
"length": { toString: function() {
"length": {
toString: function() {
throw new MyError();
}, valueOf: null
},
valueOf: null
},
"1": "A",
"3": "B",

View File

@ -15,7 +15,17 @@ var obj = {
"5": "C"
};
obj[Symbol.isConcatSpreadable] = true;
obj.length = {toString: function() { return "SIX"; }, valueOf: null };
obj.length = {
toString: function() {
return "SIX";
},
valueOf: null
};
assert(compareArray([].concat(obj), []));
obj.length = {toString: null, valueOf: function() { return "SIX"; } };
obj.length = {
toString: null,
valueOf: function() {
return "SIX";
}
};
assert(compareArray([].concat(obj), []));

View File

@ -16,7 +16,12 @@ var obj = {
"5": "C"
};
obj[Symbol.isConcatSpreadable] = true;
var obj2 = { length: 3, "0": "0", "1": "1", "2": "2" };
var obj2 = {
length: 3,
"0": "0",
"1": "1",
"2": "2"
};
var arr = ["X", "Y", "Z"];
var expected = [

View File

@ -9,13 +9,21 @@ description: Array.prototype.concat array like to length throws
features: [Symbol.isConcatSpreadable]
---*/
var obj = {
"length": {valueOf: null, toString: null},
"length": {
valueOf: null,
toString: null
},
"1": "A",
"3": "B",
"5": "C"
};
obj[Symbol.isConcatSpreadable] = true;
var obj2 = { length: 3, "0": "0", "1": "1", "2": "2" };
var obj2 = {
length: 3,
"0": "0",
"1": "1",
"2": "2"
};
var arr = ["X", "Y", "Z"];
assert.throws(TypeError, function() {
Array.prototype.concat.call(obj, obj2, arr);

View File

@ -17,7 +17,12 @@ var obj = {
"5": "C"
};
obj[Symbol.isConcatSpreadable] = true;
var obj2 = { length: 3, "0": "0", "1": "1", "2": "2" };
var obj2 = {
length: 3,
"0": "0",
"1": "1",
"2": "2"
};
var arr = ["X", "Y", "Z"];
var expected = [

View File

@ -10,7 +10,9 @@ description: Array.prototype.concat holey sloppy arguments
includes: [compareArray.js]
features: [Symbol.isConcatSpreadable]
---*/
var args = (function(a) { return arguments; })(1,2,3);
var args = (function(a) {
return arguments;
})(1, 2, 3);
delete args[1];
args[Symbol.isConcatSpreadable] = true;
assert(compareArray([1, void 0, 3, 1, void 0, 3], [].concat(args, args)));

View File

@ -31,7 +31,9 @@ function concatTypedArray(type, elems, modulo) {
var expected = new Array(4000);
expected[0] = defValue;
Object.defineProperty(ta, "length", { value: 4000 });
Object.defineProperty(ta, "length", {
value: 4000
});
ta[Symbol.isConcatSpreadable] = true;
assert(compareArray([].concat(ta), expected));
}

View File

@ -13,7 +13,9 @@ function MyError() {}
var obj = {};
obj[Symbol.isConcatSpreadable] = true;
Object.defineProperty(obj, "length", {
get: function() { throw new MyError(); }
get: function() {
throw new MyError();
}
});
assert.throws(MyError, function() {

View File

@ -19,8 +19,8 @@ class NonArray {
}
}
var obj = new NonArray(1,2,3);
var obj = new NonArray(1, 2, 3);
var result = Array.prototype.concat.call(obj, 4, 5, 6);
assert.sameValue(Array, result.constructor);
assert.sameValue(result instanceof NonArray, false);
assert(compareArray(result, [obj,4,5,6]));
assert(compareArray(result, [obj, 4, 5, 6]));

View File

@ -10,9 +10,13 @@ description: Array.prototype.concat sloppy arguments throws
features: [Symbol.isConcatSpreadable]
---*/
function MyError() {}
var args = (function(a) { return arguments; })(1,2,3);
var args = (function(a) {
return arguments;
})(1, 2, 3);
Object.defineProperty(args, 0, {
get: function() { throw new MyError(); }
get: function() {
throw new MyError();
}
});
args[Symbol.isConcatSpreadable] = true;
assert.throws(MyError, function() {

View File

@ -11,9 +11,13 @@ flags: [noStrict]
includes: [compareArray.js]
features: [Symbol.isConcatSpreadable]
---*/
var args = (function(a, a, a) { return arguments; })(1,2,3);
var args = (function(a, a, a) {
return arguments;
})(1, 2, 3);
args[Symbol.isConcatSpreadable] = true;
assert(compareArray([].concat(args, args), [1, 2, 3, 1, 2, 3]));
Object.defineProperty(args, "length", { value: 6 });
Object.defineProperty(args, "length", {
value: 6
});
assert(compareArray([].concat(args), [1, 2, 3, void 0, void 0, void 0]));

View File

@ -10,9 +10,13 @@ description: Array.prototype.concat sloppy arguments
includes: [compareArray.js]
features: [Symbol.isConcatSpreadable]
---*/
var args = (function(a, b, c) { return arguments; })(1,2,3);
var args = (function(a, b, c) {
return arguments;
})(1, 2, 3);
args[Symbol.isConcatSpreadable] = true;
assert(compareArray([].concat(args, args), [1, 2, 3, 1, 2, 3]));
Object.defineProperty(args, "length", { value: 6 });
Object.defineProperty(args, "length", {
value: 6
});
assert(compareArray([].concat(args), [1, 2, 3, void 0, void 0, void 0]));

View File

@ -31,7 +31,9 @@ function concatTypedArray(type, elems, modulo) {
var expected = new Array(4000);
expected[0] = defValue;
Object.defineProperty(ta, "length", { value: 4000 });
Object.defineProperty(ta, "length", {
value: 4000
});
ta[Symbol.isConcatSpreadable] = true;
assert(compareArray([].concat(ta), expected));
}

View File

@ -27,7 +27,7 @@ Boolean.prototype[0] = 1;
Boolean.prototype[1] = 2;
Boolean.prototype[2] = 3;
Boolean.prototype.length = 3;
assert(compareArray([1,2,3], [].concat(new Boolean(true))));
assert(compareArray([1, 2, 3], [].concat(new Boolean(true))));
// Boolean values are never concat-spreadable
assert(compareArray([true], [].concat(true)));

View File

@ -21,11 +21,11 @@ assert(compareArray([1, 2, 3], [].concat(fn)));
Function.prototype[Symbol.isConcatSpreadable] = true;
// Functions may be concat-spreadable
assert(compareArray([void 0, void 0, void 0], [].concat(function(a,b,c) {})));
assert(compareArray([void 0, void 0, void 0], [].concat(function(a, b, c) {})));
Function.prototype[0] = 1;
Function.prototype[1] = 2;
Function.prototype[2] = 3;
assert(compareArray([1,2,3], [].concat(function(a, b, c) {})));
assert(compareArray([1, 2, 3], [].concat(function(a, b, c) {})));
delete Function.prototype[Symbol.isConcatSpreadable];
delete Function.prototype[0];

View File

@ -12,7 +12,9 @@ features: [Symbol.isConcatSpreadable]
function MyError() {}
var obj = {};
Object.defineProperty(obj, Symbol.isConcatSpreadable, {
get: function() { throw new MyError(); }
get: function() {
throw new MyError();
}
});
assert.throws(MyError, function() {

View File

@ -27,7 +27,7 @@ Number.prototype[0] = 1;
Number.prototype[1] = 2;
Number.prototype[2] = 3;
Number.prototype.length = 3;
assert(compareArray([1,2,3], [].concat(new Number(123))));
assert(compareArray([1, 2, 3], [].concat(new Number(123))));
// Number values are never concat-spreadable
assert(compareArray([true], [].concat(true)));

View File

@ -27,7 +27,7 @@ assert(compareArray([].concat(/abc/), [void 0, void 0, void 0]));
RegExp.prototype[0] = 1;
RegExp.prototype[1] = 2;
RegExp.prototype[2] = 3;
assert(compareArray([].concat(/abc/), [1,2,3]));
assert(compareArray([].concat(/abc/), [1, 2, 3]));
delete RegExp.prototype[Symbol.isConcatSpreadable];
delete RegExp.prototype[0];

View File

@ -10,7 +10,9 @@ description: Array.prototype.concat Symbol.isConcatSpreadable sparse object
includes: [compareArray.js]
features: [Symbol.isConcatSpreadable]
---*/
var obj = { length: 5 };
var obj = {
length: 5
};
obj[Symbol.isConcatSpreadable] = true;
assert(compareArray([void 0, void 0, void 0, void 0, void 0], [].concat(obj)));

View File

@ -10,9 +10,14 @@ description: Array.prototype.concat strict arguments
includes: [compareArray.js]
features: [Symbol.isConcatSpreadable]
---*/
var args = (function(a, b, c) { "use strict"; return arguments; })(1,2,3);
var args = (function(a, b, c) {
"use strict";
return arguments;
})(1, 2, 3);
args[Symbol.isConcatSpreadable] = true;
assert(compareArray([].concat(args, args), [1, 2, 3, 1, 2, 3]));
Object.defineProperty(args, "length", { value: 6 });
Object.defineProperty(args, "length", {
value: 6
});
assert(compareArray([].concat(args), [1, 2, 3, void 0, void 0, void 0]));

View File

@ -12,9 +12,9 @@ description: Checking this algorithm, items are Array object
---*/
var x = new Array();
var y = new Array(0,1);
var z = new Array(2,3,4);
var arr = x.concat(y,z);
var y = new Array(0, 1);
var z = new Array(2, 3, 4);
var arr = x.concat(y, z);
//CHECK#0
arr.getClass = Object.prototype.toString;

View File

@ -13,8 +13,8 @@ description: Checking this algorithm, items are objects and primitives
var x = [0];
var y = new Object();
var z = new Array(1,2);
var arr = x.concat(y,z, -1, true, "NaN");
var z = new Array(1, 2);
var arr = x.concat(y, z, -1, true, "NaN");
//CHECK#0
arr.getClass = Object.prototype.toString;

View File

@ -11,7 +11,7 @@ es5id: 15.4.4.4_A1_T3
description: Checking this algorithm with no items
---*/
var x = [0,1];
var x = [0, 1];
var arr = x.concat();
//CHECK#0

View File

@ -11,8 +11,8 @@ es5id: 15.4.4.4_A1_T4
description: Checking this algorithm, items are [], [,]
---*/
var x = [,1];
var arr = x.concat([], [,]);
var x = [, 1];
var arr = x.concat([], [, ]);
//CHECK#0
arr.getClass = Object.prototype.toString;

View File

@ -13,8 +13,8 @@ description: Checking this for Object object, items are objects and primitives
var x = {};
x.concat = Array.prototype.concat;
var y = new Object();
var z = new Array(1,2);
var arr = x.concat(y,z, -1, true, "NaN");
var z = new Array(1, 2);
var arr = x.concat(y, z, -1, true, "NaN");
//CHECK#0
arr.getClass = Object.prototype.toString;

View File

@ -33,7 +33,9 @@ if (arr.hasOwnProperty('1') !== true) {
Object.prototype[1] = 1;
Object.prototype.length = 2;
Object.prototype.concat = Array.prototype.concat;
x = {0:0};
x = {
0: 0
};
var arr = x.concat();
//CHECK#4

Some files were not shown because too many files have changed in this diff Show More