X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=build%2Ftest%2Fdata%2Ftestrunner.js;h=e6cfc1eb003b3d717b0e181b790b281a7b04b034;hb=88c88f0704e70299cd3101a40b29cb37b79276d0;hp=6da41c3a2c77e3023f1f0e64f6cd86b5aea5d715;hpb=98b1b580c7298c1ced00f9ec4d65452b4d559da7;p=jquery.git diff --git a/build/test/data/testrunner.js b/build/test/data/testrunner.js index 6da41c3..e6cfc1e 100644 --- a/build/test/data/testrunner.js +++ b/build/test/data/testrunner.js @@ -63,9 +63,14 @@ function runTest() { }); } -function test(name, callback) { +function test(name, callback, nowait) { if(_config.currentModule) name = _config.currentModule + " module: " + name; + + var filter = location.search.slice(1); + if ( filter && encodeURIComponent(name) != filter ) + return; + synchronize(function() { _config.Test = []; try { @@ -82,6 +87,9 @@ function test(name, callback) { synchronize(function() { reset(); + // don't output pause tests + if(nowait) return; + if(_config.expected && _config.expected != _config.Test.length) { _config.Test.push( [ false, "Expected " + _config.expected + " assertions, but " + _config.Test.length + " were run" ] ); } @@ -108,7 +116,7 @@ function test(name, callback) { var li = document.createElement("li"); li.className = state; - var b = document.createElement("b"); + var b = document.createElement("strong"); b.innerHTML = name + " (" + bad + ", " + good + ", " + _config.Test.length + ")"; b.onclick = function(){ var n = this.nextSibling; @@ -117,6 +125,13 @@ function test(name, callback) { else n.style.display = "none"; }; + $(b).dblclick(function(event) { + var target = jQuery(event.target).filter("strong").clone(); + if ( target.length ) { + target.children().remove(); + location.href = location.href.match(/^(.+?)(\?.*)?$/)[1] + "?" + encodeURIComponent($.trim(target.text())); + } + }); li.appendChild( b ); li.appendChild( ol ); @@ -156,19 +171,57 @@ function ok(a, msg) { */ function isSet(a, b, msg) { var ret = true; - if ( a && b && a.length == b.length ) { - for ( var i in a ) + if ( a && b && a.length != undefined && a.length == b.length ) { + for ( var i = 0; i < a.length; i++ ) if ( a[i] != b[i] ) ret = false; } else ret = false; if ( !ret ) - _config.Test.push( [ ret, msg + " expected: " + b + " result: " + a ] ); + _config.Test.push( [ ret, msg + " expected: " + serialArray(b) + " result: " + serialArray(a) ] ); else _config.Test.push( [ ret, msg ] ); } /** + * Asserts that two objects are equivalent + */ +function isObj(a, b, msg) { + var ret = true; + + if ( a && b ) { + for ( var i in a ) + if ( a[i] != b[i] ) + ret = false; + + for ( i in b ) + if ( a[i] != b[i] ) + ret = false; + } else + ret = false; + + _config.Test.push( [ ret, msg ] ); +} + +function serialArray( a ) { + var r = []; + + if ( a && a.length ) + for ( var i = 0; i < a.length; i++ ) { + var str = a[i].nodeName; + if ( str ) { + str = str.toLowerCase(); + if ( a[i].id ) + str += "#" + a[i].id; + } else + str = a[i]; + r.push( str ); + } + + return "[ " + r.join(", ") + " ]" +} + +/** * Returns an array of elements with the given IDs, eg. * @example q("main", "foo", "bar") * @result [