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:
parent
d1bc1f5783
commit
199a6b40b3
4 changed files with 88 additions and 0 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue