1
0
mirror of https://github.com/MikeMcl/decimal.js.git synced 2024-10-27 20:34:12 +00:00
MikeMcl_decimal.js/test/test.html

113 lines
2.1 KiB
HTML
Raw Normal View History

2016-01-25 00:11:32 +00:00
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>Testing decimal.js</title>
<style>
2016-02-06 17:51:29 +00:00
body {font-family: monospace; font-size: 12px; line-height: 14px;}
2016-01-25 00:11:32 +00:00
</style>
<script src='../decimal.js'></script>
<script src='./setup.js'></script>
</head>
<body>
<script>
var arr,
2016-02-06 17:51:29 +00:00
head = document.getElementsByTagName("head")[0],
i = 0,
passed = 0,
total = 0,
time = new Date(),
modules = [
'abs',
'acos',
'acosh',
'asin',
'asinh',
'atan',
'atan2',
'atanh',
'cbrt',
'ceil',
'clone',
'cmp',
'config',
'cos',
'cosh',
'Decimal',
'div',
'divToInt',
'dpSd',
'exp',
'floor',
'hypot',
'immutability',
'intPow',
'isFiniteEtc',
'ln',
'log',
'log10',
'log2',
'minAndMax',
'minus',
'mod',
'neg',
'plus',
'pow',
'random',
'round',
'sign',
'sin',
'sinh',
'sqrt',
'tan',
'tanh',
'times',
'toBinary',
'toDP',
'toExponential',
'toFixed',
'toFraction',
'toHex',
'toNearest',
'toNumber',
'toOctal',
'toPrecision',
'toSD',
'toString',
'trunc',
'valueOf',
];
2016-01-25 00:11:32 +00:00
function load() {
2016-02-06 17:51:29 +00:00
var module = modules[i++];
if (!module) {
time = new Date() - time;
document.body.innerHTML +=
2016-11-09 17:08:38 +00:00
'<br>&nbsp;In total, ' + passed + ' of ' + total + ' tests passed in ' +
(time / 1e3) + ' secs.<br>';
2016-01-25 00:11:32 +00:00
document.body.scrollIntoView(false);
return;
}
2016-02-06 17:51:29 +00:00
var script = document.createElement("script");
script.src = './modules/' + module + '.js';
2016-01-25 00:11:32 +00:00
script.onload = script.onreadystatechange = function () {
if (!script.readyState || /loaded|complete/.test(script.readyState)) {
2016-02-06 17:51:29 +00:00
if (T.result) {
2016-01-25 00:11:32 +00:00
passed += T.result[0];
total += T.result[1];
}
head.removeChild(script);
count = script = null;
document.body.scrollIntoView(false);
setTimeout(load, 0);
}
};
head.appendChild(script);
}
2016-03-09 22:54:34 +00:00
document.body.innerHTML += '&nbsp;Testing decimal.js<br><br>';
2016-01-25 00:11:32 +00:00
load();
</script>
</body>
</html>