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
description: Testing Array.from when passed a String
author: Hank Yates (hankyates@gmail.com)
includes: [runTestCase.js]
---*/
runTestCase(function () {
var arrLikeSource = 'testValue',
testArr = Array.from(arrLikeSource);
if (testArr.length != 9) {
return false;
}
return true;
});
assert.sameValue(testArr.length, 9);

View File

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

View File

@ -5,16 +5,8 @@
es6id: 22.1.2.1_T3
description: Testing Array.from when passed an undefined
author: Hank Yates (hankyates@gmail.com)
includes: [runTestCase.js]
---*/
runTestCase(function () {
try {
assert.throws(TypeError, function() {
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: >
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);
});

View File

@ -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);
});

View File

@ -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');

View File

@ -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);
});

View File

@ -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);
});

View File

@ -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');
})();

View File

@ -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]');

View File

@ -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]');

View File

@ -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]');

View File

@ -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]');

View File

@ -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');

View File

@ -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);
});

View File

@ -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);
});

View File

@ -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');
})();

View File

@ -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())');

View File

@ -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)');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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)');

View File

@ -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)');

View File

@ -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');

View File

@ -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.');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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);

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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)');

View File

@ -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)');

View File

@ -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');

View File

@ -4,17 +4,11 @@
/*---
es5id: 15.4.4.15-8-1
description: Array.prototype.lastIndexOf must return correct index(boolean)
includes: [runTestCase.js]
---*/
function testcase() {
var obj = {toString:function (){return true}};
var _false = false;
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
{
return true;
}
}
runTestCase(testcase);
assert.sameValue(a.lastIndexOf(true), 5, 'a[5]=true');
assert.sameValue(a.lastIndexOf(false), 4, 'a[4] =_false');

View File

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

View File

@ -4,20 +4,14 @@
/*---
es5id: 15.4.4.15-8-2
description: Array.prototype.lastIndexOf 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(+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
a.lastIndexOf(-0) ===3 && // a[3] = -0
a.lastIndexOf(1) === 14 ) // a[14] = 1
{
return true;
}
}
runTestCase(testcase);
assert.sameValue(a.lastIndexOf(-(4/3)), 10, 'a[10]=-(4/3)');
assert.sameValue(a.lastIndexOf(0), 3, 'a[3] = -0, but using === -0 and 0 are equal');
assert.sameValue(a.lastIndexOf(-0), 3, 'a[3] = -0');
assert.sameValue(a.lastIndexOf(1), 14, 'a[14] = 1');

View File

@ -7,17 +7,14 @@ description: >
Array.prototype.lastIndexOf applied to Arguments object which
implements its own property get method (number of arguments is
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) {
return 2 === Array.prototype.lastIndexOf.call(arguments, arguments[0]) &&
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);
(function() {
func(0, arguments, 0, Object.prototype);
})();

View File

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

View File

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

View File

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

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.19-8-c-iii-5
description: >
Array.prototype.map - 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.map.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]');

View File

@ -6,25 +6,17 @@ es5id: 15.4.4.21-4-10
description: >
Array.prototype.reduce - 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.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: >
Array.prototype.reduce - 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.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: >
Array.prototype.reduce - the exception is not thrown if exception
was thrown by step 2
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (curVal > 10);
}
@ -19,16 +16,11 @@ function testcase() {
Object.defineProperty(obj, "length", {
get: function () {
throw new SyntaxError();
throw new Test262Error();
},
configurable: true
});
try {
assert.throws(Test262Error, function() {
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: >
Array.prototype.reduce - the exception is not thrown if exception
was thrown by step 3
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (curVal > 10);
}
@ -21,19 +18,13 @@ function testcase() {
get: function () {
return {
toString: function () {
throw new SyntaxError();
throw new Test262Error();
}
};
},
configurable: true
});
try {
assert.throws(Test262Error, function() {
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
description: Array.prototype.reduce - no observable effects occur if 'len' is 0
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
var obj = { length: 0 };
@ -21,11 +18,8 @@ function testcase() {
configurable: true
});
try {
assert.throws(TypeError, function() {
Array.prototype.reduce.call(obj, function () { });
return false;
} catch (ex) {
return !accessed;
}
}
runTestCase(testcase);
});
assert.sameValue(accessed, false, 'accessed');

View File

@ -6,25 +6,17 @@ es5id: 15.4.4.21-8-c-7
description: >
Array.prototype.reduce - the exception is not thrown if exception
was thrown by step 2
includes: [runTestCase.js]
---*/
function testcase() {
var obj = {};
Object.defineProperty(obj, "length", {
get: function () {
throw new SyntaxError();
throw new Test262Error();
},
configurable: true
});
try {
assert.throws(Test262Error, 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: >
Array.prototype.reduce - the exception is not thrown if exception
was thrown by step 3
includes: [runTestCase.js]
---*/
function testcase() {
var obj = {};
Object.defineProperty(obj, "length", {
get: function () {
return {
toString: function () {
throw new SyntaxError();
throw new Test262Error();
}
};
},
configurable: true
});
try {
assert.throws(Test262Error, 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: >
Array.prototype.reduce doesn't visit deleted elements in array
after the call
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj)
{
delete arr[3];
@ -19,8 +16,6 @@ function testcase() {
}
var arr = ['1',2,3,4,5];
if(arr.reduce(callbackfn) === "123" ) // two elements deleted
return true;
}
runTestCase(testcase);
// two elements deleted
assert.sameValue(arr.reduce(callbackfn), "123", 'arr.reduce(callbackfn)');

View File

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

View File

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

View File

@ -6,25 +6,17 @@ es5id: 15.4.4.22-8-c-7
description: >
Array.prototype.reduceRight - the exception is not thrown if
exception was thrown by step 2
includes: [runTestCase.js]
---*/
function testcase() {
var obj = {};
Object.defineProperty(obj, "length", {
get: function () {
throw new SyntaxError();
throw new Test262Error();
},
configurable: true
});
try {
assert.throws(Test262Error, 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: >
Array.prototype.reduceRight - the exception is not thrown if
exception was thrown by step 3
includes: [runTestCase.js]
---*/
function testcase() {
var obj = {};
Object.defineProperty(obj, "length", {
get: function () {
return {
toString: function () {
throw new SyntaxError();
throw new Test262Error();
}
};
},
configurable: true
});
try {
assert.throws(Test262Error, 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: >
Array.prototype.reduceRight doesn't consider unvisited deleted
elements in array after the call
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj)
{
delete arr[1];
@ -19,8 +16,6 @@ function testcase() {
}
var arr = ['1',2,3,4,5];
if(arr.reduceRight(callbackfn) === "121" ) // two elements deleted
return true;
}
runTestCase(testcase);
// two elements deleted
assert.sameValue(arr.reduceRight(callbackfn), "121", 'arr.reduceRight(callbackfn)');

View File

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

View File

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

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.22-9-c-ii-7
description: >
Array.prototype.reduceRight - unhandled exceptions happened in
callbackfn terminate iteration
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
function callbackfn(prevVal, curVal, idx, obj) {
@ -18,17 +15,14 @@ function testcase() {
accessed = true;
}
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 };
try {
assert.throws(Test262Error, function() {
Array.prototype.reduceRight.call(obj, callbackfn, 1);
return false;
} catch (ex) {
return !accessed;
}
}
runTestCase(testcase);
});
assert.sameValue(accessed, false, 'accessed');

View File

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

View File

@ -7,28 +7,21 @@ description: >
Date.prototype.toISOString - RangeError is not thrown when value
of date is Date(1970, 0, -99999999, 0, 0, 0, 1), the time zone is
UTC(0)
includes: [runTestCase.js]
---*/
function testcase() {
var timeZoneMinutes = new Date().getTimezoneOffset() * (-1);
var date, dateStr;
if (timeZoneMinutes > 0) {
date = new Date(1970, 0, -99999999, 0, 0, 0, 1);
try {
assert.throws(RangeError, function() {
date.toISOString();
return false;
} catch (e) {
return e instanceof RangeError;
}
});
} else {
date = new Date(1970, 0, -99999999, 0, 0 + timeZoneMinutes + 60, 0, 1);
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 is Date(1970, 0, 100000001, 0, 0, 0, 1), the time zone is
UTC(0)
includes: [runTestCase.js]
---*/
function testcase() {
var timeZoneMinutes = new Date().getTimezoneOffset() * (-1);
var date, dateStr;
try {
assert.throws(RangeError, function() {
if (timeZoneMinutes > 0) {
date = new Date(1970, 0, 100000001, 0, 0 + timeZoneMinutes + 60, 0, 1);
dateStr = date.toISOString();
return false;
} else {
date = new Date(1970, 0, 100000001, 0, 0, 0, 1);
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
of date is Date(1970, 0, -99999999, 0, 0, 0, 0), the time zone is
UTC(0)
includes: [runTestCase.js]
---*/
function testcase() {
var timeZoneMinutes = new Date().getTimezoneOffset() * (-1);
var date, dateStr;
if (timeZoneMinutes > 0) {
date = new Date(1970, 0, -99999999, 0, 0, 0, 0);
try {
assert.throws(RangeError, function() {
date.toISOString();
return false;
} catch (e) {
return e instanceof RangeError;
}
});
} else {
date = new Date(1970, 0, -99999999, 0, 0 + timeZoneMinutes + 60, 0, 0);
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
description: Error.prototype.message is not enumerable.
includes: [runTestCase.js]
---*/
function testcase() {
for (var i in Error.prototype) {
if (i==="message") {
return false;
assert.notSameValue(i, "message", 'i');
}
}
return true;
}
runTestCase(testcase);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,16 +4,8 @@
/*---
es5id: 15.12.1.1-0-1
description: The JSON lexical grammar treats whitespace as a token seperator
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(SyntaxError, function() {
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: >
<VT> is not valid JSON whitespace as specified by the production
JSONWhitespace.
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(SyntaxError, function() {
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: >
<FF> is not valid JSON whitespace as specified by the production
JSONWhitespace.
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(SyntaxError, function() {
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: >
<NBSP> is not valid JSON whitespace as specified by the production
JSONWhitespace.
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(SyntaxError, function() {
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: >
<ZWSPP> is not valid JSON whitespace as specified by the
production JSONWhitespace.
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(SyntaxError, function() {
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: >
<BOM> is not valid JSON whitespace as specified by the production
JSONWhitespace.
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(SyntaxError, function() {
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: >
other category z spaces are not valid JSON whitespace as specified
by the production JSONWhitespace.
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(SyntaxError, function() {
// 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');
}
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: >
U+2028 and U+2029 are not valid JSON whitespace as specified by
the production JSONWhitespace.
includes: [runTestCase.js]
---*/
function testcase() {
try {
assert.throws(SyntaxError, function() {
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