mirror of
https://github.com/tc39/test262.git
synced 2025-07-22 13:34:38 +02:00
Replace runTestCase with assert helpers [test/built-ins/Array/prototype/indexOf]
This commit is contained in:
parent
659aa4c0f8
commit
7510a91a7e
@ -4,13 +4,8 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-0-1
|
||||
description: Array.prototype.indexOf must exist as a function
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var f = Array.prototype.indexOf;
|
||||
if (typeof(f) === "function") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(typeof(f), "function", 'typeof(f)');
|
||||
|
@ -4,12 +4,6 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-0-2
|
||||
description: Array.prototype.indexOf has a length property whose value is 1.
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
if (Array.prototype.indexOf.length === 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.length, 1, 'Array.prototype.indexOf.length');
|
||||
|
@ -4,15 +4,10 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-1-11
|
||||
description: Array.prototype.indexOf applied to Date object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = new Date();
|
||||
obj.length = 2;
|
||||
obj[1] = true;
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
|
@ -4,15 +4,10 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-1-12
|
||||
description: Array.prototype.indexOf applied to RegExp object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = new RegExp();
|
||||
obj.length = 2;
|
||||
obj[1] = true;
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
|
@ -4,15 +4,10 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-1-14
|
||||
description: Array.prototype.indexOf applied to Error object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = new SyntaxError();
|
||||
obj[1] = true;
|
||||
obj.length = 2;
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
|
@ -4,16 +4,11 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-1-15
|
||||
description: Array.prototype.indexOf applied to Arguments object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
function fun() {
|
||||
return arguments;
|
||||
}
|
||||
var obj = fun(1, true, 3);
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
|
@ -4,15 +4,10 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-1-4
|
||||
description: Array.prototype.indexOf applied to Boolean Object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = new Boolean(false);
|
||||
obj.length = 2;
|
||||
obj[1] = true;
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
|
@ -4,15 +4,10 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-1-6
|
||||
description: Array.prototype.indexOf applied to Number object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = new Number(-3);
|
||||
obj.length = 2;
|
||||
obj[1] = true;
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
|
@ -4,13 +4,8 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-1-8
|
||||
description: Array.prototype.indexOf applied to String object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = new String("null");
|
||||
|
||||
return Array.prototype.indexOf.call(obj, 'l') === 2;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, 'l'), 2, 'Array.prototype.indexOf.call(obj, "l")');
|
||||
|
@ -4,16 +4,11 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-1-9
|
||||
description: Array.prototype.indexOf applied to Function object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = function (a, b) {
|
||||
return a + b;
|
||||
};
|
||||
obj[1] = true;
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
|
@ -6,10 +6,8 @@ es5id: 15.4.4.14-10-2
|
||||
description: >
|
||||
Array.prototype.indexOf returns -1 if 'length' is 0 and does not
|
||||
access any other properties
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var accessed = false;
|
||||
var f = {length: 0};
|
||||
Object.defineProperty(f,"0",{get: function () {accessed = true; return 1;}});
|
||||
@ -17,8 +15,6 @@ function testcase() {
|
||||
|
||||
var i = Array.prototype.indexOf.call(f,1);
|
||||
|
||||
if (i === -1 && accessed==false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(i, -1, 'i');
|
||||
assert.sameValue(accessed, false, 'accessed');
|
||||
|
@ -6,13 +6,10 @@ es5id: 15.4.4.14-2-1
|
||||
description: >
|
||||
Array.prototype.indexOf - 'length' is own data property on an
|
||||
Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var objOne = { 1: true, length: 2 };
|
||||
var objTwo = { 2: true, length: 2 };
|
||||
return Array.prototype.indexOf.call(objOne, true) === 1 &&
|
||||
Array.prototype.indexOf.call(objTwo, true) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(Array.prototype.indexOf.call(objOne, true), 1, 'Array.prototype.indexOf.call(objOne, true)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(objTwo, true), -1, 'Array.prototype.indexOf.call(objTwo, true)');
|
||||
|
@ -4,11 +4,8 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-2-10
|
||||
description: Array.prototype.indexOf - 'length' is inherited accessor property
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var proto = {};
|
||||
Object.defineProperty(proto, "length", {
|
||||
get: function () {
|
||||
@ -25,7 +22,5 @@ function testcase() {
|
||||
var childTwo = new Con();
|
||||
childTwo[2] = true;
|
||||
|
||||
return Array.prototype.indexOf.call(childOne, true) === 1 &&
|
||||
Array.prototype.indexOf.call(childTwo, true) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(childOne, true), 1, 'Array.prototype.indexOf.call(childOne, true)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(childTwo, true), -1, 'Array.prototype.indexOf.call(childTwo, true)');
|
||||
|
@ -6,17 +6,12 @@ es5id: 15.4.4.14-2-11
|
||||
description: >
|
||||
Array.prototype.indexOf - 'length' is own accessor property
|
||||
without a get function
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 1: true };
|
||||
Object.defineProperty(obj, "length", {
|
||||
set: function () { },
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-2-13
|
||||
description: >
|
||||
Array.prototype.indexOf - 'length' is inherited accessor property
|
||||
without a get function
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var proto = {};
|
||||
Object.defineProperty(proto, "length", {
|
||||
set: function () { },
|
||||
@ -23,6 +20,4 @@ function testcase() {
|
||||
var child = new Con();
|
||||
child[1] = true;
|
||||
|
||||
return Array.prototype.indexOf.call(child, true) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(child, true), -1, 'Array.prototype.indexOf.call(child, true)');
|
||||
|
@ -4,13 +4,8 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-2-14
|
||||
description: Array.prototype.indexOf - 'length' is undefined property
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: true, 1: true };
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
|
@ -6,17 +6,12 @@ es5id: 15.4.4.14-2-17
|
||||
description: >
|
||||
Array.prototype.indexOf applied to Arguments object which
|
||||
implements its own property get method
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var func = function (a, b) {
|
||||
arguments[2] = false;
|
||||
return Array.prototype.indexOf.call(arguments, true) === 1 &&
|
||||
Array.prototype.indexOf.call(arguments, false) === -1;
|
||||
};
|
||||
|
||||
return func(0, true);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert(func(0, true), 'func(0, true) !== true');
|
||||
|
@ -6,18 +6,13 @@ es5id: 15.4.4.14-2-19
|
||||
description: >
|
||||
Array.prototype.indexOf applied to Function object which
|
||||
implements its own property get method
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = function (a, b) {
|
||||
return a + b;
|
||||
};
|
||||
obj[1] = "b";
|
||||
obj[2] = "c";
|
||||
|
||||
return Array.prototype.indexOf.call(obj, obj[1]) === 1 &&
|
||||
Array.prototype.indexOf.call(obj, obj[2]) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, obj[1]), 1, 'Array.prototype.indexOf.call(obj, obj[1])');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, obj[2]), -1, 'Array.prototype.indexOf.call(obj, obj[2])');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-2-3
|
||||
description: >
|
||||
Array.prototype.indexOf - 'length' is own data property that
|
||||
overrides an inherited data property on an Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var proto = { length: 0 };
|
||||
|
||||
var Con = function () {};
|
||||
@ -20,6 +17,4 @@ function testcase() {
|
||||
child.length = 2;
|
||||
child[1] = true;
|
||||
|
||||
return Array.prototype.indexOf.call(child, true) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(child, true), 1, 'Array.prototype.indexOf.call(child, true)');
|
||||
|
@ -6,10 +6,8 @@ es5id: 15.4.4.14-2-5
|
||||
description: >
|
||||
Array.prototype.indexOf - 'length' is own data property that
|
||||
overrides an inherited accessor property on an Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var proto = {};
|
||||
Object.defineProperty(proto, "length", {
|
||||
get: function () {
|
||||
@ -29,6 +27,4 @@ function testcase() {
|
||||
});
|
||||
child[1] = true;
|
||||
|
||||
return Array.prototype.indexOf.call(child, true) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(child, true), 1, 'Array.prototype.indexOf.call(child, true)');
|
||||
|
@ -4,10 +4,8 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-2-6
|
||||
description: Array.prototype.indexOf - 'length' is an inherited data property
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var proto = { length: 2 };
|
||||
|
||||
var Con = function () {};
|
||||
@ -18,7 +16,5 @@ function testcase() {
|
||||
var childTwo = new Con();
|
||||
childTwo[2] = true;
|
||||
|
||||
return Array.prototype.indexOf.call(childOne, true) === 1 &&
|
||||
Array.prototype.indexOf.call(childTwo, true) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(childOne, true), 1, 'Array.prototype.indexOf.call(childOne, true)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(childTwo, true), -1, 'Array.prototype.indexOf.call(childTwo, true)');
|
||||
|
@ -4,10 +4,8 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-2-7
|
||||
description: Array.prototype.indexOf - 'length' is own accessor property
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var objOne = { 1: true };
|
||||
var objTwo = { 2: true };
|
||||
Object.defineProperty(objOne, "length", {
|
||||
@ -23,7 +21,5 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return Array.prototype.indexOf.call(objOne, true) === 1 &&
|
||||
Array.prototype.indexOf.call(objTwo, true) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(objOne, true), 1, 'Array.prototype.indexOf.call(objOne, true)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(objTwo, true), -1, 'Array.prototype.indexOf.call(objTwo, true)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-2-8
|
||||
description: >
|
||||
Array.prototype.indexOf - 'length' is own accessor property that
|
||||
overrides an inherited data property
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var proto = { length: 0 };
|
||||
|
||||
var Con = function () {};
|
||||
@ -26,6 +23,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return Array.prototype.indexOf.call(child, true) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(child, true), 1, 'Array.prototype.indexOf.call(child, true)');
|
||||
|
@ -6,10 +6,8 @@ es5id: 15.4.4.14-2-9
|
||||
description: >
|
||||
Array.prototype.indexOf - 'length' is own accessor property that
|
||||
overrides an inherited accessor property
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var proto = {};
|
||||
Object.defineProperty(proto, "length", {
|
||||
get: function () {
|
||||
@ -31,6 +29,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return Array.prototype.indexOf.call(child, true) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(child, true), 1, 'Array.prototype.indexOf.call(child, true)');
|
||||
|
@ -4,13 +4,8 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-3-1
|
||||
description: Array.prototype.indexOf - value of 'length' is undefined
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: 1, 1: 1, length: undefined };
|
||||
|
||||
return Array.prototype.indexOf.call(obj, 1) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, 1), -1, 'Array.prototype.indexOf.call(obj, 1)');
|
||||
|
@ -6,13 +6,8 @@ es5id: 15.4.4.14-3-10
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'length' is number primitive
|
||||
(value is NaN)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: 0, length: NaN };
|
||||
|
||||
return Array.prototype.indexOf.call(obj, 0) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, 0), -1, 'Array.prototype.indexOf.call(obj, 0)');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-11
|
||||
description: >
|
||||
Array.prototype.indexOf - 'length' is a string containing a
|
||||
positive number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 1: 1, 2: 2, length: "2" };
|
||||
|
||||
return Array.prototype.indexOf.call(obj, 1) === 1 &&
|
||||
Array.prototype.indexOf.call(obj, 2) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, 1), 1, 'Array.prototype.indexOf.call(obj, 1)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, 2), -1, 'Array.prototype.indexOf.call(obj, 2)');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-12
|
||||
description: >
|
||||
Array.prototype.indexOf - 'length' is a string containing a
|
||||
negative number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 1: "true", 2: "2", length: "-4294967294" };
|
||||
|
||||
return Array.prototype.indexOf.call(obj, "true") === -1 &&
|
||||
Array.prototype.indexOf.call(obj, "2") === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, "true"), -1, 'Array.prototype.indexOf.call(obj, "true")');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, "2"), -1, 'Array.prototype.indexOf.call(obj, "2")');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-13
|
||||
description: >
|
||||
Array.prototype.indexOf - 'length' is a string containing a
|
||||
decimal number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 199: true, 200: "200.59", length: "200.59" };
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === 199 &&
|
||||
Array.prototype.indexOf.call(obj, "200.59") === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), 199, 'Array.prototype.indexOf.call(obj, true)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, "200.59"), -1, 'Array.prototype.indexOf.call(obj, "200.59")');
|
||||
|
@ -6,17 +6,12 @@ es5id: 15.4.4.14-3-14
|
||||
description: >
|
||||
Array.prototype.indexOf - 'length' is a string containing
|
||||
+/-Infinity
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var objOne = { 0: true, 1: true, length: "Infinity" };
|
||||
var objTwo = { 0: true, 1: true, length: "+Infinity" };
|
||||
var objThree = { 0: true, 1: true, length: "-Infinity" };
|
||||
|
||||
return Array.prototype.indexOf.call(objOne, true) === 0 &&
|
||||
Array.prototype.indexOf.call(objTwo, true) === 0 &&
|
||||
Array.prototype.indexOf.call(objThree, true) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(objOne, true), 0, 'Array.prototype.indexOf.call(objOne, true)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(objTwo, true), 0, 'Array.prototype.indexOf.call(objTwo, true)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(objThree, true), -1, 'Array.prototype.indexOf.call(objThree, true)');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-15
|
||||
description: >
|
||||
Array.prototype.indexOf - 'length' is a string containing an
|
||||
exponential number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 1: true, 2: "2E0", length: "2E0" };
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === 1 &&
|
||||
Array.prototype.indexOf.call(obj, "2E0") === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, "2E0"), -1, 'Array.prototype.indexOf.call(obj, "2E0")');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-16
|
||||
description: >
|
||||
Array.prototype.indexOf - 'length' is a string containing a hex
|
||||
number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 10: true, 11: "0x00B", length: "0x00B" };
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === 10 &&
|
||||
Array.prototype.indexOf.call(obj, "0x00B") === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), 10, 'Array.prototype.indexOf.call(obj, true)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, "0x00B"), -1, 'Array.prototype.indexOf.call(obj, "0x00B")');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-17
|
||||
description: >
|
||||
Array.prototype.indexOf - 'length' is a string containing a number
|
||||
with leading zeros
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 1: true, 2: "0002.0", length: "0002.0" };
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === 1 &&
|
||||
Array.prototype.indexOf.call(obj, "0002.0") === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, "0002.0"), -1, 'Array.prototype.indexOf.call(obj, "0002.0")');
|
||||
|
@ -6,13 +6,8 @@ es5id: 15.4.4.14-3-18
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'length' is a string that can't
|
||||
convert to a number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: true, 100: true, length: "one" };
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-3-19
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'length' is an Object which has
|
||||
an own toString method.
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
// objects inherit the default valueOf() method from Object
|
||||
// that simply returns itself. Since the default valueOf() method
|
||||
// does not return a primitive value, ES next tries to convert the object
|
||||
@ -28,7 +25,5 @@ function testcase() {
|
||||
}
|
||||
};
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === 1 &&
|
||||
Array.prototype.indexOf.call(obj, 2) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, 2), -1, 'Array.prototype.indexOf.call(obj, 2)');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.14-3-2
|
||||
description: >
|
||||
Array.prototype.indexOf return -1 when 'length' is a boolean
|
||||
(value is true)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var obj = { 0: 0, 1: 1, length: true };
|
||||
return Array.prototype.indexOf.call(obj, 0) === 0 &&
|
||||
Array.prototype.indexOf.call(obj, 1) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, 0), 0, 'Array.prototype.indexOf.call(obj, 0)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, 1), -1, 'Array.prototype.indexOf.call(obj, 1)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-3-20
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'length' is an Object which has
|
||||
an own valueOf method.
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
//valueOf method will be invoked first, since hint is Number
|
||||
var obj = {
|
||||
1: true,
|
||||
@ -22,7 +19,5 @@ function testcase() {
|
||||
}
|
||||
};
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === 1 &&
|
||||
Array.prototype.indexOf.call(obj, 2) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, 2), -1, 'Array.prototype.indexOf.call(obj, 2)');
|
||||
|
@ -7,11 +7,8 @@ description: >
|
||||
Array.prototype.indexOf - 'length' is an object that has an own
|
||||
valueOf method that returns an object and toString method that
|
||||
returns a string
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var toStringAccessed = false;
|
||||
var valueOfAccessed = false;
|
||||
|
||||
@ -30,6 +27,6 @@ function testcase() {
|
||||
}
|
||||
};
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === 1 && toStringAccessed && valueOfAccessed;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
assert(toStringAccessed, 'toStringAccessed !== true');
|
||||
assert(valueOfAccessed, 'valueOfAccessed !== true');
|
||||
|
@ -7,11 +7,8 @@ description: >
|
||||
Array.prototype.indexOf uses inherited valueOf method when
|
||||
'length' is an object with an own toString and inherited valueOf
|
||||
methods
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var toStringAccessed = false;
|
||||
var valueOfAccessed = false;
|
||||
|
||||
@ -36,6 +33,6 @@ function testcase() {
|
||||
length: child
|
||||
};
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === 1 && valueOfAccessed && !toStringAccessed;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
assert(valueOfAccessed, 'valueOfAccessed !== true');
|
||||
assert.sameValue(toStringAccessed, false, 'toStringAccessed');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-24
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'length' is a positive
|
||||
non-integer, ensure truncation occurs in the proper direction
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 122: true, 123: false, length: 123.321 }; //length will be 123 finally
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === 122 &&
|
||||
Array.prototype.indexOf.call(obj, false) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), 122, 'Array.prototype.indexOf.call(obj, true)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, false), -1, 'Array.prototype.indexOf.call(obj, false)');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-25
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'length' is a negative
|
||||
non-integer
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 1: true, 2: false, length: -4294967294.5 }; //length will be 0 finally
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === -1 &&
|
||||
Array.prototype.indexOf.call(obj, false) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, false), -1, 'Array.prototype.indexOf.call(obj, false)');
|
||||
|
@ -6,10 +6,8 @@ es5id: 15.4.4.14-3-28
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'length' is boundary value
|
||||
(2^32)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = {};
|
||||
var obj = {
|
||||
0: targetObj,
|
||||
@ -18,6 +16,4 @@ function testcase() {
|
||||
length: 4294967296
|
||||
};
|
||||
|
||||
return Array.prototype.indexOf.call(obj, targetObj) === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, targetObj), 0, 'Array.prototype.indexOf.call(obj, targetObj)');
|
||||
|
@ -6,10 +6,8 @@ es5id: 15.4.4.14-3-29
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'length' is boundary value
|
||||
(2^32 + 1)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = {};
|
||||
var obj = {
|
||||
0: targetObj,
|
||||
@ -17,7 +15,5 @@ function testcase() {
|
||||
length: 4294967297
|
||||
};
|
||||
|
||||
return Array.prototype.indexOf.call(obj, targetObj) === 0 &&
|
||||
Array.prototype.indexOf.call(obj, 4294967297) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, targetObj), 0, 'Array.prototype.indexOf.call(obj, targetObj)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, 4294967297), 1, 'Array.prototype.indexOf.call(obj, 4294967297)');
|
||||
|
@ -6,13 +6,8 @@ es5id: 15.4.4.14-3-3
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'length' is a number (value is
|
||||
0)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: true, length: 0 };
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
|
@ -6,13 +6,8 @@ es5id: 15.4.4.14-3-4
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'length' is a number (value is
|
||||
+0)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: true, length: +0 };
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
|
@ -6,13 +6,8 @@ es5id: 15.4.4.14-3-5
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'length' is a number (value is
|
||||
-0)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: true, length: -0 };
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-6
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'length' is a number (value is
|
||||
positive)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 3: true, 4: false, length: 4 };
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === 3 &&
|
||||
Array.prototype.indexOf.call(obj, false) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), 3, 'Array.prototype.indexOf.call(obj, true)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, false), -1, 'Array.prototype.indexOf.call(obj, false)');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-7
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'length' is a number (value is
|
||||
negative)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 4: true, 5: false, length: 5 - Math.pow(2, 32) };
|
||||
|
||||
return Array.prototype.indexOf.call(obj, true) === -1 &&
|
||||
Array.prototype.indexOf.call(obj, false) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, false), -1, 'Array.prototype.indexOf.call(obj, false)');
|
||||
|
@ -6,13 +6,8 @@ es5id: 15.4.4.14-3-8
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'length' is a number (value is
|
||||
Infinity)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: 0, length: Infinity };
|
||||
|
||||
return Array.prototype.indexOf.call(obj, 0) === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, 0), 0, 'Array.prototype.indexOf.call(obj, 0)');
|
||||
|
@ -6,13 +6,8 @@ es5id: 15.4.4.14-3-9
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'length' is a number (value is
|
||||
-Infinity)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: 0, length: -Infinity };
|
||||
|
||||
return Array.prototype.indexOf.call(obj, 0) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, 0), -1, 'Array.prototype.indexOf.call(obj, 0)');
|
||||
|
@ -4,13 +4,8 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-4-1
|
||||
description: Array.prototype.indexOf returns -1 if 'length' is 0 (empty array)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var i = [].indexOf(42);
|
||||
if (i === -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(i, -1, 'i');
|
||||
|
@ -4,12 +4,9 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-4-10
|
||||
description: Array.prototype.indexOf - 'length' is a number of value -6e-1
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = [];
|
||||
var obj = { 0: targetObj, 100: targetObj, length: -6e-1 };
|
||||
return Array.prototype.indexOf.call(obj, targetObj) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, targetObj), -1, 'Array.prototype.indexOf.call(obj, targetObj)');
|
||||
|
@ -4,12 +4,9 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-4-11
|
||||
description: Array.prototype.indexOf - 'length' is an empty string
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = [];
|
||||
var obj = { 0: targetObj, 100: targetObj, length: "" };
|
||||
return Array.prototype.indexOf.call(obj, targetObj) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, targetObj), -1, 'Array.prototype.indexOf.call(obj, targetObj)');
|
||||
|
@ -6,15 +6,9 @@ es5id: 15.4.4.14-4-2
|
||||
description: >
|
||||
Array.prototype.indexOf returns -1 if 'length' is 0 ( length
|
||||
overridden to null (type conversion))
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var i = Array.prototype.indexOf.call({length: null}, 1);
|
||||
|
||||
if (i === -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(i, -1, 'i');
|
||||
|
@ -6,15 +6,9 @@ es5id: 15.4.4.14-4-3
|
||||
description: >
|
||||
Array.prototype.indexOf returns -1 if 'length' is 0 (length
|
||||
overridden to false (type conversion))
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var i = Array.prototype.indexOf.call({length: false}, 1);
|
||||
|
||||
if (i === -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(i, -1, 'i');
|
||||
|
@ -6,15 +6,9 @@ es5id: 15.4.4.14-4-4
|
||||
description: >
|
||||
Array.prototype.indexOf returns -1 if 'length' is 0 (generic
|
||||
'array' with length 0 )
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var i = Array.prototype.lastIndexOf.call({length: 0}, 1);
|
||||
|
||||
if (i === -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(i, -1, 'i');
|
||||
|
@ -6,15 +6,9 @@ es5id: 15.4.4.14-4-5
|
||||
description: >
|
||||
Array.prototype.indexOf returns -1 if 'length' is 0 ( length
|
||||
overridden to '0' (type conversion))
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var i = Array.prototype.indexOf.call({length: '0'}, 1);
|
||||
|
||||
if (i === -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(i, -1, 'i');
|
||||
|
@ -6,15 +6,9 @@ es5id: 15.4.4.14-4-6
|
||||
description: >
|
||||
Array.prototype.indexOf returns -1 if 'length' is 0 (subclassed
|
||||
Array, length overridden with obj with valueOf)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var i = Array.prototype.indexOf.call({length: { valueOf: function () { return 0;}}}, 1);
|
||||
|
||||
if (i === -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(i, -1, 'i');
|
||||
|
@ -6,12 +6,8 @@ es5id: 15.4.4.14-4-7
|
||||
description: >
|
||||
Array.prototype.indexOf returns -1 if 'length' is 0 ( length is
|
||||
object overridden with obj w/o valueOf (toString))
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
|
||||
// objects inherit the default valueOf method of the Object object;
|
||||
// that simply returns the itself. Since the default valueOf() method
|
||||
// does not return a primitive value, ES next tries to convert the object
|
||||
@ -19,8 +15,5 @@ function testcase() {
|
||||
// resulting string to a number.
|
||||
var i = Array.prototype.indexOf.call({length: { toString: function () { return '0';}}}, 1);
|
||||
|
||||
if (i === -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(i, -1, 'i');
|
||||
|
@ -6,12 +6,8 @@ es5id: 15.4.4.14-4-8
|
||||
description: >
|
||||
Array.prototype.indexOf returns -1 if 'length' is 0 (length is an
|
||||
empty array)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
|
||||
// objects inherit the default valueOf method of the Object object;
|
||||
// that simply returns the itself. Since the default valueOf() method
|
||||
// does not return a primitive value, ES next tries to convert the object
|
||||
@ -27,8 +23,5 @@ function testcase() {
|
||||
// or if its one element is not a number, the array converts to NaN.
|
||||
var i = Array.prototype.indexOf.call({length: [ ]}, 1);
|
||||
|
||||
if (i === -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(i, -1, 'i');
|
||||
|
@ -4,12 +4,9 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-4-9
|
||||
description: Array.prototype.indexOf - 'length' is a number of value 0.1
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = [];
|
||||
var obj = { 0: targetObj, 100: targetObj, length: 0.1 };
|
||||
return Array.prototype.indexOf.call(obj, targetObj) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, targetObj), -1, 'Array.prototype.indexOf.call(obj, targetObj)');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.14-5-10
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'fromIndex' is a number (value
|
||||
is positive number)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = {};
|
||||
return [0, targetObj, 2].indexOf(targetObj, 2) === -1 &&
|
||||
[0, 1, targetObj].indexOf(targetObj, 2) === 2;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue([0, targetObj, 2].indexOf(targetObj, 2), -1, '[0, targetObj, 2].indexOf(targetObj, 2)');
|
||||
assert.sameValue([0, 1, targetObj].indexOf(targetObj, 2), 2, '[0, 1, targetObj].indexOf(targetObj, 2)');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.14-5-11
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'fromIndex' is a number (value
|
||||
is negative number)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = {};
|
||||
return [0, targetObj, 2].indexOf(targetObj, -1) === -1 &&
|
||||
[0, 1, targetObj].indexOf(targetObj, -1) === 2;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue([0, targetObj, 2].indexOf(targetObj, -1), -1, '[0, targetObj, 2].indexOf(targetObj, -1)');
|
||||
assert.sameValue([0, 1, targetObj].indexOf(targetObj, -1), 2, '[0, 1, targetObj].indexOf(targetObj, -1)');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.14-5-12
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'fromIndex' is a number (value
|
||||
is Infinity)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var arr = [];
|
||||
arr[Math.pow(2, 32) - 2] = true; //length is the max value of Uint type
|
||||
return arr.indexOf(true, Infinity) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(arr.indexOf(true, Infinity), -1, 'arr.indexOf(true, Infinity)');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.14-5-16
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'fromIndex' is a string
|
||||
containing Infinity
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var arr = [];
|
||||
arr[Math.pow(2, 32) - 2] = true; //length is the max value of Uint type
|
||||
return arr.indexOf(true, "Infinity") === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(arr.indexOf(true, "Infinity"), -1, 'arr.indexOf(true, "Infinity")');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.14-5-18
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'fromIndex' is a string
|
||||
containing an exponential number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = {};
|
||||
return [0, 1, targetObj, 3, 4].indexOf(targetObj, "3E0") === -1 &&
|
||||
[0, 1, 2, targetObj, 4].indexOf(targetObj, "3E0") === 3;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue([0, 1, targetObj, 3, 4].indexOf(targetObj, "3E0"), -1, '[0, 1, targetObj, 3, 4].indexOf(targetObj, "3E0")');
|
||||
assert.sameValue([0, 1, 2, targetObj, 4].indexOf(targetObj, "3E0"), 3, '[0, 1, 2, targetObj, 4].indexOf(targetObj, "3E0")');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.14-5-19
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'fromIndex' is a string
|
||||
containing a hex number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = {};
|
||||
return [0, 1, targetObj, 3, 4].indexOf(targetObj, "0x0003") === -1 &&
|
||||
[0, 1, 2, targetObj, 4].indexOf(targetObj, "0x0003") === 3;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue([0, 1, targetObj, 3, 4].indexOf(targetObj, "0x0003"), -1, '[0, 1, targetObj, 3, 4].indexOf(targetObj, "0x0003")');
|
||||
assert.sameValue([0, 1, 2, targetObj, 4].indexOf(targetObj, "0x0003"), 3, '[0, 1, 2, targetObj, 4].indexOf(targetObj, "0x0003")');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.14-5-20
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'fromIndex' which is a string
|
||||
containing a number with leading zeros
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = {};
|
||||
return [0, 1, targetObj, 3, 4].indexOf(targetObj, "0003.10") === -1 &&
|
||||
[0, 1, 2, targetObj, 4].indexOf(targetObj, "0003.10") === 3;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue([0, 1, targetObj, 3, 4].indexOf(targetObj, "0003.10"), -1, '[0, 1, targetObj, 3, 4].indexOf(targetObj, "0003.10")');
|
||||
assert.sameValue([0, 1, 2, targetObj, 4].indexOf(targetObj, "0003.10"), 3, '[0, 1, 2, targetObj, 4].indexOf(targetObj, "0003.10")');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-5-21
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'fromIndex' is an Object, which
|
||||
has an own toString method
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
// objects inherit the default valueOf() method from Object
|
||||
// that simply returns itself. Since the default valueOf() method
|
||||
// does not return a primitive value, ES next tries to convert the object
|
||||
@ -22,6 +19,4 @@ function testcase() {
|
||||
}
|
||||
};
|
||||
|
||||
return [0, true].indexOf(true, fromIndex) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([0, true].indexOf(true, fromIndex), 1, '[0, true].indexOf(true, fromIndex)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-5-22
|
||||
description: >
|
||||
Array.prototype.indexOf - value of 'fromIndex' is an Object, which
|
||||
has an own valueOf method
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var fromIndex = {
|
||||
valueOf: function () {
|
||||
return 1;
|
||||
@ -18,6 +15,4 @@ function testcase() {
|
||||
};
|
||||
|
||||
|
||||
return [0, true].indexOf(true, fromIndex) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([0, true].indexOf(true, fromIndex), 1, '[0, true].indexOf(true, fromIndex)');
|
||||
|
@ -7,11 +7,8 @@ description: >
|
||||
Array.prototype.indexOf - value of 'fromIndex' is an object that
|
||||
has an own valueOf method that returns an object and toString
|
||||
method that returns a string
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var toStringAccessed = false;
|
||||
var valueOfAccessed = false;
|
||||
|
||||
@ -27,6 +24,6 @@ function testcase() {
|
||||
}
|
||||
};
|
||||
|
||||
return [0, true].indexOf(true, fromIndex) === 1 && toStringAccessed && valueOfAccessed;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([0, true].indexOf(true, fromIndex), 1, '[0, true].indexOf(true, fromIndex)');
|
||||
assert(toStringAccessed, 'toStringAccessed !== true');
|
||||
assert(valueOfAccessed, 'valueOfAccessed !== true');
|
||||
|
@ -7,11 +7,8 @@ description: >
|
||||
Array.prototype.indexOf uses inherited valueOf method when value
|
||||
of 'fromIndex' is an object with an own toString and inherited
|
||||
valueOf methods
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var toStringAccessed = false;
|
||||
var valueOfAccessed = false;
|
||||
|
||||
@ -31,6 +28,6 @@ function testcase() {
|
||||
return 2;
|
||||
};
|
||||
|
||||
return [0, true].indexOf(true, child) === 1 && valueOfAccessed && !toStringAccessed;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([0, true].indexOf(true, child), 1, '[0, true].indexOf(true, child)');
|
||||
assert(valueOfAccessed, 'valueOfAccessed !== true');
|
||||
assert.sameValue(toStringAccessed, false, 'toStringAccessed');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.14-5-31
|
||||
description: >
|
||||
Array.prototype.indexOf - 'fromIndex' is a positive non-integer,
|
||||
verify truncation occurs in the proper direction
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = {};
|
||||
return [0, targetObj, 2].indexOf(targetObj, 2.5) === -1 &&
|
||||
[0, 1, targetObj].indexOf(targetObj, 2.5) === 2;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue([0, targetObj, 2].indexOf(targetObj, 2.5), -1, '[0, targetObj, 2].indexOf(targetObj, 2.5)');
|
||||
assert.sameValue([0, 1, targetObj].indexOf(targetObj, 2.5), 2, '[0, 1, targetObj].indexOf(targetObj, 2.5)');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.14-5-32
|
||||
description: >
|
||||
Array.prototype.indexOf - 'fromIndex' is a negative non-integer,
|
||||
verify truncation occurs in the proper direction
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = {};
|
||||
return [0, targetObj, 2].indexOf(targetObj, -1.5) === -1 &&
|
||||
[0, 1, targetObj].indexOf(targetObj, -1.5) === 2;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue([0, targetObj, 2].indexOf(targetObj, -1.5), -1, '[0, targetObj, 2].indexOf(targetObj, -1.5)');
|
||||
assert.sameValue([0, 1, targetObj].indexOf(targetObj, -1.5), 2, '[0, 1, targetObj].indexOf(targetObj, -1.5)');
|
||||
|
@ -4,14 +4,11 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-5-6
|
||||
description: Array.prototype.indexOf - 'fromIndex' isn't passed
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var arr = [0, 1, 2, 3, 4];
|
||||
//'fromIndex' will be set as 0 if not passed by default
|
||||
return arr.indexOf(0) === arr.indexOf(0, 0) &&
|
||||
arr.indexOf(2) === arr.indexOf(2, 0) &&
|
||||
arr.indexOf(4) === arr.indexOf(4, 0);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(arr.indexOf(0), arr.indexOf(0, 0), 'arr.indexOf(0)');
|
||||
assert.sameValue(arr.indexOf(2), arr.indexOf(2, 0), 'arr.indexOf(2)');
|
||||
assert.sameValue(arr.indexOf(4), arr.indexOf(4, 0), 'arr.indexOf(4)');
|
||||
|
@ -6,15 +6,10 @@ es5id: 15.4.4.14-6-1
|
||||
description: >
|
||||
Array.prototype.indexOf returns -1 if fromIndex is greater than
|
||||
Array length
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = [1,2,3];
|
||||
if (a.indexOf(1,5) === -1 &&
|
||||
a.indexOf(1,3) === -1 &&
|
||||
[ ].indexOf(1,0) === -1 ){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.indexOf(1,5), -1, 'a.indexOf(1,5)');
|
||||
assert.sameValue(a.indexOf(1,3), -1, 'a.indexOf(1,3)');
|
||||
assert.sameValue([ ].indexOf(1,0), -1, '[ ].indexOf(1,0)');
|
||||
|
@ -4,17 +4,12 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-8-1
|
||||
description: Array.prototype.indexOf with negative fromIndex
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = new Array(1,2,3);
|
||||
|
||||
if (a.indexOf(2,-1) === -1 &&
|
||||
a.indexOf(2,-2) === 1 &&
|
||||
a.indexOf(1,-3) === 0 &&
|
||||
a.indexOf(1,-5.3) === 0 ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.indexOf(2,-1), -1, 'a.indexOf(2,-1)');
|
||||
assert.sameValue(a.indexOf(2,-2), 1, 'a.indexOf(2,-2)');
|
||||
assert.sameValue(a.indexOf(1,-3), 0, 'a.indexOf(1,-3)');
|
||||
assert.sameValue(a.indexOf(1,-5.3), 0, 'a.indexOf(1,-5.3)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-11
|
||||
description: >
|
||||
Array.prototype.indexOf - the length of iteration isn't changed by
|
||||
adding elements to the array during iteration
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = [20];
|
||||
|
||||
Object.defineProperty(arr, "0", {
|
||||
@ -21,6 +18,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return arr.indexOf(1) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(arr.indexOf(1), -1, 'arr.indexOf(1)');
|
||||
|
@ -4,16 +4,10 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-9-7
|
||||
description: Array.prototype.indexOf must return correct index (self reference)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = new Array(0,1,2,3);
|
||||
a[2] = a;
|
||||
if (a.indexOf(a) === 2 &&
|
||||
a.indexOf(3) === 3 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.indexOf(a), 2, 'a.indexOf(a)');
|
||||
assert.sameValue(a.indexOf(3), 3, 'a.indexOf(3)');
|
||||
|
@ -4,16 +4,10 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-9-8
|
||||
description: Array.prototype.indexOf must return correct index (Array)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var b = new Array("0,1");
|
||||
var a = new Array(0,b,"0,1",3);
|
||||
if (a.indexOf(b.toString()) === 2 &&
|
||||
a.indexOf("0,1") === 2 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.indexOf(b.toString()), 2, 'a.indexOf(b.toString())');
|
||||
assert.sameValue(a.indexOf("0,1"), 2, 'a.indexOf("0,1")');
|
||||
|
@ -4,10 +4,8 @@
|
||||
/*---
|
||||
es5id: 15.4.4.14-9-9
|
||||
description: Array.prototype.indexOf must return correct index (Sparse Array)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = new Array(0,1);
|
||||
a[4294967294] = 2; // 2^32-2 - is max array element
|
||||
a[4294967295] = 3; // 2^32-1 added as non-array element property
|
||||
@ -15,9 +13,8 @@ function testcase() {
|
||||
a[4294967297] = 5; // 2^32+1 added as non-array element property
|
||||
|
||||
// start searching near the end so in case implementation actually tries to test all missing elements!!
|
||||
return (a.indexOf(2,4294967290 ) === 4294967294 &&
|
||||
a.indexOf(3,4294967290) === -1 &&
|
||||
a.indexOf(4,4294967290) === -1 &&
|
||||
a.indexOf(5,4294967290) === -1 ) ;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.indexOf(2,4294967290 ), 4294967294, 'a.indexOf(2,4294967290 )');
|
||||
assert.sameValue(a.indexOf(3,4294967290), -1, 'a.indexOf(3,4294967290)');
|
||||
assert.sameValue(a.indexOf(4,4294967290), -1, 'a.indexOf(4,4294967290)');
|
||||
assert.sameValue(a.indexOf(5,4294967290), -1, 'a.indexOf(5,4294967290)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-1
|
||||
description: >
|
||||
Array.prototype.indexOf - added properties in step 2 are visible
|
||||
here
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = { };
|
||||
|
||||
Object.defineProperty(arr, "length", {
|
||||
@ -21,6 +18,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return 2 === Array.prototype.indexOf.call(arr, "length");
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(arr, "length"), 2, 'Array.prototype.indexOf.call(arr, "length")');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-11
|
||||
description: >
|
||||
Array.prototype.indexOf - deleting own property causes index
|
||||
property not to be visited on an Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = { length: 2 };
|
||||
|
||||
Object.defineProperty(arr, "1", {
|
||||
@ -28,6 +25,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return -1 === Array.prototype.indexOf.call(arr, 6.99);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(arr, 6.99), -1, 'Array.prototype.indexOf.call(arr, 6.99)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-12
|
||||
description: >
|
||||
Array.prototype.indexOf - deleting own property causes index
|
||||
property not to be visited on an Array
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = [1, 2];
|
||||
|
||||
Object.defineProperty(arr, "1", {
|
||||
@ -28,6 +25,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return -1 === arr.indexOf("6.99");
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(arr.indexOf("6.99"), -1, 'arr.indexOf("6.99")');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-17
|
||||
description: >
|
||||
Array.prototype.indexOf - decreasing length of array causes index
|
||||
property not to be visited
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = [0, 1, 2, "last"];
|
||||
|
||||
Object.defineProperty(arr, "0", {
|
||||
@ -21,6 +18,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return -1 === arr.indexOf("last");
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(arr.indexOf("last"), -1, 'arr.indexOf("last")');
|
||||
|
@ -7,11 +7,8 @@ description: >
|
||||
Array.prototype.indexOf - decreasing length of array does not
|
||||
delete non-configurable properties
|
||||
flags: [noStrict]
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = [0, 1, 2];
|
||||
|
||||
Object.defineProperty(arr, "2", {
|
||||
@ -29,6 +26,5 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return 2 === arr.indexOf("unconfigurable");
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(arr.indexOf("unconfigurable"), 2, 'arr.indexOf("unconfigurable")');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-2
|
||||
description: >
|
||||
Array.prototype.indexOf - added properties in step 5 are visible
|
||||
here on an Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = { length: 30 };
|
||||
var targetObj = function () { };
|
||||
|
||||
@ -21,6 +18,5 @@ function testcase() {
|
||||
}
|
||||
};
|
||||
|
||||
return 4 === Array.prototype.indexOf.call(arr, targetObj, fromIndex);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(Array.prototype.indexOf.call(arr, targetObj, fromIndex), 4, 'Array.prototype.indexOf.call(arr, targetObj, fromIndex)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-3
|
||||
description: >
|
||||
Array.prototype.indexOf - added properties in step 5 are visible
|
||||
here on an Array
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = [];
|
||||
arr.length = 30;
|
||||
var targetObj = function () { };
|
||||
@ -22,6 +19,4 @@ function testcase() {
|
||||
}
|
||||
};
|
||||
|
||||
return 4 === arr.indexOf(targetObj, fromIndex);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(arr.indexOf(targetObj, fromIndex), 4, 'arr.indexOf(targetObj, fromIndex)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-4
|
||||
description: >
|
||||
Array.prototype.indexOf - deleted properties in step 2 are visible
|
||||
here
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = { 2: 6.99 };
|
||||
|
||||
Object.defineProperty(arr, "length", {
|
||||
@ -21,6 +18,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return -1 === Array.prototype.indexOf.call(arr, 6.99);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(arr, 6.99), -1, 'Array.prototype.indexOf.call(arr, 6.99)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-5
|
||||
description: >
|
||||
Array.prototype.indexOf - deleted properties in step 5 are visible
|
||||
here on an Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = { 10: false, length: 30 };
|
||||
|
||||
var fromIndex = {
|
||||
@ -20,6 +17,4 @@ function testcase() {
|
||||
}
|
||||
};
|
||||
|
||||
return -1 === Array.prototype.indexOf.call(arr, false, fromIndex);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(arr, false, fromIndex), -1, 'Array.prototype.indexOf.call(arr, false, fromIndex)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-6
|
||||
description: >
|
||||
Array.prototype.indexOf - deleted properties in step 5 are visible
|
||||
here on an Array
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = [];
|
||||
arr[10] = "10";
|
||||
arr.length = 20;
|
||||
@ -22,6 +19,4 @@ function testcase() {
|
||||
}
|
||||
};
|
||||
|
||||
return -1 === arr.indexOf("10", fromIndex);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(arr.indexOf("10", fromIndex), -1, 'arr.indexOf("10", fromIndex)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-7
|
||||
description: >
|
||||
Array.prototype.indexOf - properties added into own object after
|
||||
current position are visited on an Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = { length: 2 };
|
||||
|
||||
Object.defineProperty(arr, "0", {
|
||||
@ -26,6 +23,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return Array.prototype.indexOf.call(arr, 1) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(arr, 1), 1, 'Array.prototype.indexOf.call(arr, 1)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-8
|
||||
description: >
|
||||
Array.prototype.indexOf - properties added into own object after
|
||||
current position are visited on an Array
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = [0, , 2];
|
||||
|
||||
Object.defineProperty(arr, "0", {
|
||||
@ -26,6 +23,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return arr.indexOf(1) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(arr.indexOf(1), 1, 'arr.indexOf(1)');
|
||||
|
@ -6,13 +6,10 @@ es5id: 15.4.4.14-9-b-i-1
|
||||
description: >
|
||||
Array.prototype.indexOf - element to be retrieved is own data
|
||||
property on an Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var obj = { 0: 0, 1: 1, 2: 2, length: 3 };
|
||||
return Array.prototype.indexOf.call(obj, 0) === 0 &&
|
||||
Array.prototype.indexOf.call(obj, 1) === 1 &&
|
||||
Array.prototype.indexOf.call(obj, 2) === 2;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, 0), 0, 'Array.prototype.indexOf.call(obj, 0)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, 1), 1, 'Array.prototype.indexOf.call(obj, 1)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, 2), 2, 'Array.prototype.indexOf.call(obj, 2)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-b-i-10
|
||||
description: >
|
||||
Array.prototype.indexOf - element to be retrieved is own accessor
|
||||
property on an Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { length: 3 };
|
||||
Object.defineProperty(obj, "0", {
|
||||
get: function () {
|
||||
@ -33,8 +30,6 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return 0 === Array.prototype.indexOf.call(obj, 0) &&
|
||||
1 === Array.prototype.indexOf.call(obj, 1) &&
|
||||
2 === Array.prototype.indexOf.call(obj, 2);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, 0), 0, 'Array.prototype.indexOf.call(obj, 0)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, 1), 1, 'Array.prototype.indexOf.call(obj, 1)');
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, 2), 2, 'Array.prototype.indexOf.call(obj, 2)');
|
||||
|
@ -6,17 +6,12 @@ es5id: 15.4.4.14-9-b-i-17
|
||||
description: >
|
||||
Array.prototype.indexOf - element to be retrieved is own accessor
|
||||
property without a get function on an Array
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = [];
|
||||
Object.defineProperty(arr, "0", {
|
||||
set: function () { },
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return arr.indexOf(undefined) === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(arr.indexOf(undefined), 0, 'arr.indexOf(undefined)');
|
||||
|
@ -6,17 +6,12 @@ es5id: 15.4.4.14-9-b-i-18
|
||||
description: >
|
||||
Array.prototype.indexOf - element to be retrieved is own accessor
|
||||
property without a get function on an Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { length: 1 };
|
||||
Object.defineProperty(obj, "0", {
|
||||
set: function () { },
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return 0 === Array.prototype.indexOf.call(obj, undefined);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(obj, undefined), 0, 'Array.prototype.indexOf.call(obj, undefined)');
|
||||
|
@ -7,11 +7,8 @@ description: >
|
||||
Array.prototype.indexOf - element to be retrieved is own accessor
|
||||
property without a get function that overrides an inherited
|
||||
accessor property on an Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var proto = {};
|
||||
Object.defineProperty(proto, "0", {
|
||||
get: function () {
|
||||
@ -31,6 +28,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return Array.prototype.indexOf.call(child, undefined) === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(child, undefined), 0, 'Array.prototype.indexOf.call(child, undefined)');
|
||||
|
@ -7,16 +7,11 @@ description: >
|
||||
Array.prototype.indexOf applied to Arguments object which
|
||||
implements its own property get method (number of arguments is
|
||||
less than number of parameters)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var func = function (a, b) {
|
||||
return 0 === Array.prototype.indexOf.call(arguments, arguments[0]) &&
|
||||
-1 === Array.prototype.indexOf.call(arguments, arguments[1]);
|
||||
};
|
||||
|
||||
return func(true);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert(func(true), 'func(true) !== true');
|
||||
|
@ -7,17 +7,12 @@ description: >
|
||||
Array.prototype.indexOf applied to Arguments object which
|
||||
implements its own property get method (number of arguments equals
|
||||
to number of parameters)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var func = function (a, b) {
|
||||
return 0 === Array.prototype.indexOf.call(arguments, arguments[0]) &&
|
||||
1 === Array.prototype.indexOf.call(arguments, arguments[1]) &&
|
||||
-1 === Array.prototype.indexOf.call(arguments, arguments[2]);
|
||||
};
|
||||
|
||||
return func(0, true);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert(func(0, true), 'func(0, true) !== true');
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user