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

LibJS: Add the TypedArray.of() method

This commit is contained in:
Idan Horowitz 2021-06-17 19:22:14 +03:00 committed by Linus Groh
parent b91df26d4a
commit cc5c1df64b
4 changed files with 88 additions and 0 deletions

View file

@ -0,0 +1,28 @@
const TYPED_ARRAYS = [
Uint8Array,
Uint16Array,
Uint32Array,
Int8Array,
Int16Array,
Int32Array,
Float32Array,
Float64Array,
];
const BIGINT_TYPED_ARRAYS = [BigUint64Array, BigInt64Array];
test("basic functionality", () => {
TYPED_ARRAYS.forEach(T => {
const newTypedArray = T.of(1, 2, 3);
expect(newTypedArray[0]).toBe(1);
expect(newTypedArray[1]).toBe(2);
expect(newTypedArray[2]).toBe(3);
});
BIGINT_TYPED_ARRAYS.forEach(T => {
const newTypedArray = T.of(1n, 2n, 3n);
expect(newTypedArray[0]).toBe(1n);
expect(newTypedArray[1]).toBe(2n);
expect(newTypedArray[2]).toBe(3n);
});
});