From a2d45bd48d85bad2953d94b399a4882068e620f6 Mon Sep 17 00:00:00 2001 From: qiu_yu_jia Date: Thu, 4 Sep 2025 15:26:48 +0800 Subject: [PATCH] lambda functions index numbere2int Issue: https://gitee.com/openharmony/arkcompiler_runtime_core/issues/ICXF2K Signed-off-by: qiu_yu_jia --- .../ets/stdlib/escompat/TypedArrays.ets | 384 +++++++++--------- .../ets/stdlib/escompat/TypedUArrays.ets | 150 +++---- .../ets/templates/stdlib/typedArray.ets.j2 | 12 +- .../ets/templates/stdlib/typedUArray.ets.j2 | 6 +- .../tests/ets_es_checked/float32array.yaml | 8 +- .../ets_es_checked/float32array_lambas.yaml | 16 +- .../tests/ets_es_checked/float64array.yaml | 8 +- .../ets_es_checked/float64array_lambas.yaml | 16 +- .../ets/tests/ets_es_checked/int16array.yaml | 8 +- .../ets_es_checked/int16array_lambas.yaml | 16 +- .../ets/tests/ets_es_checked/int32array.yaml | 8 +- .../ets_es_checked/int32array_lambas.yaml | 16 +- .../ets/tests/ets_es_checked/int8array.yaml | 8 +- .../ets_es_checked/int8array_lambas.yaml | 16 +- .../ets/tests/ets_es_checked/uint16array.yaml | 8 +- .../ets_es_checked/uint16array_lambas.yaml | 16 +- .../ets/tests/ets_es_checked/uint32array.yaml | 8 +- .../ets_es_checked/uint32array_lambas.yaml | 16 +- .../ets/tests/ets_es_checked/uint8array.yaml | 8 +- .../ets_es_checked/uint8array_lambas.yaml | 16 +- .../ets_es_checked/uint8clampedarray.yaml | 8 +- .../uint8clampedarray_lambas.yaml | 16 +- .../utils/test_core_typedarray.j2 | 4 +- .../utils/test_core_typedarray_methods.j2 | 86 ++-- .../utils/test_core_typeduarray.j2 | 4 +- .../utils/test_core_typeduarray_function2.j2 | 6 +- .../utils/test_core_typeduarray_methods.j2 | 76 ++-- 27 files changed, 472 insertions(+), 472 deletions(-) diff --git a/static_core/plugins/ets/stdlib/escompat/TypedArrays.ets b/static_core/plugins/ets/stdlib/escompat/TypedArrays.ets index 2091bd3574..f91e6b32e4 100644 --- a/static_core/plugins/ets/stdlib/escompat/TypedArrays.ets +++ b/static_core/plugins/ets/stdlib/escompat/TypedArrays.ets @@ -1270,8 +1270,8 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns the last element that satisfies fn */ public findLast(fn: (val: number) => boolean): number { - let newF: (val: number, index: number, array: Int8Array) => boolean = - (val: number, index: number, array: Int8Array): boolean => { return fn(val) } + let newF: (val: number, index: int, array: Int8Array) => boolean = + (val: number, index: int, array: Int8Array): boolean => { return fn(val) } return (this.findLast(newF)).toDouble() } @@ -1341,9 +1341,9 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns false unless predicate function returns true for an array element, * in which case true is immediately returned. */ - public some(predicate: (element: number, index: number, array: Int8Array) => boolean): boolean { + public some(predicate: (element: number, index: int, array: Int8Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { + if (predicate((this.getUnsafe(i)).toDouble(), i, this)) { return true } } @@ -1364,11 +1364,11 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduce( - callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, + callbackfn: (previousValue: U, currentValue: number, currentIndex: int, array: Int8Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -1385,14 +1385,14 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduce method on an empty array without an initial value creates a TypeError */ - public reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number): number { + public reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: int, array: Int8Array) => number): number { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } let accumulatedValue = (this.getUnsafe(0)).toDouble() for (let i = 1; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -1411,11 +1411,11 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduceRight( - callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, + callbackfn: (previousValue: U, currentValue: number, currentIndex: int, array: Int8Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -1433,14 +1433,14 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduceRight method on an empty array without an initial value creates a TypeError */ - public reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number): number { + public reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: int, array: Int8Array) => number): number { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } let accumulatedValue: number = (this.getUnsafe(this.lengthInt - 1)).toDouble() for (let i = this.lengthInt - 2; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -1452,11 +1452,11 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns a new Int8Array where for each element from current Int8Array fn was applied */ - public map(fn: (val: number, index: number, array: Int8Array) => number): Int8Array { + public map(fn: (val: number, index: int, array: Int8Array) => number): Int8Array { let resBuf = new ArrayBuffer(this.lengthInt * Int8Array.BYTES_PER_ELEMENT) let res = new Int8Array(resBuf, 0, (resBuf.getByteLength() / Int8Array.BYTES_PER_ELEMENT).toInt()) for (let i = 0; i < this.lengthInt; ++i) { - res.set(i, fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this).toByte()) + res.set(i, fn((this.getUnsafe(i)).toDouble(), i, this).toByte()) } return res } @@ -1471,9 +1471,9 @@ export final class Int8Array implements Iterable, ArrayLike { * @returns true unless predicate function returns a false for an array element, * in which case false is immediately returned. */ - public every(predicate: (element: number, index: number, array: Int8Array) => boolean): boolean { + public every(predicate: (element: number, index: int, array: Int8Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (!predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { + if (!predicate((this.getUnsafe(i)).toDouble(), i, this)) { return false } } @@ -1487,11 +1487,11 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns a new Int8Array with elements from current Int8Array that satisfy condition fn */ - public filter(fn: (val: number, index: number, array: Int8Array) => boolean): Int8Array { + public filter(fn: (val: number, index: int, array: Int8Array) => boolean): Int8Array { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; ++i) { - markers[i] = fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) + markers[i] = fn((this.getUnsafe(i)).toDouble(), i, this) if (markers[i]) { ++resLen } @@ -1517,10 +1517,10 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns number | undefined */ - public find(predicate: (value: number, index: number, obj: Int8Array) => boolean): number | undefined { + public find(predicate: (value: number, index: int, obj: Int8Array) => boolean): number | undefined { for (let i = 0; i < this.lengthInt; ++i) { let val = this.getUnsafe(i) - if (predicate((val).toDouble(), i.toDouble(), this)) { + if (predicate((val).toDouble(), i, this)) { return (val).toDouble() } } @@ -1535,15 +1535,15 @@ export final class Int8Array implements Iterable, ArrayLike { * order, until it finds one where predicate returns true. If such an element is found, * findIndex immediately returns that element index. Otherwise, findIndex returns -1 * - * @returns number + * @returns int */ - public findIndex(predicate: (value: number, index: number, obj: Int8Array) => boolean): number { + public findIndex(predicate: (value: number, index: int, obj: Int8Array) => boolean): int { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { - return i.toDouble() + if (predicate((this.getUnsafe(i)).toDouble(), i, this)) { + return i } } - return (-1).toDouble() + return -1 } /** @@ -1553,10 +1553,10 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns the last element that satisfies fn */ - public findLast(fn: (val: number, index: number, array: Int8Array) => boolean): byte { + public findLast(fn: (val: number, index: int, array: Int8Array) => boolean): byte { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn((val).toDouble(), i.toDouble(), this)) { + if (fn((val).toDouble(), i, this)) { return val } } @@ -1570,14 +1570,14 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns the index of the last element that satisfies fn, -1 otherwise */ - public findLastIndex(fn: (val: number, index: number, array: Int8Array) => boolean): number { + public findLastIndex(fn: (val: number, index: int, array: Int8Array) => boolean): int { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn((val).toDouble(), i.toDouble(), this)) { + if (fn((val).toDouble(), i, this)) { return i } } - return (-1).toDouble() + return -1 } /** @@ -1588,9 +1588,9 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns None */ - public forEach(callbackfn: (value: number, index: number, array: Int8Array) => void): void { + public forEach(callbackfn: (value: number, index: int, array: Int8Array) => void): void { for (let i = 0; i < this.lengthInt; ++i) { - callbackfn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) + callbackfn((this.getUnsafe(i)).toDouble(), i, this) } } @@ -2882,8 +2882,8 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns the last element that satisfies fn */ public findLast(fn: (val: number) => boolean): number { - let newF: (val: number, index: number, array: Int16Array) => boolean = - (val: number, index: number, array: Int16Array): boolean => { return fn(val) } + let newF: (val: number, index: int, array: Int16Array) => boolean = + (val: number, index: int, array: Int16Array): boolean => { return fn(val) } return (this.findLast(newF)).toDouble() } @@ -2953,9 +2953,9 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns false unless predicate function returns true for an array element, * in which case true is immediately returned. */ - public some(predicate: (element: number, index: number, array: Int16Array) => boolean): boolean { + public some(predicate: (element: number, index: int, array: Int16Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { + if (predicate((this.getUnsafe(i)).toDouble(), i, this)) { return true } } @@ -2976,11 +2976,11 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduce( - callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, + callbackfn: (previousValue: U, currentValue: number, currentIndex: int, array: Int16Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -2997,14 +2997,14 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduce method on an empty array without an initial value creates a TypeError */ - public reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number): number { + public reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: int, array: Int16Array) => number): number { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } let accumulatedValue = (this.getUnsafe(0)).toDouble() for (let i = 1; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -3023,11 +3023,11 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduceRight( - callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, + callbackfn: (previousValue: U, currentValue: number, currentIndex: int, array: Int16Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -3045,14 +3045,14 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduceRight method on an empty array without an initial value creates a TypeError */ - public reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number): number { + public reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: int, array: Int16Array) => number): number { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } let accumulatedValue: number = (this.getUnsafe(this.lengthInt - 1)).toDouble() for (let i = this.lengthInt - 2; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -3064,11 +3064,11 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns a new Int16Array where for each element from current Int16Array fn was applied */ - public map(fn: (val: number, index: number, array: Int16Array) => number): Int16Array { + public map(fn: (val: number, index: int, array: Int16Array) => number): Int16Array { let resBuf = new ArrayBuffer(this.lengthInt * Int16Array.BYTES_PER_ELEMENT) let res = new Int16Array(resBuf, 0, (resBuf.getByteLength() / Int16Array.BYTES_PER_ELEMENT).toInt()) for (let i = 0; i < this.lengthInt; ++i) { - res.set(i, fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this).toShort()) + res.set(i, fn((this.getUnsafe(i)).toDouble(), i, this).toShort()) } return res } @@ -3083,9 +3083,9 @@ export final class Int16Array implements Iterable, ArrayLike { * @returns true unless predicate function returns a false for an array element, * in which case false is immediately returned. */ - public every(predicate: (element: number, index: number, array: Int16Array) => boolean): boolean { + public every(predicate: (element: number, index: int, array: Int16Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (!predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { + if (!predicate((this.getUnsafe(i)).toDouble(), i, this)) { return false } } @@ -3099,11 +3099,11 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns a new Int16Array with elements from current Int16Array that satisfy condition fn */ - public filter(fn: (val: number, index: number, array: Int16Array) => boolean): Int16Array { + public filter(fn: (val: number, index: int, array: Int16Array) => boolean): Int16Array { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; ++i) { - markers[i] = fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) + markers[i] = fn((this.getUnsafe(i)).toDouble(), i, this) if (markers[i]) { ++resLen } @@ -3129,10 +3129,10 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns number | undefined */ - public find(predicate: (value: number, index: number, obj: Int16Array) => boolean): number | undefined { + public find(predicate: (value: number, index: int, obj: Int16Array) => boolean): number | undefined { for (let i = 0; i < this.lengthInt; ++i) { let val = this.getUnsafe(i) - if (predicate((val).toDouble(), i.toDouble(), this)) { + if (predicate((val).toDouble(), i, this)) { return (val).toDouble() } } @@ -3147,15 +3147,15 @@ export final class Int16Array implements Iterable, ArrayLike { * order, until it finds one where predicate returns true. If such an element is found, * findIndex immediately returns that element index. Otherwise, findIndex returns -1 * - * @returns number + * @returns int */ - public findIndex(predicate: (value: number, index: number, obj: Int16Array) => boolean): number { + public findIndex(predicate: (value: number, index: int, obj: Int16Array) => boolean): int { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { - return i.toDouble() + if (predicate((this.getUnsafe(i)).toDouble(), i, this)) { + return i } } - return (-1).toDouble() + return -1 } /** @@ -3165,10 +3165,10 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns the last element that satisfies fn */ - public findLast(fn: (val: number, index: number, array: Int16Array) => boolean): short { + public findLast(fn: (val: number, index: int, array: Int16Array) => boolean): short { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn((val).toDouble(), i.toDouble(), this)) { + if (fn((val).toDouble(), i, this)) { return val } } @@ -3182,14 +3182,14 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns the index of the last element that satisfies fn, -1 otherwise */ - public findLastIndex(fn: (val: number, index: number, array: Int16Array) => boolean): number { + public findLastIndex(fn: (val: number, index: int, array: Int16Array) => boolean): int { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn((val).toDouble(), i.toDouble(), this)) { + if (fn((val).toDouble(), i, this)) { return i } } - return (-1).toDouble() + return -1 } /** @@ -3200,9 +3200,9 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns None */ - public forEach(callbackfn: (value: number, index: number, array: Int16Array) => void): void { + public forEach(callbackfn: (value: number, index: int, array: Int16Array) => void): void { for (let i = 0; i < this.lengthInt; ++i) { - callbackfn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) + callbackfn((this.getUnsafe(i)).toDouble(), i, this) } } @@ -4470,8 +4470,8 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns the last element that satisfies fn */ public findLast(fn: (val: number) => boolean): number { - let newF: (val: number, index: number, array: Int32Array) => boolean = - (val: number, index: number, array: Int32Array): boolean => { return fn(val) } + let newF: (val: number, index: int, array: Int32Array) => boolean = + (val: number, index: int, array: Int32Array): boolean => { return fn(val) } return (this.findLast(newF)).toDouble() } @@ -4541,9 +4541,9 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns false unless predicate function returns true for an array element, * in which case true is immediately returned. */ - public some(predicate: (element: number, index: number, array: Int32Array) => boolean): boolean { + public some(predicate: (element: number, index: int, array: Int32Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { + if (predicate((this.getUnsafe(i)).toDouble(), i, this)) { return true } } @@ -4564,11 +4564,11 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduce( - callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, + callbackfn: (previousValue: U, currentValue: number, currentIndex: int, array: Int32Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -4585,14 +4585,14 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduce method on an empty array without an initial value creates a TypeError */ - public reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number): number { + public reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: int, array: Int32Array) => number): number { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } let accumulatedValue = (this.getUnsafe(0)).toDouble() for (let i = 1; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -4611,11 +4611,11 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduceRight( - callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, + callbackfn: (previousValue: U, currentValue: number, currentIndex: int, array: Int32Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -4633,14 +4633,14 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduceRight method on an empty array without an initial value creates a TypeError */ - public reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number): number { + public reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: int, array: Int32Array) => number): number { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } let accumulatedValue: number = (this.getUnsafe(this.lengthInt - 1)).toDouble() for (let i = this.lengthInt - 2; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -4652,11 +4652,11 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns a new Int32Array where for each element from current Int32Array fn was applied */ - public map(fn: (val: number, index: number, array: Int32Array) => number): Int32Array { + public map(fn: (val: number, index: int, array: Int32Array) => number): Int32Array { let resBuf = new ArrayBuffer(this.lengthInt * Int32Array.BYTES_PER_ELEMENT) let res = new Int32Array(resBuf, 0, (resBuf.getByteLength() / Int32Array.BYTES_PER_ELEMENT).toInt()) for (let i = 0; i < this.lengthInt; ++i) { - res.set(i, fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this).toInt()) + res.set(i, fn((this.getUnsafe(i)).toDouble(), i, this).toInt()) } return res } @@ -4671,9 +4671,9 @@ export final class Int32Array implements Iterable, ArrayLike { * @returns true unless predicate function returns a false for an array element, * in which case false is immediately returned. */ - public every(predicate: (element: number, index: number, array: Int32Array) => boolean): boolean { + public every(predicate: (element: number, index: int, array: Int32Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (!predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { + if (!predicate((this.getUnsafe(i)).toDouble(), i, this)) { return false } } @@ -4687,11 +4687,11 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns a new Int32Array with elements from current Int32Array that satisfy condition fn */ - public filter(fn: (val: number, index: number, array: Int32Array) => boolean): Int32Array { + public filter(fn: (val: number, index: int, array: Int32Array) => boolean): Int32Array { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; ++i) { - markers[i] = fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) + markers[i] = fn((this.getUnsafe(i)).toDouble(), i, this) if (markers[i]) { ++resLen } @@ -4717,10 +4717,10 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns number | undefined */ - public find(predicate: (value: number, index: number, obj: Int32Array) => boolean): number | undefined { + public find(predicate: (value: number, index: int, obj: Int32Array) => boolean): number | undefined { for (let i = 0; i < this.lengthInt; ++i) { let val = this.getUnsafe(i) - if (predicate((val).toDouble(), i.toDouble(), this)) { + if (predicate((val).toDouble(), i, this)) { return (val).toDouble() } } @@ -4735,15 +4735,15 @@ export final class Int32Array implements Iterable, ArrayLike { * order, until it finds one where predicate returns true. If such an element is found, * findIndex immediately returns that element index. Otherwise, findIndex returns -1 * - * @returns number + * @returns int */ - public findIndex(predicate: (value: number, index: number, obj: Int32Array) => boolean): number { + public findIndex(predicate: (value: number, index: int, obj: Int32Array) => boolean): int { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { - return i.toDouble() + if (predicate((this.getUnsafe(i)).toDouble(), i, this)) { + return i } } - return (-1).toDouble() + return -1 } /** @@ -4753,10 +4753,10 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns the last element that satisfies fn */ - public findLast(fn: (val: number, index: number, array: Int32Array) => boolean): int { + public findLast(fn: (val: number, index: int, array: Int32Array) => boolean): int { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn((val).toDouble(), i.toDouble(), this)) { + if (fn((val).toDouble(), i, this)) { return val } } @@ -4770,14 +4770,14 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns the index of the last element that satisfies fn, -1 otherwise */ - public findLastIndex(fn: (val: number, index: number, array: Int32Array) => boolean): number { + public findLastIndex(fn: (val: number, index: int, array: Int32Array) => boolean): int { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn((val).toDouble(), i.toDouble(), this)) { + if (fn((val).toDouble(), i, this)) { return i } } - return (-1).toDouble() + return -1 } /** @@ -4788,9 +4788,9 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns None */ - public forEach(callbackfn: (value: number, index: number, array: Int32Array) => void): void { + public forEach(callbackfn: (value: number, index: int, array: Int32Array) => void): void { for (let i = 0; i < this.lengthInt; ++i) { - callbackfn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) + callbackfn((this.getUnsafe(i)).toDouble(), i, this) } } @@ -6070,8 +6070,8 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns the last element that satisfies fn */ public findLast(fn: (val: BigInt) => boolean): BigInt { - let newF: (val: BigInt, index: number, array: BigInt64Array) => boolean = - (val: BigInt, index: number, array: BigInt64Array): boolean => { return fn(val) } + let newF: (val: BigInt, index: int, array: BigInt64Array) => boolean = + (val: BigInt, index: int, array: BigInt64Array): boolean => { return fn(val) } return new BigInt(this.findLast(newF)) } @@ -6145,9 +6145,9 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns false unless predicate function returns true for an array element, * in which case true is immediately returned. */ - public some(predicate: (element: BigInt, index: number, array: BigInt64Array) => boolean): boolean { + public some(predicate: (element: BigInt, index: int, array: BigInt64Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate(new BigInt(this.getUnsafe(i)), i.toDouble(), this)) { + if (predicate(new BigInt(this.getUnsafe(i)), i, this)) { return true } } @@ -6168,11 +6168,11 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduce( - callbackfn: (previousValue: U, currentValue: BigInt, currentIndex: number, array: BigInt64Array) => U, + callbackfn: (previousValue: U, currentValue: BigInt, currentIndex: int, array: BigInt64Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i, this) } return accumulatedValue } @@ -6189,14 +6189,14 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduce method on an empty array without an initial value creates a TypeError */ - public reduce(callbackfn: (previousValue: BigInt, currentValue: BigInt, currentIndex: number, array: BigInt64Array) => BigInt): BigInt { + public reduce(callbackfn: (previousValue: BigInt, currentValue: BigInt, currentIndex: int, array: BigInt64Array) => BigInt): BigInt { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } let accumulatedValue = new BigInt(this.getUnsafe(0)) for (let i = 1; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i, this) } return accumulatedValue } @@ -6215,11 +6215,11 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduceRight( - callbackfn: (previousValue: U, currentValue: BigInt, currentIndex: number, array: BigInt64Array) => U, + callbackfn: (previousValue: U, currentValue: BigInt, currentIndex: int, array: BigInt64Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i, this) } return accumulatedValue } @@ -6237,14 +6237,14 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduceRight method on an empty array without an initial value creates a TypeError */ - public reduceRight(callbackfn: (previousValue: BigInt, currentValue: BigInt, currentIndex: number, array: BigInt64Array) => BigInt): BigInt { + public reduceRight(callbackfn: (previousValue: BigInt, currentValue: BigInt, currentIndex: int, array: BigInt64Array) => BigInt): BigInt { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } let accumulatedValue: BigInt = new BigInt(this.getUnsafe(this.lengthInt - 1)) for (let i = this.lengthInt - 2; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, new BigInt(this.getUnsafe(i)), i, this) } return accumulatedValue } @@ -6256,11 +6256,11 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns a new BigInt64Array where for each element from current BigInt64Array fn was applied */ - public map(fn: (val: BigInt, index: number, array: BigInt64Array) => BigInt): BigInt64Array { + public map(fn: (val: BigInt, index: int, array: BigInt64Array) => BigInt): BigInt64Array { let resBuf = new ArrayBuffer(this.lengthInt * BigInt64Array.BYTES_PER_ELEMENT) let res = new BigInt64Array(resBuf, 0, (resBuf.getByteLength() / BigInt64Array.BYTES_PER_ELEMENT).toInt()) for (let i = 0; i < this.lengthInt; ++i) { - res.set(i, fn(new BigInt(this.getUnsafe(i)), i.toDouble(), this).getLong()) + res.set(i, fn(new BigInt(this.getUnsafe(i)), i, this).getLong()) } return res } @@ -6275,9 +6275,9 @@ export final class BigInt64Array implements Iterable, ArrayLike * @returns true unless predicate function returns a false for an array element, * in which case false is immediately returned. */ - public every(predicate: (element: BigInt, index: number, array: BigInt64Array) => boolean): boolean { + public every(predicate: (element: BigInt, index: int, array: BigInt64Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (!predicate(new BigInt(this.getUnsafe(i)), i.toDouble(), this)) { + if (!predicate(new BigInt(this.getUnsafe(i)), i, this)) { return false } } @@ -6291,11 +6291,11 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns a new BigInt64Array with elements from current BigInt64Array that satisfy condition fn */ - public filter(fn: (val: BigInt, index: number, array: BigInt64Array) => boolean): BigInt64Array { + public filter(fn: (val: BigInt, index: int, array: BigInt64Array) => boolean): BigInt64Array { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; ++i) { - markers[i] = fn(new BigInt(this.getUnsafe(i)), i.toDouble(), this) + markers[i] = fn(new BigInt(this.getUnsafe(i)), i, this) if (markers[i]) { ++resLen } @@ -6321,10 +6321,10 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns BigInt | undefined */ - public find(predicate: (value: BigInt, index: number, obj: BigInt64Array) => boolean): BigInt | undefined { + public find(predicate: (value: BigInt, index: int, obj: BigInt64Array) => boolean): BigInt | undefined { for (let i = 0; i < this.lengthInt; ++i) { let val = this.getUnsafe(i) - if (predicate(new BigInt(val), i.toDouble(), this)) { + if (predicate(new BigInt(val), i, this)) { return new BigInt(val) } } @@ -6339,15 +6339,15 @@ export final class BigInt64Array implements Iterable, ArrayLike * order, until it finds one where predicate returns true. If such an element is found, * findIndex immediately returns that element index. Otherwise, findIndex returns -1 * - * @returns number + * @returns int */ - public findIndex(predicate: (value: BigInt, index: number, obj: BigInt64Array) => boolean): number { + public findIndex(predicate: (value: BigInt, index: int, obj: BigInt64Array) => boolean): int { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate(new BigInt(this.getUnsafe(i)), i.toDouble(), this)) { - return i.toDouble() + if (predicate(new BigInt(this.getUnsafe(i)), i, this)) { + return i } } - return (-1).toDouble() + return -1 } /** @@ -6357,10 +6357,10 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns the last element that satisfies fn */ - public findLast(fn: (val: BigInt, index: number, array: BigInt64Array) => boolean): long { + public findLast(fn: (val: BigInt, index: int, array: BigInt64Array) => boolean): long { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn(new BigInt(val), i.toDouble(), this)) { + if (fn(new BigInt(val), i, this)) { return val } } @@ -6374,14 +6374,14 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns the index of the last element that satisfies fn, -1 otherwise */ - public findLastIndex(fn: (val: BigInt, index: number, array: BigInt64Array) => boolean): number { + public findLastIndex(fn: (val: BigInt, index: int, array: BigInt64Array) => boolean): int { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn(new BigInt(val), i.toDouble(), this)) { + if (fn(new BigInt(val), i, this)) { return i } } - return (-1).toDouble() + return -1 } /** @@ -6392,9 +6392,9 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns None */ - public forEach(callbackfn: (value: BigInt, index: number, array: BigInt64Array) => void): void { + public forEach(callbackfn: (value: BigInt, index: int, array: BigInt64Array) => void): void { for (let i = 0; i < this.lengthInt; ++i) { - callbackfn(new BigInt(this.getUnsafe(i)), i.toDouble(), this) + callbackfn(new BigInt(this.getUnsafe(i)), i, this) } } @@ -7647,8 +7647,8 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns the last element that satisfies fn */ public findLast(fn: (val: number) => boolean): number { - let newF: (val: number, index: number, array: Float32Array) => boolean = - (val: number, index: number, array: Float32Array): boolean => { return fn(val) } + let newF: (val: number, index: int, array: Float32Array) => boolean = + (val: number, index: int, array: Float32Array): boolean => { return fn(val) } return (this.findLast(newF)).toDouble() } @@ -7735,9 +7735,9 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns false unless predicate function returns true for an array element, * in which case true is immediately returned. */ - public some(predicate: (element: number, index: number, array: Float32Array) => boolean): boolean { + public some(predicate: (element: number, index: int, array: Float32Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { + if (predicate((this.getUnsafe(i)).toDouble(), i, this)) { return true } } @@ -7758,11 +7758,11 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduce( - callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, + callbackfn: (previousValue: U, currentValue: number, currentIndex: int, array: Float32Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -7779,14 +7779,14 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduce method on an empty array without an initial value creates a TypeError */ - public reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number): number { + public reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: int, array: Float32Array) => number): number { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } let accumulatedValue = (this.getUnsafe(0)).toDouble() for (let i = 1; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -7805,11 +7805,11 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduceRight( - callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, + callbackfn: (previousValue: U, currentValue: number, currentIndex: int, array: Float32Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -7827,14 +7827,14 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduceRight method on an empty array without an initial value creates a TypeError */ - public reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number): number { + public reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: int, array: Float32Array) => number): number { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } let accumulatedValue: number = (this.getUnsafe(this.lengthInt - 1)).toDouble() for (let i = this.lengthInt - 2; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -7846,11 +7846,11 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns a new Float32Array where for each element from current Float32Array fn was applied */ - public map(fn: (val: number, index: number, array: Float32Array) => number): Float32Array { + public map(fn: (val: number, index: int, array: Float32Array) => number): Float32Array { let resBuf = new ArrayBuffer(this.lengthInt * Float32Array.BYTES_PER_ELEMENT) let res = new Float32Array(resBuf, 0, (resBuf.getByteLength() / Float32Array.BYTES_PER_ELEMENT).toInt()) for (let i = 0; i < this.lengthInt; ++i) { - res.set(i, fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this).toFloat()) + res.set(i, fn((this.getUnsafe(i)).toDouble(), i, this).toFloat()) } return res } @@ -7865,9 +7865,9 @@ export final class Float32Array implements Iterable, ArrayLike { * @returns true unless predicate function returns a false for an array element, * in which case false is immediately returned. */ - public every(predicate: (element: number, index: number, array: Float32Array) => boolean): boolean { + public every(predicate: (element: number, index: int, array: Float32Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (!predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { + if (!predicate((this.getUnsafe(i)).toDouble(), i, this)) { return false } } @@ -7881,11 +7881,11 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns a new Float32Array with elements from current Float32Array that satisfy condition fn */ - public filter(fn: (val: number, index: number, array: Float32Array) => boolean): Float32Array { + public filter(fn: (val: number, index: int, array: Float32Array) => boolean): Float32Array { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; ++i) { - markers[i] = fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) + markers[i] = fn((this.getUnsafe(i)).toDouble(), i, this) if (markers[i]) { ++resLen } @@ -7911,10 +7911,10 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns number | undefined */ - public find(predicate: (value: number, index: number, obj: Float32Array) => boolean): number | undefined { + public find(predicate: (value: number, index: int, obj: Float32Array) => boolean): number | undefined { for (let i = 0; i < this.lengthInt; ++i) { let val = this.getUnsafe(i) - if (predicate((val).toDouble(), i.toDouble(), this)) { + if (predicate((val).toDouble(), i, this)) { return (val).toDouble() } } @@ -7929,15 +7929,15 @@ export final class Float32Array implements Iterable, ArrayLike { * order, until it finds one where predicate returns true. If such an element is found, * findIndex immediately returns that element index. Otherwise, findIndex returns -1 * - * @returns number + * @returns int */ - public findIndex(predicate: (value: number, index: number, obj: Float32Array) => boolean): number { + public findIndex(predicate: (value: number, index: int, obj: Float32Array) => boolean): int { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { - return i.toDouble() + if (predicate((this.getUnsafe(i)).toDouble(), i, this)) { + return i } } - return (-1).toDouble() + return -1 } /** @@ -7947,10 +7947,10 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns the last element that satisfies fn */ - public findLast(fn: (val: number, index: number, array: Float32Array) => boolean): float { + public findLast(fn: (val: number, index: int, array: Float32Array) => boolean): float { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn((val).toDouble(), i.toDouble(), this)) { + if (fn((val).toDouble(), i, this)) { return val } } @@ -7964,14 +7964,14 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns the index of the last element that satisfies fn, -1 otherwise */ - public findLastIndex(fn: (val: number, index: number, array: Float32Array) => boolean): number { + public findLastIndex(fn: (val: number, index: int, array: Float32Array) => boolean): int { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn((val).toDouble(), i.toDouble(), this)) { + if (fn((val).toDouble(), i, this)) { return i } } - return (-1).toDouble() + return -1 } /** @@ -7982,9 +7982,9 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns None */ - public forEach(callbackfn: (value: number, index: number, array: Float32Array) => void): void { + public forEach(callbackfn: (value: number, index: int, array: Float32Array) => void): void { for (let i = 0; i < this.lengthInt; ++i) { - callbackfn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) + callbackfn((this.getUnsafe(i)).toDouble(), i, this) } } @@ -9164,8 +9164,8 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns the last element that satisfies fn */ public findLast(fn: (val: number) => boolean): number { - let newF: (val: number, index: number, array: Float64Array) => boolean = - (val: number, index: number, array: Float64Array): boolean => { return fn(val) } + let newF: (val: number, index: int, array: Float64Array) => boolean = + (val: number, index: int, array: Float64Array): boolean => { return fn(val) } return (this.findLast(newF)).toDouble() } @@ -9252,9 +9252,9 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns false unless predicate function returns true for an array element, * in which case true is immediately returned. */ - public some(predicate: (element: number, index: number, array: Float64Array) => boolean): boolean { + public some(predicate: (element: number, index: int, array: Float64Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { + if (predicate((this.getUnsafe(i)).toDouble(), i, this)) { return true } } @@ -9275,11 +9275,11 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduce( - callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, + callbackfn: (previousValue: U, currentValue: number, currentIndex: int, array: Float64Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -9296,14 +9296,14 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduce method on an empty array without an initial value creates a TypeError */ - public reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number): number { + public reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: int, array: Float64Array) => number): number { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } let accumulatedValue = (this.getUnsafe(0)).toDouble() for (let i = 1; i < this.lengthInt; ++i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -9322,11 +9322,11 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduceRight( - callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, + callbackfn: (previousValue: U, currentValue: number, currentIndex: int, array: Float64Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -9344,14 +9344,14 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduceRight method on an empty array without an initial value creates a TypeError */ - public reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number): number { + public reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: int, array: Float64Array) => number): number { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } let accumulatedValue: number = (this.getUnsafe(this.lengthInt - 1)).toDouble() for (let i = this.lengthInt - 2; i >= 0; --i) { - accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i.toDouble(), this) + accumulatedValue = callbackfn(accumulatedValue, (this.getUnsafe(i)).toDouble(), i, this) } return accumulatedValue } @@ -9363,11 +9363,11 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns a new Float64Array where for each element from current Float64Array fn was applied */ - public map(fn: (val: number, index: number, array: Float64Array) => number): Float64Array { + public map(fn: (val: number, index: int, array: Float64Array) => number): Float64Array { let resBuf = new ArrayBuffer(this.lengthInt * Float64Array.BYTES_PER_ELEMENT) let res = new Float64Array(resBuf, 0, (resBuf.getByteLength() / Float64Array.BYTES_PER_ELEMENT).toInt()) for (let i = 0; i < this.lengthInt; ++i) { - res.set(i, fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this).toDouble()) + res.set(i, fn((this.getUnsafe(i)).toDouble(), i, this).toDouble()) } return res } @@ -9382,9 +9382,9 @@ export final class Float64Array implements Iterable, ArrayLike { * @returns true unless predicate function returns a false for an array element, * in which case false is immediately returned. */ - public every(predicate: (element: number, index: number, array: Float64Array) => boolean): boolean { + public every(predicate: (element: number, index: int, array: Float64Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; ++i) { - if (!predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { + if (!predicate((this.getUnsafe(i)).toDouble(), i, this)) { return false } } @@ -9398,11 +9398,11 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns a new Float64Array with elements from current Float64Array that satisfy condition fn */ - public filter(fn: (val: number, index: number, array: Float64Array) => boolean): Float64Array { + public filter(fn: (val: number, index: int, array: Float64Array) => boolean): Float64Array { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; ++i) { - markers[i] = fn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) + markers[i] = fn((this.getUnsafe(i)).toDouble(), i, this) if (markers[i]) { ++resLen } @@ -9428,10 +9428,10 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns number | undefined */ - public find(predicate: (value: number, index: number, obj: Float64Array) => boolean): number | undefined { + public find(predicate: (value: number, index: int, obj: Float64Array) => boolean): number | undefined { for (let i = 0; i < this.lengthInt; ++i) { let val = this.getUnsafe(i) - if (predicate((val).toDouble(), i.toDouble(), this)) { + if (predicate((val).toDouble(), i, this)) { return (val).toDouble() } } @@ -9446,15 +9446,15 @@ export final class Float64Array implements Iterable, ArrayLike { * order, until it finds one where predicate returns true. If such an element is found, * findIndex immediately returns that element index. Otherwise, findIndex returns -1 * - * @returns number + * @returns int */ - public findIndex(predicate: (value: number, index: number, obj: Float64Array) => boolean): number { + public findIndex(predicate: (value: number, index: int, obj: Float64Array) => boolean): int { for (let i = 0; i < this.lengthInt; ++i) { - if (predicate((this.getUnsafe(i)).toDouble(), i.toDouble(), this)) { - return i.toDouble() + if (predicate((this.getUnsafe(i)).toDouble(), i, this)) { + return i } } - return (-1).toDouble() + return -1 } /** @@ -9464,10 +9464,10 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns the last element that satisfies fn */ - public findLast(fn: (val: number, index: number, array: Float64Array) => boolean): double { + public findLast(fn: (val: number, index: int, array: Float64Array) => boolean): double { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn((val).toDouble(), i.toDouble(), this)) { + if (fn((val).toDouble(), i, this)) { return val } } @@ -9481,14 +9481,14 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns the index of the last element that satisfies fn, -1 otherwise */ - public findLastIndex(fn: (val: number, index: number, array: Float64Array) => boolean): number { + public findLastIndex(fn: (val: number, index: int, array: Float64Array) => boolean): int { for (let i = this.lengthInt - 1; i >= 0; --i) { let val = this.getUnsafe(i) - if (fn((val).toDouble(), i.toDouble(), this)) { + if (fn((val).toDouble(), i, this)) { return i } } - return (-1).toDouble() + return -1 } /** @@ -9499,9 +9499,9 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns None */ - public forEach(callbackfn: (value: number, index: number, array: Float64Array) => void): void { + public forEach(callbackfn: (value: number, index: int, array: Float64Array) => void): void { for (let i = 0; i < this.lengthInt; ++i) { - callbackfn((this.getUnsafe(i)).toDouble(), i.toDouble(), this) + callbackfn((this.getUnsafe(i)).toDouble(), i, this) } } diff --git a/static_core/plugins/ets/stdlib/escompat/TypedUArrays.ets b/static_core/plugins/ets/stdlib/escompat/TypedUArrays.ets index 77de5230e0..98c5b7d041 100644 --- a/static_core/plugins/ets/stdlib/escompat/TypedUArrays.ets +++ b/static_core/plugins/ets/stdlib/escompat/TypedUArrays.ets @@ -1321,7 +1321,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike boolean): boolean { + public some(predicate: (element: number, index: int, array: Uint8ClampedArray) => boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { if (predicate(this.getUnsafe(i).toDouble(), i, this)) { return true @@ -1344,7 +1344,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike( - callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, + callbackfn: (previousValue: U, currentValue: number, currentIndex: int, array: Uint8ClampedArray) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; i++) { @@ -1365,7 +1365,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike number): number { + public reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: int, array: Uint8ClampedArray) => number): number { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } @@ -1391,7 +1391,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike( - callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, + callbackfn: (previousValue: U, currentValue: number, currentIndex: int, array: Uint8ClampedArray) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; i--) { @@ -1412,7 +1412,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike number): number { + public reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: int, array: Uint8ClampedArray) => number): number { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } @@ -1431,7 +1431,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike number): Uint8ClampedArray { + public map(fn: (val: number, index: int, array: Uint8ClampedArray) => number): Uint8ClampedArray { let resBuf = new ArrayBuffer(this.lengthInt * Uint8ClampedArray.BYTES_PER_ELEMENT) let res = new Uint8ClampedArray(resBuf) for (let i = 0; i < this.lengthInt; i++) { @@ -1451,7 +1451,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike boolean): boolean { + public every(predicate: (element: number, index: int, array: Uint8ClampedArray) => boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { if (!predicate(this.getUnsafe(i).toDouble(), i, this)) { return false @@ -1467,7 +1467,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike boolean): Uint8ClampedArray { + public filter(fn: (val: number, index: int, array: Uint8ClampedArray) => boolean): Uint8ClampedArray { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; i++) { @@ -1496,7 +1496,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike boolean): number | undefined { + public find(predicate: (value: number, index: int, array: Uint8ClampedArray) => boolean): number | undefined { for (let i = 0; i < this.lengthInt; i++) { let val = this.getUnsafe(i).toDouble() if (predicate(val, i, this)) { @@ -1514,9 +1514,9 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike boolean): number { + public findIndex(predicate: (value: number, index: int, obj: Uint8ClampedArray) => boolean): int { for (let i = 0; i < this.lengthInt; i++) { if (predicate(this.getUnsafe(i).toDouble(), i, this)) { return i @@ -1532,7 +1532,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike boolean): number { + public findLast(fn: (val: number, index: int, array: Uint8ClampedArray) => boolean): number { for (let i = this.lengthInt - 1; i >= 0; i--) { let val = this.getUnsafe(i).toDouble() if (fn(val, i, this)) { @@ -1549,7 +1549,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike boolean): number { + public findLastIndex(fn: (val: number, index: int, array: Uint8ClampedArray) => boolean): int { for (let i = this.lengthInt - 1; i >= 0; i--) { if (fn(this.getUnsafe(i).toDouble(), i, this)) { return i @@ -1566,9 +1566,9 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike void): void { + public forEach(callbackfn: (value: number, index: int, array: Uint8ClampedArray) => void): void { for (let i = 0; i < this.lengthInt; i++) { - callbackfn(this.getUnsafe(i).toDouble(), i.toDouble(), this) + callbackfn(this.getUnsafe(i).toDouble(), i, this) } } @@ -2933,7 +2933,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns false unless predicate function returns true for an array element, * in which case true is immediately returned. */ - public some(predicate: (element: number, index: number, array: Uint8Array) => boolean): boolean { + public some(predicate: (element: number, index: int, array: Uint8Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { if (predicate(this.getUnsafe(i).toDouble(), i, this)) { return true @@ -2956,7 +2956,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduce( - callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, + callbackfn: (previousValue: U, currentValue: number, currentIndex: int, array: Uint8Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; i++) { @@ -2977,7 +2977,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduce method on an empty array without an initial value creates a TypeError */ - public reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number): number { + public reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: int, array: Uint8Array) => number): number { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } @@ -3003,7 +3003,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduceRight( - callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, + callbackfn: (previousValue: U, currentValue: number, currentIndex: int, array: Uint8Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; i--) { @@ -3024,7 +3024,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduceRight method on an empty array without an initial value creates a TypeError */ - public reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number): number { + public reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: int, array: Uint8Array) => number): number { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } @@ -3043,7 +3043,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns a new Uint8Array where for each element from current Uint8Array fn was applied */ - public map(fn: (val: number, index: number, array: Uint8Array) => number): Uint8Array { + public map(fn: (val: number, index: int, array: Uint8Array) => number): Uint8Array { let resBuf = new ArrayBuffer(this.lengthInt * Uint8Array.BYTES_PER_ELEMENT) let res = new Uint8Array(resBuf) for (let i = 0; i < this.lengthInt; i++) { @@ -3063,7 +3063,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @returns true unless predicate function returns a false for an array element, * in which case false is immediately returned. */ - public every(predicate: (element: number, index: number, array: Uint8Array) => boolean): boolean { + public every(predicate: (element: number, index: int, array: Uint8Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { if (!predicate(this.getUnsafe(i).toDouble(), i, this)) { return false @@ -3079,7 +3079,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns a new Uint8Array with elements from current Uint8Array that satisfy condition fn */ - public filter(fn: (val: number, index: number, array: Uint8Array) => boolean): Uint8Array { + public filter(fn: (val: number, index: int, array: Uint8Array) => boolean): Uint8Array { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; i++) { @@ -3108,7 +3108,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns number | undefined */ - public find(predicate: (value: number, index: number, array: Uint8Array) => boolean): number | undefined { + public find(predicate: (value: number, index: int, array: Uint8Array) => boolean): number | undefined { for (let i = 0; i < this.lengthInt; i++) { let val = this.getUnsafe(i).toDouble() if (predicate(val, i, this)) { @@ -3126,9 +3126,9 @@ export final class Uint8Array implements Iterable, ArrayLike { * order, until it finds one where predicate returns true. If such an element is found, * findIndex immediately returns that element index. Otherwise, findIndex returns -1 * - * @returns number + * @returns int */ - public findIndex(predicate: (value: number, index: number, obj: Uint8Array) => boolean): number { + public findIndex(predicate: (value: number, index: int, obj: Uint8Array) => boolean): int { for (let i = 0; i < this.lengthInt; i++) { if (predicate(this.getUnsafe(i).toDouble(), i, this)) { return i @@ -3144,7 +3144,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns the last element that satisfies fn */ - public findLast(fn: (val: number, index: number, array: Uint8Array) => boolean): number { + public findLast(fn: (val: number, index: int, array: Uint8Array) => boolean): number { for (let i = this.lengthInt - 1; i >= 0; i--) { let val = this.getUnsafe(i).toDouble() if (fn(val, i, this)) { @@ -3161,7 +3161,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns the index of the last element that satisfies fn, -1 otherwise */ - public findLastIndex(fn: (val: number, index: number, array: Uint8Array) => boolean): number { + public findLastIndex(fn: (val: number, index: int, array: Uint8Array) => boolean): int { for (let i = this.lengthInt - 1; i >= 0; i--) { if (fn(this.getUnsafe(i).toDouble(), i, this)) { return i @@ -3178,9 +3178,9 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns None */ - public forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void): void { + public forEach(callbackfn: (value: number, index: int, array: Uint8Array) => void): void { for (let i = 0; i < this.lengthInt; i++) { - callbackfn(this.getUnsafe(i).toDouble(), i.toDouble(), this) + callbackfn(this.getUnsafe(i).toDouble(), i, this) } } @@ -4528,7 +4528,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns false unless predicate function returns true for an array element, * in which case true is immediately returned. */ - public some(predicate: (element: number, index: number, array: Uint16Array) => boolean): boolean { + public some(predicate: (element: number, index: int, array: Uint16Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { if (predicate(this.getUnsafe(i).toDouble(), i, this)) { return true @@ -4551,7 +4551,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduce( - callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, + callbackfn: (previousValue: U, currentValue: number, currentIndex: int, array: Uint16Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; i++) { @@ -4572,7 +4572,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduce method on an empty array without an initial value creates a TypeError */ - public reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number): number { + public reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: int, array: Uint16Array) => number): number { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } @@ -4598,7 +4598,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduceRight( - callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, + callbackfn: (previousValue: U, currentValue: number, currentIndex: int, array: Uint16Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; i--) { @@ -4619,7 +4619,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduceRight method on an empty array without an initial value creates a TypeError */ - public reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number): number { + public reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: int, array: Uint16Array) => number): number { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } @@ -4638,7 +4638,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns a new Uint16Array where for each element from current Uint16Array fn was applied */ - public map(fn: (val: number, index: number, array: Uint16Array) => number): Uint16Array { + public map(fn: (val: number, index: int, array: Uint16Array) => number): Uint16Array { let resBuf = new ArrayBuffer(this.lengthInt * Uint16Array.BYTES_PER_ELEMENT) let res = new Uint16Array(resBuf) for (let i = 0; i < this.lengthInt; i++) { @@ -4658,7 +4658,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @returns true unless predicate function returns a false for an array element, * in which case false is immediately returned. */ - public every(predicate: (element: number, index: number, array: Uint16Array) => boolean): boolean { + public every(predicate: (element: number, index: int, array: Uint16Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { if (!predicate(this.getUnsafe(i).toDouble(), i, this)) { return false @@ -4674,7 +4674,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns a new Uint16Array with elements from current Uint16Array that satisfy condition fn */ - public filter(fn: (val: number, index: number, array: Uint16Array) => boolean): Uint16Array { + public filter(fn: (val: number, index: int, array: Uint16Array) => boolean): Uint16Array { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; i++) { @@ -4703,7 +4703,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns number | undefined */ - public find(predicate: (value: number, index: number, array: Uint16Array) => boolean): number | undefined { + public find(predicate: (value: number, index: int, array: Uint16Array) => boolean): number | undefined { for (let i = 0; i < this.lengthInt; i++) { let val = this.getUnsafe(i).toDouble() if (predicate(val, i, this)) { @@ -4721,9 +4721,9 @@ export final class Uint16Array implements Iterable, ArrayLike { * order, until it finds one where predicate returns true. If such an element is found, * findIndex immediately returns that element index. Otherwise, findIndex returns -1 * - * @returns number + * @returns int */ - public findIndex(predicate: (value: number, index: number, obj: Uint16Array) => boolean): number { + public findIndex(predicate: (value: number, index: int, obj: Uint16Array) => boolean): int { for (let i = 0; i < this.lengthInt; i++) { if (predicate(this.getUnsafe(i).toDouble(), i, this)) { return i @@ -4739,7 +4739,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns the last element that satisfies fn */ - public findLast(fn: (val: number, index: number, array: Uint16Array) => boolean): number { + public findLast(fn: (val: number, index: int, array: Uint16Array) => boolean): number { for (let i = this.lengthInt - 1; i >= 0; i--) { let val = this.getUnsafe(i).toDouble() if (fn(val, i, this)) { @@ -4756,7 +4756,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns the index of the last element that satisfies fn, -1 otherwise */ - public findLastIndex(fn: (val: number, index: number, array: Uint16Array) => boolean): number { + public findLastIndex(fn: (val: number, index: int, array: Uint16Array) => boolean): int { for (let i = this.lengthInt - 1; i >= 0; i--) { if (fn(this.getUnsafe(i).toDouble(), i, this)) { return i @@ -4773,9 +4773,9 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns None */ - public forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void): void { + public forEach(callbackfn: (value: number, index: int, array: Uint16Array) => void): void { for (let i = 0; i < this.lengthInt; i++) { - callbackfn(this.getUnsafe(i).toDouble(), i.toDouble(), this) + callbackfn(this.getUnsafe(i).toDouble(), i, this) } } @@ -6158,7 +6158,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns false unless predicate function returns true for an array element, * in which case true is immediately returned. */ - public some(predicate: (element: number, index: number, array: Uint32Array) => boolean): boolean { + public some(predicate: (element: number, index: int, array: Uint32Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { if (predicate(this.getUnsafe(i).toDouble(), i, this)) { return true @@ -6181,7 +6181,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduce( - callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, + callbackfn: (previousValue: U, currentValue: number, currentIndex: int, array: Uint32Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; i++) { @@ -6202,7 +6202,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduce method on an empty array without an initial value creates a TypeError */ - public reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number): number { + public reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: int, array: Uint32Array) => number): number { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } @@ -6228,7 +6228,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduceRight( - callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, + callbackfn: (previousValue: U, currentValue: number, currentIndex: int, array: Uint32Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; i--) { @@ -6249,7 +6249,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduceRight method on an empty array without an initial value creates a TypeError */ - public reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number): number { + public reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: int, array: Uint32Array) => number): number { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } @@ -6268,7 +6268,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns a new Uint32Array where for each element from current Uint32Array fn was applied */ - public map(fn: (val: number, index: number, array: Uint32Array) => number): Uint32Array { + public map(fn: (val: number, index: int, array: Uint32Array) => number): Uint32Array { let resBuf = new ArrayBuffer(this.lengthInt * Uint32Array.BYTES_PER_ELEMENT) let res = new Uint32Array(resBuf) for (let i = 0; i < this.lengthInt; i++) { @@ -6288,7 +6288,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @returns true unless predicate function returns a false for an array element, * in which case false is immediately returned. */ - public every(predicate: (element: number, index: number, array: Uint32Array) => boolean): boolean { + public every(predicate: (element: number, index: int, array: Uint32Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { if (!predicate(this.getUnsafe(i).toDouble(), i, this)) { return false @@ -6304,7 +6304,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns a new Uint32Array with elements from current Uint32Array that satisfy condition fn */ - public filter(fn: (val: number, index: number, array: Uint32Array) => boolean): Uint32Array { + public filter(fn: (val: number, index: int, array: Uint32Array) => boolean): Uint32Array { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; i++) { @@ -6333,7 +6333,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns number | undefined */ - public find(predicate: (value: number, index: number, array: Uint32Array) => boolean): number | undefined { + public find(predicate: (value: number, index: int, array: Uint32Array) => boolean): number | undefined { for (let i = 0; i < this.lengthInt; i++) { let val = this.getUnsafe(i).toDouble() if (predicate(val, i, this)) { @@ -6351,9 +6351,9 @@ export final class Uint32Array implements Iterable, ArrayLike { * order, until it finds one where predicate returns true. If such an element is found, * findIndex immediately returns that element index. Otherwise, findIndex returns -1 * - * @returns number + * @returns int */ - public findIndex(predicate: (value: number, index: number, obj: Uint32Array) => boolean): number { + public findIndex(predicate: (value: number, index: int, obj: Uint32Array) => boolean): int { for (let i = 0; i < this.lengthInt; i++) { if (predicate(this.getUnsafe(i).toDouble(), i, this)) { return i @@ -6369,7 +6369,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns the last element that satisfies fn */ - public findLast(fn: (val: number, index: number, array: Uint32Array) => boolean): number { + public findLast(fn: (val: number, index: int, array: Uint32Array) => boolean): number { for (let i = this.lengthInt - 1; i >= 0; i--) { let val = this.getUnsafe(i).toDouble() if (fn(val, i, this)) { @@ -6386,7 +6386,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns the index of the last element that satisfies fn, -1 otherwise */ - public findLastIndex(fn: (val: number, index: number, array: Uint32Array) => boolean): number { + public findLastIndex(fn: (val: number, index: int, array: Uint32Array) => boolean): int { for (let i = this.lengthInt - 1; i >= 0; i--) { if (fn(this.getUnsafe(i).toDouble(), i, this)) { return i @@ -6403,9 +6403,9 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns None */ - public forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void): void { + public forEach(callbackfn: (value: number, index: int, array: Uint32Array) => void): void { for (let i = 0; i < this.lengthInt; i++) { - callbackfn(this.getUnsafe(i).toDouble(), i.toDouble(), this) + callbackfn(this.getUnsafe(i).toDouble(), i, this) } } @@ -7780,7 +7780,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns false unless predicate function returns true for an array element, * in which case true is immediately returned. */ - public some(predicate: (element: BigInt, index: number, array: BigUint64Array) => boolean): boolean { + public some(predicate: (element: BigInt, index: int, array: BigUint64Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { if (predicate(new BigInt(this.getUnsafe(i)), i, this)) { return true @@ -7803,7 +7803,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduce( - callbackfn: (previousValue: U, currentValue: BigInt, currentIndex: number, array: BigUint64Array) => U, + callbackfn: (previousValue: U, currentValue: BigInt, currentIndex: int, array: BigUint64Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = 0; i < this.lengthInt; i++) { @@ -7824,7 +7824,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduce method on an empty array without an initial value creates a TypeError */ - public reduce(callbackfn: (previousValue: BigInt, currentValue: BigInt, currentIndex: number, array: BigUint64Array) => BigInt): BigInt { + public reduce(callbackfn: (previousValue: BigInt, currentValue: BigInt, currentIndex: int, array: BigUint64Array) => BigInt): BigInt { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } @@ -7850,7 +7850,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns The value that results from running the callback function to completion over the entire typed array. */ public reduceRight( - callbackfn: (previousValue: U, currentValue: BigInt, currentIndex: number, array: BigUint64Array) => U, + callbackfn: (previousValue: U, currentValue: BigInt, currentIndex: int, array: BigUint64Array) => U, initialValue: U): U { let accumulatedValue = initialValue for (let i = this.lengthInt - 1; i >= 0; i--) { @@ -7871,7 +7871,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns The value that results from running the callback function to completion over the entire typed array. * calling reduceRight method on an empty array without an initial value creates a TypeError */ - public reduceRight(callbackfn: (previousValue: BigInt, currentValue: BigInt, currentIndex: number, array: BigUint64Array) => BigInt): BigInt { + public reduceRight(callbackfn: (previousValue: BigInt, currentValue: BigInt, currentIndex: int, array: BigUint64Array) => BigInt): BigInt { if (this.lengthInt == 0) { throw new TypeError("Reduce of empty array with no initial value") } @@ -7890,7 +7890,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns a new BigUint64Array where for each element from current BigUint64Array fn was applied */ - public map(fn: (val: BigInt, index: number, array: BigUint64Array) => BigInt): BigUint64Array { + public map(fn: (val: BigInt, index: int, array: BigUint64Array) => BigInt): BigUint64Array { let resBuf = new ArrayBuffer(this.lengthInt * BigUint64Array.BYTES_PER_ELEMENT) let res = new BigUint64Array(resBuf) for (let i = 0; i < this.lengthInt; i++) { @@ -7910,7 +7910,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @returns true unless predicate function returns a false for an array element, * in which case false is immediately returned. */ - public every(predicate: (element: BigInt, index: number, array: BigUint64Array) => boolean): boolean { + public every(predicate: (element: BigInt, index: int, array: BigUint64Array) => boolean): boolean { for (let i = 0; i < this.lengthInt; i++) { if (!predicate(new BigInt(this.getUnsafe(i)), i, this)) { return false @@ -7926,7 +7926,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns a new BigUint64Array with elements from current BigUint64Array that satisfy condition fn */ - public filter(fn: (val: BigInt, index: number, array: BigUint64Array) => boolean): BigUint64Array { + public filter(fn: (val: BigInt, index: int, array: BigUint64Array) => boolean): BigUint64Array { let markers : FixedArray = new boolean[this.lengthInt] let resLen = 0 for (let i = 0; i < this.lengthInt; i++) { @@ -7955,7 +7955,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns BigInt | undefined */ - public find(predicate: (value: BigInt, index: number, array: BigUint64Array) => boolean): BigInt | undefined { + public find(predicate: (value: BigInt, index: int, array: BigUint64Array) => boolean): BigInt | undefined { for (let i = 0; i < this.lengthInt; i++) { let val = new BigInt(this.getUnsafe(i)) if (predicate(val, i, this)) { @@ -7973,9 +7973,9 @@ export final class BigUint64Array implements Iterable, ArrayLike * order, until it finds one where predicate returns true. If such an element is found, * findIndex immediately returns that element index. Otherwise, findIndex returns -1 * - * @returns number + * @returns int */ - public findIndex(predicate: (value: BigInt, index: number, obj: BigUint64Array) => boolean): number { + public findIndex(predicate: (value: BigInt, index: int, obj: BigUint64Array) => boolean): int { for (let i = 0; i < this.lengthInt; i++) { if (predicate(new BigInt(this.getUnsafe(i)), i, this)) { return i @@ -7991,7 +7991,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns the last element that satisfies fn */ - public findLast(fn: (val: BigInt, index: number, array: BigUint64Array) => boolean): BigInt { + public findLast(fn: (val: BigInt, index: int, array: BigUint64Array) => boolean): BigInt { for (let i = this.lengthInt - 1; i >= 0; i--) { let val = new BigInt(this.getUnsafe(i)) if (fn(val, i, this)) { @@ -8008,7 +8008,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns the index of the last element that satisfies fn, -1 otherwise */ - public findLastIndex(fn: (val: BigInt, index: number, array: BigUint64Array) => boolean): number { + public findLastIndex(fn: (val: BigInt, index: int, array: BigUint64Array) => boolean): int { for (let i = this.lengthInt - 1; i >= 0; i--) { if (fn(new BigInt(this.getUnsafe(i)), i, this)) { return i @@ -8025,9 +8025,9 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns None */ - public forEach(callbackfn: (value: BigInt, index: number, array: BigUint64Array) => void): void { + public forEach(callbackfn: (value: BigInt, index: int, array: BigUint64Array) => void): void { for (let i = 0; i < this.lengthInt; i++) { - callbackfn(new BigInt(this.getUnsafe(i)), i.toDouble(), this) + callbackfn(new BigInt(this.getUnsafe(i)), i, this) } } diff --git a/static_core/plugins/ets/templates/stdlib/typedArray.ets.j2 b/static_core/plugins/ets/templates/stdlib/typedArray.ets.j2 index cb924b0999..2255c725c7 100644 --- a/static_core/plugins/ets/templates/stdlib/typedArray.ets.j2 +++ b/static_core/plugins/ets/templates/stdlib/typedArray.ets.j2 @@ -1469,7 +1469,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi /// === with element lambda functions === {#- NOTE: to add overloads with idxType == 'int' we need to enhance generics supports #} - {%- for idxType, castToIdx in [('number', '.toDouble()')] %} + {%- for idxType, castToIdx in [('int', '')] %} {%- set skip = False %} {%- set elType, castToEl, castFromEl = elementCompat, asElementCompat, fromElementCompat %} {%- set retType = 'number | undefined' if elementCompat == 'number' else 'BigInt | undefined' %} @@ -1483,8 +1483,8 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * @returns the last element that satisfies fn */ public findLast(fn: (val: {{elType}}) => boolean): {{elType}} { - let newF: (val: {{elType}}, index: number, array: {{N}}Array) => boolean = - (val: {{elType}}, index: number, array: {{N}}Array): boolean => { return fn(val) } + let newF: (val: {{elType}}, index: int, array: {{N}}Array) => boolean = + (val: {{elType}}, index: int, array: {{N}}Array): boolean => { return fn(val) } return {{castToEl % 'this.findLast(newF)'}} } @@ -1806,7 +1806,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi return i{{castToIdx}} } } - return (-1){{castToIdx}} + return -1 } /** @@ -1840,7 +1840,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi return i } } - return (-1){{castToIdx}} + return -1 } /** @@ -1851,7 +1851,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * @returns None */ - public forEach(callbackfn: (value: {{elType}}, index: number, array: {{N}}Array) => void): void { + public forEach(callbackfn: (value: {{elType}}, index: {{idxType}}, array: {{N}}Array) => void): void { for (let i = 0; i < this.lengthInt; ++i) { callbackfn({{castToEl % 'this.getUnsafe(i)'}}, i{{castToIdx}}, this) } diff --git a/static_core/plugins/ets/templates/stdlib/typedUArray.ets.j2 b/static_core/plugins/ets/templates/stdlib/typedUArray.ets.j2 index 252cdb62f6..9f5886ef62 100644 --- a/static_core/plugins/ets/templates/stdlib/typedUArray.ets.j2 +++ b/static_core/plugins/ets/templates/stdlib/typedUArray.ets.j2 @@ -1531,7 +1531,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse {%- set elType, castToEl, castFromEl = element['primitiveType'], '%s', '%s' %} {%- else %} {#- NOTE: castToIdx as toDouble() is not neccessary, widening should be applied implicitly #} - {%- set idxType, castToIdx = 'number', '' %} + {%- set idxType, castToIdx = 'int', '' %} {%- set elType, castToEl, castFromEl = element['subsetType'], asElementCompat, fromElementCompat %} {%- endif %} @@ -1795,9 +1795,9 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * @returns None */ - public forEach(callbackfn: (value: {{elType}}, index: number, array: {{element['name']}}Array) => void): void { + public forEach(callbackfn: (value: {{elType}}, index: {{idxType}}, array: {{element['name']}}Array) => void): void { for (let i = 0; i < this.lengthInt; i++) { - callbackfn({{castToEl % 'this.getUnsafe(i)'}}, i.toDouble(), this) + callbackfn({{castToEl % 'this.getUnsafe(i)'}}, i{{castToIdx}}, this) } } diff --git a/static_core/plugins/ets/tests/ets_es_checked/float32array.yaml b/static_core/plugins/ets/tests/ets_es_checked/float32array.yaml index 98b1c10dc7..bf1c106b68 100644 --- a/static_core/plugins/ets/tests/ets_es_checked/float32array.yaml +++ b/static_core/plugins/ets/tests/ets_es_checked/float32array.yaml @@ -25,14 +25,14 @@ sub: - "() => 1.1" - "(a: number) => a" - "(a: number, b: number) => a + b" - - "(a: number, b: number, i: number) => a + b + i" - - "(a: number, b: number, i: number, selfRef: Float32Array) => a + b + i" + - "(a: number, b: number, i) => a + b + i" + - "(a: number, b: number, i, selfRef: Float32Array) => a + b + i" reduce_u_lambdas: - "(): string => '*'" - "(a: string): string => '*' + a" - "(a: string, b: number): string => a + ',' + b" - - "(a: string, b: number, i: number): string => a + ',' + (b + i)" - - "(a: string, b: number, i: number, selfRef: Float32Array): string => a + ',' + (b + i)" + - "(a: string, b: number, i): string => a + ',' + (b + i)" + - "(a: string, b: number, i, selfRef: Float32Array): string => a + ',' + (b + i)" sub: - method: "at" params: diff --git a/static_core/plugins/ets/tests/ets_es_checked/float32array_lambas.yaml b/static_core/plugins/ets/tests/ets_es_checked/float32array_lambas.yaml index 1d85452601..fe6eb174b8 100644 --- a/static_core/plugins/ets/tests/ets_es_checked/float32array_lambas.yaml +++ b/static_core/plugins/ets/tests/ets_es_checked/float32array_lambas.yaml @@ -36,26 +36,26 @@ sub: - | (x: number): boolean => Math.abs(x) == 1 - | - (x: number, i: number): boolean => (x + i) > 0 + (x: number, i): boolean => (x + i) > 0 - | - (x: number, i: number, s: Float32Array): boolean => (x + i) > 0 + (x: number, i, s: Float32Array): boolean => (x + i) > 0 - | - (x: number, i: number, s: Float32Array): boolean => (x + i) % 2 == 0 + (x: number, i, s: Float32Array): boolean => (x + i) % 2 == 0 - | - (x: number, i: number, s: Float32Array): boolean => i % 2 == 0 + (x: number, i, s: Float32Array): boolean => i % 2 == 0 - | - (x: number, i: number, s: Float32Array): boolean => (x + i) < 0 + (x: number, i, s: Float32Array): boolean => (x + i) < 0 - | - (x: number, i: number, s: Float32Array): boolean => (x + i) == 1 + (x: number, i, s: Float32Array): boolean => (x + i) == 1 void_lambdas: - | (): void => {} - | (x: number): void => { x = x*2 } - | - (x: number, i: number): void => { x = x*2 } + (x: number, i): void => { x = x*2 } - | - (x: number, i: number, s: Float32Array): void => { x = x + 1000 } + (x: number, i, s: Float32Array): void => { x = x + 1000 } sub: - method: find params: diff --git a/static_core/plugins/ets/tests/ets_es_checked/float64array.yaml b/static_core/plugins/ets/tests/ets_es_checked/float64array.yaml index 5675ece159..397bf787a7 100644 --- a/static_core/plugins/ets/tests/ets_es_checked/float64array.yaml +++ b/static_core/plugins/ets/tests/ets_es_checked/float64array.yaml @@ -25,14 +25,14 @@ sub: - "() => 1.1" - "(a: number) => a" - "(a: number, b: number) => a + b" - - "(a: number, b: number, i: number) => a + b + i" - - "(a: number, b: number, i: number, selfRef: Float64Array) => a + b + i" + - "(a: number, b: number, i) => a + b + i" + - "(a: number, b: number, i, selfRef: Float64Array) => a + b + i" reduce_u_lambdas: - "(): string => '*'" - "(a: string): string => '*' + a" - "(a: string, b: number): string => a + ',' + b" - - "(a: string, b: number, i: number): string => a + ',' + (b + i)" - - "(a: string, b: number, i: number, selfRef: Float64Array): string => a + ',' + (b + i)" + - "(a: string, b: number, i): string => a + ',' + (b + i)" + - "(a: string, b: number, i, selfRef: Float64Array): string => a + ',' + (b + i)" sub: - method: "at" params: diff --git a/static_core/plugins/ets/tests/ets_es_checked/float64array_lambas.yaml b/static_core/plugins/ets/tests/ets_es_checked/float64array_lambas.yaml index e7323e403d..9b20e17bde 100644 --- a/static_core/plugins/ets/tests/ets_es_checked/float64array_lambas.yaml +++ b/static_core/plugins/ets/tests/ets_es_checked/float64array_lambas.yaml @@ -36,26 +36,26 @@ sub: - | (x: number): boolean => Math.abs(x) == 1 - | - (x: number, i: number): boolean => (x + i) > 0 + (x: number, i): boolean => (x + i) > 0 - | - (x: number, i: number, s: Float64Array): boolean => (x + i) > 0 + (x: number, i, s: Float64Array): boolean => (x + i) > 0 - | - (x: number, i: number, s: Float64Array): boolean => (x + i) % 2 == 0 + (x: number, i, s: Float64Array): boolean => (x + i) % 2 == 0 - | - (x: number, i: number, s: Float64Array): boolean => i % 2 == 0 + (x: number, i, s: Float64Array): boolean => i % 2 == 0 - | - (x: number, i: number, s: Float64Array): boolean => (x + i) < 0 + (x: number, i, s: Float64Array): boolean => (x + i) < 0 - | - (x: number, i: number, s: Float64Array): boolean => (x + i) == 1 + (x: number, i, s: Float64Array): boolean => (x + i) == 1 void_lambdas: - | (): void => {} - | (x: number): void => { x = x*2 } - | - (x: number, i: number): void => { x = x*2 } + (x: number, i): void => { x = x*2 } - | - (x: number, i: number, s: Float64Array): void => { x = x + 1000 } + (x: number, i, s: Float64Array): void => { x = x + 1000 } sub: - method: find params: diff --git a/static_core/plugins/ets/tests/ets_es_checked/int16array.yaml b/static_core/plugins/ets/tests/ets_es_checked/int16array.yaml index 8ac175ebba..776ad83c4a 100644 --- a/static_core/plugins/ets/tests/ets_es_checked/int16array.yaml +++ b/static_core/plugins/ets/tests/ets_es_checked/int16array.yaml @@ -25,14 +25,14 @@ sub: - "() => 1.0" - "(a: number) => a" - "(a: number, b: number) => a + b" - - "(a: number, b: number, i: number) => a + b + i" - - "(a: number, b: number, i: number, selfRef: Int16Array) => a + b + i" + - "(a: number, b: number, i) => a + b + i" + - "(a: number, b: number, i, selfRef: Int16Array) => a + b + i" reduce_u_lambdas: - "(): string => '*'" - "(a: string): string => '*' + a" - "(a: string, b: number): string => a + ',' + b" - - "(a: string, b: number, i: number): string => a + ',' + (b + i)" - - "(a: string, b: number, i: number, selfRef: Int16Array): string => a + ',' + (b + i)" + - "(a: string, b: number, i): string => a + ',' + (b + i)" + - "(a: string, b: number, i, selfRef: Int16Array): string => a + ',' + (b + i)" sub: - method: "at" params: diff --git a/static_core/plugins/ets/tests/ets_es_checked/int16array_lambas.yaml b/static_core/plugins/ets/tests/ets_es_checked/int16array_lambas.yaml index ee6355571a..9bdcf6e400 100644 --- a/static_core/plugins/ets/tests/ets_es_checked/int16array_lambas.yaml +++ b/static_core/plugins/ets/tests/ets_es_checked/int16array_lambas.yaml @@ -36,26 +36,26 @@ sub: - | (x: number): boolean => Math.abs(x) == 1 - | - (x: number, i: number): boolean => (x + i) > 0 + (x: number, i): boolean => (x + i) > 0 - | - (x: number, i: number, s: Int16Array): boolean => (x + i) > 0 + (x: number, i, s: Int16Array): boolean => (x + i) > 0 - | - (x: number, i: number, s: Int16Array): boolean => (x + i) % 2 == 0 + (x: number, i, s: Int16Array): boolean => (x + i) % 2 == 0 - | - (x: number, i: number, s: Int16Array): boolean => i % 2 == 0 + (x: number, i, s: Int16Array): boolean => i % 2 == 0 - | - (x: number, i: number, s: Int16Array): boolean => (x + i) < 0 + (x: number, i, s: Int16Array): boolean => (x + i) < 0 - | - (x: number, i: number, s: Int16Array): boolean => (x + i) == 1 + (x: number, i, s: Int16Array): boolean => (x + i) == 1 void_lambdas: - | (): void => {} - | (x: number): void => { x = x*2 } - | - (x: number, i: number): void => { x = x*2 } + (x: number, i): void => { x = x*2 } - | - (x: number, i: number, s: Int16Array): void => { x = x + 1000 } + (x: number, i, s: Int16Array): void => { x = x + 1000 } sub: - method: find params: diff --git a/static_core/plugins/ets/tests/ets_es_checked/int32array.yaml b/static_core/plugins/ets/tests/ets_es_checked/int32array.yaml index fd83c2a7fd..d51c8a754b 100644 --- a/static_core/plugins/ets/tests/ets_es_checked/int32array.yaml +++ b/static_core/plugins/ets/tests/ets_es_checked/int32array.yaml @@ -25,14 +25,14 @@ sub: - "() => 1.0" - "(a: number) => a" - "(a: number, b: number) => a + b" - - "(a: number, b: number, i: number) => a + b + i" - - "(a: number, b: number, i: number, selfRef: Int32Array) => a + b + i" + - "(a: number, b: number, i) => a + b + i" + - "(a: number, b: number, i, selfRef: Int32Array) => a + b + i" reduce_u_lambdas: - "(): string => '*'" - "(a: string): string => '*' + a" - "(a: string, b: number): string => a + ',' + b" - - "(a: string, b: number, i: number): string => a + ',' + (b + i)" - - "(a: string, b: number, i: number, selfRef: Int32Array): string => a + ',' + (b + i)" + - "(a: string, b: number, i): string => a + ',' + (b + i)" + - "(a: string, b: number, i, selfRef: Int32Array): string => a + ',' + (b + i)" sub: - method: "at" params: diff --git a/static_core/plugins/ets/tests/ets_es_checked/int32array_lambas.yaml b/static_core/plugins/ets/tests/ets_es_checked/int32array_lambas.yaml index 8f280f1830..71f3e04caf 100644 --- a/static_core/plugins/ets/tests/ets_es_checked/int32array_lambas.yaml +++ b/static_core/plugins/ets/tests/ets_es_checked/int32array_lambas.yaml @@ -36,26 +36,26 @@ sub: - | (x: number): boolean => Math.abs(x) == 1 - | - (x: number, i: number): boolean => (x + i) > 0 + (x: number, i): boolean => (x + i) > 0 - | - (x: number, i: number, s: Int32Array): boolean => (x + i) > 0 + (x: number, i, s: Int32Array): boolean => (x + i) > 0 - | - (x: number, i: number, s: Int32Array): boolean => (x + i) % 2 == 0 + (x: number, i, s: Int32Array): boolean => (x + i) % 2 == 0 - | - (x: number, i: number, s: Int32Array): boolean => i % 2 == 0 + (x: number, i, s: Int32Array): boolean => i % 2 == 0 - | - (x: number, i: number, s: Int32Array): boolean => (x + i) < 0 + (x: number, i, s: Int32Array): boolean => (x + i) < 0 - | - (x: number, i: number, s: Int32Array): boolean => (x + i) == 1 + (x: number, i, s: Int32Array): boolean => (x + i) == 1 void_lambdas: - | (): void => {} - | (x: number): void => { x = x*2 } - | - (x: number, i: number): void => { x = x*2 } + (x: number, i): void => { x = x*2 } - | - (x: number, i: number, s: Int32Array): void => { x = x + 1000 } + (x: number, i, s: Int32Array): void => { x = x + 1000 } sub: - method: find params: diff --git a/static_core/plugins/ets/tests/ets_es_checked/int8array.yaml b/static_core/plugins/ets/tests/ets_es_checked/int8array.yaml index 55bc2524a8..5a43cd1813 100644 --- a/static_core/plugins/ets/tests/ets_es_checked/int8array.yaml +++ b/static_core/plugins/ets/tests/ets_es_checked/int8array.yaml @@ -25,14 +25,14 @@ sub: - "() => 1.0" - "(a: number) => a" - "(a: number, b: number) => a + b" - - "(a: number, b: number, i: number) => a + b + i" - - "(a: number, b: number, i: number, selfRef: Int8Array) => a + b + i" + - "(a: number, b: number, i) => a + b + i" + - "(a: number, b: number, i, selfRef: Int8Array) => a + b + i" reduce_u_lambdas: - "(): string => '*'" - "(a: string): string => '*' + a" - "(a: string, b: number): string => a + ',' + b" - - "(a: string, b: number, i: number): string => a + ',' + (b + i)" - - "(a: string, b: number, i: number, selfRef: Int8Array): string => a + ',' + (b + i)" + - "(a: string, b: number, i): string => a + ',' + (b + i)" + - "(a: string, b: number, i, selfRef: Int8Array): string => a + ',' + (b + i)" sub: - method: "at" params: diff --git a/static_core/plugins/ets/tests/ets_es_checked/int8array_lambas.yaml b/static_core/plugins/ets/tests/ets_es_checked/int8array_lambas.yaml index 8368dc720f..5e66ad5203 100644 --- a/static_core/plugins/ets/tests/ets_es_checked/int8array_lambas.yaml +++ b/static_core/plugins/ets/tests/ets_es_checked/int8array_lambas.yaml @@ -36,26 +36,26 @@ sub: - | (x: number): boolean => Math.abs(x) == 1 - | - (x: number, i: number): boolean => (x + i) > 0 + (x: number, i): boolean => (x + i) > 0 - | - (x: number, i: number, s: Int8Array): boolean => (x + i) > 0 + (x: number, i, s: Int8Array): boolean => (x + i) > 0 - | - (x: number, i: number, s: Int8Array): boolean => (x + i) % 2 == 0 + (x: number, i, s: Int8Array): boolean => (x + i) % 2 == 0 - | - (x: number, i: number, s: Int8Array): boolean => i % 2 == 0 + (x: number, i, s: Int8Array): boolean => i % 2 == 0 - | - (x: number, i: number, s: Int8Array): boolean => (x + i) < 0 + (x: number, i, s: Int8Array): boolean => (x + i) < 0 - | - (x: number, i: number, s: Int8Array): boolean => (x + i) == 1 + (x: number, i, s: Int8Array): boolean => (x + i) == 1 void_lambdas: - | (): void => {} - | (x: number): void => { x = x*2 } - | - (x: number, i: number): void => { x = x*2 } + (x: number, i): void => { x = x*2 } - | - (x: number, i: number, s: Int8Array): void => { x = x + 1000 } + (x: number, i, s: Int8Array): void => { x = x + 1000 } sub: - method: find params: diff --git a/static_core/plugins/ets/tests/ets_es_checked/uint16array.yaml b/static_core/plugins/ets/tests/ets_es_checked/uint16array.yaml index c6cf063a61..81c2d994af 100644 --- a/static_core/plugins/ets/tests/ets_es_checked/uint16array.yaml +++ b/static_core/plugins/ets/tests/ets_es_checked/uint16array.yaml @@ -25,14 +25,14 @@ sub: - "() => 1.0" - "(a: number) => a" - "(a: number, b: number) => a + b" - - "(a: number, b: number, i: number) => a + b + i" - - "(a: number, b: number, i: number, selfRef: Uint16Array) => a + b + i" + - "(a: number, b: number, i) => a + b + i" + - "(a: number, b: number, i, selfRef: Uint16Array) => a + b + i" reduce_u_lambdas: - "(): string => '*'" - "(a: string): string => '*' + a" - "(a: string, b: number): string => a + ',' + b" - - "(a: string, b: number, i: number): string => a + ',' + (b + i)" - - "(a: string, b: number, i: number, selfRef: Uint16Array): string => a + ',' + (b + i)" + - "(a: string, b: number, i): string => a + ',' + (b + i)" + - "(a: string, b: number, i, selfRef: Uint16Array): string => a + ',' + (b + i)" sub: - method: "at" params: diff --git a/static_core/plugins/ets/tests/ets_es_checked/uint16array_lambas.yaml b/static_core/plugins/ets/tests/ets_es_checked/uint16array_lambas.yaml index 6fa0095083..457766482f 100644 --- a/static_core/plugins/ets/tests/ets_es_checked/uint16array_lambas.yaml +++ b/static_core/plugins/ets/tests/ets_es_checked/uint16array_lambas.yaml @@ -36,26 +36,26 @@ sub: - | (x: number): boolean => Math.abs(x) == 1 - | - (x: number, i: number): boolean => (x + i) > 0 + (x: number, i): boolean => (x + i) > 0 - | - (x: number, i: number, s: Uint16Array): boolean => (x + i) > 0 + (x: number, i, s: Uint16Array): boolean => (x + i) > 0 - | - (x: number, i: number, s: Uint16Array): boolean => (x + i) % 2 == 0 + (x: number, i, s: Uint16Array): boolean => (x + i) % 2 == 0 - | - (x: number, i: number, s: Uint16Array): boolean => i % 2 == 0 + (x: number, i, s: Uint16Array): boolean => i % 2 == 0 - | - (x: number, i: number, s: Uint16Array): boolean => (x + i) < 0 + (x: number, i, s: Uint16Array): boolean => (x + i) < 0 - | - (x: number, i: number, s: Uint16Array): boolean => (x + i) == 1 + (x: number, i, s: Uint16Array): boolean => (x + i) == 1 void_lambdas: - | (): void => {} - | (x: number): void => { x = x*2 } - | - (x: number, i: number): void => { x = x*2 } + (x: number, i): void => { x = x*2 } - | - (x: number, i: number, s: Uint16Array): void => { x = x + 1000 } + (x: number, i, s: Uint16Array): void => { x = x + 1000 } sub: - method: find params: diff --git a/static_core/plugins/ets/tests/ets_es_checked/uint32array.yaml b/static_core/plugins/ets/tests/ets_es_checked/uint32array.yaml index a0167fc3b3..d9f12f2667 100644 --- a/static_core/plugins/ets/tests/ets_es_checked/uint32array.yaml +++ b/static_core/plugins/ets/tests/ets_es_checked/uint32array.yaml @@ -25,14 +25,14 @@ sub: - "() => 1.0" - "(a: number) => a" - "(a: number, b: number) => a + b" - - "(a: number, b: number, i: number) => a + b + i" - - "(a: number, b: number, i: number, selfRef: Uint32Array) => a + b + i" + - "(a: number, b: number, i) => a + b + i" + - "(a: number, b: number, i, selfRef: Uint32Array) => a + b + i" reduce_u_lambdas: - "(): string => '*'" - "(a: string): string => '*' + a" - "(a: string, b: number): string => a + ',' + b" - - "(a: string, b: number, i: number): string => a + ',' + (b + i)" - - "(a: string, b: number, i: number, selfRef: Uint32Array): string => a + ',' + (b + i)" + - "(a: string, b: number, i): string => a + ',' + (b + i)" + - "(a: string, b: number, i, selfRef: Uint32Array): string => a + ',' + (b + i)" sub: - method: "at" params: diff --git a/static_core/plugins/ets/tests/ets_es_checked/uint32array_lambas.yaml b/static_core/plugins/ets/tests/ets_es_checked/uint32array_lambas.yaml index 3e7ce0ff6c..8952a1fed5 100644 --- a/static_core/plugins/ets/tests/ets_es_checked/uint32array_lambas.yaml +++ b/static_core/plugins/ets/tests/ets_es_checked/uint32array_lambas.yaml @@ -36,26 +36,26 @@ sub: - | (x: number): boolean => Math.abs(x) == 1 - | - (x: number, i: number): boolean => (x + i) > 0 + (x: number, i): boolean => (x + i) > 0 - | - (x: number, i: number, s: Uint32Array): boolean => (x + i) > 0 + (x: number, i, s: Uint32Array): boolean => (x + i) > 0 - | - (x: number, i: number, s: Uint32Array): boolean => (x + i) % 2 == 0 + (x: number, i, s: Uint32Array): boolean => (x + i) % 2 == 0 - | - (x: number, i: number, s: Uint32Array): boolean => i % 2 == 0 + (x: number, i, s: Uint32Array): boolean => i % 2 == 0 - | - (x: number, i: number, s: Uint32Array): boolean => (x + i) < 0 + (x: number, i, s: Uint32Array): boolean => (x + i) < 0 - | - (x: number, i: number, s: Uint32Array): boolean => (x + i) == 1 + (x: number, i, s: Uint32Array): boolean => (x + i) == 1 void_lambdas: - | (): void => {} - | (x: number): void => { x = x*2 } - | - (x: number, i: number): void => { x = x*2 } + (x: number, i): void => { x = x*2 } - | - (x: number, i: number, s: Uint32Array): void => { x = x + 1000 } + (x: number, i, s: Uint32Array): void => { x = x + 1000 } sub: - method: find params: diff --git a/static_core/plugins/ets/tests/ets_es_checked/uint8array.yaml b/static_core/plugins/ets/tests/ets_es_checked/uint8array.yaml index e78e9e3e05..1a39fb518a 100644 --- a/static_core/plugins/ets/tests/ets_es_checked/uint8array.yaml +++ b/static_core/plugins/ets/tests/ets_es_checked/uint8array.yaml @@ -25,14 +25,14 @@ sub: - "() => 1.0" - "(a: number) => a" - "(a: number, b: number) => a + b" - - "(a: number, b: number, i: number) => a + b + i" - - "(a: number, b: number, i: number, selfRef: Uint8Array) => a + b + i" + - "(a: number, b: number, i) => a + b + i" + - "(a: number, b: number, i, selfRef: Uint8Array) => a + b + i" reduce_u_lambdas: - "(): string => '*'" - "(a: string): string => '*' + a" - "(a: string, b: number): string => a + ',' + b" - - "(a: string, b: number, i: number): string => a + ',' + (b + i)" - - "(a: string, b: number, i: number, selfRef: Uint8Array): string => a + ',' + (b + i)" + - "(a: string, b: number, i): string => a + ',' + (b + i)" + - "(a: string, b: number, i, selfRef: Uint8Array): string => a + ',' + (b + i)" sub: - method: "at" params: diff --git a/static_core/plugins/ets/tests/ets_es_checked/uint8array_lambas.yaml b/static_core/plugins/ets/tests/ets_es_checked/uint8array_lambas.yaml index cc12b5f1ae..b5ebd7511e 100644 --- a/static_core/plugins/ets/tests/ets_es_checked/uint8array_lambas.yaml +++ b/static_core/plugins/ets/tests/ets_es_checked/uint8array_lambas.yaml @@ -36,26 +36,26 @@ sub: - | (x: number): boolean => Math.abs(x) == 1 - | - (x: number, i: number): boolean => (x + i) > 0 + (x: number, i): boolean => (x + i) > 0 - | - (x: number, i: number, s: Uint8Array): boolean => (x + i) > 0 + (x: number, i, s: Uint8Array): boolean => (x + i) > 0 - | - (x: number, i: number, s: Uint8Array): boolean => (x + i) % 2 == 0 + (x: number, i, s: Uint8Array): boolean => (x + i) % 2 == 0 - | - (x: number, i: number, s: Uint8Array): boolean => i % 2 == 0 + (x: number, i, s: Uint8Array): boolean => i % 2 == 0 - | - (x: number, i: number, s: Uint8Array): boolean => (x + i) < 0 + (x: number, i, s: Uint8Array): boolean => (x + i) < 0 - | - (x: number, i: number, s: Uint8Array): boolean => (x + i) == 1 + (x: number, i, s: Uint8Array): boolean => (x + i) == 1 void_lambdas: - | (): void => {} - | (x: number): void => { x = x*2 } - | - (x: number, i: number): void => { x = x*2 } + (x: number, i): void => { x = x*2 } - | - (x: number, i: number, s: Uint8Array): void => { x = x + 1000 } + (x: number, i, s: Uint8Array): void => { x = x + 1000 } sub: - method: find params: diff --git a/static_core/plugins/ets/tests/ets_es_checked/uint8clampedarray.yaml b/static_core/plugins/ets/tests/ets_es_checked/uint8clampedarray.yaml index 31c255b54b..7aa44aa01f 100644 --- a/static_core/plugins/ets/tests/ets_es_checked/uint8clampedarray.yaml +++ b/static_core/plugins/ets/tests/ets_es_checked/uint8clampedarray.yaml @@ -25,14 +25,14 @@ sub: - "() => 1.0" - "(a: number) => a" - "(a: number, b: number) => a + b" - - "(a: number, b: number, i: number) => a + b + i" - - "(a: number, b: number, i: number, selfRef: Uint8ClampedArray) => a + b + i" + - "(a: number, b: number, i) => a + b + i" + - "(a: number, b: number, i, selfRef: Uint8ClampedArray) => a + b + i" reduce_u_lambdas: - "(): string => '*'" - "(a: string): string => '*' + a" - "(a: string, b: number): string => a + ',' + b" - - "(a: string, b: number, i: number): string => a + ',' + (b + i)" - - "(a: string, b: number, i: number, selfRef: Uint8ClampedArray): string => a + ',' + (b + i)" + - "(a: string, b: number, i): string => a + ',' + (b + i)" + - "(a: string, b: number, i, selfRef: Uint8ClampedArray): string => a + ',' + (b + i)" sub: - method: "at" params: diff --git a/static_core/plugins/ets/tests/ets_es_checked/uint8clampedarray_lambas.yaml b/static_core/plugins/ets/tests/ets_es_checked/uint8clampedarray_lambas.yaml index 2b89dd5ced..921593aed8 100644 --- a/static_core/plugins/ets/tests/ets_es_checked/uint8clampedarray_lambas.yaml +++ b/static_core/plugins/ets/tests/ets_es_checked/uint8clampedarray_lambas.yaml @@ -36,26 +36,26 @@ sub: - | (x: number): boolean => Math.abs(x) == 1 - | - (x: number, i: number): boolean => (x + i) > 0 + (x: number, i): boolean => (x + i) > 0 - | - (x: number, i: number, s: Uint8ClampedArray): boolean => (x + i) > 0 + (x: number, i, s: Uint8ClampedArray): boolean => (x + i) > 0 - | - (x: number, i: number, s: Uint8ClampedArray): boolean => (x + i) % 2 == 0 + (x: number, i, s: Uint8ClampedArray): boolean => (x + i) % 2 == 0 - | - (x: number, i: number, s: Uint8ClampedArray): boolean => i % 2 == 0 + (x: number, i, s: Uint8ClampedArray): boolean => i % 2 == 0 - | - (x: number, i: number, s: Uint8ClampedArray): boolean => (x + i) < 0 + (x: number, i, s: Uint8ClampedArray): boolean => (x + i) < 0 - | - (x: number, i: number, s: Uint8ClampedArray): boolean => (x + i) == 1 + (x: number, i, s: Uint8ClampedArray): boolean => (x + i) == 1 void_lambdas: - | (): void => {} - | (x: number): void => { x = x*2 } - | - (x: number, i: number): void => { x = x*2 } + (x: number, i): void => { x = x*2 } - | - (x: number, i: number, s: Uint8ClampedArray): void => { x = x + 1000 } + (x: number, i, s: Uint8ClampedArray): void => { x = x + 1000 } sub: - method: find params: diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray.j2 index 0bc66c2ff5..1081cce0f8 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray.j2 @@ -236,7 +236,7 @@ function createFilteredArrayFromGiven(): int { let target: {{.item.objectType}}; try { - target = origin.filter((val: {{.item.type}}, index: number): boolean => { return (val{{.item.cast2primitive}}) > 0}); + target = origin.filter((val: {{.item.type}}, index: int): boolean => { return (val{{.item.cast2primitive}}) > 0}); } catch(e) { return fail; } @@ -344,7 +344,7 @@ function testMap(): int { let target: {{.item.objectType}}; try { - target = origin.map((val: {{.item.type}}, index: number): {{.item.type}} => { return {{.item.create}}(-val{{.item.cast2primitive}}) }); + target = origin.map((val: {{.item.type}}, index: int): {{.item.type}} => { return {{.item.create}}(-val{{.item.cast2primitive}}) }); } catch(e) { console.println(e); return fail; diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_methods.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_methods.j2 index 143bf29584..d67ce39881 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_methods.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_methods.j2 @@ -224,14 +224,14 @@ function testNonEmptyTypedArrayAt(): number { atResult = typedArray.at(index); console.log("testNonEmptyTypedArrayAt [2/3] result: " + atResult); // Assertion - if (atResult == {{.item.create}}(source[index + length.toInt()])) { + if (atResult == {{.item.create}}(source[index + length])) { console.log("testNonEmptyTypedArrayAt [2/3] test passed."); } else { console.log("testNonEmptyTypedArrayAt [2/3] test failed."); return fail; } - index = typedArray.length.toInt(); + index = typedArray.length; atResult = typedArray.at(index); console.log("testNonEmptyTypedArrayAt result [3/3]: " + atResult); // Assertion @@ -478,7 +478,7 @@ const testTypedArrayEvery = parametrize>( failures += check(boolToResult(isNegative == expected[3]), `[${array}].every(x < 0)`) const isValueEqualToIndexPlus1 = array.every( - (x: {{.item.type}}, index: number) => x == {{.item.create}}(index + 1) + (x: {{.item.type}}, index: int) => x == {{.item.create}}(index + 1) ) failures += check( boolToResult(isValueEqualToIndexPlus1 == expected[4]), @@ -486,7 +486,7 @@ const testTypedArrayEvery = parametrize>( ) const isValueEqualToIndex = array.every( - (x: {{.item.type}}, index: number) => x == {{.item.create}}(index) + (x: {{.item.type}}, index: int) => x == {{.item.create}}(index) ) failures += check( boolToResult(isValueEqualToIndex == expected[5]), @@ -495,7 +495,7 @@ const testTypedArrayEvery = parametrize>( const rhs = array.reduce((acc: {{.item.type}}, x: {{.item.type}}) => acc + x) const isArraySumEqualToIndexPlusValue = array.every( - (x: {{.item.type}}, index: number, array: {{.item.objectType}}) => { + (x: {{.item.type}}, index: int, array: {{.item.objectType}}) => { return x + {{.item.create}}(index) == rhs } ) @@ -504,17 +504,17 @@ const testTypedArrayEvery = parametrize>( `[${array}].every((x, index, arr) => x + index == sum(arr))` ) - const eqByInd = (x: {{.item.type}}, index: number, arr: {{.item.objectType}}) => x == arr[index.toInt()] + const eqByInd = (x: {{.item.type}}, index: int, arr: {{.item.objectType}}) => x == arr[index] const isValueEqualToArrayByIndex = array.every(eqByInd) failures += check( boolToResult(isValueEqualToArrayByIndex == expected[7]), - `[${array}].every((x, index, arr) => x == arr[index.toInt()])` + `[${array}].every((x, index, arr) => x == arr[index])` ) const isNoEvenNumbers = array.every( - (x: {{.item.type}}, index: number, arr: {{.item.objectType}}) => { + (x: {{.item.type}}, index: int, arr: {{.item.objectType}}) => { if (x{{.item.cast2primitive}} % 2 == 0) { - arr[index.toInt()] = {{.item.create}}(0) + arr[index] = {{.item.create}}(0) return false } return true @@ -556,9 +556,9 @@ const testTypedArraySome = parametrize>( const constTrue = array.some(() => true) const hasPositivesSome = array.some((x: {{.item.type}}) => x > {{.item.create}}(0)) - const hasElementsWithValueEqIndex = array.some((x: {{.item.type}}, index: number) => x == {{.item.create}}(index)) + const hasElementsWithValueEqIndex = array.some((x: {{.item.type}}, index: int) => x == {{.item.create}}(index)) - const neByInd = (x: {{.item.type}}, index: number, arr: {{.item.objectType}}) => x != arr[index.toInt()] + const neByInd = (x: {{.item.type}}, index: int, arr: {{.item.objectType}}) => x != arr[index] const isValueNotEqualToArrayByIndex = array.some(neByInd) let failures = 0 @@ -603,7 +603,7 @@ const testTypedArraySort = parametrize>( array.sort() const isEqualToGold = - array.every((x: {{.item.type}}, index: number) => x == expected[index.toInt()]) + array.every((x: {{.item.type}}, index: int) => x == expected[index]) // descending array.sort( @@ -613,7 +613,7 @@ const testTypedArraySort = parametrize>( ) const isEqualToGoldReversed = - array.every((x: {{.item.type}}, index: number) => x == expected[expected.length - index.toInt() - 1]) + array.every((x: {{.item.type}}, index: int) => x == expected[expected.length - index - 1]) let failures = 0 @@ -663,7 +663,7 @@ const testTypedArraySortWithNaN = parametrize isEqualOrNaN(x, expected[index])) + array.every((x: {{.item.type}}, index: int) => isEqualOrNaN(x, expected[index])) // asc array.sort((x: {{.item.type}}, y: {{.item.type}}) => { @@ -671,7 +671,7 @@ const testTypedArraySortWithNaN = parametrize isEqualOrNaN(x, expected[index.toInt()])) + array.every((x: {{.item.type}}, index: int) => isEqualOrNaN(x, expected[index])) let failures = 0 @@ -717,7 +717,7 @@ const testTypedArraySortWithNaNReversed = parametrize isEqualOrNaN(x, expected[index.toInt()])) + array.every((x: {{.item.type}}, index: int) => isEqualOrNaN(x, expected[index])) let failures = 0 failures += check(boolToResult(isEqualToGold), "is equal to gold result") @@ -791,17 +791,17 @@ function testTypedArrayMap(): number { let squared = ta.map((num: {{.item.type}}) => num * num) const isSquared = squared.every( - (num: {{.item.type}}, index: number) => num == ta[index.toInt()] * ta[index.toInt()] + (num: {{.item.type}}, index: int) => num == ta[index] * ta[index] ) - let mapWithIndex = ta.map((num: {{.item.type}}, index: number) => num + {{.item.create}}(index)) + let mapWithIndex = ta.map((num: {{.item.type}}, index: int) => num + {{.item.create}}(index)) const isMappedWithIndex = mapWithIndex.every( - (num: {{.item.type}}, index: number) => num == ta[index.toInt()] + {{.item.create}}(index) + (num: {{.item.type}}, index: int) => num == ta[index] + {{.item.create}}(index) ) - let mapWithIndexAndThis = ta.map((num: {{.item.type}}, index: number, array: {{.item.objectType}}) => num) + let mapWithIndexAndThis = ta.map((num: {{.item.type}}, index: int, array: {{.item.objectType}}) => num) const isMappedWithIndexAndThis = mapWithIndexAndThis.every( - (num: {{.item.type}}, index: number, array: {{.item.objectType}}) => num == array[index.toInt()] + (num: {{.item.type}}, index: int, array: {{.item.objectType}}) => num == array[index] ) let failures = 0 @@ -829,7 +829,7 @@ const testTypedArrayOf = parametrize>( const viaCtor = new {{.item.objectType}}(args) const viaOf = {{.item.objectType}}.of(...args) - const isEqual = viaCtor.every((x: {{.item.type}}, index: number) => x == viaOf[index.toInt()]) + const isEqual = viaCtor.every((x: {{.item.type}}, index: int) => x == viaOf[index]) let failures = 0 failures += check(boolToResult(isEqual), "result of .of method call is equal to ctor invoke") @@ -942,14 +942,14 @@ const testTypedArrayReduce = parametrize prev + cur, initialValue) const isCorrectPrevCur = testPrevCur == expectedResult - // (prev: {{.item.type}}, cur: {{.item.type}}, curIndex: number) => {{.item.type}} (Using prev, current element, and index) - const testPrevCurIndex = array.reduce((prev: {{.item.type}}, cur: {{.item.type}}, curIndex: number): {{.item.type}} => prev + cur + {{.item.create}}(curIndex), initialValue) - const expectedWithIndices = array.reduce((sum: {{.item.type}}, val: {{.item.type}}, idx: number) => sum + val + {{.item.create}}(idx), initialValue) + // (prev: {{.item.type}}, cur: {{.item.type}}, curIndex: int) => {{.item.type}} (Using prev, current element, and index) + const testPrevCurIndex = array.reduce((prev: {{.item.type}}, cur: {{.item.type}}, curIndex: int): {{.item.type}} => prev + cur + {{.item.create}}(curIndex), initialValue) + const expectedWithIndices = array.reduce((sum: {{.item.type}}, val: {{.item.type}}, idx: int) => sum + val + {{.item.create}}(idx), initialValue) const isCorrectPrevCurIndex = testPrevCurIndex == {{.item.create}}(expectedWithIndices) - // (prev: {{.item.type}}, cur: {{.item.type}}, curIndex: number, array: {{.item.objectType}}) => {{.item.type}} (Using prev, current element, index, and array) - const testPrevCurIndexArray = array.reduce((prev: {{.item.type}}, cur: {{.item.type}}, curIndex: number, arr: {{.item.objectType}}): {{.item.type}} => prev + cur + arr[curIndex.toInt()], initialValue) - const expectedResultFull = array.reduce((sum: {{.item.type}}, val: {{.item.type}}, idx: number, arr: {{.item.objectType}}) => sum + val + arr[idx.toInt()], initialValue) + // (prev: {{.item.type}}, cur: {{.item.type}}, curIndex: int, array: {{.item.objectType}}) => {{.item.type}} (Using prev, current element, index, and array) + const testPrevCurIndexArray = array.reduce((prev: {{.item.type}}, cur: {{.item.type}}, curIndex: int, arr: {{.item.objectType}}): {{.item.type}} => prev + cur + arr[curIndex], initialValue) + const expectedResultFull = array.reduce((sum: {{.item.type}}, val: {{.item.type}}, idx: int, arr: {{.item.objectType}}) => sum + val + arr[idx], initialValue) const isCorrectPrevCurIndexArray = testPrevCurIndexArray == {{.item.create}}(expectedResultFull) // Validating all results @@ -1013,14 +1013,14 @@ const testTypedArrayReduceRight = parametrize prev + cur, initialValue) const isCorrectPrevCur = testPrevCur == expectedResult - // (prev: {{.item.type}}, cur: {{.item.type}}, curIndex: number) => {{.item.type}} (Using prev, current element, and index) - const testPrevCurIndex = array.reduceRight((prev: {{.item.type}}, cur: {{.item.type}}, curIndex: number): {{.item.type}} => prev + cur + {{.item.create}}(curIndex), initialValue) - const expectedWithIndices = array.reduceRight((sum: {{.item.type}}, val: {{.item.type}}, idx: number) => sum + val + {{.item.create}}(idx), initialValue) + // (prev: {{.item.type}}, cur: {{.item.type}}, curIndex: int) => {{.item.type}} (Using prev, current element, and index) + const testPrevCurIndex = array.reduceRight((prev: {{.item.type}}, cur: {{.item.type}}, curIndex: int): {{.item.type}} => prev + cur + {{.item.create}}(curIndex), initialValue) + const expectedWithIndices = array.reduceRight((sum: {{.item.type}}, val: {{.item.type}}, idx: int) => sum + val + {{.item.create}}(idx), initialValue) const isCorrectPrevCurIndex = testPrevCurIndex == {{.item.create}}(expectedWithIndices) - // (prev: {{.item.type}}, cur: {{.item.type}}, curIndex: number, array: {{.item.objectType}}) => {{.item.type}} (Using prev, current element, index, and array) - const testPrevCurIndexArray = array.reduceRight((prev: {{.item.type}}, cur: {{.item.type}}, curIndex: number, arr: {{.item.objectType}}): {{.item.type}} => prev + cur + arr[curIndex.toInt()], initialValue) - const expectedResultFull = array.reduceRight((sum: {{.item.type}}, val: {{.item.type}}, idx: number, arr: {{.item.objectType}}) => sum + val + arr[idx.toInt()], initialValue) + // (prev: {{.item.type}}, cur: {{.item.type}}, curIndex: int, array: {{.item.objectType}}) => {{.item.type}} (Using prev, current element, index, and array) + const testPrevCurIndexArray = array.reduceRight((prev: {{.item.type}}, cur: {{.item.type}}, curIndex: int, arr: {{.item.objectType}}): {{.item.type}} => prev + cur + arr[curIndex], initialValue) + const expectedResultFull = array.reduceRight((sum: {{.item.type}}, val: {{.item.type}}, idx: int, arr: {{.item.objectType}}) => sum + val + arr[idx], initialValue) const isCorrectPrevCurIndexArray = testPrevCurIndexArray == {{.item.create}}(expectedResultFull) // Validating all results @@ -1119,11 +1119,11 @@ const testTypedArrayFill2Args = parametrize failures += check(boolToResult(isAllChangedExceptFirst == expected[1]), `.fill(value, 1) = ${fill1}`) const fillLen = copy().fill(value, array.length) - const isNothingChanged = fillLen.every((x, i) => x == array[i.toInt()]) + const isNothingChanged = fillLen.every((x, i) => x == array[i]) failures += check(boolToResult(isNothingChanged == expected[2]), `.fill(value, array.length) = ${fillLen}`) const fillM1 = copy().fill(value, -1) - const isOnlyLastChanged = fillM1[last] == value && fillM1.slice(0, last - 1).every((x, i) => x == array[i.toInt()]) + const isOnlyLastChanged = fillM1[last] == value && fillM1.slice(0, last - 1).every((x, i) => x == array[i]) failures += check(boolToResult(isOnlyLastChanged == expected[3]), `.fill(value, -1) = ${fillM1}`) const fillMLen = copy().fill(value, -array.length); @@ -1163,11 +1163,11 @@ const testTypedArrayFill3Args = parametrize const value = {{.item.create}}(val) const fill00 = copy().fill(value, 0, 0) - const isNothingChanged = fill00.every((x, i) => x == array[i.toInt()]) + const isNothingChanged = fill00.every((x, i) => x == array[i]) failures += check(boolToResult(isNothingChanged == expected[0]), `.fill(value, 0, 0) = ${fill00}`) const fill01 = copy().fill(value, 0, 1) - const isOnlyFirstChanged = fill01[0] == value && fill01.slice(1).every((x, i) => x == array[i.toInt() + 1]) + const isOnlyFirstChanged = fill01[0] == value && fill01.slice(1).every((x, i) => x == array[i + 1]) failures += check(boolToResult(isOnlyFirstChanged == expected[1]), `.fill(value, 0, 1) = ${fill01}`) const fill0Len = copy().fill(value, 0, array.length) @@ -1179,7 +1179,7 @@ const testTypedArrayFill3Args = parametrize failures += check(boolToResult(isAllChangedExceptLast == expected[3]), `.fill(value, 0, -1) = ${fill0M1}`) const fill0MLen = copy().fill(value, 0, -array.length) - const isNothingChangedNeg = fill0MLen.every((x, i) => x == array[i.toInt()]) + const isNothingChangedNeg = fill0MLen.every((x, i) => x == array[i]) failures += check(boolToResult(isNothingChangedNeg == expected[4]), `.fill(value, 0, -array.length) = ${fill0MLen}`) const fill1Last = copy().fill(value, 1, last) @@ -1193,11 +1193,11 @@ const testTypedArrayFill3Args = parametrize failures += check(boolToResult(isOnlyCenterChangedNeg == expected[6]), `.fill(value, 0, -1) = ${fill1M1}`) const fillLast1 = copy().fill(value, last, 1) - const isNothingChangedReverse = fillLast1.every((x, i) => x == array[i.toInt()]) + const isNothingChangedReverse = fillLast1.every((x, i) => x == array[i]) failures += check(boolToResult(isNothingChangedReverse == expected[7]), `.fill(value, last, 1) = ${fillLast1}`) const fillM11 = copy().fill(value, -1, 1) - const isNothingChangedReverseNeg = fillM11.every((x, i) => x == array[i.toInt()]) + const isNothingChangedReverseNeg = fillM11.every((x, i) => x == array[i]) failures += check(boolToResult(isNothingChangedReverseNeg == expected[8]), `.fill(value, -1, 1) = ${fillM11}`) } } @@ -1312,7 +1312,7 @@ const testTypedArrayFind = parametrize { if (index === 1) { - obj[index.toInt()] = {{.item.create}}(10) + obj[index] = {{.item.create}}(10) } return value > {{.item.create}}(4) }) @@ -1432,7 +1432,7 @@ const testTypedArrayFindIndex = parametrize> const mutableIndexArray = new {{.item.objectType}}(array) const changesArrayIndex = mutableIndexArray.findIndex((value, index, obj) => { if (index === 1) { - obj[index.toInt()] = {{.item.create}}(10) + obj[index] = {{.item.create}}(10) } return value > {{.item.create}}(4) }) diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray.j2 index 30e2e7ca9f..604d122fa8 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray.j2 @@ -181,7 +181,7 @@ function createFilteredArrayFromGiven(): int { let target: {{.item.objectType}}; try { - target = origin.filter((val: {{.item.type}}, index: number): boolean => { return val{{.item.cast2primitive}} > 0}); + target = origin.filter((val: {{.item.type}}, index: int): boolean => { return val{{.item.cast2primitive}} > 0}); } catch(e) { return fail; } @@ -288,7 +288,7 @@ function testMap(): int { let target: {{.item.objectType}}; try { - target = origin.map((val: {{.item.type}}, index: number): {{.item.type}} => { return val + {{.item.create}}(1) }); + target = origin.map((val: {{.item.type}}, index: int): {{.item.type}} => { return val + {{.item.create}}(1) }); } catch(e) { console.println(e); return fail; diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_function2.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_function2.j2 index 0e13ef19b7..ad0a4b2cbe 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_function2.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_function2.j2 @@ -1081,7 +1081,7 @@ function testTypedUArrayForEach(): number { } let resultArray = new {{.item.objectType}}(typedUArray.length); - typedUArray.forEach((value: {{.item.type}}, index: number, array: {{.item.objectType}}) => { + typedUArray.forEach((value: {{.item.type}}, index: int, array: {{.item.objectType}}) => { resultArray[index.toInt()] = value * {{.item.create}}(2); }); @@ -1096,7 +1096,7 @@ function testTypedUArrayForEach(): number { return success; } -// Test case for forEach(callbackFn: (value: number, index: number) => void) +// Test case for forEach(callbackFn: (value: number, index: int) => void) function testTypedUArrayForEachValueIndexCallback(): number { let source: FixedArray<{{.item.type}}> = [ {{.item.create}}(1), @@ -1117,7 +1117,7 @@ function testTypedUArrayForEachValueIndexCallback(): number { } let resultArray = new {{.item.objectType}}(typedUArray.length); - typedUArray.forEach((value: {{.item.type}}, index: number) => { + typedUArray.forEach((value: {{.item.type}}, index: int) => { resultArray[index.toInt()] = value * {{.item.create}}(2); }); diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_methods.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_methods.j2 index 65d214b603..643cba91b9 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_methods.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_methods.j2 @@ -100,7 +100,7 @@ const testTypedArrayEvery = parametrize x == {{.item.create}}(index + 1) + (x: {{.item.type}}, index: int) => x == {{.item.create}}(index + 1) ) failures += check( boolToResult(isValueEqualToIndexPlus1 == expected[4]), @@ -108,7 +108,7 @@ const testTypedArrayEvery = parametrize x == {{.item.create}}(index) + (x: {{.item.type}}, index: int) => x == {{.item.create}}(index) ) failures += check( boolToResult(isValueEqualToIndex == expected[5]), @@ -117,7 +117,7 @@ const testTypedArrayEvery = parametrize acc + x) const isArraySumEqualToIndexPlusValue = array.every( - (x: {{.item.type}}, index: number, array: {{.item.objectType}}) => { + (x: {{.item.type}}, index: int, array: {{.item.objectType}}) => { return x + {{.item.create}}(index) == rhs } ) @@ -126,17 +126,17 @@ const testTypedArrayEvery = parametrize x + index == sum(arr))` ) - const eqByInd = (x: {{.item.type}}, index: number, arr: {{.item.objectType}}) => x == arr[index.toInt()] + const eqByInd = (x: {{.item.type}}, index: int, arr: {{.item.objectType}}) => x == arr[index] const isValueEqualToArrayByIndex = array.every(eqByInd) failures += check( boolToResult(isValueEqualToArrayByIndex == expected[7]), - `[${array}].every((x, index, arr) => x == arr[index.toInt()])` + `[${array}].every((x, index, arr) => x == arr[index])` ) const isNoEvenNumbers = array.every( - (x: {{.item.type}}, index: number, arr: {{.item.objectType}}) => { + (x: {{.item.type}}, index: int, arr: {{.item.objectType}}) => { if (x{{.item.cast2primitive}} % 2 == 0) { - arr[index.toInt()] = {{.item.create}}(0) + arr[index] = {{.item.create}}(0) return false } return true @@ -178,9 +178,9 @@ const testTypedArraySome = parametrize>( const constTrue = array.some(() => true) const hasPositivesSome = array.some((x: {{.item.type}}) => x > {{.item.create}}(0)) - const hasElementsWithValueEqIndex = array.some((x: {{.item.type}}, index: number) => x == {{.item.create}}(index)) + const hasElementsWithValueEqIndex = array.some((x: {{.item.type}}, index: int) => x == {{.item.create}}(index)) - const neByInd = (x: {{.item.type}}, index: number, arr: {{.item.objectType}}) => x != arr[index.toInt()] + const neByInd = (x: {{.item.type}}, index: int, arr: {{.item.objectType}}) => x != arr[index] const isValueNotEqualToArrayByIndex = array.some(neByInd) let failures = 0 @@ -225,7 +225,7 @@ const testTypedArraySort = parametrize>( array.sort() const isEqualToGold = - array.every((x: {{.item.type}}, index: number) => x == expected[index.toInt()]) + array.every((x: {{.item.type}}, index: int) => x == expected[index]) // descending array.sort( @@ -235,7 +235,7 @@ const testTypedArraySort = parametrize>( ) const isEqualToGoldReversed = - array.every((x: {{.item.type}}, index: number) => x == expected[expected.length - index - 1]) + array.every((x: {{.item.type}}, index: int) => x == expected[expected.length - index - 1]) let failures = 0 @@ -310,17 +310,17 @@ function testTypedArrayMap(): number { let squared = ta.map((num: {{.item.type}}) => (num * num) as {{.item.type}}) const isSquared = squared.every( - (num: {{.item.type}}, index: number) => num == ta[index.toInt()] * ta[index.toInt()] + (num: {{.item.type}}, index: int) => num == ta[index] * ta[index] ) - let mapWithIndex = ta.map((num: {{.item.type}}, index: number) => (num + {{.item.create}}(index)) as {{.item.type}}) + let mapWithIndex = ta.map((num: {{.item.type}}, index: int) => (num + {{.item.create}}(index)) as {{.item.type}}) const isMappedWithIndex = mapWithIndex.every( - (num: {{.item.type}}, index: number) => num == ta[index.toInt()] + {{.item.create}}(index) + (num: {{.item.type}}, index: int) => num == ta[index] + {{.item.create}}(index) ) - let mapWithIndexAndThis = ta.map((num: {{.item.type}}, index: number, array: {{.item.objectType}}) => num) + let mapWithIndexAndThis = ta.map((num: {{.item.type}}, index: int, array: {{.item.objectType}}) => num) const isMappedWithIndexAndThis = mapWithIndexAndThis.every( - (num: {{.item.type}}, index: number, array: {{.item.objectType}}) => num == array[index.toInt()] + (num: {{.item.type}}, index: int, array: {{.item.objectType}}) => num == array[index] ) let failures = 0 @@ -348,7 +348,7 @@ const testTypedArrayOf = parametrize>( const viaCtor = new {{.item.objectType}}(args) const viaOf = {{.item.objectType}}.of(...args) - const isEqual = viaCtor.every((x: {{.item.type}}, index: number) => x == viaOf[index.toInt()]) + const isEqual = viaCtor.every((x: {{.item.type}}, index: int) => x == viaOf[index]) let failures = 0 failures += check(boolToResult(isEqual), "result of .of method call is equal to ctor invoke") @@ -461,14 +461,14 @@ const testTypedArrayReduce = parametrize prev + cur, initialValue) const isCorrectPrevCur = testPrevCur == expectedResult - // (prev: {{.item.type}}, cur: {{.item.type}}, curIndex: number) => {{.item.type}} (Using prev, current element, and index) - const testPrevCurIndex = array.reduce((prev: {{.item.type}}, cur: {{.item.type}}, curIndex: number): {{.item.type}} => prev + cur + {{.item.create}}(curIndex), initialValue) - const expectedWithIndices = array.reduce((sum: {{.item.type}}, val: {{.item.type}}, idx: number) => sum + val + {{.item.create}}(idx), initialValue) + // (prev: {{.item.type}}, cur: {{.item.type}}, curIndex: int) => {{.item.type}} (Using prev, current element, and index) + const testPrevCurIndex = array.reduce((prev: {{.item.type}}, cur: {{.item.type}}, curIndex: int): {{.item.type}} => prev + cur + {{.item.create}}(curIndex), initialValue) + const expectedWithIndices = array.reduce((sum: {{.item.type}}, val: {{.item.type}}, idx: int) => sum + val + {{.item.create}}(idx), initialValue) const isCorrectPrevCurIndex = testPrevCurIndex == {{.item.create}}(expectedWithIndices) - // (prev: {{.item.type}}, cur: {{.item.type}}, curIndex: number, array: {{.item.objectType}}) => {{.item.type}} (Using prev, current element, index, and array) - const testPrevCurIndexArray = array.reduce((prev: {{.item.type}}, cur: {{.item.type}}, curIndex: number, arr: {{.item.objectType}}): {{.item.type}} => prev + cur + arr[curIndex.toInt()], initialValue) - const expectedResultFull = array.reduce((sum: {{.item.type}}, val: {{.item.type}}, idx: number, arr: {{.item.objectType}}) => sum + val + arr[idx.toInt()], initialValue) + // (prev: {{.item.type}}, cur: {{.item.type}}, curIndex: int, array: {{.item.objectType}}) => {{.item.type}} (Using prev, current element, index, and array) + const testPrevCurIndexArray = array.reduce((prev: {{.item.type}}, cur: {{.item.type}}, curIndex: int, arr: {{.item.objectType}}): {{.item.type}} => prev + cur + arr[curIndex], initialValue) + const expectedResultFull = array.reduce((sum: {{.item.type}}, val: {{.item.type}}, idx: int, arr: {{.item.objectType}}) => sum + val + arr[idx], initialValue) const isCorrectPrevCurIndexArray = testPrevCurIndexArray == {{.item.create}}(expectedResultFull) // Validating all results @@ -532,14 +532,14 @@ const testTypedArrayReduceRight = parametrize prev + cur, initialValue) const isCorrectPrevCur = testPrevCur == expectedResult - // (prev: {{.item.type}}, cur: {{.item.type}}, curIndex: number) => {{.item.type}} (Using prev, current element, and index) - const testPrevCurIndex = array.reduceRight((prev: {{.item.type}}, cur: {{.item.type}}, curIndex: number): {{.item.type}} => prev + cur + {{.item.create}}(curIndex), initialValue) - const expectedWithIndices = array.reduceRight((sum: {{.item.type}}, val: {{.item.type}}, idx: number) => sum + val + {{.item.create}}(idx), initialValue) + // (prev: {{.item.type}}, cur: {{.item.type}}, curIndex: int) => {{.item.type}} (Using prev, current element, and index) + const testPrevCurIndex = array.reduceRight((prev: {{.item.type}}, cur: {{.item.type}}, curIndex: int): {{.item.type}} => prev + cur + {{.item.create}}(curIndex), initialValue) + const expectedWithIndices = array.reduceRight((sum: {{.item.type}}, val: {{.item.type}}, idx: int) => sum + val + {{.item.create}}(idx), initialValue) const isCorrectPrevCurIndex = testPrevCurIndex == {{.item.create}}(expectedWithIndices) - // (prev: {{.item.type}}, cur: {{.item.type}}, curIndex: number, array: {{.item.objectType}}) => {{.item.type}} (Using prev, current element, index, and array) - const testPrevCurIndexArray = array.reduceRight((prev: {{.item.type}}, cur: {{.item.type}}, curIndex: number, arr: {{.item.objectType}}): {{.item.type}} => prev + cur + arr[curIndex.toInt()], initialValue) - const expectedResultFull = array.reduceRight((sum: {{.item.type}}, val: {{.item.type}}, idx: number, arr: {{.item.objectType}}) => sum + val + arr[idx.toInt()], initialValue) + // (prev: {{.item.type}}, cur: {{.item.type}}, curIndex: int, array: {{.item.objectType}}) => {{.item.type}} (Using prev, current element, index, and array) + const testPrevCurIndexArray = array.reduceRight((prev: {{.item.type}}, cur: {{.item.type}}, curIndex: int, arr: {{.item.objectType}}): {{.item.type}} => prev + cur + arr[curIndex], initialValue) + const expectedResultFull = array.reduceRight((sum: {{.item.type}}, val: {{.item.type}}, idx: int, arr: {{.item.objectType}}) => sum + val + arr[idx], initialValue) const isCorrectPrevCurIndexArray = testPrevCurIndexArray == {{.item.create}}(expectedResultFull) // Validating all results @@ -639,12 +639,12 @@ const testTypedArrayFill2Args = parametrize failures += check(boolToResult(isAllChangedExceptFirst == expected[1]), `.fill(value, 1) = ${fill1}`) const fillLen = copy().fill(value, array.length) - const isNothingChanged = fillLen.every((x, i) => x == array[i.toInt()]) + const isNothingChanged = fillLen.every((x, i) => x == array[i]) failures += check(boolToResult(isNothingChanged == expected[2]), `.fill(value, array.length) = ${fillLen}`) const fillM1 = copy().fill(value, -1) const isOnlyLastChanged = fillM1[last]{{.item.cast2primitive}} == val && - fillM1.slice(0, last - 1).every((x, i) => x == array[i.toInt()]) + fillM1.slice(0, last - 1).every((x, i) => x == array[i]) failures += check(boolToResult(isOnlyLastChanged == expected[3]), `.fill(value, -1) = ${fillM1}`) const fillMLen = copy().fill(value, -array.length); @@ -684,12 +684,12 @@ const testTypedArrayFill3Args = parametrize const value = {{.item.create}}(val) const fill00 = copy().fill(value, 0, 0) - const isNothingChanged = fill00.every((x, i) => x == array[i.toInt()]) + const isNothingChanged = fill00.every((x, i) => x == array[i]) failures += check(boolToResult(isNothingChanged == expected[0]), `.fill(value, 0, 0) = ${fill00}`) const fill01 = copy().fill(value, 0, 1) const isOnlyFirstChanged = fill01[0]{{.item.cast2primitive}} == val && - fill01.slice(1).every((x, i) => x == array[i.toInt() + 1]) + fill01.slice(1).every((x, i) => x == array[i + 1]) failures += check(boolToResult(isOnlyFirstChanged == expected[1]), `.fill(value, 0, 1) = ${fill01}`) const fill0Len = copy().fill(value, 0, array.length) @@ -702,7 +702,7 @@ const testTypedArrayFill3Args = parametrize failures += check(boolToResult(isAllChangedExceptLast == expected[3]), `.fill(value, 0, -1) = ${fill0M1}`) const fill0MLen = copy().fill(value, 0, -array.length) - const isNothingChangedNeg = fill0MLen.every((x, i) => x == array[i.toInt()]) + const isNothingChangedNeg = fill0MLen.every((x, i) => x == array[i]) failures += check(boolToResult(isNothingChangedNeg == expected[4]), `.fill(value, 0, -array.length) = ${fill0MLen}`) const fill1Last = copy().fill(value, 1, last) @@ -716,11 +716,11 @@ const testTypedArrayFill3Args = parametrize failures += check(boolToResult(isOnlyCenterChangedNeg == expected[6]), `.fill(value, 0, -1) = ${fill1M1}`) const fillLast1 = copy().fill(value, last, 1) - const isNothingChangedReverse = fillLast1.every((x, i) => x == array[i.toInt()]) + const isNothingChangedReverse = fillLast1.every((x, i) => x == array[i]) failures += check(boolToResult(isNothingChangedReverse == expected[7]), `.fill(value, last, 1) = ${fillLast1}`) const fillM11 = copy().fill(value, -1, 1) - const isNothingChangedReverseNeg = fillM11.every((x, i) => x == array[i.toInt()]) + const isNothingChangedReverseNeg = fillM11.every((x, i) => x == array[i]) failures += check(boolToResult(isNothingChangedReverseNeg == expected[8]), `.fill(value, -1, 1) = ${fillM11}`) } } @@ -834,7 +834,7 @@ const testTypedArrayFind = parametrize { if (index === 1) { - obj[index.toInt()] = {{.item.create}}(10) + obj[index] = {{.item.create}}(10) } return value > {{.item.create}}(4) }) @@ -954,7 +954,7 @@ const testTypedArrayFindIndex = parametrize> const mutableIndexArray = new {{.item.objectType}}(array) const changesArrayIndex = mutableIndexArray.findIndex((value, index, obj) => { if (index === 1) { - obj[index.toInt()] = {{.item.create}}(10) + obj[index] = {{.item.create}}(10) } return value > {{.item.create}}(4) }) -- Gitee