summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests/Math.pow.js
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-04-23 12:36:08 +0100
committerAndreas Kling <kling@serenityos.org>2020-04-23 19:38:13 +0200
commit97366f4dd435c7906ab363d695d85fd7bb56aa96 (patch)
tree83842ca883473a4c1d512fcad3545376cb08e6fb /Libraries/LibJS/Tests/Math.pow.js
parent687096cadd0bf77da0d1dad6a3e0d8c5dbbf1812 (diff)
downloadserenity-97366f4dd435c7906ab363d695d85fd7bb56aa96.zip
LibJS: Add Math.pow()
Diffstat (limited to 'Libraries/LibJS/Tests/Math.pow.js')
-rw-r--r--Libraries/LibJS/Tests/Math.pow.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/Math.pow.js b/Libraries/LibJS/Tests/Math.pow.js
new file mode 100644
index 0000000000..b4e7670a1c
--- /dev/null
+++ b/Libraries/LibJS/Tests/Math.pow.js
@@ -0,0 +1,29 @@
+load("test-common.js");
+
+try {
+ assert(Math.pow(2, 0) === 1);
+ assert(Math.pow(2, 1) === 2);
+ assert(Math.pow(2, 2) === 4);
+ assert(Math.pow(2, 3) === 8);
+ assert(Math.pow(2, -3) === 0.125);
+ assert(Math.pow(3, 2) === 9);
+ assert(Math.pow(0, 0) === 1);
+ assert(Math.pow(2, Math.pow(3, 2)) === 512);
+ assert(Math.pow(Math.pow(2, 3), 2) === 64);
+ assert(Math.pow("2", "3") === 8);
+ assert(Math.pow("", []) === 1);
+ assert(Math.pow([], null) === 1);
+ assert(Math.pow(null, null) === 1);
+ assert(Math.pow(undefined, null) === 1);
+ assert(isNaN(Math.pow(NaN, 2)));
+ assert(isNaN(Math.pow(2, NaN)));
+ assert(isNaN(Math.pow(undefined, 2)));
+ assert(isNaN(Math.pow(2, undefined)));
+ assert(isNaN(Math.pow(null, undefined)));
+ assert(isNaN(Math.pow(2, "foo")));
+ assert(isNaN(Math.pow("foo", 2)));
+
+ console.log("PASS");
+} catch (e) {
+ console.log("FAIL: " + e);
+}