summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests/isNaN.js
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-04-22 18:05:22 +0100
committerAndreas Kling <kling@serenityos.org>2020-04-23 11:03:42 +0200
commit8ff2881b1a1aaf2225c90751b8880564e1bd9125 (patch)
tree295054fcf8b2926d09180ee79532651aa1d0f31b /Libraries/LibJS/Tests/isNaN.js
parent602a36970fb265b6297a68a92a0d35c8eaede63c (diff)
downloadserenity-8ff2881b1a1aaf2225c90751b8880564e1bd9125.zip
LibJS: Let isNaN() with no argument return true, add tests
Diffstat (limited to 'Libraries/LibJS/Tests/isNaN.js')
-rw-r--r--Libraries/LibJS/Tests/isNaN.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/isNaN.js b/Libraries/LibJS/Tests/isNaN.js
new file mode 100644
index 0000000000..7519b68fd2
--- /dev/null
+++ b/Libraries/LibJS/Tests/isNaN.js
@@ -0,0 +1,28 @@
+load("test-common.js");
+
+try {
+ assert(isNaN.length === 1);
+
+ assert(isNaN(0) === false);
+ assert(isNaN(42) === false);
+ assert(isNaN("") === false);
+ assert(isNaN("0") === false);
+ assert(isNaN("42") === false);
+ assert(isNaN(true) === false);
+ assert(isNaN(false) === false);
+ assert(isNaN(null) === false);
+ assert(isNaN([]) === false);
+ assert(isNaN(Infinity) === false);
+ assert(isNaN(-Infinity) === false);
+
+ assert(isNaN() === true);
+ assert(isNaN(NaN) === true);
+ assert(isNaN(undefined) === true);
+ assert(isNaN("foo") === true);
+ assert(isNaN({}) === true);
+ assert(isNaN([1, 2, 3]) === true);
+
+ console.log("PASS");
+} catch (e) {
+ console.log("FAIL: " + e.message);
+}