mirror of https://github.com/tc39/test262.git
Merge branch 'remove-runTestCase-builtins-other' of https://github.com/anba/test262 into anba-remove-runTestCase-builtins-other
# By André Bargull # Via André Bargull * 'remove-runTestCase-builtins-other' of https://github.com/anba/test262: Replace runTestCase with assert helpers, rest [test/built-ins] Replace runTestCase with assert helpers [test/built-ins] Conflicts: test/built-ins/Array/from/S22.1.2.1_T1.js test/built-ins/Array/from/S22.1.2.1_T2.js test/built-ins/Array/from/S22.1.2.1_T3.js
This commit is contained in:
commit
a2554d909b
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-1-1
|
||||
description: Array.isArray applied to boolean primitive
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return !Array.isArray(true);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.isArray(true), false, 'Array.isArray(true)');
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-1-10
|
||||
description: Array.isArray applied to RegExp object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return !Array.isArray(new RegExp());
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.isArray(new RegExp()), false, 'Array.isArray(new RegExp())');
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-1-11
|
||||
description: Array.isArray applied to the JSON object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return !Array.isArray(JSON);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.isArray(JSON), false, 'Array.isArray(JSON)');
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-1-12
|
||||
description: Array.isArray applied to Error object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return !Array.isArray(new SyntaxError());
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.isArray(new SyntaxError()), false, 'Array.isArray(new SyntaxError())');
|
||||
|
|
|
@ -4,13 +4,7 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-1-15
|
||||
description: Array.isArray applied to the global object
|
||||
includes:
|
||||
- runTestCase.js
|
||||
- fnGlobalObject.js
|
||||
includes: [fnGlobalObject.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return !Array.isArray(fnGlobalObject());
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.isArray(fnGlobalObject()), false, 'Array.isArray(fnGlobalObject())');
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-1-2
|
||||
description: Array.isArray applied to Boolean Object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return !Array.isArray(new Boolean(false));
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.isArray(new Boolean(false)), false, 'Array.isArray(new Boolean(false))');
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-1-3
|
||||
description: Array.isArray applied to number primitive
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return !Array.isArray(5);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.isArray(5), false, 'Array.isArray(5)');
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-1-4
|
||||
description: Array.isArray applied to Number object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return !Array.isArray(new Number(-3));
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.isArray(new Number(-3)), false, 'Array.isArray(new Number(-3))');
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-1-5
|
||||
description: Array.isArray applied to string primitive
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return !Array.isArray("abc");
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.isArray("abc"), false, 'Array.isArray("abc")');
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-1-6
|
||||
description: Array.isArray applied to String object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return !Array.isArray(new String("hello\nworld\\!"));
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.isArray(new String("hello\nworld\\!")), false, 'Array.isArray(new String("hello\nworld\\!"))');
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-1-7
|
||||
description: Array.isArray applied to Function object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return !Array.isArray(function () { });
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.isArray(function () { }), false, 'Array.isArray(function () { })');
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-1-8
|
||||
description: Array.isArray applied to the Math object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return !Array.isArray(Math);
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.isArray(Math), false, 'Array.isArray(Math)');
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.3.2-1-9
|
||||
description: Array.isArray applied to Date object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return !Array.isArray(new Date());
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.isArray(new Date()), false, 'Array.isArray(new Date())');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.3.2-2-3
|
|||
description: >
|
||||
Array.isArray applied to an Array-like object with length and some
|
||||
indexed properties
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return !Array.isArray({ 0: 12, 1: 9, length: 2 });
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.isArray({ 0: 12, 1: 9, length: 2 }), false, 'Array.isArray({ 0: 12, 1: 9, length: 2 })');
|
||||
|
|
|
@ -6,25 +6,17 @@ es5id: 15.4.4.16-4-10
|
|||
description: >
|
||||
Array.prototype.every - the exception is not thrown if exception
|
||||
was thrown by step 2
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: 11, 1: 12 };
|
||||
|
||||
Object.defineProperty(obj, "length", {
|
||||
get: function () {
|
||||
throw new SyntaxError();
|
||||
throw new Test262Error();
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
|
||||
try {
|
||||
assert.throws(Test262Error, function() {
|
||||
Array.prototype.every.call(obj, undefined);
|
||||
return false;
|
||||
} catch (ex) {
|
||||
return !(ex instanceof TypeError);
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
});
|
||||
|
|
|
@ -6,29 +6,21 @@ es5id: 15.4.4.16-4-11
|
|||
description: >
|
||||
Array.prototype.every - the exception is not thrown if exception
|
||||
was thrown by step 3
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: 11, 1: 12 };
|
||||
|
||||
Object.defineProperty(obj, "length", {
|
||||
get: function () {
|
||||
return {
|
||||
toString: function () {
|
||||
throw new SyntaxError();
|
||||
throw new Test262Error();
|
||||
}
|
||||
};
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
|
||||
try {
|
||||
assert.throws(Test262Error, function() {
|
||||
Array.prototype.every.call(obj, undefined);
|
||||
return false;
|
||||
} catch (ex) {
|
||||
return !(ex instanceof TypeError);
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
});
|
||||
|
|
|
@ -6,28 +6,22 @@ es5id: 15.4.4.16-7-c-ii-7
|
|||
description: >
|
||||
Array.prototype.every - unhandled exceptions happened in
|
||||
callbackfn terminate iteration
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var called = 0;
|
||||
|
||||
function callbackfn(val, idx, obj) {
|
||||
called++;
|
||||
if (called === 1) {
|
||||
throw new Error("Exception occurred in callbackfn");
|
||||
throw new Test262Error("Exception occurred in callbackfn");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
var obj = { 0: 11, 4: 10, 10: 8, length: 20 };
|
||||
|
||||
try {
|
||||
assert.throws(Test262Error, function() {
|
||||
Array.prototype.every.call(obj, callbackfn);
|
||||
return false;
|
||||
} catch (ex) {
|
||||
return 1 === called;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
});
|
||||
|
||||
assert.sameValue(called, 1, 'called');
|
||||
|
|
|
@ -6,25 +6,17 @@ es5id: 15.4.4.20-4-10
|
|||
description: >
|
||||
Array.prototype.filter - the exception is not thrown if exception
|
||||
was thrown by step 2
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: 11, 1: 12 };
|
||||
|
||||
Object.defineProperty(obj, "length", {
|
||||
get: function () {
|
||||
throw new SyntaxError();
|
||||
throw new Test262Error();
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
|
||||
try {
|
||||
assert.throws(Test262Error, function() {
|
||||
Array.prototype.filter.call(obj, undefined);
|
||||
return false;
|
||||
} catch (ex) {
|
||||
return !(ex instanceof TypeError);
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
});
|
||||
|
|
|
@ -6,29 +6,21 @@ es5id: 15.4.4.20-4-11
|
|||
description: >
|
||||
Array.prototype.filter - the exception is not thrown if exception
|
||||
was thrown by step 3
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: 11, 1: 12 };
|
||||
|
||||
Object.defineProperty(obj, "length", {
|
||||
get: function () {
|
||||
return {
|
||||
toString: function () {
|
||||
throw new SyntaxError();
|
||||
throw new Test262Error();
|
||||
}
|
||||
};
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
|
||||
try {
|
||||
assert.throws(Test262Error, function() {
|
||||
Array.prototype.filter.call(obj, undefined);
|
||||
return false;
|
||||
} catch (ex) {
|
||||
return !(ex instanceof TypeError);
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
});
|
||||
|
|
|
@ -5,10 +5,9 @@
|
|||
es5id: 15.4.4.20-5-1
|
||||
description: Array.prototype.filter - thisArg is passed
|
||||
flags: [noStrict]
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
(function() {
|
||||
this._15_4_4_20_5_1 = false;
|
||||
var _15_4_4_20_5_1 = true;
|
||||
|
||||
|
@ -17,6 +16,6 @@ function testcase() {
|
|||
}
|
||||
var srcArr = [1];
|
||||
var resArr = srcArr.filter(callbackfn);
|
||||
return resArr.length === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(resArr.length, 0, 'resArr.length');
|
||||
})();
|
||||
|
|
|
@ -6,11 +6,8 @@ es5id: 15.4.4.20-9-3
|
|||
description: >
|
||||
Array.prototype.filter doesn't visit deleted elements in array
|
||||
after the call
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
function callbackfn(val, idx, obj)
|
||||
{
|
||||
delete srcArr[2];
|
||||
|
@ -23,8 +20,8 @@ function testcase() {
|
|||
|
||||
var srcArr = [1,2,3,4,5];
|
||||
var resArr = srcArr.filter(callbackfn);
|
||||
if(resArr.length === 3 && resArr[0] === 1 && resArr[2] === 4 ) // two elements deleted
|
||||
return true;
|
||||
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
// two elements deleted
|
||||
assert.sameValue(resArr.length, 3, 'resArr.length');
|
||||
assert.sameValue(resArr[0], 1, 'resArr[0]');
|
||||
assert.sameValue(resArr[2], 4, 'resArr[2]');
|
||||
|
|
|
@ -6,11 +6,8 @@ es5id: 15.4.4.20-9-6
|
|||
description: >
|
||||
Array.prototype.filter visits deleted element in array after the
|
||||
call when same index is also present in prototype
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
function callbackfn(val, idx, obj)
|
||||
{
|
||||
delete srcArr[2];
|
||||
|
@ -25,8 +22,8 @@ function testcase() {
|
|||
var srcArr = [1,2,3,4,5];
|
||||
var resArr = srcArr.filter(callbackfn);
|
||||
delete Array.prototype[4];
|
||||
if(resArr.length === 4 && resArr[0] === 1 && resArr[3] == 5) // only one element deleted
|
||||
return true;
|
||||
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
// only one element deleted
|
||||
assert.sameValue(resArr.length, 4, 'resArr.length');
|
||||
assert.sameValue(resArr[0], 1, 'resArr[0]');
|
||||
assert.sameValue(resArr[3], 5, 'resArr[3]');
|
||||
|
|
|
@ -6,11 +6,8 @@ es5id: 15.4.4.20-9-c-iii-1-2
|
|||
description: >
|
||||
Array.prototype.filter - value of returned array element can be
|
||||
overwritten
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
function callbackfn(val, idx, obj) {
|
||||
return true;
|
||||
}
|
||||
|
@ -18,12 +15,7 @@ function testcase() {
|
|||
var obj = { 0: 11, 1: 9, length: 2 };
|
||||
var newArr = Array.prototype.filter.call(obj, callbackfn);
|
||||
|
||||
try {
|
||||
var tempVal = newArr[1];
|
||||
newArr[1] += 1;
|
||||
return newArr[1] !== tempVal;
|
||||
} catch (ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.notSameValue(newArr[1], tempVal, 'newArr[1]');
|
||||
|
|
|
@ -6,11 +6,8 @@ es5id: 15.4.4.20-9-c-iii-1-4
|
|||
description: >
|
||||
Array.prototype.filter - value of returned array element can be
|
||||
changed or deleted
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
function callbackfn(val, idx, obj) {
|
||||
return true;
|
||||
}
|
||||
|
@ -18,12 +15,8 @@ function testcase() {
|
|||
var obj = { 0: 11, 1: 9, length: 2 };
|
||||
var newArr = Array.prototype.filter.call(obj, callbackfn);
|
||||
|
||||
try {
|
||||
var tempVal = newArr[1];
|
||||
delete newArr[1];
|
||||
return tempVal !== undefined && newArr[1] === undefined;
|
||||
} catch (ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.notSameValue(tempVal, undefined, 'tempVal');
|
||||
assert.sameValue(newArr[1], undefined, 'newArr[1]');
|
||||
|
|
|
@ -6,11 +6,8 @@ es5id: 15.4.4.20-9-c-iii-1
|
|||
description: >
|
||||
Array.prototype.filter - getOwnPropertyDescriptor(all true) of
|
||||
returned array element
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
function callbackfn(val, idx, obj){
|
||||
if(val % 2)
|
||||
return true;
|
||||
|
@ -19,14 +16,12 @@ function testcase() {
|
|||
}
|
||||
var srcArr = [0,1,2,3,4];
|
||||
var resArr = srcArr.filter(callbackfn);
|
||||
if (resArr.length > 0){
|
||||
var desc = Object.getOwnPropertyDescriptor(resArr, 1)
|
||||
if(desc.value === 3 && //srcArr[1] = true
|
||||
desc.writable === true &&
|
||||
desc.enumerable === true &&
|
||||
desc.configurable === true){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert(resArr.length > 0, 'resArr.length > 0');
|
||||
|
||||
var desc = Object.getOwnPropertyDescriptor(resArr, 1);
|
||||
|
||||
assert.sameValue(desc.value, 3, 'desc.value'); //srcArr[1] = true
|
||||
assert.sameValue(desc.writable, true, 'desc.writable');
|
||||
assert.sameValue(desc.enumerable, true, 'desc.enumerable');
|
||||
assert.sameValue(desc.configurable, true, 'desc.configurable');
|
||||
|
|
|
@ -6,25 +6,17 @@ es5id: 15.4.4.18-4-10
|
|||
description: >
|
||||
Array.prototype.forEach - the exception is not thrown if exception
|
||||
was thrown by step 2
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: 11, 1: 12 };
|
||||
|
||||
Object.defineProperty(obj, "length", {
|
||||
get: function () {
|
||||
throw new SyntaxError();
|
||||
throw new Test262Error();
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
|
||||
try {
|
||||
assert.throws(Test262Error, function() {
|
||||
Array.prototype.forEach.call(obj, undefined);
|
||||
return false;
|
||||
} catch (ex) {
|
||||
return !(ex instanceof TypeError);
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
});
|
||||
|
|
|
@ -6,29 +6,21 @@ es5id: 15.4.4.18-4-11
|
|||
description: >
|
||||
Array.prototype.forEach - the exception is not thrown if exception
|
||||
was thrown by step 3
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj = { 0: 11, 1: 12 };
|
||||
|
||||
Object.defineProperty(obj, "length", {
|
||||
get: function () {
|
||||
return {
|
||||
toString: function () {
|
||||
throw new SyntaxError();
|
||||
throw new Test262Error();
|
||||
}
|
||||
};
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
|
||||
try {
|
||||
assert.throws(Test262Error, function() {
|
||||
Array.prototype.forEach.call(obj, undefined);
|
||||
return false;
|
||||
} catch (ex) {
|
||||
return !(ex instanceof TypeError);
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
});
|
||||
|
|
|
@ -5,10 +5,9 @@
|
|||
es5id: 15.4.4.18-5-1
|
||||
description: Array.prototype.forEach - thisArg is passed
|
||||
flags: [noStrict]
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
(function() {
|
||||
this._15_4_4_18_5_1 = false;
|
||||
var _15_4_4_18_5_1 = true;
|
||||
var result;
|
||||
|
@ -17,6 +16,6 @@ function testcase() {
|
|||
}
|
||||
var arr = [1];
|
||||
arr.forEach(callbackfn)
|
||||
return !result;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(result, false, 'result');
|
||||
})();
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.4.14-1-7
|
||||
description: Array.prototype.indexOf applied to string primitive
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return Array.prototype.indexOf.call("abc", "b") === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call("abc", "b"), 1, 'Array.prototype.indexOf.call("abc", "b")');
|
||||
|
|
|
@ -6,10 +6,8 @@ es5id: 15.4.4.14-10-1
|
|||
description: >
|
||||
Array.prototype.indexOf returns -1 for elements not present in
|
||||
array
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = new Array();
|
||||
a[100] = 1;
|
||||
a[99999] = "";
|
||||
|
@ -17,21 +15,15 @@ function testcase() {
|
|||
a[5555] = 5.5;
|
||||
a[123456] = "str";
|
||||
a[5] = 1E+309;
|
||||
if (a.indexOf(1) !== 100 ||
|
||||
a.indexOf("") !== 99999 ||
|
||||
a.indexOf("str") !== 123456 ||
|
||||
a.indexOf(1E+309) !== 5 || //Infinity
|
||||
a.indexOf(5.5) !== 5555 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (a.indexOf(true) === -1 &&
|
||||
a.indexOf(5) === -1 &&
|
||||
a.indexOf("str1") === -1 &&
|
||||
a.indexOf(null) === -1 &&
|
||||
a.indexOf(new Object()) === -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.indexOf(1), 100, 'a.indexOf(1)');
|
||||
assert.sameValue(a.indexOf(""), 99999, 'a.indexOf("")');
|
||||
assert.sameValue(a.indexOf("str"), 123456, 'a.indexOf("str")');
|
||||
assert.sameValue(a.indexOf(1E+309), 5, 'a.indexOf(1E+309)'); //Infinity
|
||||
assert.sameValue(a.indexOf(5.5), 5555, 'a.indexOf(5.5)');
|
||||
|
||||
assert.sameValue(a.indexOf(true), -1, 'a.indexOf(true)');
|
||||
assert.sameValue(a.indexOf(5), -1, 'a.indexOf(5)');
|
||||
assert.sameValue(a.indexOf("str1"), -1, 'a.indexOf("str1")');
|
||||
assert.sameValue(a.indexOf(null), -1, 'a.indexOf(null)');
|
||||
assert.sameValue(a.indexOf(new Object()), -1, 'a.indexOf(new Object())');
|
||||
|
|
|
@ -4,30 +4,19 @@
|
|||
/*---
|
||||
es5id: 15.4.4.14-2-15
|
||||
description: Array.prototype.indexOf - 'length' is property of the global object
|
||||
includes:
|
||||
- runTestCase.js
|
||||
- fnGlobalObject.js
|
||||
includes: [fnGlobalObject.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = {};
|
||||
try {
|
||||
|
||||
var oldLen = fnGlobalObject().length;
|
||||
fnGlobalObject().length = 2;
|
||||
|
||||
fnGlobalObject()[1] = targetObj;
|
||||
if (Array.prototype.indexOf.call(fnGlobalObject(), targetObj) !== 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
assert.sameValue(Array.prototype.indexOf.call(fnGlobalObject(), targetObj), 1, 'Array.prototype.indexOf.call(fnGlobalObject(), targetObj)');
|
||||
|
||||
fnGlobalObject()[1] = {};
|
||||
fnGlobalObject()[2] = targetObj;
|
||||
|
||||
return Array.prototype.indexOf.call(fnGlobalObject(), targetObj) === -1;
|
||||
} finally {
|
||||
delete fnGlobalObject()[1];
|
||||
delete fnGlobalObject()[2];
|
||||
fnGlobalObject().length = oldLen;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.indexOf.call(fnGlobalObject(), targetObj), -1, 'Array.prototype.indexOf.call(fnGlobalObject(), targetObj)');
|
||||
|
|
|
@ -7,11 +7,8 @@ description: >
|
|||
Array.prototype.indexOf throws TypeError exception when 'length'
|
||||
is an object with toString and valueOf methods that don<EFBFBD>t return
|
||||
primitive values
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var toStringAccessed = false;
|
||||
var valueOfAccessed = false;
|
||||
|
||||
|
@ -29,11 +26,9 @@ function testcase() {
|
|||
}
|
||||
};
|
||||
|
||||
try {
|
||||
assert.throws(TypeError, function() {
|
||||
Array.prototype.indexOf.call(obj);
|
||||
return false;
|
||||
} catch (e) {
|
||||
return toStringAccessed && valueOfAccessed;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
});
|
||||
|
||||
assert(toStringAccessed, 'toStringAccessed');
|
||||
assert(valueOfAccessed, 'valueOfAccessed');
|
||||
|
|
|
@ -4,14 +4,9 @@
|
|||
/*---
|
||||
es5id: 15.4.4.14-5-1
|
||||
description: Array.prototype.indexOf when fromIndex is string
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = [1,2,1,2,1,2];
|
||||
if (a.indexOf(2,"2") === 3 && // "2" resolves to 2
|
||||
a.indexOf(2,"one") === 1) { // "one" resolves to 0
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.indexOf(2,"2"), 3, '"2" resolves to 2');
|
||||
assert.sameValue(a.indexOf(2,"one"), 1, '"one" resolves to 0');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.14-5-13
|
|||
description: >
|
||||
Array.prototype.indexOf - value of 'fromIndex' is a number (value
|
||||
is -Infinity)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [true].indexOf(true, -Infinity) === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([true].indexOf(true, -Infinity), 0, '[true].indexOf(true, -Infinity)');
|
||||
|
|
|
@ -6,11 +6,7 @@ es5id: 15.4.4.14-5-14
|
|||
description: >
|
||||
Array.prototype.indexOf - value of 'fromIndex' is a number (value
|
||||
is NaN)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [true].indexOf(true, NaN) === 0 && [true].indexOf(true, -NaN) === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([true].indexOf(true, NaN), 0, '[true].indexOf(true, NaN)');
|
||||
assert.sameValue([true].indexOf(true, -NaN), 0, '[true].indexOf(true, -NaN)');
|
||||
|
|
|
@ -6,12 +6,7 @@ es5id: 15.4.4.14-5-15
|
|||
description: >
|
||||
Array.prototype.indexOf - value of 'fromIndex' is a string
|
||||
containing a negative number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [0, true, 2].indexOf(true, "-1") === -1 &&
|
||||
[0, 1, true].indexOf(true, "-1") === 2;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([0, true, 2].indexOf(true, "-1"), -1, '[0, true, 2].indexOf(true, "-1")');
|
||||
assert.sameValue([0, 1, true].indexOf(true, "-1"), 2, '[0, 1, true].indexOf(true, "-1")');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.14-5-17
|
|||
description: >
|
||||
Array.prototype.indexOf - value of 'fromIndex' is a string
|
||||
containing -Infinity
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [true].indexOf(true, "-Infinity") === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([true].indexOf(true, "-Infinity"), 0, '[true].indexOf(true, "-Infinity")');
|
||||
|
|
|
@ -4,15 +4,10 @@
|
|||
/*---
|
||||
es5id: 15.4.4.14-5-2
|
||||
description: Array.prototype.indexOf when fromIndex is floating point number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = new Array(1,2,3);
|
||||
if (a.indexOf(3,0.49) === 2 && // 0.49 resolves to 0
|
||||
a.indexOf(1,0.51) === 0 && // 0.51 resolves to 0
|
||||
a.indexOf(1,1.51) === -1) { // 1.01 resolves to 1
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.indexOf(3,0.49), 2, '0.49 resolves to 0');
|
||||
assert.sameValue(a.indexOf(1,0.51), 0, '0.51 resolves to 0');
|
||||
assert.sameValue(a.indexOf(1,1.51), -1, '1.51 resolves to 1');
|
||||
|
|
|
@ -7,11 +7,8 @@ description: >
|
|||
Array.prototype.indexOf throws TypeError exception when value of
|
||||
'fromIndex' is an object with toString and valueOf methods that
|
||||
don<EFBFBD>t return primitive values
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var toStringAccessed = false;
|
||||
var valueOfAccessed = false;
|
||||
var fromIndex = {
|
||||
|
@ -26,11 +23,9 @@ function testcase() {
|
|||
}
|
||||
};
|
||||
|
||||
try {
|
||||
assert.throws(TypeError, function() {
|
||||
[0, true].indexOf(true, fromIndex);
|
||||
return false;
|
||||
} catch (e) {
|
||||
return toStringAccessed && valueOfAccessed;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
});
|
||||
|
||||
assert(toStringAccessed, 'toStringAccessed');
|
||||
assert(valueOfAccessed, 'valueOfAccessed');
|
||||
|
|
|
@ -6,10 +6,8 @@ es5id: 15.4.4.14-5-26
|
|||
description: >
|
||||
Array.prototype.indexOf - side effects produced by step 2 are
|
||||
visible when an exception occurs
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var stepTwoOccurs = false;
|
||||
var stepFiveOccurs = false;
|
||||
|
||||
|
@ -33,11 +31,7 @@ function testcase() {
|
|||
}
|
||||
};
|
||||
|
||||
try {
|
||||
Array.prototype.indexOf.call(obj, undefined, fromIndex);
|
||||
return stepTwoOccurs && stepFiveOccurs;
|
||||
} catch (ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert(stepTwoOccurs, 'stepTwoOccurs !== true');
|
||||
assert(stepFiveOccurs, 'stepFiveOccurs !== true');
|
||||
|
|
|
@ -6,10 +6,8 @@ es5id: 15.4.4.14-5-27
|
|||
description: >
|
||||
Array.prototype.indexOf - side effects produced by step 3 are
|
||||
visible when an exception occurs
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var stepThreeOccurs = false;
|
||||
var stepFiveOccurs = false;
|
||||
|
||||
|
@ -37,11 +35,7 @@ function testcase() {
|
|||
}
|
||||
};
|
||||
|
||||
try {
|
||||
Array.prototype.indexOf.call(obj, undefined, fromIndex);
|
||||
return stepThreeOccurs && stepFiveOccurs;
|
||||
} catch (ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert(stepThreeOccurs, 'stepThreeOccurs !== true');
|
||||
assert(stepFiveOccurs, 'stepFiveOccurs !== true');
|
||||
|
|
|
@ -4,14 +4,9 @@
|
|||
/*---
|
||||
es5id: 15.4.4.14-5-3
|
||||
description: Array.prototype.indexOf when fromIndex is boolean
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = [1,2,3];
|
||||
if (a.indexOf(1,true) === -1 && // true resolves to 1
|
||||
a.indexOf(1,false) === 0 ) { // false resolves to 0
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.indexOf(1,true), -1, 'true resolves to 1');
|
||||
assert.sameValue(a.indexOf(1,false), 0, 'false resolves to 0');
|
||||
|
|
|
@ -6,15 +6,10 @@ es5id: 15.4.4.14-5-33
|
|||
description: >
|
||||
Array.prototype.indexOf match on the first element, a middle
|
||||
element and the last element when 'fromIndex' is passed
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [0, 1, 2, 3, 4].indexOf(0, 0) === 0 &&
|
||||
[0, 1, 2, 3, 4].indexOf(2, 1) === 2 &&
|
||||
[0, 1, 2, 3, 4].indexOf(2, 2) === 2 &&
|
||||
[0, 1, 2, 3, 4].indexOf(4, 2) === 4 &&
|
||||
[0, 1, 2, 3, 4].indexOf(4, 4) === 4;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([0, 1, 2, 3, 4].indexOf(0, 0), 0, '[0, 1, 2, 3, 4].indexOf(0, 0)');
|
||||
assert.sameValue([0, 1, 2, 3, 4].indexOf(2, 1), 2, '[0, 1, 2, 3, 4].indexOf(2, 1)');
|
||||
assert.sameValue([0, 1, 2, 3, 4].indexOf(2, 2), 2, '[0, 1, 2, 3, 4].indexOf(2, 2)');
|
||||
assert.sameValue([0, 1, 2, 3, 4].indexOf(4, 2), 4, '[0, 1, 2, 3, 4].indexOf(4, 2)');
|
||||
assert.sameValue([0, 1, 2, 3, 4].indexOf(4, 4), 4, '[0, 1, 2, 3, 4].indexOf(4, 4)');
|
||||
|
|
|
@ -4,13 +4,9 @@
|
|||
/*---
|
||||
es5id: 15.4.4.14-5-4
|
||||
description: Array.prototype.indexOf returns 0 if fromIndex is 'undefined'
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = [1,2,3];
|
||||
if (a.indexOf(1,undefined) === 0) { // undefined resolves to 0
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
// undefined resolves to 0
|
||||
assert.sameValue(a.indexOf(1,undefined), 0, 'a.indexOf(1,undefined)');
|
||||
|
|
|
@ -4,13 +4,9 @@
|
|||
/*---
|
||||
es5id: 15.4.4.14-5-5
|
||||
description: Array.prototype.indexOf returns 0 if fromIndex is null
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = [1,2,3];
|
||||
if (a.indexOf(1,null) === 0 ) { // null resolves to 0
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
// null resolves to 0
|
||||
assert.sameValue(a.indexOf(1,null), 0, 'a.indexOf(1,null)');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.14-5-7
|
|||
description: >
|
||||
Array.prototype.indexOf - value of 'fromIndex' is a number (value
|
||||
is 0)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [true].indexOf(true, 0) === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([true].indexOf(true, 0), 0, '[true].indexOf(true, 0)');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.14-5-8
|
|||
description: >
|
||||
Array.prototype.indexOf - value of 'fromIndex' is a number (value
|
||||
is +0)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [true].indexOf(true, +0) === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([true].indexOf(true, +0), 0, '[true].indexOf(true, +0)');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.14-5-9
|
|||
description: >
|
||||
Array.prototype.indexOf - value of 'fromIndex' is a number (value
|
||||
is -0)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [true].indexOf(true, -0) === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([true].indexOf(true, -0), 0, '[true].indexOf(true, -0)');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.14-7-1
|
|||
description: >
|
||||
Array.prototype.indexOf returns -1 when 'fromIndex' is length of
|
||||
array - 1
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [1, 2, 3].indexOf(1, 2) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([1, 2, 3].indexOf(1, 2), -1, '[1, 2, 3].indexOf(1, 2)');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.14-7-2
|
|||
description: >
|
||||
Array.prototype.indexOf returns correct index when 'fromIndex' is
|
||||
length of array - 1
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [1, 2, 3].indexOf(3, 2) === 2;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([1, 2, 3].indexOf(3, 2), 2, '[1, 2, 3].indexOf(3, 2)');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.14-7-3
|
|||
description: >
|
||||
Array.prototype.indexOf returns -1 when 'fromIndex' and 'length'
|
||||
are both 0
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [].indexOf(1, 0) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([].indexOf(1, 0), -1, '[].indexOf(1, 0)');
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.4.14-7-4
|
||||
description: Array.prototype.indexOf returns -1 when 'fromIndex' is 1
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [1, 2, 3].indexOf(1, 1) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([1, 2, 3].indexOf(1, 1), -1, '[1, 2, 3].indexOf(1, 1)');
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.4.14-7-5
|
||||
description: Array.prototype.indexOf returns correct index when 'fromIndex' is 1
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [1, 2, 3].indexOf(2, 1) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([1, 2, 3].indexOf(2, 1), 1, '[1, 2, 3].indexOf(2, 1)');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.14-8-2
|
|||
description: >
|
||||
Array.prototype.indexOf returns correct index when 'fromIndex' is
|
||||
-1
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [1, 2, 3, 4].indexOf(4, -1) === 3;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([1, 2, 3, 4].indexOf(4, -1), 3, '[1, 2, 3, 4].indexOf(4, -1)');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.14-8-3
|
|||
description: >
|
||||
Array.prototype.indexOf returns -1 when abs('fromIndex') is length
|
||||
of array - 1
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [1, 2, 3, 4].indexOf(1, -3) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([1, 2, 3, 4].indexOf(1, -3), -1, '[1, 2, 3, 4].indexOf(1, -3)');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.14-8-4
|
|||
description: >
|
||||
Array.prototype.indexOf returns -1 when abs('fromIndex') is length
|
||||
of array
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [1, 2, 3, 4].indexOf(0, -4) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([1, 2, 3, 4].indexOf(0, -4), -1, '[1, 2, 3, 4].indexOf(0, -4)');
|
||||
|
|
|
@ -4,17 +4,11 @@
|
|||
/*---
|
||||
es5id: 15.4.4.14-9-1
|
||||
description: Array.prototype.indexOf must return correct index (boolean)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var obj = {toString:function (){return true}};
|
||||
var _false = false;
|
||||
var a = [obj,"true", undefined,0,_false,null,1,"str",0,1,true,false,true,false];
|
||||
if (a.indexOf(true) === 10 && //a[10]=true
|
||||
a.indexOf(false) === 4) //a[4] =_false
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.indexOf(true), 10, 'a[10]=true');
|
||||
assert.sameValue(a.indexOf(false), 4, 'a[4] =_false');
|
||||
|
|
|
@ -7,15 +7,9 @@ info: >
|
|||
and hence NaNs could be found using indexOf *
|
||||
es5id: 15.4.4.14-9-10
|
||||
description: Array.prototype.indexOf must return correct index (NaN)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var _NaN = NaN;
|
||||
var a = new Array("NaN",undefined,0,false,null,{toString:function (){return NaN}},"false",_NaN,NaN);
|
||||
if (a.indexOf(NaN) === -1) // NaN is equal to nothing, including itself.
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.indexOf(NaN), -1, 'NaN is equal to nothing, including itself.');
|
||||
|
|
|
@ -4,20 +4,14 @@
|
|||
/*---
|
||||
es5id: 15.4.4.14-9-2
|
||||
description: Array.prototype.indexOf must return correct index (Number)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var obj = {toString:function (){return 0}};
|
||||
var one = 1;
|
||||
var _float = -(4/3);
|
||||
var a = new Array(false,undefined,null,"0",obj,-1.3333333333333, "str",-0,true,+0, one, 1,0, false, _float, -(4/3));
|
||||
if (a.indexOf(-(4/3)) === 14 && // a[14]=_float===-(4/3)
|
||||
a.indexOf(0) === 7 && // a[7] = +0, 0===+0
|
||||
a.indexOf(-0) === 7 && // a[7] = +0, -0===+0
|
||||
a.indexOf(1) === 10 ) // a[10] =one=== 1
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.indexOf(-(4/3)), 14, 'a[14]=_float===-(4/3)');
|
||||
assert.sameValue(a.indexOf(0), 7, 'a[7] = +0, 0===+0');
|
||||
assert.sameValue(a.indexOf(-0), 7, 'a[7] = +0, -0===+0');
|
||||
assert.sameValue(a.indexOf(1), 10, 'a[10] =one=== 1');
|
||||
|
|
|
@ -4,16 +4,10 @@
|
|||
/*---
|
||||
es5id: 15.4.4.14-9-3
|
||||
description: Array.prototype.indexOf must return correct index(string)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var obj = {toString:function (){return "false"}};
|
||||
var szFalse = "false";
|
||||
var a = new Array("false1",undefined,0,false,null,1,obj,0,szFalse, "false");
|
||||
if (a.indexOf("false") === 8) //a[8]=szFalse
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.indexOf("false"), 8, 'a[8]=szFalse');
|
||||
|
|
|
@ -4,17 +4,11 @@
|
|||
/*---
|
||||
es5id: 15.4.4.14-9-4
|
||||
description: Array.prototype.indexOf 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(true,0,false,null,1,"undefined",obj,1,_undefined2,_undefined1,undefined);
|
||||
if (a.indexOf(undefined) === 8) //a[8]=_undefined2
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.indexOf(undefined), 8, 'a[8]=_undefined2');
|
||||
|
|
|
@ -4,17 +4,11 @@
|
|||
/*---
|
||||
es5id: 15.4.4.14-9-5
|
||||
description: Array.prototype.indexOf 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(false,undefined,0,false,null,{toString:function (){return "false"}},"false",obj2,obj1,obj3);
|
||||
if (a.indexOf(obj3) === 8) //a[8] = obj1;
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.indexOf(obj3), 8, 'a[8] = obj1');
|
||||
|
|
|
@ -4,16 +4,10 @@
|
|||
/*---
|
||||
es5id: 15.4.4.14-9-6
|
||||
description: Array.prototype.indexOf 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,obj,true,false,null);
|
||||
if (a.indexOf(null) === 4 ) //a[4]=_null
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.indexOf(null), 4, 'a[4]=_null');
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.4.14-9-b-1
|
||||
description: Array.prototype.indexOf - non-existent property wouldn't be called
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [0, , 2].indexOf(undefined) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([0, , 2].indexOf(undefined), -1, '[0, , 2].indexOf(undefined)');
|
||||
|
|
|
@ -6,12 +6,8 @@ es5id: 15.4.4.14-9-b-i-2
|
|||
description: >
|
||||
Array.prototype.indexOf - element to be retrieved is own data
|
||||
property on an Array
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
return [true, true, true].indexOf(true) === 0 &&
|
||||
[false, true, true].indexOf(true) === 1 &&
|
||||
[false, false, true].indexOf(true) === 2;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([true, true, true].indexOf(true), 0, '[true, true, true].indexOf(true)');
|
||||
assert.sameValue([false, true, true].indexOf(true), 1, '[false, true, true].indexOf(true)');
|
||||
assert.sameValue([false, false, true].indexOf(true), 2, '[false, false, true].indexOf(true)');
|
||||
|
|
|
@ -6,16 +6,11 @@ es5id: 15.4.4.14-9-b-ii-1
|
|||
description: >
|
||||
Array.prototype.indexOf - type of array element is different from
|
||||
type of search element
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return ["true"].indexOf(true) === -1 &&
|
||||
["0"].indexOf(0) === -1 &&
|
||||
[false].indexOf(0) === -1 &&
|
||||
[undefined].indexOf(0) === -1 &&
|
||||
[null].indexOf(0) === -1 &&
|
||||
[[]].indexOf(0) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(["true"].indexOf(true), -1, '["true"].indexOf(true)');
|
||||
assert.sameValue(["0"].indexOf(0), -1, '["0"].indexOf(0)');
|
||||
assert.sameValue([false].indexOf(0), -1, '[false].indexOf(0)');
|
||||
assert.sameValue([undefined].indexOf(0), -1, '[undefined].indexOf(0)');
|
||||
assert.sameValue([null].indexOf(0), -1, '[null].indexOf(0)');
|
||||
assert.sameValue([[]].indexOf(0), -1, '[[]].indexOf(0)');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.14-9-b-ii-10
|
|||
description: >
|
||||
Array.prototype.indexOf - both array element and search element
|
||||
are Boolean type, and they have same value
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [false, true].indexOf(true) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([false, true].indexOf(true), 1, '[false, true].indexOf(true)');
|
||||
|
|
|
@ -6,14 +6,10 @@ es5id: 15.4.4.14-9-b-ii-11
|
|||
description: >
|
||||
Array.prototype.indexOf - both array element and search element
|
||||
are Object type, and they refer to the same object
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var obj1 = {};
|
||||
var obj2 = {};
|
||||
var obj3 = obj2;
|
||||
return [{}, obj1, obj2].indexOf(obj3) === 2;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue([{}, obj1, obj2].indexOf(obj3), 2, '[{}, obj1, obj2].indexOf(obj3)');
|
||||
|
|
|
@ -6,11 +6,7 @@ es5id: 15.4.4.14-9-b-ii-2
|
|||
description: >
|
||||
Array.prototype.indexOf - both type of array element and type of
|
||||
search element are Undefined
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [undefined].indexOf() === 0 && [undefined].indexOf(undefined) === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([undefined].indexOf(), 0, '[undefined].indexOf()');
|
||||
assert.sameValue([undefined].indexOf(undefined), 0, '[undefined].indexOf(undefined)');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.14-9-b-ii-3
|
|||
description: >
|
||||
Array.prototype.indexOf - both type of array element and type of
|
||||
search element are null
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [null].indexOf(null) === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([null].indexOf(null), 0, '[null].indexOf(null)');
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.4.14-9-b-ii-4
|
||||
description: Array.prototype.indexOf - search element is NaN
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [+NaN, NaN, -NaN].indexOf(NaN) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([+NaN, NaN, -NaN].indexOf(NaN), -1, '[+NaN, NaN, -NaN].indexOf(NaN)');
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.4.14-9-b-ii-5
|
||||
description: Array.prototype.indexOf - search element is -NaN
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [+NaN, NaN, -NaN].indexOf(-NaN) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([+NaN, NaN, -NaN].indexOf(-NaN), -1, '[+NaN, NaN, -NaN].indexOf(-NaN)');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.14-9-b-ii-6
|
|||
description: >
|
||||
Array.prototype.indexOf - array element is +0 and search element
|
||||
is -0
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [+0].indexOf(-0) === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([+0].indexOf(-0), 0, '[+0].indexOf(-0)');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.14-9-b-ii-7
|
|||
description: >
|
||||
Array.prototype.indexOf - array element is -0 and search element
|
||||
is +0
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [-0].indexOf(+0) === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([-0].indexOf(+0), 0, '[-0].indexOf(+0)');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.14-9-b-ii-8
|
|||
description: >
|
||||
Array.prototype.indexOf - both array element and search element
|
||||
are Number, and they have same value
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [-1, 0, 1].indexOf(1) === 2;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([-1, 0, 1].indexOf(1), 2, '[-1, 0, 1].indexOf(1)');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.14-9-b-ii-9
|
|||
description: >
|
||||
Array.prototype.indexOf - both array element and search element
|
||||
are String, and they have exactly the same sequence of characters
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return ["", "ab", "bca", "abc"].indexOf("abc") === 3;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(["", "ab", "bca", "abc"].indexOf("abc"), 3, '["", "ab", "bca", "abc"].indexOf("abc")');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.14-9-b-iii-1
|
|||
description: >
|
||||
Array.prototype.indexOf - returns index of last one when more than
|
||||
two elements in array are eligible
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [1, 2, 2, 1, 2].indexOf(2) === 1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([1, 2, 2, 1, 2].indexOf(2), 1, '[1, 2, 2, 1, 2].indexOf(2)');
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
/*---
|
||||
es5id: 15.4.4.15-1-7
|
||||
description: Array.prototype.lastIndexOf applied to string primitive
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return Array.prototype.lastIndexOf.call("abc", "c") === 2;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call("abc", "c"), 2, 'Array.prototype.lastIndexOf.call("abc", "c")');
|
||||
|
|
|
@ -6,30 +6,19 @@ es5id: 15.4.4.15-2-15
|
|||
description: >
|
||||
Array.prototype.lastIndexOf - 'length' is property of the global
|
||||
object
|
||||
includes:
|
||||
- runTestCase.js
|
||||
- fnGlobalObject.js
|
||||
includes: [fnGlobalObject.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var targetObj = {};
|
||||
try {
|
||||
|
||||
var oldLen = fnGlobalObject().length;
|
||||
fnGlobalObject().length = 2;
|
||||
|
||||
fnGlobalObject()[1] = targetObj;
|
||||
if (Array.prototype.lastIndexOf.call(fnGlobalObject(), targetObj) !== 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(fnGlobalObject(), targetObj), 1);
|
||||
|
||||
fnGlobalObject()[1] = {};
|
||||
fnGlobalObject()[2] = targetObj;
|
||||
|
||||
return Array.prototype.lastIndexOf.call(fnGlobalObject(), targetObj) === -1;
|
||||
} finally {
|
||||
delete fnGlobalObject()[1];
|
||||
delete fnGlobalObject()[2];
|
||||
fnGlobalObject().length = oldLen;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(fnGlobalObject(), targetObj), -1);
|
||||
|
|
|
@ -7,11 +7,8 @@ description: >
|
|||
Array.prototype.lastIndexOf throws TypeError exception when
|
||||
'length' is an object with toString and valueOf methods that don<EFBFBD>t
|
||||
return primitive values
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var toStringAccessed = false;
|
||||
var valueOfAccessed = false;
|
||||
|
||||
|
@ -30,11 +27,9 @@ function testcase() {
|
|||
}
|
||||
};
|
||||
|
||||
try {
|
||||
assert.throws(TypeError, function() {
|
||||
Array.prototype.lastIndexOf.call(obj, true);
|
||||
return false;
|
||||
} catch (e) {
|
||||
return toStringAccessed && valueOfAccessed;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
});
|
||||
|
||||
assert(toStringAccessed, 'toStringAccessed');
|
||||
assert(valueOfAccessed, 'valueOfAccessed');
|
||||
|
|
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-3-28
|
|||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'length' is boundary value
|
||||
(2^32)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var targetObj = {};
|
||||
var obj = {
|
||||
0: targetObj,
|
||||
|
@ -19,6 +16,4 @@ function testcase() {
|
|||
length: 4294967296
|
||||
};
|
||||
|
||||
return Array.prototype.lastIndexOf.call(obj, targetObj) === 4294967295; //verify length is 4294967296 finally
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), 4294967295, 'verify length is 4294967296 finally');
|
||||
|
|
|
@ -4,14 +4,9 @@
|
|||
/*---
|
||||
es5id: 15.4.4.15-5-1
|
||||
description: Array.prototype.lastIndexOf when fromIndex is string
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = new Array(0,1,1);
|
||||
if (a.lastIndexOf(1,"1") === 1 && // "1" resolves to 1
|
||||
a.lastIndexOf(1,"one") === -1) { // NaN string resolves to 0
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.lastIndexOf(1,"1"), 1, '"1" resolves to 1');
|
||||
assert.sameValue(a.lastIndexOf(1,"one"), -1, 'NaN string resolves to 01');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.15-5-13
|
|||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'fromIndex' is a number
|
||||
(value is -Infinity)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [true].lastIndexOf(true, -Infinity) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([true].lastIndexOf(true, -Infinity), -1, '[true].lastIndexOf(true, -Infinity)');
|
||||
|
|
|
@ -6,14 +6,10 @@ es5id: 15.4.4.15-5-14
|
|||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'fromIndex' is a number
|
||||
(value is NaN)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [0, true].lastIndexOf(true, NaN) === -1 && // from Index will be convert to +0
|
||||
[true, 0].lastIndexOf(true, NaN) === 0 &&
|
||||
[0, true].lastIndexOf(true, -NaN) === -1 &&
|
||||
[true, 0].lastIndexOf(true, -NaN) === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
// from Index will be convert to +0
|
||||
assert.sameValue([0, true].lastIndexOf(true, NaN), -1, '[0, true].lastIndexOf(true, NaN)');
|
||||
assert.sameValue([true, 0].lastIndexOf(true, NaN), 0, '[true, 0].lastIndexOf(true, NaN)');
|
||||
assert.sameValue([0, true].lastIndexOf(true, -NaN), -1, '[0, true].lastIndexOf(true, -NaN)');
|
||||
assert.sameValue([true, 0].lastIndexOf(true, -NaN), 0, '[true, 0].lastIndexOf(true, -NaN)');
|
||||
|
|
|
@ -6,12 +6,7 @@ es5id: 15.4.4.15-5-15
|
|||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'fromIndex' is a string
|
||||
containing a negative number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [0, "-2", 2].lastIndexOf("-2", "-2") === 1 &&
|
||||
[0, 2, "-2"].lastIndexOf("-2", "-2") === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([0, "-2", 2].lastIndexOf("-2", "-2"), 1, '[0, "-2", 2].lastIndexOf("-2", "-2")');
|
||||
assert.sameValue([0, 2, "-2"].lastIndexOf("-2", "-2"), -1, '[0, 2, "-2"].lastIndexOf("-2", "-2")');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.15-5-17
|
|||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'fromIndex' is a string
|
||||
containing -Infinity
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [true].lastIndexOf(true, "-Infinity") === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([true].lastIndexOf(true, "-Infinity"), -1, '[true].lastIndexOf(true, "-Infinity")');
|
||||
|
|
|
@ -4,15 +4,10 @@
|
|||
/*---
|
||||
es5id: 15.4.4.15-5-2
|
||||
description: Array.prototype.lastIndexOf when fromIndex is floating point number
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = new Array(1,2,1);
|
||||
if (a.lastIndexOf(2,1.49) === 1 && // 1.49 resolves to 1
|
||||
a.lastIndexOf(2,0.51) === -1 && // 0.51 resolves to 0
|
||||
a.lastIndexOf(1,0.51) === 0){ // 0.51 resolves to 0
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.lastIndexOf(2,1.49), 1, '1.49 resolves to 1');
|
||||
assert.sameValue(a.lastIndexOf(2,0.51), -1, '0.51 resolves to 0');
|
||||
assert.sameValue(a.lastIndexOf(1,0.51), 0, '0.51 resolves to 0');
|
||||
|
|
|
@ -7,11 +7,8 @@ description: >
|
|||
Array.prototype.lastIndexOf throws TypeError exception when value
|
||||
of 'fromIndex' is an object that both toString and valueOf methods
|
||||
than don't return primitive value
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var toStringAccessed = false;
|
||||
var valueOfAccessed = false;
|
||||
|
||||
|
@ -27,11 +24,9 @@ function testcase() {
|
|||
}
|
||||
};
|
||||
|
||||
try {
|
||||
assert.throws(TypeError, function() {
|
||||
[0, null].lastIndexOf(null, fromIndex);
|
||||
return false;
|
||||
} catch (e) {
|
||||
return toStringAccessed && valueOfAccessed;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
});
|
||||
|
||||
assert(toStringAccessed, 'toStringAccessed');
|
||||
assert(valueOfAccessed, 'valueOfAccessed');
|
||||
|
|
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-5-26
|
|||
description: >
|
||||
Array.prototype.lastIndexOf - side effects produced by step 2 are
|
||||
visible when an exception occurs
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var stepTwoOccurs = false;
|
||||
var stepFiveOccurs = false;
|
||||
var obj = {};
|
||||
|
@ -33,11 +30,7 @@ function testcase() {
|
|||
}
|
||||
};
|
||||
|
||||
try {
|
||||
Array.prototype.lastIndexOf.call(obj, undefined, fromIndex);
|
||||
return stepTwoOccurs && stepFiveOccurs;
|
||||
} catch (ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert(stepTwoOccurs, 'stepTwoOccurs !== true');
|
||||
assert(stepFiveOccurs, 'stepFiveOccurs !== true');
|
||||
|
|
|
@ -6,11 +6,8 @@ es5id: 15.4.4.15-5-27
|
|||
description: >
|
||||
Array.prototype.lastIndexOf - side effects produced by step 3 are
|
||||
visible when an exception occurs
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
var stepThreeOccurs = false;
|
||||
var stepFiveOccurs = false;
|
||||
|
||||
|
@ -38,11 +35,7 @@ function testcase() {
|
|||
}
|
||||
};
|
||||
|
||||
try {
|
||||
Array.prototype.lastIndexOf.call(obj, undefined, fromIndex);
|
||||
return stepThreeOccurs && stepFiveOccurs;
|
||||
} catch (ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert(stepThreeOccurs, 'stepThreeOccurs !== true');
|
||||
assert(stepFiveOccurs, 'stepFiveOccurs !== true');
|
||||
|
|
|
@ -4,14 +4,9 @@
|
|||
/*---
|
||||
es5id: 15.4.4.15-5-3
|
||||
description: Array.prototype.lastIndexOf when fromIndex is boolean
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = new Array(1,2,1);
|
||||
if (a.lastIndexOf(2,true) === 1 && // true resolves to 1
|
||||
a.lastIndexOf(2,false) === -1 ) { // false resolves to 0
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
assert.sameValue(a.lastIndexOf(2,true), 1, 'true resolves to 1');
|
||||
assert.sameValue(a.lastIndexOf(2,false), -1, 'false resolves to 0');
|
||||
|
|
|
@ -6,15 +6,10 @@ es5id: 15.4.4.15-5-33
|
|||
description: >
|
||||
Array.prototype.lastIndexOf - match on the first element, a middle
|
||||
element and the last element when 'fromIndex' is passed
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [0, 1, 2, 3, 4].lastIndexOf(0, 0) === 0 &&
|
||||
[0, 1, 2, 3, 4].lastIndexOf(0, 2) === 0 &&
|
||||
[0, 1, 2, 3, 4].lastIndexOf(2, 2) === 2 &&
|
||||
[0, 1, 2, 3, 4].lastIndexOf(2, 4) === 2 &&
|
||||
[0, 1, 2, 3, 4].lastIndexOf(4, 4) === 4;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(0, 0), 0, '[0, 1, 2, 3, 4].lastIndexOf(0, 0)');
|
||||
assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(0, 2), 0, '[0, 1, 2, 3, 4].lastIndexOf(0, 2)');
|
||||
assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(2, 2), 2, '[0, 1, 2, 3, 4].lastIndexOf(2, 2)');
|
||||
assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(2, 4), 2, '[0, 1, 2, 3, 4].lastIndexOf(2, 4)');
|
||||
assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(4, 4), 4, '[0, 1, 2, 3, 4].lastIndexOf(4, 4)');
|
||||
|
|
|
@ -4,15 +4,11 @@
|
|||
/*---
|
||||
es5id: 15.4.4.15-5-4
|
||||
description: Array.prototype.lastIndexOf when fromIndex is undefined
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = new Array(1,2,1);
|
||||
if (a.lastIndexOf(2,undefined) === -1 &&
|
||||
a.lastIndexOf(1,undefined) === 0 &&
|
||||
a.lastIndexOf(1) === 2) { // undefined resolves to 0, no second argument resolves to len
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
// undefined resolves to 0, no second argument resolves to len
|
||||
assert.sameValue(a.lastIndexOf(2,undefined), -1, 'a.lastIndexOf(2,undefined)');
|
||||
assert.sameValue(a.lastIndexOf(1,undefined), 0, 'a.lastIndexOf(1,undefined)');
|
||||
assert.sameValue(a.lastIndexOf(1), 2, 'a.lastIndexOf(1)');
|
||||
|
|
|
@ -4,13 +4,10 @@
|
|||
/*---
|
||||
es5id: 15.4.4.15-5-5
|
||||
description: Array.prototype.lastIndexOf when fromIndex is null
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
var a = new Array(1,2,1);
|
||||
if (a.lastIndexOf(2,null) === -1 && a.lastIndexOf(1,null) === 0) { // null resolves to 0
|
||||
return true;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
||||
|
||||
// null resolves to 0
|
||||
assert.sameValue(a.lastIndexOf(2,null), -1, 'a.lastIndexOf(2,null)');
|
||||
assert.sameValue(a.lastIndexOf(1,null), 0, 'a.lastIndexOf(1,null)');
|
||||
|
|
|
@ -6,12 +6,7 @@ es5id: 15.4.4.15-5-7
|
|||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'fromIndex' is a number
|
||||
(value is 0)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [0, 100].lastIndexOf(100, 0) === -1 && // verify fromIndex is not more than 0
|
||||
[200, 0].lastIndexOf(200, 0) === 0; // verify fromIndex is not less than 0
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([0, 100].lastIndexOf(100, 0), -1, 'verify fromIndex is not more than 0');
|
||||
assert.sameValue([200, 0].lastIndexOf(200, 0), 0, 'verify fromIndex is not less than 0');
|
||||
|
|
|
@ -6,12 +6,7 @@ es5id: 15.4.4.15-5-8
|
|||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'fromIndex' is a number
|
||||
(value is +0)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [0, true].lastIndexOf(true, +0) === -1 &&
|
||||
[true, 0].lastIndexOf(true, +0) === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([0, true].lastIndexOf(true, +0), -1, '[0, true].lastIndexOf(true, +0)');
|
||||
assert.sameValue([true, 0].lastIndexOf(true, +0), 0, '[true, 0].lastIndexOf(true, +0)');
|
||||
|
|
|
@ -6,12 +6,7 @@ es5id: 15.4.4.15-5-9
|
|||
description: >
|
||||
Array.prototype.lastIndexOf - value of 'fromIndex' is a number
|
||||
(value is -0)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [0, true].lastIndexOf(true, -0) === -1 &&
|
||||
[true, 0].lastIndexOf(true, -0) === 0;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([0, true].lastIndexOf(true, -0), -1, '[0, true].lastIndexOf(true, -0)');
|
||||
assert.sameValue([true, 0].lastIndexOf(true, -0), 0, '[true, 0].lastIndexOf(true, -0)');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.15-6-2
|
|||
description: >
|
||||
Array.prototype.lastIndexOf returns correct index when 'fromIndex'
|
||||
is length of array - 1
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [1, 2, 3].lastIndexOf(3, 2) === 2;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([1, 2, 3].lastIndexOf(3, 2), 2, '[1, 2, 3].lastIndexOf(3, 2)');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.15-6-3
|
|||
description: >
|
||||
Array.prototype.lastIndexOf returns -1 when 'fromIndex' is length
|
||||
of array - 1
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [1, 2, 3].lastIndexOf(3, 1) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([1, 2, 3].lastIndexOf(3, 1), -1, '[1, 2, 3].lastIndexOf(3, 1)');
|
||||
|
|
|
@ -6,11 +6,6 @@ es5id: 15.4.4.15-6-4
|
|||
description: >
|
||||
Array.prototype.lastIndexOf returns -1 when 'fromIndex' and
|
||||
'length' are both 0
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
function testcase() {
|
||||
|
||||
return [].lastIndexOf(1, 0) === -1;
|
||||
}
|
||||
runTestCase(testcase);
|
||||
assert.sameValue([].lastIndexOf(1, 0), -1, '[].lastIndexOf(1, 0)');
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue