mirror of
https://github.com/MikeMcl/decimal.js.git
synced 2026-03-02 03:49:24 +00:00
Initial commit
This commit is contained in:
90
test/browser/every-test.html
Normal file
90
test/browser/every-test.html
Normal file
@@ -0,0 +1,90 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang='en'>
|
||||
<head>
|
||||
<meta charset='utf-8' />
|
||||
<title>Testing decimal.js</title>
|
||||
<style> body {font-family: monospace; font-size: 12px; line-height: 14px;}</style>
|
||||
<script src='../../decimal.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
var arr,
|
||||
passed = 0,
|
||||
total = 0,
|
||||
i = 0,
|
||||
start = +new Date(),
|
||||
methods = [
|
||||
'abs',
|
||||
'baseIn',
|
||||
'baseOut',
|
||||
'ceil',
|
||||
'cmp',
|
||||
'config',
|
||||
'constructor',
|
||||
'div',
|
||||
'divToInt',
|
||||
'dpSd',
|
||||
'exp',
|
||||
'floor',
|
||||
'intPow',
|
||||
'isFiniteEtc',
|
||||
'ln',
|
||||
'log',
|
||||
'log10',
|
||||
'minAndMax',
|
||||
'minus',
|
||||
'mod',
|
||||
'neg',
|
||||
'plus',
|
||||
'pow',
|
||||
'random',
|
||||
'round',
|
||||
'sqrt',
|
||||
'times',
|
||||
'toDP',
|
||||
'toExponential',
|
||||
'toFixed',
|
||||
'toFormat',
|
||||
'toFraction',
|
||||
'toInt',
|
||||
'toNearest',
|
||||
'toNumber',
|
||||
'toPrecision',
|
||||
'toStringEtc',
|
||||
'trunc'
|
||||
];
|
||||
|
||||
function load() {
|
||||
var head = document.getElementsByTagName("head")[0],
|
||||
script = document.createElement("script");
|
||||
script.src = '../' + methods[i] + '.js';
|
||||
if (!methods[i++]) {
|
||||
document.body.innerHTML += '<br>IN TOTAL: ' + 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 += 'Decimal TESTING<br>';
|
||||
load();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user