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

LibJS: Add Uint8ClampedArray to TypedArray tests

This commit is contained in:
Luke 2021-07-06 02:25:24 +01:00 committed by Linus Groh
parent 3faeabf1dc
commit 8244d7916e
18 changed files with 20 additions and 1 deletions

View file

@ -1,5 +1,6 @@
test("basic functionality", () => { test("basic functionality", () => {
expect(Uint8Array.BYTES_PER_ELEMENT).toBe(1); expect(Uint8Array.BYTES_PER_ELEMENT).toBe(1);
expect(Uint8ClampedArray.BYTES_PER_ELEMENT).toBe(1);
expect(Uint16Array.BYTES_PER_ELEMENT).toBe(2); expect(Uint16Array.BYTES_PER_ELEMENT).toBe(2);
expect(Uint32Array.BYTES_PER_ELEMENT).toBe(4); expect(Uint32Array.BYTES_PER_ELEMENT).toBe(4);
expect(BigUint64Array.BYTES_PER_ELEMENT).toBe(8); expect(BigUint64Array.BYTES_PER_ELEMENT).toBe(8);

View file

@ -1,5 +1,6 @@
const TYPED_ARRAYS = [ const TYPED_ARRAYS = [
Uint8Array, Uint8Array,
Uint8ClampedArray,
Uint16Array, Uint16Array,
Uint32Array, Uint32Array,
Int8Array, Int8Array,

View file

@ -1,5 +1,6 @@
const TYPED_ARRAYS = [ const TYPED_ARRAYS = [
Uint8Array, Uint8Array,
Uint8ClampedArray,
Uint16Array, Uint16Array,
Uint32Array, Uint32Array,
Int8Array, Int8Array,
@ -176,6 +177,7 @@ test("typed array from TypedArray element cast", () => {
const u32Expected = [ const u32Expected = [
[0, 0xff], [0, 0xff],
[0xff, 0xff],
[0x100, 0xff], [0x100, 0xff],
[0x100, 0xff], [0x100, 0xff],
[0, -1], [0, -1],
@ -184,7 +186,7 @@ test("typed array from TypedArray element cast", () => {
[0x100, 0xff], [0x100, 0xff],
[0x100, 0xff], [0x100, 0xff],
]; ];
const u8Expected = [0xff, 0xff, 0xff, -1, 0xff, 0xff, 0xff, 0xff]; const u8Expected = [0xff, 0xff, 0xff, 0xff, -1, 0xff, 0xff, 0xff, 0xff];
TYPED_ARRAYS.forEach((T, i) => { TYPED_ARRAYS.forEach((T, i) => {
const newArrFromU32 = new T(u32Array); const newArrFromU32 = new T(u32Array);

View file

@ -1,5 +1,6 @@
const TYPED_ARRAYS = [ const TYPED_ARRAYS = [
Uint8Array, Uint8Array,
Uint8ClampedArray,
Uint16Array, Uint16Array,
Uint32Array, Uint32Array,
Int8Array, Int8Array,

View file

@ -1,5 +1,6 @@
const TYPED_ARRAYS = [ const TYPED_ARRAYS = [
{ array: Uint8Array, expected: 1 }, { array: Uint8Array, expected: 1 },
{ array: Uint8ClampedArray, expected: 1 },
{ array: Uint16Array, expected: 2 }, { array: Uint16Array, expected: 2 },
{ array: Uint32Array, expected: 4 }, { array: Uint32Array, expected: 4 },
{ array: BigUint64Array, expected: 8 }, { array: BigUint64Array, expected: 8 },

View file

@ -1,5 +1,6 @@
const TYPED_ARRAYS = [ const TYPED_ARRAYS = [
Uint8Array, Uint8Array,
Uint8ClampedArray,
Uint16Array, Uint16Array,
Uint32Array, Uint32Array,
Int8Array, Int8Array,

View file

@ -1,5 +1,6 @@
const TYPED_ARRAYS = [ const TYPED_ARRAYS = [
Uint8Array, Uint8Array,
Uint8ClampedArray,
Uint16Array, Uint16Array,
Uint32Array, Uint32Array,
BigUint64Array, BigUint64Array,

View file

@ -1,5 +1,6 @@
const TYPED_ARRAYS = [ const TYPED_ARRAYS = [
{ array: Uint8Array, expected: 3 }, { array: Uint8Array, expected: 3 },
{ array: Uint8ClampedArray, expected: 3 },
{ array: Uint16Array, expected: 6 }, { array: Uint16Array, expected: 6 },
{ array: Uint32Array, expected: 12 }, { array: Uint32Array, expected: 12 },
{ array: BigUint64Array, expected: 24 }, { array: BigUint64Array, expected: 24 },

View file

@ -1,5 +1,6 @@
const TYPED_ARRAYS = [ const TYPED_ARRAYS = [
Uint8Array, Uint8Array,
Uint8ClampedArray,
Uint16Array, Uint16Array,
Uint32Array, Uint32Array,
BigUint64Array, BigUint64Array,

View file

@ -1,5 +1,6 @@
const TYPED_ARRAYS = [ const TYPED_ARRAYS = [
Uint8Array, Uint8Array,
Uint8ClampedArray,
Uint16Array, Uint16Array,
Uint32Array, Uint32Array,
Int8Array, Int8Array,

View file

@ -1,5 +1,6 @@
const TYPED_ARRAYS = [ const TYPED_ARRAYS = [
Uint8Array, Uint8Array,
Uint8ClampedArray,
Uint16Array, Uint16Array,
Uint32Array, Uint32Array,
Int8Array, Int8Array,

View file

@ -1,5 +1,6 @@
const TYPED_ARRAYS = [ const TYPED_ARRAYS = [
Uint8Array, Uint8Array,
Uint8ClampedArray,
Uint16Array, Uint16Array,
Uint32Array, Uint32Array,
Int8Array, Int8Array,

View file

@ -1,5 +1,6 @@
const TYPED_ARRAYS = [ const TYPED_ARRAYS = [
Uint8Array, Uint8Array,
Uint8ClampedArray,
Uint16Array, Uint16Array,
Uint32Array, Uint32Array,
Int8Array, Int8Array,

View file

@ -1,5 +1,6 @@
const TYPED_ARRAYS = [ const TYPED_ARRAYS = [
Uint8Array, Uint8Array,
Uint8ClampedArray,
Uint16Array, Uint16Array,
Uint32Array, Uint32Array,
Int8Array, Int8Array,

View file

@ -1,5 +1,6 @@
const TYPED_ARRAYS = [ const TYPED_ARRAYS = [
Uint8Array, Uint8Array,
Uint8ClampedArray,
Uint16Array, Uint16Array,
Uint32Array, Uint32Array,
Int8Array, Int8Array,

View file

@ -1,5 +1,6 @@
const TYPED_ARRAYS = [ const TYPED_ARRAYS = [
Uint8Array, Uint8Array,
Uint8ClampedArray,
Uint16Array, Uint16Array,
Uint32Array, Uint32Array,
BigUint64Array, BigUint64Array,

View file

@ -1,5 +1,6 @@
const TYPED_ARRAYS = [ const TYPED_ARRAYS = [
Uint8Array, Uint8Array,
Uint8ClampedArray,
Uint16Array, Uint16Array,
Uint32Array, Uint32Array,
Int8Array, Int8Array,

View file

@ -1,5 +1,6 @@
const TYPED_ARRAYS = [ const TYPED_ARRAYS = [
Uint8Array, Uint8Array,
Uint8ClampedArray,
Uint16Array, Uint16Array,
Uint32Array, Uint32Array,
Int8Array, Int8Array,