- try {
- eval(js);
- } catch(e) {
- if(typeof console != "undefined")
- console.error(e);
- console.debug(js);
- Test.push( [ false, "Died on test #" + (Test.length+1) + ": " + e ] );
- }
-
- var good = 0, bad = 0;
- var ol = document.createElement("ol");
-
- var li = "", state = "pass";
- for ( var i = 0; i < Test.length; i++ ) {
+ function test(name, callback) {
+ Test = [];
+ try {
+ callback();
+ } catch(e) {
+ if(typeof console != "undefined") {
+ console.error("Test " + name + " died, exception and test follows");
+ console.error(e);
+ console.warn(callback.toString());
+ }
+ Test.push( [ false, "Died on test #" + (Test.length+1) + ": " + e ] );
+ }
+ reset();
+
+ var good = 0, bad = 0;
+ var ol = document.createElement("ol");
+
+ var li = "", state = "pass";
+ for ( var i = 0; i < Test.length; i++ ) {
+ var li = document.createElement("li");
+ li.className = Test[i][0] ? "pass" : "fail";
+ li.innerHTML = Test[i][1];
+ ol.appendChild( li );
+
+ stats.all++;
+ if ( !Test[i][0] ) {
+ state = "fail";
+ bad++;
+ stats.bad++;
+ } else good++;
+ }
+