r94347 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94346‎ | r94347 | r94348 >
Date:14:03, 12 August 2011
Author:krinkle
Status:ok
Tags:
Comment:
Modified paths:
  • /trunk/phase3/resources/jquery/jquery.qunit.css (modified) (history)
  • /trunk/phase3/resources/jquery/jquery.qunit.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/jquery/jquery.qunit.js
@@ -1,6 +1,6 @@
22 /**
33 * QUnit - A JavaScript Unit Testing Framework
4 - *
 4+ *
55 * http://docs.jquery.com/QUnit
66 *
77 * Copyright (c) 2011 John Resig, Jörn Zaefferer
@@ -15,10 +15,10 @@
1616 sessionStorage: (function() {
1717 try {
1818 return !!sessionStorage.getItem;
19 - } catch(e){
 19+ } catch(e) {
2020 return false;
2121 }
22 - })()
 22+ })()
2323 };
2424
2525 var testId = 0;
@@ -78,7 +78,7 @@
7979 // allow utility functions to access the current test environment
8080 // TODO why??
8181 QUnit.current_testEnvironment = this.testEnvironment;
82 -
 82+
8383 try {
8484 if ( !config.pollution ) {
8585 saveGlobal();
@@ -114,8 +114,8 @@
115115 },
116116 teardown: function() {
117117 try {
 118+ this.testEnvironment.teardown.call(this.testEnvironment);
118119 checkPollution();
119 - this.testEnvironment.teardown.call(this.testEnvironment);
120120 } catch(e) {
121121 QUnit.ok( false, "Teardown failed on " + this.testName + ": " + e.message );
122122 }
@@ -124,7 +124,7 @@
125125 if ( this.expected && this.expected != this.assertions.length ) {
126126 QUnit.ok( false, "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run" );
127127 }
128 -
 128+
129129 var good = 0, bad = 0,
130130 tests = id("qunit-tests");
131131
@@ -132,7 +132,7 @@
133133 config.moduleStats.all += this.assertions.length;
134134
135135 if ( tests ) {
136 - var ol = document.createElement("ol");
 136+ var ol = document.createElement("ol");
137137
138138 for ( var i = 0; i < this.assertions.length; i++ ) {
139139 var assertion = this.assertions[i];
@@ -166,17 +166,17 @@
167167
168168 var b = document.createElement("strong");
169169 b.innerHTML = this.name + " <b class='counts'>(<b class='failed'>" + bad + "</b>, <b class='passed'>" + good + "</b>, " + this.assertions.length + ")</b>";
170 -
 170+
171171 var a = document.createElement("a");
172172 a.innerHTML = "Rerun";
173173 a.href = QUnit.url({ filter: getText([b]).replace(/\([^)]+\)$/, "").replace(/(^\s*|\s*$)/g, "") });
174 -
 174+
175175 addEvent(b, "click", function() {
176176 var next = b.nextSibling.nextSibling,
177177 display = next.style.display;
178178 next.style.display = display === "none" ? "block" : "none";
179179 });
180 -
 180+
181181 addEvent(b, "dblclick", function(e) {
182182 var target = e && e.target ? e.target : window.event.srcElement;
183183 if ( target.nodeName.toLowerCase() == "span" || target.nodeName.toLowerCase() == "b" ) {
@@ -217,7 +217,7 @@
218218 total: this.assertions.length
219219 } );
220220 },
221 -
 221+
222222 queue: function() {
223223 var test = this;
224224 synchronize(function() {
@@ -246,7 +246,7 @@
247247 synchronize(run);
248248 };
249249 }
250 -
 250+
251251 };
252252
253253 var QUnit = {
@@ -265,7 +265,7 @@
266266
267267 QUnit.test(testName, expected, callback, true);
268268 },
269 -
 269+
270270 test: function(testName, expected, callback, async) {
271271 var name = '<span class="test-name">' + testName + '</span>', testEnvironmentArg;
272272
@@ -275,7 +275,7 @@
276276 }
277277 // is 2nd argument a testEnvironment?
278278 if ( expected && typeof expected === 'object') {
279 - testEnvironmentArg = expected;
 279+ testEnvironmentArg = expected;
280280 expected = null;
281281 }
282282
@@ -286,13 +286,13 @@
287287 if ( !validTest(config.currentModule + ": " + testName) ) {
288288 return;
289289 }
290 -
 290+
291291 var test = new Test(name, testName, expected, testEnvironmentArg, async, callback);
292292 test.module = config.currentModule;
293293 test.moduleTestEnvironment = config.currentModuleTestEnviroment;
294294 test.queue();
295295 },
296 -
 296+
297297 /**
298298 * Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.
299299 */
@@ -337,7 +337,7 @@
338338 notEqual: function(actual, expected, message) {
339339 QUnit.push(expected != actual, actual, expected, message);
340340 },
341 -
 341+
342342 deepEqual: function(actual, expected, message) {
343343 QUnit.push(QUnit.equiv(actual, expected), actual, expected, message);
344344 },
@@ -356,34 +356,34 @@
357357
358358 raises: function(block, expected, message) {
359359 var actual, ok = false;
360 -
 360+
361361 if (typeof expected === 'string') {
362362 message = expected;
363363 expected = null;
364364 }
365 -
 365+
366366 try {
367367 block();
368368 } catch (e) {
369369 actual = e;
370370 }
371 -
 371+
372372 if (actual) {
373373 // we don't want to validate thrown error
374374 if (!expected) {
375375 ok = true;
376 - // expected is a regexp
 376+ // expected is a regexp
377377 } else if (QUnit.objectType(expected) === "regexp") {
378378 ok = expected.test(actual);
379 - // expected is a constructor
 379+ // expected is a constructor
380380 } else if (actual instanceof expected) {
381381 ok = true;
382 - // expected is a validation function which returns true is validation passed
 382+ // expected is a validation function which returns true is validation passed
383383 } else if (expected.call({}, actual) === true) {
384384 ok = true;
385385 }
386386 }
387 -
 387+
388388 QUnit.ok(ok, message);
389389 },
390390
@@ -400,6 +400,9 @@
401401 // A slight delay, to avoid any current callbacks
402402 if ( defined.setTimeout ) {
403403 window.setTimeout(function() {
 404+ if (config.semaphore > 0) {
 405+ return;
 406+ }
404407 if ( config.timeout ) {
405408 clearTimeout(config.timeout);
406409 }
@@ -412,7 +415,7 @@
413416 process();
414417 }
415418 },
416 -
 419+
417420 stop: function(timeout) {
418421 config.semaphore++;
419422 config.blocking = true;
@@ -438,11 +441,18 @@
439442
440443 // block until document ready
441444 blocking: true,
442 -
 445+
 446+ // when enabled, show only failing tests
 447+ // gets persisted through sessionStorage and can be changed in UI via checkbox
 448+ hidepassed: false,
 449+
443450 // by default, run previously failed tests first
444451 // very useful in combination with "Hide passed tests" checked
445452 reorder: true,
446453
 454+ // by default, modify document.title when suite is done
 455+ altertitle: true,
 456+
447457 noglobals: false,
448458 notrycatch: false
449459 };
@@ -519,7 +529,7 @@
520530 if ( result ) {
521531 result.parentNode.removeChild( result );
522532 }
523 -
 533+
524534 if ( tests ) {
525535 result = document.createElement( "p" );
526536 result.id = "qunit-testresult";
@@ -528,10 +538,10 @@
529539 result.innerHTML = 'Running...<br/>&nbsp;';
530540 }
531541 },
532 -
 542+
533543 /**
534544 * Resets the test setup. Useful for tests that modify the DOM.
535 - *
 545+ *
536546 * If jQuery is available, uses jQuery's html(), otherwise just innerHTML.
537547 */
538548 reset: function() {
@@ -544,7 +554,7 @@
545555 }
546556 }
547557 },
548 -
 558+
549559 /**
550560 * Trigger an event on an element.
551561 *
@@ -564,12 +574,12 @@
565575 elem.fireEvent("on"+type);
566576 }
567577 },
568 -
 578+
569579 // Safe object type checking
570580 is: function( type, obj ) {
571581 return QUnit.objectType( obj ) == type;
572582 },
573 -
 583+
574584 objectType: function( obj ) {
575585 if (typeof obj === "undefined") {
576586 return "undefined";
@@ -603,7 +613,7 @@
604614 }
605615 return undefined;
606616 },
607 -
 617+
608618 push: function(result, actual, expected, message) {
609619 var details = {
610620 result: result,
@@ -611,7 +621,7 @@
612622 actual: actual,
613623 expected: expected
614624 };
615 -
 625+
616626 message = escapeHtml(message) || (result ? "okay" : "failed");
617627 message = '<span class="test-message">' + message + "</span>";
618628 expected = escapeHtml(QUnit.jsDump.parse(expected));
@@ -625,19 +635,19 @@
626636 var source = sourceFromStacktrace();
627637 if (source) {
628638 details.source = source;
629 - output += '<tr class="test-source"><th>Source: </th><td><pre>' + source +'</pre></td></tr>';
 639+ output += '<tr class="test-source"><th>Source: </th><td><pre>' + escapeHtml(source) + '</pre></td></tr>';
630640 }
631641 }
632642 output += "</table>";
633 -
 643+
634644 QUnit.log(details);
635 -
 645+
636646 config.current.assertions.push({
637647 result: !!result,
638648 message: output
639649 });
640650 },
641 -
 651+
642652 url: function( params ) {
643653 params = extend( extend( {}, QUnit.urlParams ), params );
644654 var querystring = "?",
@@ -648,7 +658,11 @@
649659 }
650660 return window.location.pathname + querystring.slice( 0, -1 );
651661 },
652 -
 662+
 663+ extend: extend,
 664+ id: id,
 665+ addEvent: addEvent,
 666+
653667 // Logging callbacks; all receive a single argument with the listed properties
654668 // run test/logs.html for any related changes
655669 begin: function() {},
@@ -670,9 +684,9 @@
671685 config.autorun = true;
672686 }
673687
674 -addEvent(window, "load", function() {
 688+QUnit.load = function() {
675689 QUnit.begin({});
676 -
 690+
677691 // Initialize the config, saving the execution queue
678692 var oldconfig = extend({}, config);
679693 QUnit.init();
@@ -695,7 +709,7 @@
696710 window.location = QUnit.url( params );
697711 });
698712 }
699 -
 713+
700714 var toolbar = id("qunit-testrunner-toolbar");
701715 if ( toolbar ) {
702716 var filter = document.createElement("input");
@@ -711,13 +725,13 @@
712726 }
713727 if ( defined.sessionStorage ) {
714728 if (filter.checked) {
715 - sessionStorage.setItem("qunit-filter-passed-tests", "true");
 729+ sessionStorage.setItem("qunit-filter-passed-tests", "true");
716730 } else {
717731 sessionStorage.removeItem("qunit-filter-passed-tests");
718732 }
719733 }
720734 });
721 - if ( defined.sessionStorage && sessionStorage.getItem("qunit-filter-passed-tests") ) {
 735+ if ( config.hidepassed || defined.sessionStorage && sessionStorage.getItem("qunit-filter-passed-tests") ) {
722736 filter.checked = true;
723737 var ol = document.getElementById("qunit-tests");
724738 ol.className = ol.className + " hidepass";
@@ -738,8 +752,10 @@
739753 if (config.autostart) {
740754 QUnit.start();
741755 }
742 -});
 756+};
743757
 758+addEvent(window, "load", QUnit.load);
 759+
744760 function done() {
745761 config.autorun = true;
746762
@@ -774,13 +790,22 @@
775791 banner.className = (config.stats.bad ? "qunit-fail" : "qunit-pass");
776792 }
777793
778 - if ( tests ) {
 794+ if ( tests ) {
779795 id( "qunit-testresult" ).innerHTML = html;
780796 }
781797
 798+ if ( config.altertitle && typeof document !== "undefined" && document.title ) {
 799+ // show ✖ for good, ✔ for bad suite result in title
 800+ // use escape sequences in case file gets loaded with non-utf-8-charset
 801+ document.title = [
 802+ (config.stats.bad ? "\u2716" : "\u2714"),
 803+ document.title.replace(/^[\u2714\u2716] /i, "")
 804+ ].join(" ");
 805+ }
 806+
782807 QUnit.done( {
783808 failed: config.stats.bad,
784 - passed: passed,
 809+ passed: passed,
785810 total: config.stats.all,
786811 runtime: runtime
787812 } );
@@ -794,7 +819,7 @@
795820 return true;
796821 }
797822
798 - not = filter.charAt( 0 ) === "!";
 823+ var not = filter.charAt( 0 ) === "!";
799824 if ( not ) {
800825 filter = filter.slice( 1 );
801826 }
@@ -862,14 +887,14 @@
863888 break;
864889 }
865890 }
866 - if (!config.blocking && !config.queue.length) {
867 - done();
868 - }
 891+ if (!config.blocking && !config.queue.length) {
 892+ done();
 893+ }
869894 }
870895
871896 function saveGlobal() {
872897 config.pollution = [];
873 -
 898+
874899 if ( config.noglobals ) {
875900 for ( var key in window ) {
876901 config.pollution.push( key );
@@ -880,7 +905,7 @@
881906 function checkPollution( name ) {
882907 var old = config.pollution;
883908 saveGlobal();
884 -
 909+
885910 var newGlobals = diff( config.pollution, old );
886911 if ( newGlobals.length > 0 ) {
887912 ok( false, "Introduced global variable(s): " + newGlobals.join(", ") );
@@ -951,170 +976,182 @@
952977 // Author: Philippe Rathé <prathe@gmail.com>
953978 QUnit.equiv = function () {
954979
955 - var innerEquiv; // the real equiv function
956 - var callers = []; // stack to decide between skip/abort functions
957 - var parents = []; // stack to avoiding loops from circular referencing
 980+ var innerEquiv; // the real equiv function
 981+ var callers = []; // stack to decide between skip/abort functions
 982+ var parents = []; // stack to avoiding loops from circular referencing
958983
959 - // Call the o related callback with the given arguments.
960 - function bindCallbacks(o, callbacks, args) {
961 - var prop = QUnit.objectType(o);
962 - if (prop) {
963 - if (QUnit.objectType(callbacks[prop]) === "function") {
964 - return callbacks[prop].apply(callbacks, args);
965 - } else {
966 - return callbacks[prop]; // or undefined
967 - }
968 - }
969 - }
970 -
971 - var callbacks = function () {
 984+ // Call the o related callback with the given arguments.
 985+ function bindCallbacks(o, callbacks, args) {
 986+ var prop = QUnit.objectType(o);
 987+ if (prop) {
 988+ if (QUnit.objectType(callbacks[prop]) === "function") {
 989+ return callbacks[prop].apply(callbacks, args);
 990+ } else {
 991+ return callbacks[prop]; // or undefined
 992+ }
 993+ }
 994+ }
972995
973 - // for string, boolean, number and null
974 - function useStrictEquality(b, a) {
975 - if (b instanceof a.constructor || a instanceof b.constructor) {
976 - // to catch short annotaion VS 'new' annotation of a declaration
977 - // e.g. var i = 1;
978 - // var j = new Number(1);
979 - return a == b;
980 - } else {
981 - return a === b;
982 - }
983 - }
 996+ var callbacks = function () {
984997
985 - return {
986 - "string": useStrictEquality,
987 - "boolean": useStrictEquality,
988 - "number": useStrictEquality,
989 - "null": useStrictEquality,
990 - "undefined": useStrictEquality,
 998+ // for string, boolean, number and null
 999+ function useStrictEquality(b, a) {
 1000+ if (b instanceof a.constructor || a instanceof b.constructor) {
 1001+ // to catch short annotaion VS 'new' annotation of a
 1002+ // declaration
 1003+ // e.g. var i = 1;
 1004+ // var j = new Number(1);
 1005+ return a == b;
 1006+ } else {
 1007+ return a === b;
 1008+ }
 1009+ }
9911010
992 - "nan": function (b) {
993 - return isNaN(b);
994 - },
 1011+ return {
 1012+ "string" : useStrictEquality,
 1013+ "boolean" : useStrictEquality,
 1014+ "number" : useStrictEquality,
 1015+ "null" : useStrictEquality,
 1016+ "undefined" : useStrictEquality,
9951017
996 - "date": function (b, a) {
997 - return QUnit.objectType(b) === "date" && a.valueOf() === b.valueOf();
998 - },
 1018+ "nan" : function(b) {
 1019+ return isNaN(b);
 1020+ },
9991021
1000 - "regexp": function (b, a) {
1001 - return QUnit.objectType(b) === "regexp" &&
1002 - a.source === b.source && // the regex itself
1003 - a.global === b.global && // and its modifers (gmi) ...
1004 - a.ignoreCase === b.ignoreCase &&
1005 - a.multiline === b.multiline;
1006 - },
 1022+ "date" : function(b, a) {
 1023+ return QUnit.objectType(b) === "date"
 1024+ && a.valueOf() === b.valueOf();
 1025+ },
10071026
1008 - // - skip when the property is a method of an instance (OOP)
1009 - // - abort otherwise,
1010 - // initial === would have catch identical references anyway
1011 - "function": function () {
1012 - var caller = callers[callers.length - 1];
1013 - return caller !== Object &&
1014 - typeof caller !== "undefined";
1015 - },
 1027+ "regexp" : function(b, a) {
 1028+ return QUnit.objectType(b) === "regexp"
 1029+ && a.source === b.source && // the regex itself
 1030+ a.global === b.global && // and its modifers
 1031+ // (gmi) ...
 1032+ a.ignoreCase === b.ignoreCase
 1033+ && a.multiline === b.multiline;
 1034+ },
10161035
1017 - "array": function (b, a) {
1018 - var i, j, loop;
1019 - var len;
 1036+ // - skip when the property is a method of an instance (OOP)
 1037+ // - abort otherwise,
 1038+ // initial === would have catch identical references anyway
 1039+ "function" : function() {
 1040+ var caller = callers[callers.length - 1];
 1041+ return caller !== Object && typeof caller !== "undefined";
 1042+ },
10201043
1021 - // b could be an object literal here
1022 - if ( ! (QUnit.objectType(b) === "array")) {
1023 - return false;
1024 - }
1025 -
1026 - len = a.length;
1027 - if (len !== b.length) { // safe and faster
1028 - return false;
1029 - }
1030 -
1031 - //track reference to avoid circular references
1032 - parents.push(a);
1033 - for (i = 0; i < len; i++) {
1034 - loop = false;
1035 - for(j=0;j<parents.length;j++){
1036 - if(parents[j] === a[i]){
1037 - loop = true;//dont rewalk array
1038 - }
1039 - }
1040 - if (!loop && ! innerEquiv(a[i], b[i])) {
1041 - parents.pop();
1042 - return false;
1043 - }
1044 - }
1045 - parents.pop();
1046 - return true;
1047 - },
 1044+ "array" : function(b, a) {
 1045+ var i, j, loop;
 1046+ var len;
10481047
1049 - "object": function (b, a) {
1050 - var i, j, loop;
1051 - var eq = true; // unless we can proove it
1052 - var aProperties = [], bProperties = []; // collection of strings
 1048+ // b could be an object literal here
 1049+ if (!(QUnit.objectType(b) === "array")) {
 1050+ return false;
 1051+ }
10531052
1054 - // comparing constructors is more strict than using instanceof
1055 - if ( a.constructor !== b.constructor) {
1056 - return false;
1057 - }
 1053+ len = a.length;
 1054+ if (len !== b.length) { // safe and faster
 1055+ return false;
 1056+ }
10581057
1059 - // stack constructor before traversing properties
1060 - callers.push(a.constructor);
1061 - //track reference to avoid circular references
1062 - parents.push(a);
1063 -
1064 - for (i in a) { // be strict: don't ensures hasOwnProperty and go deep
1065 - loop = false;
1066 - for(j=0;j<parents.length;j++){
1067 - if(parents[j] === a[i])
1068 - loop = true; //don't go down the same path twice
1069 - }
1070 - aProperties.push(i); // collect a's properties
 1058+ // track reference to avoid circular references
 1059+ parents.push(a);
 1060+ for (i = 0; i < len; i++) {
 1061+ loop = false;
 1062+ for (j = 0; j < parents.length; j++) {
 1063+ if (parents[j] === a[i]) {
 1064+ loop = true;// dont rewalk array
 1065+ }
 1066+ }
 1067+ if (!loop && !innerEquiv(a[i], b[i])) {
 1068+ parents.pop();
 1069+ return false;
 1070+ }
 1071+ }
 1072+ parents.pop();
 1073+ return true;
 1074+ },
10711075
1072 - if (!loop && ! innerEquiv(a[i], b[i])) {
1073 - eq = false;
1074 - break;
1075 - }
1076 - }
 1076+ "object" : function(b, a) {
 1077+ var i, j, loop;
 1078+ var eq = true; // unless we can proove it
 1079+ var aProperties = [], bProperties = []; // collection of
 1080+ // strings
10771081
1078 - callers.pop(); // unstack, we are done
1079 - parents.pop();
 1082+ // comparing constructors is more strict than using
 1083+ // instanceof
 1084+ if (a.constructor !== b.constructor) {
 1085+ return false;
 1086+ }
10801087
1081 - for (i in b) {
1082 - bProperties.push(i); // collect b's properties
1083 - }
 1088+ // stack constructor before traversing properties
 1089+ callers.push(a.constructor);
 1090+ // track reference to avoid circular references
 1091+ parents.push(a);
10841092
1085 - // Ensures identical properties name
1086 - return eq && innerEquiv(aProperties.sort(), bProperties.sort());
1087 - }
1088 - };
1089 - }();
 1093+ for (i in a) { // be strict: don't ensures hasOwnProperty
 1094+ // and go deep
 1095+ loop = false;
 1096+ for (j = 0; j < parents.length; j++) {
 1097+ if (parents[j] === a[i])
 1098+ loop = true; // don't go down the same path
 1099+ // twice
 1100+ }
 1101+ aProperties.push(i); // collect a's properties
10901102
1091 - innerEquiv = function () { // can take multiple arguments
1092 - var args = Array.prototype.slice.apply(arguments);
1093 - if (args.length < 2) {
1094 - return true; // end transition
1095 - }
 1103+ if (!loop && !innerEquiv(a[i], b[i])) {
 1104+ eq = false;
 1105+ break;
 1106+ }
 1107+ }
10961108
1097 - return (function (a, b) {
1098 - if (a === b) {
1099 - return true; // catch the most you can
1100 - } else if (a === null || b === null || typeof a === "undefined" || typeof b === "undefined" || QUnit.objectType(a) !== QUnit.objectType(b)) {
1101 - return false; // don't lose time with error prone cases
1102 - } else {
1103 - return bindCallbacks(a, callbacks, [b, a]);
1104 - }
 1109+ callers.pop(); // unstack, we are done
 1110+ parents.pop();
11051111
1106 - // apply transition with (1..n) arguments
1107 - })(args[0], args[1]) && arguments.callee.apply(this, args.splice(1, args.length -1));
1108 - };
 1112+ for (i in b) {
 1113+ bProperties.push(i); // collect b's properties
 1114+ }
11091115
1110 - return innerEquiv;
 1116+ // Ensures identical properties name
 1117+ return eq
 1118+ && innerEquiv(aProperties.sort(), bProperties
 1119+ .sort());
 1120+ }
 1121+ };
 1122+ }();
11111123
 1124+ innerEquiv = function() { // can take multiple arguments
 1125+ var args = Array.prototype.slice.apply(arguments);
 1126+ if (args.length < 2) {
 1127+ return true; // end transition
 1128+ }
 1129+
 1130+ return (function(a, b) {
 1131+ if (a === b) {
 1132+ return true; // catch the most you can
 1133+ } else if (a === null || b === null || typeof a === "undefined"
 1134+ || typeof b === "undefined"
 1135+ || QUnit.objectType(a) !== QUnit.objectType(b)) {
 1136+ return false; // don't lose time with error prone cases
 1137+ } else {
 1138+ return bindCallbacks(a, callbacks, [ b, a ]);
 1139+ }
 1140+
 1141+ // apply transition with (1..n) arguments
 1142+ })(args[0], args[1])
 1143+ && arguments.callee.apply(this, args.splice(1,
 1144+ args.length - 1));
 1145+ };
 1146+
 1147+ return innerEquiv;
 1148+
11121149 }();
11131150
11141151 /**
1115 - * jsDump
1116 - * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
1117 - * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
1118 - * Date: 5/15/2008
 1152+ * jsDump Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com |
 1153+ * http://flesler.blogspot.com Licensed under BSD
 1154+ * (http://www.opensource.org/licenses/bsd-license.php) Date: 5/15/2008
 1155+ *
11191156 * @projectDescription Advanced and extensible data dumping for Javascript.
11201157 * @version 1.0.0
11211158 * @author Ariel Flesler
@@ -1125,7 +1162,7 @@
11261163 return '"' + str.toString().replace(/"/g, '\\"') + '"';
11271164 };
11281165 function literal( o ) {
1129 - return o + '';
 1166+ return o + '';
11301167 };
11311168 function join( pre, arr, post ) {
11321169 var s = jsDump.separator(),
@@ -1137,25 +1174,35 @@
11381175 return pre + post;
11391176 return [ pre, inner + arr, base + post ].join(s);
11401177 };
1141 - function array( arr ) {
1142 - var i = arr.length, ret = Array(i);
 1178+ function array( arr, stack ) {
 1179+ var i = arr.length, ret = Array(i);
11431180 this.up();
11441181 while ( i-- )
1145 - ret[i] = this.parse( arr[i] );
 1182+ ret[i] = this.parse( arr[i] , undefined , stack);
11461183 this.down();
11471184 return join( '[', ret, ']' );
11481185 };
1149 -
 1186+
11501187 var reName = /^function (\w+)/;
1151 -
 1188+
11521189 var jsDump = {
1153 - parse:function( obj, type ) { //type is used mostly internally, you can fix a (custom)type in advance
1154 - var parser = this.parsers[ type || this.typeOf(obj) ];
1155 - type = typeof parser;
1156 -
1157 - return type == 'function' ? parser.call( this, obj ) :
1158 - type == 'string' ? parser :
1159 - this.parsers.error;
 1190+ parse:function( obj, type, stack ) { //type is used mostly internally, you can fix a (custom)type in advance
 1191+ stack = stack || [ ];
 1192+ var parser = this.parsers[ type || this.typeOf(obj) ];
 1193+ type = typeof parser;
 1194+ var inStack = inArray(obj, stack);
 1195+ if (inStack != -1) {
 1196+ return 'recursion('+(inStack - stack.length)+')';
 1197+ }
 1198+ //else
 1199+ if (type == 'function') {
 1200+ stack.push(obj);
 1201+ var res = parser.call( this, obj, stack );
 1202+ stack.pop();
 1203+ return res;
 1204+ }
 1205+ // else
 1206+ return (type == 'string') ? parser : this.parsers.error;
11601207 },
11611208 typeOf:function( obj ) {
11621209 var type;
@@ -1203,7 +1250,7 @@
12041251 this.parsers[name] = parser;
12051252 },
12061253 // The next 3 are exposed so you can use them
1207 - quote:quote,
 1254+ quote:quote,
12081255 literal:literal,
12091256 join:join,
12101257 //
@@ -1222,28 +1269,30 @@
12231270 if ( name )
12241271 ret += ' ' + name;
12251272 ret += '(';
1226 -
 1273+
12271274 ret = [ ret, QUnit.jsDump.parse( fn, 'functionArgs' ), '){'].join('');
12281275 return join( ret, QUnit.jsDump.parse(fn,'functionCode'), '}' );
12291276 },
12301277 array: array,
12311278 nodelist: array,
12321279 arguments: array,
1233 - object:function( map ) {
 1280+ object:function( map, stack ) {
12341281 var ret = [ ];
12351282 QUnit.jsDump.up();
1236 - for ( var key in map )
1237 - ret.push( QUnit.jsDump.parse(key,'key') + ': ' + QUnit.jsDump.parse(map[key]) );
 1283+ for ( var key in map ) {
 1284+ var val = map[key];
 1285+ ret.push( QUnit.jsDump.parse(key,'key') + ': ' + QUnit.jsDump.parse(val, undefined, stack));
 1286+ }
12381287 QUnit.jsDump.down();
12391288 return join( '{', ret, '}' );
12401289 },
12411290 node:function( node ) {
12421291 var open = QUnit.jsDump.HTML ? '&lt;' : '<',
12431292 close = QUnit.jsDump.HTML ? '&gt;' : '>';
1244 -
 1293+
12451294 var tag = node.nodeName.toLowerCase(),
12461295 ret = open + tag;
1247 -
 1296+
12481297 for ( var a in QUnit.jsDump.DOMAttrs ) {
12491298 var val = node[QUnit.jsDump.DOMAttrs[a]];
12501299 if ( val )
@@ -1253,8 +1302,8 @@
12541303 },
12551304 functionArgs:function( fn ) {//function calls it internally, it's the arguments part of the function
12561305 var l = fn.length;
1257 - if ( !l ) return '';
1258 -
 1306+ if ( !l ) return '';
 1307+
12591308 var args = Array(l);
12601309 while ( l-- )
12611310 args[l] = String.fromCharCode(97+l);//97 is 'a'
@@ -1302,6 +1351,21 @@
13031352 return ret;
13041353 };
13051354
 1355+//from jquery.js
 1356+function inArray( elem, array ) {
 1357+ if ( array.indexOf ) {
 1358+ return array.indexOf( elem );
 1359+ }
 1360+
 1361+ for ( var i = 0, length = array.length; i < length; i++ ) {
 1362+ if ( array[ i ] === elem ) {
 1363+ return i;
 1364+ }
 1365+ }
 1366+
 1367+ return -1;
 1368+}
 1369+
13061370 /*
13071371 * Javascript Diff Algorithm
13081372 * By John Resig (http://ejohn.org/)
@@ -1311,34 +1375,34 @@
13121376 *
13131377 * More Info:
13141378 * http://ejohn.org/projects/javascript-diff-algorithm/
1315 - *
 1379+ *
13161380 * Usage: QUnit.diff(expected, actual)
1317 - *
 1381+ *
13181382 * QUnit.diff("the quick brown fox jumped over", "the quick fox jumps over") == "the quick <del>brown </del> fox <del>jumped </del><ins>jumps </ins> over"
13191383 */
13201384 QUnit.diff = (function() {
1321 - function diff(o, n){
 1385+ function diff(o, n) {
13221386 var ns = new Object();
13231387 var os = new Object();
1324 -
 1388+
13251389 for (var i = 0; i < n.length; i++) {
1326 - if (ns[n[i]] == null)
 1390+ if (ns[n[i]] == null)
13271391 ns[n[i]] = {
13281392 rows: new Array(),
13291393 o: null
13301394 };
13311395 ns[n[i]].rows.push(i);
13321396 }
1333 -
 1397+
13341398 for (var i = 0; i < o.length; i++) {
1335 - if (os[o[i]] == null)
 1399+ if (os[o[i]] == null)
13361400 os[o[i]] = {
13371401 rows: new Array(),
13381402 n: null
13391403 };
13401404 os[o[i]].rows.push(i);
13411405 }
1342 -
 1406+
13431407 for (var i in ns) {
13441408 if (ns[i].rows.length == 1 && typeof(os[i]) != "undefined" && os[i].rows.length == 1) {
13451409 n[ns[i].rows[0]] = {
@@ -1351,7 +1415,7 @@
13521416 };
13531417 }
13541418 }
1355 -
 1419+
13561420 for (var i = 0; i < n.length - 1; i++) {
13571421 if (n[i].text != null && n[i + 1].text == null && n[i].row + 1 < o.length && o[n[i].row + 1].text == null &&
13581422 n[i + 1] == o[n[i].row + 1]) {
@@ -1365,7 +1429,7 @@
13661430 };
13671431 }
13681432 }
1369 -
 1433+
13701434 for (var i = n.length - 1; i > 0; i--) {
13711435 if (n[i].text != null && n[i - 1].text == null && n[i].row > 0 && o[n[i].row - 1].text == null &&
13721436 n[i - 1] == o[n[i].row - 1]) {
@@ -1379,20 +1443,20 @@
13801444 };
13811445 }
13821446 }
1383 -
 1447+
13841448 return {
13851449 o: o,
13861450 n: n
13871451 };
13881452 }
1389 -
1390 - return function(o, n){
 1453+
 1454+ return function(o, n) {
13911455 o = o.replace(/\s+$/, '');
13921456 n = n.replace(/\s+$/, '');
13931457 var out = diff(o == "" ? [] : o.split(/\s+/), n == "" ? [] : n.split(/\s+/));
13941458
13951459 var str = "";
1396 -
 1460+
13971461 var oSpace = o.match(/\s+/g);
13981462 if (oSpace == null) {
13991463 oSpace = [" "];
@@ -1407,7 +1471,7 @@
14081472 else {
14091473 nSpace.push(" ");
14101474 }
1411 -
 1475+
14121476 if (out.n.length == 0) {
14131477 for (var i = 0; i < out.o.length; i++) {
14141478 str += '<del>' + out.o[i] + oSpace[i] + "</del>";
@@ -1419,14 +1483,14 @@
14201484 str += '<del>' + out.o[n] + oSpace[n] + "</del>";
14211485 }
14221486 }
1423 -
 1487+
14241488 for (var i = 0; i < out.n.length; i++) {
14251489 if (out.n[i].text == null) {
14261490 str += '<ins>' + out.n[i] + nSpace[i] + "</ins>";
14271491 }
14281492 else {
14291493 var pre = "";
1430 -
 1494+
14311495 for (n = out.n[i].row + 1; n < out.o.length && out.o[n].text == null; n++) {
14321496 pre += '<del>' + out.o[n] + oSpace[n] + "</del>";
14331497 }
@@ -1434,9 +1498,9 @@
14351499 }
14361500 }
14371501 }
1438 -
 1502+
14391503 return str;
14401504 };
14411505 })();
14421506
1443 -})(this);
\ No newline at end of file
 1507+})(this);
Index: trunk/phase3/resources/jquery/jquery.qunit.css
@@ -1,9 +1,9 @@
22 /**
33 * QUnit - A JavaScript Unit Testing Framework
4 - *
 4+ *
55 * http://docs.jquery.com/QUnit
66 *
7 - * Copyright (c) 2011 John Resig, Jörn Zaefferer
 7+ * Copyright (c) 2011 John Resig, Jörn Zaefferer
88 * Dual licensed under the MIT (MIT-LICENSE.txt)
99 * or GPL (GPL-LICENSE.txt) licenses.
1010 */
@@ -11,7 +11,7 @@
1212 /** Font Family and Sizes */
1313
1414 #qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
15 - font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
 15+ font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
1616 }
1717
1818 #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
@@ -37,7 +37,7 @@
3838 font-size: 1.5em;
3939 line-height: 1em;
4040 font-weight: normal;
41 -
 41+
4242 border-radius: 15px 15px 0 0;
4343 -moz-border-radius: 15px 15px 0 0;
4444 -webkit-border-top-right-radius: 15px;
@@ -105,13 +105,13 @@
106106 #qunit-tests ol {
107107 margin-top: 0.5em;
108108 padding: 0.5em;
109 -
 109+
110110 background-color: #fff;
111 -
 111+
112112 border-radius: 15px;
113113 -moz-border-radius: 15px;
114114 -webkit-border-radius: 15px;
115 -
 115+
116116 box-shadow: inset 0px 2px 13px #999;
117117 -moz-box-shadow: inset 0px 2px 13px #999;
118118 -webkit-box-shadow: inset 0px 2px 13px #999;
@@ -174,7 +174,7 @@
175175
176176 #qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
177177 #qunit-tests .pass .test-name { color: #366097; }
178 -
 178+
179179 #qunit-tests .pass .test-actual,
180180 #qunit-tests .pass .test-expected { color: #999999; }
181181
@@ -186,6 +186,7 @@
187187 color: #710909;
188188 background-color: #fff;
189189 border-left: 26px solid #EE5757;
 190+ white-space: pre;
190191 }
191192
192193 #qunit-tests > li:last-child {
@@ -222,4 +223,4 @@
223224 position: absolute;
224225 top: -10000px;
225226 left: -10000px;
226 -}
\ No newline at end of file
 227+}

Status & tagging log