Replace runTestCase with assert helpers [test/built-ins/Array/prototype/indexOf]

This commit is contained in:
André Bargull 2015-08-06 18:16:54 +02:00
parent 659aa4c0f8
commit 7510a91a7e
105 changed files with 195 additions and 676 deletions

View File

@ -4,13 +4,8 @@
/*--- /*---
es5id: 15.4.4.14-0-1 es5id: 15.4.4.14-0-1
description: Array.prototype.indexOf must exist as a function description: Array.prototype.indexOf must exist as a function
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var f = Array.prototype.indexOf; var f = Array.prototype.indexOf;
if (typeof(f) === "function") {
return true; assert.sameValue(typeof(f), "function", 'typeof(f)');
}
}
runTestCase(testcase);

View File

@ -4,12 +4,6 @@
/*--- /*---
es5id: 15.4.4.14-0-2 es5id: 15.4.4.14-0-2
description: Array.prototype.indexOf has a length property whose value is 1. description: Array.prototype.indexOf has a length property whose value is 1.
includes: [runTestCase.js]
---*/ ---*/
function testcase() { assert.sameValue(Array.prototype.indexOf.length, 1, 'Array.prototype.indexOf.length');
if (Array.prototype.indexOf.length === 1) {
return true;
}
}
runTestCase(testcase);

View File

@ -4,15 +4,10 @@
/*--- /*---
es5id: 15.4.4.14-1-11 es5id: 15.4.4.14-1-11
description: Array.prototype.indexOf applied to Date object description: Array.prototype.indexOf applied to Date object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = new Date(); var obj = new Date();
obj.length = 2; obj.length = 2;
obj[1] = true; obj[1] = true;
return Array.prototype.indexOf.call(obj, true) === 1; assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);

View File

@ -4,15 +4,10 @@
/*--- /*---
es5id: 15.4.4.14-1-12 es5id: 15.4.4.14-1-12
description: Array.prototype.indexOf applied to RegExp object description: Array.prototype.indexOf applied to RegExp object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = new RegExp(); var obj = new RegExp();
obj.length = 2; obj.length = 2;
obj[1] = true; obj[1] = true;
return Array.prototype.indexOf.call(obj, true) === 1; assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);

View File

@ -4,15 +4,10 @@
/*--- /*---
es5id: 15.4.4.14-1-14 es5id: 15.4.4.14-1-14
description: Array.prototype.indexOf applied to Error object description: Array.prototype.indexOf applied to Error object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = new SyntaxError(); var obj = new SyntaxError();
obj[1] = true; obj[1] = true;
obj.length = 2; obj.length = 2;
return Array.prototype.indexOf.call(obj, true) === 1; assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);

View File

@ -4,16 +4,11 @@
/*--- /*---
es5id: 15.4.4.14-1-15 es5id: 15.4.4.14-1-15
description: Array.prototype.indexOf applied to Arguments object description: Array.prototype.indexOf applied to Arguments object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function fun() { function fun() {
return arguments; return arguments;
} }
var obj = fun(1, true, 3); var obj = fun(1, true, 3);
return Array.prototype.indexOf.call(obj, true) === 1; assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);

View File

@ -4,15 +4,10 @@
/*--- /*---
es5id: 15.4.4.14-1-4 es5id: 15.4.4.14-1-4
description: Array.prototype.indexOf applied to Boolean Object description: Array.prototype.indexOf applied to Boolean Object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = new Boolean(false); var obj = new Boolean(false);
obj.length = 2; obj.length = 2;
obj[1] = true; obj[1] = true;
return Array.prototype.indexOf.call(obj, true) === 1; assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);

View File

@ -4,15 +4,10 @@
/*--- /*---
es5id: 15.4.4.14-1-6 es5id: 15.4.4.14-1-6
description: Array.prototype.indexOf applied to Number object description: Array.prototype.indexOf applied to Number object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = new Number(-3); var obj = new Number(-3);
obj.length = 2; obj.length = 2;
obj[1] = true; obj[1] = true;
return Array.prototype.indexOf.call(obj, true) === 1; assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);

View File

@ -4,13 +4,8 @@
/*--- /*---
es5id: 15.4.4.14-1-8 es5id: 15.4.4.14-1-8
description: Array.prototype.indexOf applied to String object description: Array.prototype.indexOf applied to String object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = new String("null"); var obj = new String("null");
return Array.prototype.indexOf.call(obj, 'l') === 2; assert.sameValue(Array.prototype.indexOf.call(obj, 'l'), 2, 'Array.prototype.indexOf.call(obj, "l")');
}
runTestCase(testcase);

View File

@ -4,16 +4,11 @@
/*--- /*---
es5id: 15.4.4.14-1-9 es5id: 15.4.4.14-1-9
description: Array.prototype.indexOf applied to Function object description: Array.prototype.indexOf applied to Function object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = function (a, b) { var obj = function (a, b) {
return a + b; return a + b;
}; };
obj[1] = true; obj[1] = true;
return Array.prototype.indexOf.call(obj, true) === 1; assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);

View File

@ -6,10 +6,8 @@ es5id: 15.4.4.14-10-2
description: > description: >
Array.prototype.indexOf returns -1 if 'length' is 0 and does not Array.prototype.indexOf returns -1 if 'length' is 0 and does not
access any other properties access any other properties
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var accessed = false; var accessed = false;
var f = {length: 0}; var f = {length: 0};
Object.defineProperty(f,"0",{get: function () {accessed = true; return 1;}}); Object.defineProperty(f,"0",{get: function () {accessed = true; return 1;}});
@ -17,8 +15,6 @@ function testcase() {
var i = Array.prototype.indexOf.call(f,1); var i = Array.prototype.indexOf.call(f,1);
if (i === -1 && accessed==false) {
return true; assert.sameValue(i, -1, 'i');
} assert.sameValue(accessed, false, 'accessed');
}
runTestCase(testcase);

View File

@ -6,13 +6,10 @@ es5id: 15.4.4.14-2-1
description: > description: >
Array.prototype.indexOf - 'length' is own data property on an Array.prototype.indexOf - 'length' is own data property on an
Array-like object Array-like object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var objOne = { 1: true, length: 2 }; var objOne = { 1: true, length: 2 };
var objTwo = { 2: true, length: 2 }; var objTwo = { 2: true, length: 2 };
return Array.prototype.indexOf.call(objOne, true) === 1 &&
Array.prototype.indexOf.call(objTwo, true) === -1; 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)');
runTestCase(testcase);

View File

@ -4,11 +4,8 @@
/*--- /*---
es5id: 15.4.4.14-2-10 es5id: 15.4.4.14-2-10
description: Array.prototype.indexOf - 'length' is inherited accessor property description: Array.prototype.indexOf - 'length' is inherited accessor property
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var proto = {}; var proto = {};
Object.defineProperty(proto, "length", { Object.defineProperty(proto, "length", {
get: function () { get: function () {
@ -25,7 +22,5 @@ function testcase() {
var childTwo = new Con(); var childTwo = new Con();
childTwo[2] = true; childTwo[2] = true;
return Array.prototype.indexOf.call(childOne, true) === 1 && assert.sameValue(Array.prototype.indexOf.call(childOne, true), 1, 'Array.prototype.indexOf.call(childOne, true)');
Array.prototype.indexOf.call(childTwo, true) === -1; assert.sameValue(Array.prototype.indexOf.call(childTwo, true), -1, 'Array.prototype.indexOf.call(childTwo, true)');
}
runTestCase(testcase);

View File

@ -6,17 +6,12 @@ es5id: 15.4.4.14-2-11
description: > description: >
Array.prototype.indexOf - 'length' is own accessor property Array.prototype.indexOf - 'length' is own accessor property
without a get function without a get function
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 1: true }; var obj = { 1: true };
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
set: function () { }, set: function () { },
configurable: true configurable: true
}); });
return Array.prototype.indexOf.call(obj, true) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-2-13
description: > description: >
Array.prototype.indexOf - 'length' is inherited accessor property Array.prototype.indexOf - 'length' is inherited accessor property
without a get function without a get function
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var proto = {}; var proto = {};
Object.defineProperty(proto, "length", { Object.defineProperty(proto, "length", {
set: function () { }, set: function () { },
@ -23,6 +20,4 @@ function testcase() {
var child = new Con(); var child = new Con();
child[1] = true; child[1] = true;
return Array.prototype.indexOf.call(child, true) === -1; assert.sameValue(Array.prototype.indexOf.call(child, true), -1, 'Array.prototype.indexOf.call(child, true)');
}
runTestCase(testcase);

View File

@ -4,13 +4,8 @@
/*--- /*---
es5id: 15.4.4.14-2-14 es5id: 15.4.4.14-2-14
description: Array.prototype.indexOf - 'length' is undefined property description: Array.prototype.indexOf - 'length' is undefined property
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: true, 1: true }; var obj = { 0: true, 1: true };
return Array.prototype.indexOf.call(obj, true) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);

View File

@ -6,17 +6,12 @@ es5id: 15.4.4.14-2-17
description: > description: >
Array.prototype.indexOf applied to Arguments object which Array.prototype.indexOf applied to Arguments object which
implements its own property get method implements its own property get method
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var func = function (a, b) { var func = function (a, b) {
arguments[2] = false; arguments[2] = false;
return Array.prototype.indexOf.call(arguments, true) === 1 && return Array.prototype.indexOf.call(arguments, true) === 1 &&
Array.prototype.indexOf.call(arguments, false) === -1; Array.prototype.indexOf.call(arguments, false) === -1;
}; };
return func(0, true); assert(func(0, true), 'func(0, true) !== true');
}
runTestCase(testcase);

View File

@ -6,18 +6,13 @@ es5id: 15.4.4.14-2-19
description: > description: >
Array.prototype.indexOf applied to Function object which Array.prototype.indexOf applied to Function object which
implements its own property get method implements its own property get method
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = function (a, b) { var obj = function (a, b) {
return a + b; return a + b;
}; };
obj[1] = "b"; obj[1] = "b";
obj[2] = "c"; obj[2] = "c";
return Array.prototype.indexOf.call(obj, obj[1]) === 1 && assert.sameValue(Array.prototype.indexOf.call(obj, obj[1]), 1, 'Array.prototype.indexOf.call(obj, obj[1])');
Array.prototype.indexOf.call(obj, obj[2]) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, obj[2]), -1, 'Array.prototype.indexOf.call(obj, obj[2])');
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-2-3
description: > description: >
Array.prototype.indexOf - 'length' is own data property that Array.prototype.indexOf - 'length' is own data property that
overrides an inherited data property on an Array-like object overrides an inherited data property on an Array-like object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var proto = { length: 0 }; var proto = { length: 0 };
var Con = function () {}; var Con = function () {};
@ -20,6 +17,4 @@ function testcase() {
child.length = 2; child.length = 2;
child[1] = true; child[1] = true;
return Array.prototype.indexOf.call(child, true) === 1; assert.sameValue(Array.prototype.indexOf.call(child, true), 1, 'Array.prototype.indexOf.call(child, true)');
}
runTestCase(testcase);

View File

@ -6,10 +6,8 @@ es5id: 15.4.4.14-2-5
description: > description: >
Array.prototype.indexOf - 'length' is own data property that Array.prototype.indexOf - 'length' is own data property that
overrides an inherited accessor property on an Array-like object overrides an inherited accessor property on an Array-like object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var proto = {}; var proto = {};
Object.defineProperty(proto, "length", { Object.defineProperty(proto, "length", {
get: function () { get: function () {
@ -29,6 +27,4 @@ function testcase() {
}); });
child[1] = true; child[1] = true;
return Array.prototype.indexOf.call(child, true) === 1; assert.sameValue(Array.prototype.indexOf.call(child, true), 1, 'Array.prototype.indexOf.call(child, true)');
}
runTestCase(testcase);

View File

@ -4,10 +4,8 @@
/*--- /*---
es5id: 15.4.4.14-2-6 es5id: 15.4.4.14-2-6
description: Array.prototype.indexOf - 'length' is an inherited data property description: Array.prototype.indexOf - 'length' is an inherited data property
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var proto = { length: 2 }; var proto = { length: 2 };
var Con = function () {}; var Con = function () {};
@ -18,7 +16,5 @@ function testcase() {
var childTwo = new Con(); var childTwo = new Con();
childTwo[2] = true; childTwo[2] = true;
return Array.prototype.indexOf.call(childOne, true) === 1 && assert.sameValue(Array.prototype.indexOf.call(childOne, true), 1, 'Array.prototype.indexOf.call(childOne, true)');
Array.prototype.indexOf.call(childTwo, true) === -1; assert.sameValue(Array.prototype.indexOf.call(childTwo, true), -1, 'Array.prototype.indexOf.call(childTwo, true)');
}
runTestCase(testcase);

View File

@ -4,10 +4,8 @@
/*--- /*---
es5id: 15.4.4.14-2-7 es5id: 15.4.4.14-2-7
description: Array.prototype.indexOf - 'length' is own accessor property description: Array.prototype.indexOf - 'length' is own accessor property
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var objOne = { 1: true }; var objOne = { 1: true };
var objTwo = { 2: true }; var objTwo = { 2: true };
Object.defineProperty(objOne, "length", { Object.defineProperty(objOne, "length", {
@ -23,7 +21,5 @@ function testcase() {
configurable: true configurable: true
}); });
return Array.prototype.indexOf.call(objOne, true) === 1 && assert.sameValue(Array.prototype.indexOf.call(objOne, true), 1, 'Array.prototype.indexOf.call(objOne, true)');
Array.prototype.indexOf.call(objTwo, true) === -1; assert.sameValue(Array.prototype.indexOf.call(objTwo, true), -1, 'Array.prototype.indexOf.call(objTwo, true)');
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-2-8
description: > description: >
Array.prototype.indexOf - 'length' is own accessor property that Array.prototype.indexOf - 'length' is own accessor property that
overrides an inherited data property overrides an inherited data property
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var proto = { length: 0 }; var proto = { length: 0 };
var Con = function () {}; var Con = function () {};
@ -26,6 +23,4 @@ function testcase() {
configurable: true configurable: true
}); });
return Array.prototype.indexOf.call(child, true) === 1; assert.sameValue(Array.prototype.indexOf.call(child, true), 1, 'Array.prototype.indexOf.call(child, true)');
}
runTestCase(testcase);

View File

@ -6,10 +6,8 @@ es5id: 15.4.4.14-2-9
description: > description: >
Array.prototype.indexOf - 'length' is own accessor property that Array.prototype.indexOf - 'length' is own accessor property that
overrides an inherited accessor property overrides an inherited accessor property
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var proto = {}; var proto = {};
Object.defineProperty(proto, "length", { Object.defineProperty(proto, "length", {
get: function () { get: function () {
@ -31,6 +29,4 @@ function testcase() {
configurable: true configurable: true
}); });
return Array.prototype.indexOf.call(child, true) === 1; assert.sameValue(Array.prototype.indexOf.call(child, true), 1, 'Array.prototype.indexOf.call(child, true)');
}
runTestCase(testcase);

View File

@ -4,13 +4,8 @@
/*--- /*---
es5id: 15.4.4.14-3-1 es5id: 15.4.4.14-3-1
description: Array.prototype.indexOf - value of 'length' is undefined description: Array.prototype.indexOf - value of 'length' is undefined
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 1, 1: 1, length: undefined }; var obj = { 0: 1, 1: 1, length: undefined };
return Array.prototype.indexOf.call(obj, 1) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, 1), -1, 'Array.prototype.indexOf.call(obj, 1)');
}
runTestCase(testcase);

View File

@ -6,13 +6,8 @@ es5id: 15.4.4.14-3-10
description: > description: >
Array.prototype.indexOf - value of 'length' is number primitive Array.prototype.indexOf - value of 'length' is number primitive
(value is NaN) (value is NaN)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 0, length: NaN }; var obj = { 0: 0, length: NaN };
return Array.prototype.indexOf.call(obj, 0) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, 0), -1, 'Array.prototype.indexOf.call(obj, 0)');
}
runTestCase(testcase);

View File

@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-11
description: > description: >
Array.prototype.indexOf - 'length' is a string containing a Array.prototype.indexOf - 'length' is a string containing a
positive number positive number
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 1: 1, 2: 2, length: "2" }; var obj = { 1: 1, 2: 2, length: "2" };
return Array.prototype.indexOf.call(obj, 1) === 1 && assert.sameValue(Array.prototype.indexOf.call(obj, 1), 1, 'Array.prototype.indexOf.call(obj, 1)');
Array.prototype.indexOf.call(obj, 2) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, 2), -1, 'Array.prototype.indexOf.call(obj, 2)');
}
runTestCase(testcase);

View File

@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-12
description: > description: >
Array.prototype.indexOf - 'length' is a string containing a Array.prototype.indexOf - 'length' is a string containing a
negative number negative number
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 1: "true", 2: "2", length: "-4294967294" }; var obj = { 1: "true", 2: "2", length: "-4294967294" };
return Array.prototype.indexOf.call(obj, "true") === -1 && assert.sameValue(Array.prototype.indexOf.call(obj, "true"), -1, 'Array.prototype.indexOf.call(obj, "true")');
Array.prototype.indexOf.call(obj, "2") === -1; assert.sameValue(Array.prototype.indexOf.call(obj, "2"), -1, 'Array.prototype.indexOf.call(obj, "2")');
}
runTestCase(testcase);

View File

@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-13
description: > description: >
Array.prototype.indexOf - 'length' is a string containing a Array.prototype.indexOf - 'length' is a string containing a
decimal number decimal number
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 199: true, 200: "200.59", length: "200.59" }; var obj = { 199: true, 200: "200.59", length: "200.59" };
return Array.prototype.indexOf.call(obj, true) === 199 && assert.sameValue(Array.prototype.indexOf.call(obj, true), 199, 'Array.prototype.indexOf.call(obj, true)');
Array.prototype.indexOf.call(obj, "200.59") === -1; assert.sameValue(Array.prototype.indexOf.call(obj, "200.59"), -1, 'Array.prototype.indexOf.call(obj, "200.59")');
}
runTestCase(testcase);

View File

@ -6,17 +6,12 @@ es5id: 15.4.4.14-3-14
description: > description: >
Array.prototype.indexOf - 'length' is a string containing Array.prototype.indexOf - 'length' is a string containing
+/-Infinity +/-Infinity
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var objOne = { 0: true, 1: true, length: "Infinity" }; var objOne = { 0: true, 1: true, length: "Infinity" };
var objTwo = { 0: true, 1: true, length: "+Infinity" }; var objTwo = { 0: true, 1: true, length: "+Infinity" };
var objThree = { 0: true, 1: true, length: "-Infinity" }; var objThree = { 0: true, 1: true, length: "-Infinity" };
return Array.prototype.indexOf.call(objOne, true) === 0 && assert.sameValue(Array.prototype.indexOf.call(objOne, true), 0, 'Array.prototype.indexOf.call(objOne, true)');
Array.prototype.indexOf.call(objTwo, true) === 0 && assert.sameValue(Array.prototype.indexOf.call(objTwo, true), 0, 'Array.prototype.indexOf.call(objTwo, true)');
Array.prototype.indexOf.call(objThree, true) === -1; assert.sameValue(Array.prototype.indexOf.call(objThree, true), -1, 'Array.prototype.indexOf.call(objThree, true)');
}
runTestCase(testcase);

View File

@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-15
description: > description: >
Array.prototype.indexOf - 'length' is a string containing an Array.prototype.indexOf - 'length' is a string containing an
exponential number exponential number
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 1: true, 2: "2E0", length: "2E0" }; var obj = { 1: true, 2: "2E0", length: "2E0" };
return Array.prototype.indexOf.call(obj, true) === 1 && assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
Array.prototype.indexOf.call(obj, "2E0") === -1; assert.sameValue(Array.prototype.indexOf.call(obj, "2E0"), -1, 'Array.prototype.indexOf.call(obj, "2E0")');
}
runTestCase(testcase);

View File

@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-16
description: > description: >
Array.prototype.indexOf - 'length' is a string containing a hex Array.prototype.indexOf - 'length' is a string containing a hex
number number
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 10: true, 11: "0x00B", length: "0x00B" }; var obj = { 10: true, 11: "0x00B", length: "0x00B" };
return Array.prototype.indexOf.call(obj, true) === 10 && assert.sameValue(Array.prototype.indexOf.call(obj, true), 10, 'Array.prototype.indexOf.call(obj, true)');
Array.prototype.indexOf.call(obj, "0x00B") === -1; assert.sameValue(Array.prototype.indexOf.call(obj, "0x00B"), -1, 'Array.prototype.indexOf.call(obj, "0x00B")');
}
runTestCase(testcase);

View File

@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-17
description: > description: >
Array.prototype.indexOf - 'length' is a string containing a number Array.prototype.indexOf - 'length' is a string containing a number
with leading zeros with leading zeros
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 1: true, 2: "0002.0", length: "0002.0" }; var obj = { 1: true, 2: "0002.0", length: "0002.0" };
return Array.prototype.indexOf.call(obj, true) === 1 && assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
Array.prototype.indexOf.call(obj, "0002.0") === -1; assert.sameValue(Array.prototype.indexOf.call(obj, "0002.0"), -1, 'Array.prototype.indexOf.call(obj, "0002.0")');
}
runTestCase(testcase);

View File

@ -6,13 +6,8 @@ es5id: 15.4.4.14-3-18
description: > description: >
Array.prototype.indexOf - value of 'length' is a string that can't Array.prototype.indexOf - value of 'length' is a string that can't
convert to a number convert to a number
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: true, 100: true, length: "one" }; var obj = { 0: true, 100: true, length: "one" };
return Array.prototype.indexOf.call(obj, true) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-3-19
description: > description: >
Array.prototype.indexOf - value of 'length' is an Object which has Array.prototype.indexOf - value of 'length' is an Object which has
an own toString method. an own toString method.
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
// objects inherit the default valueOf() method from Object // objects inherit the default valueOf() method from Object
// that simply returns itself. Since the default valueOf() method // that simply returns itself. Since the default valueOf() method
// does not return a primitive value, ES next tries to convert the object // 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 && assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
Array.prototype.indexOf.call(obj, 2) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, 2), -1, 'Array.prototype.indexOf.call(obj, 2)');
}
runTestCase(testcase);

View File

@ -6,12 +6,9 @@ es5id: 15.4.4.14-3-2
description: > description: >
Array.prototype.indexOf return -1 when 'length' is a boolean Array.prototype.indexOf return -1 when 'length' is a boolean
(value is true) (value is true)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 0, 1: 1, length: true }; var obj = { 0: 0, 1: 1, length: true };
return Array.prototype.indexOf.call(obj, 0) === 0 &&
Array.prototype.indexOf.call(obj, 1) === -1; 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)');
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-3-20
description: > description: >
Array.prototype.indexOf - value of 'length' is an Object which has Array.prototype.indexOf - value of 'length' is an Object which has
an own valueOf method. an own valueOf method.
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
//valueOf method will be invoked first, since hint is Number //valueOf method will be invoked first, since hint is Number
var obj = { var obj = {
1: true, 1: true,
@ -22,7 +19,5 @@ function testcase() {
} }
}; };
return Array.prototype.indexOf.call(obj, true) === 1 && assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
Array.prototype.indexOf.call(obj, 2) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, 2), -1, 'Array.prototype.indexOf.call(obj, 2)');
}
runTestCase(testcase);

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.indexOf - 'length' is an object that has an own Array.prototype.indexOf - 'length' is an object that has an own
valueOf method that returns an object and toString method that valueOf method that returns an object and toString method that
returns a string returns a string
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var toStringAccessed = false; var toStringAccessed = false;
var valueOfAccessed = false; var valueOfAccessed = false;
@ -30,6 +27,6 @@ function testcase() {
} }
}; };
return Array.prototype.indexOf.call(obj, true) === 1 && toStringAccessed && valueOfAccessed; assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
} assert(toStringAccessed, 'toStringAccessed !== true');
runTestCase(testcase); assert(valueOfAccessed, 'valueOfAccessed !== true');

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.indexOf uses inherited valueOf method when Array.prototype.indexOf uses inherited valueOf method when
'length' is an object with an own toString and inherited valueOf 'length' is an object with an own toString and inherited valueOf
methods methods
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var toStringAccessed = false; var toStringAccessed = false;
var valueOfAccessed = false; var valueOfAccessed = false;
@ -36,6 +33,6 @@ function testcase() {
length: child length: child
}; };
return Array.prototype.indexOf.call(obj, true) === 1 && valueOfAccessed && !toStringAccessed; assert.sameValue(Array.prototype.indexOf.call(obj, true), 1, 'Array.prototype.indexOf.call(obj, true)');
} assert(valueOfAccessed, 'valueOfAccessed !== true');
runTestCase(testcase); assert.sameValue(toStringAccessed, false, 'toStringAccessed');

View File

@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-24
description: > description: >
Array.prototype.indexOf - value of 'length' is a positive Array.prototype.indexOf - value of 'length' is a positive
non-integer, ensure truncation occurs in the proper direction 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 var obj = { 122: true, 123: false, length: 123.321 }; //length will be 123 finally
return Array.prototype.indexOf.call(obj, true) === 122 && assert.sameValue(Array.prototype.indexOf.call(obj, true), 122, 'Array.prototype.indexOf.call(obj, true)');
Array.prototype.indexOf.call(obj, false) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, false), -1, 'Array.prototype.indexOf.call(obj, false)');
}
runTestCase(testcase);

View File

@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-25
description: > description: >
Array.prototype.indexOf - value of 'length' is a negative Array.prototype.indexOf - value of 'length' is a negative
non-integer non-integer
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 1: true, 2: false, length: -4294967294.5 }; //length will be 0 finally var obj = { 1: true, 2: false, length: -4294967294.5 }; //length will be 0 finally
return Array.prototype.indexOf.call(obj, true) === -1 && assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)');
Array.prototype.indexOf.call(obj, false) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, false), -1, 'Array.prototype.indexOf.call(obj, false)');
}
runTestCase(testcase);

View File

@ -6,10 +6,8 @@ es5id: 15.4.4.14-3-28
description: > description: >
Array.prototype.indexOf - value of 'length' is boundary value Array.prototype.indexOf - value of 'length' is boundary value
(2^32) (2^32)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var targetObj = {}; var targetObj = {};
var obj = { var obj = {
0: targetObj, 0: targetObj,
@ -18,6 +16,4 @@ function testcase() {
length: 4294967296 length: 4294967296
}; };
return Array.prototype.indexOf.call(obj, targetObj) === 0; assert.sameValue(Array.prototype.indexOf.call(obj, targetObj), 0, 'Array.prototype.indexOf.call(obj, targetObj)');
}
runTestCase(testcase);

View File

@ -6,10 +6,8 @@ es5id: 15.4.4.14-3-29
description: > description: >
Array.prototype.indexOf - value of 'length' is boundary value Array.prototype.indexOf - value of 'length' is boundary value
(2^32 + 1) (2^32 + 1)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var targetObj = {}; var targetObj = {};
var obj = { var obj = {
0: targetObj, 0: targetObj,
@ -17,7 +15,5 @@ function testcase() {
length: 4294967297 length: 4294967297
}; };
return Array.prototype.indexOf.call(obj, targetObj) === 0 && assert.sameValue(Array.prototype.indexOf.call(obj, targetObj), 0, 'Array.prototype.indexOf.call(obj, targetObj)');
Array.prototype.indexOf.call(obj, 4294967297) === 1; assert.sameValue(Array.prototype.indexOf.call(obj, 4294967297), 1, 'Array.prototype.indexOf.call(obj, 4294967297)');
}
runTestCase(testcase);

View File

@ -6,13 +6,8 @@ es5id: 15.4.4.14-3-3
description: > description: >
Array.prototype.indexOf - value of 'length' is a number (value is Array.prototype.indexOf - value of 'length' is a number (value is
0) 0)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: true, length: 0 }; var obj = { 0: true, length: 0 };
return Array.prototype.indexOf.call(obj, true) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);

View File

@ -6,13 +6,8 @@ es5id: 15.4.4.14-3-4
description: > description: >
Array.prototype.indexOf - value of 'length' is a number (value is Array.prototype.indexOf - value of 'length' is a number (value is
+0) +0)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: true, length: +0 }; var obj = { 0: true, length: +0 };
return Array.prototype.indexOf.call(obj, true) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);

View File

@ -6,13 +6,8 @@ es5id: 15.4.4.14-3-5
description: > description: >
Array.prototype.indexOf - value of 'length' is a number (value is Array.prototype.indexOf - value of 'length' is a number (value is
-0) -0)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: true, length: -0 }; var obj = { 0: true, length: -0 };
return Array.prototype.indexOf.call(obj, true) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)');
}
runTestCase(testcase);

View File

@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-6
description: > description: >
Array.prototype.indexOf - value of 'length' is a number (value is Array.prototype.indexOf - value of 'length' is a number (value is
positive) positive)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 3: true, 4: false, length: 4 }; var obj = { 3: true, 4: false, length: 4 };
return Array.prototype.indexOf.call(obj, true) === 3 && assert.sameValue(Array.prototype.indexOf.call(obj, true), 3, 'Array.prototype.indexOf.call(obj, true)');
Array.prototype.indexOf.call(obj, false) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, false), -1, 'Array.prototype.indexOf.call(obj, false)');
}
runTestCase(testcase);

View File

@ -6,14 +6,9 @@ es5id: 15.4.4.14-3-7
description: > description: >
Array.prototype.indexOf - value of 'length' is a number (value is Array.prototype.indexOf - value of 'length' is a number (value is
negative) negative)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 4: true, 5: false, length: 5 - Math.pow(2, 32) }; var obj = { 4: true, 5: false, length: 5 - Math.pow(2, 32) };
return Array.prototype.indexOf.call(obj, true) === -1 && assert.sameValue(Array.prototype.indexOf.call(obj, true), -1, 'Array.prototype.indexOf.call(obj, true)');
Array.prototype.indexOf.call(obj, false) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, false), -1, 'Array.prototype.indexOf.call(obj, false)');
}
runTestCase(testcase);

View File

@ -6,13 +6,8 @@ es5id: 15.4.4.14-3-8
description: > description: >
Array.prototype.indexOf - value of 'length' is a number (value is Array.prototype.indexOf - value of 'length' is a number (value is
Infinity) Infinity)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 0, length: Infinity }; var obj = { 0: 0, length: Infinity };
return Array.prototype.indexOf.call(obj, 0) === 0; assert.sameValue(Array.prototype.indexOf.call(obj, 0), 0, 'Array.prototype.indexOf.call(obj, 0)');
}
runTestCase(testcase);

View File

@ -6,13 +6,8 @@ es5id: 15.4.4.14-3-9
description: > description: >
Array.prototype.indexOf - value of 'length' is a number (value is Array.prototype.indexOf - value of 'length' is a number (value is
-Infinity) -Infinity)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 0, length: -Infinity }; var obj = { 0: 0, length: -Infinity };
return Array.prototype.indexOf.call(obj, 0) === -1; assert.sameValue(Array.prototype.indexOf.call(obj, 0), -1, 'Array.prototype.indexOf.call(obj, 0)');
}
runTestCase(testcase);

View File

@ -4,13 +4,8 @@
/*--- /*---
es5id: 15.4.4.14-4-1 es5id: 15.4.4.14-4-1
description: Array.prototype.indexOf returns -1 if 'length' is 0 (empty array) description: Array.prototype.indexOf returns -1 if 'length' is 0 (empty array)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var i = [].indexOf(42); var i = [].indexOf(42);
if (i === -1) {
return true; assert.sameValue(i, -1, 'i');
}
}
runTestCase(testcase);

View File

@ -4,12 +4,9 @@
/*--- /*---
es5id: 15.4.4.14-4-10 es5id: 15.4.4.14-4-10
description: Array.prototype.indexOf - 'length' is a number of value -6e-1 description: Array.prototype.indexOf - 'length' is a number of value -6e-1
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var targetObj = []; var targetObj = [];
var obj = { 0: targetObj, 100: targetObj, length: -6e-1 }; var obj = { 0: targetObj, 100: targetObj, length: -6e-1 };
return Array.prototype.indexOf.call(obj, targetObj) === -1;
} assert.sameValue(Array.prototype.indexOf.call(obj, targetObj), -1, 'Array.prototype.indexOf.call(obj, targetObj)');
runTestCase(testcase);

View File

@ -4,12 +4,9 @@
/*--- /*---
es5id: 15.4.4.14-4-11 es5id: 15.4.4.14-4-11
description: Array.prototype.indexOf - 'length' is an empty string description: Array.prototype.indexOf - 'length' is an empty string
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var targetObj = []; var targetObj = [];
var obj = { 0: targetObj, 100: targetObj, length: "" }; var obj = { 0: targetObj, 100: targetObj, length: "" };
return Array.prototype.indexOf.call(obj, targetObj) === -1;
} assert.sameValue(Array.prototype.indexOf.call(obj, targetObj), -1, 'Array.prototype.indexOf.call(obj, targetObj)');
runTestCase(testcase);

View File

@ -6,15 +6,9 @@ es5id: 15.4.4.14-4-2
description: > description: >
Array.prototype.indexOf returns -1 if 'length' is 0 ( length Array.prototype.indexOf returns -1 if 'length' is 0 ( length
overridden to null (type conversion)) overridden to null (type conversion))
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var i = Array.prototype.indexOf.call({length: null}, 1); var i = Array.prototype.indexOf.call({length: null}, 1);
if (i === -1) {
return true; assert.sameValue(i, -1, 'i');
}
}
runTestCase(testcase);

View File

@ -6,15 +6,9 @@ es5id: 15.4.4.14-4-3
description: > description: >
Array.prototype.indexOf returns -1 if 'length' is 0 (length Array.prototype.indexOf returns -1 if 'length' is 0 (length
overridden to false (type conversion)) overridden to false (type conversion))
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var i = Array.prototype.indexOf.call({length: false}, 1); var i = Array.prototype.indexOf.call({length: false}, 1);
if (i === -1) {
return true; assert.sameValue(i, -1, 'i');
}
}
runTestCase(testcase);

View File

@ -6,15 +6,9 @@ es5id: 15.4.4.14-4-4
description: > description: >
Array.prototype.indexOf returns -1 if 'length' is 0 (generic Array.prototype.indexOf returns -1 if 'length' is 0 (generic
'array' with length 0 ) 'array' with length 0 )
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var i = Array.prototype.lastIndexOf.call({length: 0}, 1); var i = Array.prototype.lastIndexOf.call({length: 0}, 1);
if (i === -1) {
return true; assert.sameValue(i, -1, 'i');
}
}
runTestCase(testcase);

View File

@ -6,15 +6,9 @@ es5id: 15.4.4.14-4-5
description: > description: >
Array.prototype.indexOf returns -1 if 'length' is 0 ( length Array.prototype.indexOf returns -1 if 'length' is 0 ( length
overridden to '0' (type conversion)) overridden to '0' (type conversion))
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var i = Array.prototype.indexOf.call({length: '0'}, 1); var i = Array.prototype.indexOf.call({length: '0'}, 1);
if (i === -1) {
return true; assert.sameValue(i, -1, 'i');
}
}
runTestCase(testcase);

View File

@ -6,15 +6,9 @@ es5id: 15.4.4.14-4-6
description: > description: >
Array.prototype.indexOf returns -1 if 'length' is 0 (subclassed Array.prototype.indexOf returns -1 if 'length' is 0 (subclassed
Array, length overridden with obj with valueOf) Array, length overridden with obj with valueOf)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var i = Array.prototype.indexOf.call({length: { valueOf: function () { return 0;}}}, 1); var i = Array.prototype.indexOf.call({length: { valueOf: function () { return 0;}}}, 1);
if (i === -1) {
return true; assert.sameValue(i, -1, 'i');
}
}
runTestCase(testcase);

View File

@ -6,12 +6,8 @@ es5id: 15.4.4.14-4-7
description: > description: >
Array.prototype.indexOf returns -1 if 'length' is 0 ( length is Array.prototype.indexOf returns -1 if 'length' is 0 ( length is
object overridden with obj w/o valueOf (toString)) object overridden with obj w/o valueOf (toString))
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
// objects inherit the default valueOf method of the Object object; // objects inherit the default valueOf method of the Object object;
// that simply returns the itself. Since the default valueOf() method // that simply returns the itself. Since the default valueOf() method
// does not return a primitive value, ES next tries to convert the object // does not return a primitive value, ES next tries to convert the object
@ -19,8 +15,5 @@ function testcase() {
// resulting string to a number. // resulting string to a number.
var i = Array.prototype.indexOf.call({length: { toString: function () { return '0';}}}, 1); var i = Array.prototype.indexOf.call({length: { toString: function () { return '0';}}}, 1);
if (i === -1) {
return true; assert.sameValue(i, -1, 'i');
}
}
runTestCase(testcase);

View File

@ -6,12 +6,8 @@ es5id: 15.4.4.14-4-8
description: > description: >
Array.prototype.indexOf returns -1 if 'length' is 0 (length is an Array.prototype.indexOf returns -1 if 'length' is 0 (length is an
empty array) empty array)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
// objects inherit the default valueOf method of the Object object; // objects inherit the default valueOf method of the Object object;
// that simply returns the itself. Since the default valueOf() method // that simply returns the itself. Since the default valueOf() method
// does not return a primitive value, ES next tries to convert the object // 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. // or if its one element is not a number, the array converts to NaN.
var i = Array.prototype.indexOf.call({length: [ ]}, 1); var i = Array.prototype.indexOf.call({length: [ ]}, 1);
if (i === -1) {
return true; assert.sameValue(i, -1, 'i');
}
}
runTestCase(testcase);

View File

@ -4,12 +4,9 @@
/*--- /*---
es5id: 15.4.4.14-4-9 es5id: 15.4.4.14-4-9
description: Array.prototype.indexOf - 'length' is a number of value 0.1 description: Array.prototype.indexOf - 'length' is a number of value 0.1
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var targetObj = []; var targetObj = [];
var obj = { 0: targetObj, 100: targetObj, length: 0.1 }; var obj = { 0: targetObj, 100: targetObj, length: 0.1 };
return Array.prototype.indexOf.call(obj, targetObj) === -1;
} assert.sameValue(Array.prototype.indexOf.call(obj, targetObj), -1, 'Array.prototype.indexOf.call(obj, targetObj)');
runTestCase(testcase);

View File

@ -6,12 +6,9 @@ es5id: 15.4.4.14-5-10
description: > description: >
Array.prototype.indexOf - value of 'fromIndex' is a number (value Array.prototype.indexOf - value of 'fromIndex' is a number (value
is positive number) is positive number)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var targetObj = {}; var targetObj = {};
return [0, targetObj, 2].indexOf(targetObj, 2) === -1 &&
[0, 1, targetObj].indexOf(targetObj, 2) === 2; 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)');
runTestCase(testcase);

View File

@ -6,12 +6,9 @@ es5id: 15.4.4.14-5-11
description: > description: >
Array.prototype.indexOf - value of 'fromIndex' is a number (value Array.prototype.indexOf - value of 'fromIndex' is a number (value
is negative number) is negative number)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var targetObj = {}; var targetObj = {};
return [0, targetObj, 2].indexOf(targetObj, -1) === -1 &&
[0, 1, targetObj].indexOf(targetObj, -1) === 2; 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)');
runTestCase(testcase);

View File

@ -6,12 +6,9 @@ es5id: 15.4.4.14-5-12
description: > description: >
Array.prototype.indexOf - value of 'fromIndex' is a number (value Array.prototype.indexOf - value of 'fromIndex' is a number (value
is Infinity) is Infinity)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var arr = []; var arr = [];
arr[Math.pow(2, 32) - 2] = true; //length is the max value of Uint type arr[Math.pow(2, 32) - 2] = true; //length is the max value of Uint type
return arr.indexOf(true, Infinity) === -1;
} assert.sameValue(arr.indexOf(true, Infinity), -1, 'arr.indexOf(true, Infinity)');
runTestCase(testcase);

View File

@ -6,12 +6,9 @@ es5id: 15.4.4.14-5-16
description: > description: >
Array.prototype.indexOf - value of 'fromIndex' is a string Array.prototype.indexOf - value of 'fromIndex' is a string
containing Infinity containing Infinity
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var arr = []; var arr = [];
arr[Math.pow(2, 32) - 2] = true; //length is the max value of Uint type arr[Math.pow(2, 32) - 2] = true; //length is the max value of Uint type
return arr.indexOf(true, "Infinity") === -1;
} assert.sameValue(arr.indexOf(true, "Infinity"), -1, 'arr.indexOf(true, "Infinity")');
runTestCase(testcase);

View File

@ -6,12 +6,9 @@ es5id: 15.4.4.14-5-18
description: > description: >
Array.prototype.indexOf - value of 'fromIndex' is a string Array.prototype.indexOf - value of 'fromIndex' is a string
containing an exponential number containing an exponential number
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var targetObj = {}; var targetObj = {};
return [0, 1, targetObj, 3, 4].indexOf(targetObj, "3E0") === -1 &&
[0, 1, 2, targetObj, 4].indexOf(targetObj, "3E0") === 3; 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")');
runTestCase(testcase);

View File

@ -6,12 +6,9 @@ es5id: 15.4.4.14-5-19
description: > description: >
Array.prototype.indexOf - value of 'fromIndex' is a string Array.prototype.indexOf - value of 'fromIndex' is a string
containing a hex number containing a hex number
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var targetObj = {}; var targetObj = {};
return [0, 1, targetObj, 3, 4].indexOf(targetObj, "0x0003") === -1 &&
[0, 1, 2, targetObj, 4].indexOf(targetObj, "0x0003") === 3; 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")');
runTestCase(testcase);

View File

@ -6,12 +6,9 @@ es5id: 15.4.4.14-5-20
description: > description: >
Array.prototype.indexOf - value of 'fromIndex' which is a string Array.prototype.indexOf - value of 'fromIndex' which is a string
containing a number with leading zeros containing a number with leading zeros
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var targetObj = {}; var targetObj = {};
return [0, 1, targetObj, 3, 4].indexOf(targetObj, "0003.10") === -1 &&
[0, 1, 2, targetObj, 4].indexOf(targetObj, "0003.10") === 3; 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")');
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-5-21
description: > description: >
Array.prototype.indexOf - value of 'fromIndex' is an Object, which Array.prototype.indexOf - value of 'fromIndex' is an Object, which
has an own toString method has an own toString method
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
// objects inherit the default valueOf() method from Object // objects inherit the default valueOf() method from Object
// that simply returns itself. Since the default valueOf() method // that simply returns itself. Since the default valueOf() method
// does not return a primitive value, ES next tries to convert the object // 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; assert.sameValue([0, true].indexOf(true, fromIndex), 1, '[0, true].indexOf(true, fromIndex)');
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-5-22
description: > description: >
Array.prototype.indexOf - value of 'fromIndex' is an Object, which Array.prototype.indexOf - value of 'fromIndex' is an Object, which
has an own valueOf method has an own valueOf method
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var fromIndex = { var fromIndex = {
valueOf: function () { valueOf: function () {
return 1; return 1;
@ -18,6 +15,4 @@ function testcase() {
}; };
return [0, true].indexOf(true, fromIndex) === 1; assert.sameValue([0, true].indexOf(true, fromIndex), 1, '[0, true].indexOf(true, fromIndex)');
}
runTestCase(testcase);

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.indexOf - value of 'fromIndex' is an object that Array.prototype.indexOf - value of 'fromIndex' is an object that
has an own valueOf method that returns an object and toString has an own valueOf method that returns an object and toString
method that returns a string method that returns a string
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var toStringAccessed = false; var toStringAccessed = false;
var valueOfAccessed = false; var valueOfAccessed = false;
@ -27,6 +24,6 @@ function testcase() {
} }
}; };
return [0, true].indexOf(true, fromIndex) === 1 && toStringAccessed && valueOfAccessed; assert.sameValue([0, true].indexOf(true, fromIndex), 1, '[0, true].indexOf(true, fromIndex)');
} assert(toStringAccessed, 'toStringAccessed !== true');
runTestCase(testcase); assert(valueOfAccessed, 'valueOfAccessed !== true');

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.indexOf uses inherited valueOf method when value Array.prototype.indexOf uses inherited valueOf method when value
of 'fromIndex' is an object with an own toString and inherited of 'fromIndex' is an object with an own toString and inherited
valueOf methods valueOf methods
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var toStringAccessed = false; var toStringAccessed = false;
var valueOfAccessed = false; var valueOfAccessed = false;
@ -31,6 +28,6 @@ function testcase() {
return 2; return 2;
}; };
return [0, true].indexOf(true, child) === 1 && valueOfAccessed && !toStringAccessed; assert.sameValue([0, true].indexOf(true, child), 1, '[0, true].indexOf(true, child)');
} assert(valueOfAccessed, 'valueOfAccessed !== true');
runTestCase(testcase); assert.sameValue(toStringAccessed, false, 'toStringAccessed');

View File

@ -6,12 +6,9 @@ es5id: 15.4.4.14-5-31
description: > description: >
Array.prototype.indexOf - 'fromIndex' is a positive non-integer, Array.prototype.indexOf - 'fromIndex' is a positive non-integer,
verify truncation occurs in the proper direction verify truncation occurs in the proper direction
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var targetObj = {}; var targetObj = {};
return [0, targetObj, 2].indexOf(targetObj, 2.5) === -1 &&
[0, 1, targetObj].indexOf(targetObj, 2.5) === 2; 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)');
runTestCase(testcase);

View File

@ -6,12 +6,9 @@ es5id: 15.4.4.14-5-32
description: > description: >
Array.prototype.indexOf - 'fromIndex' is a negative non-integer, Array.prototype.indexOf - 'fromIndex' is a negative non-integer,
verify truncation occurs in the proper direction verify truncation occurs in the proper direction
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var targetObj = {}; var targetObj = {};
return [0, targetObj, 2].indexOf(targetObj, -1.5) === -1 &&
[0, 1, targetObj].indexOf(targetObj, -1.5) === 2; 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)');
runTestCase(testcase);

View File

@ -4,14 +4,11 @@
/*--- /*---
es5id: 15.4.4.14-5-6 es5id: 15.4.4.14-5-6
description: Array.prototype.indexOf - 'fromIndex' isn't passed description: Array.prototype.indexOf - 'fromIndex' isn't passed
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var arr = [0, 1, 2, 3, 4]; var arr = [0, 1, 2, 3, 4];
//'fromIndex' will be set as 0 if not passed by default //'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) && assert.sameValue(arr.indexOf(0), arr.indexOf(0, 0), 'arr.indexOf(0)');
arr.indexOf(4) === arr.indexOf(4, 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)');
runTestCase(testcase);

View File

@ -6,15 +6,10 @@ es5id: 15.4.4.14-6-1
description: > description: >
Array.prototype.indexOf returns -1 if fromIndex is greater than Array.prototype.indexOf returns -1 if fromIndex is greater than
Array length Array length
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var a = [1,2,3]; var a = [1,2,3];
if (a.indexOf(1,5) === -1 &&
a.indexOf(1,3) === -1 && assert.sameValue(a.indexOf(1,5), -1, 'a.indexOf(1,5)');
[ ].indexOf(1,0) === -1 ){ assert.sameValue(a.indexOf(1,3), -1, 'a.indexOf(1,3)');
return true; assert.sameValue([ ].indexOf(1,0), -1, '[ ].indexOf(1,0)');
}
}
runTestCase(testcase);

View File

@ -4,17 +4,12 @@
/*--- /*---
es5id: 15.4.4.14-8-1 es5id: 15.4.4.14-8-1
description: Array.prototype.indexOf with negative fromIndex description: Array.prototype.indexOf with negative fromIndex
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var a = new Array(1,2,3); var a = new Array(1,2,3);
if (a.indexOf(2,-1) === -1 &&
a.indexOf(2,-2) === 1 && assert.sameValue(a.indexOf(2,-1), -1, 'a.indexOf(2,-1)');
a.indexOf(1,-3) === 0 && assert.sameValue(a.indexOf(2,-2), 1, 'a.indexOf(2,-2)');
a.indexOf(1,-5.3) === 0 ) { assert.sameValue(a.indexOf(1,-3), 0, 'a.indexOf(1,-3)');
return true; assert.sameValue(a.indexOf(1,-5.3), 0, 'a.indexOf(1,-5.3)');
}
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-11
description: > description: >
Array.prototype.indexOf - the length of iteration isn't changed by Array.prototype.indexOf - the length of iteration isn't changed by
adding elements to the array during iteration adding elements to the array during iteration
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var arr = [20]; var arr = [20];
Object.defineProperty(arr, "0", { Object.defineProperty(arr, "0", {
@ -21,6 +18,4 @@ function testcase() {
configurable: true configurable: true
}); });
return arr.indexOf(1) === -1; assert.sameValue(arr.indexOf(1), -1, 'arr.indexOf(1)');
}
runTestCase(testcase);

View File

@ -4,16 +4,10 @@
/*--- /*---
es5id: 15.4.4.14-9-7 es5id: 15.4.4.14-9-7
description: Array.prototype.indexOf must return correct index (self reference) description: Array.prototype.indexOf must return correct index (self reference)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var a = new Array(0,1,2,3); var a = new Array(0,1,2,3);
a[2] = a; a[2] = a;
if (a.indexOf(a) === 2 &&
a.indexOf(3) === 3 ) assert.sameValue(a.indexOf(a), 2, 'a.indexOf(a)');
{ assert.sameValue(a.indexOf(3), 3, 'a.indexOf(3)');
return true;
}
}
runTestCase(testcase);

View File

@ -4,16 +4,10 @@
/*--- /*---
es5id: 15.4.4.14-9-8 es5id: 15.4.4.14-9-8
description: Array.prototype.indexOf must return correct index (Array) description: Array.prototype.indexOf must return correct index (Array)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var b = new Array("0,1"); var b = new Array("0,1");
var a = new Array(0,b,"0,1",3); var a = new Array(0,b,"0,1",3);
if (a.indexOf(b.toString()) === 2 &&
a.indexOf("0,1") === 2 ) assert.sameValue(a.indexOf(b.toString()), 2, 'a.indexOf(b.toString())');
{ assert.sameValue(a.indexOf("0,1"), 2, 'a.indexOf("0,1")');
return true;
}
}
runTestCase(testcase);

View File

@ -4,10 +4,8 @@
/*--- /*---
es5id: 15.4.4.14-9-9 es5id: 15.4.4.14-9-9
description: Array.prototype.indexOf must return correct index (Sparse Array) description: Array.prototype.indexOf must return correct index (Sparse Array)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var a = new Array(0,1); var a = new Array(0,1);
a[4294967294] = 2; // 2^32-2 - is max array element a[4294967294] = 2; // 2^32-2 - is max array element
a[4294967295] = 3; // 2^32-1 added as non-array element property 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 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!! // 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 && assert.sameValue(a.indexOf(2,4294967290 ), 4294967294, 'a.indexOf(2,4294967290 )');
a.indexOf(4,4294967290) === -1 && assert.sameValue(a.indexOf(3,4294967290), -1, 'a.indexOf(3,4294967290)');
a.indexOf(5,4294967290) === -1 ) ; assert.sameValue(a.indexOf(4,4294967290), -1, 'a.indexOf(4,4294967290)');
} assert.sameValue(a.indexOf(5,4294967290), -1, 'a.indexOf(5,4294967290)');
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-1
description: > description: >
Array.prototype.indexOf - added properties in step 2 are visible Array.prototype.indexOf - added properties in step 2 are visible
here here
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var arr = { }; var arr = { };
Object.defineProperty(arr, "length", { Object.defineProperty(arr, "length", {
@ -21,6 +18,4 @@ function testcase() {
configurable: true configurable: true
}); });
return 2 === Array.prototype.indexOf.call(arr, "length"); assert.sameValue(Array.prototype.indexOf.call(arr, "length"), 2, 'Array.prototype.indexOf.call(arr, "length")');
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-11
description: > description: >
Array.prototype.indexOf - deleting own property causes index Array.prototype.indexOf - deleting own property causes index
property not to be visited on an Array-like object property not to be visited on an Array-like object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var arr = { length: 2 }; var arr = { length: 2 };
Object.defineProperty(arr, "1", { Object.defineProperty(arr, "1", {
@ -28,6 +25,4 @@ function testcase() {
configurable: true configurable: true
}); });
return -1 === Array.prototype.indexOf.call(arr, 6.99); assert.sameValue(Array.prototype.indexOf.call(arr, 6.99), -1, 'Array.prototype.indexOf.call(arr, 6.99)');
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-12
description: > description: >
Array.prototype.indexOf - deleting own property causes index Array.prototype.indexOf - deleting own property causes index
property not to be visited on an Array property not to be visited on an Array
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var arr = [1, 2]; var arr = [1, 2];
Object.defineProperty(arr, "1", { Object.defineProperty(arr, "1", {
@ -28,6 +25,4 @@ function testcase() {
configurable: true configurable: true
}); });
return -1 === arr.indexOf("6.99"); assert.sameValue(arr.indexOf("6.99"), -1, 'arr.indexOf("6.99")');
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-17
description: > description: >
Array.prototype.indexOf - decreasing length of array causes index Array.prototype.indexOf - decreasing length of array causes index
property not to be visited property not to be visited
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var arr = [0, 1, 2, "last"]; var arr = [0, 1, 2, "last"];
Object.defineProperty(arr, "0", { Object.defineProperty(arr, "0", {
@ -21,6 +18,4 @@ function testcase() {
configurable: true configurable: true
}); });
return -1 === arr.indexOf("last"); assert.sameValue(arr.indexOf("last"), -1, 'arr.indexOf("last")');
}
runTestCase(testcase);

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.indexOf - decreasing length of array does not Array.prototype.indexOf - decreasing length of array does not
delete non-configurable properties delete non-configurable properties
flags: [noStrict] flags: [noStrict]
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var arr = [0, 1, 2]; var arr = [0, 1, 2];
Object.defineProperty(arr, "2", { Object.defineProperty(arr, "2", {
@ -29,6 +26,5 @@ function testcase() {
configurable: true configurable: true
}); });
return 2 === arr.indexOf("unconfigurable");
} assert.sameValue(arr.indexOf("unconfigurable"), 2, 'arr.indexOf("unconfigurable")');
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-2
description: > description: >
Array.prototype.indexOf - added properties in step 5 are visible Array.prototype.indexOf - added properties in step 5 are visible
here on an Array-like object here on an Array-like object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var arr = { length: 30 }; var arr = { length: 30 };
var targetObj = function () { }; var targetObj = function () { };
@ -21,6 +18,5 @@ function testcase() {
} }
}; };
return 4 === Array.prototype.indexOf.call(arr, targetObj, fromIndex);
} assert.sameValue(Array.prototype.indexOf.call(arr, targetObj, fromIndex), 4, 'Array.prototype.indexOf.call(arr, targetObj, fromIndex)');
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-3
description: > description: >
Array.prototype.indexOf - added properties in step 5 are visible Array.prototype.indexOf - added properties in step 5 are visible
here on an Array here on an Array
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var arr = []; var arr = [];
arr.length = 30; arr.length = 30;
var targetObj = function () { }; var targetObj = function () { };
@ -22,6 +19,4 @@ function testcase() {
} }
}; };
return 4 === arr.indexOf(targetObj, fromIndex); assert.sameValue(arr.indexOf(targetObj, fromIndex), 4, 'arr.indexOf(targetObj, fromIndex)');
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-4
description: > description: >
Array.prototype.indexOf - deleted properties in step 2 are visible Array.prototype.indexOf - deleted properties in step 2 are visible
here here
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var arr = { 2: 6.99 }; var arr = { 2: 6.99 };
Object.defineProperty(arr, "length", { Object.defineProperty(arr, "length", {
@ -21,6 +18,4 @@ function testcase() {
configurable: true configurable: true
}); });
return -1 === Array.prototype.indexOf.call(arr, 6.99); assert.sameValue(Array.prototype.indexOf.call(arr, 6.99), -1, 'Array.prototype.indexOf.call(arr, 6.99)');
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-5
description: > description: >
Array.prototype.indexOf - deleted properties in step 5 are visible Array.prototype.indexOf - deleted properties in step 5 are visible
here on an Array-like object here on an Array-like object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var arr = { 10: false, length: 30 }; var arr = { 10: false, length: 30 };
var fromIndex = { var fromIndex = {
@ -20,6 +17,4 @@ function testcase() {
} }
}; };
return -1 === Array.prototype.indexOf.call(arr, false, fromIndex); assert.sameValue(Array.prototype.indexOf.call(arr, false, fromIndex), -1, 'Array.prototype.indexOf.call(arr, false, fromIndex)');
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-6
description: > description: >
Array.prototype.indexOf - deleted properties in step 5 are visible Array.prototype.indexOf - deleted properties in step 5 are visible
here on an Array here on an Array
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var arr = []; var arr = [];
arr[10] = "10"; arr[10] = "10";
arr.length = 20; arr.length = 20;
@ -22,6 +19,4 @@ function testcase() {
} }
}; };
return -1 === arr.indexOf("10", fromIndex); assert.sameValue(arr.indexOf("10", fromIndex), -1, 'arr.indexOf("10", fromIndex)');
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-7
description: > description: >
Array.prototype.indexOf - properties added into own object after Array.prototype.indexOf - properties added into own object after
current position are visited on an Array-like object current position are visited on an Array-like object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var arr = { length: 2 }; var arr = { length: 2 };
Object.defineProperty(arr, "0", { Object.defineProperty(arr, "0", {
@ -26,6 +23,4 @@ function testcase() {
configurable: true configurable: true
}); });
return Array.prototype.indexOf.call(arr, 1) === 1; assert.sameValue(Array.prototype.indexOf.call(arr, 1), 1, 'Array.prototype.indexOf.call(arr, 1)');
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-a-8
description: > description: >
Array.prototype.indexOf - properties added into own object after Array.prototype.indexOf - properties added into own object after
current position are visited on an Array current position are visited on an Array
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var arr = [0, , 2]; var arr = [0, , 2];
Object.defineProperty(arr, "0", { Object.defineProperty(arr, "0", {
@ -26,6 +23,4 @@ function testcase() {
configurable: true configurable: true
}); });
return arr.indexOf(1) === 1; assert.sameValue(arr.indexOf(1), 1, 'arr.indexOf(1)');
}
runTestCase(testcase);

View File

@ -6,13 +6,10 @@ es5id: 15.4.4.14-9-b-i-1
description: > description: >
Array.prototype.indexOf - element to be retrieved is own data Array.prototype.indexOf - element to be retrieved is own data
property on an Array-like object property on an Array-like object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 0, 1: 1, 2: 2, length: 3 }; 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 && assert.sameValue(Array.prototype.indexOf.call(obj, 0), 0, 'Array.prototype.indexOf.call(obj, 0)');
Array.prototype.indexOf.call(obj, 2) === 2; 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)');
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.14-9-b-i-10
description: > description: >
Array.prototype.indexOf - element to be retrieved is own accessor Array.prototype.indexOf - element to be retrieved is own accessor
property on an Array-like object property on an Array-like object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { length: 3 }; var obj = { length: 3 };
Object.defineProperty(obj, "0", { Object.defineProperty(obj, "0", {
get: function () { get: function () {
@ -33,8 +30,6 @@ function testcase() {
configurable: true configurable: true
}); });
return 0 === Array.prototype.indexOf.call(obj, 0) && assert.sameValue(Array.prototype.indexOf.call(obj, 0), 0, 'Array.prototype.indexOf.call(obj, 0)');
1 === Array.prototype.indexOf.call(obj, 1) && assert.sameValue(Array.prototype.indexOf.call(obj, 1), 1, 'Array.prototype.indexOf.call(obj, 1)');
2 === Array.prototype.indexOf.call(obj, 2); assert.sameValue(Array.prototype.indexOf.call(obj, 2), 2, 'Array.prototype.indexOf.call(obj, 2)');
}
runTestCase(testcase);

View File

@ -6,17 +6,12 @@ es5id: 15.4.4.14-9-b-i-17
description: > description: >
Array.prototype.indexOf - element to be retrieved is own accessor Array.prototype.indexOf - element to be retrieved is own accessor
property without a get function on an Array property without a get function on an Array
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var arr = []; var arr = [];
Object.defineProperty(arr, "0", { Object.defineProperty(arr, "0", {
set: function () { }, set: function () { },
configurable: true configurable: true
}); });
return arr.indexOf(undefined) === 0; assert.sameValue(arr.indexOf(undefined), 0, 'arr.indexOf(undefined)');
}
runTestCase(testcase);

View File

@ -6,17 +6,12 @@ es5id: 15.4.4.14-9-b-i-18
description: > description: >
Array.prototype.indexOf - element to be retrieved is own accessor Array.prototype.indexOf - element to be retrieved is own accessor
property without a get function on an Array-like object property without a get function on an Array-like object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { length: 1 }; var obj = { length: 1 };
Object.defineProperty(obj, "0", { Object.defineProperty(obj, "0", {
set: function () { }, set: function () { },
configurable: true configurable: true
}); });
return 0 === Array.prototype.indexOf.call(obj, undefined); assert.sameValue(Array.prototype.indexOf.call(obj, undefined), 0, 'Array.prototype.indexOf.call(obj, undefined)');
}
runTestCase(testcase);

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.indexOf - element to be retrieved is own accessor Array.prototype.indexOf - element to be retrieved is own accessor
property without a get function that overrides an inherited property without a get function that overrides an inherited
accessor property on an Array-like object accessor property on an Array-like object
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var proto = {}; var proto = {};
Object.defineProperty(proto, "0", { Object.defineProperty(proto, "0", {
get: function () { get: function () {
@ -31,6 +28,4 @@ function testcase() {
configurable: true configurable: true
}); });
return Array.prototype.indexOf.call(child, undefined) === 0; assert.sameValue(Array.prototype.indexOf.call(child, undefined), 0, 'Array.prototype.indexOf.call(child, undefined)');
}
runTestCase(testcase);

View File

@ -7,16 +7,11 @@ description: >
Array.prototype.indexOf applied to Arguments object which Array.prototype.indexOf applied to Arguments object which
implements its own property get method (number of arguments is implements its own property get method (number of arguments is
less than number of parameters) less than number of parameters)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var func = function (a, b) { var func = function (a, b) {
return 0 === Array.prototype.indexOf.call(arguments, arguments[0]) && return 0 === Array.prototype.indexOf.call(arguments, arguments[0]) &&
-1 === Array.prototype.indexOf.call(arguments, arguments[1]); -1 === Array.prototype.indexOf.call(arguments, arguments[1]);
}; };
return func(true); assert(func(true), 'func(true) !== true');
}
runTestCase(testcase);

View File

@ -7,17 +7,12 @@ description: >
Array.prototype.indexOf applied to Arguments object which Array.prototype.indexOf applied to Arguments object which
implements its own property get method (number of arguments equals implements its own property get method (number of arguments equals
to number of parameters) to number of parameters)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var func = function (a, b) { var func = function (a, b) {
return 0 === Array.prototype.indexOf.call(arguments, arguments[0]) && return 0 === Array.prototype.indexOf.call(arguments, arguments[0]) &&
1 === Array.prototype.indexOf.call(arguments, arguments[1]) && 1 === Array.prototype.indexOf.call(arguments, arguments[1]) &&
-1 === Array.prototype.indexOf.call(arguments, arguments[2]); -1 === Array.prototype.indexOf.call(arguments, arguments[2]);
}; };
return func(0, true); assert(func(0, true), 'func(0, true) !== true');
}
runTestCase(testcase);

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