diff options
Diffstat (limited to 'Userland/Libraries/LibJS/Tests')
-rw-r--r-- | Userland/Libraries/LibJS/Tests/builtins/TypedArray/TypedArray.prototype.BYTES_PER_ELEMENT.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/builtins/TypedArray/TypedArray.prototype.BYTES_PER_ELEMENT.js b/Userland/Libraries/LibJS/Tests/builtins/TypedArray/TypedArray.prototype.BYTES_PER_ELEMENT.js new file mode 100644 index 0000000000..3d221eebd9 --- /dev/null +++ b/Userland/Libraries/LibJS/Tests/builtins/TypedArray/TypedArray.prototype.BYTES_PER_ELEMENT.js @@ -0,0 +1,18 @@ +// Update when more typed arrays get added +const TYPED_ARRAYS = [ + { array: Uint8Array, expected: 1 }, + { array: Uint16Array, expected: 2 }, + { array: Uint32Array, expected: 4 }, + { array: Int8Array, expected: 1 }, + { array: Int16Array, expected: 2 }, + { array: Int32Array, expected: 4 }, + { array: Float32Array, expected: 4 }, + { array: Float64Array, expected: 8 }, +]; + +test("basic functionality", () => { + TYPED_ARRAYS.forEach(T => { + const typedArray = new T.array(); + expect(typedArray.BYTES_PER_ELEMENT).toBe(T.expected); + }); +}); |