1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
<!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>
<script src='../test.js'></script>
</head>
<body>
<script>
var arr;
var head = document.getElementsByTagName("head")[0];
var color = 'green';
var passed = 0;
var total = 0;
var i = 0;
var methods = [
'abs',
'div',
'cmp',
'minus',
'mod',
'plus',
'pow',
'prec',
'round',
'sqrt',
'times',
'toExponential',
'toFixed',
'toNumber',
'toPrecision',
'toString'
];
var start = +new Date();
function load() {
var method = methods[i++];
if (!method) {
document.body.innerHTML += '<br><div style="display:inline-block;padding:4px;border:4px solid ' + color +
'">In total, ' + passed + ' of ' + total + ' tests passed in ' + ((+new Date() - start) / 1000) + ' secs.</div>';
document.body.scrollIntoView(false);
return;
}
var script = document.createElement("script");
script.src = '../methods/' + method + '.js';
script.onload = script.onreadystatechange = function () {
if (!script.readyState || /loaded|complete/.test(script.readyState)) {
if (test.result) {
passed += test.result[0];
total += test.result[1];
if (test.result[0] !== test.result[1]) color = 'red';
} else {
document.body.innerHTML += '<div style="color:red"> Test script failed - see error console.</div>';
}
head.removeChild(script);
count = script = null;
document.body.scrollIntoView(false);
setTimeout(load, 0);
}
};
head.appendChild(script);
}
document.body.innerHTML += ' Testing big.js<br><br>';
load();
</script>
</body>
</html>
|