test.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <!DOCTYPE html>
  2. <html lang='en'>
  3. <head>
  4. <meta charset='utf-8' />
  5. <title>Testing bignumber.js</title>
  6. <style> body {font-family: monospace; font-size: 12px; line-height: 14px;}</style>
  7. <script src='../bignumber.js'></script>
  8. <script src='./tester.js'></script>
  9. </head>
  10. <body>
  11. <script>
  12. var arr,
  13. head = document.getElementsByTagName("head")[0],
  14. i = 0,
  15. passed = 0,
  16. total = 0,
  17. time = new Date(),
  18. methods = [
  19. 'absoluteValue',
  20. 'BigNumber',
  21. 'comparedTo',
  22. 'clone',
  23. 'config',
  24. 'dividedBy',
  25. 'dividedToIntegerBy',
  26. 'decimalPlaces',
  27. 'exponentiatedBy',
  28. 'integerValue',
  29. 'isBigNumber',
  30. 'minmax',
  31. 'minus',
  32. 'modulo',
  33. 'multipliedBy',
  34. 'negated',
  35. 'isMethods',
  36. 'plus',
  37. 'precision',
  38. 'random',
  39. 'shiftedBy',
  40. 'squareRoot',
  41. 'toExponential',
  42. 'toFixed',
  43. 'toFormat',
  44. 'toFraction',
  45. 'toNumber',
  46. 'toPrecision',
  47. 'toString'
  48. ];
  49. function load() {
  50. var method = methods[i++];
  51. if (!method) {
  52. time = new Date() - time;
  53. document.body.innerHTML +=
  54. '<br>&nbsp;In total, ' + passed + ' of ' + total + ' tests passed in ' + (time / 1e3) + ' secs.<br>';
  55. document.body.scrollIntoView(false);
  56. return;
  57. }
  58. var script = document.createElement("script");
  59. script.src = './methods/' + method + '.js';
  60. script.onload = script.onreadystatechange = function () {
  61. if (!script.readyState || /loaded|complete/.test(script.readyState)) {
  62. if (Test.result) {
  63. passed += Test.result[0];
  64. total += Test.result[1];
  65. }
  66. head.removeChild(script);
  67. count = script = null;
  68. document.body.scrollIntoView(false);
  69. setTimeout(load, 0);
  70. }
  71. };
  72. head.appendChild(script);
  73. }
  74. document.body.innerHTML += '&nbsp;Testing bignumber.js<br><br>';
  75. load();
  76. </script>
  77. </body>
  78. </html>