summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-05-08 16:32:56 +0100
committerAndreas Kling <kling@serenityos.org>2020-05-08 20:06:49 +0200
commite333b600646fddb3e10cff44830b29cc8c90c406 (patch)
tree3f3a22c1ec826d598b85de3d99e6c5e90f45567c /Libraries/LibJS/Tests
parentca22476d9d641fc5a3def0e7de2237e8eb79015a (diff)
downloadserenity-e333b600646fddb3e10cff44830b29cc8c90c406.zip
LibJS: Add Array.of()
Diffstat (limited to 'Libraries/LibJS/Tests')
-rw-r--r--Libraries/LibJS/Tests/Array.of.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/Array.of.js b/Libraries/LibJS/Tests/Array.of.js
new file mode 100644
index 0000000000..1fb4200847
--- /dev/null
+++ b/Libraries/LibJS/Tests/Array.of.js
@@ -0,0 +1,37 @@
+load("test-common.js");
+
+try {
+ assert(Array.of.length === 0);
+
+ assert(typeof Array.of() === "object");
+
+ var a;
+
+ a = Array.of(5);
+ assert(a.length === 1);
+ assert(a[0] === 5);
+
+ a = Array.of("5");
+ assert(a.length === 1);
+ assert(a[0] === "5");
+
+ a = Array.of(Infinity);
+ assert(a.length === 1);
+ assert(a[0] === Infinity);
+
+ a = Array.of(1, 2, 3);
+ assert(a.length === 3);
+ assert(a[0] === 1);
+ assert(a[1] === 2);
+ assert(a[2] === 3);
+
+ a = Array.of([1, 2, 3]);
+ assert(a.length === 1);
+ assert(a[0][0] === 1);
+ assert(a[0][1] === 2);
+ assert(a[0][2] === 3);
+
+ console.log("PASS");
+} catch (e) {
+ console.log("FAIL: " + e);
+}