Created
October 8, 2014 14:08
-
-
Save al-the-x/90e9fe543a98a157f591 to your computer and use it in GitHub Desktop.
Write your own `assert.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
| var assert = require('assert'); | |
| /** | |
| * @param Array actual | |
| * @param Array expected | |
| * @param String message optional | |
| * @return Boolean | |
| */ | |
| assert.deepEqual = function(actual, expected, message){ | |
| /* Then a miracle occurs... */ | |
| } | |
| assert(assert.deepEqual([ ], [ ]) === true); | |
| assert(assert.deepEqual([ 1 ], [ 1 ]) === true); | |
| assert(assert.deepEqual([ 1, 2, 3 ], [ 1, 2, 3 ]) === true); | |
| // assert.deepEqual() should fail with the provided message... | |
| assert.throws(function(){ | |
| assert.deepEqual([ ], [ 1 ], 'this should fail'); | |
| }, /this should fail/); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment