v0.2.2-rc.1
This commit is contained in:
parent
484a9d6c70
commit
270b20a2b0
110 changed files with 17357 additions and 3070 deletions
28
tests/test.js
Normal file
28
tests/test.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
if (!this.console) {
|
||||
var log = function (value) { document.write("<pre>" + value + "</pre>") }
|
||||
this.console = {log: log, error: log}
|
||||
}
|
||||
|
||||
function test(condition) {
|
||||
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) {
|
||||
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")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue