1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 09:58:14 +00:00

LibJS: Implement initializing a TypedArray from an array-like object

Used by twitch.tv and based on the following specification:
https://tc39.es/ecma262/#sec-initializetypedarrayfromarraylike
This commit is contained in:
Idan Horowitz 2021-04-16 23:24:59 +03:00 committed by Linus Groh
parent c9196995be
commit 06a2173586
2 changed files with 54 additions and 2 deletions

View file

@ -183,6 +183,18 @@ test("typed array created from TypedArray do not share buffer", () => {
expect(u8Array[1]).toBe(2);
});
test("typed array from Array-Like", () => {
TYPED_ARRAYS.forEach(T => {
function func() {
const newTypedArray = new T(arguments);
expect(newTypedArray[0]).toBe(1);
expect(newTypedArray[1]).toBe(2);
expect(newTypedArray[2]).toBe(3);
}
func(1, 2, 3);
});
});
test("TypedArray is not exposed on the global object", () => {
expect(globalThis.TypedArray).toBeUndefined();
});