big.js/test/browser/every-test.html
Michael Mclaughlin 0b79acd7aa Rename Big.E_POS to Big.PE, Big.E_NEG to Big.NE.
Refactor error messaging. Throw if null is passed to toFixed etc. and amend tests accordingly. Clean-up and reformat.
2017-09-27 22:14:56 +01:00

66 lines
1.8 KiB
HTML

<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>Testing big.js</title>
<style> body {font-family: monospace; font-size: 12px; line-height: 14px;}</style>
<script src='../../big.js'></script>
</head>
<body>
<script>
var arr,
passed = 0,
total = 0,
i = 0,
start = +new Date(),
methods = [
'abs',
'div',
'cmp',
'minus',
'mod',
'plus',
'pow',
'round',
'sqrt',
'times',
'toExponential',
'toFixed',
'toPrecision',
'toString'
];
function load() {
var head = document.getElementsByTagName("head")[0],
script = document.createElement("script");
script.src = '../' + methods[i] + '.js';
if (!methods[i++]) {
document.body.innerHTML += '<br>RESULTS: ' + passed + ' of ' + total +
' tests passed in ' + ( (+new Date() - start) / 1000 ) + ' secs.<br>';
document.body.scrollIntoView(false);
return;
}
script.onload = script.onreadystatechange = function () {
if (!script.readyState || /loaded|complete/.test(script.readyState)) {
if (!count) {
document.body.innerHTML +=
'<br><span style="color: red">TEST SCRIPT FAILED - see error console.</span>';
} else {
passed += count[0];
total += count[1];
}
head.removeChild(script);
count = script = null;
document.body.innerHTML += '<br>';
document.body.scrollIntoView(false);
setTimeout(load, 0);
}
};
head.appendChild(script);
}
document.body.innerHTML += 'Testing big.js<br>';
load();
</script>
</body>
</html>