2 * QUnit v1.10.0 - A JavaScript Unit Testing Framework
6 * Copyright 2012 jQuery Foundation and other contributors
7 * Released under the MIT license.
8 * http://jquery.org/license
17 fileName
= (sourceFromStacktrace( 0 ) || "" ).replace(/(:\d+)+\)?/, "").replace(/.+\//, ""),
18 toString
= Object
.prototype.toString
,
19 hasOwn
= Object
.prototype.hasOwnProperty
,
20 // Keep a local reference to Date (GH-283)
23 setTimeout
: typeof window
.setTimeout
!== "undefined",
24 sessionStorage
: (function() {
25 var x
= "qunit-test-string";
27 sessionStorage
.setItem( x
, x
);
28 sessionStorage
.removeItem( x
);
36 function Test( settings
) {
37 extend( this, settings
);
39 this.testNumber
= ++Test
.count
;
47 tests
= id( "qunit-tests" );
50 b
= document
.createElement( "strong" );
51 b
.innerHTML
= this.name
;
53 // `a` initialized at top of scope
54 a
= document
.createElement( "a" );
55 a
.innerHTML
= "Rerun";
56 a
.href
= QUnit
.url({ testNumber
: this.testNumber
});
58 li
= document
.createElement( "li" );
61 li
.className
= "running";
62 li
.id
= this.id
= "qunit-test-output" + testId
++;
64 tests
.appendChild( li
);
68 if ( this.module
!== config
.previousModule
) {
69 if ( config
.previousModule
) {
70 runLoggingCallbacks( "moduleDone", QUnit
, {
71 name
: config
.previousModule
,
72 failed
: config
.moduleStats
.bad
,
73 passed
: config
.moduleStats
.all
- config
.moduleStats
.bad
,
74 total
: config
.moduleStats
.all
77 config
.previousModule
= this.module
;
78 config
.moduleStats
= { all
: 0, bad
: 0 };
79 runLoggingCallbacks( "moduleStart", QUnit
, {
82 } else if ( config
.autorun
) {
83 runLoggingCallbacks( "moduleStart", QUnit
, {
88 config
.current
= this;
90 this.testEnvironment
= extend({
92 teardown: function() {}
93 }, this.moduleTestEnvironment
);
95 runLoggingCallbacks( "testStart", QUnit
, {
100 // allow utility functions to access the current test environment
102 QUnit
.current_testEnvironment
= this.testEnvironment
;
104 if ( !config
.pollution
) {
107 if ( config
.notrycatch
) {
108 this.testEnvironment
.setup
.call( this.testEnvironment
);
112 this.testEnvironment
.setup
.call( this.testEnvironment
);
114 QUnit
.pushFailure( "Setup failed on " + this.testName
+ ": " + e
.message
, extractStacktrace( e
, 1 ) );
118 config
.current
= this;
120 var running
= id( "qunit-testresult" );
123 running
.innerHTML
= "Running: <br/>" + this.name
;
130 if ( config
.notrycatch
) {
131 this.callback
.call( this.testEnvironment
, QUnit
.assert
);
136 this.callback
.call( this.testEnvironment
, QUnit
.assert
);
138 QUnit
.pushFailure( "Died on test #" + (this.assertions
.length
+ 1) + " " + this.stack
+ ": " + e
.message
, extractStacktrace( e
, 0 ) );
139 // else next test will carry the responsibility
142 // Restart the tests if they're blocking
143 if ( config
.blocking
) {
148 teardown: function() {
149 config
.current
= this;
150 if ( config
.notrycatch
) {
151 this.testEnvironment
.teardown
.call( this.testEnvironment
);
155 this.testEnvironment
.teardown
.call( this.testEnvironment
);
157 QUnit
.pushFailure( "Teardown failed on " + this.testName
+ ": " + e
.message
, extractStacktrace( e
, 1 ) );
163 config
.current
= this;
164 if ( config
.requireExpects
&& this.expected
== null ) {
165 QUnit
.pushFailure( "Expected number of assertions to be defined, but expect() was not called.", this.stack
);
166 } else if ( this.expected
!= null && this.expected
!= this.assertions
.length
) {
167 QUnit
.pushFailure( "Expected " + this.expected
+ " assertions, but " + this.assertions
.length
+ " were run", this.stack
);
168 } else if ( this.expected
== null && !this.assertions
.length
) {
169 QUnit
.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.", this.stack
);
172 var assertion
, a
, b
, i
, li
, ol
,
176 tests
= id( "qunit-tests" );
178 config
.stats
.all
+= this.assertions
.length
;
179 config
.moduleStats
.all
+= this.assertions
.length
;
182 ol
= document
.createElement( "ol" );
184 for ( i
= 0; i
< this.assertions
.length
; i
++ ) {
185 assertion
= this.assertions
[i
];
187 li
= document
.createElement( "li" );
188 li
.className
= assertion
.result
? "pass" : "fail";
189 li
.innerHTML
= assertion
.message
|| ( assertion
.result
? "okay" : "failed" );
190 ol
.appendChild( li
);
192 if ( assertion
.result
) {
197 config
.moduleStats
.bad
++;
201 // store result when possible
202 if ( QUnit
.config
.reorder
&& defined
.sessionStorage
) {
204 sessionStorage
.setItem( "qunit-test-" + this.module
+ "-" + this.testName
, bad
);
206 sessionStorage
.removeItem( "qunit-test-" + this.module
+ "-" + this.testName
);
211 ol
.style
.display
= "none";
214 // `b` initialized at top of scope
215 b
= document
.createElement( "strong" );
216 b
.innerHTML
= this.name
+ " <b class='counts'>(<b class='failed'>" + bad
+ "</b>, <b class='passed'>" + good
+ "</b>, " + this.assertions
.length
+ ")</b>";
218 addEvent(b
, "click", function() {
219 var next
= b
.nextSibling
.nextSibling
,
220 display
= next
.style
.display
;
221 next
.style
.display
= display
=== "none" ? "block" : "none";
224 addEvent(b
, "dblclick", function( e
) {
225 var target
= e
&& e
.target
? e
.target
: window
.event
.srcElement
;
226 if ( target
.nodeName
.toLowerCase() == "span" || target
.nodeName
.toLowerCase() == "b" ) {
227 target
= target
.parentNode
;
229 if ( window
.location
&& target
.nodeName
.toLowerCase() === "strong" ) {
230 window
.location
= QUnit
.url({ testNumber
: test
.testNumber
});
234 // `li` initialized at top of scope
236 li
.className
= bad
? "fail" : "pass";
237 li
.removeChild( li
.firstChild
);
240 li
.appendChild ( a
);
241 li
.appendChild( ol
);
244 for ( i
= 0; i
< this.assertions
.length
; i
++ ) {
245 if ( !this.assertions
[i
].result
) {
248 config
.moduleStats
.bad
++;
253 runLoggingCallbacks( "testDone", QUnit
, {
257 passed
: this.assertions
.length
- bad
,
258 total
: this.assertions
.length
263 config
.current
= undefined;
270 synchronize(function() {
274 // each of these can by async
275 synchronize(function() {
278 synchronize(function() {
281 synchronize(function() {
284 synchronize(function() {
289 // `bad` initialized at top of scope
290 // defer when previous test run passed, if storage is available
291 bad
= QUnit
.config
.reorder
&& defined
.sessionStorage
&&
292 +sessionStorage
.getItem( "qunit-test-" + this.module
+ "-" + this.testName
);
297 synchronize( run
, true );
302 // Root QUnit object.
303 // `QUnit` initialized at top of scope
306 // call on start of module test to prepend name to all tests
307 module: function( name
, testEnvironment
) {
308 config
.currentModule
= name
;
309 config
.currentModuleTestEnvironment
= testEnvironment
;
310 config
.modules
[name
] = true;
313 asyncTest: function( testName
, expected
, callback
) {
314 if ( arguments
.length
=== 2 ) {
319 QUnit
.test( testName
, expected
, callback
, true );
322 test: function( testName
, expected
, callback
, async
) {
324 name
= "<span class='test-name'>" + escapeInnerText( testName
) + "</span>";
326 if ( arguments
.length
=== 2 ) {
331 if ( config
.currentModule
) {
332 name
= "<span class='module-name'>" + config
.currentModule
+ "</span>: " + name
;
341 module
: config
.currentModule
,
342 moduleTestEnvironment
: config
.currentModuleTestEnvironment
,
343 stack
: sourceFromStacktrace( 2 )
346 if ( !validTest( test
) ) {
353 // Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.
354 expect: function( asserts
) {
355 if (arguments
.length
=== 1) {
356 config
.current
.expected
= asserts
;
358 return config
.current
.expected
;
362 start: function( count
) {
363 config
.semaphore
-= count
|| 1;
364 // don't start until equal number of stop-calls
365 if ( config
.semaphore
> 0 ) {
368 // ignore if start is called more often then stop
369 if ( config
.semaphore
< 0 ) {
370 config
.semaphore
= 0;
372 // A slight delay, to avoid any current callbacks
373 if ( defined
.setTimeout
) {
374 window
.setTimeout(function() {
375 if ( config
.semaphore
> 0 ) {
378 if ( config
.timeout
) {
379 clearTimeout( config
.timeout
);
382 config
.blocking
= false;
386 config
.blocking
= false;
391 stop: function( count
) {
392 config
.semaphore
+= count
|| 1;
393 config
.blocking
= true;
395 if ( config
.testTimeout
&& defined
.setTimeout
) {
396 clearTimeout( config
.timeout
);
397 config
.timeout
= window
.setTimeout(function() {
398 QUnit
.ok( false, "Test timed out" );
399 config
.semaphore
= 1;
401 }, config
.testTimeout
);
407 // All of these must call either QUnit.push() or manually do:
408 // - runLoggingCallbacks( "log", .. );
409 // - config.current.assertions.push({ .. });
412 * Asserts rough true-ish result.
415 * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
417 ok: function( result
, msg
) {
418 if ( !config
.current
) {
419 throw new Error( "ok() assertion outside test context, was " + sourceFromStacktrace(2) );
425 module
: config
.current
.module
,
426 name
: config
.current
.testName
,
431 msg
= escapeInnerText( msg
|| (result
? "okay" : "failed" ) );
432 msg
= "<span class='test-message'>" + msg
+ "</span>";
435 source
= sourceFromStacktrace( 2 );
437 details
.source
= source
;
438 msg
+= "<table><tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source
) + "</pre></td></tr></table>";
441 runLoggingCallbacks( "log", QUnit
, details
);
442 config
.current
.assertions
.push({
449 * Assert that the first two arguments are equal, with an optional message.
450 * Prints out both actual and expected values.
453 * @example equal( format( "Received {0} bytes.", 2), "Received 2 bytes.", "format() replaces {0} with next argument" );
455 equal: function( actual
, expected
, message
) {
456 QUnit
.push( expected
== actual
, actual
, expected
, message
);
463 notEqual: function( actual
, expected
, message
) {
464 QUnit
.push( expected
!= actual
, actual
, expected
, message
);
471 deepEqual: function( actual
, expected
, message
) {
472 QUnit
.push( QUnit
.equiv(actual
, expected
), actual
, expected
, message
);
479 notDeepEqual: function( actual
, expected
, message
) {
480 QUnit
.push( !QUnit
.equiv(actual
, expected
), actual
, expected
, message
);
487 strictEqual: function( actual
, expected
, message
) {
488 QUnit
.push( expected
=== actual
, actual
, expected
, message
);
492 * @name notStrictEqual
495 notStrictEqual: function( actual
, expected
, message
) {
496 QUnit
.push( expected
!== actual
, actual
, expected
, message
);
499 throws: function( block
, expected
, message
) {
503 // 'expected' is optional
504 if ( typeof expected
=== "string" ) {
509 config
.current
.ignoreGlobalErrors
= true;
511 block
.call( config
.current
.testEnvironment
);
515 config
.current
.ignoreGlobalErrors
= false;
518 // we don't want to validate thrown error
521 // expected is a regexp
522 } else if ( QUnit
.objectType( expected
) === "regexp" ) {
523 ok
= expected
.test( actual
);
524 // expected is a constructor
525 } else if ( actual
instanceof expected
) {
527 // expected is a validation function which returns true is validation passed
528 } else if ( expected
.call( {}, actual
) === true ) {
532 QUnit
.push( ok
, actual
, null, message
);
534 QUnit
.pushFailure( message
, null, 'No exception was thrown.' );
540 * @deprecate since 1.8.0
541 * Kept assertion helpers in root for backwards compatibility
543 extend( QUnit
, QUnit
.assert
);
546 * @deprecated since 1.9.0
547 * Kept global "raises()" for backwards compatibility
549 QUnit
.raises
= QUnit
.assert
.throws;
552 * @deprecated since 1.0.0, replaced with error pushes since 1.3.0
553 * Kept to avoid TypeErrors for undefined methods.
555 QUnit
.equals = function() {
556 QUnit
.push( false, false, false, "QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead" );
558 QUnit
.same = function() {
559 QUnit
.push( false, false, false, "QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead" );
562 // We want access to the constructor's prototype
567 // Make F QUnit's constructor so that we can add to the prototype later
568 QUnit
.constructor = F
;
572 * Config object: Maintain internal state
573 * Later exposed as QUnit.config
574 * `config` initialized at top of scope
577 // The queue of tests to run
580 // block until document ready
583 // when enabled, show only failing tests
584 // gets persisted through sessionStorage and can be changed in UI via checkbox
587 // by default, run previously failed tests first
588 // very useful in combination with "Hide passed tests" checked
591 // by default, modify document.title when suite is done
594 // when enabled, all tests must call expect()
595 requireExpects
: false,
597 // add checkboxes that are persisted in the query-string
598 // when enabled, the id is set to `true` as a `QUnit.config` property
602 label
: "Check for Globals",
603 tooltip
: "Enabling this will test if any test introduces new properties on the `window` object. Stored as query-strings."
607 label
: "No try-catch",
608 tooltip
: "Enabling this will run tests outside of a try-catch block. Makes debugging exceptions in IE reasonable. Stored as query-strings."
612 // Set of all modules.
615 // logging callback queues
625 // Initialize more QUnit.config and QUnit.urlParams
628 location
= window
.location
|| { search
: "", protocol
: "file:" },
629 params
= location
.search
.slice( 1 ).split( "&" ),
630 length
= params
.length
,
635 for ( i
= 0; i
< length
; i
++ ) {
636 current
= params
[ i
].split( "=" );
637 current
[ 0 ] = decodeURIComponent( current
[ 0 ] );
638 // allow just a key to turn on a flag, e.g., test.html?noglobals
639 current
[ 1 ] = current
[ 1 ] ? decodeURIComponent( current
[ 1 ] ) : true;
640 urlParams
[ current
[ 0 ] ] = current
[ 1 ];
644 QUnit
.urlParams
= urlParams
;
646 // String search anywhere in moduleName+testName
647 config
.filter
= urlParams
.filter
;
649 // Exact match of the module name
650 config
.module
= urlParams
.module
;
652 config
.testNumber
= parseInt( urlParams
.testNumber
, 10 ) || null;
654 // Figure out if we're running the tests from a server or not
655 QUnit
.isLocal
= location
.protocol
=== "file:";
658 // Export global variables, unless an 'exports' object exists,
659 // in that case we assume we're in CommonJS (dealt with on the bottom of the script)
660 if ( typeof exports
=== "undefined" ) {
661 extend( window
, QUnit
);
663 // Expose QUnit object
664 window
.QUnit
= QUnit
;
667 // Extend QUnit object,
668 // these after set here because they should not be exposed as global functions
672 // Initialize the configuration options
675 stats
: { all
: 0, bad
: 0 },
676 moduleStats
: { all
: 0, bad
: 0 },
677 started
: +new Date(),
687 var tests
, banner
, result
,
688 qunit
= id( "qunit" );
692 "<h1 id='qunit-header'>" + escapeInnerText( document
.title
) + "</h1>" +
693 "<h2 id='qunit-banner'></h2>" +
694 "<div id='qunit-testrunner-toolbar'></div>" +
695 "<h2 id='qunit-userAgent'></h2>" +
696 "<ol id='qunit-tests'></ol>";
699 tests
= id( "qunit-tests" );
700 banner
= id( "qunit-banner" );
701 result
= id( "qunit-testresult" );
704 tests
.innerHTML
= "";
708 banner
.className
= "";
712 result
.parentNode
.removeChild( result
);
716 result
= document
.createElement( "p" );
717 result
.id
= "qunit-testresult";
718 result
.className
= "result";
719 tests
.parentNode
.insertBefore( result
, tests
);
720 result
.innerHTML
= "Running...<br/> ";
724 // Resets the test setup. Useful for tests that modify the DOM.
726 var fixture
= id( "qunit-fixture" );
728 fixture
.innerHTML
= config
.fixture
;
732 // Trigger an event on an element.
733 // @example triggerEvent( document.body, "click" );
734 triggerEvent: function( elem
, type
, event
) {
735 if ( document
.createEvent
) {
736 event
= document
.createEvent( "MouseEvents" );
737 event
.initMouseEvent(type
, true, true, elem
.ownerDocument
.defaultView
,
738 0, 0, 0, 0, 0, false, false, false, false, 0, null);
740 elem
.dispatchEvent( event
);
741 } else if ( elem
.fireEvent
) {
742 elem
.fireEvent( "on" + type
);
746 // Safe object type checking
747 is: function( type
, obj
) {
748 return QUnit
.objectType( obj
) == type
;
751 objectType: function( obj
) {
752 if ( typeof obj
=== "undefined" ) {
754 // consider: typeof null === object
756 if ( obj
=== null ) {
760 var type
= toString
.call( obj
).match(/^\[object\s(.*)\]$/)[1] || "";
774 return type
.toLowerCase();
776 if ( typeof obj
=== "object" ) {
782 push: function( result
, actual
, expected
, message
) {
783 if ( !config
.current
) {
784 throw new Error( "assertion outside test context, was " + sourceFromStacktrace() );
789 module
: config
.current
.module
,
790 name
: config
.current
.testName
,
797 message
= escapeInnerText( message
) || ( result
? "okay" : "failed" );
798 message
= "<span class='test-message'>" + message
+ "</span>";
802 expected
= escapeInnerText( QUnit
.jsDump
.parse(expected
) );
803 actual
= escapeInnerText( QUnit
.jsDump
.parse(actual
) );
804 output
+= "<table><tr class='test-expected'><th>Expected: </th><td><pre>" + expected
+ "</pre></td></tr>";
806 if ( actual
!= expected
) {
807 output
+= "<tr class='test-actual'><th>Result: </th><td><pre>" + actual
+ "</pre></td></tr>";
808 output
+= "<tr class='test-diff'><th>Diff: </th><td><pre>" + QUnit
.diff( expected
, actual
) + "</pre></td></tr>";
811 source
= sourceFromStacktrace();
814 details
.source
= source
;
815 output
+= "<tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source
) + "</pre></td></tr>";
818 output
+= "</table>";
821 runLoggingCallbacks( "log", QUnit
, details
);
823 config
.current
.assertions
.push({
829 pushFailure: function( message
, source
, actual
) {
830 if ( !config
.current
) {
831 throw new Error( "pushFailure() assertion outside test context, was " + sourceFromStacktrace(2) );
836 module
: config
.current
.module
,
837 name
: config
.current
.testName
,
842 message
= escapeInnerText( message
) || "error";
843 message
= "<span class='test-message'>" + message
+ "</span>";
849 output
+= "<tr class='test-actual'><th>Result: </th><td><pre>" + escapeInnerText( actual
) + "</pre></td></tr>";
853 details
.source
= source
;
854 output
+= "<tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source
) + "</pre></td></tr>";
857 output
+= "</table>";
859 runLoggingCallbacks( "log", QUnit
, details
);
861 config
.current
.assertions
.push({
867 url: function( params
) {
868 params
= extend( extend( {}, QUnit
.urlParams
), params
);
872 for ( key
in params
) {
873 if ( !hasOwn
.call( params
, key
) ) {
876 querystring
+= encodeURIComponent( key
) + "=" +
877 encodeURIComponent( params
[ key
] ) + "&";
879 return window
.location
.pathname
+ querystring
.slice( 0, -1 );
885 // load, equiv, jsDump, diff: Attached later
889 * @deprecated: Created for backwards compatibility with test runner that set the hook function
890 * into QUnit.{hook}, instead of invoking it and passing the hook function.
891 * QUnit.constructor is set to the empty F() above so that we can add to it's prototype here.
892 * Doing this allows us to tell if the following methods have been overwritten on the actual
895 extend( QUnit
.constructor.prototype, {
897 // Logging callbacks; all receive a single argument with the listed properties
898 // run test/logs.html for any related changes
899 begin
: registerLoggingCallback( "begin" ),
901 // done: { failed, passed, total, runtime }
902 done
: registerLoggingCallback( "done" ),
904 // log: { result, actual, expected, message }
905 log
: registerLoggingCallback( "log" ),
907 // testStart: { name }
908 testStart
: registerLoggingCallback( "testStart" ),
910 // testDone: { name, failed, passed, total }
911 testDone
: registerLoggingCallback( "testDone" ),
913 // moduleStart: { name }
914 moduleStart
: registerLoggingCallback( "moduleStart" ),
916 // moduleDone: { name, failed, passed, total }
917 moduleDone
: registerLoggingCallback( "moduleDone" )
920 if ( typeof document
=== "undefined" || document
.readyState
=== "complete" ) {
921 config
.autorun
= true;
924 QUnit
.load = function() {
925 runLoggingCallbacks( "begin", QUnit
, {} );
927 // Initialize the config, saving the execution queue
928 var banner
, filter
, i
, label
, len
, main
, ol
, toolbar
, userAgent
, val
, urlConfigCheckboxes
, moduleFilter
,
930 moduleFilterHtml
= "",
932 oldconfig
= extend( {}, config
);
935 extend(config
, oldconfig
);
937 config
.blocking
= false;
939 len
= config
.urlConfig
.length
;
941 for ( i
= 0; i
< len
; i
++ ) {
942 val
= config
.urlConfig
[i
];
943 if ( typeof val
=== "string" ) {
947 tooltip
: "[no tooltip available]"
950 config
[ val
.id
] = QUnit
.urlParams
[ val
.id
];
951 urlConfigHtml
+= "<input id='qunit-urlconfig-" + val
.id
+ "' name='" + val
.id
+ "' type='checkbox'" + ( config
[ val
.id
] ? " checked='checked'" : "" ) + " title='" + val
.tooltip
+ "'><label for='qunit-urlconfig-" + val
.id
+ "' title='" + val
.tooltip
+ "'>" + val
.label
+ "</label>";
954 moduleFilterHtml
+= "<label for='qunit-modulefilter'>Module: </label><select id='qunit-modulefilter' name='modulefilter'><option value='' " + ( config
.module
=== undefined ? "selected" : "" ) + ">< All Modules ></option>";
955 for ( i
in config
.modules
) {
956 if ( config
.modules
.hasOwnProperty( i
) ) {
958 moduleFilterHtml
+= "<option value='" + encodeURIComponent(i
) + "' " + ( config
.module
=== i
? "selected" : "" ) + ">" + i
+ "</option>";
961 moduleFilterHtml
+= "</select>";
963 // `userAgent` initialized at top of scope
964 userAgent
= id( "qunit-userAgent" );
966 userAgent
.innerHTML
= navigator
.userAgent
;
969 // `banner` initialized at top of scope
970 banner
= id( "qunit-header" );
972 banner
.innerHTML
= "<a href='" + QUnit
.url({ filter
: undefined, module
: undefined, testNumber
: undefined }) + "'>" + banner
.innerHTML
+ "</a> ";
975 // `toolbar` initialized at top of scope
976 toolbar
= id( "qunit-testrunner-toolbar" );
978 // `filter` initialized at top of scope
979 filter
= document
.createElement( "input" );
980 filter
.type
= "checkbox";
981 filter
.id
= "qunit-filter-pass";
983 addEvent( filter
, "click", function() {
985 ol
= document
.getElementById( "qunit-tests" );
987 if ( filter
.checked
) {
988 ol
.className
= ol
.className
+ " hidepass";
990 tmp
= " " + ol
.className
.replace( /[\n\t\r]/g, " " ) + " ";
991 ol
.className
= tmp
.replace( / hidepass
/, " " );
993 if ( defined
.sessionStorage
) {
994 if (filter
.checked
) {
995 sessionStorage
.setItem( "qunit-filter-passed-tests", "true" );
997 sessionStorage
.removeItem( "qunit-filter-passed-tests" );
1002 if ( config
.hidepassed
|| defined
.sessionStorage
&& sessionStorage
.getItem( "qunit-filter-passed-tests" ) ) {
1003 filter
.checked
= true;
1004 // `ol` initialized at top of scope
1005 ol
= document
.getElementById( "qunit-tests" );
1006 ol
.className
= ol
.className
+ " hidepass";
1008 toolbar
.appendChild( filter
);
1010 // `label` initialized at top of scope
1011 label
= document
.createElement( "label" );
1012 label
.setAttribute( "for", "qunit-filter-pass" );
1013 label
.setAttribute( "title", "Only show tests and assertons that fail. Stored in sessionStorage." );
1014 label
.innerHTML
= "Hide passed tests";
1015 toolbar
.appendChild( label
);
1017 urlConfigCheckboxes
= document
.createElement( 'span' );
1018 urlConfigCheckboxes
.innerHTML
= urlConfigHtml
;
1019 addEvent( urlConfigCheckboxes
, "change", function( event
) {
1021 params
[ event
.target
.name
] = event
.target
.checked
? true : undefined;
1022 window
.location
= QUnit
.url( params
);
1024 toolbar
.appendChild( urlConfigCheckboxes
);
1026 if (numModules
> 1) {
1027 moduleFilter
= document
.createElement( 'span' );
1028 moduleFilter
.setAttribute( 'id', 'qunit-modulefilter-container' );
1029 moduleFilter
.innerHTML
= moduleFilterHtml
;
1030 addEvent( moduleFilter
, "change", function() {
1031 var selectBox
= moduleFilter
.getElementsByTagName("select")[0],
1032 selectedModule
= decodeURIComponent(selectBox
.options
[selectBox
.selectedIndex
].value
);
1034 window
.location
= QUnit
.url( { module
: ( selectedModule
=== "" ) ? undefined : selectedModule
} );
1036 toolbar
.appendChild(moduleFilter
);
1040 // `main` initialized at top of scope
1041 main
= id( "qunit-fixture" );
1043 config
.fixture
= main
.innerHTML
;
1046 if ( config
.autostart
) {
1051 addEvent( window
, "load", QUnit
.load
);
1053 // `onErrorFnPrev` initialized at top of scope
1054 // Preserve other handlers
1055 onErrorFnPrev
= window
.onerror
;
1057 // Cover uncaught exceptions
1058 // Returning true will surpress the default browser handler,
1059 // returning false will let it run.
1060 window
.onerror = function ( error
, filePath
, linerNr
) {
1062 if ( onErrorFnPrev
) {
1063 ret
= onErrorFnPrev( error
, filePath
, linerNr
);
1066 // Treat return value as window.onerror itself does,
1067 // Only do our handling if not surpressed.
1068 if ( ret
!== true ) {
1069 if ( QUnit
.config
.current
) {
1070 if ( QUnit
.config
.current
.ignoreGlobalErrors
) {
1073 QUnit
.pushFailure( error
, filePath
+ ":" + linerNr
);
1075 QUnit
.test( "global failure", extend( function() {
1076 QUnit
.pushFailure( error
, filePath
+ ":" + linerNr
);
1077 }, { validTest
: validTest
} ) );
1086 config
.autorun
= true;
1088 // Log the last module results
1089 if ( config
.currentModule
) {
1090 runLoggingCallbacks( "moduleDone", QUnit
, {
1091 name
: config
.currentModule
,
1092 failed
: config
.moduleStats
.bad
,
1093 passed
: config
.moduleStats
.all
- config
.moduleStats
.bad
,
1094 total
: config
.moduleStats
.all
1099 banner
= id( "qunit-banner" ),
1100 tests
= id( "qunit-tests" ),
1101 runtime
= +new Date() - config
.started
,
1102 passed
= config
.stats
.all
- config
.stats
.bad
,
1104 "Tests completed in ",
1106 " milliseconds.<br/>",
1107 "<span class='passed'>",
1109 "</span> tests of <span class='total'>",
1111 "</span> passed, <span class='failed'>",
1117 banner
.className
= ( config
.stats
.bad
? "qunit-fail" : "qunit-pass" );
1121 id( "qunit-testresult" ).innerHTML
= html
;
1124 if ( config
.altertitle
&& typeof document
!== "undefined" && document
.title
) {
1125 // show ✖ for good, ✔ for bad suite result in title
1126 // use escape sequences in case file gets loaded with non-utf-8-charset
1128 ( config
.stats
.bad
? "\u2716" : "\u2714" ),
1129 document
.title
.replace( /^[\u2714\u2716] /i, "" )
1133 // clear own sessionStorage items if all tests passed
1134 if ( config
.reorder
&& defined
.sessionStorage
&& config
.stats
.bad
=== 0 ) {
1135 // `key` & `i` initialized at top of scope
1136 for ( i
= 0; i
< sessionStorage
.length
; i
++ ) {
1137 key
= sessionStorage
.key( i
++ );
1138 if ( key
.indexOf( "qunit-test-" ) === 0 ) {
1139 sessionStorage
.removeItem( key
);
1144 // scroll back to top to show results
1145 if ( window
.scrollTo
) {
1146 window
.scrollTo(0, 0);
1149 runLoggingCallbacks( "done", QUnit
, {
1150 failed
: config
.stats
.bad
,
1152 total
: config
.stats
.all
,
1157 /** @return Boolean: true if this test should be ran */
1158 function validTest( test
) {
1160 filter
= config
.filter
&& config
.filter
.toLowerCase(),
1161 module
= config
.module
&& config
.module
.toLowerCase(),
1162 fullName
= (test
.module
+ ": " + test
.testName
).toLowerCase();
1164 // Internally-generated tests are always valid
1165 if ( test
.callback
&& test
.callback
.validTest
=== validTest
) {
1166 delete test
.callback
.validTest
;
1170 if ( config
.testNumber
) {
1171 return test
.testNumber
=== config
.testNumber
;
1174 if ( module
&& ( !test
.module
|| test
.module
.toLowerCase() !== module
) ) {
1182 include
= filter
.charAt( 0 ) !== "!";
1184 filter
= filter
.slice( 1 );
1187 // If the filter matches, we need to honour include
1188 if ( fullName
.indexOf( filter
) !== -1 ) {
1192 // Otherwise, do the opposite
1196 // so far supports only Firefox, Chrome and Opera (buggy), Safari (for real exceptions)
1197 // Later Safari and IE10 are supposed to support error.stack as well
1198 // See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error/Stack
1199 function extractStacktrace( e
, offset
) {
1200 offset
= offset
=== undefined ? 3 : offset
;
1202 var stack
, include
, i
, regex
;
1204 if ( e
.stacktrace
) {
1206 return e
.stacktrace
.split( "\n" )[ offset
+ 3 ];
1207 } else if ( e
.stack
) {
1209 stack
= e
.stack
.split( "\n" );
1210 if (/^error$/i.test( stack
[0] ) ) {
1215 for ( i
= offset
; i
< stack
.length
; i
++ ) {
1216 if ( stack
[ i
].indexOf( fileName
) != -1 ) {
1219 include
.push( stack
[ i
] );
1221 if ( include
.length
) {
1222 return include
.join( "\n" );
1225 return stack
[ offset
];
1226 } else if ( e
.sourceURL
) {
1227 // Safari, PhantomJS
1228 // hopefully one day Safari provides actual stacktraces
1229 // exclude useless self-reference for generated Error objects
1230 if ( /qunit.js$/.test( e
.sourceURL
) ) {
1233 // for actual exceptions, this is useful
1234 return e
.sourceURL
+ ":" + e
.line
;
1237 function sourceFromStacktrace( offset
) {
1241 return extractStacktrace( e
, offset
);
1245 function escapeInnerText( s
) {
1250 return s
.replace( /[\&<>]/g, function( s
) {
1252 case "&": return "&";
1253 case "<": return "<";
1254 case ">": return ">";
1260 function synchronize( callback
, last
) {
1261 config
.queue
.push( callback
);
1263 if ( config
.autorun
&& !config
.blocking
) {
1268 function process( last
) {
1272 var start
= new Date().getTime();
1273 config
.depth
= config
.depth
? config
.depth
+ 1 : 1;
1275 while ( config
.queue
.length
&& !config
.blocking
) {
1276 if ( !defined
.setTimeout
|| config
.updateRate
<= 0 || ( ( new Date().getTime() - start
) < config
.updateRate
) ) {
1277 config
.queue
.shift()();
1279 window
.setTimeout( next
, 13 );
1284 if ( last
&& !config
.blocking
&& !config
.queue
.length
&& config
.depth
=== 0 ) {
1289 function saveGlobal() {
1290 config
.pollution
= [];
1292 if ( config
.noglobals
) {
1293 for ( var key
in window
) {
1294 // in Opera sometimes DOM element ids show up here, ignore them
1295 if ( !hasOwn
.call( window
, key
) || /^qunit-test-output/.test( key
) ) {
1298 config
.pollution
.push( key
);
1303 function checkPollution( name
) {
1306 old
= config
.pollution
;
1310 newGlobals
= diff( config
.pollution
, old
);
1311 if ( newGlobals
.length
> 0 ) {
1312 QUnit
.pushFailure( "Introduced global variable(s): " + newGlobals
.join(", ") );
1315 deletedGlobals
= diff( old
, config
.pollution
);
1316 if ( deletedGlobals
.length
> 0 ) {
1317 QUnit
.pushFailure( "Deleted global variable(s): " + deletedGlobals
.join(", ") );
1321 // returns a new Array with the elements that are in a but not in b
1322 function diff( a
, b
) {
1326 for ( i
= 0; i
< result
.length
; i
++ ) {
1327 for ( j
= 0; j
< b
.length
; j
++ ) {
1328 if ( result
[i
] === b
[j
] ) {
1329 result
.splice( i
, 1 );
1338 function extend( a
, b
) {
1339 for ( var prop
in b
) {
1340 if ( b
[ prop
] === undefined ) {
1343 // Avoid "Member not found" error in IE8 caused by setting window.constructor
1344 } else if ( prop
!== "constructor" || a
!== window
) {
1345 a
[ prop
] = b
[ prop
];
1352 function addEvent( elem
, type
, fn
) {
1353 if ( elem
.addEventListener
) {
1354 elem
.addEventListener( type
, fn
, false );
1355 } else if ( elem
.attachEvent
) {
1356 elem
.attachEvent( "on" + type
, fn
);
1362 function id( name
) {
1363 return !!( typeof document
!== "undefined" && document
&& document
.getElementById
) &&
1364 document
.getElementById( name
);
1367 function registerLoggingCallback( key
) {
1368 return function( callback
) {
1369 config
[key
].push( callback
);
1373 // Supports deprecated method of completely overwriting logging callbacks
1374 function runLoggingCallbacks( key
, scope
, args
) {
1377 if ( QUnit
.hasOwnProperty( key
) ) {
1378 QUnit
[ key
].call(scope
, args
);
1380 callbacks
= config
[ key
];
1381 for ( i
= 0; i
< callbacks
.length
; i
++ ) {
1382 callbacks
[ i
].call( scope
, args
);
1387 // Test for equality any JavaScript type.
1388 // Author: Philippe Rathé <prathe@gmail.com>
1389 QUnit
.equiv
= (function() {
1391 // Call the o related callback with the given arguments.
1392 function bindCallbacks( o
, callbacks
, args
) {
1393 var prop
= QUnit
.objectType( o
);
1395 if ( QUnit
.objectType( callbacks
[ prop
] ) === "function" ) {
1396 return callbacks
[ prop
].apply( callbacks
, args
);
1398 return callbacks
[ prop
]; // or undefined
1403 // the real equiv function
1405 // stack to decide between skip/abort functions
1407 // stack to avoiding loops from circular referencing
1410 getProto
= Object
.getPrototypeOf
|| function ( obj
) {
1411 return obj
.__proto__
;
1413 callbacks
= (function () {
1415 // for string, boolean, number and null
1416 function useStrictEquality( b
, a
) {
1417 if ( b
instanceof a
.constructor || a
instanceof b
.constructor ) {
1418 // to catch short annotaion VS 'new' annotation of a
1421 // var j = new Number(1);
1429 "string": useStrictEquality
,
1430 "boolean": useStrictEquality
,
1431 "number": useStrictEquality
,
1432 "null": useStrictEquality
,
1433 "undefined": useStrictEquality
,
1435 "nan": function( b
) {
1439 "date": function( b
, a
) {
1440 return QUnit
.objectType( b
) === "date" && a
.valueOf() === b
.valueOf();
1443 "regexp": function( b
, a
) {
1444 return QUnit
.objectType( b
) === "regexp" &&
1446 a
.source
=== b
.source
&&
1448 a
.global
=== b
.global
&&
1450 a
.ignoreCase
=== b
.ignoreCase
&&
1451 a
.multiline
=== b
.multiline
&&
1452 a
.sticky
=== b
.sticky
;
1455 // - skip when the property is a method of an instance (OOP)
1456 // - abort otherwise,
1457 // initial === would have catch identical references anyway
1458 "function": function() {
1459 var caller
= callers
[callers
.length
- 1];
1460 return caller
!== Object
&& typeof caller
!== "undefined";
1463 "array": function( b
, a
) {
1464 var i
, j
, len
, loop
;
1466 // b could be an object literal here
1467 if ( QUnit
.objectType( b
) !== "array" ) {
1472 if ( len
!== b
.length
) {
1477 // track reference to avoid circular references
1479 for ( i
= 0; i
< len
; i
++ ) {
1481 for ( j
= 0; j
< parents
.length
; j
++ ) {
1482 if ( parents
[j
] === a
[i
] ) {
1483 loop
= true;// dont rewalk array
1486 if ( !loop
&& !innerEquiv(a
[i
], b
[i
]) ) {
1495 "object": function( b
, a
) {
1502 // comparing constructors is more strict than using
1504 if ( a
.constructor !== b
.constructor ) {
1505 // Allow objects with no prototype to be equivalent to
1506 // objects with Object as their constructor.
1507 if ( !(( getProto(a
) === null && getProto(b
) === Object
.prototype ) ||
1508 ( getProto(b
) === null && getProto(a
) === Object
.prototype ) ) ) {
1513 // stack constructor before traversing properties
1514 callers
.push( a
.constructor );
1515 // track reference to avoid circular references
1518 for ( i
in a
) { // be strict: don't ensures hasOwnProperty
1521 for ( j
= 0; j
< parents
.length
; j
++ ) {
1522 if ( parents
[j
] === a
[i
] ) {
1523 // don't go down the same path twice
1527 aProperties
.push(i
); // collect a's properties
1529 if (!loop
&& !innerEquiv( a
[i
], b
[i
] ) ) {
1535 callers
.pop(); // unstack, we are done
1539 bProperties
.push( i
); // collect b's properties
1542 // Ensures identical properties name
1543 return eq
&& innerEquiv( aProperties
.sort(), bProperties
.sort() );
1548 innerEquiv = function() { // can take multiple arguments
1549 var args
= [].slice
.apply( arguments
);
1550 if ( args
.length
< 2 ) {
1551 return true; // end transition
1554 return (function( a
, b
) {
1556 return true; // catch the most you can
1557 } else if ( a
=== null || b
=== null || typeof a
=== "undefined" ||
1558 typeof b
=== "undefined" ||
1559 QUnit
.objectType(a
) !== QUnit
.objectType(b
) ) {
1560 return false; // don't lose time with error prone cases
1562 return bindCallbacks(a
, callbacks
, [ b
, a
]);
1565 // apply transition with (1..n) arguments
1566 }( args
[0], args
[1] ) && arguments
.callee
.apply( this, args
.splice(1, args
.length
- 1 )) );
1573 * jsDump Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com |
1574 * http://flesler.blogspot.com Licensed under BSD
1575 * (http://www.opensource.org/licenses/bsd-license.php) Date: 5/15/2008
1577 * @projectDescription Advanced and extensible data dumping for Javascript.
1579 * @author Ariel Flesler
1580 * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html}
1582 QUnit
.jsDump
= (function() {
1583 function quote( str
) {
1584 return '"' + str
.toString().replace( /"/g, '\\"' ) + '"';
1586 function literal( o ) {
1589 function join( pre, arr, post ) {
1590 var s = jsDump.separator(),
1591 base = jsDump.indent(),
1592 inner = jsDump.indent(1);
1594 arr = arr.join( "," + s + inner );
1599 return [ pre, inner + arr, base + post ].join(s);
1601 function array( arr, stack ) {
1602 var i = arr.length, ret = new Array(i);
1605 ret[i] = this.parse( arr[i] , undefined , stack);
1608 return join( "[", ret, "]" );
1611 var reName = /^function (\w+)/,
1613 parse: function( obj, type, stack ) { //type is used mostly internally, you can fix a (custom)type in advance
1614 stack = stack || [ ];
1616 parser = this.parsers[ type || this.typeOf(obj) ];
1618 type = typeof parser;
1619 inStack = inArray( obj, stack );
1621 if ( inStack != -1 ) {
1622 return "recursion(" + (inStack - stack.length) + ")";
1625 if ( type == "function" ) {
1627 res = parser.call( this, obj, stack );
1632 return ( type == "string
" ) ? parser : this.parsers.error;
1634 typeOf: function( obj ) {
1636 if ( obj === null ) {
1638 } else if ( typeof obj === "undefined" ) {
1640 } else if ( QUnit.is( "regexp
", obj) ) {
1642 } else if ( QUnit.is( "date
", obj) ) {
1644 } else if ( QUnit.is( "function", obj) ) {
1646 } else if ( typeof obj.setInterval !== undefined && typeof obj.document !== "undefined" && typeof obj.nodeType === "undefined" ) {
1648 } else if ( obj.nodeType === 9 ) {
1650 } else if ( obj.nodeType ) {
1654 toString.call( obj ) === "[object Array
]" ||
1656 ( typeof obj.length === "number
" && typeof obj.item !== "undefined" && ( obj.length ? obj.item(0) === obj[0] : ( obj.item( 0 ) === null && typeof obj[0] === "undefined" ) ) )
1664 separator: function() {
1665 return this.multiline ? this.HTML ? "<br
/>" : "\n" : this.HTML ? " 
;" : " ";
1667 indent: function( extra ) {// extra can be a number, shortcut for increasing-calling-decreasing
1668 if ( !this.multiline ) {
1671 var chr = this.indentChar;
1673 chr = chr.replace( /\t/g, " " ).replace( / /g, " 
;" );
1675 return new Array( this._depth_ + (extra||0) ).join(chr);
1678 this._depth_ += a || 1;
1680 down: function( a ) {
1681 this._depth_ -= a || 1;
1683 setParser: function( name, parser ) {
1684 this.parsers[name] = parser;
1686 // The next 3 are exposed so you can use them
1692 // This is the list of parsers, to modify them, use jsDump.setParser
1695 document: "[Document
]",
1696 error: "[ERROR
]", //when no parser is found, shouldn"t happen
1697 unknown
: "[Unknown]",
1699 "undefined": "undefined",
1700 "function": function( fn
) {
1701 var ret
= "function",
1702 name
= "name" in fn
? fn
.name
: (reName
.exec(fn
) || [])[1];//functions never have name in IE
1709 ret
= [ ret
, QUnit
.jsDump
.parse( fn
, "functionArgs" ), "){" ].join( "" );
1710 return join( ret
, QUnit
.jsDump
.parse(fn
,"functionCode" ), "}" );
1715 object: function( map
, stack
) {
1716 var ret
= [ ], keys
, key
, val
, i
;
1718 if ( Object
.keys
) {
1719 keys
= Object
.keys( map
);
1722 for ( key
in map
) {
1727 for ( i
= 0; i
< keys
.length
; i
++ ) {
1730 ret
.push( QUnit
.jsDump
.parse( key
, "key" ) + ": " + QUnit
.jsDump
.parse( val
, undefined, stack
) );
1732 QUnit
.jsDump
.down();
1733 return join( "{", ret
, "}" );
1735 node: function( node
) {
1737 open
= QUnit
.jsDump
.HTML
? "<" : "<",
1738 close
= QUnit
.jsDump
.HTML
? ">" : ">",
1739 tag
= node
.nodeName
.toLowerCase(),
1742 for ( a
in QUnit
.jsDump
.DOMAttrs
) {
1743 val
= node
[ QUnit
.jsDump
.DOMAttrs
[a
] ];
1745 ret
+= " " + a
+ "=" + QUnit
.jsDump
.parse( val
, "attribute" );
1748 return ret
+ close
+ open
+ "/" + tag
+ close
;
1750 functionArgs: function( fn
) {//function calls it internally, it's the arguments part of the function
1758 args
= new Array(l
);
1760 args
[l
] = String
.fromCharCode(97+l
);//97 is 'a'
1762 return " " + args
.join( ", " ) + " ";
1764 key
: quote
, //object calls it internally, the key part of an item in a map
1765 functionCode
: "[code]", //function calls it internally, it's the content of the function
1766 attribute
: quote
, //node calls it internally, it's an html attribute value
1769 regexp
: literal
, //regex
1774 //attributes to dump from nodes, name=>realName
1777 "class": "className"
1779 HTML
: false,//if true, entities are escaped ( <, >, \t, space and \n )
1780 indentChar
: " ",//indentation unit
1781 multiline
: true //if true, items in a collection, are separated by a \n, else just a space.
1788 function getText( elems
) {
1792 for ( i
= 0; elems
[i
]; i
++ ) {
1795 // Get the text from text nodes and CDATA nodes
1796 if ( elem
.nodeType
=== 3 || elem
.nodeType
=== 4 ) {
1797 ret
+= elem
.nodeValue
;
1799 // Traverse everything else, except comment nodes
1800 } else if ( elem
.nodeType
!== 8 ) {
1801 ret
+= getText( elem
.childNodes
);
1809 function inArray( elem
, array
) {
1810 if ( array
.indexOf
) {
1811 return array
.indexOf( elem
);
1814 for ( var i
= 0, length
= array
.length
; i
< length
; i
++ ) {
1815 if ( array
[ i
] === elem
) {
1824 * Javascript Diff Algorithm
1825 * By John Resig (http://ejohn.org/)
1826 * Modified by Chu Alan "sprite"
1828 * Released under the MIT license.
1831 * http://ejohn.org/projects/javascript-diff-algorithm/
1833 * Usage: QUnit.diff(expected, actual)
1835 * 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"
1837 QUnit
.diff
= (function() {
1838 function diff( o
, n
) {
1843 for ( i
= 0; i
< n
.length
; i
++ ) {
1844 if ( ns
[ n
[i
] ] == null ) {
1850 ns
[ n
[i
] ].rows
.push( i
);
1853 for ( i
= 0; i
< o
.length
; i
++ ) {
1854 if ( os
[ o
[i
] ] == null ) {
1860 os
[ o
[i
] ].rows
.push( i
);
1864 if ( !hasOwn
.call( ns
, i
) ) {
1867 if ( ns
[i
].rows
.length
== 1 && typeof os
[i
] != "undefined" && os
[i
].rows
.length
== 1 ) {
1868 n
[ ns
[i
].rows
[0] ] = {
1869 text
: n
[ ns
[i
].rows
[0] ],
1872 o
[ os
[i
].rows
[0] ] = {
1873 text
: o
[ os
[i
].rows
[0] ],
1879 for ( i
= 0; i
< n
.length
- 1; i
++ ) {
1880 if ( n
[i
].text
!= null && n
[ i
+ 1 ].text
== null && n
[i
].row
+ 1 < o
.length
&& o
[ n
[i
].row
+ 1 ].text
== null &&
1881 n
[ i
+ 1 ] == o
[ n
[i
].row
+ 1 ] ) {
1887 o
[ n
[i
].row
+ 1 ] = {
1888 text
: o
[ n
[i
].row
+ 1 ],
1894 for ( i
= n
.length
- 1; i
> 0; i
-- ) {
1895 if ( n
[i
].text
!= null && n
[ i
- 1 ].text
== null && n
[i
].row
> 0 && o
[ n
[i
].row
- 1 ].text
== null &&
1896 n
[ i
- 1 ] == o
[ n
[i
].row
- 1 ]) {
1902 o
[ n
[i
].row
- 1 ] = {
1903 text
: o
[ n
[i
].row
- 1 ],
1915 return function( o
, n
) {
1916 o
= o
.replace( /\s+$/, "" );
1917 n
= n
.replace( /\s+$/, "" );
1921 out
= diff( o
=== "" ? [] : o
.split(/\s+/), n
=== "" ? [] : n
.split(/\s+/) ),
1922 oSpace
= o
.match(/\s+/g),
1923 nSpace
= n
.match(/\s+/g);
1925 if ( oSpace
== null ) {
1932 if ( nSpace
== null ) {
1939 if ( out
.n
.length
=== 0 ) {
1940 for ( i
= 0; i
< out
.o
.length
; i
++ ) {
1941 str
+= "<del>" + out
.o
[i
] + oSpace
[i
] + "</del>";
1945 if ( out
.n
[0].text
== null ) {
1946 for ( n
= 0; n
< out
.o
.length
&& out
.o
[n
].text
== null; n
++ ) {
1947 str
+= "<del>" + out
.o
[n
] + oSpace
[n
] + "</del>";
1951 for ( i
= 0; i
< out
.n
.length
; i
++ ) {
1952 if (out
.n
[i
].text
== null) {
1953 str
+= "<ins>" + out
.n
[i
] + nSpace
[i
] + "</ins>";
1956 // `pre` initialized at top of scope
1959 for ( n
= out
.n
[i
].row
+ 1; n
< out
.o
.length
&& out
.o
[n
].text
== null; n
++ ) {
1960 pre
+= "<del>" + out
.o
[n
] + oSpace
[n
] + "</del>";
1962 str
+= " " + out
.n
[i
].text
+ nSpace
[i
] + pre
;
1971 // for CommonJS enviroments, export everything
1972 if ( typeof exports
!== "undefined" ) {
1973 extend(exports
, QUnit
);
1976 // get at whatever the global object is, like window in browsers
1977 }( (function() {return this;}.call()) ));