-- v3: jscript: Fix Array.reduce when last element doesn't exist. jscript: Fix Array.map when last element doesn't exist.
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/array.c | 6 ++++-- dlls/mshtml/tests/es5.js | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c index 48f665da576..c673b82fed2 100644 --- a/dlls/jscript/array.c +++ b/dlls/jscript/array.c @@ -1354,14 +1354,16 @@ static HRESULT Array_map(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned if(argc > 1) context_this = argv[1];
- hres = create_array(ctx, length, &array); + hres = create_array(ctx, 0, &array); if(FAILED(hres)) goto done;
for(k = 0; k < length; k++) { hres = jsdisp_get_idx(jsthis, k, &callback_args[0]); - if(hres == DISP_E_UNKNOWNNAME) + if(hres == DISP_E_UNKNOWNNAME) { + hres = S_OK; continue; + } if(FAILED(hres)) break;
diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index 7e2f66daabf..fbcb1b42f3e 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -431,6 +431,13 @@ sync_test("array_map", function() { [1,2].map(function() { ok(this.valueOf() === 137, "this.valueOf() = " + this.valueOf()); }, 137); + + r = [1,,2,].map(function(x) { return "" + x; }); + ok(r.length === 3, "[1,,2,].map length = " + r.length); + ok(r[0] === "1", "[1,,2,].map[0] = " + r[0]); + ok(r[2] === "2", "[1,,2,].map[2] = " + r[2]); + ok(!("1" in r), "[1,,2,].map[1] exists"); + ok(!("3" in r), "[1,,2,].map[3] exists"); });
sync_test("array_sort", function() {
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/array.c | 4 +++- dlls/mshtml/tests/es5.js | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c index c673b82fed2..36f45120055 100644 --- a/dlls/jscript/array.c +++ b/dlls/jscript/array.c @@ -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;
diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index fbcb1b42f3e..b6ce7be3c54 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -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");
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=138867
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/jscript/array.c:1422 error: patch failed: dlls/mshtml/tests/es5.js:1336 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/jscript/array.c:1422 error: patch failed: dlls/mshtml/tests/es5.js:1336 Task: Patch failed to apply
=== debian11b (build log) ===
error: patch failed: dlls/jscript/array.c:1422 error: patch failed: dlls/mshtml/tests/es5.js:1336 Task: Patch failed to apply
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=138867
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/jscript/array.c:1422 error: patch failed: dlls/mshtml/tests/es5.js:1336 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/jscript/array.c:1422 error: patch failed: dlls/mshtml/tests/es5.js:1336 Task: Patch failed to apply
=== debian11b (build log) ===
error: patch failed: dlls/jscript/array.c:1422 error: patch failed: dlls/mshtml/tests/es5.js:1336 Task: Patch failed to apply
This merge request was approved by Jacek Caban.