Skip to content

assert.deepStrictEqual is fooled by strange dates #10258

Closed
@akdor1154

Description

@akdor1154
  • Version: v6.9.1
  • Platform: OS X
  • Subsystem: assert

assert.deepStrictEqual (and strictEqual) is fooled by the following code:

function FakeDate() {};
FakeDate.prototype = Date.prototype;
const f = new FakeDate();
const d = new Date();

f.toString();
//TypeError: Method Date.prototype.toString called on incompatible receiver [object Object]

d.toString();
//'Wed Dec 14 2016 09:53:28 GMT+1100 (AEDT)'

assert.deepStrictEqual(d, f);
// does not throw any error

I think it's reasonable to expect that assert.deepStrictEqual should consider d and f as unequal.

I have not tested on Node master, however there are no relevant changes in assert.js between 6.9.1 and master.

Metadata

Metadata

Assignees

No one assigned

    Labels

    assertIssues and PRs related to the assert subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions