forked from lvandeve/jmat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
82 lines (79 loc) · 2.07 KB
/
Copy pathtest.html
File metadata and controls
82 lines (79 loc) · 2.07 KB
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
73
74
75
76
77
78
79
80
81
82
<html>
<head>
<title>Jmat Unit Test</title>
<script>
// redefine console.log to also output to web page directly
(function() {
var cl = console.log;
console.log = function(s) {
var el;
try {
el = document.getElementById("log");
el.innerHTML = el.innerHTML + s.toString() + '<br>';
} catch (e) {};
cl.apply(this, arguments);
};
})();
</script>
<style>
b { color: #f00 }
</style>
</head>
<body>
<h1>Jmat Unit Test</h1>
<pre id="log">Console output:<p></pre>
<script>
function removeMath() {
console.log("Removing Math functions Jmat can polyfill...");
['gamma', 'factorial', 'lambertw', 'erf', 'erfc'].map(function(fun) {
Math[fun] = undefined;
});
['sinh', 'cosh', 'tanh', 'asinh', 'acosh', 'atanh', 'clz32', 'log2', 'log10', 'log1p', 'expm1'].map(function(fun) {
Math[fun] = undefined;
});
};
removeMath();
console.log("Loading jmat.js...");
</script>
<script src="jmat.js"></script>
<script>
// uncomment to sabotage (have unit test fail)
// Jmat.near = undefined;
</script>
<script src="jmat_test.js"></script>
<script>
console.log("Testing jmat.js...");
try {
Jmat.doUnitTest();
} catch (e) {
console.log('<b>'+e.toString()+'</b>');
};
</script>
<script>
console.log("Trying to forget having seen jmat.js...");
Real = undefined;
Complex = undefined;
Matrix = undefined;
BigInt = undefined;
Quaternion = undefined;
Jmat = undefined;
console.log("");
removeMath();
console.log("Loading jmat.min.js...");
</script>
<script src="jmat.min.js"></script>
<script>
// uncomment to sabotage (have unit test fail)
// Jmat.near = undefined;
</script>
<script src="jmat_test.js"></script>
<script>
console.log("Testing jmat.min.js...");
try {
Jmat.doUnitTest();
} catch (e) {
console.log('<b>'+e.toString()+'</b>');
};
</script>
</body>
</html>