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:
parent
c9196995be
commit
06a2173586
2 changed files with 54 additions and 2 deletions
|
@ -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();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue