add esid to array/prototype/sort tests

This commit is contained in:
deathbearbrown 2017-06-30 14:08:13 -07:00 committed by Rick Waldron
parent 474237a725
commit 7c3675494a
23 changed files with 86 additions and 63 deletions

View File

@ -5,11 +5,12 @@
info: >
If this object does not have a property named by ToString(j),
and this object does not have a property named by ToString(k), return +0
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A1.1_T1
description: If comparefn is undefined, use SortCompare operator
---*/
var x = new Array(2);
var x = new Array(2);
x.sort();
//CHECK#1
@ -20,7 +21,7 @@ if (x.length !== 2) {
//CHECK#2
if (x[0] !== undefined) {
$ERROR('#2: var x = new Array(2); x.sort(); x[0] === undefined. Actual: ' + (x[0]));
}
}
//CHECK#3
if (x[1] !== undefined) {

View File

@ -6,12 +6,13 @@ info: >
If this object does not have a property named by
ToString(j), return 1. If this object does not have a property
named by ToString(k), return -1
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A1.2_T1
description: If comparefn is undefined, use SortCompare operator
---*/
var x = new Array(2);
x[1] = 1;
x[1] = 1;
x.sort();
//CHECK#1
@ -22,7 +23,7 @@ if (x.length !== 2) {
//CHECK#2
if (x[0] !== 1) {
$ERROR('#2: var x = new Array(2); x[1] = 1; x.sort(); x[0] === 1. Actual: ' + (x[0]));
}
}
//CHECK#3
if (x[1] !== undefined) {
@ -30,7 +31,7 @@ if (x[1] !== undefined) {
}
var x = new Array(2);
x[0] = 1;
x[0] = 1;
x.sort();
//CHECK#4
@ -41,7 +42,7 @@ if (x.length !== 2) {
//CHECK#5
if (x[0] !== 1) {
$ERROR('#5: var x = new Array(2); x[0] = 1; x.sort(); x[0] === 1. Actual: ' + (x[0]));
}
}
//CHECK#6
if (x[1] !== undefined) {

View File

@ -6,18 +6,19 @@ info: >
If this object does not have a property named by
ToString(j), return 1. If this object does not have a property
named by ToString(k), return -1
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A1.2_T2
description: If comparefn is not undefined
---*/
var myComparefn = function(x,y) {
if (x === undefined) return -1;
if (x === undefined) return -1;
if (y === undefined) return 1;
return 0;
}
var x = new Array(2);
x[1] = 1;
x[1] = 1;
x.sort(myComparefn);
//CHECK#1
@ -28,7 +29,7 @@ if (x.length !== 2) {
//CHECK#2
if (x[0] !== 1) {
$ERROR('#2: var x = new Array(2); x[1] = 1; x.sort(myComparefn); x[0] === 1. Actual: ' + (x[0]));
}
}
//CHECK#3
if (x[1] !== undefined) {
@ -36,7 +37,7 @@ if (x[1] !== undefined) {
}
var x = new Array(2);
x[0] = 1;
x[0] = 1;
x.sort(myComparefn);
//CHECK#4
@ -47,7 +48,7 @@ if (x.length !== 2) {
//CHECK#5
if (x[0] !== 1) {
$ERROR('#5: var x = new Array(2); x[0] = 1; x.sort(myComparefn); x[0] === 1. Actual: ' + (x[0]));
}
}
//CHECK#6
if (x[1] !== undefined) {

View File

@ -5,11 +5,12 @@
info: >
If [[Get]] ToString(j) and [[Get]] ToString(k)
are both undefined, return +0
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A1.3_T1
description: If comparefn is undefined, use SortCompare operator
---*/
var x = new Array(undefined, undefined);
var x = new Array(undefined, undefined);
x.sort();
//CHECK#1
@ -20,7 +21,7 @@ if (x.length !== 2) {
//CHECK#2
if (x[0] !== undefined) {
$ERROR('#2: var x = new Array(undefined, undefined); x.sort(); x[0] === undefined. Actual: ' + (x[0]));
}
}
//CHECK#3
if (x[1] !== undefined) {

View File

@ -5,6 +5,7 @@
info: >
If [[Get]] ToString(j) is undefined, return 1.
If [[]Get] ToString(k) is undefined, return -1
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A1.4_T1
description: If comparefn is undefined, use SortCompare operator
---*/
@ -20,7 +21,7 @@ if (x.length !== 2) {
//CHECK#2
if (x[0] !== 1) {
$ERROR('#2: var x = new Array(undefined, 1); x.sort(); x[0] === 1. Actual: ' + (x[0]));
}
}
//CHECK#3
if (x[1] !== undefined) {
@ -38,7 +39,7 @@ if (x.length !== 2) {
//CHECK#5
if (x[0] !== 1) {
$ERROR('#5: var x = new Array(1, undefined); x.sort(); x[0] === 1. Actual: ' + (x[0]));
}
}
//CHECK#6
if (x[1] !== undefined) {

View File

@ -5,12 +5,13 @@
info: >
If [[Get]] ToString(j) is undefined, return 1.
If [[]Get] ToString(k) is undefined, return -1
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A1.4_T2
description: If comparefn is not undefined
---*/
var myComparefn = function(x,y) {
if (x === undefined) return -1;
if (x === undefined) return -1;
if (y === undefined) return 1;
return 0;
}
@ -26,7 +27,7 @@ if (x.length !== 2) {
//CHECK#2
if (x[0] !== 1) {
$ERROR('#2: var x = new Array(undefined, 1); x.sort(myComparefn); x[0] === 1. Actual: ' + (x[0]));
}
}
//CHECK#3
if (x[1] !== undefined) {
@ -44,7 +45,7 @@ if (x.length !== 2) {
//CHECK#5
if (x[0] !== 1) {
$ERROR('#5: var x = new Array(1, undefined); x.sort(myComparefn); x[0] === 1. Actual: ' + (x[0]));
}
}
//CHECK#6
if (x[1] !== undefined) {

View File

@ -3,6 +3,7 @@
/*---
info: If comparefn is undefined, use SortCompare operator
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A1.5_T1
description: Checking sort() and sort(undefined)
---*/
@ -18,7 +19,7 @@ if (x.length !== 2) {
//CHECK#2
if (x[0] !== 0) {
$ERROR('#2: var x = new Array(1,0); x.sort(); x[0] === 0. Actual: ' + (x[0]));
}
}
//CHECK#3
if (x[1] !== 1) {
@ -36,7 +37,7 @@ if (x.length !== 2) {
//CHECK#5
if (x[0] !== 0) {
$ERROR('#5: var x = new Array(1,0); x.sort(undefined); x[0] === 0. Actual: ' + (x[0]));
}
}
//CHECK#6
if (x[1] !== 1) {

View File

@ -6,6 +6,7 @@ info: >
If ToString([[Get]] ToString(j)) < ToString([[Get]] ToString(k)), return -1.
If ToString([[Get]] ToString(j)) > ToString([[Get]] ToString(k)), return 1;
return -1
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A2.1_T1
description: Checking ENGLISH ALPHABET
---*/

View File

@ -6,6 +6,7 @@ info: >
If ToString([[Get]] ToString(j)) < ToString([[Get]] ToString(k)), return -1.
If ToString([[Get]] ToString(j)) > ToString([[Get]] ToString(k)), return 1;
return -1
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A2.1_T2
description: Checking RUSSIAN ALPHABET
---*/

View File

@ -6,21 +6,22 @@ info: >
If ToString([[Get]] ToString(j)) < ToString([[Get]] ToString(k)), return -1.
If ToString([[Get]] ToString(j)) > ToString([[Get]] ToString(k)), return 1;
return -1
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A2.1_T3
description: Checking ToString operator
---*/
var obj = {valueOf: function() {return 1}, toString: function() {return -2}};
var alphabetR = [undefined, 2, 1, "X", -1, "a", true, obj, NaN, Infinity];
var alphabetR = [undefined, 2, 1, "X", -1, "a", true, obj, NaN, Infinity];
var alphabet = [-1, obj, 1, 2, Infinity, NaN, "X", "a", true, undefined];
//CHECK#1
alphabetR.sort();
var result = true;
for (var i = 0; i < 10; i++) {
if (!(isNaN(alphabetR[i]) && isNaN(alphabet[i]))) {
if (!(isNaN(alphabetR[i]) && isNaN(alphabet[i]))) {
if (alphabetR[i] !== alphabet[i]) result = false;
}
}
}
if (result !== true) {

View File

@ -3,6 +3,7 @@
/*---
info: My comparefn is inverse implementation comparefn
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A2.2_T1
description: Checking ENGLISH ALPHABET
---*/
@ -14,7 +15,7 @@ var myComparefn = function(x,y) {
var xS = String(x);
var yS = String(y);
if (xS < yS) return 1
if (xS > yS) return -1;
if (xS > yS) return -1;
return 0;
}

View File

@ -3,6 +3,7 @@
/*---
info: My comparefn is inverse implementation comparefn
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A2.2_T2
description: Checking RUSSIAN ALPHABET
---*/
@ -14,7 +15,7 @@ var myComparefn = function(x,y) {
var xS = String(x);
var yS = String(y);
if (xS < yS) return 1
if (xS > yS) return -1;
if (xS > yS) return -1;
return 0;
}

View File

@ -3,29 +3,30 @@
/*---
info: My comparefn is inverse implementation comparefn
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A2.2_T3
description: Checking ToString operator
---*/
var obj = {valueOf: function() {return 1}, toString: function() {return -2}};
var alphabetR = [undefined, 2, 1, "X", -1, "a", true, obj, NaN, Infinity];
var obj = {valueOf: function() {return 1}, toString: function() {return -2}};
var alphabetR = [undefined, 2, 1, "X", -1, "a", true, obj, NaN, Infinity];
var alphabet = [true, "a", "X", NaN, Infinity, 2, 1, obj, -1, undefined];
var myComparefn = function(x,y) {
var xS = String(x);
var yS = String(y);
if (xS < yS) return 1
if (xS > yS) return -1;
if (xS > yS) return -1;
return 0;
}
//CHECK#1
alphabetR.sort(myComparefn);
var result = true;
for (var i = 0; i < 10; i++) {
if (!(isNaN(alphabetR[i]) && isNaN(alphabet[i]))) {
if (!(isNaN(alphabetR[i]) && isNaN(alphabet[i]))) {
if (alphabetR[i] !== alphabet[i]) result = false;
}
}
}
if (result !== true) {

View File

@ -5,16 +5,17 @@
info: >
The sort function is intentionally generic.
It does not require that its this value be an Array object
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A3_T1
description: If comparefn is undefined, use SortCompare operator
---*/
var obj = {valueOf: function() {return 1}, toString: function() {return -2}};
var alphabetR = {0:undefined, 1:2, 2:1, 3:"X", 4:-1, 5:"a", 6:true, 7:obj, 8:NaN, 9:Infinity};
alphabetR.sort = Array.prototype.sort;
alphabetR.sort = Array.prototype.sort;
alphabetR.length = 10;
var alphabet = [-1, obj, 1, 2, Infinity, NaN, "X", "a", true, undefined];
alphabetR.sort();
//CHECK#0
@ -22,13 +23,13 @@ alphabetR.getClass = Object.prototype.toString;
if (alphabetR.getClass() !== "[object " + "Object" + "]") {
$ERROR('#0: alphabetR.sort() is Object object, not Array object');
}
//CHECK#1
var result = true;
for (var i = 0; i < 10; i++) {
if (!(isNaN(alphabetR[i]) && isNaN(alphabet[i]))) {
if (!(isNaN(alphabetR[i]) && isNaN(alphabet[i]))) {
if (alphabetR[i] !== alphabet[i]) result = false;
}
}
}
if (result !== true) {

View File

@ -5,24 +5,25 @@
info: >
The sort function is intentionally generic.
It does not require that its this value be an Array object
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A3_T2
description: If comparefn is not undefined
---*/
var obj = {valueOf: function() {return 1}, toString: function() {return -2}};
var alphabetR = {0:undefined, 1:2, 2:1, 3:"X", 4:-1, 5:"a", 6:true, 7:obj, 8:NaN, 9:Infinity};
alphabetR.sort = Array.prototype.sort;
alphabetR.length = 10;
alphabetR.sort = Array.prototype.sort;
alphabetR.length = 10;
var alphabet = [true, "a", "X", NaN, Infinity, 2, 1, obj, -1, undefined];
var myComparefn = function(x,y) {
var xS = String(x);
var yS = String(y);
if (xS < yS) return 1
if (xS > yS) return -1;
if (xS > yS) return -1;
return 0;
}
alphabetR.sort(myComparefn);
//CHECK#0
@ -30,13 +31,13 @@ alphabetR.getClass = Object.prototype.toString;
if (alphabetR.getClass() !== "[object " + "Object" + "]") {
$ERROR('#0: alphabetR.sort() is Object object, not Array object');
}
//CHECK#1
var result = true;
for (var i = 0; i < 10; i++) {
if (!(isNaN(alphabetR[i]) && isNaN(alphabet[i]))) {
if (!(isNaN(alphabetR[i]) && isNaN(alphabet[i]))) {
if (alphabetR[i] !== alphabet[i]) result = false;
}
}
}
if (result !== true) {

View File

@ -3,6 +3,7 @@
/*---
info: Check ToLength(length) for non Array objects
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A4_T3
description: length = -4294967294
---*/
@ -27,12 +28,12 @@ if (obj.length !== -4294967294) {
//CHECK#3
if (obj[0] !== "z") {
$ERROR('#3: var obj = {}; obj.sort = Array.prototype.sort; obj[0] = "z"; obj[1] = "y"; obj[2] = "x"; obj.length = -4294967294; obj.sort(); obj[0] === "z". Actual: ' + (obj[0]));
}
}
//CHECK#4
if (obj[1] !== "y") {
$ERROR('#4: var obj = {}; obj.sort = Array.prototype.sort; obj[0] = "z"; obj[1] = "y"; obj[2] = "x"; obj.length = -4294967294; obj.sort(); obj[1] === "y". Actual: ' + (obj[1]));
}
}
//CHECK#5
if (obj[2] !== "x") {

View File

@ -3,6 +3,7 @@
/*---
info: Array.sort should not eat exceptions
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A5_T1
description: comparefn function throw "error"
---*/

View File

@ -3,6 +3,7 @@
/*---
info: "[[Get]], [[Delete]] from not an inherited property"
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A6_T2
description: >
[[Prototype]] of Array instance is Array.prototype, [[Prototype]
@ -15,25 +16,25 @@ x.length = 2;
x.sort();
//CHECK#1
if (x[0] !== 0) {
$ERROR('#1: Array.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x[0] === 0. Actual: ' + (x[0]));
if (x[0] !== 0) {
$ERROR('#1: Array.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x[0] === 0. Actual: ' + (x[0]));
}
//CHECK#2
if (x[1] !== 1) {
$ERROR('#2: Array.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x[1] === 1. Actual: ' + (x[1]));
if (x[1] !== 1) {
$ERROR('#2: Array.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x[1] === 1. Actual: ' + (x[1]));
}
x.length = 0;
//CHECK#3
if (x[0] !== undefined) {
$ERROR('#3: Array.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x.length = 0; x[0] === undefined. Actual: ' + (x[0]));
if (x[0] !== undefined) {
$ERROR('#3: Array.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x.length = 0; x[0] === undefined. Actual: ' + (x[0]));
}
//CHECK#4
if (x[1] !== -1) {
$ERROR('#4: Array.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x.length = 0; x[1] === -1. Actual: ' + (x[1]));
if (x[1] !== -1) {
$ERROR('#4: Array.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x.length = 0; x[1] === -1. Actual: ' + (x[1]));
}
Object.prototype[1] = -1;
@ -43,24 +44,24 @@ x = {0:1,1:0};
x.sort();
//CHECK#5
if (x[0] !== 0) {
$ERROR('#5: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.sort = Array.prototype.sort; x = {0:1,1:0}; x.sort(); x[0] === 0. Actual: ' + (x[0]));
if (x[0] !== 0) {
$ERROR('#5: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.sort = Array.prototype.sort; x = {0:1,1:0}; x.sort(); x[0] === 0. Actual: ' + (x[0]));
}
//CHECK#6
if (x[1] !== 1) {
$ERROR('#6: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.sort = Array.prototype.sort; x = {0:1,1:0}; x.sort(); x[1] === 1. Actual: ' + (x[1]));
if (x[1] !== 1) {
$ERROR('#6: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.sort = Array.prototype.sort; x = {0:1,1:0}; x.sort(); x[1] === 1. Actual: ' + (x[1]));
}
delete x[0];
delete x[1];
//CHECK#7
if (x[0] !== undefined) {
$ERROR('#7: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.sort = Array.prototype.sort; x = {0:1,1:0}; x.sort(); delete x[0]; delete x[1]; x[0] === undefined. Actual: ' + (x[0]));
if (x[0] !== undefined) {
$ERROR('#7: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.sort = Array.prototype.sort; x = {0:1,1:0}; x.sort(); delete x[0]; delete x[1]; x[0] === undefined. Actual: ' + (x[0]));
}
//CHECK#8
if (x[1] !== -1) {
$ERROR('#8: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.sort = Array.prototype.sort; x = {0:1,1:0}; x.sort(); delete x[0]; delete x[1]; x[1] === -1. Actual: ' + (x[1]));
if (x[1] !== -1) {
$ERROR('#8: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.sort = Array.prototype.sort; x = {0:1,1:0}; x.sort(); delete x[0]; delete x[1]; x[1] === -1. Actual: ' + (x[1]));
}

View File

@ -3,6 +3,7 @@
/*---
info: The sort property of Array can't be used as constructor
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A7.7
description: >
If property does not implement the internal [[Construct]] method,

View File

@ -3,6 +3,7 @@
/*---
info: Call the comparefn passing undefined as the this value (step 13b)
esid: sec-array.prototype.sort
es5id: 15.4.4.11_A8
description: comparefn tests that its this value is undefined
flags: [noStrict]

View File

@ -2,6 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.prototype.sort
description: >
The SortCompare abstract operation calls ToString() for identical
elements (step 14/15)

View File

@ -2,6 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.prototype.sort
description: >
Array.prototype.sort does not change non-existent elements to
undefined elements, that means holes are preserved (cf. spec text

View File

@ -2,6 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.prototype.sort
es6id: 22.1.3.24
description: >
Array.prototype.sort.name is "sort".