summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Tests
diff options
context:
space:
mode:
authorLuke <luke.wilde@live.co.uk>2021-05-21 21:34:25 +0100
committerLinus Groh <mail@linusgroh.de>2021-05-21 22:52:35 +0100
commit58afd71ad2f33dd75ed49253315ab2d6443b155d (patch)
treea195bd2cb2634f80149d47b912be63f94cd2e677 /Userland/Libraries/LibJS/Tests
parent8004a2dc777debc61d3098282a8ab856ed16de76 (diff)
downloadserenity-58afd71ad2f33dd75ed49253315ab2d6443b155d.zip
LibJS: Expose TypedArray.prototype.byteLength
Diffstat (limited to 'Userland/Libraries/LibJS/Tests')
-rw-r--r--Userland/Libraries/LibJS/Tests/builtins/TypedArray/TypedArray.prototype.byteLength.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/builtins/TypedArray/TypedArray.prototype.byteLength.js b/Userland/Libraries/LibJS/Tests/builtins/TypedArray/TypedArray.prototype.byteLength.js
new file mode 100644
index 0000000000..6d647fa46b
--- /dev/null
+++ b/Userland/Libraries/LibJS/Tests/builtins/TypedArray/TypedArray.prototype.byteLength.js
@@ -0,0 +1,19 @@
+// Update when more typed arrays get added
+const TYPED_ARRAYS = [
+ { array: Uint8Array, expected: 3 },
+ { array: Uint16Array, expected: 6 },
+ { array: Uint32Array, expected: 12 },
+ { array: Int8Array, expected: 3 },
+ { array: Int16Array, expected: 6 },
+ { array: Int32Array, expected: 12 },
+ { array: Float32Array, expected: 12 },
+ { array: Float64Array, expected: 24 },
+];
+
+test("basic functionality", () => {
+ TYPED_ARRAYS.forEach(T => {
+ const typedArray = new T.array([1, 2, 3]);
+ expect(Object.hasOwn(typedArray, "byteOffset")).toBeFalse();
+ expect(typedArray.byteLength).toBe(T.expected);
+ });
+});