1
0
mirror of https://github.com/MikeMcl/decimal.js.git synced 2024-09-28 06:20:53 +00:00
MikeMcl_decimal.js/test/modules/sign.js
Michael Mclaughlin caad23d669 refactor tests
2016-02-06 17:51:29 +00:00

28 lines
586 B
JavaScript

if (typeof T === 'undefined') require('../setup');
T('sign', function () {
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);
});