1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 19:05:08 +00:00

LibJS: Implement basic for..in and for..of loops

This commit is contained in:
Linus Groh 2020-04-21 19:21:26 +01:00 committed by Andreas Kling
parent c378a1c730
commit 07af2e6b2c
8 changed files with 372 additions and 90 deletions

View file

@ -0,0 +1,41 @@
load("test-common.js");
try {
assertVisitsAll(visit => {
for (const property in "") {
visit(property);
}
}, []);
assertVisitsAll(visit => {
for (const property in 123) {
visit(property);
}
}, []);
assertVisitsAll(visit => {
for (const property in {}) {
visit(property);
}
}, []);
assertVisitsAll(visit => {
for (const property in "hello") {
visit(property);
}
}, ["0", "1", "2", "3", "4"]);
assertVisitsAll(visit => {
for (const property in {a: 1, b: 2, c: 2}) {
visit(property);
}
}, ["a", "b", "c"]);
var property;
for (property in "abc");
assert(property === "2");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}