summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests/test-common.js
diff options
context:
space:
mode:
authorAngel <angel@ttm.sh>2020-05-26 20:31:22 +0200
committerAndreas Kling <kling@serenityos.org>2020-05-26 20:34:44 +0200
commit199a6b40b3e7ae997d6ecfde6276c86cc2a1dd30 (patch)
tree036ceeb78c37490f1aa6c269393019e60f3a2bdc /Libraries/LibJS/Tests/test-common.js
parentd1bc1f5783f31a9339c192e889a24ccd82813b4f (diff)
downloadserenity-199a6b40b3e7ae997d6ecfde6276c86cc2a1dd30.zip
LibJS: Add Array.prototype.fill
Diffstat (limited to 'Libraries/LibJS/Tests/test-common.js')
-rw-r--r--Libraries/LibJS/Tests/test-common.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/test-common.js b/Libraries/LibJS/Tests/test-common.js
index 7be49e77bb..0a14352b97 100644
--- a/Libraries/LibJS/Tests/test-common.js
+++ b/Libraries/LibJS/Tests/test-common.js
@@ -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));