Fix Array.prototype.reduce and reduceRight (#3487)
Don't throw TypeError when object length is 0 and initialValue is undefined. Additionally the error message should be more precise and match other engines. Fixes #3463 JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
This commit is contained in:
committed by
Robert Fancsik
parent
40b38f70ef
commit
9e0709e401
@@ -34,14 +34,6 @@ try {
|
||||
assert(e instanceof TypeError);
|
||||
}
|
||||
|
||||
try {
|
||||
var arg2;
|
||||
[].reduceRight(func, arg2);
|
||||
assert(false);
|
||||
} catch(e) {
|
||||
assert(e instanceof TypeError);
|
||||
}
|
||||
|
||||
try {
|
||||
var a = new Array();
|
||||
a.length = 10;
|
||||
@@ -54,6 +46,8 @@ try {
|
||||
// various checks
|
||||
assert([].reduceRight(func, 1) === 1);
|
||||
|
||||
assert([].reduceRight(func, undefined) === undefined);
|
||||
|
||||
assert([0].reduceRight(func) === 0);
|
||||
|
||||
assert([0, 1].reduceRight(func) === 1);
|
||||
|
||||
@@ -39,6 +39,8 @@ catch(e) {
|
||||
// various checks
|
||||
assert ([].reduce(func, 1) === 1);
|
||||
|
||||
assert ([].reduce(func, undefined) === undefined);
|
||||
|
||||
assert ([0].reduce(func) === 0);
|
||||
|
||||
assert ([0, 1].reduce(func) === 1);
|
||||
|
||||
Reference in New Issue
Block a user