From 46e43f4bde4a35785b4997b81e86cd19f046b69b Mon Sep 17 00:00:00 2001 From: Minteck Date: Tue, 21 Dec 2021 16:52:28 +0100 Subject: Commit --- src/node_modules/is-nan/test/tests.js | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/node_modules/is-nan/test/tests.js (limited to 'src/node_modules/is-nan/test/tests.js') diff --git a/src/node_modules/is-nan/test/tests.js b/src/node_modules/is-nan/test/tests.js new file mode 100644 index 0000000..cd6a500 --- /dev/null +++ b/src/node_modules/is-nan/test/tests.js @@ -0,0 +1,40 @@ +'use strict'; + +module.exports = function (numberIsNaN, t) { + t.test('not NaN', function (st) { + st.test('primitives', function (sst) { + sst.notOk(numberIsNaN(), 'undefined is not NaN'); + sst.notOk(numberIsNaN(null), 'null is not NaN'); + sst.notOk(numberIsNaN(false), 'false is not NaN'); + sst.notOk(numberIsNaN(true), 'true is not NaN'); + sst.notOk(numberIsNaN(0), 'positive zero is not NaN'); + sst.notOk(numberIsNaN(Infinity), 'Infinity is not NaN'); + sst.notOk(numberIsNaN(-Infinity), '-Infinity is not NaN'); + sst.notOk(numberIsNaN('foo'), 'string is not NaN'); + sst.notOk(numberIsNaN('NaN'), 'string NaN is not NaN'); + sst.end(); + }); + + st.notOk(numberIsNaN([]), 'array is not NaN'); + st.notOk(numberIsNaN({}), 'object is not NaN'); + st.notOk(numberIsNaN(function () {}), 'function is not NaN'); + + st.test('valueOf', function (vt) { + var obj = { + valueOf: function () { + return NaN; + } + }; + vt.ok(numberIsNaN(Number(obj)), 'object with valueOf of NaN, converted to Number, is NaN'); + vt.notOk(numberIsNaN(obj), 'object with valueOf of NaN is not NaN'); + vt.end(); + }); + + st.end(); + }); + + t.test('NaN literal', function (st) { + st.ok(numberIsNaN(NaN), 'NaN is NaN'); + st.end(); + }); +}; -- cgit