Commit ed674d63 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

jscript: Fix Array.reduce when last element doesn't exist.

parent 40b36d42
......@@ -1422,8 +1422,10 @@ static HRESULT Array_reduce(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsign
for(k = 0; k < length; k++) {
hres = jsdisp_get_idx(jsthis, k, &callback_args[1]);
if(hres == DISP_E_UNKNOWNNAME)
if(hres == DISP_E_UNKNOWNNAME) {
hres = S_OK;
continue;
}
if(FAILED(hres))
break;
......
......@@ -1336,6 +1336,9 @@ sync_test("reduce", function() {
r = [1,2,3].reduce(function(a, value) { return a + value; }, "str");
ok(r === "str123", "reduce() returned " + r);
r = [1,2,].reduce(function(a, value) { return a + value; }, "str");
ok(r === "str12", "reduce() returned " + r);
array = [1,2,3];
r = array.reduce(function(a, value, index, src) {
ok(src === array, "src != array");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment