1
0
mirror of https://github.com/MikeMcl/decimal.js.git synced 2026-09-23 12:24:47 +00:00

Add immutability tests

This commit is contained in:
Michael Mclaughlin
2016-02-04 23:52:10 +00:00
parent a62bb62b6b
commit c2c4480881
59 changed files with 24997 additions and 24484 deletions

View File

@@ -1,30 +1,30 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('sign');
T('sign');
function t(n, expected) {
T.assertEqual(expected, Decimal.sign(n));
}
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(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.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('0', 0);
t('-0', -0);
t('1', 1);
t('-1', -1);
t('9.99', 1);
t('-9.99', -1);
T.stop();
T.stop();
})();