Skip to content

Commit

Permalink
fix #5865 (#5890)
Browse files Browse the repository at this point in the history
* make sure types are the same

* tests
  • Loading branch information
dylan-conway committed Sep 22, 2023
1 parent 341c1c1 commit 9d54592
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/bun.js/bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ bool Bun__deepEquals(JSC__JSGlobalObject* globalObject, JSValue v1, JSValue v2,
case Float64ArrayType:
case BigInt64ArrayType:
case BigUint64ArrayType: {
if (!isTypedArrayType(static_cast<JSC::JSType>(c2Type))) {
if (!isTypedArrayType(static_cast<JSC::JSType>(c2Type)) || c1Type != c2Type) {
return false;
}

Expand Down
6 changes: 6 additions & 0 deletions test/js/bun/test/expect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,12 @@ describe("expect()", () => {
expect(g).not.toEqual(a);
});

test("deepEquals and typed arrays", () => {
expect(new Uint8Array([0, 255])).not.toEqual(new Uint8ClampedArray([0, 255]));
expect(new Int8Array([0, -1])).not.toEqual(new Uint8Array([0, 255]));
expect(new Float32Array([0])).not.toEqual(new Uint8Array([0, 0, 0, 0]));
});

test("deepEquals throw getters", () => {
let a = {
get x() {
Expand Down

0 comments on commit 9d54592

Please sign in to comment.