From 5535af6a48738a8cb5918567b0bec01e5759076c Mon Sep 17 00:00:00 2001 From: Obinna Ikeh Date: Thu, 30 Jun 2022 20:46:38 +0100 Subject: [PATCH] LibJS: Add tests for %TypedArray%.prototype.toReversed --- .../TypedArray.prototype.toReversd.js | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Userland/Libraries/LibJS/Tests/builtins/TypedArray/TypedArray.prototype.toReversd.js b/Userland/Libraries/LibJS/Tests/builtins/TypedArray/TypedArray.prototype.toReversd.js index 074c80fe3b63393..89db5ee6533dbbd 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/TypedArray/TypedArray.prototype.toReversd.js +++ b/Userland/Libraries/LibJS/Tests/builtins/TypedArray/TypedArray.prototype.toReversd.js @@ -14,11 +14,11 @@ const BIGINT_TYPED_ARRAYS = [BigUint64Array, BigInt64Array]; test("length is 0", () => { TYPED_ARRAYS.forEach(T => { - expect(T.prototype.reverse).toHaveLength(0); + expect(T.prototype.toReversed).toHaveLength(0); }); BIGINT_TYPED_ARRAYS.forEach(T => { - expect(T.prototype.toReverse).toHaveLength(0); + expect(T.prototype.toReversed).toHaveLength(0); }); }); @@ -26,42 +26,43 @@ describe("basic functionality", () => { test("Odd length array", () => { TYPED_ARRAYS.forEach(T => { const array = new T([1, 2, 3]); - expect(array.reverse()).toEqual([3, 2, 1]); - expect(array).toEqual([3, 2, 1]); + + expect(array.toReversed()).toEqual([3, 2, 1]); + expect(array).toEqual([1, 2, 3]); }); BIGINT_TYPED_ARRAYS.forEach(T => { const array = new T([1n, 2n, 3n]); - expect(array.reverse()).toEqual([3n, 2n, 1n]); - expect(array).toEqual([3n, 2n, 1n]); + expect(array.toReversed()).toEqual([3n, 2n, 1n]); + expect(array).toEqual([1n, 2n, 3n]); }); }); test("Even length array", () => { TYPED_ARRAYS.forEach(T => { const array = new T([1, 2]); - expect(array.reverse()).toEqual([2, 1]); - expect(array).toEqual([2, 1]); + expect(array.toReversed()).toEqual([2, 1]); + expect(array).toEqual([1, 2]); }); BIGINT_TYPED_ARRAYS.forEach(T => { const array = new T([1n, 2n]); - expect(array.reverse()).toEqual([2n, 1n]); - expect(array).toEqual([2n, 1n]); + expect(array.toReversed()).toEqual([2n, 1n]); + expect(array).toEqual([1n, 2n]); }); }); test("Empty array", () => { TYPED_ARRAYS.forEach(T => { const array = new T([]); - expect(array.reverse()).toEqual([]); + expect(array.toReversed()).toEqual([]); expect(array).toEqual([]); }); BIGINT_TYPED_ARRAYS.forEach(T => { const array = new T([]); - expect(array.reverse()).toEqual([]); + expect(array.toReversed()).toEqual([]); expect(array).toEqual([]); }); }); -}); \ No newline at end of file +});