};
var queue = [];
var blocking = false;
+var timeout;
function synchronize(callback) {
queue[queue.length] = callback;
function stop() {
blocking = true;
- setTimeout(start, asyncTimeout * 1000);
+ timeout = setTimeout(start, asyncTimeout * 1000);
}
function start() {
+ if(timeout)
+ clearTimeout(timeout);
blocking = false;
process();
}
}
function test(name, callback) {
- Test = [];
synchronize(function() {
+ Test = [];
try {
callback();
} catch(e) {
- if(typeof console != "undefined") {
+ if( typeof console != "undefined" && console.error && console.warn ) {
console.error("Test " + name + " died, exception and test follows");
console.error(e);
console.warn(callback.toString());
ret = false;
} else
ret = false;
- if ( !ret && console )
- console.log( msg, a, b );
- Test.push( [ ret, msg ] );
+ if ( !ret )
+ Test.push( [ ret, msg + " expected: " + b + " result: " + a ] );
+ else
+ Test.push( [ ret, msg ] );
}
/**