Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deepEqual only compares TypedArrays but not bare ArrayBuffers #8

Open
Swiftb0y opened this issue May 1, 2020 · 0 comments
Open

deepEqual only compares TypedArrays but not bare ArrayBuffers #8

Swiftb0y opened this issue May 1, 2020 · 0 comments

Comments

@Swiftb0y
Copy link

Swiftb0y commented May 1, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant