diff options
author | 2023-09-21 21:02:34 -0700 | |
---|---|---|
committer | 2023-09-21 21:02:34 -0700 | |
commit | 9d5459221ff663b6c0058440167e098886d97cc2 (patch) | |
tree | a858b76f77c3b038df5806d4f8b52e1d91b89b7b | |
parent | 341c1c1804401ff48b44774206c646751976c217 (diff) | |
download | bun-9d5459221ff663b6c0058440167e098886d97cc2.tar.gz bun-9d5459221ff663b6c0058440167e098886d97cc2.tar.zst bun-9d5459221ff663b6c0058440167e098886d97cc2.zip |
fix #5865 (#5890)
* make sure types are the same
* tests
-rw-r--r-- | src/bun.js/bindings/bindings.cpp | 2 | ||||
-rw-r--r-- | test/js/bun/test/expect.test.js | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index bff5640ef..1e0d1c97e 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -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; } diff --git a/test/js/bun/test/expect.test.js b/test/js/bun/test/expect.test.js index b6e312022..8c9959d01 100644 --- a/test/js/bun/test/expect.test.js +++ b/test/js/bun/test/expect.test.js @@ -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() { |