add esid to array/prototype/push tests (#1116)

This commit is contained in:
Sue Lockwood 2017-06-30 07:42:59 -07:00 committed by Leo Balter
parent d6b492205d
commit 5ff6550197
12 changed files with 50 additions and 38 deletions

View File

@ -6,6 +6,7 @@ info: >
The arguments are appended to the end of the array, in
the order in which they appear. The new length of the array is returned
as the result of the call
esid: sec-array.prototype.push
es5id: 15.4.4.7_A1_T1
description: Checking case when push is given no arguments or one argument
---*/
@ -15,7 +16,7 @@ var x = new Array();
var push = x.push(1);
if (push !== 1) {
$ERROR('#1: x = new Array(); x.push(1) === 1. Actual: ' + (push));
}
}
//CHECK#2
if (x[0] !== 1) {

View File

@ -6,6 +6,7 @@ info: >
The arguments are appended to the end of the array, in
the order in which they appear. The new length of the array is returned
as the result of the call
esid: sec-array.prototype.push
es5id: 15.4.4.7_A1_T2
description: Checking case when push is given many arguments
---*/
@ -21,7 +22,7 @@ x[0] = 0;
var push = x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1);
if (push !== 6) {
$ERROR('#2: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1) === 6. Actual: ' + (push));
}
}
//CHECK#3
if (x[0] !== 0) {
@ -36,12 +37,12 @@ if (x[1] !== true) {
//CHECK#5
if (x[2] !== Number.POSITIVE_INFINITY) {
$ERROR('#5: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[2] === Number.POSITIVE_INFINITY. Actual: ' + (x[2]));
}
}
//CHECK#6
if (x[3] !== "NaN") {
$ERROR('#6: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[3] === "NaN". Actual: ' + (x[3]));
}
}
//CHECK#7
if (x[4] !== "1") {

View File

@ -5,6 +5,7 @@
info: >
The push function is intentionally generic.
It does not require that its this value be an Array object
esid: sec-array.prototype.push
es5id: 15.4.4.7_A2_T1
description: >
The arguments are appended to the end of the array, in the order
@ -18,7 +19,7 @@ obj.push = Array.prototype.push;
if (obj.length !== undefined) {
$ERROR('#0: var obj = {}; obj.length === undefined. Actual: ' + (obj.length));
} else {
//CHECK#1
//CHECK#1
var push = obj.push(-1);
if (push !== 1) {
$ERROR('#1: var obj = {}; obj.push = Array.prototype.push; obj.push(-1) === 1. Actual: ' + (push));
@ -31,14 +32,14 @@ if (push !== 1) {
if (obj["0"] !== -1) {
$ERROR('#3: var obj = {}; obj.push = Array.prototype.push; obj.push(-1); obj["0"] === -1. Actual: ' + (obj["0"]));
}
}
}
//CHECK#4
obj.length = undefined;
var push = obj.push(-4);
if (push !== 1) {
$ERROR('#4: var obj = {}; obj.length = undefined; obj.push = Array.prototype.push; obj.push(-4) === 1. Actual: ' + (push));
}
}
//CHECK#5
if (obj.length !== 1) {
@ -55,7 +56,7 @@ obj.length = null
var push = obj.push(-7);
if (push !== 1) {
$ERROR('#7: var obj = {}; obj.length = null; obj.push = Array.prototype.push; obj.push(-7) === 1. Actual: ' + (push));
}
}
//CHECK#8
if (obj.length !== 1) {

View File

@ -5,6 +5,7 @@
info: >
The push function is intentionally generic.
It does not require that its this value be an Array object
esid: sec-array.prototype.push
es5id: 15.4.4.7_A2_T2
description: >
The arguments are appended to the end of the array, in the order
@ -73,7 +74,7 @@ if (push !== 1) {
//CHECK#11
if (obj.length !== 1) {
$ERROR('#11: var obj = {}; obj.length = 0.5; obj.push = Array.prototype.push; obj.push(-10); obj.length === 1. Actual: ' + (obj.length));
}
}
//CHECK#12
if (obj["0"] !== -10) {
@ -90,7 +91,7 @@ if (push !== 2) {
//CHECK#14
if (obj.length !== 2) {
$ERROR('#14: var obj = {}; obj.length = 1.5; obj.push = Array.prototype.push; obj.push(-13); obj.length === 2. Actual: ' + (obj.length));
}
}
//CHECK#15
if (obj["1"] !== -13) {

View File

@ -5,6 +5,7 @@
info: >
The push function is intentionally generic.
It does not require that its this value be an Array object
esid: sec-array.prototype.push
es5id: 15.4.4.7_A2_T3
description: >
Operator use ToNumber from length. If Type(value) is Object,
@ -26,7 +27,7 @@ obj.length = {valueOf: function() {return 3}, toString: function() {return 1}};
var push = obj.push();
if (push !== 3) {
$ERROR('#0: obj.length = {valueOf: function() {return 3}, toString: function() {return 1}} obj.push() === 3. Actual: ' + (push));
}
}
//CHECK#3
obj.length = {valueOf: function() {return 3}, toString: function() {return {}}};
@ -36,9 +37,9 @@ if (push !== 3) {
}
//CHECK#4
try {
obj.length = {valueOf: function() {return 3}, toString: function() {throw "error"}};
try {
obj.length = {valueOf: function() {return 3}, toString: function() {throw "error"}};
var push = obj.push();
if (push !== 3) {
$ERROR('#4.1: obj.length = {valueOf: function() {return 3}, toString: function() {throw "error"}}; obj.push() === ",". Actual: ' + (push));
@ -68,26 +69,26 @@ if (push !== 1) {
//CHECK#7
try {
obj.length = {valueOf: function() {throw "error"}, toString: function() {return 1}};
obj.length = {valueOf: function() {throw "error"}, toString: function() {return 1}};
var push = obj.push();
$ERROR('#7.1: obj.length = {valueOf: function() {throw "error"}, toString: function() {return 1}}; obj.push() throw "error". Actual: ' + (push));
}
}
catch (e) {
if (e !== "error") {
$ERROR('#7.2: obj.length = {valueOf: function() {throw "error"}, toString: function() {return 1}}; obj.push() throw "error". Actual: ' + (e));
}
}
}
//CHECK#8
try {
obj.length = {valueOf: function() {return {}}, toString: function() {return {}}};
var push = obj.push();
$ERROR('#8.1: obj.length = {valueOf: function() {return {}}, toString: function() {return {}}} obj.push() throw TypeError. Actual: ' + (push));
}
}
catch (e) {
if ((e instanceof TypeError) !== true) {
$ERROR('#8.2: obj.length = {valueOf: function() {return {}}, toString: function() {return {}}} obj.push() throw TypeError. Actual: ' + (e));
}
}
}

View File

@ -3,6 +3,7 @@
/*---
info: Check ToLength(length) for Array object
esid: sec-array.prototype.push
es5id: 15.4.4.7_A3
description: If ToUint32(length) !== length, throw RangeError
---*/

View File

@ -3,6 +3,7 @@
/*---
info: Check ToLength(length) for non Array objects
esid: sec-array.prototype.push
es5id: 15.4.4.7_A4_T1
description: length = 4294967296
---*/
@ -30,12 +31,12 @@ if (obj[0] !== undefined) {
//CHECK#4
if (obj[1] !== undefined) {
$ERROR('#4: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[1] === undefined. Actual: ' + (obj[1]));
}
}
//CHECK#5
if (obj[2] !== undefined) {
$ERROR('#5: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[2] === undefined. Actual: ' + (obj[2]));
}
}
//CHECK#6
if (obj[4294967296] !== "x") {
@ -45,12 +46,12 @@ if (obj[4294967296] !== "x") {
//CHECK#7
if (obj[4294967297] !== "y") {
$ERROR('#7: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[4294967297] === "y". Actual: ' + (obj[4294967297]));
}
}
//CHECK#8
if (obj[4294967298] !== "z") {
$ERROR('#8: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[4294967298] === "z". Actual: ' + (obj[4294967298]));
}
}
var obj = {};
obj.push = Array.prototype.push;

View File

@ -3,6 +3,7 @@
/*---
info: Check ToLength(length) for non Array objects
esid: sec-array.prototype.push
es5id: 15.4.4.7_A4_T2
description: length = 4294967295
---*/
@ -30,7 +31,7 @@ if (obj[4294967295] !== "x") {
//CHECK#4
if (obj[4294967296] !== "y") {
$ERROR('#4: var obj = {}; obj.push = Array.prototype.push; obj.length = 4294967295; obj.push("x", "y", "z"); obj[4294967296] === "y". Actual: ' + (obj[4294967296]));
}
}
//CHECK#5
if (obj[4294967297] !== "z") {

View File

@ -3,6 +3,7 @@
/*---
info: Check ToLength(length) for non Array objects
esid: sec-array.prototype.push
es5id: 15.4.4.7_A4_T3
description: length = -1
---*/
@ -30,12 +31,12 @@ if (obj[4294967295] !== undefined) {
//CHECK#4
if (obj[4294967296] !== undefined) {
$ERROR('#4: var obj = {}; obj.push = Array.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[4294967296] === undefined. Actual: ' + (obj[4294967296]));
}
}
//CHECK#5
if (obj[4294967297] !== undefined) {
$ERROR('#5: var obj = {}; obj.push = Array.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[4294967297] === undefined. Actual: ' + (obj[4294967297]));
}
}
//CHECK#6
if (obj[0] !== "x") {

View File

@ -3,6 +3,7 @@
/*---
info: "[[Get]] from not an inherited property"
esid: sec-array.prototype.push
es5id: 15.4.4.7_A5_T1
description: >
[[Prototype]] of Array instance is Array.prototype, [[Prototype]
@ -16,28 +17,28 @@ var x = {0:0};
//CHECK#1
var push = x.push(1);
if (push !== 2) {
$ERROR('#1: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = Array.prototype.push; x = {0:0}; x.push(1) === 2. Actual: ' + (push));
if (push !== 2) {
$ERROR('#1: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = Array.prototype.push; x = {0:0}; x.push(1) === 2. Actual: ' + (push));
}
//CHECK#2
if (x.length !== 2) {
$ERROR('#2: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = Array.prototype.push; x = {0:0}; x.push(1); x.length === 2. Actual: ' + (x.length));
if (x.length !== 2) {
$ERROR('#2: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = Array.prototype.push; x = {0:0}; x.push(1); x.length === 2. Actual: ' + (x.length));
}
//CHECK#3
if (x[1] !== 1) {
$ERROR('#3: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = Array.prototype.push; x = {0:0}; x.push(1); x[1] === 1. Actual: ' + (x[1]));
if (x[1] !== 1) {
$ERROR('#3: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = Array.prototype.push; x = {0:0}; x.push(1); x[1] === 1. Actual: ' + (x[1]));
}
//CHECK#4
delete x[1];
if (x[1] !== -1) {
$ERROR('#4: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = Array.prototype.push; x = {0:0}; x.push(1); delete x[1]; x[1] === -1. Actual: ' + (x[1]));
if (x[1] !== -1) {
$ERROR('#4: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = Array.prototype.push; x = {0:0}; x.push(1); delete x[1]; x[1] === -1. Actual: ' + (x[1]));
}
//CHECK#5
delete x.length;
if (x.length !== 1) {
$ERROR('#5: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = Array.prototype.push; x = {0:0}; delete x; x.push(1); x.length === 1. Actual: ' + (x.length));
if (x.length !== 1) {
$ERROR('#5: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = Array.prototype.push; x = {0:0}; delete x; x.push(1); x.length === 1. Actual: ' + (x.length));
}

View File

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

View File

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