Replace runTestCase with assert helpers, rest [test/built-ins]

This commit is contained in:
André Bargull 2015-08-13 17:56:55 +02:00
parent 1b14708467
commit 4ec97779fd
219 changed files with 695 additions and 2057 deletions

View File

@ -5,16 +5,9 @@
es6id: 22.1.2.1_T1 es6id: 22.1.2.1_T1
description: Testing Array.from when passed a String description: Testing Array.from when passed a String
author: Hank Yates (hankyates@gmail.com) author: Hank Yates (hankyates@gmail.com)
includes: [runTestCase.js]
---*/ ---*/
runTestCase(function () {
var arrLikeSource = 'testValue', var arrLikeSource = 'testValue',
testArr = Array.from(arrLikeSource); testArr = Array.from(arrLikeSource);
if (testArr.length != 9) { assert.sameValue(testArr.length, 9);
return false;
}
return true;
});

View File

@ -5,10 +5,8 @@
es6id: 22.1.2.1_T2 es6id: 22.1.2.1_T2
description: Testing Array.from when passed an Object is passed description: Testing Array.from when passed an Object is passed
author: Hank Yates (hankyates@gmail.com) author: Hank Yates (hankyates@gmail.com)
includes: [runTestCase.js]
---*/ ---*/
runTestCase(function () {
var testArr = Array.from({ var testArr = Array.from({
'a': 1, 'a': 1,
'b': '2', 'b': '2',
@ -16,10 +14,4 @@ runTestCase(function () {
'length': '3' 'length': '3'
}); });
if (testArr.length != 3) { assert.sameValue(testArr.length, 3);
return false;
}
return true;
});

View File

@ -5,16 +5,8 @@
es6id: 22.1.2.1_T3 es6id: 22.1.2.1_T3
description: Testing Array.from when passed an undefined description: Testing Array.from when passed an undefined
author: Hank Yates (hankyates@gmail.com) author: Hank Yates (hankyates@gmail.com)
includes: [runTestCase.js]
---*/ ---*/
runTestCase(function () { assert.throws(TypeError, function() {
try {
Array.from(undefined); Array.from(undefined);
} catch (e) {
return e instanceof TypeError;
}
return false;
}); });

View File

@ -6,25 +6,17 @@ es5id: 15.4.4.16-4-10
description: > description: >
Array.prototype.every - the exception is not thrown if exception Array.prototype.every - the exception is not thrown if exception
was thrown by step 2 was thrown by step 2
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 11, 1: 12 }; var obj = { 0: 11, 1: 12 };
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
throw new SyntaxError(); throw new Test262Error();
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.every.call(obj, undefined); Array.prototype.every.call(obj, undefined);
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -6,29 +6,21 @@ es5id: 15.4.4.16-4-11
description: > description: >
Array.prototype.every - the exception is not thrown if exception Array.prototype.every - the exception is not thrown if exception
was thrown by step 3 was thrown by step 3
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 11, 1: 12 }; var obj = { 0: 11, 1: 12 };
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
return { return {
toString: function () { toString: function () {
throw new SyntaxError(); throw new Test262Error();
} }
}; };
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.every.call(obj, undefined); Array.prototype.every.call(obj, undefined);
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -6,28 +6,22 @@ es5id: 15.4.4.16-7-c-ii-7
description: > description: >
Array.prototype.every - unhandled exceptions happened in Array.prototype.every - unhandled exceptions happened in
callbackfn terminate iteration callbackfn terminate iteration
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var called = 0; var called = 0;
function callbackfn(val, idx, obj) { function callbackfn(val, idx, obj) {
called++; called++;
if (called === 1) { if (called === 1) {
throw new Error("Exception occurred in callbackfn"); throw new Test262Error("Exception occurred in callbackfn");
} }
return true; return true;
} }
var obj = { 0: 11, 4: 10, 10: 8, length: 20 }; var obj = { 0: 11, 4: 10, 10: 8, length: 20 };
try { assert.throws(Test262Error, function() {
Array.prototype.every.call(obj, callbackfn); Array.prototype.every.call(obj, callbackfn);
return false; });
} catch (ex) {
return 1 === called; assert.sameValue(called, 1, 'called');
}
}
runTestCase(testcase);

View File

@ -6,25 +6,17 @@ es5id: 15.4.4.20-4-10
description: > description: >
Array.prototype.filter - the exception is not thrown if exception Array.prototype.filter - the exception is not thrown if exception
was thrown by step 2 was thrown by step 2
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 11, 1: 12 }; var obj = { 0: 11, 1: 12 };
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
throw new SyntaxError(); throw new Test262Error();
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.filter.call(obj, undefined); Array.prototype.filter.call(obj, undefined);
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -6,29 +6,21 @@ es5id: 15.4.4.20-4-11
description: > description: >
Array.prototype.filter - the exception is not thrown if exception Array.prototype.filter - the exception is not thrown if exception
was thrown by step 3 was thrown by step 3
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 11, 1: 12 }; var obj = { 0: 11, 1: 12 };
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
return { return {
toString: function () { toString: function () {
throw new SyntaxError(); throw new Test262Error();
} }
}; };
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.filter.call(obj, undefined); Array.prototype.filter.call(obj, undefined);
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -5,10 +5,9 @@
es5id: 15.4.4.20-5-1 es5id: 15.4.4.20-5-1
description: Array.prototype.filter - thisArg is passed description: Array.prototype.filter - thisArg is passed
flags: [noStrict] flags: [noStrict]
includes: [runTestCase.js]
---*/ ---*/
function testcase() { (function() {
this._15_4_4_20_5_1 = false; this._15_4_4_20_5_1 = false;
var _15_4_4_20_5_1 = true; var _15_4_4_20_5_1 = true;
@ -17,6 +16,6 @@ function testcase() {
} }
var srcArr = [1]; var srcArr = [1];
var resArr = srcArr.filter(callbackfn); var resArr = srcArr.filter(callbackfn);
return resArr.length === 0;
} assert.sameValue(resArr.length, 0, 'resArr.length');
runTestCase(testcase); })();

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.20-9-3
description: > description: >
Array.prototype.filter doesn't visit deleted elements in array Array.prototype.filter doesn't visit deleted elements in array
after the call after the call
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function callbackfn(val, idx, obj) function callbackfn(val, idx, obj)
{ {
delete srcArr[2]; delete srcArr[2];
@ -23,8 +20,8 @@ function testcase() {
var srcArr = [1,2,3,4,5]; var srcArr = [1,2,3,4,5];
var resArr = srcArr.filter(callbackfn); var resArr = srcArr.filter(callbackfn);
if(resArr.length === 3 && resArr[0] === 1 && resArr[2] === 4 ) // two elements deleted
return true;
} // two elements deleted
runTestCase(testcase); assert.sameValue(resArr.length, 3, 'resArr.length');
assert.sameValue(resArr[0], 1, 'resArr[0]');
assert.sameValue(resArr[2], 4, 'resArr[2]');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.20-9-6
description: > description: >
Array.prototype.filter visits deleted element in array after the Array.prototype.filter visits deleted element in array after the
call when same index is also present in prototype call when same index is also present in prototype
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function callbackfn(val, idx, obj) function callbackfn(val, idx, obj)
{ {
delete srcArr[2]; delete srcArr[2];
@ -25,8 +22,8 @@ function testcase() {
var srcArr = [1,2,3,4,5]; var srcArr = [1,2,3,4,5];
var resArr = srcArr.filter(callbackfn); var resArr = srcArr.filter(callbackfn);
delete Array.prototype[4]; delete Array.prototype[4];
if(resArr.length === 4 && resArr[0] === 1 && resArr[3] == 5) // only one element deleted
return true;
} // only one element deleted
runTestCase(testcase); assert.sameValue(resArr.length, 4, 'resArr.length');
assert.sameValue(resArr[0], 1, 'resArr[0]');
assert.sameValue(resArr[3], 5, 'resArr[3]');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.20-9-c-iii-1-2
description: > description: >
Array.prototype.filter - value of returned array element can be Array.prototype.filter - value of returned array element can be
overwritten overwritten
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function callbackfn(val, idx, obj) { function callbackfn(val, idx, obj) {
return true; return true;
} }
@ -18,12 +15,7 @@ function testcase() {
var obj = { 0: 11, 1: 9, length: 2 }; var obj = { 0: 11, 1: 9, length: 2 };
var newArr = Array.prototype.filter.call(obj, callbackfn); var newArr = Array.prototype.filter.call(obj, callbackfn);
try {
var tempVal = newArr[1]; var tempVal = newArr[1];
newArr[1] += 1; newArr[1] += 1;
return newArr[1] !== tempVal;
} catch (ex) { assert.notSameValue(newArr[1], tempVal, 'newArr[1]');
return false;
}
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.20-9-c-iii-1-4
description: > description: >
Array.prototype.filter - value of returned array element can be Array.prototype.filter - value of returned array element can be
changed or deleted changed or deleted
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function callbackfn(val, idx, obj) { function callbackfn(val, idx, obj) {
return true; return true;
} }
@ -18,12 +15,8 @@ function testcase() {
var obj = { 0: 11, 1: 9, length: 2 }; var obj = { 0: 11, 1: 9, length: 2 };
var newArr = Array.prototype.filter.call(obj, callbackfn); var newArr = Array.prototype.filter.call(obj, callbackfn);
try {
var tempVal = newArr[1]; var tempVal = newArr[1];
delete newArr[1]; delete newArr[1];
return tempVal !== undefined && newArr[1] === undefined;
} catch (ex) { assert.notSameValue(tempVal, undefined, 'tempVal');
return false; assert.sameValue(newArr[1], undefined, 'newArr[1]');
}
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.20-9-c-iii-1
description: > description: >
Array.prototype.filter - getOwnPropertyDescriptor(all true) of Array.prototype.filter - getOwnPropertyDescriptor(all true) of
returned array element returned array element
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function callbackfn(val, idx, obj){ function callbackfn(val, idx, obj){
if(val % 2) if(val % 2)
return true; return true;
@ -19,14 +16,12 @@ function testcase() {
} }
var srcArr = [0,1,2,3,4]; var srcArr = [0,1,2,3,4];
var resArr = srcArr.filter(callbackfn); var resArr = srcArr.filter(callbackfn);
if (resArr.length > 0){
var desc = Object.getOwnPropertyDescriptor(resArr, 1) assert(resArr.length > 0, 'resArr.length > 0');
if(desc.value === 3 && //srcArr[1] = true
desc.writable === true && var desc = Object.getOwnPropertyDescriptor(resArr, 1);
desc.enumerable === true &&
desc.configurable === true){ assert.sameValue(desc.value, 3, 'desc.value'); //srcArr[1] = true
return true; assert.sameValue(desc.writable, true, 'desc.writable');
} assert.sameValue(desc.enumerable, true, 'desc.enumerable');
} assert.sameValue(desc.configurable, true, 'desc.configurable');
}
runTestCase(testcase);

View File

@ -6,25 +6,17 @@ es5id: 15.4.4.18-4-10
description: > description: >
Array.prototype.forEach - the exception is not thrown if exception Array.prototype.forEach - the exception is not thrown if exception
was thrown by step 2 was thrown by step 2
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 11, 1: 12 }; var obj = { 0: 11, 1: 12 };
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
throw new SyntaxError(); throw new Test262Error();
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.forEach.call(obj, undefined); Array.prototype.forEach.call(obj, undefined);
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -6,29 +6,21 @@ es5id: 15.4.4.18-4-11
description: > description: >
Array.prototype.forEach - the exception is not thrown if exception Array.prototype.forEach - the exception is not thrown if exception
was thrown by step 3 was thrown by step 3
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 11, 1: 12 }; var obj = { 0: 11, 1: 12 };
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
return { return {
toString: function () { toString: function () {
throw new SyntaxError(); throw new Test262Error();
} }
}; };
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.forEach.call(obj, undefined); Array.prototype.forEach.call(obj, undefined);
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -5,10 +5,9 @@
es5id: 15.4.4.18-5-1 es5id: 15.4.4.18-5-1
description: Array.prototype.forEach - thisArg is passed description: Array.prototype.forEach - thisArg is passed
flags: [noStrict] flags: [noStrict]
includes: [runTestCase.js]
---*/ ---*/
function testcase() { (function() {
this._15_4_4_18_5_1 = false; this._15_4_4_18_5_1 = false;
var _15_4_4_18_5_1 = true; var _15_4_4_18_5_1 = true;
var result; var result;
@ -17,6 +16,6 @@ function testcase() {
} }
var arr = [1]; var arr = [1];
arr.forEach(callbackfn) arr.forEach(callbackfn)
return !result;
} assert.sameValue(result, false, 'result');
runTestCase(testcase); })();

View File

@ -6,10 +6,8 @@ es5id: 15.4.4.14-10-1
description: > description: >
Array.prototype.indexOf returns -1 for elements not present in Array.prototype.indexOf returns -1 for elements not present in
array array
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var a = new Array(); var a = new Array();
a[100] = 1; a[100] = 1;
a[99999] = ""; a[99999] = "";
@ -17,21 +15,15 @@ function testcase() {
a[5555] = 5.5; a[5555] = 5.5;
a[123456] = "str"; a[123456] = "str";
a[5] = 1E+309; a[5] = 1E+309;
if (a.indexOf(1) !== 100 ||
a.indexOf("") !== 99999 || assert.sameValue(a.indexOf(1), 100, 'a.indexOf(1)');
a.indexOf("str") !== 123456 || assert.sameValue(a.indexOf(""), 99999, 'a.indexOf("")');
a.indexOf(1E+309) !== 5 || //Infinity assert.sameValue(a.indexOf("str"), 123456, 'a.indexOf("str")');
a.indexOf(5.5) !== 5555 ) assert.sameValue(a.indexOf(1E+309), 5, 'a.indexOf(1E+309)'); //Infinity
{ assert.sameValue(a.indexOf(5.5), 5555, 'a.indexOf(5.5)');
return false;
} assert.sameValue(a.indexOf(true), -1, 'a.indexOf(true)');
if (a.indexOf(true) === -1 && assert.sameValue(a.indexOf(5), -1, 'a.indexOf(5)');
a.indexOf(5) === -1 && assert.sameValue(a.indexOf("str1"), -1, 'a.indexOf("str1")');
a.indexOf("str1") === -1 && assert.sameValue(a.indexOf(null), -1, 'a.indexOf(null)');
a.indexOf(null) === -1 && assert.sameValue(a.indexOf(new Object()), -1, 'a.indexOf(new Object())');
a.indexOf(new Object()) === -1)
{
return true;
}
}
runTestCase(testcase);

View File

@ -4,30 +4,19 @@
/*--- /*---
es5id: 15.4.4.14-2-15 es5id: 15.4.4.14-2-15
description: Array.prototype.indexOf - 'length' is property of the global object description: Array.prototype.indexOf - 'length' is property of the global object
includes: includes: [fnGlobalObject.js]
- runTestCase.js
- fnGlobalObject.js
---*/ ---*/
function testcase() {
var targetObj = {}; var targetObj = {};
try {
var oldLen = fnGlobalObject().length; var oldLen = fnGlobalObject().length;
fnGlobalObject().length = 2; fnGlobalObject().length = 2;
fnGlobalObject()[1] = targetObj; 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()[1] = {};
fnGlobalObject()[2] = targetObj; fnGlobalObject()[2] = targetObj;
return Array.prototype.indexOf.call(fnGlobalObject(), targetObj) === -1; assert.sameValue(Array.prototype.indexOf.call(fnGlobalObject(), targetObj), -1, 'Array.prototype.indexOf.call(fnGlobalObject(), targetObj)');
} finally {
delete fnGlobalObject()[1];
delete fnGlobalObject()[2];
fnGlobalObject().length = oldLen;
}
}
runTestCase(testcase);

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.indexOf throws TypeError exception when 'length' Array.prototype.indexOf throws TypeError exception when 'length'
is an object with toString and valueOf methods that don<EFBFBD>t return is an object with toString and valueOf methods that don<EFBFBD>t return
primitive values primitive values
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var toStringAccessed = false; var toStringAccessed = false;
var valueOfAccessed = false; var valueOfAccessed = false;
@ -29,11 +26,9 @@ function testcase() {
} }
}; };
try { assert.throws(TypeError, function() {
Array.prototype.indexOf.call(obj); Array.prototype.indexOf.call(obj);
return false; });
} catch (e) {
return toStringAccessed && valueOfAccessed; assert(toStringAccessed, 'toStringAccessed');
} assert(valueOfAccessed, 'valueOfAccessed');
}
runTestCase(testcase);

View File

@ -4,14 +4,9 @@
/*--- /*---
es5id: 15.4.4.14-5-1 es5id: 15.4.4.14-5-1
description: Array.prototype.indexOf when fromIndex is string description: Array.prototype.indexOf when fromIndex is string
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var a = [1,2,1,2,1,2]; 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 assert.sameValue(a.indexOf(2,"2"), 3, '"2" resolves to 2');
return true; assert.sameValue(a.indexOf(2,"one"), 1, '"one" resolves to 0');
}
}
runTestCase(testcase);

View File

@ -4,15 +4,10 @@
/*--- /*---
es5id: 15.4.4.14-5-2 es5id: 15.4.4.14-5-2
description: Array.prototype.indexOf when fromIndex is floating point number description: Array.prototype.indexOf when fromIndex is floating point number
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var a = new Array(1,2,3); 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 assert.sameValue(a.indexOf(3,0.49), 2, '0.49 resolves to 0');
a.indexOf(1,1.51) === -1) { // 1.01 resolves to 1 assert.sameValue(a.indexOf(1,0.51), 0, '0.51 resolves to 0');
return true; assert.sameValue(a.indexOf(1,1.51), -1, '1.51 resolves to 1');
}
}
runTestCase(testcase);

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.indexOf throws TypeError exception when value of Array.prototype.indexOf throws TypeError exception when value of
'fromIndex' is an object with toString and valueOf methods that 'fromIndex' is an object with toString and valueOf methods that
don<EFBFBD>t return primitive values don<EFBFBD>t return primitive values
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var toStringAccessed = false; var toStringAccessed = false;
var valueOfAccessed = false; var valueOfAccessed = false;
var fromIndex = { var fromIndex = {
@ -26,11 +23,9 @@ function testcase() {
} }
}; };
try { assert.throws(TypeError, function() {
[0, true].indexOf(true, fromIndex); [0, true].indexOf(true, fromIndex);
return false; });
} catch (e) {
return toStringAccessed && valueOfAccessed; assert(toStringAccessed, 'toStringAccessed');
} assert(valueOfAccessed, 'valueOfAccessed');
}
runTestCase(testcase);

View File

@ -6,10 +6,8 @@ es5id: 15.4.4.14-5-26
description: > description: >
Array.prototype.indexOf - side effects produced by step 2 are Array.prototype.indexOf - side effects produced by step 2 are
visible when an exception occurs visible when an exception occurs
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var stepTwoOccurs = false; var stepTwoOccurs = false;
var stepFiveOccurs = false; var stepFiveOccurs = false;
@ -33,11 +31,7 @@ function testcase() {
} }
}; };
try {
Array.prototype.indexOf.call(obj, undefined, fromIndex); Array.prototype.indexOf.call(obj, undefined, fromIndex);
return stepTwoOccurs && stepFiveOccurs;
} catch (ex) { assert(stepTwoOccurs, 'stepTwoOccurs !== true');
return false; assert(stepFiveOccurs, 'stepFiveOccurs !== true');
}
}
runTestCase(testcase);

View File

@ -6,10 +6,8 @@ es5id: 15.4.4.14-5-27
description: > description: >
Array.prototype.indexOf - side effects produced by step 3 are Array.prototype.indexOf - side effects produced by step 3 are
visible when an exception occurs visible when an exception occurs
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var stepThreeOccurs = false; var stepThreeOccurs = false;
var stepFiveOccurs = false; var stepFiveOccurs = false;
@ -37,11 +35,7 @@ function testcase() {
} }
}; };
try {
Array.prototype.indexOf.call(obj, undefined, fromIndex); Array.prototype.indexOf.call(obj, undefined, fromIndex);
return stepThreeOccurs && stepFiveOccurs;
} catch (ex) { assert(stepThreeOccurs, 'stepThreeOccurs !== true');
return false; assert(stepFiveOccurs, 'stepFiveOccurs !== true');
}
}
runTestCase(testcase);

View File

@ -4,14 +4,9 @@
/*--- /*---
es5id: 15.4.4.14-5-3 es5id: 15.4.4.14-5-3
description: Array.prototype.indexOf when fromIndex is boolean description: Array.prototype.indexOf when fromIndex is boolean
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var a = [1,2,3]; var a = [1,2,3];
if (a.indexOf(1,true) === -1 && // true resolves to 1
a.indexOf(1,false) === 0 ) { // false resolves to 0 assert.sameValue(a.indexOf(1,true), -1, 'true resolves to 1');
return true; assert.sameValue(a.indexOf(1,false), 0, 'false resolves to 0');
}
}
runTestCase(testcase);

View File

@ -4,13 +4,9 @@
/*--- /*---
es5id: 15.4.4.14-5-4 es5id: 15.4.4.14-5-4
description: Array.prototype.indexOf returns 0 if fromIndex is 'undefined' description: Array.prototype.indexOf returns 0 if fromIndex is 'undefined'
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var a = [1,2,3]; var a = [1,2,3];
if (a.indexOf(1,undefined) === 0) { // undefined resolves to 0
return true; // undefined resolves to 0
} assert.sameValue(a.indexOf(1,undefined), 0, 'a.indexOf(1,undefined)');
}
runTestCase(testcase);

View File

@ -4,13 +4,9 @@
/*--- /*---
es5id: 15.4.4.14-5-5 es5id: 15.4.4.14-5-5
description: Array.prototype.indexOf returns 0 if fromIndex is null description: Array.prototype.indexOf returns 0 if fromIndex is null
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var a = [1,2,3]; var a = [1,2,3];
if (a.indexOf(1,null) === 0 ) { // null resolves to 0
return true; // null resolves to 0
} assert.sameValue(a.indexOf(1,null), 0, 'a.indexOf(1,null)');
}
runTestCase(testcase);

View File

@ -4,17 +4,11 @@
/*--- /*---
es5id: 15.4.4.14-9-1 es5id: 15.4.4.14-9-1
description: Array.prototype.indexOf must return correct index (boolean) description: Array.prototype.indexOf must return correct index (boolean)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {toString:function (){return true}}; var obj = {toString:function (){return true}};
var _false = false; var _false = false;
var a = [obj,"true", undefined,0,_false,null,1,"str",0,1,true,false,true,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 assert.sameValue(a.indexOf(true), 10, 'a[10]=true');
{ assert.sameValue(a.indexOf(false), 4, 'a[4] =_false');
return true;
}
}
runTestCase(testcase);

View File

@ -7,15 +7,9 @@ info: >
and hence NaNs could be found using indexOf * and hence NaNs could be found using indexOf *
es5id: 15.4.4.14-9-10 es5id: 15.4.4.14-9-10
description: Array.prototype.indexOf must return correct index (NaN) description: Array.prototype.indexOf must return correct index (NaN)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var _NaN = NaN; var _NaN = NaN;
var a = new Array("NaN",undefined,0,false,null,{toString:function (){return NaN}},"false",_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.
{ assert.sameValue(a.indexOf(NaN), -1, 'NaN is equal to nothing, including itself.');
return true;
}
}
runTestCase(testcase);

View File

@ -4,20 +4,14 @@
/*--- /*---
es5id: 15.4.4.14-9-2 es5id: 15.4.4.14-9-2
description: Array.prototype.indexOf must return correct index (Number) description: Array.prototype.indexOf must return correct index (Number)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {toString:function (){return 0}}; var obj = {toString:function (){return 0}};
var one = 1; var one = 1;
var _float = -(4/3); 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)); 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 assert.sameValue(a.indexOf(-(4/3)), 14, 'a[14]=_float===-(4/3)');
a.indexOf(-0) === 7 && // a[7] = +0, -0===+0 assert.sameValue(a.indexOf(0), 7, 'a[7] = +0, 0===+0');
a.indexOf(1) === 10 ) // a[10] =one=== 1 assert.sameValue(a.indexOf(-0), 7, 'a[7] = +0, -0===+0');
{ assert.sameValue(a.indexOf(1), 10, 'a[10] =one=== 1');
return true;
}
}
runTestCase(testcase);

View File

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

View File

@ -4,17 +4,11 @@
/*--- /*---
es5id: 15.4.4.14-9-4 es5id: 15.4.4.14-9-4
description: Array.prototype.indexOf must return correct index(undefined) description: Array.prototype.indexOf must return correct index(undefined)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {toString:function (){return undefined;}}; var obj = {toString:function (){return undefined;}};
var _undefined1 = undefined; var _undefined1 = undefined;
var _undefined2; var _undefined2;
var a = new Array(true,0,false,null,1,"undefined",obj,1,_undefined2,_undefined1,undefined); var a = new Array(true,0,false,null,1,"undefined",obj,1,_undefined2,_undefined1,undefined);
if (a.indexOf(undefined) === 8) //a[8]=_undefined2
{ assert.sameValue(a.indexOf(undefined), 8, 'a[8]=_undefined2');
return true;
}
}
runTestCase(testcase);

View File

@ -4,17 +4,11 @@
/*--- /*---
es5id: 15.4.4.14-9-5 es5id: 15.4.4.14-9-5
description: Array.prototype.indexOf must return correct index (Object) description: Array.prototype.indexOf must return correct index (Object)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj1 = {toString:function (){return "false"}}; var obj1 = {toString:function (){return "false"}};
var obj2 = {toString:function (){return "false"}}; var obj2 = {toString:function (){return "false"}};
var obj3 = obj1; var obj3 = obj1;
var a = new Array(false,undefined,0,false,null,{toString:function (){return "false"}},"false",obj2,obj1,obj3); 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;
{ assert.sameValue(a.indexOf(obj3), 8, 'a[8] = obj1');
return true;
}
}
runTestCase(testcase);

View File

@ -4,16 +4,10 @@
/*--- /*---
es5id: 15.4.4.14-9-6 es5id: 15.4.4.14-9-6
description: Array.prototype.indexOf must return correct index(null) description: Array.prototype.indexOf must return correct index(null)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {toString:function (){return null}}; var obj = {toString:function (){return null}};
var _null = null; var _null = null;
var a = new Array(true,undefined,0,false,_null,1,"str",0,1,obj,true,false,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
{ assert.sameValue(a.indexOf(null), 4, 'a[4]=_null');
return true;
}
}
runTestCase(testcase);

View File

@ -6,30 +6,19 @@ es5id: 15.4.4.15-2-15
description: > description: >
Array.prototype.lastIndexOf - 'length' is property of the global Array.prototype.lastIndexOf - 'length' is property of the global
object object
includes: includes: [fnGlobalObject.js]
- runTestCase.js
- fnGlobalObject.js
---*/ ---*/
function testcase() {
var targetObj = {}; var targetObj = {};
try {
var oldLen = fnGlobalObject().length; var oldLen = fnGlobalObject().length;
fnGlobalObject().length = 2; fnGlobalObject().length = 2;
fnGlobalObject()[1] = targetObj; 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()[1] = {};
fnGlobalObject()[2] = targetObj; fnGlobalObject()[2] = targetObj;
return Array.prototype.lastIndexOf.call(fnGlobalObject(), targetObj) === -1; assert.sameValue(Array.prototype.lastIndexOf.call(fnGlobalObject(), targetObj), -1);
} finally {
delete fnGlobalObject()[1];
delete fnGlobalObject()[2];
fnGlobalObject().length = oldLen;
}
}
runTestCase(testcase);

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.lastIndexOf throws TypeError exception when Array.prototype.lastIndexOf throws TypeError exception when
'length' is an object with toString and valueOf methods that don<EFBFBD>t 'length' is an object with toString and valueOf methods that don<EFBFBD>t
return primitive values return primitive values
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var toStringAccessed = false; var toStringAccessed = false;
var valueOfAccessed = false; var valueOfAccessed = false;
@ -30,11 +27,9 @@ function testcase() {
} }
}; };
try { assert.throws(TypeError, function() {
Array.prototype.lastIndexOf.call(obj, true); Array.prototype.lastIndexOf.call(obj, true);
return false; });
} catch (e) {
return toStringAccessed && valueOfAccessed; assert(toStringAccessed, 'toStringAccessed');
} assert(valueOfAccessed, 'valueOfAccessed');
}
runTestCase(testcase);

View File

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

View File

@ -4,14 +4,9 @@
/*--- /*---
es5id: 15.4.4.15-5-1 es5id: 15.4.4.15-5-1
description: Array.prototype.lastIndexOf when fromIndex is string description: Array.prototype.lastIndexOf when fromIndex is string
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var a = new Array(0,1,1); 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 assert.sameValue(a.lastIndexOf(1,"1"), 1, '"1" resolves to 1');
return true; assert.sameValue(a.lastIndexOf(1,"one"), -1, 'NaN string resolves to 01');
}
}
runTestCase(testcase);

View File

@ -4,15 +4,10 @@
/*--- /*---
es5id: 15.4.4.15-5-2 es5id: 15.4.4.15-5-2
description: Array.prototype.lastIndexOf when fromIndex is floating point number description: Array.prototype.lastIndexOf when fromIndex is floating point number
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var a = new Array(1,2,1); 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 assert.sameValue(a.lastIndexOf(2,1.49), 1, '1.49 resolves to 1');
a.lastIndexOf(1,0.51) === 0){ // 0.51 resolves to 0 assert.sameValue(a.lastIndexOf(2,0.51), -1, '0.51 resolves to 0');
return true; assert.sameValue(a.lastIndexOf(1,0.51), 0, '0.51 resolves to 0');
}
}
runTestCase(testcase);

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.lastIndexOf throws TypeError exception when value Array.prototype.lastIndexOf throws TypeError exception when value
of 'fromIndex' is an object that both toString and valueOf methods of 'fromIndex' is an object that both toString and valueOf methods
than don't return primitive value than don't return primitive value
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var toStringAccessed = false; var toStringAccessed = false;
var valueOfAccessed = false; var valueOfAccessed = false;
@ -27,11 +24,9 @@ function testcase() {
} }
}; };
try { assert.throws(TypeError, function() {
[0, null].lastIndexOf(null, fromIndex); [0, null].lastIndexOf(null, fromIndex);
return false; });
} catch (e) {
return toStringAccessed && valueOfAccessed; assert(toStringAccessed, 'toStringAccessed');
} assert(valueOfAccessed, 'valueOfAccessed');
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.15-5-26
description: > description: >
Array.prototype.lastIndexOf - side effects produced by step 2 are Array.prototype.lastIndexOf - side effects produced by step 2 are
visible when an exception occurs visible when an exception occurs
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var stepTwoOccurs = false; var stepTwoOccurs = false;
var stepFiveOccurs = false; var stepFiveOccurs = false;
var obj = {}; var obj = {};
@ -33,11 +30,7 @@ function testcase() {
} }
}; };
try {
Array.prototype.lastIndexOf.call(obj, undefined, fromIndex); Array.prototype.lastIndexOf.call(obj, undefined, fromIndex);
return stepTwoOccurs && stepFiveOccurs;
} catch (ex) { assert(stepTwoOccurs, 'stepTwoOccurs !== true');
return false; assert(stepFiveOccurs, 'stepFiveOccurs !== true');
}
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.15-5-27
description: > description: >
Array.prototype.lastIndexOf - side effects produced by step 3 are Array.prototype.lastIndexOf - side effects produced by step 3 are
visible when an exception occurs visible when an exception occurs
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var stepThreeOccurs = false; var stepThreeOccurs = false;
var stepFiveOccurs = false; var stepFiveOccurs = false;
@ -38,11 +35,7 @@ function testcase() {
} }
}; };
try {
Array.prototype.lastIndexOf.call(obj, undefined, fromIndex); Array.prototype.lastIndexOf.call(obj, undefined, fromIndex);
return stepThreeOccurs && stepFiveOccurs;
} catch (ex) { assert(stepThreeOccurs, 'stepThreeOccurs !== true');
return false; assert(stepFiveOccurs, 'stepFiveOccurs !== true');
}
}
runTestCase(testcase);

View File

@ -4,14 +4,9 @@
/*--- /*---
es5id: 15.4.4.15-5-3 es5id: 15.4.4.15-5-3
description: Array.prototype.lastIndexOf when fromIndex is boolean description: Array.prototype.lastIndexOf when fromIndex is boolean
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var a = new Array(1,2,1); 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 assert.sameValue(a.lastIndexOf(2,true), 1, 'true resolves to 1');
return true; assert.sameValue(a.lastIndexOf(2,false), -1, 'false resolves to 0');
}
}
runTestCase(testcase);

View File

@ -4,15 +4,11 @@
/*--- /*---
es5id: 15.4.4.15-5-4 es5id: 15.4.4.15-5-4
description: Array.prototype.lastIndexOf when fromIndex is undefined description: Array.prototype.lastIndexOf when fromIndex is undefined
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var a = new Array(1,2,1); var a = new Array(1,2,1);
if (a.lastIndexOf(2,undefined) === -1 &&
a.lastIndexOf(1,undefined) === 0 && // undefined resolves to 0, no second argument resolves to len
a.lastIndexOf(1) === 2) { // undefined resolves to 0, no second argument resolves to len assert.sameValue(a.lastIndexOf(2,undefined), -1, 'a.lastIndexOf(2,undefined)');
return true; assert.sameValue(a.lastIndexOf(1,undefined), 0, 'a.lastIndexOf(1,undefined)');
} assert.sameValue(a.lastIndexOf(1), 2, 'a.lastIndexOf(1)');
}
runTestCase(testcase);

View File

@ -4,13 +4,10 @@
/*--- /*---
es5id: 15.4.4.15-5-5 es5id: 15.4.4.15-5-5
description: Array.prototype.lastIndexOf when fromIndex is null description: Array.prototype.lastIndexOf when fromIndex is null
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var a = new Array(1,2,1); var a = new Array(1,2,1);
if (a.lastIndexOf(2,null) === -1 && a.lastIndexOf(1,null) === 0) { // null resolves to 0
return true; // 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)');
runTestCase(testcase);

View File

@ -6,12 +6,7 @@ es5id: 15.4.4.15-5-7
description: > description: >
Array.prototype.lastIndexOf - value of 'fromIndex' is a number Array.prototype.lastIndexOf - value of 'fromIndex' is a number
(value is 0) (value is 0)
includes: [runTestCase.js]
---*/ ---*/
function 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');
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);

View File

@ -4,17 +4,11 @@
/*--- /*---
es5id: 15.4.4.15-8-1 es5id: 15.4.4.15-8-1
description: Array.prototype.lastIndexOf must return correct index(boolean) description: Array.prototype.lastIndexOf must return correct index(boolean)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {toString:function (){return true}}; var obj = {toString:function (){return true}};
var _false = false; var _false = false;
var a = new Array(false,true,false,obj,_false,true,"true", undefined,0,null,1,"str",0,1); var a = new Array(false,true,false,obj,_false,true,"true", undefined,0,null,1,"str",0,1);
if (a.lastIndexOf(true) === 5 && //a[5]=true
a.lastIndexOf(false) === 4) //a[4] =_false assert.sameValue(a.lastIndexOf(true), 5, 'a[5]=true');
{ assert.sameValue(a.lastIndexOf(false), 4, 'a[4] =_false');
return true;
}
}
runTestCase(testcase);

View File

@ -7,15 +7,9 @@ info: >
and hence NaNs could be found using lastIndexOf * and hence NaNs could be found using lastIndexOf *
es5id: 15.4.4.15-8-10 es5id: 15.4.4.15-8-10
description: Array.prototype.lastIndexOf must return correct index (NaN) description: Array.prototype.lastIndexOf must return correct index (NaN)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var _NaN = NaN; var _NaN = NaN;
var a = new Array("NaN",_NaN,NaN, undefined,0,false,null,{toString:function (){return NaN}},"false"); var a = new Array("NaN",_NaN,NaN, undefined,0,false,null,{toString:function (){return NaN}},"false");
if (a.lastIndexOf(NaN) === -1) // NaN matches nothing, not even itself
{ assert.sameValue(a.lastIndexOf(NaN), -1, 'NaN matches nothing, not even itself');
return true;
}
}
runTestCase(testcase);

View File

@ -4,20 +4,14 @@
/*--- /*---
es5id: 15.4.4.15-8-2 es5id: 15.4.4.15-8-2
description: Array.prototype.lastIndexOf must return correct index(Number) description: Array.prototype.lastIndexOf must return correct index(Number)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {toString:function (){return 0}}; var obj = {toString:function (){return 0}};
var one = 1; var one = 1;
var _float = -(4/3); var _float = -(4/3);
var a = new Array(+0,true,0,-0, false,undefined,null,"0",obj, _float,-(4/3),-1.3333333333333,"str",one, 1, false); var a = new Array(+0,true,0,-0, false,undefined,null,"0",obj, _float,-(4/3),-1.3333333333333,"str",one, 1, false);
if (a.lastIndexOf(-(4/3)) === 10 && // a[10]=-(4/3)
a.lastIndexOf(0) === 3 && // a[3] = -0, but using === -0 and 0 are equal assert.sameValue(a.lastIndexOf(-(4/3)), 10, 'a[10]=-(4/3)');
a.lastIndexOf(-0) ===3 && // a[3] = -0 assert.sameValue(a.lastIndexOf(0), 3, 'a[3] = -0, but using === -0 and 0 are equal');
a.lastIndexOf(1) === 14 ) // a[14] = 1 assert.sameValue(a.lastIndexOf(-0), 3, 'a[3] = -0');
{ assert.sameValue(a.lastIndexOf(1), 14, 'a[14] = 1');
return true;
}
}
runTestCase(testcase);

View File

@ -7,17 +7,14 @@ description: >
Array.prototype.lastIndexOf applied to Arguments object which Array.prototype.lastIndexOf applied to Arguments object which
implements its own property get method (number of arguments is implements its own property get method (number of arguments is
greater than number of parameters) greater than number of parameters)
includes: [runTestCase.js]
---*/ ---*/
function testcase() { var func = function (a, b) {
assert.sameValue(Array.prototype.lastIndexOf.call(arguments, arguments[0]), 2);
assert.sameValue(Array.prototype.lastIndexOf.call(arguments, arguments[3]), 3);
assert.sameValue(Array.prototype.lastIndexOf.call(arguments, arguments[4]), -1);
};
var func = function (a, b) { (function() {
return 2 === Array.prototype.lastIndexOf.call(arguments, arguments[0]) && func(0, arguments, 0, Object.prototype);
3 === Array.prototype.lastIndexOf.call(arguments, arguments[3]) && })();
-1 === Array.prototype.lastIndexOf.call(arguments, arguments[4]);
};
return func(0, arguments, 0, Object.prototype);
}
runTestCase(testcase);

View File

@ -4,10 +4,8 @@
/*--- /*---
es5id: 15.4.4.15-9-1 es5id: 15.4.4.15-9-1
description: Array.prototype.lastIndexOf returns -1 for elements not present description: Array.prototype.lastIndexOf returns -1 for elements not present
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var a = new Array(); var a = new Array();
a[100] = 1; a[100] = 1;
a[99999] = ""; a[99999] = "";
@ -15,21 +13,15 @@ function testcase() {
a[5555] = 5.5; a[5555] = 5.5;
a[123456] = "str"; a[123456] = "str";
a[5] = 1E+309; a[5] = 1E+309;
if (a.lastIndexOf(1) !== 100 ||
a.lastIndexOf("") !== 99999 || assert.sameValue(a.lastIndexOf(1), 100, 'a.lastIndexOf(1)');
a.lastIndexOf("str") !== 123456 || assert.sameValue(a.lastIndexOf(""), 99999, 'a.lastIndexOf("")');
a.lastIndexOf(5.5) !== 5555 || assert.sameValue(a.lastIndexOf("str"), 123456, 'a.lastIndexOf("str")');
a.lastIndexOf(1E+309) !== 5 ) assert.sameValue(a.lastIndexOf(5.5), 5555, 'a.lastIndexOf(5.5)');
{ assert.sameValue(a.lastIndexOf(1E+309), 5, 'a.lastIndexOf(1E+309)');
return false;
} assert.sameValue(a.lastIndexOf(true), -1, 'a.lastIndexOf(true)');
if (a.lastIndexOf(true) === -1 && assert.sameValue(a.lastIndexOf(5), -1, 'a.lastIndexOf(5)');
a.lastIndexOf(5) === -1 && assert.sameValue(a.lastIndexOf("str1"), -1, 'a.lastIndexOf("str1")');
a.lastIndexOf("str1") === -1 && assert.sameValue(a.lastIndexOf(null), -1, 'a.lastIndexOf(null)');
a.lastIndexOf(null) === -1 && assert.sameValue(a.lastIndexOf(new Object()), -1, 'a.lastIndexOf(new Object())');
a.lastIndexOf(new Object()) === -1 )
{
return true;
}
}
runTestCase(testcase);

View File

@ -6,25 +6,17 @@ es5id: 15.4.4.19-4-10
description: > description: >
Array.prototype.map - the exception is not thrown if exception was Array.prototype.map - the exception is not thrown if exception was
thrown by step 2 thrown by step 2
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 11, 1: 12 }; var obj = { 0: 11, 1: 12 };
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
throw new SyntaxError(); throw new Test262Error();
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.map.call(obj, undefined); Array.prototype.map.call(obj, undefined);
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -6,29 +6,21 @@ es5id: 15.4.4.19-4-11
description: > description: >
Array.prototype.map - the exception is not thrown if exception was Array.prototype.map - the exception is not thrown if exception was
thrown by step 3 thrown by step 3
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 11, 1: 12 }; var obj = { 0: 11, 1: 12 };
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
return { return {
toString: function () { toString: function () {
throw new SyntaxError(); throw new Test262Error();
} }
}; };
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.map.call(obj, undefined); Array.prototype.map.call(obj, undefined);
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.19-8-c-iii-1
description: > description: >
Array.prototype.map - getOwnPropertyDescriptor(all true) of Array.prototype.map - getOwnPropertyDescriptor(all true) of
returned array element returned array element
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function callbackfn(val, idx, obj){ function callbackfn(val, idx, obj){
if(val % 2) if(val % 2)
return (2 * val + 1); return (2 * val + 1);
@ -19,14 +16,12 @@ function testcase() {
} }
var srcArr = [0,1,2,3,4]; var srcArr = [0,1,2,3,4];
var resArr = srcArr.map(callbackfn); var resArr = srcArr.map(callbackfn);
if (resArr.length > 0){
var desc = Object.getOwnPropertyDescriptor(resArr, 1) assert(resArr.length > 0, 'resArr.length > 0');
if(desc.value === 3 && //srcArr[1] = 2*1+1 = 3
desc.writable === true && var desc = Object.getOwnPropertyDescriptor(resArr, 1);
desc.enumerable === true &&
desc.configurable === true){ assert.sameValue(desc.value, 3, 'desc.value'); //srcArr[1] = 2*1+1 = 3
return true; assert.sameValue(desc.writable, true, 'desc.writable');
} assert.sameValue(desc.enumerable, true, 'desc.enumerable');
} assert.sameValue(desc.configurable, true, 'desc.configurable');
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.19-8-c-iii-3
description: > description: >
Array.prototype.map - value of returned array element can be Array.prototype.map - value of returned array element can be
overwritten overwritten
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function callbackfn(val, idx, obj) { function callbackfn(val, idx, obj) {
return 11; return 11;
} }
@ -18,12 +15,7 @@ function testcase() {
var obj = { 0: 11, 1: 9, length: 2 }; var obj = { 0: 11, 1: 9, length: 2 };
var newArr = Array.prototype.map.call(obj, callbackfn); var newArr = Array.prototype.map.call(obj, callbackfn);
try {
var tempVal = newArr[1]; var tempVal = newArr[1];
newArr[1] += 1; newArr[1] += 1;
return newArr[1] !== tempVal;
} catch (ex) { assert.notSameValue(newArr[1], tempVal, 'newArr[1]');
return false;
}
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.19-8-c-iii-5
description: > description: >
Array.prototype.map - value of returned array element can be Array.prototype.map - value of returned array element can be
changed or deleted changed or deleted
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function callbackfn(val, idx, obj) { function callbackfn(val, idx, obj) {
return true; return true;
} }
@ -18,12 +15,8 @@ function testcase() {
var obj = { 0: 11, 1: 9, length: 2 }; var obj = { 0: 11, 1: 9, length: 2 };
var newArr = Array.prototype.map.call(obj, callbackfn); var newArr = Array.prototype.map.call(obj, callbackfn);
try {
var tempVal = newArr[1]; var tempVal = newArr[1];
delete newArr[1]; delete newArr[1];
return tempVal !== undefined && newArr[1] === undefined;
} catch (ex) { assert.notSameValue(tempVal, undefined, 'tempVal');
return false; assert.sameValue(newArr[1], undefined, 'newArr[1]');
}
}
runTestCase(testcase);

View File

@ -6,25 +6,17 @@ es5id: 15.4.4.21-4-10
description: > description: >
Array.prototype.reduce - the exception is not thrown if exception Array.prototype.reduce - the exception is not thrown if exception
was thrown by step 2 was thrown by step 2
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 11, 1: 12 }; var obj = { 0: 11, 1: 12 };
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
throw new SyntaxError(); throw new Test262Error();
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.reduce.call(obj, undefined); Array.prototype.reduce.call(obj, undefined);
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -6,29 +6,21 @@ es5id: 15.4.4.21-4-11
description: > description: >
Array.prototype.reduce - the exception is not thrown if exception Array.prototype.reduce - the exception is not thrown if exception
was thrown by step 3 was thrown by step 3
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 11, 1: 12 }; var obj = { 0: 11, 1: 12 };
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
return { return {
toString: function () { toString: function () {
throw new SyntaxError(); throw new Test262Error();
} }
}; };
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.reduce.call(obj, undefined); Array.prototype.reduce.call(obj, undefined);
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-5-12
description: > description: >
Array.prototype.reduce - the exception is not thrown if exception Array.prototype.reduce - the exception is not thrown if exception
was thrown by step 2 was thrown by step 2
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) { function callbackfn(prevVal, curVal, idx, obj) {
return (curVal > 10); return (curVal > 10);
} }
@ -19,16 +16,11 @@ function testcase() {
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
throw new SyntaxError(); throw new Test262Error();
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.reduce.call(obj, callbackfn); Array.prototype.reduce.call(obj, callbackfn);
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-5-13
description: > description: >
Array.prototype.reduce - the exception is not thrown if exception Array.prototype.reduce - the exception is not thrown if exception
was thrown by step 3 was thrown by step 3
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) { function callbackfn(prevVal, curVal, idx, obj) {
return (curVal > 10); return (curVal > 10);
} }
@ -21,19 +18,13 @@ function testcase() {
get: function () { get: function () {
return { return {
toString: function () { toString: function () {
throw new SyntaxError(); throw new Test262Error();
} }
}; };
}, },
configurable: true configurable: true
}); });
assert.throws(Test262Error, function() {
try {
Array.prototype.reduce.call(obj, callbackfn); Array.prototype.reduce.call(obj, callbackfn);
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -4,11 +4,8 @@
/*--- /*---
es5id: 15.4.4.21-8-b-1 es5id: 15.4.4.21-8-b-1
description: Array.prototype.reduce - no observable effects occur if 'len' is 0 description: Array.prototype.reduce - no observable effects occur if 'len' is 0
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var accessed = false; var accessed = false;
var obj = { length: 0 }; var obj = { length: 0 };
@ -21,11 +18,8 @@ function testcase() {
configurable: true configurable: true
}); });
try { assert.throws(TypeError, function() {
Array.prototype.reduce.call(obj, function () { }); Array.prototype.reduce.call(obj, function () { });
return false; });
} catch (ex) {
return !accessed; assert.sameValue(accessed, false, 'accessed');
}
}
runTestCase(testcase);

View File

@ -6,25 +6,17 @@ es5id: 15.4.4.21-8-c-7
description: > description: >
Array.prototype.reduce - the exception is not thrown if exception Array.prototype.reduce - the exception is not thrown if exception
was thrown by step 2 was thrown by step 2
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {}; var obj = {};
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
throw new SyntaxError(); throw new Test262Error();
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.reduce.call(obj, function () { }); Array.prototype.reduce.call(obj, function () { });
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -6,29 +6,21 @@ es5id: 15.4.4.21-8-c-8
description: > description: >
Array.prototype.reduce - the exception is not thrown if exception Array.prototype.reduce - the exception is not thrown if exception
was thrown by step 3 was thrown by step 3
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {}; var obj = {};
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
return { return {
toString: function () { toString: function () {
throw new SyntaxError(); throw new Test262Error();
} }
}; };
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.reduce.call(obj, function () { }); Array.prototype.reduce.call(obj, function () { });
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-9-3
description: > description: >
Array.prototype.reduce doesn't visit deleted elements in array Array.prototype.reduce doesn't visit deleted elements in array
after the call after the call
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) function callbackfn(prevVal, curVal, idx, obj)
{ {
delete arr[3]; delete arr[3];
@ -19,8 +16,6 @@ function testcase() {
} }
var arr = ['1',2,3,4,5]; var arr = ['1',2,3,4,5];
if(arr.reduce(callbackfn) === "123" ) // two elements deleted
return true;
} // two elements deleted
runTestCase(testcase); assert.sameValue(arr.reduce(callbackfn), "123", 'arr.reduce(callbackfn)');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-9-6
description: > description: >
Array.prototype.reduce visits deleted element in array after the Array.prototype.reduce visits deleted element in array after the
call when same index is also present in prototype call when same index is also present in prototype
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) function callbackfn(prevVal, curVal, idx, obj)
{ {
delete arr[3]; delete arr[3];
@ -23,8 +20,5 @@ function testcase() {
var res = arr.reduce(callbackfn); var res = arr.reduce(callbackfn);
delete Array.prototype[4]; delete Array.prototype[4];
if(res === "1235" ) //one element acually deleted //one element acually deleted
return true; assert.sameValue(res, "1235", 'res');
}
runTestCase(testcase);

View File

@ -6,25 +6,17 @@ es5id: 15.4.4.22-4-10
description: > description: >
Array.prototype.reduceRight - the exception is not thrown if Array.prototype.reduceRight - the exception is not thrown if
exception was thrown by step 2 exception was thrown by step 2
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 11, 1: 12 }; var obj = { 0: 11, 1: 12 };
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
throw new SyntaxError(); throw new Test262Error();
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.reduceRight.call(obj, undefined); Array.prototype.reduceRight.call(obj, undefined);
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -6,29 +6,21 @@ es5id: 15.4.4.22-4-11
description: > description: >
Array.prototype.reduceRight - the exception is not thrown if Array.prototype.reduceRight - the exception is not thrown if
exception was thrown by step 3 exception was thrown by step 3
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 11, 1: 12 }; var obj = { 0: 11, 1: 12 };
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
return { return {
toString: function () { toString: function () {
throw new SyntaxError(); throw new Test262Error();
} }
}; };
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.reduceRight.call(obj, undefined); Array.prototype.reduceRight.call(obj, undefined);
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -6,25 +6,17 @@ es5id: 15.4.4.22-5-12
description: > description: >
Array.prototype.reduceRight - the exception is not thrown if Array.prototype.reduceRight - the exception is not thrown if
exception was thrown by step 2 exception was thrown by step 2
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 11, 1: 12 }; var obj = { 0: 11, 1: 12 };
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
throw new SyntaxError(); throw new Test262Error();
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.reduceRight.call(obj, function () { }); Array.prototype.reduceRight.call(obj, function () { });
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -6,29 +6,21 @@ es5id: 15.4.4.22-5-13
description: > description: >
Array.prototype.reduceRight - the exception is not thrown if Array.prototype.reduceRight - the exception is not thrown if
exception was thrown by step 3 exception was thrown by step 3
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 11, 1: 12 }; var obj = { 0: 11, 1: 12 };
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
return { return {
toString: function () { toString: function () {
throw new SyntaxError(); throw new Test262Error();
} }
}; };
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.reduceRight.call(obj, function () { }); Array.prototype.reduceRight.call(obj, function () { });
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.22-8-b-1
description: > description: >
Array.prototype.reduceRight - no observable effects occur if 'len' Array.prototype.reduceRight - no observable effects occur if 'len'
is 0 is 0
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var accessed = false; var accessed = false;
var obj = { length: 0 }; var obj = { length: 0 };
@ -23,11 +20,8 @@ function testcase() {
configurable: true configurable: true
}); });
try { assert.throws(TypeError, function() {
Array.prototype.reduceRight.call(obj, function () { }); Array.prototype.reduceRight.call(obj, function () { });
return false; });
} catch (ex) {
return !accessed; assert.sameValue(accessed, false, 'accessed');
}
}
runTestCase(testcase);

View File

@ -6,25 +6,17 @@ es5id: 15.4.4.22-8-c-7
description: > description: >
Array.prototype.reduceRight - the exception is not thrown if Array.prototype.reduceRight - the exception is not thrown if
exception was thrown by step 2 exception was thrown by step 2
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {}; var obj = {};
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
throw new SyntaxError(); throw new Test262Error();
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.reduceRight.call(obj, function () { }); Array.prototype.reduceRight.call(obj, function () { });
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -6,29 +6,21 @@ es5id: 15.4.4.22-8-c-8
description: > description: >
Array.prototype.reduceRight - the exception is not thrown if Array.prototype.reduceRight - the exception is not thrown if
exception was thrown by step 3 exception was thrown by step 3
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = {}; var obj = {};
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
return { return {
toString: function () { toString: function () {
throw new SyntaxError(); throw new Test262Error();
} }
}; };
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.reduceRight.call(obj, function () { }); Array.prototype.reduceRight.call(obj, function () { });
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.22-9-3
description: > description: >
Array.prototype.reduceRight doesn't consider unvisited deleted Array.prototype.reduceRight doesn't consider unvisited deleted
elements in array after the call elements in array after the call
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) function callbackfn(prevVal, curVal, idx, obj)
{ {
delete arr[1]; delete arr[1];
@ -19,8 +16,6 @@ function testcase() {
} }
var arr = ['1',2,3,4,5]; var arr = ['1',2,3,4,5];
if(arr.reduceRight(callbackfn) === "121" ) // two elements deleted
return true;
} // two elements deleted
runTestCase(testcase); assert.sameValue(arr.reduceRight(callbackfn), "121", 'arr.reduceRight(callbackfn)');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.22-9-6
description: > description: >
Array.prototype.reduceRight visits deleted element in array after Array.prototype.reduceRight visits deleted element in array after
the call when same index is also present in prototype the call when same index is also present in prototype
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) function callbackfn(prevVal, curVal, idx, obj)
{ {
delete arr[1]; delete arr[1];
@ -22,8 +19,5 @@ function testcase() {
var res = arr.reduceRight(callbackfn); var res = arr.reduceRight(callbackfn);
delete Array.prototype[2]; delete Array.prototype[2];
if(res === "151" ) //one element deleted //one element deleted
return true; assert.sameValue(res, "151", 'res');
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.22-9-c-i-33
description: > description: >
Array.prototype.reduceRight - unnhandled exceptions happened in Array.prototype.reduceRight - unnhandled exceptions happened in
getter terminate iteration on an Array getter terminate iteration on an Array
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var accessed = false; var accessed = false;
function callbackfn(prevVal, curVal, idx, obj) { function callbackfn(prevVal, curVal, idx, obj) {
if (idx <= 1) { if (idx <= 1) {
@ -22,16 +19,13 @@ function testcase() {
Object.defineProperty(arr, "1", { Object.defineProperty(arr, "1", {
get: function () { get: function () {
throw new RangeError("unhandle exception happened in getter"); throw new Test262Error("unhandle exception happened in getter");
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
arr.reduceRight(callbackfn, "initialValue"); arr.reduceRight(callbackfn, "initialValue");
return true; });
} catch (ex) {
return (ex instanceof RangeError) && !accessed; assert.sameValue(accessed, false, 'accessed');
}
}
runTestCase(testcase);

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.22-9-c-ii-7
description: > description: >
Array.prototype.reduceRight - unhandled exceptions happened in Array.prototype.reduceRight - unhandled exceptions happened in
callbackfn terminate iteration callbackfn terminate iteration
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var accessed = false; var accessed = false;
function callbackfn(prevVal, curVal, idx, obj) { function callbackfn(prevVal, curVal, idx, obj) {
@ -18,17 +15,14 @@ function testcase() {
accessed = true; accessed = true;
} }
if (idx === 10) { if (idx === 10) {
throw new Error("Exception occurred in callbackfn"); throw new Test262Error("Exception occurred in callbackfn");
} }
} }
var obj = { 0: 11, 4: 10, 10: 8, length: 20 }; var obj = { 0: 11, 4: 10, 10: 8, length: 20 };
try { assert.throws(Test262Error, function() {
Array.prototype.reduceRight.call(obj, callbackfn, 1); Array.prototype.reduceRight.call(obj, callbackfn, 1);
return false; });
} catch (ex) {
return !accessed; assert.sameValue(accessed, false, 'accessed');
}
}
runTestCase(testcase);

View File

@ -6,25 +6,17 @@ es5id: 15.4.4.17-4-10
description: > description: >
Array.prototype.some - the exception is not thrown if exception Array.prototype.some - the exception is not thrown if exception
was thrown by step 2 was thrown by step 2
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 11, 1: 12 }; var obj = { 0: 11, 1: 12 };
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
throw new SyntaxError(); throw new Test262Error();
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.some.call(obj, undefined); Array.prototype.some.call(obj, undefined);
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -6,29 +6,21 @@ es5id: 15.4.4.17-4-11
description: > description: >
Array.prototype.some - the exception is not thrown if exception Array.prototype.some - the exception is not thrown if exception
was thrown by step 3 was thrown by step 3
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var obj = { 0: 11, 1: 12 }; var obj = { 0: 11, 1: 12 };
Object.defineProperty(obj, "length", { Object.defineProperty(obj, "length", {
get: function () { get: function () {
return { return {
toString: function () { toString: function () {
throw new SyntaxError(); throw new Test262Error();
} }
}; };
}, },
configurable: true configurable: true
}); });
try { assert.throws(Test262Error, function() {
Array.prototype.some.call(obj, undefined); Array.prototype.some.call(obj, undefined);
return false; });
} catch (ex) {
return !(ex instanceof TypeError);
}
}
runTestCase(testcase);

View File

@ -5,10 +5,9 @@
es5id: 15.4.4.17-5-1 es5id: 15.4.4.17-5-1
description: Array.prototype.some - thisArg is passed description: Array.prototype.some - thisArg is passed
flags: [noStrict] flags: [noStrict]
includes: [runTestCase.js]
---*/ ---*/
function testcase() { (function() {
this._15_4_4_17_5_1 = false; this._15_4_4_17_5_1 = false;
var _15_4_4_17_5_1 = true; var _15_4_4_17_5_1 = true;
@ -16,6 +15,6 @@ function testcase() {
return this._15_4_4_17_5_1; return this._15_4_4_17_5_1;
} }
var arr = [1]; var arr = [1];
return !arr.some(callbackfn);
} assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)');
runTestCase(testcase); })();

View File

@ -7,28 +7,21 @@ description: >
Date.prototype.toISOString - RangeError is not thrown when value Date.prototype.toISOString - RangeError is not thrown when value
of date is Date(1970, 0, -99999999, 0, 0, 0, 1), the time zone is of date is Date(1970, 0, -99999999, 0, 0, 0, 1), the time zone is
UTC(0) UTC(0)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var timeZoneMinutes = new Date().getTimezoneOffset() * (-1); var timeZoneMinutes = new Date().getTimezoneOffset() * (-1);
var date, dateStr; var date, dateStr;
if (timeZoneMinutes > 0) { if (timeZoneMinutes > 0) {
date = new Date(1970, 0, -99999999, 0, 0, 0, 1); date = new Date(1970, 0, -99999999, 0, 0, 0, 1);
try { assert.throws(RangeError, function() {
date.toISOString(); date.toISOString();
return false; });
} catch (e) {
return e instanceof RangeError;
}
} else { } else {
date = new Date(1970, 0, -99999999, 0, 0 + timeZoneMinutes + 60, 0, 1); date = new Date(1970, 0, -99999999, 0, 0 + timeZoneMinutes + 60, 0, 1);
dateStr = date.toISOString(); dateStr = date.toISOString();
return dateStr[dateStr.length - 1] === "Z"; assert.sameValue(dateStr[dateStr.length - 1], "Z");
} }
}
runTestCase(testcase);

View File

@ -7,24 +7,17 @@ description: >
Date.prototype.toISOString - RangeError is thrown when value of Date.prototype.toISOString - RangeError is thrown when value of
date is Date(1970, 0, 100000001, 0, 0, 0, 1), the time zone is date is Date(1970, 0, 100000001, 0, 0, 0, 1), the time zone is
UTC(0) UTC(0)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var timeZoneMinutes = new Date().getTimezoneOffset() * (-1); var timeZoneMinutes = new Date().getTimezoneOffset() * (-1);
var date, dateStr; var date, dateStr;
try {
assert.throws(RangeError, function() {
if (timeZoneMinutes > 0) { if (timeZoneMinutes > 0) {
date = new Date(1970, 0, 100000001, 0, 0 + timeZoneMinutes + 60, 0, 1); date = new Date(1970, 0, 100000001, 0, 0 + timeZoneMinutes + 60, 0, 1);
dateStr = date.toISOString(); dateStr = date.toISOString();
return false;
} else { } else {
date = new Date(1970, 0, 100000001, 0, 0, 0, 1); date = new Date(1970, 0, 100000001, 0, 0, 0, 1);
dateStr = date.toISOString(); dateStr = date.toISOString();
return false;
} }
} catch (e) { });
return e instanceof RangeError;
}
}
runTestCase(testcase);

View File

@ -7,28 +7,21 @@ description: >
Date.prototype.toISOString - RangeError is not thrown when value Date.prototype.toISOString - RangeError is not thrown when value
of date is Date(1970, 0, -99999999, 0, 0, 0, 0), the time zone is of date is Date(1970, 0, -99999999, 0, 0, 0, 0), the time zone is
UTC(0) UTC(0)
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
var timeZoneMinutes = new Date().getTimezoneOffset() * (-1); var timeZoneMinutes = new Date().getTimezoneOffset() * (-1);
var date, dateStr; var date, dateStr;
if (timeZoneMinutes > 0) { if (timeZoneMinutes > 0) {
date = new Date(1970, 0, -99999999, 0, 0, 0, 0); date = new Date(1970, 0, -99999999, 0, 0, 0, 0);
try { assert.throws(RangeError, function() {
date.toISOString(); date.toISOString();
return false; });
} catch (e) {
return e instanceof RangeError;
}
} else { } else {
date = new Date(1970, 0, -99999999, 0, 0 + timeZoneMinutes + 60, 0, 0); date = new Date(1970, 0, -99999999, 0, 0 + timeZoneMinutes + 60, 0, 0);
dateStr = date.toISOString(); dateStr = date.toISOString();
return dateStr[dateStr.length - 1] === "Z"; assert.sameValue(dateStr[dateStr.length - 1], "Z");
} }
}
runTestCase(testcase);

View File

@ -4,15 +4,8 @@
/*--- /*---
es5id: 15.11.4.3-1 es5id: 15.11.4.3-1
description: Error.prototype.message is not enumerable. description: Error.prototype.message is not enumerable.
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
for (var i in Error.prototype) { for (var i in Error.prototype) {
if (i==="message") { assert.notSameValue(i, "message", 'i');
return false;
}
} }
return true;
}
runTestCase(testcase);

View File

@ -4,15 +4,8 @@
/*--- /*---
es5id: 15.11.4.2-1 es5id: 15.11.4.2-1
description: Error.prototype.name is not enumerable. description: Error.prototype.name is not enumerable.
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
for (var i in Error.prototype) { for (var i in Error.prototype) {
if (i==="name") { assert.notSameValue(i, "name", 'i');
return false;
}
} }
return true;
}
runTestCase(testcase);

View File

@ -7,16 +7,6 @@ description: >
Duplicate seperate parameter name in Function constructor called Duplicate seperate parameter name in Function constructor called
from strict mode allowed if body not strict from strict mode allowed if body not strict
flags: [onlyStrict] flags: [onlyStrict]
includes: [runTestCase.js]
---*/ ---*/
function testcase()
{
try {
Function('a','a','return;'); Function('a','a','return;');
return true;
} catch (e) {
return false;
}
}
runTestCase(testcase);

View File

@ -8,16 +8,6 @@ description: >
named 'eval' does not throws SyntaxError if function body is not named 'eval' does not throws SyntaxError if function body is not
strict mode strict mode
flags: [onlyStrict] flags: [onlyStrict]
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
try {
Function('eval', 'return;'); Function('eval', 'return;');
return true;
} catch (e) {
return false;
}
}
runTestCase(testcase);

View File

@ -7,17 +7,6 @@ description: >
Duplicate combined parameter name allowed in Function constructor Duplicate combined parameter name allowed in Function constructor
called in strict mode if body not strict called in strict mode if body not strict
flags: [onlyStrict] flags: [onlyStrict]
includes: [runTestCase.js]
---*/ ---*/
function testcase()
{
try {
Function('a,a','return a;'); Function('a,a','return a;');
return true;
} catch (e) {
return false;
}
}
runTestCase(testcase);

View File

@ -8,16 +8,6 @@ description: >
named arguments does not throws SyntaxError if function body is named arguments does not throws SyntaxError if function body is
not strict mode not strict mode
flags: [onlyStrict] flags: [onlyStrict]
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
try {
Function('arguments', 'return;'); Function('arguments', 'return;');
return true;
} catch (e) {
return false;
}
}
runTestCase(testcase);

View File

@ -4,16 +4,8 @@
/*--- /*---
es5id: 15.3.4.5-2-16 es5id: 15.3.4.5-2-16
description: Function.prototype.bind - 'Target' is a function description: Function.prototype.bind - 'Target' is a function
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function testFunc() {} function testFunc() {}
try {
testFunc.bind(); testFunc.bind();
return true;
} catch (e) {
return false;
}
}
runTestCase(testcase);

View File

@ -6,17 +6,11 @@ es5id: 15.3.4.5-20-2
description: > description: >
Function.prototype.bind - [[Get]] attribute of 'caller' property Function.prototype.bind - [[Get]] attribute of 'caller' property
in 'F' is thrower in 'F' is thrower
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function foo() { } function foo() { }
var obj = foo.bind({}); var obj = foo.bind({});
try {
return obj.caller && false; assert.throws(TypeError, function() {
} catch (ex) { obj.caller;
return (ex instanceof TypeError); });
}
}
runTestCase(testcase);

View File

@ -6,17 +6,11 @@ es5id: 15.3.4.5-21-2
description: > description: >
Function.prototype.bind - [[Get]] attribute of 'arguments' Function.prototype.bind - [[Get]] attribute of 'arguments'
property in 'F' is thrower property in 'F' is thrower
includes: [runTestCase.js]
---*/ ---*/
function testcase() {
function foo() { } function foo() { }
var obj = foo.bind({}); var obj = foo.bind({});
try {
return obj.arguments && false; assert.throws(TypeError, function() {
} catch (ex) { obj.arguments;
return (ex instanceof TypeError); });
}
}
runTestCase(testcase);

View File

@ -4,16 +4,8 @@
/*--- /*---
es5id: 15.12.1.1-0-1 es5id: 15.12.1.1-0-1
description: The JSON lexical grammar treats whitespace as a token seperator description: The JSON lexical grammar treats whitespace as a token seperator
includes: [runTestCase.js]
---*/ ---*/
function testcase() { assert.throws(SyntaxError, function() {
try {
JSON.parse('12\t\r\n 34'); // should produce a syntax error as whitespace results in two tokens JSON.parse('12\t\r\n 34'); // should produce a syntax error as whitespace results in two tokens
} });
catch (e) {
if (e.name === 'SyntaxError') return true;
}
}
runTestCase(testcase);

View File

@ -6,16 +6,8 @@ es5id: 15.12.1.1-0-2
description: > description: >
<VT> is not valid JSON whitespace as specified by the production <VT> is not valid JSON whitespace as specified by the production
JSONWhitespace. JSONWhitespace.
includes: [runTestCase.js]
---*/ ---*/
function testcase() { assert.throws(SyntaxError, function() {
try {
JSON.parse('\u000b1234'); // should produce a syntax error JSON.parse('\u000b1234'); // should produce a syntax error
} });
catch (e) {
return true; // treat any exception as a pass, other tests ensure that JSON.parse throws SyntaxError exceptions
}
}
runTestCase(testcase);

View File

@ -6,16 +6,8 @@ es5id: 15.12.1.1-0-3
description: > description: >
<FF> is not valid JSON whitespace as specified by the production <FF> is not valid JSON whitespace as specified by the production
JSONWhitespace. JSONWhitespace.
includes: [runTestCase.js]
---*/ ---*/
function testcase() { assert.throws(SyntaxError, function() {
try {
JSON.parse('\u000c1234'); // should produce a syntax error JSON.parse('\u000c1234'); // should produce a syntax error
} });
catch (e) {
return true; // treat any exception as a pass, other tests ensure that JSON.parse throws SyntaxError exceptions
}
}
runTestCase(testcase);

View File

@ -6,16 +6,8 @@ es5id: 15.12.1.1-0-4
description: > description: >
<NBSP> is not valid JSON whitespace as specified by the production <NBSP> is not valid JSON whitespace as specified by the production
JSONWhitespace. JSONWhitespace.
includes: [runTestCase.js]
---*/ ---*/
function testcase() { assert.throws(SyntaxError, function() {
try {
JSON.parse('\u00a01234'); // should produce a syntax error JSON.parse('\u00a01234'); // should produce a syntax error
} });
catch (e) {
return true; // treat any exception as a pass, other tests ensure that JSON.parse throws SyntaxError exceptions
}
}
runTestCase(testcase);

View File

@ -6,16 +6,8 @@ es5id: 15.12.1.1-0-5
description: > description: >
<ZWSPP> is not valid JSON whitespace as specified by the <ZWSPP> is not valid JSON whitespace as specified by the
production JSONWhitespace. production JSONWhitespace.
includes: [runTestCase.js]
---*/ ---*/
function testcase() { assert.throws(SyntaxError, function() {
try {
JSON.parse('\u200b1234'); // should produce a syntax error JSON.parse('\u200b1234'); // should produce a syntax error
} });
catch (e) {
return true; // treat any exception as a pass, other tests ensure that JSON.parse throws SyntaxError exceptions
}
}
runTestCase(testcase);

View File

@ -6,16 +6,8 @@ es5id: 15.12.1.1-0-6
description: > description: >
<BOM> is not valid JSON whitespace as specified by the production <BOM> is not valid JSON whitespace as specified by the production
JSONWhitespace. JSONWhitespace.
includes: [runTestCase.js]
---*/ ---*/
function testcase() { assert.throws(SyntaxError, function() {
try {
JSON.parse('\ufeff1234'); // should produce a syntax error a JSON.parse('\ufeff1234'); // should produce a syntax error a
} });
catch (e) {
return true; // treat any exception as a pass, other tests ensure that JSON.parse throws SyntaxError exceptions
}
}
runTestCase(testcase);

View File

@ -6,17 +6,9 @@ es5id: 15.12.1.1-0-7
description: > description: >
other category z spaces are not valid JSON whitespace as specified other category z spaces are not valid JSON whitespace as specified
by the production JSONWhitespace. by the production JSONWhitespace.
includes: [runTestCase.js]
---*/ ---*/
function testcase() { assert.throws(SyntaxError, function() {
try {
// the following should produce a syntax error // the following should produce a syntax error
JSON.parse('\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u30001234'); JSON.parse('\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u30001234');
} });
catch (e) {
return true; // treat any exception as a pass, other tests ensure that JSON.parse throws SyntaxError exceptions
}
}
runTestCase(testcase);

View File

@ -6,16 +6,8 @@ es5id: 15.12.1.1-0-8
description: > description: >
U+2028 and U+2029 are not valid JSON whitespace as specified by U+2028 and U+2029 are not valid JSON whitespace as specified by
the production JSONWhitespace. the production JSONWhitespace.
includes: [runTestCase.js]
---*/ ---*/
function testcase() { assert.throws(SyntaxError, function() {
try {
JSON.parse('\u2028\u20291234'); // should produce a syntax error JSON.parse('\u2028\u20291234'); // should produce a syntax error
} });
catch (e) {
return true; // treat any exception as a pass, other tests ensure that JSON.parse throws SyntaxError exceptions
}
}
runTestCase(testcase);

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