summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests/test-common.js
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-04-21 19:21:26 +0100
committerAndreas Kling <kling@serenityos.org>2020-05-25 18:45:36 +0200
commit07af2e6b2cf2dd0f6bd94e8918f5a1894d83633b (patch)
tree90592a51ce54d94d1e6ae149754501d17eaed5a9 /Libraries/LibJS/Tests/test-common.js
parentc378a1c730c998dc7f69571a3123a633010d2a3a (diff)
downloadserenity-07af2e6b2cf2dd0f6bd94e8918f5a1894d83633b.zip
LibJS: Implement basic for..in and for..of loops
Diffstat (limited to 'Libraries/LibJS/Tests/test-common.js')
-rw-r--r--Libraries/LibJS/Tests/test-common.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/test-common.js b/Libraries/LibJS/Tests/test-common.js
index a31cc67a62..7be49e77bb 100644
--- a/Libraries/LibJS/Tests/test-common.js
+++ b/Libraries/LibJS/Tests/test-common.js
@@ -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