Fix undefined initialValue handling in Array.prototype.reduce and reduceRight function.

JerryScript-DCO-1.0-Signed-off-by: Kristof Kosztyo kkosztyo.u-szeged@partner.samsung.com
This commit is contained in:
Kristof Kosztyo
2015-08-13 15:33:36 +02:00
parent 5bb56643aa
commit 9ffa6a39d3
4 changed files with 42 additions and 18 deletions
+10
View File
@@ -61,3 +61,13 @@ assert (long_array.reduce(func,10) === 11);
long_array[10000] = 1;
assert (long_array.reduce(func,10) === 12);
var accessed = false;
function callbackfn(prevVal, curVal, idx, obj) {
accessed = true;
return typeof prevVal === "undefined";
}
var obj = { 0: 11, length: 1 };
assert (Array.prototype.reduce.call(obj, callbackfn, undefined) === true && accessed);