1
0
mirror of https://github.com/MikeMcl/decimal.js.git synced 2024-10-27 20:34:12 +00:00
MikeMcl_decimal.js/test/modules/sign.js

31 lines
649 B
JavaScript
Raw Normal View History

2016-01-25 00:11:32 +00:00
if (typeof T === 'undefined') require('../setup');
(function () {
T('sign');
function t(n, expected) {
T.assertEqual(expected, Decimal.sign(n));
}
t(NaN, NaN);
t('NaN', NaN);
t(Infinity, 1);
t(-Infinity, -1);
t('Infinity', 1);
t('-Infinity', -1);
T.assert(1 / Decimal.sign('0') === Infinity);
T.assert(1 / Decimal.sign(new Decimal('0')) === Infinity);
T.assert(1 / Decimal.sign('-0') === -Infinity);
T.assert(1 / Decimal.sign(new Decimal('-0')) === -Infinity);
t('0', 0);
t('-0', -0);
t('1', 1);
t('-1', -1);
t('9.99', 1);
t('-9.99', -1);
T.stop();
})();