mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:37:44 +00:00
LibJS: Do not throw a TypeError when sorting a detached TypedArray
This is a normative change in the ECMA-262 spec. See:
e0c74e1
This commit is contained in:
parent
d04a683f85
commit
84a81dd466
2 changed files with 18 additions and 3 deletions
|
@ -51,3 +51,21 @@ test("basic functionality", () => {
|
|||
expect(typedArray[2]).toBe(1n);
|
||||
});
|
||||
});
|
||||
|
||||
test("detached buffer", () => {
|
||||
TYPED_ARRAYS.forEach(T => {
|
||||
const typedArray = new T(3);
|
||||
typedArray[0] = 3;
|
||||
typedArray[1] = 1;
|
||||
typedArray[2] = 2;
|
||||
|
||||
typedArray.sort((a, b) => {
|
||||
detachArrayBuffer(typedArray.buffer);
|
||||
return a - b;
|
||||
});
|
||||
|
||||
expect(typedArray[0]).toBeUndefined();
|
||||
expect(typedArray[1]).toBeUndefined();
|
||||
expect(typedArray[2]).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue