Index: trunk/parsers/wikidom/lib/qunit.css |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | /** |
3 | | - * QUnit - A JavaScript Unit Testing Framework |
| 3 | + * QUnit 1.1.0pre - A JavaScript Unit Testing Framework |
4 | 4 | * |
5 | 5 | * http://docs.jquery.com/QUnit |
6 | 6 | * |
— | — | @@ -186,6 +186,7 @@ |
187 | 187 | color: #710909; |
188 | 188 | background-color: #fff; |
189 | 189 | border-left: 26px solid #EE5757; |
| 190 | + white-space: pre; |
190 | 191 | } |
191 | 192 | |
192 | 193 | #qunit-tests > li:last-child { |
— | — | @@ -222,4 +223,4 @@ |
223 | 224 | position: absolute; |
224 | 225 | top: -10000px; |
225 | 226 | left: -10000px; |
226 | | -} |
\ No newline at end of file |
| 227 | +} |
Index: trunk/parsers/wikidom/lib/qunit.js |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | /** |
3 | | - * QUnit - A JavaScript Unit Testing Framework |
| 3 | + * QUnit 1.1.0pre - A JavaScript Unit Testing Framework |
4 | 4 | * |
5 | 5 | * http://docs.jquery.com/QUnit |
6 | 6 | * |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | setup: function() { |
50 | 50 | if (this.module != config.previousModule) { |
51 | 51 | if ( config.previousModule ) { |
52 | | - QUnit.moduleDone( { |
| 52 | + runLoggingCallbacks('moduleDone', QUnit, { |
53 | 53 | name: config.previousModule, |
54 | 54 | failed: config.moduleStats.bad, |
55 | 55 | passed: config.moduleStats.all - config.moduleStats.bad, |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | } |
59 | 59 | config.previousModule = this.module; |
60 | 60 | config.moduleStats = { all: 0, bad: 0 }; |
61 | | - QUnit.moduleStart( { |
| 61 | + runLoggingCallbacks( 'moduleStart', QUnit, { |
62 | 62 | name: this.module |
63 | 63 | } ); |
64 | 64 | } |
— | — | @@ -71,9 +71,10 @@ |
72 | 72 | extend(this.testEnvironment, this.testEnvironmentArg); |
73 | 73 | } |
74 | 74 | |
75 | | - QUnit.testStart( { |
76 | | - name: this.testName |
77 | | - } ); |
| 75 | + runLoggingCallbacks( 'testStart', QUnit, { |
| 76 | + name: this.testName, |
| 77 | + module: this.module |
| 78 | + }); |
78 | 79 | |
79 | 80 | // allow utility functions to access the current test environment |
80 | 81 | // TODO why?? |
— | — | @@ -210,8 +211,9 @@ |
211 | 212 | fail("reset() failed, following Test " + this.testName + ", exception and reset fn follows", e, QUnit.reset); |
212 | 213 | } |
213 | 214 | |
214 | | - QUnit.testDone( { |
| 215 | + runLoggingCallbacks( 'testDone', QUnit, { |
215 | 216 | name: this.testName, |
| 217 | + module: this.module, |
216 | 218 | failed: bad, |
217 | 219 | passed: this.assertions.length - bad, |
218 | 220 | total: this.assertions.length |
— | — | @@ -310,8 +312,8 @@ |
311 | 313 | result: a, |
312 | 314 | message: msg |
313 | 315 | }; |
314 | | - msg = escapeHtml(msg); |
315 | | - QUnit.log(details); |
| 316 | + msg = escapeInnerText(msg); |
| 317 | + runLoggingCallbacks( 'log', QUnit, details ); |
316 | 318 | config.current.assertions.push({ |
317 | 319 | result: a, |
318 | 320 | message: msg |
— | — | @@ -387,8 +389,8 @@ |
388 | 390 | QUnit.ok(ok, message); |
389 | 391 | }, |
390 | 392 | |
391 | | - start: function() { |
392 | | - config.semaphore--; |
| 393 | + start: function(count) { |
| 394 | + config.semaphore -= count || 1; |
393 | 395 | if (config.semaphore > 0) { |
394 | 396 | // don't start until equal number of stop-calls |
395 | 397 | return; |
— | — | @@ -416,20 +418,30 @@ |
417 | 419 | } |
418 | 420 | }, |
419 | 421 | |
420 | | - stop: function(timeout) { |
421 | | - config.semaphore++; |
| 422 | + stop: function(count) { |
| 423 | + config.semaphore += count || 1; |
422 | 424 | config.blocking = true; |
423 | 425 | |
424 | | - if ( timeout && defined.setTimeout ) { |
| 426 | + if ( config.testTimeout && defined.setTimeout ) { |
425 | 427 | clearTimeout(config.timeout); |
426 | 428 | config.timeout = window.setTimeout(function() { |
427 | 429 | QUnit.ok( false, "Test timed out" ); |
| 430 | + config.semaphore = 1; |
428 | 431 | QUnit.start(); |
429 | | - }, timeout); |
| 432 | + }, config.testTimeout); |
430 | 433 | } |
431 | 434 | } |
432 | 435 | }; |
433 | 436 | |
| 437 | +//We want access to the constructor's prototype |
| 438 | +(function() { |
| 439 | + function F(){}; |
| 440 | + F.prototype = QUnit; |
| 441 | + QUnit = new F(); |
| 442 | + //Make F QUnit's constructor so that we can add to the prototype later |
| 443 | + QUnit.constructor = F; |
| 444 | +})(); |
| 445 | + |
434 | 446 | // Backwards compatibility, deprecated |
435 | 447 | QUnit.equals = QUnit.equal; |
436 | 448 | QUnit.same = QUnit.deepEqual; |
— | — | @@ -453,8 +465,16 @@ |
454 | 466 | // by default, modify document.title when suite is done |
455 | 467 | altertitle: true, |
456 | 468 | |
457 | | - noglobals: false, |
458 | | - notrycatch: false |
| 469 | + urlConfig: ['noglobals', 'notrycatch'], |
| 470 | + |
| 471 | + //logging callback queues |
| 472 | + begin: [], |
| 473 | + done: [], |
| 474 | + log: [], |
| 475 | + testStart: [], |
| 476 | + testDone: [], |
| 477 | + moduleStart: [], |
| 478 | + moduleDone: [] |
459 | 479 | }; |
460 | 480 | |
461 | 481 | // Load paramaters |
— | — | @@ -472,9 +492,6 @@ |
473 | 493 | // allow just a key to turn on a flag, e.g., test.html?noglobals |
474 | 494 | current[ 1 ] = current[ 1 ] ? decodeURIComponent( current[ 1 ] ) : true; |
475 | 495 | urlParams[ current[ 0 ] ] = current[ 1 ]; |
476 | | - if ( current[ 0 ] in config ) { |
477 | | - config[ current[ 0 ] ] = current[ 1 ]; |
478 | | - } |
479 | 496 | } |
480 | 497 | } |
481 | 498 | |
— | — | @@ -622,10 +639,10 @@ |
623 | 640 | expected: expected |
624 | 641 | }; |
625 | 642 | |
626 | | - message = escapeHtml(message) || (result ? "okay" : "failed"); |
| 643 | + message = escapeInnerText(message) || (result ? "okay" : "failed"); |
627 | 644 | message = '<span class="test-message">' + message + "</span>"; |
628 | | - expected = escapeHtml(QUnit.jsDump.parse(expected)); |
629 | | - actual = escapeHtml(QUnit.jsDump.parse(actual)); |
| 645 | + expected = escapeInnerText(QUnit.jsDump.parse(expected)); |
| 646 | + actual = escapeInnerText(QUnit.jsDump.parse(actual)); |
630 | 647 | var output = message + '<table><tr class="test-expected"><th>Expected: </th><td><pre>' + expected + '</pre></td></tr>'; |
631 | 648 | if (actual != expected) { |
632 | 649 | output += '<tr class="test-actual"><th>Result: </th><td><pre>' + actual + '</pre></td></tr>'; |
— | — | @@ -635,12 +652,12 @@ |
636 | 653 | var source = sourceFromStacktrace(); |
637 | 654 | if (source) { |
638 | 655 | details.source = source; |
639 | | - output += '<tr class="test-source"><th>Source: </th><td><pre>' + escapeHtml(source) + '</pre></td></tr>'; |
| 656 | + output += '<tr class="test-source"><th>Source: </th><td><pre>' + escapeInnerText(source) + '</pre></td></tr>'; |
640 | 657 | } |
641 | 658 | } |
642 | 659 | output += "</table>"; |
643 | 660 | |
644 | | - QUnit.log(details); |
| 661 | + runLoggingCallbacks( 'log', QUnit, details ); |
645 | 662 | |
646 | 663 | config.current.assertions.push({ |
647 | 664 | result: !!result, |
— | — | @@ -661,23 +678,28 @@ |
662 | 679 | |
663 | 680 | extend: extend, |
664 | 681 | id: id, |
665 | | - addEvent: addEvent, |
| 682 | + addEvent: addEvent |
| 683 | +}); |
666 | 684 | |
| 685 | +//QUnit.constructor is set to the empty F() above so that we can add to it's prototype later |
| 686 | +//Doing this allows us to tell if the following methods have been overwritten on the actual |
| 687 | +//QUnit object, which is a deprecated way of using the callbacks. |
| 688 | +extend(QUnit.constructor.prototype, { |
667 | 689 | // Logging callbacks; all receive a single argument with the listed properties |
668 | 690 | // run test/logs.html for any related changes |
669 | | - begin: function() {}, |
| 691 | + begin: registerLoggingCallback('begin'), |
670 | 692 | // done: { failed, passed, total, runtime } |
671 | | - done: function() {}, |
| 693 | + done: registerLoggingCallback('done'), |
672 | 694 | // log: { result, actual, expected, message } |
673 | | - log: function() {}, |
| 695 | + log: registerLoggingCallback('log'), |
674 | 696 | // testStart: { name } |
675 | | - testStart: function() {}, |
| 697 | + testStart: registerLoggingCallback('testStart'), |
676 | 698 | // testDone: { name, failed, passed, total } |
677 | | - testDone: function() {}, |
| 699 | + testDone: registerLoggingCallback('testDone'), |
678 | 700 | // moduleStart: { name } |
679 | | - moduleStart: function() {}, |
| 701 | + moduleStart: registerLoggingCallback('moduleStart'), |
680 | 702 | // moduleDone: { name, failed, passed, total } |
681 | | - moduleDone: function() {} |
| 703 | + moduleDone: registerLoggingCallback('moduleDone') |
682 | 704 | }); |
683 | 705 | |
684 | 706 | if ( typeof document === "undefined" || document.readyState === "complete" ) { |
— | — | @@ -685,7 +707,7 @@ |
686 | 708 | } |
687 | 709 | |
688 | 710 | QUnit.load = function() { |
689 | | - QUnit.begin({}); |
| 711 | + runLoggingCallbacks( 'begin', QUnit, {} ); |
690 | 712 | |
691 | 713 | // Initialize the config, saving the execution queue |
692 | 714 | var oldconfig = extend({}, config); |
— | — | @@ -694,15 +716,19 @@ |
695 | 717 | |
696 | 718 | config.blocking = false; |
697 | 719 | |
| 720 | + var urlConfigHtml = '', len = config.urlConfig.length; |
| 721 | + for ( var i = 0, val; i < len, val = config.urlConfig[i]; i++ ) { |
| 722 | + config[val] = QUnit.urlParams[val]; |
| 723 | + urlConfigHtml += '<label><input name="' + val + '" type="checkbox"' + ( config[val] ? ' checked="checked"' : '' ) + '>' + val + '</label>'; |
| 724 | + } |
| 725 | + |
698 | 726 | var userAgent = id("qunit-userAgent"); |
699 | 727 | if ( userAgent ) { |
700 | 728 | userAgent.innerHTML = navigator.userAgent; |
701 | 729 | } |
702 | 730 | var banner = id("qunit-header"); |
703 | 731 | if ( banner ) { |
704 | | - banner.innerHTML = '<a href="' + QUnit.url({ filter: undefined }) + '"> ' + banner.innerHTML + '</a> ' + |
705 | | - '<label><input name="noglobals" type="checkbox"' + ( config.noglobals ? ' checked="checked"' : '' ) + '>noglobals</label>' + |
706 | | - '<label><input name="notrycatch" type="checkbox"' + ( config.notrycatch ? ' checked="checked"' : '' ) + '>notrycatch</label>'; |
| 732 | + banner.innerHTML = '<a href="' + QUnit.url({ filter: undefined }) + '"> ' + banner.innerHTML + '</a> ' + urlConfigHtml; |
707 | 733 | addEvent( banner, "change", function( event ) { |
708 | 734 | var params = {}; |
709 | 735 | params[ event.target.name ] = event.target.checked ? true : undefined; |
— | — | @@ -761,7 +787,7 @@ |
762 | 788 | |
763 | 789 | // Log the last module results |
764 | 790 | if ( config.currentModule ) { |
765 | | - QUnit.moduleDone( { |
| 791 | + runLoggingCallbacks( 'moduleDone', QUnit, { |
766 | 792 | name: config.currentModule, |
767 | 793 | failed: config.moduleStats.bad, |
768 | 794 | passed: config.moduleStats.all - config.moduleStats.bad, |
— | — | @@ -803,7 +829,7 @@ |
804 | 830 | ].join(" "); |
805 | 831 | } |
806 | 832 | |
807 | | - QUnit.done( { |
| 833 | + runLoggingCallbacks( 'done', QUnit, { |
808 | 834 | failed: config.stats.bad, |
809 | 835 | passed: passed, |
810 | 836 | total: config.stats.all, |
— | — | @@ -847,20 +873,22 @@ |
848 | 874 | } else if (e.stack) { |
849 | 875 | // Firefox, Chrome |
850 | 876 | return e.stack.split("\n")[4]; |
| 877 | + } else if (e.sourceURL) { |
| 878 | + // Safari, PhantomJS |
| 879 | + // TODO sourceURL points at the 'throw new Error' line above, useless |
| 880 | + //return e.sourceURL + ":" + e.line; |
851 | 881 | } |
852 | 882 | } |
853 | 883 | } |
854 | 884 | |
855 | | -function escapeHtml(s) { |
| 885 | +function escapeInnerText(s) { |
856 | 886 | if (!s) { |
857 | 887 | return ""; |
858 | 888 | } |
859 | 889 | s = s + ""; |
860 | | - return s.replace(/[\&"<>\\]/g, function(s) { |
| 890 | + return s.replace(/[\&<>]/g, function(s) { |
861 | 891 | switch(s) { |
862 | 892 | case "&": return "&"; |
863 | | - case "\\": return "\\\\"; |
864 | | - case '"': return '\"'; |
865 | 893 | case "<": return "<"; |
866 | 894 | case ">": return ">"; |
867 | 895 | default: return s; |
— | — | @@ -970,9 +998,27 @@ |
971 | 999 | document.getElementById( name ); |
972 | 1000 | } |
973 | 1001 | |
| 1002 | +function registerLoggingCallback(key){ |
| 1003 | + return function(callback){ |
| 1004 | + config[key].push( callback ); |
| 1005 | + }; |
| 1006 | +} |
| 1007 | + |
| 1008 | +// Supports deprecated method of completely overwriting logging callbacks |
| 1009 | +function runLoggingCallbacks(key, scope, args) { |
| 1010 | + //debugger; |
| 1011 | + var callbacks; |
| 1012 | + if ( QUnit.hasOwnProperty(key) ) { |
| 1013 | + QUnit[key].call(scope, args); |
| 1014 | + } else { |
| 1015 | + callbacks = config[key]; |
| 1016 | + for( var i = 0; i < callbacks.length; i++ ) { |
| 1017 | + callbacks[i].call( scope, args ); |
| 1018 | + } |
| 1019 | + } |
| 1020 | +} |
| 1021 | + |
974 | 1022 | // Test for equality any JavaScript type. |
975 | | -// Discussions and reference: http://philrathe.com/articles/equiv |
976 | | -// Test suites: http://philrathe.com/tests/equiv |
977 | 1023 | // Author: Philippe Rathé <prathe@gmail.com> |
978 | 1024 | QUnit.equiv = function () { |
979 | 1025 | |
— | — | @@ -1198,10 +1244,10 @@ |
1199 | 1245 | if (type == 'function') { |
1200 | 1246 | stack.push(obj); |
1201 | 1247 | var res = parser.call( this, obj, stack ); |
1202 | | - stack.pop(); |
| 1248 | + stack.pop(); |
1203 | 1249 | return res; |
1204 | | - } |
1205 | | - // else |
| 1250 | + } |
| 1251 | + // else |
1206 | 1252 | return (type == 'string') ? parser : this.parsers.error; |
1207 | 1253 | }, |
1208 | 1254 | typeOf:function( obj ) { |
— | — | @@ -1382,13 +1428,13 @@ |
1383 | 1429 | */ |
1384 | 1430 | QUnit.diff = (function() { |
1385 | 1431 | function diff(o, n) { |
1386 | | - var ns = new Object(); |
1387 | | - var os = new Object(); |
| 1432 | + var ns = {}; |
| 1433 | + var os = {}; |
1388 | 1434 | |
1389 | 1435 | for (var i = 0; i < n.length; i++) { |
1390 | 1436 | if (ns[n[i]] == null) |
1391 | 1437 | ns[n[i]] = { |
1392 | | - rows: new Array(), |
| 1438 | + rows: [], |
1393 | 1439 | o: null |
1394 | 1440 | }; |
1395 | 1441 | ns[n[i]].rows.push(i); |
— | — | @@ -1397,7 +1443,7 @@ |
1398 | 1444 | for (var i = 0; i < o.length; i++) { |
1399 | 1445 | if (os[o[i]] == null) |
1400 | 1446 | os[o[i]] = { |
1401 | | - rows: new Array(), |
| 1447 | + rows: [], |
1402 | 1448 | n: null |
1403 | 1449 | }; |
1404 | 1450 | os[o[i]].rows.push(i); |
— | — | @@ -1503,4 +1549,4 @@ |
1504 | 1550 | }; |
1505 | 1551 | })(); |
1506 | 1552 | |
1507 | | -})(this); |
\ No newline at end of file |
| 1553 | +})(this); |