diff --git a/test/modules/abs.js b/test/modules/abs.js index 082c67d..bf88705 100644 --- a/test/modules/abs.js +++ b/test/modules/abs.js @@ -4,7 +4,9 @@ if (typeof T === 'undefined') require('../setup'); T('absoluteValue'); function t(expected, value){ - T.assertEqual(expected, new Decimal(value).abs().valueOf()); + var x = new Decimal(value); + T.assertEqual(expected, x.abs().valueOf()); + T.assert(x.eq(value) || x.isNaN()); } Decimal.config({ diff --git a/test/modules/cos.js b/test/modules/cos.js index ce813d2..4d79ac6 100644 --- a/test/modules/cos.js +++ b/test/modules/cos.js @@ -6,12 +6,10 @@ if (typeof T === 'undefined') require('../setup'); function t(n, pr, rm, expected) { Decimal.precision = pr; Decimal.rounding = rm; - T.assertEqual(expected, Decimal.cos(n).valueOf()); - T.assertEqual(expected, new Decimal(n).cos().valueOf()); - var x = new Decimal(n); - x.cos(); - T.assertEqual(new Decimal(n).valueOf(), x.valueOf()); + T.assertEqual(expected, x.cos().valueOf()); + T.assertEqual(expected, Decimal.cos(n).valueOf()); + T.assert(x.eq(n) || x.isNaN()); } Decimal.config({ @@ -44,6 +42,7 @@ if (typeof T === 'undefined') require('../setup'); t('0.3834777777', 3, 4, '0.927'); t('16355.3334', 9, 4, '0.979658167'); t('0.997737586545708065463833973312637902054356957830033', 5, 5, '0.5422'); + t('-0.997737586545708065463833973312637902054356957830033', 5, 5, '0.5422'); t('7803700', 4, 2, '-0.9032'); t('841822094288189413002174891207354317', 5, 2, '-0.86017'); t('67942', 8, 3, '-0.33958641'); diff --git a/test/modules/exp.js b/test/modules/exp.js index 4dc98be..62d619d 100644 --- a/test/modules/exp.js +++ b/test/modules/exp.js @@ -6,8 +6,10 @@ if (typeof T === 'undefined') require('../setup'); function t(n, expected, pr, rm) { Decimal.precision = pr; Decimal.rounding = rm; + var x = new Decimal(n); + T.assertEqual(expected, x.exp().valueOf()); T.assertEqual(expected, Decimal.exp(n).valueOf()); - T.assertEqual(expected, new Decimal(n).exp().valueOf()); + T.assert(x.eq(n) || x.isNaN()); } Decimal.config({ diff --git a/test/modules/sin.js b/test/modules/sin.js index 0eb0299..a5baf1b 100644 --- a/test/modules/sin.js +++ b/test/modules/sin.js @@ -6,8 +6,10 @@ if (typeof T === 'undefined') require('../setup'); function t(n, pr, rm, expected) { Decimal.precision = pr; Decimal.rounding = rm; + var x = new Decimal(n); + T.assertEqual(expected, x.sin().valueOf()); T.assertEqual(expected, Decimal.sin(n).valueOf()); - T.assertEqual(expected, new Decimal(n).sin().valueOf()); + T.assert(x.eq(n) || x.isNaN()); } Decimal.config({ @@ -28,6 +30,9 @@ if (typeof T === 'undefined') require('../setup'); t('93332358216', 48, 5, '0.000816283943127306029649893248669685836695194145277'); t('766737078569022420173292205068953186848344673451240027655054631094318050', 18, 6, '0.00111135055272494455'); + t('-93332358216', 48, 5, '-0.000816283943127306029649893248669685836695194145277'); + t('-766737078569022420173292205068953186848344673451240027655054631094318050', 18, 6, '-0.00111135055272494455'); + t('0.359136383962093189473162700700590970518456985109181875257764726415814563424613193774806585890478208084275468196568294033', 38, 1, '0.35146584650000000000000000000000000006'); t('3202222222227222222222222222222224222222222222222222222222.222222222222222222222222222', 7, 0, '0.5499568'); t('8', 5, 6, '0.98936'); diff --git a/test/modules/tan.js b/test/modules/tan.js index ed12bc9..b6c4902 100644 --- a/test/modules/tan.js +++ b/test/modules/tan.js @@ -6,8 +6,10 @@ if (typeof T === 'undefined') require('../setup'); function t(n, pr, rm, expected) { Decimal.precision = pr; Decimal.rounding = rm; + var x = new Decimal(n); + T.assertEqual(expected, x.tan().valueOf()); T.assertEqual(expected, Decimal.tan(n).valueOf()); - T.assertEqual(expected, new Decimal(n).tan().valueOf()); + T.assert(x.eq(n) || x.isNaN()); } Decimal.config({ @@ -26,8 +28,10 @@ if (typeof T === 'undefined') require('../setup'); t('-Infinity', 40, 4, 'NaN'); t('3', 5, 5, '-0.14255'); + t('-3', 5, 5, '0.14255'); t('0.8', 7, 6, '1.029639'); t('539998661123466984649191689138494900416386817996524', 7, 6, '32.04695'); + t('-539998661123466984649191689138494900416386817996524', 7, 6, '-32.04695'); t('0.5172293543584894071801901902', 5, 1, '0.56888'); t('5', 10, 5, '-3.380515006'); t('0.5283979979897015', 1, 4, '0.6'); diff --git a/test/modules/times.js b/test/modules/times.js index 260fb83..24e0345 100644 --- a/test/modules/times.js +++ b/test/modules/times.js @@ -4,7 +4,9 @@ if (typeof T === 'undefined') require('../setup'); T('times'); var t = function (multiplicand, multiplier, expected) { - T.assertEqual(expected, new Decimal(multiplicand).times(multiplier).valueOf()); + var x = new Decimal(multiplicand); + T.assertEqual(expected, x.times(multiplier).valueOf()); + T.assert(x.eq(multiplicand) || x.isNaN()); } Decimal.config({