Skip to content

Commit

Permalink
fix: deep symbol comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer committed Feb 25, 2022
1 parent 3b39bf3 commit 00f8433
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,48 @@ describe('Generic', function () {

});

describe.only('Symbols', function () {

it('returns true for same symbols', function () {
var symb = Symbol('a');
var objectA = { [symb]: 'a' };
var objectB = { [symb]: 'a' };
assert(eql(objectA, objectB) === true, 'eql(obj, obj)');
});

it('returns false for different values', function () {
var symb = Symbol('a');
var objectA = { [symb]: 'a' };
var objectB = { [symb]: 'b' };
assert(eql(objectA, objectB) === false, 'eql(obj, obj) === false');
});

it('returns false for different symbols', function () {
var symb = Symbol('a');
var symb2 = Symbol('b');
var objectA = { [symb]: 'a' };
var objectB = { [symb2]: 'a' };
assert(eql(objectA, objectB) === false, 'eql(obj, obj) === false');
});

it('returns true for same nested symbols', function () {
var symb = Symbol('a');
var symb2 = Symbol('b');
var objectA = { [symb]: { [symb2]: 'a' } };
var objectB = { [symb]: { [symb2]: 'a' } };
assert(eql(objectA, objectB) === true, 'eql(obj, obj)');
});

it('returns false for different nested symbols', function () {
var symb = Symbol('a');
var symb2 = Symbol('b');
var objectA = { [symb]: { [symb2]: 'a' } };
var objectB = { [symb]: { [symb]: 'a' } };
assert(eql(objectA, objectB) === false, 'eql(obj, obj) === false');
});
});


describe('errors', function () {

it('returns true for same errors', function () {
Expand Down

0 comments on commit 00f8433

Please sign in to comment.