Skip to content

Instantly share code, notes, and snippets.

@NicholasMurray
Created February 25, 2014 00:03
Show Gist options
  • Save NicholasMurray/9199941 to your computer and use it in GitHub Desktop.
Save NicholasMurray/9199941 to your computer and use it in GitHub Desktop.
QUnit deepEqual
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