1if (typeof T === 'undefined') require('../setup'); 2 3T('sum', function () { 4 var expected; 5 6 function t() { 7 T.assertEqualDecimal(expected, Decimal.sum.apply(Decimal, arguments)); 8 } 9 10 expected = new Decimal(0); 11 12 t('0'); 13 t('0', new Decimal(0)); 14 t(1, 0, '-1'); 15 t(0, new Decimal('-10'), 0, 0, 0, 0, 0, 10); 16 t(11, -11); 17 t(1, '2', new Decimal(3), new Decimal('4'), -10); 18 t(new Decimal(-10), '9', new Decimal(0.01), 0.99); 19 20 expected = new Decimal(10); 21 22 t('10'); 23 t('0', new Decimal('10')); 24 t(10, 0); 25 t(0, 0, 0, 0, 0, 0, 10); 26 t(11, -1); 27 t(1, '2', new Decimal(3), new Decimal('4')); 28 t('9', new Decimal(0.01), 0.99); 29 30 expected = new Decimal(600); 31 32 t(100, 200, 300); 33 t('100', '200', '300'); 34 t(new Decimal(100), new Decimal(200), new Decimal(300)); 35 t(100, '200', new Decimal(300)); 36 t(99.9, 200.05, 300.05); 37 38 expected = new Decimal(NaN); 39 40 t(NaN); 41 t('1', NaN); 42 t(100, 200, NaN); 43 t(NaN, 0, '9', new Decimal(0), 11, Infinity); 44 t(0, new Decimal('-Infinity'), '9', new Decimal(NaN), 11); 45 t(4, '-Infinity', 0, '9', new Decimal(0), Infinity, 2); 46 47 expected = new Decimal(Infinity); 48 49 t(Infinity); 50 t(1, '1e10000000000000000000000000000000000000000', '4'); 51 t(100, 200, 'Infinity'); 52 t(0, new Decimal('Infinity'), '9', new Decimal(0), 11); 53 t(0, '9', new Decimal(0), 11, Infinity); 54 t(4, new Decimal(Infinity), 0, '9', new Decimal(0), Infinity, 2); 55 56 expected = new Decimal(-Infinity); 57 58 t(-Infinity); 59 t(1, '-1e10000000000000000000000000000000000000000', '4'); 60 t(100, 200, '-Infinity'); 61 t(0, new Decimal('-Infinity'), '9', new Decimal(0), 11); 62 t(0, '9', new Decimal(0), 11, -Infinity); 63 t(4, new Decimal(-Infinity), 0, '9', new Decimal(0), -Infinity, 2); 64});