Lint old tests

This commit is contained in:
impinball 2016-01-22 11:46:57 -05:00
parent b218f5156f
commit fb3a534de0
12 changed files with 2976 additions and 1903 deletions

View file

@ -1,28 +1,38 @@
if (!this.console) {
var log = function (value) { document.write("<pre>" + value + "</pre>") }
this.console = {log: log, error: log}
}
/* eslint-env browser */
function test(condition) {
test.total++
(function (global) {
"use strict"
try {
if (!condition()) throw new Error("failed")
function log(value) {
document.write("<pre>" + value + "</pre>")
}
catch (e) {
console.error(e)
test.failures.push(condition)
}
}
test.total = 0
test.failures = []
test.print = function (print) {
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")
if (!global.console) {
global.console = {log: log, error: log}
}
}
global.test = test
function test(condition) {
test.total++
try {
if (!condition()) throw new Error("failed")
} catch (e) {
console.error(e) // eslint-disable-line no-console
test.failures.push(condition)
}
}
test.total = 0
test.failures = []
test.print = function (print) {
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")
}
}
})(this)