mithril-vndb/tests/test.js
impinball 9ae592ee4d Do some local style modifications and profile.
1. Do some temporary style modifications to help make the code more readable
   for profiling (with help from ESLint).
2. Profile the code, and optimize accordingly.
2015-07-23 05:17:02 -04:00

33 lines
710 B
JavaScript

/* eslint-disable no-console */
if (!this.console) {
var log = function(value) {
"use strict"
document.write("<pre>" + value + "</pre>")
}
this.console = {log: log, error: log}
}
function test(condition) {
"use strict"
test.total++
try {
if (!condition()) throw new Error("failed")
} catch (e) {
console.error(e)
test.failures.push(condition)
}
}
test.total = 0
test.failures = []
test.print = function(print) {
"use strict"
for (var i = 0; i < test.failures.length; i++) {
print(test.failures[i].toString())
}
print("tests: " + test.total + "\nfailures: " + test.failures.length)
if (test.failures.length > 0) {
throw new Error(test.failures.length + " tests did not pass")
}
}