X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=build%2Ftest%2Fdata%2Ftestrunner.js;h=78395aadb9e51591d782537c6f7ecf50c776d04b;hb=f8fcc9525d2d596c98d84f8fc085579018437813;hp=0ff0ad50065266b9b5f2c6bfb019a69fb6562c5c;hpb=4c66f62a6fcc84a6c85249d0fb34b93edd40be00;p=jquery.git diff --git a/build/test/data/testrunner.js b/build/test/data/testrunner.js index 0ff0ad5..78395aa 100644 --- a/build/test/data/testrunner.js +++ b/build/test/data/testrunner.js @@ -15,7 +15,10 @@ var _config = { $(function() { $('#userAgent').html(navigator.userAgent); - runTest(); + if($.browser.safari) + $("h1").append(" - Disabled for Safari"); + else + runTest(); }); function synchronize(callback) { @@ -63,9 +66,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 +94,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" ] ); } @@ -204,4 +219,22 @@ function t(a,b,c) { */ function url(value) { return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000); -} \ No newline at end of file +} + +/** + * 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 ] ); +}