From: Fabrice Bellard Date: Sat, 7 Nov 2026 13:07:01 +0000 (+0100) Subject: added tests for Array iterator length property access X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=3134fbd403d205e61350b9c384fd0c8a222f34a0;p=quickjs.git added tests for Array iterator length property access --- diff --git a/tests/test_builtin.js b/tests/test_builtin.js index d0e1691..7fcc4bd 100644 --- a/tests/test_builtin.js +++ b/tests/test_builtin.js @@ -244,6 +244,7 @@ function test_array() assert(a.toString(), ",,,,,,,,,,2"); test_array_extension(); + test_array_iterator(); } function test_array_extension() @@ -269,6 +270,17 @@ function test_array_extension() assert(o.length, 3); } +function test_array_iterator() +{ + var n = 0; + for (var x of Array.prototype.values.call({ length: -1, 0: "a" })) { if (++n > 3) break; } + assert(n, 0); + + n = 0; + for (var k of Array.prototype.keys.call({ length: 2 ** 32 + 1 })) { if (++n > 5) break; } + assert(n, 6); +} + function test_string() { var a;