1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:47:44 +00:00

LibJS: Implement initializing a TypedArray from an iterable object

Based on these specifications (which required IterableToList as well):
https://tc39.es/ecma262/#sec-typedarray
https://tc39.es/ecma262/#sec-initializetypedarrayfromlist
This commit is contained in:
Idan Horowitz 2021-04-16 23:54:41 +03:00 committed by Linus Groh
parent 06a2173586
commit e3c634fdd0
4 changed files with 61 additions and 5 deletions

View file

@ -195,6 +195,17 @@ test("typed array from Array-Like", () => {
});
});
test("typed array from Iterable", () => {
const from = new String("123");
TYPED_ARRAYS.forEach(T => {
const newTypedArray = new T(from);
expect(newTypedArray[0]).toBe(1);
expect(newTypedArray[1]).toBe(2);
expect(newTypedArray[2]).toBe(3);
});
});
test("TypedArray is not exposed on the global object", () => {
expect(globalThis.TypedArray).toBeUndefined();
});