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

LibJS: Add %TypedArray%.prototype.toLocaleString

This commit is contained in:
Idan Horowitz 2021-07-09 23:11:14 +03:00 committed by Linus Groh
parent 56d8098d13
commit a44de7a55f
3 changed files with 71 additions and 0 deletions

View file

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