Skip to content

deepEqual only compares TypedArrays but not bare ArrayBuffers #8

Description

@Swiftb0y

The following code reproduces the issue:

require("should");

const a = (new Uint8Array([1])).buffer;
const b = (new Uint8Array([2])).buffer; 

console.log(a.constructor, b.constructor);
// [Function: ArrayBuffer] [Function: ArrayBuffer]
console.log(a.should.deepEqual(b)); // doesn't throw
/*
Assertion {
  obj: ArrayBuffer { [Uint8Contents]: <01>, byteLength: 1 },
  anyOne: false,
  negate: false,
  params: {
    operator: 'to equal',
    expected: ArrayBuffer { [Uint8Contents]: <02>, byteLength: 1 },
    message: undefined,
    details: '',
    showDiff: true
  }
}
*/

const c = new Uint8Array([1]);
const d = new Uint8Array([2]);

console.log(c.constructor, d.constructor);
// [Function: Uint8Array] [Function: Uint8Array]
console.log(c.should.deepEqual(d)); // throws

The first deepEqual should throw as well, but it doesn't. I'm using shouldjs 13.2.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions