sum.js 534 B

123456789101112131415
  1. if (typeof Test === 'undefined') require('../tester');
  2. Test('sum', function () {
  3. function t(expected, value){
  4. Test.isTrue(expected.eq(value));
  5. }
  6. var expectedSum = new BigNumber(600);
  7. t(expectedSum, BigNumber.sum(100, 200, 300));
  8. t(expectedSum, BigNumber.sum('100', '200', '300'));
  9. t(expectedSum, BigNumber.sum(new BigNumber(100), new BigNumber(200), new BigNumber(300)));
  10. t(expectedSum, BigNumber.sum(100, '200', new BigNumber(300)));
  11. t(expectedSum, BigNumber.sum(99.9, 200.05, 300.05));
  12. });