summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-05-08 16:28:35 +0100
committerAndreas Kling <kling@serenityos.org>2020-05-08 20:06:49 +0200
commitca22476d9d641fc5a3def0e7de2237e8eb79015a (patch)
treef0aefa2fd6be38920f3ae912ba82a88d041b03d5 /Libraries/LibJS/Tests
parent01fd6ce04582e9714d592a3bcb9825792cca81dc (diff)
downloadserenity-ca22476d9d641fc5a3def0e7de2237e8eb79015a.zip
LibJS: Add Array.isArray()
Diffstat (limited to 'Libraries/LibJS/Tests')
-rw-r--r--Libraries/LibJS/Tests/Array.isArray.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/Array.isArray.js b/Libraries/LibJS/Tests/Array.isArray.js
new file mode 100644
index 0000000000..714f6e08ea
--- /dev/null
+++ b/Libraries/LibJS/Tests/Array.isArray.js
@@ -0,0 +1,28 @@
+load("test-common.js");
+
+try {
+ assert(Array.isArray.length === 1);
+
+ assert(Array.isArray() === false);
+ assert(Array.isArray("1") === false);
+ assert(Array.isArray("foo") === false);
+ assert(Array.isArray(1) === false);
+ assert(Array.isArray(1, 2, 3) === false);
+ assert(Array.isArray(undefined) === false);
+ assert(Array.isArray(null) === false);
+ assert(Array.isArray(Infinity) === false);
+ assert(Array.isArray({}) === false);
+
+ assert(Array.isArray([]) === true);
+ assert(Array.isArray([1]) === true);
+ assert(Array.isArray([1, 2, 3]) === true);
+ assert(Array.isArray(new Array()) === true);
+ assert(Array.isArray(new Array(10)) === true);
+ assert(Array.isArray(new Array("a", "b", "c")) === true);
+ // FIXME: Array.prototype is supposed to be an array!
+ // assert(Array.isArray(Array.prototype) === true);
+
+ console.log("PASS");
+} catch (e) {
+ console.log("FAIL: " + e);
+}