Created
February 25, 2014 00:03
-
-
Save NicholasMurray/9199941 to your computer and use it in GitHub Desktop.
QUnit deepEqual
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deepEqual: function( actual, expected, message ) { | |
QUnit.push( QUnit.equiv(actual, expected), actual, expected, message ); | |
} | |
... | |
innerEquiv = function() { // can take multiple arguments | |
var args = [].slice.apply( arguments ); | |
if ( args.length < 2 ) { | |
return true; // end transition | |
} | |
return (function( a, b ) { | |
if ( a === b ) { | |
return true; // catch the most you can | |
} else if ( a === null || b === null || typeof a === "undefined" || | |
typeof b === "undefined" || | |
QUnit.objectType(a) !== QUnit.objectType(b) ) { | |
return false; // don't lose time with error prone cases | |
} else { | |
return bindCallbacks(a, callbacks, [ b, a ]); | |
} | |
// apply transition with (1..n) arguments | |
}( args[0], args[1] ) && innerEquiv.apply( this, args.splice(1, args.length - 1 )) ); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment