X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=build%2Ftest%2Fdata%2Ftestrunner.js;h=899d6700cb0fbc530cf2549584bdb8d2c21200f6;hb=a69aad2242a5be4ee21955d6132247b4781d410e;hp=6da41c3a2c77e3023f1f0e64f6cd86b5aea5d715;hpb=98b1b580c7298c1ced00f9ec4d65452b4d559da7;p=jquery.git diff --git a/build/test/data/testrunner.js b/build/test/data/testrunner.js index 6da41c3..899d670 100644 --- a/build/test/data/testrunner.js +++ b/build/test/data/testrunner.js @@ -15,6 +15,8 @@ var _config = { $(function() { $('#userAgent').html(navigator.userAgent); + if($.browser.safari) + $("h1").append(" - Slowed down for Safari to prevent crashes"); runTest(); }); @@ -63,9 +65,18 @@ function runTest() { }); } -function test(name, callback) { +function test(name, callback, nowait) { + // safari seems to have some memory problems, so we need to slow it down + if($.browser.safari && !nowait) { + test("", function() { + stop(); + setTimeout(start, 250); + }, true); + } + if(_config.currentModule) name = _config.currentModule + " module: " + name; + synchronize(function() { _config.Test = []; try { @@ -82,6 +93,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" ] ); } @@ -191,4 +205,35 @@ function t(a,b,c) { for ( var i = 0; i < f.length; i++ ) s += (s && ",") + '"' + f[i].id + '"'; isSet(f, q.apply(q,c), a + " (" + b + ")"); -} \ No newline at end of file +} + +/** + * Add random number to url to stop IE from caching + * + * @example url("data/test.html") + * @result "data/test.html?10538358428943" + * + * @example url("data/test.php?foo=bar") + * @result "data/test.php?foo=bar&10538358345554" + */ +function url(value) { + return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000); +} + +/** + * Checks that the first two arguments are equal, with an optional message. + * Prints out both expected and actual values on failure. + * + * Prefered to ok( expected == actual, message ) + * + * @example equals( "Expected 2 characters.", v.formatMessage("Expected {0} characters.", 2) ); + * + * @param Object expected + * @param Object actual + * @param String message (optional) + */ +function equals(expected, actual, message) { + var result = expected == actual; + message = message || result ? "okay" : "failed"; + _config.Test.push( [ result, result ? message + ": " + expected : message + " expected: " + expected + " actual: " + actual ] ); +}