2016-01-25 00:11:32 +00:00
|
|
|
if (typeof T === 'undefined') require('../setup');
|
|
|
|
|
|
|
|
(function () {
|
2016-02-04 23:52:10 +00:00
|
|
|
T('sign');
|
2016-01-25 00:11:32 +00:00
|
|
|
|
2016-02-04 23:52:10 +00:00
|
|
|
function t(n, expected) {
|
|
|
|
T.assertEqual(expected, Decimal.sign(n));
|
|
|
|
}
|
2016-01-25 00:11:32 +00:00
|
|
|
|
2016-02-04 23:52:10 +00:00
|
|
|
t(NaN, NaN);
|
|
|
|
t('NaN', NaN);
|
|
|
|
t(Infinity, 1);
|
|
|
|
t(-Infinity, -1);
|
|
|
|
t('Infinity', 1);
|
|
|
|
t('-Infinity', -1);
|
2016-01-25 00:11:32 +00:00
|
|
|
|
2016-02-04 23:52:10 +00:00
|
|
|
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);
|
2016-01-25 00:11:32 +00:00
|
|
|
|
2016-02-04 23:52:10 +00:00
|
|
|
t('0', 0);
|
|
|
|
t('-0', -0);
|
|
|
|
t('1', 1);
|
|
|
|
t('-1', -1);
|
|
|
|
t('9.99', 1);
|
|
|
|
t('-9.99', -1);
|
2016-01-25 00:11:32 +00:00
|
|
|
|
2016-02-04 23:52:10 +00:00
|
|
|
T.stop();
|
2016-01-25 00:11:32 +00:00
|
|
|
})();
|