13 lines
No EOL
371 B
JavaScript
13 lines
No EOL
371 B
JavaScript
function test(condition) {
|
|
try {if (!condition()) throw new Error}
|
|
catch (e) {console.error(e);test.failures.push(condition)}
|
|
test.total++
|
|
}
|
|
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)
|
|
} |