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

This commit is contained in:
André Bargull 2015-08-06 18:18:58 +02:00
parent 976a687b27
commit df43797c70
159 changed files with 291 additions and 978 deletions

View File

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

View File

@ -4,12 +4,6 @@
/*---
es5id: 15.4.4.21-0-2
description: Array.prototype.reduce.length must be 1
includes: [runTestCase.js]
---*/
function testcase() {
if (Array.prototype.reduce.length === 1) {
return true;
}
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.length, 1, 'Array.prototype.reduce.length');

View File

@ -4,10 +4,8 @@
/*---
es5id: 15.4.4.21-1-11
description: Array.prototype.reduce applied to Date object
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return obj instanceof Date;
}
@ -16,6 +14,4 @@ function testcase() {
obj.length = 1;
obj[0] = 1;
return Array.prototype.reduce.call(obj, callbackfn, 1);
}
runTestCase(testcase);
assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true');

View File

@ -4,10 +4,8 @@
/*---
es5id: 15.4.4.21-1-12
description: Array.prototype.reduce applied to RegExp object
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return obj instanceof RegExp;
}
@ -16,6 +14,4 @@ function testcase() {
obj.length = 1;
obj[0] = 1;
return Array.prototype.reduce.call(obj, callbackfn, 1);
}
runTestCase(testcase);
assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true');

View File

@ -4,10 +4,8 @@
/*---
es5id: 15.4.4.21-1-14
description: Array.prototype.reduce applied to Error object
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return obj instanceof Error;
}
@ -16,6 +14,4 @@ function testcase() {
obj.length = 1;
obj[0] = 1;
return Array.prototype.reduce.call(obj, callbackfn, 1);
}
runTestCase(testcase);
assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true');

View File

@ -4,11 +4,8 @@
/*---
es5id: 15.4.4.21-1-15
description: Array.prototype.reduce applied to the Arguments object
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return ('[object Arguments]' === Object.prototype.toString.call(obj));
}
@ -17,6 +14,4 @@ function testcase() {
return arguments;
}("a", "b"));
return Array.prototype.reduce.call(obj, callbackfn, 1);
}
runTestCase(testcase);
assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true');

View File

@ -4,10 +4,8 @@
/*---
es5id: 15.4.4.21-1-4
description: Array.prototype.reduce applied to Boolean object
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return obj instanceof Boolean;
}
@ -17,6 +15,4 @@ function testcase() {
obj[0] = 11;
obj[1] = 12;
return Array.prototype.reduce.call(obj, callbackfn, 1);
}
runTestCase(testcase);
assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true');

View File

@ -4,10 +4,8 @@
/*---
es5id: 15.4.4.21-1-6
description: Array.prototype.reduce applied to Number object
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return obj instanceof Number;
}
@ -16,6 +14,5 @@ function testcase() {
obj.length = 2;
obj[0] = 11;
obj[1] = 12;
return Array.prototype.reduce.call(obj, callbackfn, 1);
}
runTestCase(testcase);
assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true');

View File

@ -4,15 +4,10 @@
/*---
es5id: 15.4.4.21-1-7
description: Array.prototype.reduce applied to string primitive
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return obj instanceof String;
}
return Array.prototype.reduce.call("abc", callbackfn, 1);
}
runTestCase(testcase);
assert(Array.prototype.reduce.call("abc", callbackfn, 1), 'Array.prototype.reduce.call("abc", callbackfn, 1) !== true');

View File

@ -4,17 +4,12 @@
/*---
es5id: 15.4.4.21-1-8
description: Array.prototype.reduce applied to String object
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return obj instanceof String;
}
var obj = new String("abc");
return Array.prototype.reduce.call(obj, callbackfn, 1);
}
runTestCase(testcase);
assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true');

View File

@ -4,10 +4,8 @@
/*---
es5id: 15.4.4.21-1-9
description: Array.prototype.reduce applied to Function object
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return obj instanceof Function;
}
@ -18,6 +16,4 @@ function testcase() {
obj[0] = 11;
obj[1] = 9;
return Array.prototype.reduce.call(obj, callbackfn, 1);
}
runTestCase(testcase);
assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true');

View File

@ -6,25 +6,17 @@ es5id: 15.4.4.21-10-1
description: >
Array.prototype.reduce doesn't mutate the Array on which it is
called on
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj)
{
return 1;
}
var srcArr = [1,2,3,4,5];
srcArr.reduce(callbackfn);
if(srcArr[0] === 1 &&
srcArr[1] === 2 &&
srcArr[2] === 3 &&
srcArr[3] === 4 &&
srcArr[4] === 5)
{
return true;
}
}
runTestCase(testcase);
assert.sameValue(srcArr[0], 1, 'srcArr[0]');
assert.sameValue(srcArr[1], 2, 'srcArr[1]');
assert.sameValue(srcArr[2], 3, 'srcArr[2]');
assert.sameValue(srcArr[3], 4, 'srcArr[3]');
assert.sameValue(srcArr[4], 5, 'srcArr[4]');

View File

@ -6,20 +6,12 @@ es5id: 15.4.4.21-10-2
description: >
Array.prototype.reduce reduces the array in ascending order of
indices
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj)
{
return prevVal + curVal;
}
var srcArr = ['1','2','3','4','5'];
if(srcArr.reduce(callbackfn) === '12345')
{
return true;
}
}
runTestCase(testcase);
assert.sameValue(srcArr.reduce(callbackfn), '12345', 'srcArr.reduce(callbackfn)');

View File

@ -4,16 +4,12 @@
/*---
es5id: 15.4.4.21-10-3
description: Array.prototype.reduce - subclassed array of length 1
includes: [runTestCase.js]
---*/
function testcase() {
foo.prototype = [1];
function foo() {}
var f = new foo();
function cb(){}
if(f.reduce(cb) === 1)
return true;
}
runTestCase(testcase);
assert.sameValue(f.reduce(cb), 1, 'f.reduce(cb)');

View File

@ -4,16 +4,12 @@
/*---
es5id: 15.4.4.21-10-4
description: Array.prototype.reduce - subclassed array with length more than 1
includes: [runTestCase.js]
---*/
function testcase() {
foo.prototype = new Array(1, 2, 3, 4);
function foo() {}
var f = new foo();
function cb(prevVal, curVal, idx, obj){return prevVal + curVal;}
if(f.reduce(cb) === 10)
return true;
}
runTestCase(testcase);
assert.sameValue(f.reduce(cb), 10, 'f.reduce(cb)');

View File

@ -6,20 +6,12 @@ es5id: 15.4.4.21-10-5
description: >
Array.prototype.reduce reduces the array in ascending order of
indices(initialvalue present)
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj)
{
return prevVal + curVal;
}
var srcArr = ['1','2','3','4','5'];
if(srcArr.reduce(callbackfn,'0') === '012345')
{
return true;
}
}
runTestCase(testcase);
assert.sameValue(srcArr.reduce(callbackfn,'0'), '012345', 'srcArr.reduce(callbackfn,"0")');

View File

@ -6,16 +6,12 @@ es5id: 15.4.4.21-10-6
description: >
Array.prototype.reduce - subclassed array when initialvalue
provided
includes: [runTestCase.js]
---*/
function testcase() {
foo.prototype = [1,2,3,4];
function foo() {}
var f = new foo();
function cb(prevVal, curVal, idx, obj){return prevVal + curVal;}
if(f.reduce(cb,-1) === 9)
return true;
}
runTestCase(testcase);
assert.sameValue(f.reduce(cb,-1), 9, 'f.reduce(cb,-1)');

View File

@ -6,16 +6,12 @@ es5id: 15.4.4.21-10-7
description: >
Array.prototype.reduce - subclassed array with length 1 and
initialvalue provided
includes: [runTestCase.js]
---*/
function testcase() {
foo.prototype = [1];
function foo() {}
var f = new foo();
function cb(prevVal, curVal, idx, obj){return prevVal + curVal;}
if(f.reduce(cb,-1) === 0)
return true;
}
runTestCase(testcase);
assert.sameValue(f.reduce(cb,-1), 0, 'f.reduce(cb,-1)');

View File

@ -4,11 +4,8 @@
/*---
es5id: 15.4.4.21-10-8
description: Array.prototype.reduce doesn't visit expandos
includes: [runTestCase.js]
---*/
function testcase() {
var callCnt = 0;
function callbackfn(prevVal, curVal, idx, obj)
{
@ -20,10 +17,4 @@ function testcase() {
srcArr[true] = 11;
srcArr.reduce(callbackfn);
if(callCnt == 4)
{
return true;
}
}
runTestCase(testcase);
assert.sameValue(callCnt, 4, 'callCnt');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-2-1
description: >
Array.prototype.reduce - 'length' is own data property on an
Array-like object
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (obj.length === 2);
}
@ -22,6 +19,4 @@ function testcase() {
length: 2
};
return Array.prototype.reduce.call(obj, callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-2-10
description: >
Array.prototype.reduce applied to Array-like object, 'length' is
an inherited accessor property
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (obj.length === 2);
}
@ -32,6 +29,4 @@ function testcase() {
child[1] = 11;
child[2] = 9;
return Array.prototype.reduce.call(child, callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), true, 'Array.prototype.reduce.call(child, callbackfn, 1)');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-2-11
description: >
Array.prototype.reduce applied to Array-like object, 'length' is
an own accessor property without a get function
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
function callbackfn(prevVal, curVal, idx, obj) {
accessed = true;
@ -25,6 +22,5 @@ function testcase() {
configurable: true
});
return Array.prototype.reduce.call(obj, callbackfn, 1) === 1 && !accessed;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
assert.sameValue(accessed, false, 'accessed');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-2-13
description: >
Array.prototype.reduce applied to Array-like object that 'length'
is inherited accessor property without a get function
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
function callbackfn(prevVal, curVal, idx, obj) {
@ -30,6 +27,5 @@ function testcase() {
child[0] = 11;
child[1] = 12;
return Array.prototype.reduce.call(child, callbackfn, 1) === 1 && !accessed;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), 1, 'Array.prototype.reduce.call(child, callbackfn, 1)');
assert.sameValue(accessed, false, 'accessed');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-2-14
description: >
Array.prototype.reduce applied to the Array-like object that
'length' property doesn't exist
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
function callbackfn(prevVal, curVal, idx, obj) {
@ -19,7 +16,5 @@ function testcase() {
var obj = { 0: 11, 1: 12 };
return Array.prototype.reduce.call(obj, callbackfn, 1) === 1 && !accessed;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
assert.sameValue(accessed, false, 'accessed');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-2-17
description: >
Array.prototype.reduce applied to the Arguments object, which
implements its own property get method
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (obj.length === 2);
}
@ -20,6 +17,4 @@ function testcase() {
return Array.prototype.reduce.call(arguments, callbackfn, 1);
};
return func(12, 11) === true;
}
runTestCase(testcase);
assert.sameValue(func(12, 11), true, 'func(12, 11)');

View File

@ -6,17 +6,12 @@ es5id: 15.4.4.21-2-18
description: >
Array.prototype.reduce applied to String object, which implements
its own property get method
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (obj.length === 3);
}
var str = new String("012");
return Array.prototype.reduce.call(str, callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(str, callbackfn, 1), true, 'Array.prototype.reduce.call(str, callbackfn, 1)');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-2-19
description: >
Array.prototype.reduce applied to Function object, which
implements its own property get method
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (obj.length === 2);
}
@ -22,6 +19,4 @@ function testcase() {
fun[1] = 11;
fun[2] = 9;
return Array.prototype.reduce.call(fun, callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(fun, callbackfn, 1), true, 'Array.prototype.reduce.call(fun, callbackfn, 1)');

View File

@ -4,15 +4,10 @@
/*---
es5id: 15.4.4.21-2-2
description: Array.prototype.reduce - 'length' is own data property on an Array
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (obj.length === 2);
}
return [12, 11].reduce(callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue([12, 11].reduce(callbackfn, 1), true, '[12, 11].reduce(callbackfn, 1)');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-2-3
description: >
Array.prototype.reduce - 'length' is an own data property that
overrides an inherited data property on an Array-like object
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (obj.length === 2);
}
@ -26,6 +23,4 @@ function testcase() {
child[1] = 11;
child[2] = 9;
return Array.prototype.reduce.call(child, callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), true, 'Array.prototype.reduce.call(child, callbackfn, 1)');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-2-5
description: >
Array.prototype.reduce applied to Array-like object, 'length' is
an own data property that overrides an inherited accessor property
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (obj.length === 2);
}
@ -36,6 +33,4 @@ function testcase() {
child[1] = 11;
child[2] = 9;
return Array.prototype.reduce.call(child, callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), true, 'Array.prototype.reduce.call(child, callbackfn, 1)');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-2-6
description: >
Array.prototype.reduce applied to Array-like object, 'length' is
an inherited data property
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (obj.length === 2);
}
@ -25,6 +22,4 @@ function testcase() {
child[1] = 11;
child[2] = 9;
return Array.prototype.reduce.call(child, callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), true, 'Array.prototype.reduce.call(child, callbackfn, 1)');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-2-7
description: >
Array.prototype.reduce applied to Array-like object, 'length' is
an own accessor property
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (obj.length === 2);
}
@ -28,6 +25,4 @@ function testcase() {
obj[1] = 11;
obj[2] = 9;
return Array.prototype.reduce.call(obj, callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-2-8
description: >
Array.prototype.reduce applied to Array-like object, 'length' is
an own accessor property that overrides an inherited data property
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (obj.length === 2);
}
@ -33,6 +30,4 @@ function testcase() {
child[1] = 11;
child[2] = 9;
return Array.prototype.reduce.call(child, callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), true, 'Array.prototype.reduce.call(child, callbackfn, 1)');

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.reduce applied to Array-like object, 'length' is
an own accessor property that overrides an inherited accessor
property
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (obj.length === 2);
}
@ -41,6 +38,4 @@ function testcase() {
child[1] = 11;
child[2] = 9;
return Array.prototype.reduce.call(child, callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), true, 'Array.prototype.reduce.call(child, callbackfn, 1)');

View File

@ -4,11 +4,8 @@
/*---
es5id: 15.4.4.21-3-1
description: Array.prototype.reduce - value of 'length' is undefined
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
function callbackfn(prevVal, curVal, idx, obj) {
@ -18,6 +15,5 @@ function testcase() {
var obj = { 0: 0, 1: 1, length: undefined };
return Array.prototype.reduce.call(obj, callbackfn, 1) === 1 && !accessed;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
assert.sameValue(accessed, false, 'accessed');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-3-10
description: >
Array.prototype.reduce - value of 'length' is number primitive
(value is NaN)
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
function callbackfn(prevVal, curVal, idx, obj) {
@ -20,6 +17,5 @@ function testcase() {
var obj = { 0: 9, length: NaN };
return Array.prototype.reduce.call(obj, callbackfn, 1) === 1 && !accessed;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
assert.sameValue(accessed, false, 'accessed');

View File

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

View File

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

View File

@ -6,17 +6,12 @@ es5id: 15.4.4.21-3-13
description: >
Array.prototype.reduce - 'length' is a string containing a decimal
number
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (curVal === 11 && idx === 1);
}
var obj = { 1: 11, 2: 9, length: "2.5" };
return Array.prototype.reduce.call(obj, callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');

View File

@ -4,11 +4,8 @@
/*---
es5id: 15.4.4.21-3-14
description: Array.prototype.reduce - 'length' is a string containing -Infinity
includes: [runTestCase.js]
---*/
function testcase() {
var accessed2 = false;
function callbackfn2(prevVal, curVal, idx, obj) {
@ -18,7 +15,5 @@ function testcase() {
var obj2 = { 0: 9, length: "-Infinity" };
return Array.prototype.reduce.call(obj2, callbackfn2, 1) === 1
&& !accessed2;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj2, callbackfn2, 1), 1, 'Array.prototype.reduce.call(obj2, callbackfn2, 1)');
assert.sameValue(accessed2, false, 'accessed2');

View File

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

View File

@ -6,17 +6,12 @@ es5id: 15.4.4.21-3-16
description: >
Array.prototype.reduce - 'length' is a string containing a hex
number
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (curVal === 11 && idx === 1);
}
var obj = { 1: 11, 2: 9, length: "0x0002" };
return Array.prototype.reduce.call(obj, callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');

View File

@ -6,17 +6,12 @@ es5id: 15.4.4.21-3-17
description: >
Array.prototype.reduce - 'length' is a string containing a number
with leading zeros
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (curVal === 11 && idx === 1);
}
var obj = { 1: 11, 2: 9, length: "0002.00" };
return Array.prototype.reduce.call(obj, callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-3-18
description: >
Array.prototype.reduce - value of 'length' is a string that can't
convert to a number
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
function callbackfn(prevVal, curVal, idx, obj) {
accessed = true;
@ -19,6 +16,5 @@ function testcase() {
var obj = { 0: 9, length: "asdf!_" };
return Array.prototype.reduce.call(obj, callbackfn, 1) === 1 && !accessed;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
assert.sameValue(accessed, false, 'accessed');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-3-19
description: >
Array.prototype.reduce - value of 'length' is an Object which has
an own toString method
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (curVal === 11 && idx === 1);
}
@ -25,6 +22,4 @@ function testcase() {
}
};
return Array.prototype.reduce.call(obj, callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');

View File

@ -6,18 +6,12 @@ es5id: 15.4.4.21-3-2
description: >
Array.prototype.reduce - value of 'length' is a boolean (value is
true)
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (curVal === 11 && idx === 0);
}
var obj = { 0: 11, 1: 9, length: true };
return Array.prototype.reduce.call(obj, callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-3-20
description: >
Array.prototype.reduce - value of 'length' is an object which has
an own valueOf method
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (curVal === 11 && idx === 1);
}
@ -25,6 +22,4 @@ function testcase() {
}
};
return Array.prototype.reduce.call(obj, callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');

View File

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

View File

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

View File

@ -6,10 +6,8 @@ es5id: 15.4.4.21-3-24
description: >
Array.prototype.reduce - value of 'length' is a positive
non-integer, ensure truncation occurs in the proper direction
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (curVal === 11 && idx === 1);
}
@ -20,6 +18,4 @@ function testcase() {
length: 2.685
};
return Array.prototype.reduce.call(obj, callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-3-25
description: >
Array.prototype.reduce - value of 'length' is a negative
non-integer
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (curVal === 11 && idx === 1);
}
@ -21,6 +18,4 @@ function testcase() {
length: -4294967294.5
};
return Array.prototype.reduce.call(obj, callbackfn, 1) === 1;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');

View File

@ -4,11 +4,8 @@
/*---
es5id: 15.4.4.21-3-3
description: Array.prototype.reduce - value of 'length' is a number (value is 0)
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
function callbackfn(prevVal, curVal, idx, obj) {
@ -18,6 +15,5 @@ function testcase() {
var obj = { 0: 1, 1: 1, length: 0 };
return Array.prototype.reduce.call(obj, callbackfn, 1) === 1 && !accessed;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
assert.sameValue(accessed, false, 'accessed');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-3-4
description: >
Array.prototype.reduce - value of 'length' is a number (value is
+0)
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
function callbackfn(prevVal, curVal, idx, obj) {
@ -20,6 +17,5 @@ function testcase() {
var obj = { 0: 11, length: +0 };
return Array.prototype.reduce.call(obj, callbackfn, 1) === 1 && !accessed;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
assert.sameValue(accessed, false, 'accessed');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-3-5
description: >
Array.prototype.reduce - value of 'length' is a number (value is
-0)
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
function callbackfn(prevVal, curVal, idx, obj) {
@ -20,6 +17,5 @@ function testcase() {
var obj = { 0: 11, length: -0 };
return Array.prototype.reduce.call(obj, callbackfn, 1) === 1 && !accessed;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
assert.sameValue(accessed, false, 'accessed');

View File

@ -6,17 +6,12 @@ es5id: 15.4.4.21-3-6
description: >
Array.prototype.reduce - value of 'length' is a number (value is
positive)
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (curVal === 11 && idx === 1);
}
var obj = { 1: 11, 2: 9, length: 2 };
return Array.prototype.reduce.call(obj, callbackfn, 1) === true;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');

View File

@ -6,17 +6,12 @@ es5id: 15.4.4.21-3-7
description: >
Array.prototype.reduce - value of 'length' is a number (value is
negative)
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return (curVal === 11 && idx === 1);
}
var obj = { 1: 11, 2: 9, length: -4294967294 };
return Array.prototype.reduce.call(obj, callbackfn, 1) === 1;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-3-9
description: >
Array.prototype.reduce - value of 'length' is a number (value is
-Infinity)
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
function callbackfn(prevVal, curVal, idx, obj) {
@ -19,6 +16,5 @@ function testcase() {
var obj = { 0: 9, length: -Infinity };
return Array.prototype.reduce.call(obj, callbackfn, 1) === 1 && !accessed;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
assert.sameValue(accessed, false, 'accessed');

View File

@ -4,17 +4,13 @@
/*---
es5id: 15.4.4.21-4-12
description: Array.prototype.reduce - 'callbackfn' is a function
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
function callbackfn(prevVal, curVal, idx, obj) {
accessed = true;
return curVal > 10;
}
return [11, 9].reduce(callbackfn, 1) === false && accessed;
}
runTestCase(testcase);
assert.sameValue([11, 9].reduce(callbackfn, 1), false, '[11, 9].reduce(callbackfn, 1)');
assert(accessed, 'accessed !== true');

View File

@ -6,16 +6,12 @@ es5id: 15.4.4.21-5-9
description: >
Array.prototype.reduce - 'initialValue' is returned if 'len' is 0
and 'initialValue' is present
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
function callbackfn(prevVal, curVal, idx, obj) {
accessed = true;
}
return [].reduce(callbackfn, 3) === 3 && !accessed;
}
runTestCase(testcase);
assert.sameValue([].reduce(callbackfn, 3), 3, '[].reduce(callbackfn, 3)');
assert.sameValue(accessed, false, 'accessed');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-8-b-2
description: >
Array.prototype.reduce - modifications to length don't change
number of iterations in step 9
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
return idx;
}
@ -25,6 +22,4 @@ function testcase() {
configurable: true
});
return Array.prototype.reduce.call(obj, callbackfn) === 3;
}
runTestCase(testcase);
assert.sameValue(Array.prototype.reduce.call(obj, callbackfn), 3, 'Array.prototype.reduce.call(obj, callbackfn)');

View File

@ -4,11 +4,8 @@
/*---
es5id: 15.4.4.21-8-b-3
description: Array.prototype.reduce - loop is broken once 'kPresent' is true
includes: [runTestCase.js]
---*/
function testcase() {
var called = 0;
var testResult = false;
var firstCalled = 0;
@ -40,6 +37,7 @@ function testcase() {
});
arr.reduce(callbackfn);
return testResult && firstCalled === 1 && secondCalled === 1;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');
assert.sameValue(firstCalled, 1, 'firstCalled');
assert.sameValue(secondCalled, 1, 'secondCalled');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-8-b-iii-1-1
description: >
Array.prototype.reduce - element to be retrieved is own data
property on an Array-like object
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
if (idx === 1) {
@ -20,6 +17,5 @@ function testcase() {
var obj = { 0: 0, 1: 1, 2: 2, length: 2 };
Array.prototype.reduce.call(obj, callbackfn);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -6,10 +6,8 @@ es5id: 15.4.4.21-8-b-iii-1-10
description: >
Array.prototype.reduce - when element to be retrieved is own
accessor property on an Array
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
@ -28,6 +26,5 @@ function testcase() {
});
arr.reduce(callbackfn);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.reduce - element to be retrieved is own accessor
property that overrides an inherited data property on an
Array-like object
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
if (idx === 1) {
@ -35,6 +32,5 @@ function testcase() {
});
Array.prototype.reduce.call(child, callbackfn);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -7,10 +7,8 @@ description: >
Array.prototype.reduce - element to be retrieved is own accessor
property that overrides an inherited accessor property on an
Array-like object
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
@ -42,6 +40,5 @@ function testcase() {
});
Array.prototype.reduce.call(child, callbackfn);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-8-b-iii-1-15
description: >
Array.prototype.reduce - element to be retrieved is inherited
accessor property on an Array-like object
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
if (idx === 1) {
@ -34,6 +31,5 @@ function testcase() {
child.length = 3;
Array.prototype.reduce.call(child, callbackfn);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-8-b-iii-1-17
description: >
Array.prototype.reduce - element to be retrieved is own accessor
property without a get function on an Array-like object
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
if (idx === 1) {
@ -26,6 +23,5 @@ function testcase() {
});
Array.prototype.reduce.call(obj, callbackfn);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-8-b-iii-1-18
description: >
Array.prototype.reduce - element to be retrieved is own accessor
property without a get function on an Array
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
if (idx === 1) {
@ -26,6 +23,5 @@ function testcase() {
});
arr.reduce(callbackfn);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-8-b-iii-1-2
description: >
Array.prototype.reduce - element to be retrieved is own data
property on an Array
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
if (idx === 1) {
@ -20,6 +17,5 @@ function testcase() {
var arr = [0, 1, 2];
arr.reduce(callbackfn);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-8-b-iii-1-21
description: >
Array.prototype.reduce - element to be retrieved is inherited
accessor property without a get function on an Array-like object
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
if (idx === 1) {
@ -32,6 +29,5 @@ function testcase() {
child.length = 3;
Array.prototype.reduce.call(child, callbackfn);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.reduce - This object is the Arguments object which
implements its own property get method (number of arguments is
less than number of parameters)
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
if (idx === 1) {
@ -24,6 +21,5 @@ function testcase() {
};
func(0, 1);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.reduce - This object is the Arguments object which
implements its own property get method (number of arguments equals
number of parameters)
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
if (idx === 2) {
@ -25,6 +22,5 @@ function testcase() {
};
func(0, 1, 2);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.reduce - This object is the Arguments object which
implements its own property get method (number of arguments is
greater than number of parameters)
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
if (idx === 3) {
@ -26,6 +23,5 @@ function testcase() {
};
func(0, 1, 2, 3);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-8-b-iii-1-28
description: >
Array.prototype.reduce - applied to String object, which
implements its own property get method
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
if (idx === 1) {
@ -20,7 +17,5 @@ function testcase() {
var str = new String("012");
Array.prototype.reduce.call(str, callbackfn);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-8-b-iii-1-29
description: >
Array.prototype.reduce - applied to Function object which
implements its own property get method
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
if (idx === 1) {
@ -27,7 +24,5 @@ function testcase() {
obj[3] = 3;
Array.prototype.reduce.call(obj, callbackfn);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.reduce - element to be retrieved is own data
property that overrides an inherited data property on an
Array-like object
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
if (idx === 1) {
@ -29,7 +26,5 @@ function testcase() {
child.length = 3;
Array.prototype.reduce.call(child, callbackfn);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-8-b-iii-1-30
description: >
Array.prototype.reduce - element changed by getter on current
iterations is observed in subsequent iterations on an Array
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
if (idx === 1) {
@ -41,6 +38,5 @@ function testcase() {
});
arr.reduce(callbackfn);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.reduce - element changed by getter on current
iterations is observed in subsequent iterations on an Array-like
object
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
if (idx === 1) {
@ -42,7 +39,5 @@ function testcase() {
});
Array.prototype.reduce.call(obj, callbackfn);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.reduce - element to be retrieved is own data
property that overrides an inherited accessor property on an
Array-like object
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
if (idx === 1) {
@ -40,6 +37,5 @@ function testcase() {
child[1] = "1";
Array.prototype.reduce.call(child, callbackfn);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-8-b-iii-1-7
description: >
Array.prototype.reduce - element to be retrieved is inherited data
property on an Array-like object
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
if (idx === 1) {
@ -26,6 +23,5 @@ function testcase() {
child.length = 3;
Array.prototype.reduce.call(child, callbackfn);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-8-b-iii-1-9
description: >
Array.prototype.reduce - element to be retrieved is own accessor
property on an Array-like object
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(prevVal, curVal, idx, obj) {
if (idx === 1) {
@ -27,6 +24,5 @@ function testcase() {
});
Array.prototype.reduce.call(obj, callbackfn);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -6,10 +6,8 @@ es5id: 15.4.4.21-9-1
description: >
Array.prototype.reduce doesn't consider new elements added to
array after it is called
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
arr[5] = 6;
arr[2] = 3;
@ -17,6 +15,5 @@ function testcase() {
}
var arr = [1, 2, , 4, '5'];
return arr.reduce(callbackfn) === "105";
}
runTestCase(testcase);
assert.sameValue(arr.reduce(callbackfn), "105", 'arr.reduce(callbackfn)');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-9-10
description: >
Array.prototype.reduce called with an initial value doesn't
consider new elements added to array after it is called
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
arr[5] = 6;
arr[2] = 3;
@ -18,6 +15,5 @@ function testcase() {
}
var arr = [1,2,,4,'5'];
return arr.reduce(callbackfn, "") === "12345";
}
runTestCase(testcase);
assert.sameValue(arr.reduce(callbackfn, ""), "12345", 'arr.reduce(callbackfn, "")');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-9-2
description: >
Array.prototype.reduce considers new value of elements in array
after it is called
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj)
{
arr[3] = -2;
@ -19,8 +16,5 @@ function testcase() {
}
var arr = [1,2,3,4,5];
if(arr.reduce(callbackfn) === 3)
return true;
}
runTestCase(testcase);
assert.sameValue(arr.reduce(callbackfn), 3, 'arr.reduce(callbackfn)');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-9-4
description: >
Array.prototype.reduce doesn't visit deleted elements when
Array.length is decreased
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj)
{
arr.length = 2;
@ -18,8 +15,5 @@ function testcase() {
}
var arr = [1,2,3,4,5];
if(arr.reduce(callbackfn) === 3 )
return true;
}
runTestCase(testcase);
assert.sameValue(arr.reduce(callbackfn), 3, 'arr.reduce(callbackfn)');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-9-5
description: >
Array.prototype.reduce - callbackfn not called for array with one
element
includes: [runTestCase.js]
---*/
function testcase() {
var callCnt = 0;
function callbackfn(prevVal, curVal, idx, obj)
{
@ -19,7 +16,6 @@ function testcase() {
}
var arr = [1];
if(arr.reduce(callbackfn) === 1 && callCnt === 0 )
return true;
}
runTestCase(testcase);
assert.sameValue(arr.reduce(callbackfn), 1, 'arr.reduce(callbackfn)');
assert.sameValue(callCnt, 0, 'callCnt');

View File

@ -6,10 +6,8 @@ es5id: 15.4.4.21-9-7
description: >
Array.prototype.reduce stops calling callbackfn once the array is
deleted during the call
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj) {
delete o.arr;
return prevVal + curVal;
@ -17,6 +15,6 @@ function testcase() {
var o = new Object();
o.arr = ['1', 2, 3, 4, 5];
return o.arr.reduce(callbackfn) === "12345" && !o.hasOwnProperty("arr");
}
runTestCase(testcase);
assert.sameValue(o.arr.reduce(callbackfn), "12345", 'o.arr.reduce(callbackfn)');
assert.sameValue(o.hasOwnProperty("arr"), false, 'o.hasOwnProperty("arr")');

View File

@ -4,11 +4,8 @@
/*---
es5id: 15.4.4.21-9-8
description: Array.prototype.reduce - no observable effects occur if 'len' is 0
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
var callbackAccessed = false;
function callbackfn() {
@ -26,6 +23,6 @@ function testcase() {
});
Array.prototype.reduce.call(obj, function () { }, "initialValue");
return !accessed && !callbackAccessed;
}
runTestCase(testcase);
assert.sameValue(accessed, false, 'accessed');
assert.sameValue(callbackAccessed, false, 'callbackAccessed');

View File

@ -6,10 +6,8 @@ es5id: 15.4.4.21-9-9
description: >
Array.prototype.reduce - modifications to length don't change
number of iterations in step 9
includes: [runTestCase.js]
---*/
function testcase() {
var called = 0;
function callbackfn(accum, val, idx, obj) {
called++;
@ -27,6 +25,5 @@ function testcase() {
var newAccum = arr.reduce(callbackfn, "initialValue");
return newAccum === "initialValue01" && called === 2;
}
runTestCase(testcase);
assert.sameValue(newAccum, "initialValue01", 'newAccum');
assert.sameValue(called, 2, 'called');

View File

@ -6,19 +6,12 @@ es5id: 15.4.4.21-9-b-1
description: >
Array.prototype.reduce returns initialvalue when Array is empty
and initialValue is present
includes: [runTestCase.js]
---*/
function testcase() {
function callbackfn(prevVal, curVal, idx, obj)
{
}
var arr = new Array(10);
if(arr.reduce(callbackfn,5) === 5)
return true;
}
runTestCase(testcase);
assert.sameValue(arr.reduce(callbackfn,5), 5, 'arr.reduce(callbackfn,5)');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-9-b-14
description: >
Array.prototype.reduce - decreasing length of array in step 8
causes deleted index property not to be visited
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
var testResult = true;
@ -33,6 +30,5 @@ function testcase() {
arr.reduce(callbackfn);
return testResult && accessed;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');
assert(accessed, 'accessed !== true');

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.reduce - decreasing length of array in step 8 does
not delete non-configurable properties
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(accum, val, idx, obj) {
@ -39,6 +36,4 @@ function testcase() {
arr.reduce(callbackfn);
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-9-b-17
description: >
Array.prototype.reduce - properties added into own object are
visited on an Array-like object
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(accum, val, idx, obj) {
@ -35,6 +32,5 @@ function testcase() {
});
Array.prototype.reduce.call(obj, callbackfn, "initialValue");
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-9-b-18
description: >
Array.prototype.reduce - properties added into own object are
visited on an Array
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(accum, val, idx, obj) {
@ -35,6 +32,5 @@ function testcase() {
});
arr.reduce(callbackfn, "initialValue");
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-9-b-2
description: >
Array.prototype.reduce - added properties in step 2 are visible
here
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(accum, val, idx, obj) {
@ -31,6 +28,4 @@ function testcase() {
Array.prototype.reduce.call(obj, callbackfn, "initialValue");
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-9-b-21
description: >
Array.prototype.reduce - deleting own property causes deleted
index property not to be visited on an Array-like object
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
var testResult = true;
@ -39,6 +36,6 @@ function testcase() {
});
Array.prototype.reduce.call(obj, callbackfn, "initialValue");
return testResult && accessed;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');
assert(accessed, 'accessed !== true');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-9-b-22
description: >
Array.prototype.reduce - deleting own property causes deleted
index property not to be visited on an Array
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
var testResult = true;
@ -39,6 +36,6 @@ function testcase() {
});
arr.reduce(callbackfn, "initialValue");
return testResult && accessed;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');
assert(accessed, 'accessed !== true');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-9-b-27
description: >
Array.prototype.reduce - decreasing length of array causes deleted
index property not to be visited
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
var testResult = true;
@ -33,6 +30,5 @@ function testcase() {
arr.reduce(callbackfn, "initialValue");
return testResult && accessed;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');
assert(accessed, 'accessed !== true');

View File

@ -7,11 +7,8 @@ description: >
Array.prototype.reduce - decreasing length of array does not
delete non-configurable properties
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
var testResult = false;
function callbackfn(accum, val, idx, obj) {
@ -39,6 +36,4 @@ function testcase() {
arr.reduce(callbackfn, "initialValue");
return testResult;
}
runTestCase(testcase);
assert(testResult, 'testResult !== true');

View File

@ -6,11 +6,8 @@ es5id: 15.4.4.21-9-b-3
description: >
Array.prototype.reduce - deleted properties in step 2 are visible
here
includes: [runTestCase.js]
---*/
function testcase() {
var accessed = false;
var testResult = true;
@ -33,6 +30,5 @@ function testcase() {
Array.prototype.reduce.call(obj, callbackfn, "initialValue");
return accessed && testResult;
}
runTestCase(testcase);
assert(accessed, 'accessed !== true');
assert(testResult, 'testResult !== true');

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