From: Jörn Zaefferer Date: Sat, 18 Nov 2006 13:37:01 +0000 (+0000) Subject: Testsuite 2.0 X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;h=7cc550727c4e0bcd93c5d435f0799f568fc74dfa;p=jquery.git Testsuite 2.0 --- diff --git a/build.xml b/build.xml index 2d13c31..7424dbf 100644 --- a/build.xml +++ b/build.xml @@ -45,10 +45,10 @@ - - - - + + + + @@ -101,18 +101,14 @@ - + - - - - - - + + diff --git a/build/test/data/test.js b/build/test/data/test.js index 9294f06..6ff89dd 100644 --- a/build/test/data/test.js +++ b/build/test/data/test.js @@ -1,2 +1,3 @@ foobar = "bar"; $('#ap').html('bar'); +ok( true, "test.js executed"); \ No newline at end of file diff --git a/build/test/data/testrunner.js b/build/test/data/testrunner.js index 06d12cb..c3afea3 100644 --- a/build/test/data/testrunner.js +++ b/build/test/data/testrunner.js @@ -1,59 +1,69 @@ -var asyncTimeout = 2 // seconds for async timeout - -var fixture; -var Test; -var stats = { - all: 0, - bad: 0 +var _config = { + fixture: null, + Test: [], + stats: { + all: 0, + bad: 0 + }, + queue: [], + blocking: true, + timeout: null, + expected: null, + currentModule: null, + asyncTimeout: 2 // seconds for async timeout }; -var queue = []; -var blocking = false; -var timeout; + +$(function() { + $('#userAgent').html(navigator.userAgent); + runTest(); +}); function synchronize(callback) { - queue[queue.length] = callback; - if(!blocking) { + _config.queue[_config.queue.length] = callback; + if(!_config.blocking) { process(); } } function process() { - while(queue.length && !blocking) { - var call = queue[0]; - queue = queue.slice(1); + while(_config.queue.length && !_config.blocking) { + var call = _config.queue[0]; + _config.queue = _config.queue.slice(1); call(); } } function stop() { - blocking = true; - timeout = setTimeout(start, asyncTimeout * 1000); + _config.blocking = true; + _config.timeout = setTimeout(start, _config.asyncTimeout * 1000); } function start() { - if(timeout) - clearTimeout(timeout); - blocking = false; + if(_config.timeout) + clearTimeout(_config.timeout); + _config.blocking = false; process(); } -function runTest(tests) { - var startTime = new Date(); - fixture = document.getElementById('main').innerHTML; - tests(); +function runTest() { + _config.blocking = false; + var time = new Date(); + _config.fixture = document.getElementById('main').innerHTML; synchronize(function() { - var runTime = new Date() - startTime; - var result = document.createElement("div"); - result.innerHTML = ['

Tests completed in ', - runTime, ' milliseconds.
', - stats.bad, ' tests of ', stats.all, ' failed.

'].join(''); - document.getElementsByTagName("body")[0].appendChild(result); - $("