From e6be4d48cd6e492370043f96f0823e49941f353f Mon Sep 17 00:00:00 2001 From: Scott Newcomer Date: Fri, 25 Feb 2022 10:52:29 -0600 Subject: [PATCH 1/2] Bug: deep equality Symbol --- test/expect.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/expect.js b/test/expect.js index 2a053570..cc208610 100644 --- a/test/expect.js +++ b/test/expect.js @@ -1473,6 +1473,26 @@ describe('expect', function () { expect(a).not.to.deep.equal({}); }); + it('deep.equal(Symbol)', function(){ + var symb = Symbol('a'); + var a = { [symb]: 'b' } + , b = { [symb]: 'b' }; + expect(a).to.deep.equal(a); + expect(a).to.deep.equal(b); + + var symb2 = Symbol('c'); + var c = { [symb]: { [symb2]: 'c' } } + , d = { [symb]: { [symb2]: 'b' } }; + expect(c).to.deep.equal(c); + // this test should fail + expect(d).to.deep.equal(d); + + var symb3 = Symbol('d'); + var e = { [symb]: { [symb3]: 'b' } }; + // this test should fail + expect(d).to.deep.equal(e); + }); + it('empty', function(){ function FakeArgs() {}; FakeArgs.prototype.length = 0; From 0168a73a4e1fdafdfbf5f3e2baf1808e810cb910 Mon Sep 17 00:00:00 2001 From: Scott Newcomer Date: Fri, 25 Feb 2022 10:57:46 -0600 Subject: [PATCH 2/2] proper fail --- test/expect.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/expect.js b/test/expect.js index cc208610..647ca008 100644 --- a/test/expect.js +++ b/test/expect.js @@ -1484,13 +1484,14 @@ describe('expect', function () { var c = { [symb]: { [symb2]: 'c' } } , d = { [symb]: { [symb2]: 'b' } }; expect(c).to.deep.equal(c); - // this test should fail - expect(d).to.deep.equal(d); + expect(d).to.not.deep.equal(c); var symb3 = Symbol('d'); var e = { [symb]: { [symb3]: 'b' } }; - // this test should fail - expect(d).to.deep.equal(e); + expect(d).to.not.deep.equal(e); + + var f = { [symb]: { [symb3]: 'b' } }; + expect(e).to.deep.equal(f); }); it('empty', function(){