mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Replace runTestCase with assert helpers [test/built-ins/Array/prototype/lastIndexOf]
This commit is contained in:
parent
7510a91a7e
commit
354b7cc11b
@ -4,13 +4,8 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-0-1
|
||||
description: Array.prototype.lastIndexOf must exist as a function
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var f = Array.prototype.lastIndexOf;
|
||||
if (typeof(f) === "function") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(typeof(f), "function", 'typeof(f)');
|
||||
|
@ -4,12 +4,6 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-0-2
|
||||
description: Array.prototype.lastIndexOf has a length property whose value is 1.
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
if (Array.prototype.lastIndexOf.length === 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.length, 1, 'Array.prototype.lastIndexOf.length');
|
||||
|
@ -4,15 +4,10 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-1-11
|
||||
description: Array.prototype.lastIndexOf applied to Date object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = new Date();
|
||||
obj.length = 2;
|
||||
obj[1] = true;
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, true) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)');
|
||||
|
@ -4,15 +4,10 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-1-12
|
||||
description: Array.prototype.lastIndexOf applied to RegExp object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = new RegExp("afdasf");
|
||||
obj.length = 100;
|
||||
obj[1] = "afdasf";
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, "afdasf") === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, "afdasf"), 1, 'Array.prototype.lastIndexOf.call(obj, "afdasf")');
|
||||
|
@ -4,15 +4,10 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-1-14
|
||||
description: Array.prototype.lastIndexOf applied to Error object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = new SyntaxError();
|
||||
obj.length = 2;
|
||||
obj[1] = Infinity;
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, Infinity) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, Infinity), 1, 'Array.prototype.lastIndexOf.call(obj, Infinity)');
|
||||
|
@ -4,15 +4,10 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-1-15
|
||||
description: Array.prototype.lastIndexOf applied to the Arguments object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = (function fun() {
|
||||
return arguments;
|
||||
}(1, 2, 3));
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, 2) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2), 1, 'Array.prototype.lastIndexOf.call(obj, 2)');
|
||||
|
@ -4,15 +4,10 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-1-4
|
||||
description: Array.prototype.lastIndexOf applied to Boolean object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = new Boolean(false);
|
||||
obj.length = 2;
|
||||
obj[1] = true;
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, true) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)');
|
||||
|
@ -4,15 +4,10 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-1-6
|
||||
description: Array.prototype.lastIndexOf applied to Number object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = new Number(-3);
|
||||
obj.length = 2;
|
||||
obj[1] = true;
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, true) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)');
|
||||
|
@ -4,13 +4,8 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-1-8
|
||||
description: Array.prototype.lastIndexOf applied to String object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = new String("undefined");
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, "f") === 4;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, "f"), 4, 'Array.prototype.lastIndexOf.call(obj, "f")');
|
||||
|
@ -4,16 +4,11 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-1-9
|
||||
description: Array.prototype.lastIndexOf applied to Function object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = function (a, b) {
|
||||
return a + b;
|
||||
};
|
||||
obj[1] = true;
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, true) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)');
|
||||
|
@ -6,13 +6,9 @@ es5id: 15.4.4.15-2-1
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 'length' is own data property on an
|
||||
Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var obj = { 1: null, 2: undefined, length: 2 };
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, null) === 1 &&
|
||||
Array.prototype.lastIndexOf.call(obj, undefined) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, null), 1, 'Array.prototype.lastIndexOf.call(obj, null)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, undefined), -1, 'Array.prototype.lastIndexOf.call(obj, undefined)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-2-10
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 'length' is inherited accessor
|
||||
property on an Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var proto = {};
|
||||
Object.defineProperty(proto, "length", {
|
||||
get: function () {
|
||||
@ -26,7 +23,5 @@ function testcase() {
|
||||
child[1] = 1;
|
||||
child[2] = 2;
|
||||
|
||||
return Array.prototype.lastIndexOf.call(child, 1) === 1 &&
|
||||
Array.prototype.lastIndexOf.call(child, 2) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(child, 1), 1, 'Array.prototype.lastIndexOf.call(child, 1)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(child, 2), -1, 'Array.prototype.lastIndexOf.call(child, 2)');
|
||||
|
@ -6,17 +6,12 @@ es5id: 15.4.4.15-2-11
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 'length' is own accessor property
|
||||
without a get function on an Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: 1 };
|
||||
Object.defineProperty(obj, "length", {
|
||||
set: function () { },
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, 1) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), -1, 'Array.prototype.lastIndexOf.call(obj, 1)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-2-13
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 'length' is inherited accessor
|
||||
property without a get function on an Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var proto = {};
|
||||
Object.defineProperty(proto, "length", {
|
||||
set: function () { },
|
||||
@ -23,6 +20,4 @@ function testcase() {
|
||||
var child = new Con();
|
||||
child[0] = true;
|
||||
|
||||
return Array.prototype.lastIndexOf.call(child, true) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(child, true), -1, 'Array.prototype.lastIndexOf.call(child, true)');
|
||||
|
@ -6,13 +6,8 @@ es5id: 15.4.4.15-2-14
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 'length' is undefined property on an
|
||||
Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: null, 1: undefined };
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, null) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, null), -1, 'Array.prototype.lastIndexOf.call(obj, null)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-2-17
|
||||
description: >
|
||||
Array.prototype.lastIndexOf applied to Arguments object which
|
||||
implements its own property get method
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var targetObj = function () { };
|
||||
var func = function (a, b) {
|
||||
arguments[2] = function () { };
|
||||
@ -18,6 +15,4 @@ function testcase() {
|
||||
Array.prototype.lastIndexOf.call(arguments, arguments[2]) === -1;
|
||||
};
|
||||
|
||||
return func(0, targetObj);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert(func(0, targetObj), 'func(0, targetObj) !== true');
|
||||
|
@ -6,18 +6,13 @@ es5id: 15.4.4.15-2-19
|
||||
description: >
|
||||
Array.prototype.lastIndexOf applied to String 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.lastIndexOf.call(obj, obj[1]) === 1 &&
|
||||
Array.prototype.lastIndexOf.call(obj, obj[2]) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, obj[1]), 1, 'Array.prototype.lastIndexOf.call(obj, obj[1])');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, obj[2]), -1, 'Array.prototype.lastIndexOf.call(obj, obj[2])');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-2-3
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - '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] = child;
|
||||
|
||||
return Array.prototype.lastIndexOf.call(child, child) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(child, child), 1, 'Array.prototype.lastIndexOf.call(child, child)');
|
||||
|
@ -6,10 +6,8 @@ es5id: 15.4.4.15-2-5
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - '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] = null;
|
||||
|
||||
return Array.prototype.lastIndexOf.call(child, null) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(child, null), 1, 'Array.prototype.lastIndexOf.call(child, null)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-2-6
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 'length' is an inherited data
|
||||
property on an Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var proto = { length: 2 };
|
||||
|
||||
var Con = function () {};
|
||||
@ -20,7 +17,5 @@ function testcase() {
|
||||
child[1] = "x";
|
||||
child[2] = "y";
|
||||
|
||||
return Array.prototype.lastIndexOf.call(child, "x") === 1 &&
|
||||
Array.prototype.lastIndexOf.call(child, "y") === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(child, "x"), 1, 'Array.prototype.lastIndexOf.call(child, "x")');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(child, "y"), -1, 'Array.prototype.lastIndexOf.call(child, "y")');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-2-7
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 'length' is own accessor property on
|
||||
an Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 1: true, 2: false };
|
||||
|
||||
Object.defineProperty(obj, "length", {
|
||||
@ -20,7 +17,5 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, true) === 1 &&
|
||||
Array.prototype.lastIndexOf.call(obj, false) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, false), -1, 'Array.prototype.lastIndexOf.call(obj, false)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-2-8
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 'length' is own accessor property
|
||||
that overrides an inherited data property on an Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var proto = { length: 0 };
|
||||
|
||||
var Con = function () {};
|
||||
@ -26,6 +23,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return Array.prototype.lastIndexOf.call(child, eval) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(child, eval), 1, 'Array.prototype.lastIndexOf.call(child, eval)');
|
||||
|
@ -7,10 +7,8 @@ description: >
|
||||
Array.prototype.lastIndexOf - 'length' is own accessor 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 () {
|
||||
@ -32,6 +30,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return Array.prototype.lastIndexOf.call(child, true) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(child, true), 1, 'Array.prototype.lastIndexOf.call(child, true)');
|
||||
|
@ -4,13 +4,8 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-3-1
|
||||
description: Array.prototype.lastIndexOf - value of 'length' is undefined
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: 1, 1: 1, length: undefined };
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, 1) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), -1, 'Array.prototype.lastIndexOf.call(obj, 1)');
|
||||
|
@ -6,13 +6,8 @@ es5id: 15.4.4.15-3-10
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'length' is a number (value
|
||||
is NaN)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: 0, length: NaN };
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, 0) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 0), -1, 'Array.prototype.lastIndexOf.call(obj, 0)');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.15-3-11
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'length' is a string
|
||||
containing positive number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = {1: true, 2: false, length: "2"};
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, true) === 1 &&
|
||||
Array.prototype.lastIndexOf.call(obj, false) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, false), -1, 'Array.prototype.lastIndexOf.call(obj, false)');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.15-3-12
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'length' is a string
|
||||
containing negative number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = {1: null, 2: undefined, length: "-4294967294"};
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, null) === -1 &&
|
||||
Array.prototype.lastIndexOf.call(obj, undefined) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, null), -1, 'Array.prototype.lastIndexOf.call(obj, null)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, undefined), -1, 'Array.prototype.lastIndexOf.call(obj, undefined)');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.15-3-13
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'length' is a string
|
||||
containing a decimal number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 4: 4, 5: 5, length: "5.512345" };
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, 4) === 4 &&
|
||||
Array.prototype.lastIndexOf.call(obj, 5) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 4), 4, 'Array.prototype.lastIndexOf.call(obj, 4)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 5), -1, 'Array.prototype.lastIndexOf.call(obj, 5)');
|
||||
|
@ -6,13 +6,8 @@ es5id: 15.4.4.15-3-14
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'length' is a string
|
||||
containing -Infinity
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var objThree = { 0: true, 1: true, length: "-Infinity" };
|
||||
|
||||
return Array.prototype.lastIndexOf.call(objThree, true) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(objThree, true), -1, 'Array.prototype.lastIndexOf.call(objThree, true)');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.15-3-15
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'length' is a string
|
||||
containing an exponential number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = {229: 229, 230: 2.3E2, length: "2.3E2"};
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, 229) === 229 &&
|
||||
Array.prototype.lastIndexOf.call(obj, 2.3E2) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 229), 229, 'Array.prototype.lastIndexOf.call(obj, 229)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2.3E2), -1, 'Array.prototype.lastIndexOf.call(obj, 2.3E2)');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.15-3-16
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'length' is a string which
|
||||
is able to be converted into hex number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 2573: 2573, 2574: 0x000A0E, length: "0x000A0E" };
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, 2573) === 2573 &&
|
||||
Array.prototype.lastIndexOf.call(obj, 0x000A0E) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2573), 2573, 'Array.prototype.lastIndexOf.call(obj, 2573)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 0x000A0E), -1, 'Array.prototype.lastIndexOf.call(obj, 0x000A0E)');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.15-3-17
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'length' is a string
|
||||
containing a number with leading zeros
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 1: 1, 2: 2, length: "0002.0" };
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, 1) === 1 &&
|
||||
Array.prototype.lastIndexOf.call(obj, 2) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), 1, 'Array.prototype.lastIndexOf.call(obj, 1)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2), -1, 'Array.prototype.lastIndexOf.call(obj, 2)');
|
||||
|
@ -6,13 +6,9 @@ es5id: 15.4.4.15-3-18
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'length' is a string that
|
||||
can't convert to a number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = new String("123abc123");
|
||||
var obj = { 0: targetObj, length: "123abc123" };
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, targetObj) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), -1, 'Array.prototype.lastIndexOf.call(obj, targetObj)');
|
||||
|
@ -6,13 +6,9 @@ es5id: 15.4.4.15-3-19
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'length' is an Object which
|
||||
has an own toString method
|
||||
includes:
|
||||
- runTestCase.js
|
||||
- fnGlobalObject.js
|
||||
includes: [fnGlobalObject.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
|
||||
@ -31,7 +27,5 @@ function testcase() {
|
||||
}
|
||||
};
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, targetObj) === 1 &&
|
||||
Array.prototype.lastIndexOf.call(obj, 2) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), 1, 'Array.prototype.lastIndexOf.call(obj, targetObj)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2), -1, 'Array.prototype.lastIndexOf.call(obj, 2)');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.15-3-2
|
||||
description: >
|
||||
Array.prototype.lastIndexOf return -1 when value of 'length' is a
|
||||
boolean (value is true)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var obj = { 0: 0, 1: 1, length: true };
|
||||
return Array.prototype.lastIndexOf.call(obj, 0) === 0 &&
|
||||
Array.prototype.lastIndexOf.call(obj, 1) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 0), 0, 'Array.prototype.lastIndexOf.call(obj, 0)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), -1, 'Array.prototype.lastIndexOf.call(obj, 1)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-3-20
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 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,
|
||||
@ -23,7 +20,5 @@ function testcase() {
|
||||
}
|
||||
};
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, true) === 1 &&
|
||||
Array.prototype.lastIndexOf.call(obj, 2) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2), -1, 'Array.prototype.lastIndexOf.call(obj, 2)');
|
||||
|
@ -7,11 +7,8 @@ description: >
|
||||
Array.prototype.lastIndexOf - '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;
|
||||
|
||||
@ -31,6 +28,6 @@ function testcase() {
|
||||
}
|
||||
};
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, targetObj) === 1 && toStringAccessed && valueOfAccessed;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), 1, 'Array.prototype.lastIndexOf.call(obj, targetObj)');
|
||||
assert(toStringAccessed, 'toStringAccessed !== true');
|
||||
assert(valueOfAccessed, 'valueOfAccessed !== true');
|
||||
|
@ -7,11 +7,8 @@ description: >
|
||||
Array.prototype.lastIndexOf uses inherited valueOf method when
|
||||
'length' is an object with an own toString and an 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.lastIndexOf.call(obj, child) === 1 && valueOfAccessed && !toStringAccessed;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, child), 1, 'Array.prototype.lastIndexOf.call(obj, child)');
|
||||
assert(valueOfAccessed, 'valueOfAccessed !== true');
|
||||
assert.sameValue(toStringAccessed, false, 'toStringAccessed');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.15-3-24
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 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.5 };
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, true) === 122 &&
|
||||
Array.prototype.lastIndexOf.call(obj, false) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 122, 'Array.prototype.lastIndexOf.call(obj, true)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, false), -1, 'Array.prototype.lastIndexOf.call(obj, false)');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.15-3-25
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'length' is a negative
|
||||
non-integer
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 1: true, 2: false, length: -4294967294.5 };
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, true) === -1 &&
|
||||
Array.prototype.lastIndexOf.call(obj, false) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), -1, 'Array.prototype.lastIndexOf.call(obj, true)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, false), -1, 'Array.prototype.lastIndexOf.call(obj, false)');
|
||||
|
@ -6,13 +6,8 @@ es5id: 15.4.4.15-3-3
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'length' is a number (value
|
||||
is 0)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: "undefined", length: 0 };
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, "undefined") === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, "undefined"), -1, 'Array.prototype.lastIndexOf.call(obj, "undefined")');
|
||||
|
@ -6,13 +6,8 @@ es5id: 15.4.4.15-3-4
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'length' is a number (value
|
||||
is -0)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: true, length: -0 };
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, true) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), -1, 'Array.prototype.lastIndexOf.call(obj, true)');
|
||||
|
@ -6,13 +6,8 @@ es5id: 15.4.4.15-3-5
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'length' is a number (value
|
||||
is +0)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: +0, length: +0 };
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, +0) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, +0), -1, 'Array.prototype.lastIndexOf.call(obj, +0)');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.15-3-6
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'length' is a number (value
|
||||
is a positive number)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 99: true, 100: 100, length: 100 };
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, true) === 99 &&
|
||||
Array.prototype.lastIndexOf.call(obj, 100) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 99, 'Array.prototype.lastIndexOf.call(obj, true)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 100), -1, 'Array.prototype.lastIndexOf.call(obj, 100)');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.15-3-7
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'length' is a number (value
|
||||
is a negative number)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 4: -Infinity, 5: Infinity, length: 5 - Math.pow(2, 32) };
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, -Infinity) === -1 &&
|
||||
Array.prototype.lastIndexOf.call(obj, Infinity) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, -Infinity), -1, 'Array.prototype.lastIndexOf.call(obj, -Infinity)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, Infinity), -1, 'Array.prototype.lastIndexOf.call(obj, Infinity)');
|
||||
|
@ -6,13 +6,8 @@ es5id: 15.4.4.15-3-9
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'length' is a number (value
|
||||
is -Infinity)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: 0, length: -Infinity };
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, 0) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 0), -1, 'Array.prototype.lastIndexOf.call(obj, 0)');
|
||||
|
@ -6,13 +6,8 @@ es5id: 15.4.4.15-4-1
|
||||
description: >
|
||||
Array.prototype.lastIndexOf returns -1 if 'length' is 0 (empty
|
||||
array)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var i = [].lastIndexOf(42);
|
||||
if (i === -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(i, -1, 'i');
|
||||
|
@ -4,12 +4,9 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-4-10
|
||||
description: Array.prototype.lastIndexOf - '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.lastIndexOf.call(obj, targetObj) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), -1, 'Array.prototype.lastIndexOf.call(obj, targetObj)');
|
||||
|
@ -4,12 +4,9 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-4-11
|
||||
description: Array.prototype.lastIndexOf - 'length' is an empty string
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = [];
|
||||
var obj = { 0: targetObj, 100: targetObj, length: "" };
|
||||
return Array.prototype.lastIndexOf.call(obj, targetObj) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), -1, 'Array.prototype.lastIndexOf.call(obj, targetObj)');
|
||||
|
@ -6,15 +6,9 @@ es5id: 15.4.4.15-4-2
|
||||
description: >
|
||||
Array.prototype.lastIndexOf returns -1 if 'length' is 0 ( length
|
||||
overridden to null (type conversion))
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var i = Array.prototype.lastIndexOf.call({length: null}, 1);
|
||||
|
||||
if (i === -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(i, -1, 'i');
|
||||
|
@ -6,15 +6,9 @@ es5id: 15.4.4.15-4-3
|
||||
description: >
|
||||
Array.prototype.lastIndexOf returns -1 if 'length' is 0 (length
|
||||
overridden to false (type conversion))
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var i = Array.prototype.lastIndexOf.call({length: false}, 1);
|
||||
|
||||
if (i === -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(i, -1, 'i');
|
||||
|
@ -6,10 +6,8 @@ es5id: 15.4.4.15-4-4
|
||||
description: >
|
||||
Array.prototype.lastIndexOf returns -1 if 'length' is 0 (generic
|
||||
'array' with length 0 )
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
foo.prototype = new Array(1, 2, 3);
|
||||
function foo() {}
|
||||
var f = new foo();
|
||||
@ -17,8 +15,5 @@ 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.15-4-5
|
||||
description: >
|
||||
Array.prototype.lastIndexOf returns -1 if 'length' is 0 ( length
|
||||
overridden to '0' (type conversion))
|
||||
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.15-4-6
|
||||
description: >
|
||||
Array.prototype.lastIndexOf returns -1 if 'length' is 0
|
||||
(subclassed Array, length overridden with obj with valueOf)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var i = Array.prototype.lastIndexOf.call({length: { valueOf: function () { return 0;}}}, 1);
|
||||
|
||||
if (i === -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(i, -1, 'i');
|
||||
|
@ -6,10 +6,8 @@ es5id: 15.4.4.15-4-7
|
||||
description: >
|
||||
Array.prototype.lastIndexOf returns -1 if 'length' is 0 ( length
|
||||
is object overridden with obj w/o valueOf (toString))
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
foo.prototype = new Array(1, 2, 3);
|
||||
function foo() {}
|
||||
var f = new foo();
|
||||
@ -24,8 +22,5 @@ function testcase() {
|
||||
// resulting string to a number.
|
||||
var i = Array.prototype.lastIndexOf.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.15-4-8
|
||||
description: >
|
||||
Array.prototype.lastIndexOf 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.lastIndexOf.call({length: [ ]}, 1);
|
||||
|
||||
if (i === -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(i, -1, 'i');
|
||||
|
@ -4,12 +4,9 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-4-9
|
||||
description: Array.prototype.lastIndexOf - '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.lastIndexOf.call(obj, targetObj) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), -1, 'Array.prototype.lastIndexOf.call(obj, targetObj)');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.15-5-10
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'fromIndex' is a number
|
||||
(value is positive number)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = {};
|
||||
return [0, targetObj, true].lastIndexOf(targetObj, 1.5) === 1 &&
|
||||
[0, true, targetObj].lastIndexOf(targetObj, 1.5) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue([0, targetObj, true].lastIndexOf(targetObj, 1.5), 1, '[0, targetObj, true].lastIndexOf(targetObj, 1.5)');
|
||||
assert.sameValue([0, true, targetObj].lastIndexOf(targetObj, 1.5), -1, '[0, true, targetObj].lastIndexOf(targetObj, 1.5)');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.15-5-11
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'fromIndex' is a number
|
||||
(value is negative number)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = {};
|
||||
return [0, targetObj, true].lastIndexOf(targetObj, -2.5) === 1 &&
|
||||
[0, true, targetObj].lastIndexOf(targetObj, -2.5) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue([0, targetObj, true].lastIndexOf(targetObj, -2.5), 1, '[0, targetObj, true].lastIndexOf(targetObj, -2.5)');
|
||||
assert.sameValue([0, true, targetObj].lastIndexOf(targetObj, -2.5), -1, '[0, true, targetObj].lastIndexOf(targetObj, -2.5)');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.15-5-12
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'fromIndex' is a number
|
||||
(value is Infinity)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var arr = [];
|
||||
arr[Math.pow(2, 32) - 2] = null; // length is the max value of Uint type
|
||||
return arr.lastIndexOf(null, Infinity) === (Math.pow(2, 32) - 2);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(arr.lastIndexOf(null, Infinity), Math.pow(2, 32) - 2, 'arr.lastIndexOf(null, Infinity)');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.15-5-16
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 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.lastIndexOf(true, "Infinity") === (Math.pow(2, 32) - 2);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(arr.lastIndexOf(true, "Infinity"), Math.pow(2, 32) - 2, 'arr.lastIndexOf(true, "Infinity")');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.15-5-18
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'fromIndex' is a string
|
||||
containing an exponential number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = {};
|
||||
return [0, NaN, targetObj, 3, false].lastIndexOf(targetObj, "2E0") === 2 &&
|
||||
[0, NaN, 3, targetObj, false].lastIndexOf(targetObj, "2E0") === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue([0, NaN, targetObj, 3, false].lastIndexOf(targetObj, "2E0"), 2, '[0, NaN, targetObj, 3, false].lastIndexOf(targetObj, "2E0")');
|
||||
assert.sameValue([0, NaN, 3, targetObj, false].lastIndexOf(targetObj, "2E0"), -1, '[0, NaN, 3, targetObj, false].lastIndexOf(targetObj, "2E0")');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.15-5-19
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'fromIndex' is a string
|
||||
containing a hex number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = {};
|
||||
return [0, true, targetObj, 3, false].lastIndexOf(targetObj, "0x0002") === 2 &&
|
||||
[0, true, 3, targetObj, false].lastIndexOf(targetObj, "0x0002") === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue([0, true, targetObj, 3, false].lastIndexOf(targetObj, "0x0002"), 2, '[0, true, targetObj, 3, false].lastIndexOf(targetObj, "0x0002")');
|
||||
assert.sameValue([0, true, 3, targetObj, false].lastIndexOf(targetObj, "0x0002"), -1, '[0, true, 3, targetObj, false].lastIndexOf(targetObj, "0x0002")');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.15-5-20
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'fromIndex' which is a
|
||||
string containing a number with leading zeros
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = {};
|
||||
return [0, true, targetObj, 3, false].lastIndexOf(targetObj, "0002.10") === 2 &&
|
||||
[0, true, 3, targetObj, false].lastIndexOf(targetObj, "0002.10") === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue([0, true, targetObj, 3, false].lastIndexOf(targetObj, "0002.10"), 2, '[0, true, targetObj, 3, false].lastIndexOf(targetObj, "0002.10")');
|
||||
assert.sameValue([0, true, 3, targetObj, false].lastIndexOf(targetObj, "0002.10"), -1, '[0, true, 3, targetObj, false].lastIndexOf(targetObj, "0002.10")');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-5-21
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'fromIndex' which is an
|
||||
Object, and 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
|
||||
@ -23,7 +20,5 @@ function testcase() {
|
||||
};
|
||||
var targetObj = new RegExp();
|
||||
|
||||
return [0, true, targetObj, 3, false].lastIndexOf(targetObj, fromIndex) === 2 &&
|
||||
[0, true, 3, targetObj, false].lastIndexOf(targetObj, fromIndex) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([0, true, targetObj, 3, false].lastIndexOf(targetObj, fromIndex), 2, '[0, true, targetObj, 3, false].lastIndexOf(targetObj, fromIndex)');
|
||||
assert.sameValue([0, true, 3, targetObj, false].lastIndexOf(targetObj, fromIndex), -1, '[0, true, 3, targetObj, false].lastIndexOf(targetObj, fromIndex)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-5-22
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'fromIndex' which is an
|
||||
object, and has an own valueOf method
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var fromIndex = {
|
||||
valueOf: function () {
|
||||
return 2;
|
||||
@ -18,7 +15,6 @@ function testcase() {
|
||||
};
|
||||
|
||||
var targetObj = function () {};
|
||||
return [0, true, targetObj, 3, false].lastIndexOf(targetObj, fromIndex) === 2 &&
|
||||
[0, true, 3, targetObj, false].lastIndexOf(targetObj, fromIndex) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue([0, true, targetObj, 3, false].lastIndexOf(targetObj, fromIndex), 2, '[0, true, targetObj, 3, false].lastIndexOf(targetObj, fromIndex)');
|
||||
assert.sameValue([0, true, 3, targetObj, false].lastIndexOf(targetObj, fromIndex), -1, '[0, true, 3, targetObj, false].lastIndexOf(targetObj, fromIndex)');
|
||||
|
@ -7,11 +7,8 @@ description: >
|
||||
Array.prototype.lastIndexOf - 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].lastIndexOf(true, fromIndex) === 1 && toStringAccessed && valueOfAccessed;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([0, true].lastIndexOf(true, fromIndex), 1, '[0, true].lastIndexOf(true, fromIndex)');
|
||||
assert(toStringAccessed, 'toStringAccessed !== true');
|
||||
assert(valueOfAccessed, 'valueOfAccessed !== true');
|
||||
|
@ -7,11 +7,8 @@ description: >
|
||||
Array.prototype.lastIndexOf use 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 1;
|
||||
};
|
||||
|
||||
return [0, true].lastIndexOf(true, child) === 1 && valueOfAccessed && !toStringAccessed;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([0, true].lastIndexOf(true, child), 1, '[0, true].lastIndexOf(true, child)');
|
||||
assert(valueOfAccessed, 'valueOfAccessed !== true');
|
||||
assert.sameValue(toStringAccessed, false, 'toStringAccessed');
|
||||
|
@ -6,12 +6,9 @@ es5id: 15.4.4.15-5-31
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 'fromIndex' is a positive
|
||||
non-integer, verify truncation occurs in the proper direction
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = {};
|
||||
return [0, targetObj, true].lastIndexOf(targetObj, 1.5) === 1 &&
|
||||
[0, true, targetObj].lastIndexOf(targetObj, 1.5) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue([0, targetObj, true].lastIndexOf(targetObj, 1.5), 1, '[0, targetObj, true].lastIndexOf(targetObj, 1.5)');
|
||||
assert.sameValue([0, true, targetObj].lastIndexOf(targetObj, 1.5), -1, '[0, true, targetObj].lastIndexOf(targetObj, 1.5)');
|
||||
|
@ -6,13 +6,9 @@ es5id: 15.4.4.15-5-32
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 'fromIndex' is a negative
|
||||
non-integer, verify truncation occurs in the proper direction
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = {};
|
||||
return [0, targetObj, true].lastIndexOf(targetObj, -2.5) === 1 &&
|
||||
[0, true, targetObj].lastIndexOf(targetObj, -2.5) === -1;
|
||||
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([0, targetObj, true].lastIndexOf(targetObj, -2.5), 1, '[0, targetObj, true].lastIndexOf(targetObj, -2.5)');
|
||||
assert.sameValue([0, true, targetObj].lastIndexOf(targetObj, -2.5), -1, '[0, true, targetObj].lastIndexOf(targetObj, -2.5)');
|
||||
|
@ -4,14 +4,11 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-5-6
|
||||
description: Array.prototype.lastIndexOf when 'fromIndex' isn't passed
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var arr = [0, 1, 2, 3, 4];
|
||||
//'fromIndex' will be set as 4 if not passed by default
|
||||
return arr.lastIndexOf(0) === arr.lastIndexOf(0, 4) &&
|
||||
arr.lastIndexOf(2) === arr.lastIndexOf(2, 4) &&
|
||||
arr.lastIndexOf(4) === arr.lastIndexOf(4, 4);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(arr.lastIndexOf(0), arr.lastIndexOf(0, 4), 'arr.lastIndexOf(0)');
|
||||
assert.sameValue(arr.lastIndexOf(2), arr.lastIndexOf(2, 4), 'arr.lastIndexOf(2)');
|
||||
assert.sameValue(arr.lastIndexOf(4), arr.lastIndexOf(4, 4), 'arr.lastIndexOf(4)');
|
||||
|
@ -6,14 +6,9 @@ es5id: 15.4.4.15-6-1
|
||||
description: >
|
||||
Array.prototype.lastIndexOf when fromIndex greater than
|
||||
Array.length
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = new Array(1,2,3);
|
||||
if (a.lastIndexOf(3,5.4) === 2 &&
|
||||
a.lastIndexOf(3,3.1) === 2 ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.lastIndexOf(3,5.4), 2, 'a.lastIndexOf(3,5.4)');
|
||||
assert.sameValue(a.lastIndexOf(3,3.1), 2, 'a.lastIndexOf(3,3.1)');
|
||||
|
@ -4,16 +4,11 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-7-1
|
||||
description: Array.prototype.lastIndexOf with negative fromIndex
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = new Array(1,2,3);
|
||||
|
||||
if (a.lastIndexOf(2,-2) === 1 &&
|
||||
a.lastIndexOf(2,-3) === -1 &&
|
||||
a.lastIndexOf(1,-5.3) === -1 ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.lastIndexOf(2,-2), 1, 'a.lastIndexOf(2,-2)');
|
||||
assert.sameValue(a.lastIndexOf(2,-3), -1, 'a.lastIndexOf(2,-3)');
|
||||
assert.sameValue(a.lastIndexOf(1,-5.3), -1, 'a.lastIndexOf(1,-5.3)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-8-11
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 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.lastIndexOf(1) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(arr.lastIndexOf(1), -1, 'arr.lastIndexOf(1)');
|
||||
|
@ -4,16 +4,10 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-8-3
|
||||
description: Array.prototype.lastIndexOf must return correct index(string)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var obj = {toString:function (){return "false"}};
|
||||
var szFalse = "false";
|
||||
var a = new Array(szFalse, "false","false1",undefined,0,false,null,1,obj,0);
|
||||
if (a.lastIndexOf("false") === 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.lastIndexOf("false"), 1, 'a.lastIndexOf("false")');
|
||||
|
@ -4,17 +4,11 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-8-4
|
||||
description: Array.prototype.lastIndexOf must return correct index(undefined)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var obj = {toString:function (){return undefined;}};
|
||||
var _undefined1 = undefined;
|
||||
var _undefined2;
|
||||
var a = new Array(_undefined1,_undefined2,undefined,true,0,false,null,1,"undefined",obj,1);
|
||||
if (a.lastIndexOf(undefined) === 2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.lastIndexOf(undefined), 2, 'a.lastIndexOf(undefined)');
|
||||
|
@ -4,17 +4,11 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-8-5
|
||||
description: Array.prototype.lastIndexOf must return correct index(Object)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var obj1 = {toString:function (){return "false"}};
|
||||
var obj2 = {toString:function (){return "false"}};
|
||||
var obj3 = obj1;
|
||||
var a = new Array(obj2,obj1,obj3,false,undefined,0,false,null,{toString:function (){return "false"}},"false");
|
||||
if (a.lastIndexOf(obj3) === 2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.lastIndexOf(obj3), 2, 'a.lastIndexOf(obj3)');
|
||||
|
@ -4,16 +4,10 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-8-6
|
||||
description: Array.prototype.lastIndexOf must return correct index(null)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var obj = {toString:function (){return null}};
|
||||
var _null = null;
|
||||
var a = new Array(true,undefined,0,false,null,1,"str",0,1,null,true,false,undefined,_null,"null",undefined,"str",obj);
|
||||
if (a.lastIndexOf(null) === 13 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.lastIndexOf(null), 13, 'a.lastIndexOf(null)');
|
||||
|
@ -6,16 +6,10 @@ es5id: 15.4.4.15-8-7
|
||||
description: >
|
||||
Array.prototype.lastIndexOf must return correct index (self
|
||||
reference)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = new Array(0,1,2,3);
|
||||
a[2] = a;
|
||||
if (a.lastIndexOf(a) === 2 &&
|
||||
a.lastIndexOf(3) === 3 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.lastIndexOf(a), 2, 'a.lastIndexOf(a)');
|
||||
assert.sameValue(a.lastIndexOf(3), 3, 'a.lastIndexOf(3)');
|
||||
|
@ -4,16 +4,10 @@
|
||||
/*---
|
||||
es5id: 15.4.4.15-8-8
|
||||
description: Array.prototype.lastIndexOf 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.lastIndexOf(b.toString()) === 2 &&
|
||||
a.lastIndexOf("0,1") === 2 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.lastIndexOf(b.toString()), 2, 'a.lastIndexOf(b.toString())');
|
||||
assert.sameValue(a.lastIndexOf("0,1"), 2, 'a.lastIndexOf("0,1")');
|
||||
|
@ -6,10 +6,8 @@ es5id: 15.4.4.15-8-9
|
||||
description: >
|
||||
Array.prototype.lastIndexOf 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 index
|
||||
a[4294967295] = 3; // 2^32-1 added as non-array element property
|
||||
@ -21,9 +19,7 @@ function testcase() {
|
||||
a[4294967202] = 5;
|
||||
|
||||
|
||||
return (a.lastIndexOf(2) === 4294967294 &&
|
||||
a.lastIndexOf(3) === 4294967200 &&
|
||||
a.lastIndexOf(4) === 4294967201 &&
|
||||
a.lastIndexOf(5) === 4294967202) ;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(a.lastIndexOf(2), 4294967294, 'a.lastIndexOf(2)');
|
||||
assert.sameValue(a.lastIndexOf(3), 4294967200, 'a.lastIndexOf(3)');
|
||||
assert.sameValue(a.lastIndexOf(4), 4294967201, 'a.lastIndexOf(4)');
|
||||
assert.sameValue(a.lastIndexOf(5), 4294967202, 'a.lastIndexOf(5)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-8-a-1
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 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.lastIndexOf.call(arr, "length");
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(arr, "length"), 2, 'Array.prototype.lastIndexOf.call(arr, "length")');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-8-a-11
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - deleting own property causes index
|
||||
property not to be visited on an Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = { length: 200 };
|
||||
|
||||
Object.defineProperty(arr, "1", {
|
||||
@ -28,6 +25,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return -1 === Array.prototype.lastIndexOf.call(arr, 6.99);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(arr, 6.99), -1, 'Array.prototype.lastIndexOf.call(arr, 6.99)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-8-a-12
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - deleting own property causes index
|
||||
property not to be visited on an Array
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = [1, 2, 3, 4];
|
||||
|
||||
Object.defineProperty(arr, "1", {
|
||||
@ -28,6 +25,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return -1 === arr.lastIndexOf("6.99");
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(arr.lastIndexOf("6.99"), -1, 'arr.lastIndexOf("6.99")');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-8-a-17
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - decreasing length of array causes
|
||||
index property not to be visited
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = [0, 1, 2, "last", 4];
|
||||
|
||||
Object.defineProperty(arr, "4", {
|
||||
@ -21,6 +18,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return -1 === arr.lastIndexOf("last");
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(arr.lastIndexOf("last"), -1, 'arr.lastIndexOf("last")');
|
||||
|
@ -7,11 +7,8 @@ description: >
|
||||
Array.prototype.lastIndexOf - decreasing length of array does not
|
||||
delete non-configurable properties
|
||||
flags: [noStrict]
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = [0, 1, 2, 3];
|
||||
|
||||
Object.defineProperty(arr, "2", {
|
||||
@ -29,6 +26,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return 2 === arr.lastIndexOf("unconfigurable");
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(arr.lastIndexOf("unconfigurable"), 2, 'arr.lastIndexOf("unconfigurable")');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-8-a-2
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 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.lastIndexOf.call(arr, targetObj, fromIndex);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(arr, targetObj, fromIndex), 4, 'Array.prototype.lastIndexOf.call(arr, targetObj, fromIndex)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-8-a-3
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 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.lastIndexOf(targetObj, fromIndex);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(arr.lastIndexOf(targetObj, fromIndex), 4, 'arr.lastIndexOf(targetObj, fromIndex)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-8-a-4
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 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.lastIndexOf.call(arr, 6.99);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(arr, 6.99), -1, 'Array.prototype.lastIndexOf.call(arr, 6.99)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-8-a-5
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - deleted properties of 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.lastIndexOf.call(arr, false, fromIndex);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(arr, false, fromIndex), -1, 'Array.prototype.lastIndexOf.call(arr, false, fromIndex)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-8-a-6
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - deleted properties of 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.lastIndexOf("10", fromIndex);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(arr.lastIndexOf("10", fromIndex), -1, 'arr.lastIndexOf("10", fromIndex)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-8-a-7
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - properties added into own object
|
||||
after current position are visited on an Array-like object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var arr = { length: 8 };
|
||||
|
||||
Object.defineProperty(arr, "4", {
|
||||
@ -26,6 +23,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return Array.prototype.lastIndexOf.call(arr, 1) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(arr, 1), 1, 'Array.prototype.lastIndexOf.call(arr, 1)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-8-a-8
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 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, "2", {
|
||||
@ -26,6 +23,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return arr.lastIndexOf(1) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(arr.lastIndexOf(1), 1, 'arr.lastIndexOf(1)');
|
||||
|
@ -6,15 +6,10 @@ es5id: 15.4.4.15-8-b-i-1
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 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.lastIndexOf.call(obj, 0) === 0 &&
|
||||
Array.prototype.lastIndexOf.call(obj, 1) === 1 &&
|
||||
Array.prototype.lastIndexOf.call(obj, 2) === 2;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 0), 0, 'Array.prototype.lastIndexOf.call(obj, 0)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), 1, 'Array.prototype.lastIndexOf.call(obj, 1)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2), 2, 'Array.prototype.lastIndexOf.call(obj, 2)');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-8-b-i-10
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 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.lastIndexOf.call(obj, 0) &&
|
||||
1 === Array.prototype.lastIndexOf.call(obj, 1) &&
|
||||
2 === Array.prototype.lastIndexOf.call(obj, 2);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 0), 0, 'Array.prototype.lastIndexOf.call(obj, 0)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), 1, 'Array.prototype.lastIndexOf.call(obj, 1)');
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2), 2, 'Array.prototype.lastIndexOf.call(obj, 2)');
|
||||
|
@ -6,17 +6,12 @@ es5id: 15.4.4.15-8-b-i-17
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 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.lastIndexOf(undefined) === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(arr.lastIndexOf(undefined), 0, 'arr.lastIndexOf(undefined)');
|
||||
|
@ -6,17 +6,12 @@ es5id: 15.4.4.15-8-b-i-18
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - 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.lastIndexOf.call(obj, undefined);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, undefined), 0, 'Array.prototype.lastIndexOf.call(obj, undefined)');
|
||||
|
@ -7,16 +7,11 @@ description: >
|
||||
Array.prototype.lastIndexOf 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.lastIndexOf.call(arguments, arguments[0]) &&
|
||||
-1 === Array.prototype.lastIndexOf.call(arguments, arguments[1]);
|
||||
};
|
||||
|
||||
return func(true);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert(func(true), 'func(true) !== true');
|
||||
|
@ -7,17 +7,12 @@ description: >
|
||||
Array.prototype.lastIndexOf 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.lastIndexOf.call(arguments, arguments[0]) &&
|
||||
1 === Array.prototype.lastIndexOf.call(arguments, arguments[1]) &&
|
||||
-1 === Array.prototype.lastIndexOf.call(arguments, arguments[2]);
|
||||
};
|
||||
|
||||
return func(0, true);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert(func(0, true), 'func(0, true) !== true');
|
||||
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-8-b-i-28
|
||||
description: >
|
||||
Array.prototype.lastIndexOf - side-effects are visible in
|
||||
subsequent iterations on an Array
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var preIterVisible = false;
|
||||
var arr = [];
|
||||
|
||||
@ -33,6 +30,4 @@ function testcase() {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return arr.lastIndexOf(true) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(arr.lastIndexOf(true), 1, 'arr.lastIndexOf(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