From b4e23b5af0820a66c2e275051f613f3df9a4444d Mon Sep 17 00:00:00 2001 From: John Resig Date: Sat, 8 Sep 2007 12:42:32 +0000 Subject: Reorganzing the jQuery source (first phase). --- build/test/data/cow.jpg | Bin 1635 -> 0 bytes build/test/data/dashboard.xml | 11 -- build/test/data/json.php | 9 -- build/test/data/json_obj.js | 1 - build/test/data/jsonp.php | 10 -- build/test/data/name.html | 1 - build/test/data/name.php | 29 ---- build/test/data/test.html | 7 - build/test/data/test.js | 3 - build/test/data/test.php | 7 - build/test/data/test2.html | 5 - build/test/data/test3.html | 3 - build/test/data/testrunner.js | 303 ----------------------------------------- build/test/data/testsuite.css | 113 --------------- build/test/data/text.php | 12 -- build/test/data/with_fries.xml | 25 ---- build/test/index.html | 157 --------------------- build/test/test.js | 41 ------ 18 files changed, 737 deletions(-) delete mode 100644 build/test/data/cow.jpg delete mode 100644 build/test/data/dashboard.xml delete mode 100644 build/test/data/json.php delete mode 100644 build/test/data/json_obj.js delete mode 100644 build/test/data/jsonp.php delete mode 100644 build/test/data/name.html delete mode 100644 build/test/data/name.php delete mode 100644 build/test/data/test.html delete mode 100644 build/test/data/test.js delete mode 100644 build/test/data/test.php delete mode 100644 build/test/data/test2.html delete mode 100644 build/test/data/test3.html delete mode 100644 build/test/data/testrunner.js delete mode 100644 build/test/data/testsuite.css delete mode 100644 build/test/data/text.php delete mode 100644 build/test/data/with_fries.xml delete mode 100644 build/test/index.html delete mode 100644 build/test/test.js (limited to 'build/test') diff --git a/build/test/data/cow.jpg b/build/test/data/cow.jpg deleted file mode 100644 index 2c5b67225..000000000 Binary files a/build/test/data/cow.jpg and /dev/null differ diff --git a/build/test/data/dashboard.xml b/build/test/data/dashboard.xml deleted file mode 100644 index 10f6b3347..000000000 --- a/build/test/data/dashboard.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/build/test/data/json.php b/build/test/data/json.php deleted file mode 100644 index 08e3f9e32..000000000 --- a/build/test/data/json.php +++ /dev/null @@ -1,9 +0,0 @@ - \ No newline at end of file diff --git a/build/test/data/json_obj.js b/build/test/data/json_obj.js deleted file mode 100644 index 7fa61820f..000000000 --- a/build/test/data/json_obj.js +++ /dev/null @@ -1 +0,0 @@ -{ "data": {"lang": "en", "length": 25} } diff --git a/build/test/data/jsonp.php b/build/test/data/jsonp.php deleted file mode 100644 index 75000252b..000000000 --- a/build/test/data/jsonp.php +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/build/test/data/name.html b/build/test/data/name.html deleted file mode 100644 index 0fa32d1a8..000000000 --- a/build/test/data/name.html +++ /dev/null @@ -1 +0,0 @@ -ERROR diff --git a/build/test/data/name.php b/build/test/data/name.php deleted file mode 100644 index a4b990e3d..000000000 --- a/build/test/data/name.php +++ /dev/null @@ -1,29 +0,0 @@ -$xml$result"; - die(); -} -$name = $_REQUEST['name']; -if($name == 'foo') { - echo "bar"; - die(); -} else if($name == 'peter') { - echo "pan"; - die(); -} -$request = apache_request_headers(); -$request = $request['X-Custom-Header']; -if(strlen($request) > 0) { - echo $request; - die(); -} -echo 'ERROR '; -?> \ No newline at end of file diff --git a/build/test/data/test.html b/build/test/data/test.html deleted file mode 100644 index fc6dc3860..000000000 --- a/build/test/data/test.html +++ /dev/null @@ -1,7 +0,0 @@ -html text
- - -blabla diff --git a/build/test/data/test.js b/build/test/data/test.js deleted file mode 100644 index f8bdd091e..000000000 --- a/build/test/data/test.js +++ /dev/null @@ -1,3 +0,0 @@ -var foobar = "bar"; -$('#ap').html('bar'); -ok( true, "test.js executed"); diff --git a/build/test/data/test.php b/build/test/data/test.php deleted file mode 100644 index 9dbea9798..000000000 --- a/build/test/data/test.php +++ /dev/null @@ -1,7 +0,0 @@ -html text
- - -blabla \ No newline at end of file diff --git a/build/test/data/test2.html b/build/test/data/test2.html deleted file mode 100644 index ebf610e43..000000000 --- a/build/test/data/test2.html +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/build/test/data/test3.html b/build/test/data/test3.html deleted file mode 100644 index 909d41745..000000000 --- a/build/test/data/test3.html +++ /dev/null @@ -1,3 +0,0 @@ -
This is a user
-
This is a user
-
This is a teacher
diff --git a/build/test/data/testrunner.js b/build/test/data/testrunner.js deleted file mode 100644 index 69377e452..000000000 --- a/build/test/data/testrunner.js +++ /dev/null @@ -1,303 +0,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 isLocal = !!(window.location.protocol == 'file:'); - -$(function() { - $('#userAgent').html(navigator.userAgent); - runTest(); -}); - -function synchronize(callback) { - _config.queue[_config.queue.length] = callback; - if(!_config.blocking) { - process(); - } -} - -function process() { - while(_config.queue.length && !_config.blocking) { - var call = _config.queue[0]; - _config.queue = _config.queue.slice(1); - call(); - } -} - -function stop(allowFailure) { - _config.blocking = true; - var handler = allowFailure ? start : function() { - ok( false, "Test timed out" ); - start(); - }; - // Disabled, caused too many random errors - //_config.timeout = setTimeout(handler, _config.asyncTimeout * 1000); -} -function start() { - // A slight delay, to avoid any current callbacks - setTimeout(function(){ - if(_config.timeout) - clearTimeout(_config.timeout); - _config.blocking = false; - process(); - }, 13); -} - -function runTest() { - _config.blocking = false; - var time = new Date(); - _config.fixture = document.getElementById('main').innerHTML; - synchronize(function() { - time = new Date() - time; - $("
").html(['

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

'] - .join('')) - .appendTo("body"); - $("#banner").addClass(_config.stats.bad ? "fail" : "pass"); - }); -} - -function test(name, callback, nowait) { - if(_config.currentModule) - name = _config.currentModule + " module: " + name; - - var filter = location.search.slice(1); - if ( filter && encodeURIComponent(name).indexOf(filter) == -1 ) - return; - - synchronize(function() { - _config.Test = []; - try { - callback(); - } catch(e) { - if( typeof console != "undefined" && console.error && console.warn ) { - console.error("Test " + name + " died, exception and test follows"); - console.error(e); - console.warn(callback.toString()); - } - _config.Test.push( [ false, "Died on test #" + (_config.Test.length+1) + ": " + e ] ); - } - }); - 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" ] ); - } - _config.expected = null; - - var good = 0, bad = 0; - var ol = document.createElement("ol"); - ol.style.display = "none"; - var li = "", state = "pass"; - for ( var i = 0; i < _config.Test.length; i++ ) { - var li = document.createElement("li"); - li.className = _config.Test[i][0] ? "pass" : "fail"; - li.innerHTML = _config.Test[i][1]; - ol.appendChild( li ); - - _config.stats.all++; - if ( !_config.Test[i][0] ) { - state = "fail"; - bad++; - _config.stats.bad++; - } else good++; - } - - var li = document.createElement("li"); - li.className = state; - - var b = document.createElement("strong"); - b.innerHTML = name + " (" + bad + ", " + good + ", " + _config.Test.length + ")"; - b.onclick = function(){ - var n = this.nextSibling; - if ( jQuery.css( n, "display" ) == "none" ) - n.style.display = "block"; - 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 ); - - document.getElementById("tests").appendChild( li ); - }); -} - -// call on start of module test to prepend name to all tests -function module(moduleName) { - _config.currentModule = moduleName; -} - -/** - * Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through. - */ -function expect(asserts) { - _config.expected = asserts; -} - -/** - * Resets the test setup. Useful for tests that modify the DOM. - */ -function reset() { - document.getElementById('main').innerHTML = _config.fixture; -} - -/** - * Asserts true. - * @example ok( $("a").size() > 5, "There must be at least 5 anchors" ); - */ -function ok(a, msg) { - _config.Test.push( [ !!a, msg ] ); -} - -/** - * Asserts that two arrays are the same - */ -function isSet(a, b, msg) { - var ret = true; - 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: " + 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 [
, , ] - */ -function q() { - var r = []; - for ( var i = 0; i < arguments.length; i++ ) - r.push( document.getElementById( arguments[i] ) ); - return r; -} - -/** - * Asserts that a select matches the given IDs - * @example t("Check for something", "//[a]", ["foo", "baar"]); - * @result returns true if "//[a]" return two elements with the IDs 'foo' and 'baar' - */ -function t(a,b,c) { - var f = jQuery(b); - var s = ""; - for ( var i = 0; i < f.length; i++ ) - s += (s && ",") + '"' + f[i].id + '"'; - isSet(f, q.apply(q,c), a + " (" + b + ")"); -} - -/** - * 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(actual, expected, message) { - var result = expected == actual; - message = message || (result ? "okay" : "failed"); - _config.Test.push( [ result, result ? message + ": " + expected : message + " expected: " + expected + " actual: " + actual ] ); -} - -/** - * Trigger an event on an element. - * - * @example triggerEvent( document.body, "click" ); - * - * @param DOMElement elem - * @param String type - */ -function triggerEvent( elem, type, event ) { - if ( jQuery.browser.mozilla || jQuery.browser.opera ) { - event = document.createEvent("MouseEvents"); - event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView, - 0, 0, 0, 0, 0, false, false, false, false, 0, null); - elem.dispatchEvent( event ); - } else if ( jQuery.browser.msie ) { - elem.fireEvent("on"+type); - } -} diff --git a/build/test/data/testsuite.css b/build/test/data/testsuite.css deleted file mode 100644 index b9d487bc4..000000000 --- a/build/test/data/testsuite.css +++ /dev/null @@ -1,113 +0,0 @@ -body, div, h1 { font-family: 'trebuchet ms', verdana, arial; margin: 0; padding: 0 } -body {font-size: 10pt; } -h1 { padding: 15px; font-size: large; background-color: #06b; color: white; } -h2 { padding: 10px; background-color: #eee; color: black; margin: 0; font-size: small; font-weight: normal } - -.pass { color: green; } -.fail { color: red; } -p.result { margin-left: 1em; } - -#banner { height: 2em; border-bottom: 1px solid white; } -h2.pass { background-color: green; } -h2.fail { background-color: red; } - -div#fx-tests h4 { - background: red; -} - -div#fx-tests h4.pass { - background: green; -} - -div#fx-tests div.box { - background: red url(data/cow.jpg) no-repeat; - overflow: hidden; - border: 2px solid #000; -} - -div#fx-tests div.overflow { - overflow: visible; -} - -div.inline { - display: inline; -} - -div.autoheight { - height: auto; -} - -div.autowidth { - width: auto; -} - -div.autoopacity { - opacity: auto; -} - -div.largewidth { - width: 100px; -} - -div.largeheight { - height: 100px; -} - -div.largeopacity { - filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100); -} - -div.medwidth { - width: 50px; -} - -div.medheight { - height: 50px; -} - -div.medopacity { - opacity: 0.5; - filter: progid:DXImageTransform.Microsoft.Alpha(opacity=50); -} - -div.nowidth { - width: 0px; -} - -div.noheight { - height: 0px; -} - -div.noopacity { - opacity: 0; - filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0); -} - -div.hidden { - display: none; -} - -div#fx-tests div.widewidth { - background-repeat: repeat-x; -} - -div#fx-tests div.wideheight { - background-repeat: repeat-y; -} - -div#fx-tests div.widewidth.wideheight { - background-repeat: repeat; -} - -div#fx-tests div.noback { - background-image: none; -} - -div.chain, div.chain div { width: 100px; height: 20px; position: relative; float: left; } -div.chain div { position: absolute; top: 0px; left: 0px; } - -div.chain.test { background: red; } -div.chain.test div { background: green; } - -div.chain.out { background: green; } -div.chain.out div { background: red; display: none; } diff --git a/build/test/data/text.php b/build/test/data/text.php deleted file mode 100644 index c06ef4b8e..000000000 --- a/build/test/data/text.php +++ /dev/null @@ -1,12 +0,0 @@ -Lorem ipsum dolor sit amet -consectetuer adipiscing elit -Sed lorem leo -lorem leo consectetuer adipiscing elit -Sed lorem leo -rhoncus sit amet -elementum at -bibendum at, eros -Cras at mi et tortor egestas vestibulum -sed Cras at mi vestibulum -Phasellus sed felis sit amet -orci dapibus semper. diff --git a/build/test/data/with_fries.xml b/build/test/data/with_fries.xml deleted file mode 100644 index 88e0e49d5..000000000 --- a/build/test/data/with_fries.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - 1 - - - - - foo - - - - - - - diff --git a/build/test/index.html b/build/test/index.html deleted file mode 100644 index b2876b7bb..000000000 --- a/build/test/index.html +++ /dev/null @@ -1,157 +0,0 @@ - - - - - jQuery Test Suite - - - - - - - - - - - -

jQuery Test Suite

- -

- - - - -
    - - diff --git a/build/test/test.js b/build/test/test.js deleted file mode 100644 index e76b795a2..000000000 --- a/build/test/test.js +++ /dev/null @@ -1,41 +0,0 @@ -load( "build/js/writeFile.js", "build/js/parse.js" ); - -function addParams(name, params) { - if(params.length > 0) { - name += "("; - for ( var i = 0; i < params.length; i++) { - name += params[i].type + ", "; - } - return name.substring(0, name.length - 2) + ")"; - } else { - return name + "()"; - } -} -function addTestWrapper(name, test) { - return 'test("' + name + '", function() {\n' + test + '\n});'; -} - -var dir = arguments[1]; -var jq = parse( read(arguments[0]) ); - -var testFile = []; - -String.prototype.decode = function() { - return this.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&"); -}; - -for ( var i = 0; i < jq.length; i++ ) { - if ( jq[i].tests.length > 0 ) { - var method = jq[i]; - var name = addParams(method.name, method.params); - for(var j = 0; j < method.tests.length; j++) { - if(j > 0) { - name += "x"; - } - testFile[testFile.length] = addTestWrapper(name, method.tests[j].decode()) + "\n"; - } - } -} - -var indexFile = readFile( "build/test/index.html" ); -writeFile( dir + "/index.html", indexFile.replace( /{TESTS}/g, testFile.join("\n") ) ); -- cgit v1.2.3