Skip to content

Commit

Permalink
[Tests] add array/object tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 31, 2019
1 parent ed266e8 commit 558eecf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"files": ["example/**", "test/**"],
"rules": {
"array-bracket-newline": 0,
"max-statements": 0,
"no-console": 0,
"no-magic-numbers": 0,
},
Expand Down
22 changes: 22 additions & 0 deletions test/cmp.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,25 @@ test('regexen', function (t) {

t.end();
});

test('arrays and objects', function (t) {
t.ok(equal([], {}), 'empty array and empty object are equal');
t.ok(equal({}, []), 'empty object and empty array are equal');

t.ok(equal([], {}, { strict: true }), 'strict: empty array and empty object are equal');
t.ok(equal({}, [], { strict: true }), 'strict: empty object and empty array are equal');

t.notOk(equal([], { length: 0 }), 'empty array and empty arraylike object are not equal');
t.notOk(equal({ length: 0 }, []), 'empty arraylike object and empty array are not equal');

t.notOk(equal([], { length: 0 }, { strict: true }), 'strict: empty array and empty arraylike object are not equal');
t.notOk(equal({ length: 0 }, [], { strict: true }), 'strict: empty arraylike object and empty array are not equal');

t.ok(equal([1], { 0: 1 }), 'array and object are equal');
t.ok(equal({ 0: 1 }, [1]), 'object and array are equal');

t.ok(equal([1], { 0: 1 }, { strict: true }), 'strict: array and object are equal');
t.ok(equal({ 0: 1 }, [1], { strict: true }), 'strict: object and array are equal');

t.end();
});

0 comments on commit 558eecf

Please sign in to comment.