function TestCase() { this._tests = new Array(); } TestCase.prototype._tests; TestCase.prototype.addTest = function(callback) { this._tests.push(callback); } TestCase.prototype.runTests = function() { var status = document.createElement("DIV"); var html = "

" + pass + " passed, " + fail + " failed"; status.innerHTML = html; return (fail == 0); } function funcname(f) { var s = f.toString().match(/function (\w*)/)[1]; if (s == null || s.length == 0) return "anonymous"; return s; } function assertTrue(val) { if (val != true) { throw "assertTrue failed"; } } function assertFalse(val) { return assertTrue(!val); } function assertEquals(a, b) { try { // TODO(aporter): Type safe comparison? return assertTrue(""+a == ""+b); } catch (e) { var s = "assertEquals('"; s += a; s += "', '"; s += b; s += "') failed"; throw s; } } function assertNotEquals(a, b) { try { return assertTrue(a != b); } catch (e) { throw "assertNotEquals(" + a + ", " + b + ") failed"; } }