]> git.kaiwu.me - quickjs.git/commitdiff
added tests for Array iterator length property access
authorFabrice Bellard <fabrice@bellard.org>
Sat, 7 Nov 2026 13:07:01 +0000 (14:07 +0100)
committerFabrice Bellard <fabrice@bellard.org>
Sat, 7 Nov 2026 13:07:01 +0000 (14:07 +0100)
tests/test_builtin.js

index d0e1691480b9b957f06231d25410083805496a73..7fcc4bd34d8c3dfe550edd0979608c89d57aee75 100644 (file)
@@ -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;