1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:27:44 +00:00

LibJS: Add Array.prototype.fill

This commit is contained in:
Angel 2020-05-26 20:31:22 +02:00 committed by Andreas Kling
parent d1bc1f5783
commit 199a6b40b3
4 changed files with 88 additions and 0 deletions

View file

@ -50,6 +50,21 @@ function assertThrowsError(testFunction, options) {
}
}
/**
* Ensures the provided arrays contain exactly the same items.
* @param {Array} a First array
* @param {Array} b Second array
*/
function assertArrayEquals(a, b) {
if (a.length != b.length)
throw new AssertionError("Array lengths do not match");
for (var i = 0; i < a.length; i++) {
if (a[i] !== b[i])
throw new AssertionError("Elements do not match");
}
}
const assertVisitsAll = (testFunction, expectedOutput) => {
const visited = [];
testFunction(value => visited.push(value));