Skip to content

Commit

Permalink
Added test cases for sets and maps with keys of 0 and -0. Added strin…
Browse files Browse the repository at this point in the history
…gs with test case purpose to a couple of tests that were missing them.
  • Loading branch information
andrew brown committed Apr 21, 2016
1 parent 2e53862 commit c05eefe
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions test/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,12 +559,20 @@
var other = {a: 1};
assert.strictEqual(_.isEqual(new Foo, other), false, 'Objects from different constructors are not equal');


// Tricky object cases val comparisions
assert.equal(_.isEqual([0], [-0]), false);
assert.equal(_.isEqual({a: 0}, {a: -0}), false);
assert.equal(_.isEqual([NaN], [NaN]), true);
assert.equal(_.isEqual({a: NaN}, {a: NaN}), true);
assert.equal(_.isEqual([0], [-0]), false, '0 and -0 are not equal as array values');
assert.equal(_.isEqual({a: 0}, {a: -0}), false, '0 and -0 are not equal as object values');
assert.equal(_.isEqual([NaN], [NaN]), true, 'NaN and NaN are equal as array values');
assert.equal(_.isEqual({a: NaN}, {a: NaN}), true, 'NaN and NaN are equal as object values');

// SameValueZero tests for isEq function used for sets and maps
var set0 = new Set().add(0);
var setNeg0 = new Set().add(-0);
var map0 = new Map().set(0, 0);
var mapNeg0 = new Map().set(-0, 0);
assert.equal(_.isEqual(set0, setNeg0), true, 'In sets 0 and -0 are equal');
assert.equal(_.isEqual(map0, mapNeg0), true, 'In maps keys of 0 and -0 are equal');


if (typeof Symbol !== 'undefined') {
var symbol = Symbol('x');
Expand Down

0 comments on commit c05eefe

Please sign in to comment.