1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:58:12 +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

@ -50,6 +50,13 @@ function assertThrowsError(testFunction, options) {
}
}
const assertVisitsAll = (testFunction, expectedOutput) => {
const visited = [];
testFunction(value => visited.push(value));
assert(visited.length === expectedOutput.length);
expectedOutput.forEach((value, i) => assert(visited[i] === value));
};
/**
* Check whether the difference between two numbers is less than 0.000001.
* @param {Number} a First number