提交 b7581100 编写于 作者: M mahaifeng

[array-buffer]添加#TEST 注释

上级 f62fd355
...@@ -63,6 +63,7 @@ export class TFloat32Array { ...@@ -63,6 +63,7 @@ export class TFloat32Array {
} }
testConstructor() { testConstructor() {
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let float32 = new Float32Array(buffer); let float32 = new Float32Array(buffer);
float32[1] = 42; float32[1] = 42;
...@@ -70,30 +71,33 @@ export class TFloat32Array { ...@@ -70,30 +71,33 @@ export class TFloat32Array {
} }
testSet() { testSet() {
// #TEST Float32Array.set
let float32 = new Float32Array(8); let float32 = new Float32Array(8);
var array = [1, 2, 3] var array = [1, 2, 3]
float32.set(array, 1); float32.set(array, 1);
expect(float32.toString()).toEqual("0,1,2,3,0,0,0,0"); expect(float32.toString()).toEqual("0,1,2,3,0,0,0,0");
// #END
} }
testCopyWith() { testCopyWith() {
console.log("testCopyWith 1") // #TEST Float32Array.copyWithin
let float32 = new Float32Array(8); let float32 = new Float32Array(8);
float32.set([1, 2, 3], 1); float32.set([1, 2, 3], 1);
console.log("testCopyWith 1")
float32.copyWithin(3, 0, 3); float32.copyWithin(3, 0, 3);
console.log("testCopyWith 1")
expect(float32.toString()).toEqual("0,1,2,0,1,2,0,0"); expect(float32.toString()).toEqual("0,1,2,0,1,2,0,0");
// #END
} }
testEvery() { testEvery() {
// const isBelowThreshold = (currentValue: number, index: number, array:Float32Array): boolean => currentValue < 40; // #TEST Float32Array.every
let result = new Float32Array([12, 5, 8, 130, 44]).every((value : number, _ : number, _a : Float32Array) : let result = new Float32Array([12, 5, 8, 130, 44]).every((value : number, _ : number, _a : Float32Array) : boolean => value < 40);
boolean => value < 40); //
expect(result).toEqual(false); expect(result).toEqual(false);
// #END
} }
testFill() { testFill() {
// #TEST Float32Array.fill
let float32 = new Float32Array([1, 2, 3]).fill(4); let float32 = new Float32Array([1, 2, 3]).fill(4);
expect(float32.toString()).toEqual("4,4,4"); expect(float32.toString()).toEqual("4,4,4");
...@@ -108,23 +112,26 @@ export class TFloat32Array { ...@@ -108,23 +112,26 @@ export class TFloat32Array {
float32 = new Float32Array([1, 2, 3]).fill(4, -3, -2); float32 = new Float32Array([1, 2, 3]).fill(4, -3, -2);
expect(float32.toString()).toEqual("4,2,3"); expect(float32.toString()).toEqual("4,2,3");
// #END
} }
testFilter() { testFilter() {
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; // #TEST Float32Array.filter
let float32 = new Float32Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Float32Array) : boolean => value >= 10);
let float32 = new Float32Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Float32Array) :
boolean => value >= 10);
expect(float32.toString()).toEqual("12,44"); expect(float32.toString()).toEqual("12,44");
// #END
} }
find() { find() {
// #TEST Float32Array.find
let float32 = new Float32Array([4, 5, 8, 12]); let float32 = new Float32Array([4, 5, 8, 12]);
let res = float32.find((value : number, _ : number, _a : Float32Array) : boolean => value > 5); let res = float32.find((value : number, _ : number, _a : Float32Array) : boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
// #END
} }
findIndex() { findIndex() {
// #TEST Float32Array.findIndex
let float32 = new Float32Array([4, 6, 8, 12]); let float32 = new Float32Array([4, 6, 8, 12]);
let res = float32.findIndex((value : number, _ : number, _a : Float32Array) : boolean => value > 100); let res = float32.findIndex((value : number, _ : number, _a : Float32Array) : boolean => value > 100);
expect(res).toEqual(-1); expect(res).toEqual(-1);
...@@ -132,22 +139,28 @@ export class TFloat32Array { ...@@ -132,22 +139,28 @@ export class TFloat32Array {
let ufloat32 = new Float32Array([4, 6, 7, 120]); let ufloat32 = new Float32Array([4, 6, 7, 120]);
res = ufloat32.findIndex((value : number, _ : number, _a : Float32Array) : boolean => value > 100); res = ufloat32.findIndex((value : number, _ : number, _a : Float32Array) : boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
// #END
} }
foreach() { foreach() {
// #TEST Float32Array.forEach
new Float32Array([0, 1, 2, 3]).forEach((value : number, index : number, _ : Float32Array) => { new Float32Array([0, 1, 2, 3]).forEach((value : number, index : number, _ : Float32Array) => {
console.log(`a[${index}] = ${value}`); console.log(`a[${index}] = ${value}`);
}); });
// #END
} }
iterator() { iterator() {
// #TEST Float32Array.entries
let arr = new Float32Array([10, 20, 30, 40, 50]); let arr = new Float32Array([10, 20, 30, 40, 50]);
let entries = arr.entries(); let entries = arr.entries();
expect(entries.next().value[1]).toEqual(10); expect(entries.next().value[1]).toEqual(10);
expect(entries.next().value[1]).toEqual(20); expect(entries.next().value[1]).toEqual(20);
// #END
} }
includes() { includes() {
// #TEST Float32Array.includes
let float32 = new Float32Array([1, 2, 3]); let float32 = new Float32Array([1, 2, 3]);
let res = float32.includes(2.0); let res = float32.includes(2.0);
expect(res).toEqual(true); expect(res).toEqual(true);
...@@ -157,9 +170,11 @@ export class TFloat32Array { ...@@ -157,9 +170,11 @@ export class TFloat32Array {
res = float32.includes(3.0, 3); res = float32.includes(3.0, 3);
expect(res).toEqual(false); expect(res).toEqual(false);
// #END
} }
indexOf() { indexOf() {
// #TEST Float32Array.indexOf
let float32 = new Float32Array([2, 5, 9]); let float32 = new Float32Array([2, 5, 9]);
let res = float32.indexOf(2); let res = float32.indexOf(2);
expect(res).toEqual(0); expect(res).toEqual(0);
...@@ -175,9 +190,11 @@ export class TFloat32Array { ...@@ -175,9 +190,11 @@ export class TFloat32Array {
res = float32.indexOf(2, -3); res = float32.indexOf(2, -3);
expect(res).toEqual(0); expect(res).toEqual(0);
// #END
} }
join() { join() {
// #TEST Float32Array.join
let float32 = new Float32Array([1, 2, 3]); let float32 = new Float32Array([1, 2, 3]);
let res = float32.join(); let res = float32.join();
expect(res).toEqual("1,2,3"); expect(res).toEqual("1,2,3");
...@@ -187,9 +204,11 @@ export class TFloat32Array { ...@@ -187,9 +204,11 @@ export class TFloat32Array {
res = float32.join(""); res = float32.join("");
expect(res).toEqual("123"); expect(res).toEqual("123");
// #END
} }
keys() { keys() {
// #TEST Float32Array.keys
let arr = new Float32Array([10, 20, 30, 40, 50]); let arr = new Float32Array([10, 20, 30, 40, 50]);
let keys = arr.keys(); let keys = arr.keys();
expect(keys.next().value).toEqual(0); expect(keys.next().value).toEqual(0);
...@@ -197,46 +216,53 @@ export class TFloat32Array { ...@@ -197,46 +216,53 @@ export class TFloat32Array {
expect(keys.next().value).toEqual(2); expect(keys.next().value).toEqual(2);
expect(keys.next().value).toEqual(3); expect(keys.next().value).toEqual(3);
expect(keys.next().value).toEqual(4); expect(keys.next().value).toEqual(4);
// #END
} }
map() { map() {
// #TEST Float32Array.map
let numbers = new Float32Array([1, 4, 9]); let numbers = new Float32Array([1, 4, 9]);
let doubles = numbers.map((value : number, _ : number, _a : Float32Array) : number => value * 2); let doubles = numbers.map((value : number, _ : number, _a : Float32Array) : number => value * 2);
expect(numbers.toString()).toEqual("1,4,9"); expect(numbers.toString()).toEqual("1,4,9");
expect(doubles.toString()).toEqual("2,8,18"); expect(doubles.toString()).toEqual("2,8,18");
// #END
} }
reduce() { reduce() {
// #TEST Float32Array.reduce
let total = new Float32Array([0, 1, 2, 3]); let total = new Float32Array([0, 1, 2, 3]);
let res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Float32Array) : let res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Float32Array) : number => accumulator + currentValue);
number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Float32Array([0, 1, 2, 3]); total = new Float32Array([0, 1, 2, 3]);
res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Float32Array) : res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Float32Array) : number => accumulator + currentValue, 8);
number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
// #END
} }
reduceRight() { reduceRight() {
// #TEST Float32Array.reduceRight
let total = new Float32Array([0, 1, 2, 3]); let total = new Float32Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : let res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Float32Array) : number => accumulator + currentValue);
Float32Array) : number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Float32Array([0, 1, 2, 3]); total = new Float32Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Float32Array) : res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Float32Array) : number => accumulator + currentValue, 8);
number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
// #END
} }
reverse() { reverse() {
// #TEST Float32Array.reverse
let float32 = new Float32Array([1, 2, 3]); let float32 = new Float32Array([1, 2, 3]);
float32.reverse(); float32.reverse();
expect(float32.toString()).toEqual("3,2,1"); expect(float32.toString()).toEqual("3,2,1");
// #END
} }
slice() { slice() {
// #TEST Float32Array.slice
let float32 = new Float32Array([1, 2, 3]); let float32 = new Float32Array([1, 2, 3]);
let res = float32.slice(1); let res = float32.slice(1);
expect(res.toString()).toEqual("2,3"); expect(res.toString()).toEqual("2,3");
...@@ -249,18 +275,22 @@ export class TFloat32Array { ...@@ -249,18 +275,22 @@ export class TFloat32Array {
res = float32.slice(0, 1); res = float32.slice(0, 1);
expect(res.toString()).toEqual("1"); expect(res.toString()).toEqual("1");
// #END
} }
sort() { sort() {
// #TEST Float32Array.sort
let numbers = new Float32Array([40, 1, 5]); let numbers = new Float32Array([40, 1, 5]);
numbers.sort(); numbers.sort();
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
numbers.sort((a, b) : number => a - b); numbers.sort((a, b) : number => a - b);
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
// #END
} }
subarray() { subarray() {
// #TEST Float32Array.subarray
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let float32 = new Float32Array(buffer); let float32 = new Float32Array(buffer);
float32.set([1, 2, 3]); float32.set([1, 2, 3]);
...@@ -268,17 +298,21 @@ export class TFloat32Array { ...@@ -268,17 +298,21 @@ export class TFloat32Array {
let sub = float32.subarray(0, 4); let sub = float32.subarray(0, 4);
expect(sub.toString()).toEqual("1,2,3,0"); expect(sub.toString()).toEqual("1,2,3,0");
// #END
} }
values() { values() {
// #TEST Float32Array.values
let arr = new Float32Array([1, 2, 3]); let arr = new Float32Array([1, 2, 3]);
let values = arr.values(); let values = arr.values();
expect(values.next().value).toEqual(1); expect(values.next().value).toEqual(1);
expect(values.next().value).toEqual(2); expect(values.next().value).toEqual(2);
expect(values.next().value).toEqual(3); expect(values.next().value).toEqual(3);
// #END
} }
arrayBufferSlice() { arrayBufferSlice() {
// #TEST ArrayBuffer.slice
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let float32 = new Float32Array(buffer); let float32 = new Float32Array(buffer);
float32[3] = 42; float32[3] = 42;
...@@ -287,6 +321,8 @@ export class TFloat32Array { ...@@ -287,6 +321,8 @@ export class TFloat32Array {
let res = buffer.slice(8); let res = buffer.slice(8);
let sliced = new Float32Array(res); let sliced = new Float32Array(res);
expect(sliced[1]).toEqual(42); expect(sliced[1]).toEqual(42);
// #END
} }
// #endif // #endif
} }
\ No newline at end of file
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
export class TFloat64Array { export class TFloat64Array {
test() { test() {
// #ifdef APP-ANDROID
this.testfloat64(); this.testfloat64();
this.testConstructor(); this.testConstructor();
this.testSet(); this.testSet();
...@@ -31,8 +32,9 @@ export class TFloat64Array { ...@@ -31,8 +32,9 @@ export class TFloat64Array {
this.subarray(); this.subarray();
this.values(); this.values();
this.arrayBufferSlice(); this.arrayBufferSlice();
// #endif
} }
// #ifdef APP-ANDROID
testfloat64() { testfloat64() {
let float64 = new Float64Array(2); let float64 = new Float64Array(2);
float64[0] = 42; float64[0] = 42;
...@@ -60,27 +62,32 @@ export class TFloat64Array { ...@@ -60,27 +62,32 @@ export class TFloat64Array {
} }
testSet() { testSet() {
// #TEST Float64Array.set
let float64 = new Float64Array(8); let float64 = new Float64Array(8);
var array = [1, 2, 3] var array = [1, 2, 3];
float64.set(array, 1); float64.set(array, 1);
expect(float64.toString()).toEqual("0,1,2,3,0,0,0,0"); expect(float64.toString()).toEqual("0,1,2,3,0,0,0,0");
// #END
} }
testCopyWith() { testCopyWith() {
// #TEST Float64Array.copyWithin
let float64 = new Float64Array(8); let float64 = new Float64Array(8);
float64.set([1, 2, 3], 1); float64.set([1, 2, 3], 1);
float64.copyWithin(3, 0, 3); float64.copyWithin(3, 0, 3);
expect(float64.toString()).toEqual("0,1,2,0,1,2,0,0"); expect(float64.toString()).toEqual("0,1,2,0,1,2,0,0");
// #END
} }
testEvery() { testEvery() {
// const isBelowThreshold = (currentValue: number, index: number, array:Float64Array): boolean => currentValue < 40; // #TEST Float64Array.every
let result = new Float64Array([-10, -20, -30, -40, -50]).every((value: number, _: number, _a: let result = new Float64Array([-10, -20, -30, -40, -50]).every((value : number, _ : number, _a : Float64Array) : boolean => value < 0);
Float64Array): boolean => value < 0); //
expect(result).toEqual(true); expect(result).toEqual(true);
// #END
} }
testFill() { testFill() {
// #TEST Float64Array.fill
let float64 = new Float64Array([1, 2, 3]).fill(4); let float64 = new Float64Array([1, 2, 3]).fill(4);
expect(float64.toString()).toEqual("4,4,4"); expect(float64.toString()).toEqual("4,4,4");
...@@ -95,46 +102,56 @@ export class TFloat64Array { ...@@ -95,46 +102,56 @@ export class TFloat64Array {
float64 = new Float64Array([1, 2, 3]).fill(4, -3, -2); float64 = new Float64Array([1, 2, 3]).fill(4, -3, -2);
expect(float64.toString()).toEqual("4,2,3"); expect(float64.toString()).toEqual("4,2,3");
// #END
} }
testFilter() { testFilter() {
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; // #TEST Float64Array.filter
let float64 = new Float64Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Float64Array) : boolean => value >= 10);
let float64 = new Float64Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Float64Array):
boolean => value >= 10);
expect(float64.toString()).toEqual("12,44"); expect(float64.toString()).toEqual("12,44");
// #END
} }
find() { find() {
// #TEST Float64Array.find
let float64 = new Float64Array([4, 5, 8, 12]); let float64 = new Float64Array([4, 5, 8, 12]);
let res = float64.find((value: number, _: number, _a: Float64Array): boolean => value > 5); let res = float64.find((value : number, _ : number, _a : Float64Array) : boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
// #END
} }
findIndex() { findIndex() {
// #TEST Float64Array.findIndex
let float64 = new Float64Array([4, 6, 8, 12]); let float64 = new Float64Array([4, 6, 8, 12]);
let res = float64.findIndex((value: number, _: number, _a: Float64Array): boolean => value > 100); let res = float64.findIndex((value : number, _ : number, _a : Float64Array) : boolean => value > 100);
expect(res).toEqual(-1); expect(res).toEqual(-1);
let ufloat64 = new Float64Array([4, 6, 7, 120]); let ufloat64 = new Float64Array([4, 6, 7, 120]);
res = ufloat64.findIndex((value: number, _: number, _a: Float64Array): boolean => value > 100); res = ufloat64.findIndex((value : number, _ : number, _a : Float64Array) : boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
// #END
} }
foreach() { foreach() {
new Float64Array([0, 1, 2, 3]).forEach((value: number, index: number, _: Float64Array) => { // #TEST Float64Array.forEach
new Float64Array([0, 1, 2, 3]).forEach((value : number, index : number, _ : Float64Array) => {
console.log(`a[${index}] = ${value}`); console.log(`a[${index}] = ${value}`);
}); });
// #END
} }
iterator() { iterator() {
// #TEST Float64Array.entries
let arr = new Float64Array([10, 20, 30, 40, 50]); let arr = new Float64Array([10, 20, 30, 40, 50]);
let entries = arr.entries(); let entries = arr.entries();
expect(entries.next().value[1]).toEqual(10); expect(entries.next().value[1]).toEqual(10);
expect(entries.next().value[1]).toEqual(20); expect(entries.next().value[1]).toEqual(20);
// #END
} }
includes() { includes() {
// #TEST Float64Array.includes
let float64 = new Float64Array([1, 2, 3]); let float64 = new Float64Array([1, 2, 3]);
let res = float64.includes(2); let res = float64.includes(2);
expect(res).toEqual(true); expect(res).toEqual(true);
...@@ -144,9 +161,11 @@ export class TFloat64Array { ...@@ -144,9 +161,11 @@ export class TFloat64Array {
res = float64.includes(3, 3); res = float64.includes(3, 3);
expect(res).toEqual(false); expect(res).toEqual(false);
// #END
} }
indexOf() { indexOf() {
// #TEST Float64Array.indexOf
let float64 = new Float64Array([2, 5, 9]); let float64 = new Float64Array([2, 5, 9]);
let res = float64.indexOf(2); let res = float64.indexOf(2);
expect(res).toEqual(0); expect(res).toEqual(0);
...@@ -162,9 +181,11 @@ export class TFloat64Array { ...@@ -162,9 +181,11 @@ export class TFloat64Array {
res = float64.indexOf(2, -3); res = float64.indexOf(2, -3);
expect(res).toEqual(0); expect(res).toEqual(0);
// #END
} }
join() { join() {
// #TEST Float64Array.join
let float64 = new Float64Array([1, 2, 3]); let float64 = new Float64Array([1, 2, 3]);
let res = float64.join(); let res = float64.join();
expect(res).toEqual("1,2,3"); expect(res).toEqual("1,2,3");
...@@ -174,10 +195,12 @@ export class TFloat64Array { ...@@ -174,10 +195,12 @@ export class TFloat64Array {
res = float64.join(""); res = float64.join("");
expect(res).toEqual("123"); expect(res).toEqual("123");
// #END
} }
keys() { keys() {
//todo 有差异 js 是keys.next().value // #TEST Float64Array.keys
let arr = new Float64Array([10, 20, 30, 40, 50]); let arr = new Float64Array([10, 20, 30, 40, 50]);
let keys = arr.keys(); let keys = arr.keys();
expect(keys.next().value).toEqual(0); expect(keys.next().value).toEqual(0);
...@@ -185,46 +208,52 @@ export class TFloat64Array { ...@@ -185,46 +208,52 @@ export class TFloat64Array {
expect(keys.next().value).toEqual(2); expect(keys.next().value).toEqual(2);
expect(keys.next().value).toEqual(3); expect(keys.next().value).toEqual(3);
expect(keys.next().value).toEqual(4); expect(keys.next().value).toEqual(4);
// #END
} }
map() { map() {
// #TEST Float64Array.map
let numbers = new Float64Array([1, 4, 9]); let numbers = new Float64Array([1, 4, 9]);
let doubles = numbers.map((value: number, _: number, _a: Float64Array): number => value * 2); let doubles = numbers.map((value : number, _ : number, _a : Float64Array) : number => value * 2);
expect(numbers.toString()).toEqual("1,4,9"); expect(numbers.toString()).toEqual("1,4,9");
expect(doubles.toString()).toEqual("2,8,18"); expect(doubles.toString()).toEqual("2,8,18");
// #END
} }
reduce() { reduce() {
// #TEST Float64Array.reduce
let total = new Float64Array([0, 1, 2, 3]); let total = new Float64Array([0, 1, 2, 3]);
let res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Float64Array): let res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Float64Array) : number => accumulator + currentValue);
number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Float64Array([0, 1, 2, 3]); total = new Float64Array([0, 1, 2, 3]);
res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Float64Array): res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Float64Array) : number => accumulator + currentValue, 8);
number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
// #END
} }
reduceRight() { reduceRight() {
// #TEST Float64Array.reduceRight
let total = new Float64Array([0, 1, 2, 3]); let total = new Float64Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: let res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Float64Array) : number => accumulator + currentValue);
Float64Array): number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Float64Array([0, 1, 2, 3]); total = new Float64Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Float64Array): res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Float64Array) : number => accumulator + currentValue, 8);
number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
// #END
} }
reverse() { reverse() {
// #TEST Float64Array.reverse
let float64 = new Float64Array([1, 2, 3]); let float64 = new Float64Array([1, 2, 3]);
float64.reverse(); float64.reverse();
expect(float64.toString()).toEqual("3,2,1"); expect(float64.toString()).toEqual("3,2,1");
// #END
} }
slice() { slice() {
// #TEST Float64Array.slice
let float64 = new Float64Array([1, 2, 3]); let float64 = new Float64Array([1, 2, 3]);
let res = float64.slice(1); let res = float64.slice(1);
expect(res.toString()).toEqual("2,3"); expect(res.toString()).toEqual("2,3");
...@@ -237,18 +266,23 @@ export class TFloat64Array { ...@@ -237,18 +266,23 @@ export class TFloat64Array {
res = float64.slice(0, 1); res = float64.slice(0, 1);
expect(res.toString()).toEqual("1"); expect(res.toString()).toEqual("1");
// #END
} }
sort() { sort() {
// #TEST Float64Array.sort
let numbers = new Float64Array([40, 1, 5]); let numbers = new Float64Array([40, 1, 5]);
numbers.sort(); numbers.sort();
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
numbers.sort((a, b): number => a - b); numbers.sort((a, b) : number => a - b);
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
// #END
} }
subarray() { subarray() {
// #TEST Float64Array.subarray
let buffer = new ArrayBuffer(32); let buffer = new ArrayBuffer(32);
let float64 = new Float64Array(buffer); let float64 = new Float64Array(buffer);
float64.set([1, 2, 3]); float64.set([1, 2, 3]);
...@@ -256,17 +290,21 @@ export class TFloat64Array { ...@@ -256,17 +290,21 @@ export class TFloat64Array {
let sub = float64.subarray(0, 4); let sub = float64.subarray(0, 4);
expect(sub.toString()).toEqual("1,2,3,0"); expect(sub.toString()).toEqual("1,2,3,0");
// #END
} }
values() { values() {
// #TEST Float64Array.values
let arr = new Float64Array([1, 2, 3]); let arr = new Float64Array([1, 2, 3]);
let values = arr.values(); let values = arr.values();
expect(values.next().value).toEqual(1); expect(values.next().value).toEqual(1);
expect(values.next().value).toEqual(2); expect(values.next().value).toEqual(2);
expect(values.next().value).toEqual(3); expect(values.next().value).toEqual(3);
// #END
} }
arrayBufferSlice() { arrayBufferSlice() {
// #TEST Float64Array with ArrayBuffer.slice
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let float64 = new Float64Array(buffer); let float64 = new Float64Array(buffer);
float64[1] = 42; float64[1] = 42;
...@@ -275,5 +313,8 @@ export class TFloat64Array { ...@@ -275,5 +313,8 @@ export class TFloat64Array {
let res = buffer.slice(8); let res = buffer.slice(8);
let sliced = new Float64Array(res); let sliced = new Float64Array(res);
expect(sliced[0]).toEqual(42); expect(sliced[0]).toEqual(42);
// #END
} }
// #endif
} }
\ No newline at end of file
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
export class TInt16Array { export class TInt16Array {
test() { test() {
// #ifdef APP-ANDROID
this.testConstructor(); this.testConstructor();
this.testSet(); this.testSet();
this.testCopyWith(); this.testCopyWith();
...@@ -30,9 +31,10 @@ export class TInt16Array { ...@@ -30,9 +31,10 @@ export class TInt16Array {
this.subarray(); this.subarray();
this.values(); this.values();
this.arrayBufferSlice(); this.arrayBufferSlice();
// #endif
} }
// #ifdef APP-ANDROID
testConstructor() { testConstructor() {
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let int16 = new Int16Array(buffer); let int16 = new Int16Array(buffer);
...@@ -41,29 +43,32 @@ export class TInt16Array { ...@@ -41,29 +43,32 @@ export class TInt16Array {
} }
testSet() { testSet() {
// #TEST Int16Array.set
let int16 = new Int16Array(8); let int16 = new Int16Array(8);
var array = [1, 2, 3] var array = [1, 2, 3];
int16.set(array, 1); int16.set(array, 1);
expect(int16.toString()).toEqual("0,1,2,3,0,0,0,0"); expect(int16.toString()).toEqual("0,1,2,3,0,0,0,0");
// #END
} }
testCopyWith() { testCopyWith() {
console.log("testCopyWith 1") // #TEST Int16Array.copyWithin
let int16 = new Int16Array(8); let int16 = new Int16Array(8);
int16.set([1, 2, 3], 1); int16.set([1, 2, 3], 1);
console.log("testCopyWith 1")
int16.copyWithin(3, 0, 3); int16.copyWithin(3, 0, 3);
console.log("testCopyWith 1")
expect(int16.toString()).toEqual("0,1,2,0,1,2,0,0"); expect(int16.toString()).toEqual("0,1,2,0,1,2,0,0");
// #END
} }
testEvery() { testEvery() {
// const isBelowThreshold = (currentValue: number, index: number, array:Int16Array): boolean => currentValue < 40; // #TEST Int16Array.every
let result = new Int16Array([12, 5, 8, 130, 44]).every((value : number, _ : number, _a : Int16Array) : boolean => value < 40); // let result = new Int16Array([12, 5, 8, 130, 44]).every((value, _, _a:Int16Array):boolean => value < 40);
expect(result).toEqual(false); expect(result).toEqual(false);
// #END
} }
testFill() { testFill() {
// #TEST Int16Array.fill
let int16 = new Int16Array([1, 2, 3]).fill(4); let int16 = new Int16Array([1, 2, 3]).fill(4);
expect(int16.toString()).toEqual("4,4,4"); expect(int16.toString()).toEqual("4,4,4");
...@@ -78,44 +83,54 @@ export class TInt16Array { ...@@ -78,44 +83,54 @@ export class TInt16Array {
int16 = new Int16Array([1, 2, 3]).fill(4, -3, -2); int16 = new Int16Array([1, 2, 3]).fill(4, -3, -2);
expect(int16.toString()).toEqual("4,2,3"); expect(int16.toString()).toEqual("4,2,3");
// #END
} }
testFilter() { testFilter() {
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; // #TEST Int16Array.filter
let int16 = new Int16Array([12, 5, 8, 44]).filter((value, _, _a:Int16Array):boolean => value >= 10);
let int16 = new Int16Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Int16Array) : boolean => value >= 10);
expect(int16.toString()).toEqual("12,44"); expect(int16.toString()).toEqual("12,44");
// #END
} }
find() { find() {
// #TEST Int16Array.find
let int16 = new Int16Array([4, 5, 8, 12]); let int16 = new Int16Array([4, 5, 8, 12]);
let res = int16.find((value : number, _ : number, _a : Int16Array) : boolean => value > 5); let res = int16.find((value, _, _a:Int16Array):boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
// #END
} }
findIndex() { findIndex() {
// #TEST Int16Array.findIndex
let int16 = new Int16Array([4, 6, 8, 12]); let int16 = new Int16Array([4, 6, 8, 12]);
let res = int16.findIndex((value : number, _ : number, _a : Int16Array) : boolean => value > 100); let res = int16.findIndex((value, _, _a:Int16Array):boolean => value > 100);
expect(res).toEqual(-1); expect(res).toEqual(-1);
int16 = new Int16Array([4, 6, 7, 120]); int16 = new Int16Array([4, 6, 7, 120]);
res = int16.findIndex((value : number, _ : number, _a : Int16Array) : boolean => value > 100); res = int16.findIndex((value, _, _a:Int16Array):boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
// #END
} }
foreach() { foreach() {
new Int16Array([0, 1, 2, 3]).forEach((value : number, index : number, _ : Int16Array) => { // #TEST Int16Array.forEach
new Int16Array([0, 1, 2, 3]).forEach((value, index, _:Int16Array) => {
console.log(`a[${index}] = ${value}`); console.log(`a[${index}] = ${value}`);
}); });
// #END
} }
iterator() { iterator() {
// #TEST Int16Array.entries
let arr = new Int16Array([10, 20, 30, 40, 50]); let arr = new Int16Array([10, 20, 30, 40, 50]);
let entries = arr.entries(); let entries = arr.entries();
expect(entries.next().value[1]).toEqual(10); expect(entries.next().value[1]).toEqual(10);
// #END
} }
includes() { includes() {
// #TEST Int16Array.includes
let int16 = new Int16Array([1, 2, 3]); let int16 = new Int16Array([1, 2, 3]);
let res = int16.includes(2); let res = int16.includes(2);
expect(res).toEqual(true); expect(res).toEqual(true);
...@@ -125,9 +140,11 @@ export class TInt16Array { ...@@ -125,9 +140,11 @@ export class TInt16Array {
res = int16.includes(3, 3); res = int16.includes(3, 3);
expect(res).toEqual(false); expect(res).toEqual(false);
// #END
} }
indexOf() { indexOf() {
// #TEST Int16Array.indexOf
let int16 = new Int16Array([2, 5, 9]); let int16 = new Int16Array([2, 5, 9]);
let res = int16.indexOf(2); let res = int16.indexOf(2);
expect(res).toEqual(0); expect(res).toEqual(0);
...@@ -143,9 +160,11 @@ export class TInt16Array { ...@@ -143,9 +160,11 @@ export class TInt16Array {
res = int16.indexOf(2, -3); res = int16.indexOf(2, -3);
expect(res).toEqual(0); expect(res).toEqual(0);
// #END
} }
join() { join() {
// #TEST Int16Array.join
let int16 = new Int16Array([1, 2, 3]); let int16 = new Int16Array([1, 2, 3]);
let res = int16.join(); let res = int16.join();
expect(res).toEqual("1,2,3"); expect(res).toEqual("1,2,3");
...@@ -155,9 +174,11 @@ export class TInt16Array { ...@@ -155,9 +174,11 @@ export class TInt16Array {
res = int16.join(""); res = int16.join("");
expect(res).toEqual("123"); expect(res).toEqual("123");
// #END
} }
keys() { keys() {
// #TEST Int16Array.keys
let arr = new Int16Array([10, 20, 30, 40, 50]); let arr = new Int16Array([10, 20, 30, 40, 50]);
let keys = arr.keys(); let keys = arr.keys();
expect(keys.next().value).toEqual(0); expect(keys.next().value).toEqual(0);
...@@ -165,42 +186,52 @@ export class TInt16Array { ...@@ -165,42 +186,52 @@ export class TInt16Array {
expect(keys.next().value).toEqual(2); expect(keys.next().value).toEqual(2);
expect(keys.next().value).toEqual(3); expect(keys.next().value).toEqual(3);
expect(keys.next().value).toEqual(4); expect(keys.next().value).toEqual(4);
// #END
} }
map() { map() {
// #TEST Int16Array.map
let numbers = new Int16Array([1, 4, 9]); let numbers = new Int16Array([1, 4, 9]);
let doubles = numbers.map((value : number, _ : number, _a : Int16Array) : number => value * 2); let doubles = numbers.map((value, _, _a:Int16Array):number => value * 2);
expect(numbers.toString()).toEqual("1,4,9"); expect(numbers.toString()).toEqual("1,4,9");
expect(doubles.toString()).toEqual("2,8,18"); expect(doubles.toString()).toEqual("2,8,18");
// #END
} }
reduce() { reduce() {
// #TEST Int16Array.reduce
let total = new Int16Array([0, 1, 2, 3]); let total = new Int16Array([0, 1, 2, 3]);
let res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Int16Array) : number => accumulator + currentValue); let res = total.reduce((accumulator, currentValue, _, _a:Int16Array):number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Int16Array([0, 1, 2, 3]); total = new Int16Array([0, 1, 2, 3]);
res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Int16Array) : number => accumulator + currentValue, 8); res = total.reduce((accumulator, currentValue, _, _a:Int16Array):number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
// #END
} }
reduceRight() { reduceRight() {
// #TEST Int16Array.reduceRight
let total = new Int16Array([0, 1, 2, 3]); let total = new Int16Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Int16Array) : number => accumulator + currentValue); let res = total.reduceRight((accumulator, currentValue, _, _a:Int16Array):number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Int16Array([0, 1, 2, 3]); total = new Int16Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Int16Array) : number => accumulator + currentValue, 8); res = total.reduceRight((accumulator, currentValue, _, _a:Int16Array):number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
// #END
} }
reverse() { reverse() {
// #TEST Int16Array.reverse
let int16 = new Int16Array([1, 2, 3]); let int16 = new Int16Array([1, 2, 3]);
int16.reverse(); int16.reverse();
expect(int16.toString()).toEqual("3,2,1"); expect(int16.toString()).toEqual("3,2,1");
// #END
} }
slice() { slice() {
// #TEST Int16Array.slice
let int16 = new Int16Array([1, 2, 3]); let int16 = new Int16Array([1, 2, 3]);
let res = int16.slice(1); let res = int16.slice(1);
expect(res.toString()).toEqual("2,3"); expect(res.toString()).toEqual("2,3");
...@@ -213,18 +244,22 @@ export class TInt16Array { ...@@ -213,18 +244,22 @@ export class TInt16Array {
res = int16.slice(0, 1); res = int16.slice(0, 1);
expect(res.toString()).toEqual("1"); expect(res.toString()).toEqual("1");
// #END
} }
sort() { sort() {
// #TEST Int16Array.sort
let numbers = new Int16Array([40, 1, 5]); let numbers = new Int16Array([40, 1, 5]);
numbers.sort(); numbers.sort();
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
numbers.sort((a, b) : number => a - b); numbers.sort((a, b):number => a - b);
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
// #END
} }
subarray() { subarray() {
// #TEST Int16Array.subarray
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let int16 = new Int16Array(buffer); let int16 = new Int16Array(buffer);
int16.set([1, 2, 3]); int16.set([1, 2, 3]);
...@@ -232,15 +267,19 @@ export class TInt16Array { ...@@ -232,15 +267,19 @@ export class TInt16Array {
let sub = int16.subarray(0, 4); let sub = int16.subarray(0, 4);
expect(sub.toString()).toEqual("1,2,3,0"); expect(sub.toString()).toEqual("1,2,3,0");
// #END
} }
values() { values() {
// #TEST Int16Array.values
let arr = new Int16Array([1, 2, 3]); let arr = new Int16Array([1, 2, 3]);
let values = arr.values(); let values = arr.values();
expect(values.next().value).toEqual(1); expect(values.next().value).toEqual(1);
// #END
} }
arrayBufferSlice() { arrayBufferSlice() {
// #TEST ArrayBuffer.slice with Int16Array
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let int16 = new Int16Array(buffer); let int16 = new Int16Array(buffer);
int16[4] = 42; int16[4] = 42;
...@@ -249,5 +288,8 @@ export class TInt16Array { ...@@ -249,5 +288,8 @@ export class TInt16Array {
let res = buffer.slice(8, 12); let res = buffer.slice(8, 12);
let sliced = new Int16Array(res); let sliced = new Int16Array(res);
expect(sliced[0]).toEqual(42); expect(sliced[0]).toEqual(42);
// #END
} }
// #endif
} }
\ No newline at end of file
...@@ -35,7 +35,7 @@ export class TInt32Array { ...@@ -35,7 +35,7 @@ export class TInt32Array {
// #endif // #endif
} }
// #ifdef APP-ANDROID // #ifdef APP-ANDROID
testInt32Array() { testInt32Array() {
let int32 = new Int32Array(2); let int32 = new Int32Array(2);
int32[0] = 42; int32[0] = 42;
...@@ -63,29 +63,35 @@ export class TInt32Array { ...@@ -63,29 +63,35 @@ export class TInt32Array {
} }
testSet() { testSet() {
// #TEST Int32Array.set
let int32 = new Int32Array(8); let int32 = new Int32Array(8);
var array =[1, 2, 3] var array = [1, 2, 3]
int32.set(array, 1); int32.set(array, 1);
expect(int32.toString()).toEqual("0,1,2,3,0,0,0,0"); expect(int32.toString()).toEqual("0,1,2,3,0,0,0,0");
// #END
} }
testCopyWith() { testCopyWith() {
// #TEST Int32Array.copyWithin
console.log("testCopyWith 1") console.log("testCopyWith 1")
let int32 = new Int32Array(8); let int32 = new Int32Array(8);
int32.set([1, 2, 3], 1); int32.set([1, 2, 3], 1);
console.log("testCopyWith 1") console.log("testCopyWith 1")
int32.copyWithin(3, 0, 3); int32.copyWithin(3, 0, 3);
console.log("testCopyWith 1") console.log("testCopyWith 1")
expect(int32.toString()).toEqual("0,1,2,0,1,2,0,0"); expect(int32.toString()).toEqual("0,1,2,0,1,2,0,0");
// #END
} }
testEvery() { testEvery() {
// const isBelowThreshold = (currentValue: number, index: number, array:Int32Array): boolean => currentValue < 40; // #TEST Int32Array.every
let result = new Int32Array([12, 5, 8, 130, 44]).every((value:number,_ : number, _a : Int32Array): boolean => value< 40); // let result = new Int32Array([12, 5, 8, 130, 44]).every((value : number, _ : number, _a : Int32Array) : boolean => value < 40);
expect(result).toEqual(false); expect(result).toEqual(false);
// #END
} }
testFill() { testFill() {
// #TEST Int32Array.fill
let int32 = new Int32Array([1, 2, 3]).fill(4); let int32 = new Int32Array([1, 2, 3]).fill(4);
expect(int32.toString()).toEqual("4,4,4"); expect(int32.toString()).toEqual("4,4,4");
...@@ -100,45 +106,54 @@ export class TInt32Array { ...@@ -100,45 +106,54 @@ export class TInt32Array {
int32 = new Int32Array([1, 2, 3]).fill(4, -3, -2); int32 = new Int32Array([1, 2, 3]).fill(4, -3, -2);
expect(int32.toString()).toEqual("4,2,3"); expect(int32.toString()).toEqual("4,2,3");
// #END
} }
testFilter() { testFilter() {
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; // #TEST Int32Array.filter
let int32 = new Int32Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Int32Array) : boolean => value >= 10);
let int32 = new Int32Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Int32Array): boolean => value>= 10);
expect(int32.toString()).toEqual("12,44"); expect(int32.toString()).toEqual("12,44");
// #END
} }
find() { find() {
// #TEST Int32Array.find
let int32 = new Int32Array([4, 5, 8, 12]); let int32 = new Int32Array([4, 5, 8, 12]);
let res = int32.find((value : number, _ : number, _a : Int32Array): boolean => value > 5); let res = int32.find((value : number, _ : number, _a : Int32Array) : boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
// #END
} }
findIndex() { findIndex() {
// #TEST Int32Array.findIndex
let int32 = new Int32Array([4, 6, 8, 12]); let int32 = new Int32Array([4, 6, 8, 12]);
let res = int32.findIndex((value : number, _ : number, _a : Int32Array): boolean => value > 100); let res = int32.findIndex((value : number, _ : number, _a : Int32Array) : boolean => value > 100);
expect(res).toEqual(-1); expect(res).toEqual(-1);
int32 = new Int32Array([4, 6, 7, 120]); int32 = new Int32Array([4, 6, 7, 120]);
res = int32.findIndex((value : number, _ : number, _a : Int32Array): boolean => value > 100); res = int32.findIndex((value : number, _ : number, _a : Int32Array) : boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
// #END
} }
foreach() { foreach() {
// #TEST Int32Array.forEach
new Int32Array([0, 1, 2, 3]).forEach((value : number, index : number, _ : Int32Array) => { new Int32Array([0, 1, 2, 3]).forEach((value : number, index : number, _ : Int32Array) => {
console.log(`a[${index}] = ${value}`); console.log(`a[${index}] = ${value}`);
}); });
// #END
} }
iterator() { iterator() {
// #TEST Int32Array.entries
let arr = new Int32Array([10, 20, 30, 40, 50]); let arr = new Int32Array([10, 20, 30, 40, 50]);
let entries = arr.entries(); let entries = arr.entries();
expect(entries.next().value[1]).toEqual(10); expect(entries.next().value[1]).toEqual(10);
// #END
} }
includes() { includes() {
// #TEST Int32Array.includes
let int32 = new Int32Array([1, 2, 3]); let int32 = new Int32Array([1, 2, 3]);
let res = int32.includes(2); let res = int32.includes(2);
expect(res).toEqual(true); expect(res).toEqual(true);
...@@ -148,9 +163,11 @@ export class TInt32Array { ...@@ -148,9 +163,11 @@ export class TInt32Array {
res = int32.includes(3, 3); res = int32.includes(3, 3);
expect(res).toEqual(false); expect(res).toEqual(false);
// #END
} }
indexOf() { indexOf() {
// #TEST Int32Array.indexOf
let int32 = new Int32Array([2, 5, 9]); let int32 = new Int32Array([2, 5, 9]);
let res = int32.indexOf(2); let res = int32.indexOf(2);
expect(res).toEqual(0); expect(res).toEqual(0);
...@@ -166,9 +183,11 @@ export class TInt32Array { ...@@ -166,9 +183,11 @@ export class TInt32Array {
res = int32.indexOf(2, -3); res = int32.indexOf(2, -3);
expect(res).toEqual(0); expect(res).toEqual(0);
// #END
} }
join() { join() {
// #TEST Int32Array.join
let int32 = new Int32Array([1, 2, 3]); let int32 = new Int32Array([1, 2, 3]);
let res = int32.join(); let res = int32.join();
expect(res).toEqual("1,2,3"); expect(res).toEqual("1,2,3");
...@@ -178,48 +197,60 @@ export class TInt32Array { ...@@ -178,48 +197,60 @@ export class TInt32Array {
res = int32.join(""); res = int32.join("");
expect(res).toEqual("123"); expect(res).toEqual("123");
// #END
} }
keys() { keys() {
// #TEST Int32Array.keys
let arr = new Int32Array([10, 20, 30, 40, 50]); let arr = new Int32Array([10, 20, 30, 40, 50]);
let keys = arr.keys(); let keys = arr.keys();
expect(keys.next().value).toEqual(0); expect(keys.next().value).toEqual(0);
// #END
} }
map() { map() {
// #TEST Int32Array.map
let numbers = new Int32Array([1, 4, 9]); let numbers = new Int32Array([1, 4, 9]);
let doubles = numbers.map((value : number, _ : number, _a : Int32Array): number => value * 2); let doubles = numbers.map((value : number, _ : number, _a : Int32Array) : number => value * 2);
expect(numbers.toString()).toEqual("1,4,9"); expect(numbers.toString()).toEqual("1,4,9");
expect(doubles.toString()).toEqual("2,8,18"); expect(doubles.toString()).toEqual("2,8,18");
// #END
} }
reduce() { reduce() {
// #TEST Int32Array.reduce
let total = new Int32Array([0, 1, 2, 3]); let total = new Int32Array([0, 1, 2, 3]);
let res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Int32Array): number => accumulator + currentValue); let res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Int32Array) : number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Int32Array([0, 1, 2, 3]); total = new Int32Array([0, 1, 2, 3]);
res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Int32Array): number => accumulator + currentValue, 8); res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Int32Array) : number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
// #END
} }
reduceRight() { reduceRight() {
// #TEST Int32Array.reduceRight
let total = new Int32Array([0, 1, 2, 3]); let total = new Int32Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue : number, _ : number, _a : Int32Array): number => accumulator + currentValue); let res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Int32Array) : number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Int32Array([0, 1, 2, 3]); total = new Int32Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue : number, _ : number, _a : Int32Array): number => accumulator + currentValue, 8); res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Int32Array) : number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
// #END
} }
reverse() { reverse() {
// #TEST Int32Array.reverse
let int32 = new Int32Array([1, 2, 3]); let int32 = new Int32Array([1, 2, 3]);
int32.reverse(); int32.reverse();
expect(int32.toString()).toEqual("3,2,1"); expect(int32.toString()).toEqual("3,2,1");
// #END
} }
slice() { slice() {
// #TEST Int32Array.slice
let int32 = new Int32Array([1, 2, 3]); let int32 = new Int32Array([1, 2, 3]);
let res = int32.slice(1); let res = int32.slice(1);
expect(res.toString()).toEqual("2,3"); expect(res.toString()).toEqual("2,3");
...@@ -232,18 +263,22 @@ export class TInt32Array { ...@@ -232,18 +263,22 @@ export class TInt32Array {
res = int32.slice(0, 1); res = int32.slice(0, 1);
expect(res.toString()).toEqual("1"); expect(res.toString()).toEqual("1");
// #END
} }
sort() { sort() {
// #TEST Int32Array.sort
let numbers = new Int32Array([40, 1, 5]); let numbers = new Int32Array([40, 1, 5]);
numbers.sort(); numbers.sort();
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
numbers.sort((a, b):number => a - b); numbers.sort((a, b) : number => a - b);
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
// #END
} }
subarray() { subarray() {
// #TEST Int32Array.subarray
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let int32 = new Int32Array(buffer); let int32 = new Int32Array(buffer);
int32.set([1, 2, 3]); int32.set([1, 2, 3]);
...@@ -251,15 +286,19 @@ export class TInt32Array { ...@@ -251,15 +286,19 @@ export class TInt32Array {
let sub = int32.subarray(0, 4); let sub = int32.subarray(0, 4);
expect(sub.toString()).toEqual("1,2,3,0"); expect(sub.toString()).toEqual("1,2,3,0");
// #END
} }
values() { values() {
// #TEST Int32Array.values
let arr = new Int32Array([1, 2, 3]); let arr = new Int32Array([1, 2, 3]);
let values = arr.values(); let values = arr.values();
expect(values.next().value).toEqual(1); expect(values.next().value).toEqual(1);
// #END
} }
arrayBufferSlice() { arrayBufferSlice() {
// #TEST ArrayBuffer.slice
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let int32 = new Int32Array(buffer); let int32 = new Int32Array(buffer);
int32[3] = 42; int32[3] = 42;
...@@ -268,6 +307,8 @@ export class TInt32Array { ...@@ -268,6 +307,8 @@ export class TInt32Array {
let res = buffer.slice(8); let res = buffer.slice(8);
let sliced = new Int32Array(res); let sliced = new Int32Array(res);
expect(sliced[1]).toEqual(42); expect(sliced[1]).toEqual(42);
// #END
} }
// #endif // #endif
} }
\ No newline at end of file
...@@ -8,6 +8,7 @@ import { ...@@ -8,6 +8,7 @@ import {
export class TInt8Array { export class TInt8Array {
test() { test() {
// #ifdef APP-ANDROID
this.testConstructor(); this.testConstructor();
this.testSet(); this.testSet();
this.testCopyWith(); this.testCopyWith();
...@@ -31,9 +32,10 @@ export class TInt8Array { ...@@ -31,9 +32,10 @@ export class TInt8Array {
this.subarray(); this.subarray();
this.values(); this.values();
this.arrayBufferSlice(); this.arrayBufferSlice();
//#endif
} }
// #ifdef APP-ANDROID
testConstructor() { testConstructor() {
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let int8View = new Int8Array(buffer); let int8View = new Int8Array(buffer);
...@@ -42,30 +44,35 @@ export class TInt8Array { ...@@ -42,30 +44,35 @@ export class TInt8Array {
} }
testSet() { testSet() {
// #TEST Int8Array.set
let int8 = new Int8Array(8); let int8 = new Int8Array(8);
var array = [1, 2, 3] var array = [1, 2, 3]
int8.set(array, 1); int8.set(array, 1);
expect(int8.toString()).toEqual("0,1,2,3,0,0,0,0"); expect(int8.toString()).toEqual("0,1,2,3,0,0,0,0");
// #END
} }
testCopyWith() { testCopyWith() {
console.log("testCopyWith 1") // #TEST Int8Array.copyWith
let int8 = new Int8Array(8); let int8 = new Int8Array(8);
int8.set([1, 2, 3], 1); int8.set([1, 2, 3], 1);
console.log("testCopyWith 1")
int8.copyWithin(3, 0, 3); int8.copyWithin(3, 0, 3);
console.log("testCopyWith 1")
expect(int8.toString()).toEqual("0,1,2,0,1,2,0,0"); expect(int8.toString()).toEqual("0,1,2,0,1,2,0,0");
// #END
} }
testEvery() { testEvery() {
// #TEST Int8Array.every
// const isBelowThreshold = (currentValue: number, index: number, array:Int8Array): boolean => currentValue < 40; // const isBelowThreshold = (currentValue: number, index: number, array:Int8Array): boolean => currentValue < 40;
let result = new Int8Array([12, 5, 8, 130, 44]).every((value: number, _: number, _a: Int8Array): boolean => let result = new Int8Array([12, 5, 8, 130, 44]).every((value : number, _ : number, _a : Int8Array) : boolean =>
value < 40); // value < 40);
expect(result).toEqual(false); expect(result).toEqual(false);
// #END
} }
testFill() { testFill() {
// #TEST Int8Array.fill
let int8 = new Int8Array([1, 2, 3]).fill(4); let int8 = new Int8Array([1, 2, 3]).fill(4);
expect(int8.toString()).toEqual("4,4,4"); expect(int8.toString()).toEqual("4,4,4");
...@@ -80,46 +87,58 @@ export class TInt8Array { ...@@ -80,46 +87,58 @@ export class TInt8Array {
int8 = new Int8Array([1, 2, 3]).fill(4, -3, -2); int8 = new Int8Array([1, 2, 3]).fill(4, -3, -2);
expect(int8.toString()).toEqual("4,2,3"); expect(int8.toString()).toEqual("4,2,3");
// #END
} }
testFilter() { testFilter() {
// #TEST Int8Array.filter
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
let int8 = new Int8Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Int8Array): boolean => let int8 = new Int8Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Int8Array) : boolean =>
value >= 10); value >= 10);
expect(int8.toString()).toEqual("12,44"); expect(int8.toString()).toEqual("12,44");
// #END
} }
find() { find() {
// #TEST Int8Array.find
let int8 = new Int8Array([4, 5, 8, 12]); let int8 = new Int8Array([4, 5, 8, 12]);
let res = int8.find((value: number, _: number, _a: Int8Array): boolean => value > 5); let res = int8.find((value : number, _ : number, _a : Int8Array) : boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
// #END
} }
findIndex() { findIndex() {
// #TEST Int8Array.findIndex
let int8 = new Int8Array([4, 6, 8, 12]); let int8 = new Int8Array([4, 6, 8, 12]);
let res = int8.findIndex((value: number, _: number, _a: Int8Array): boolean => value > 100); let res = int8.findIndex((value : number, _ : number, _a : Int8Array) : boolean => value > 100);
expect(res).toEqual(-1); expect(res).toEqual(-1);
int8 = new Int8Array([4, 6, 7, 120]); int8 = new Int8Array([4, 6, 7, 120]);
res = int8.findIndex((value: number, _: number, _a: Int8Array): boolean => value > 100); res = int8.findIndex((value : number, _ : number, _a : Int8Array) : boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
// #END
} }
foreach() { foreach() {
new Int8Array([0, 1, 2, 3]).forEach((value: number, index: number, _: Int8Array) => { // #TEST Int8Array.forEach
new Int8Array([0, 1, 2, 3]).forEach((value : number, index : number, _a : Int8Array) => {
console.log(`a[${index}] = ${value}`); console.log(`a[${index}] = ${value}`);
}); });
// #END
} }
iterator() { iterator() {
// #TEST Int8Array.entries
let arr = new Int8Array([10, 20, 30, 40, 50]); let arr = new Int8Array([10, 20, 30, 40, 50]);
let entries = arr.entries(); let entries = arr.entries();
expect(entries.next().value[1]).toEqual(10); expect(entries.next().value[1]).toEqual(10);
expect(entries.next().value[1]).toEqual(20); expect(entries.next().value[1]).toEqual(20);
// #END
} }
includes() { includes() {
// #TEST Int8Array.includes
let int8 = new Int8Array([1, 2, 3]); let int8 = new Int8Array([1, 2, 3]);
let res = int8.includes(2); let res = int8.includes(2);
expect(res).toEqual(true); expect(res).toEqual(true);
...@@ -129,9 +148,11 @@ export class TInt8Array { ...@@ -129,9 +148,11 @@ export class TInt8Array {
res = int8.includes(3, 3); res = int8.includes(3, 3);
expect(res).toEqual(false); expect(res).toEqual(false);
// #END
} }
indexOf() { indexOf() {
// #TEST Int8Array.indexOf
let int8 = new Int8Array([2, 5, 9]); let int8 = new Int8Array([2, 5, 9]);
let res = int8.indexOf(2); let res = int8.indexOf(2);
expect(res).toEqual(0); expect(res).toEqual(0);
...@@ -147,9 +168,11 @@ export class TInt8Array { ...@@ -147,9 +168,11 @@ export class TInt8Array {
res = int8.indexOf(2, -3); res = int8.indexOf(2, -3);
expect(res).toEqual(0); expect(res).toEqual(0);
// #END
} }
join() { join() {
// #TEST Int8Array.join
let int8 = new Int8Array([1, 2, 3]); let int8 = new Int8Array([1, 2, 3]);
let res = int8.join(); let res = int8.join();
expect(res).toEqual("1,2,3"); expect(res).toEqual("1,2,3");
...@@ -159,9 +182,11 @@ export class TInt8Array { ...@@ -159,9 +182,11 @@ export class TInt8Array {
res = int8.join(""); res = int8.join("");
expect(res).toEqual("123"); expect(res).toEqual("123");
// #END
} }
keys() { keys() {
// #TEST Int8Array.keys
let arr = new Int8Array([10, 20, 30, 40, 50]); let arr = new Int8Array([10, 20, 30, 40, 50]);
let keys = arr.keys(); let keys = arr.keys();
expect(keys.next().value).toEqual(0); expect(keys.next().value).toEqual(0);
...@@ -169,47 +194,57 @@ export class TInt8Array { ...@@ -169,47 +194,57 @@ export class TInt8Array {
expect(keys.next().value).toEqual(2); expect(keys.next().value).toEqual(2);
expect(keys.next().value).toEqual(3); expect(keys.next().value).toEqual(3);
expect(keys.next().value).toEqual(4); expect(keys.next().value).toEqual(4);
// #END
} }
map() { map() {
// #TEST Int8Array.map
let numbers = new Int8Array([1, 4, 9]); let numbers = new Int8Array([1, 4, 9]);
let doubles = numbers.map((value: number, _: number, _a: Int8Array): number => value * 2); let doubles = numbers.map((value : number, _ : number, _a : Int8Array) : number => value * 2);
expect(numbers.toString()).toEqual("1,4,9"); expect(numbers.toString()).toEqual("1,4,9");
expect(doubles.toString()).toEqual("2,8,18"); expect(doubles.toString()).toEqual("2,8,18");
// #END
} }
reduce() { reduce() {
// #TEST Int8Array.reduce
let total = new Int8Array([0, 1, 2, 3]); let total = new Int8Array([0, 1, 2, 3]);
let res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Int8Array): let res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Int8Array) :
number => accumulator + currentValue); number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Int8Array([0, 1, 2, 3]); total = new Int8Array([0, 1, 2, 3]);
res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Int8Array): number => res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Int8Array) : number =>
accumulator + currentValue, 8); accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
// #END
} }
reduceRight() { reduceRight() {
// #TEST Int8Array.reduceRight
let total = new Int8Array([0, 1, 2, 3]); let total = new Int8Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Int8Array): let res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Int8Array) :
number => accumulator + currentValue); number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Int8Array([0, 1, 2, 3]); total = new Int8Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Int8Array): res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Int8Array) :
number => accumulator + currentValue, 8); number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
// #END
} }
reverse() { reverse() {
// #TEST Int8Array.reverse
let int8 = new Int8Array([1, 2, 3]); let int8 = new Int8Array([1, 2, 3]);
int8.reverse(); int8.reverse();
expect(int8.toString()).toEqual("3,2,1"); expect(int8.toString()).toEqual("3,2,1");
// #END
} }
slice() { slice() {
// #TEST Int8Array.slice
let int8 = new Int8Array([1, 2, 3]); let int8 = new Int8Array([1, 2, 3]);
let res = int8.slice(1); let res = int8.slice(1);
expect(res.toString()).toEqual("2,3"); expect(res.toString()).toEqual("2,3");
...@@ -222,18 +257,22 @@ export class TInt8Array { ...@@ -222,18 +257,22 @@ export class TInt8Array {
res = int8.slice(0, 1); res = int8.slice(0, 1);
expect(res.toString()).toEqual("1"); expect(res.toString()).toEqual("1");
// #END
} }
sort() { sort() {
// #TEST Int8Array.sort
let numbers = new Int8Array([40, 1, 5]); let numbers = new Int8Array([40, 1, 5]);
numbers.sort(); numbers.sort();
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
numbers.sort((a, b): number => a - b); numbers.sort((a, b) : number => a - b);
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
// #END
} }
subarray() { subarray() {
// #TEST Int8Array.subarray
let buffer = new ArrayBuffer(8); let buffer = new ArrayBuffer(8);
let int8 = new Int8Array(buffer); let int8 = new Int8Array(buffer);
int8.set([1, 2, 3]); int8.set([1, 2, 3]);
...@@ -241,24 +280,31 @@ export class TInt8Array { ...@@ -241,24 +280,31 @@ export class TInt8Array {
let sub = int8.subarray(0, 4); let sub = int8.subarray(0, 4);
expect(sub.toString()).toEqual("1,2,3,0"); expect(sub.toString()).toEqual("1,2,3,0");
// #END
} }
values() { values() {
// #TEST Int8Array.values
let arr = new Int8Array([1, 2, 3]); let arr = new Int8Array([1, 2, 3]);
let values = arr.values(); let values = arr.values();
expect(values.next().value).toEqual(1); expect(values.next().value).toEqual(1);
expect(values.next().value).toEqual(2); expect(values.next().value).toEqual(2);
expect(values.next().value).toEqual(3); expect(values.next().value).toEqual(3);
// #END
} }
arrayBufferSlice() { arrayBufferSlice() {
// #TEST ArrayBuffer.slice with Int8Array
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let int8 = new Int8Array(buffer); let int8 = new Int8Array(buffer);
int8[4] = 42; int8[4] = 42;
expect(int8.toString()).toEqual("0,0,0,0,42,0,0,0,0,0,0,0,0,0,0,0"); expect(int8.toString()).toEqual("0,0,0,0,42,0,0,0,0,0,0,0,0,0,0,0");
let res = buffer.slice(4, 12); let res = buffer.slice(4, 5);
let sliced = new Int8Array(res); let sliced = new Int8Array(res);
expect(sliced[0]).toEqual(42); expect(sliced[0]).toEqual(42);
// #END
} }
// #endif
} }
\ No newline at end of file
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
export class TUint8Array { export class TUint8Array {
test() { test() {
// #ifdef APP-ANDROID
this.testMAX(); this.testMAX();
this.testConstructor(); this.testConstructor();
this.testSet(); this.testSet();
...@@ -31,7 +32,9 @@ export class TUint8Array { ...@@ -31,7 +32,9 @@ export class TUint8Array {
this.subarray(); this.subarray();
this.values(); this.values();
this.arrayBufferSlice(); this.arrayBufferSlice();
// #endif
} }
// #ifdef APP-ANDROID
from() { from() {
var s = new Set([1, 2, 3]); var s = new Set([1, 2, 3]);
var unit8 = Uint8Array.from(s); var unit8 = Uint8Array.from(s);
...@@ -52,29 +55,36 @@ export class TUint8Array { ...@@ -52,29 +55,36 @@ export class TUint8Array {
} }
testSet() { testSet() {
// #TEST Uint8Array.set
let uint8 = new Uint8Array(8); let uint8 = new Uint8Array(8);
var array = [1, 2, 3] var array = [1, 2, 3];
uint8.set(array, 1); uint8.set(array, 1);
expect(uint8.toString()).toEqual("0,1,2,3,0,0,0,0"); expect(uint8.toString()).toEqual("0,1,2,3,0,0,0,0");
// #END
} }
testCopyWith() { testCopyWith() {
console.log("testCopyWith 1") // #TEST Uint8Array.copyWithin
console.log("testCopyWith 1");
let uint8 = new Uint8Array(8); let uint8 = new Uint8Array(8);
uint8.set([1, 2, 3], 1); uint8.set([1, 2, 3], 1);
uint8.copyWithin(3, 0, 3); uint8.copyWithin(3, 0, 3);
expect(uint8.toString()).toEqual("0,1,2,0,1,2,0,0"); expect(uint8.toString()).toEqual("0,1,2,0,1,2,0,0");
// #END
} }
testEvery() { testEvery() {
// const isBelowThreshold = (currentValue: number, index: number, array:Uint8Array): boolean => currentValue < 40; // #TEST Uint8Array.every
let result = new Uint8Array([12, 5, 8, 130, 44]).every((value: number, _: number, _a: Uint8Array): boolean => // const isBelowThreshold = (currentValue: number, index: number, array: Uint8Array): boolean => currentValue < 40;
value < 40); // let result = new Uint8Array([12, 5, 8, 130, 44]).every((value : number, _ : number, _a : Uint8Array) : boolean =>
value < 40);
expect(result).toEqual(false); expect(result).toEqual(false);
// #END
} }
testFill() { testFill() {
// #TEST Uint8Array.fill
let uint8 = new Uint8Array([1, 2, 3]).fill(4); let uint8 = new Uint8Array([1, 2, 3]).fill(4);
expect(uint8.toString()).toEqual("4,4,4"); expect(uint8.toString()).toEqual("4,4,4");
...@@ -89,46 +99,54 @@ export class TUint8Array { ...@@ -89,46 +99,54 @@ export class TUint8Array {
uint8 = new Uint8Array([1, 2, 3]).fill(4, -3, -2); uint8 = new Uint8Array([1, 2, 3]).fill(4, -3, -2);
expect(uint8.toString()).toEqual("4,2,3"); expect(uint8.toString()).toEqual("4,2,3");
// #END
} }
testFilter() { testFilter() {
// #TEST Uint8Array.filter
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
let uint8 = new Uint8Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Uint8Array): boolean => value >= let uint8 = new Uint8Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Uint8Array) : boolean => value >= 10);
10);
expect(uint8.toString()).toEqual("12,44"); expect(uint8.toString()).toEqual("12,44");
// #END
} }
find() { find() {
// #TEST Uint8Array.find
let uint8 = new Uint8Array([4, 5, 8, 12]); let uint8 = new Uint8Array([4, 5, 8, 12]);
let res = uint8.find((value: number, _: number, _a: Uint8Array): boolean => value > 5); let res = uint8.find((value : number, _ : number, _a : Uint8Array) : boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
// #END
} }
findIndex() { findIndex() {
// #TEST Uint8Array.findIndex
let uint8 = new Uint8Array([4, 6, 8, 12]); let uint8 = new Uint8Array([4, 6, 8, 12]);
let res = uint8.findIndex((value: number, _: number, _a: Uint8Array): boolean => value > 100); let res = uint8.findIndex((value : number, _ : number, _a : Uint8Array) : boolean => value > 100);
expect(res).toEqual(-1); expect(res).toEqual(-1);
let uuint8 = new Uint8Array([4, 6, 7, 120]); let uuint8 = new Uint8Array([4, 6, 7, 120]);
res = uuint8.findIndex((value: number, _: number, _a: Uint8Array): boolean => value > 100); res = uuint8.findIndex((value : number, _ : number, _a : Uint8Array) : boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
// #END
} }
foreach() { foreach() {
new Uint8Array([0, 1, 2, 3]).forEach((value: number, index: number, _: Uint8Array) => { // #TEST Uint8Array.forEach
new Uint8Array([0, 1, 2, 3]).forEach((value : number, index : number, _ : Uint8Array) => {
console.log(`a[${index}] = ${value}`); console.log(`a[${index}] = ${value}`);
}); });
// #END
} }
iterator() { iterator() {
// #TEST Uint8Array.entries
let arr = new Uint8Array([10, 20, 30, 40, 50]); let arr = new Uint8Array([10, 20, 30, 40, 50]);
let entries = arr.entries(); let entries = arr.entries();
expect(entries.next().value[1]).toEqual(10); expect(entries.next().value[1]).toEqual(10);
// #END
} }
includes() { includes() {
// #TEST Uint8Array.includes
let uint8 = new Uint8Array([1, 2, 3]); let uint8 = new Uint8Array([1, 2, 3]);
let res = uint8.includes(2); let res = uint8.includes(2);
expect(res).toEqual(true); expect(res).toEqual(true);
...@@ -138,9 +156,11 @@ export class TUint8Array { ...@@ -138,9 +156,11 @@ export class TUint8Array {
res = uint8.includes(3, 3); res = uint8.includes(3, 3);
expect(res).toEqual(false); expect(res).toEqual(false);
// #END
} }
indexOf() { indexOf() {
// #TEST Uint8Array.indexOf
let uint8 = new Uint8Array([2, 5, 9]); let uint8 = new Uint8Array([2, 5, 9]);
let res = uint8.indexOf(2); let res = uint8.indexOf(2);
expect(res).toEqual(0); expect(res).toEqual(0);
...@@ -156,9 +176,11 @@ export class TUint8Array { ...@@ -156,9 +176,11 @@ export class TUint8Array {
res = uint8.indexOf(2, -3); res = uint8.indexOf(2, -3);
expect(res).toEqual(0); expect(res).toEqual(0);
// #END
} }
join() { join() {
// #TEST Uint8Array.join
let uint8 = new Uint8Array([1, 2, 3]); let uint8 = new Uint8Array([1, 2, 3]);
let res = uint8.join(); let res = uint8.join();
expect(res).toEqual("1,2,3"); expect(res).toEqual("1,2,3");
...@@ -168,52 +190,62 @@ export class TUint8Array { ...@@ -168,52 +190,62 @@ export class TUint8Array {
res = uint8.join(""); res = uint8.join("");
expect(res).toEqual("123"); expect(res).toEqual("123");
// #END
} }
keys() { keys() {
// #TEST Uint8Array.keys
let arr = new Uint8Array([10, 20, 30, 40, 50]); let arr = new Uint8Array([10, 20, 30, 40, 50]);
let keys = arr.keys(); let keys = arr.keys();
expect(keys.next().value).toEqual(0); expect(keys.next().value).toEqual(0);
// #END
} }
map() { map() {
// #TEST Uint8Array.map
let numbers = new Uint8Array([1, 4, 9]); let numbers = new Uint8Array([1, 4, 9]);
let doubles = numbers.map((value: number, _: number, _a: Uint8Array): number => value * 2); let doubles = numbers.map((value : number, _ : number, _a : Uint8Array) : number => value * 2);
expect(numbers.toString()).toEqual("1,4,9"); expect(numbers.toString()).toEqual("1,4,9");
expect(doubles.toString()).toEqual("2,8,18"); expect(doubles.toString()).toEqual("2,8,18");
// #END
} }
reduce() { reduce() {
// #TEST Uint8Array.reduce
let total = new Uint8Array([0, 1, 2, 3]); let total = new Uint8Array([0, 1, 2, 3]);
let res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Uint8Array): number => let res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Uint8Array) : number =>
accumulator + currentValue); accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Uint8Array([0, 1, 2, 3]); total = new Uint8Array([0, 1, 2, 3]);
res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Uint8Array): number => accumulator + res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Uint8Array) : number => accumulator +
currentValue, 8); currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
// #END
} }
reduceRight() { reduceRight() {
// #TEST Uint8Array.reduceRight
let total = new Uint8Array([0, 1, 2, 3]); let total = new Uint8Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Uint8Array): number => let res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Uint8Array) : number =>
accumulator + currentValue); accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Uint8Array([0, 1, 2, 3]); total = new Uint8Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Uint8Array): number => res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Uint8Array) : number =>
accumulator + currentValue, 8); accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
// #END
} }
reverse() { reverse() {
// #TEST Uint8Array.reverse
let uint8 = new Uint8Array([1, 2, 3]); let uint8 = new Uint8Array([1, 2, 3]);
uint8.reverse(); uint8.reverse();
expect(uint8.toString()).toEqual("3,2,1"); expect(uint8.toString()).toEqual("3,2,1");
// #END
} }
slice() { slice() {
// #TEST Uint8Array.slice
let uint8 = new Uint8Array([1, 2, 3]); let uint8 = new Uint8Array([1, 2, 3]);
let res = uint8.slice(1); let res = uint8.slice(1);
expect(res.toString()).toEqual("2,3"); expect(res.toString()).toEqual("2,3");
...@@ -226,18 +258,22 @@ export class TUint8Array { ...@@ -226,18 +258,22 @@ export class TUint8Array {
res = uint8.slice(0, 1); res = uint8.slice(0, 1);
expect(res.toString()).toEqual("1"); expect(res.toString()).toEqual("1");
// #END
} }
sort() { sort() {
// #TEST Uint8Array.sort
let numbers = new Uint8Array([40, 1, 5]); let numbers = new Uint8Array([40, 1, 5]);
numbers.sort(); numbers.sort();
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
numbers.sort((a, b): number => a - b); numbers.sort((a, b) : number => a - b);
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
// #END
} }
subarray() { subarray() {
// #TEST Uint8Array.subarray
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let uint8 = new Uint8Array(buffer); let uint8 = new Uint8Array(buffer);
uint8.set([1, 2, 3]); uint8.set([1, 2, 3]);
...@@ -245,16 +281,19 @@ export class TUint8Array { ...@@ -245,16 +281,19 @@ export class TUint8Array {
let sub = uint8.subarray(0, 4); let sub = uint8.subarray(0, 4);
expect(sub.toString()).toEqual("1,2,3,0"); expect(sub.toString()).toEqual("1,2,3,0");
// #END
} }
values() { values() {
// #TEST Uint8Array.values
let arr = new Uint8Array([1, 2, 3]); let arr = new Uint8Array([1, 2, 3]);
let values = arr.values(); let values = arr.values();
expect(values.next().value).toEqual(1); expect(values.next().value).toEqual(1);
// #END
} }
arrayBufferSlice() { arrayBufferSlice() {
// #TEST ArrayBuffer.slice with Uint8Array
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let uint8 = new Uint8Array(buffer); let uint8 = new Uint8Array(buffer);
uint8[4] = 42; uint8[4] = 42;
...@@ -263,5 +302,8 @@ export class TUint8Array { ...@@ -263,5 +302,8 @@ export class TUint8Array {
let res = buffer.slice(4, 12); let res = buffer.slice(4, 12);
let sliced = new Uint8Array(res); let sliced = new Uint8Array(res);
expect(sliced[0]).toEqual(42); expect(sliced[0]).toEqual(42);
// #END
} }
// #endif
} }
\ No newline at end of file
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
export class TUint8ClampedArray { export class TUint8ClampedArray {
test() { test() {
// #ifdef APP-ANDROID
this.testMAX(); this.testMAX();
this.testConstructor(); this.testConstructor();
this.testSet(); this.testSet();
...@@ -31,8 +32,10 @@ export class TUint8ClampedArray { ...@@ -31,8 +32,10 @@ export class TUint8ClampedArray {
this.subarray(); this.subarray();
this.values(); this.values();
this.arrayBufferSlice(); this.arrayBufferSlice();
// #endif
} }
// #ifdef APP-ANDROID
testMAX() { testMAX() {
let uint8Clamped = new Uint8ClampedArray(16); let uint8Clamped = new Uint8ClampedArray(16);
uint8Clamped[0] = 255; uint8Clamped[0] = 255;
...@@ -47,29 +50,36 @@ export class TUint8ClampedArray { ...@@ -47,29 +50,36 @@ export class TUint8ClampedArray {
} }
testSet() { testSet() {
// #TEST Uint8ClampedArray.set
let uint8Clamped = new Uint8ClampedArray(8); let uint8Clamped = new Uint8ClampedArray(8);
var array = [1, 2, 3] var array = [1, 2, 3];
uint8Clamped.set(array, 1); uint8Clamped.set(array, 1);
expect(uint8Clamped.toString()).toEqual("0,1,2,3,0,0,0,0"); expect(uint8Clamped.toString()).toEqual("0,1,2,3,0,0,0,0");
// #END
} }
testCopyWith() { testCopyWith() {
// #TEST Uint8ClampedArray.copyWithin
console.log("testCopyWith 1") console.log("testCopyWith 1")
let uint8Clamped = new Uint8ClampedArray(8); let uint8Clamped = new Uint8ClampedArray(8);
uint8Clamped.set([1, 2, 3], 1); uint8Clamped.set([1, 2, 3], 1);
uint8Clamped.copyWithin(3, 0, 3); uint8Clamped.copyWithin(3, 0, 3);
expect(uint8Clamped.toString()).toEqual("0,1,2,0,1,2,0,0"); expect(uint8Clamped.toString()).toEqual("0,1,2,0,1,2,0,0");
// #END
} }
testEvery() { testEvery() {
// #TEST Uint8ClampedArray.every
// const isBelowThreshold = (currentValue: number, index: number, array:Uint8ClampedArray): boolean => currentValue < 40; // const isBelowThreshold = (currentValue: number, index: number, array:Uint8ClampedArray): boolean => currentValue < 40;
let result = new Uint8ClampedArray([12, 5, 8, 130, 44]).every((value: number, _: number, _a: let result = new Uint8ClampedArray([12, 5, 8, 130, 44]).every((value : number, _ : number, _a :
Uint8ClampedArray): boolean => value < 40); // Uint8ClampedArray) : boolean => value < 40); //
expect(result).toEqual(false); expect(result).toEqual(false);
// #END
} }
testFill() { testFill() {
// #TEST Uint8ClampedArray.fill
let uint8Clamped = new Uint8ClampedArray([1, 2, 3]).fill(4); let uint8Clamped = new Uint8ClampedArray([1, 2, 3]).fill(4);
expect(uint8Clamped.toString()).toEqual("4,4,4"); expect(uint8Clamped.toString()).toEqual("4,4,4");
...@@ -84,46 +94,58 @@ export class TUint8ClampedArray { ...@@ -84,46 +94,58 @@ export class TUint8ClampedArray {
uint8Clamped = new Uint8ClampedArray([1, 2, 3]).fill(4, -3, -2); uint8Clamped = new Uint8ClampedArray([1, 2, 3]).fill(4, -3, -2);
expect(uint8Clamped.toString()).toEqual("4,2,3"); expect(uint8Clamped.toString()).toEqual("4,2,3");
// #END
} }
testFilter() { testFilter() {
// #TEST Uint8ClampedArray.filter
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
let uint8Clamped = new Uint8ClampedArray([12, 5, 8, 44]).filter((value: number, _: number, _a: let uint8Clamped = new Uint8ClampedArray([12, 5, 8, 44]).filter((value : number, _ : number, _a :
Uint8ClampedArray): boolean => value >= 10); Uint8ClampedArray) : boolean => value >= 10);
expect(uint8Clamped.toString()).toEqual("12,44"); expect(uint8Clamped.toString()).toEqual("12,44");
// #END
} }
find() { find() {
// #TEST Uint8ClampedArray.find
let uint8Clamped = new Uint8ClampedArray([4, 5, 8, 12]); let uint8Clamped = new Uint8ClampedArray([4, 5, 8, 12]);
let res = uint8Clamped.find((value: number, _: number, _a: Uint8ClampedArray): boolean => value > 5); let res = uint8Clamped.find((value : number, _ : number, _a : Uint8ClampedArray) : boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
// #END
} }
findIndex() { findIndex() {
// #TEST Uint8ClampedArray.findIndex
let uint8Clamped = new Uint8ClampedArray([4, 6, 8, 12]); let uint8Clamped = new Uint8ClampedArray([4, 6, 8, 12]);
let res = uint8Clamped.findIndex((value: number, _: number, _a: Uint8ClampedArray): boolean => value > 100); let res = uint8Clamped.findIndex((value : number, _ : number, _a : Uint8ClampedArray) : boolean => value > 100);
expect(res).toEqual(-1); expect(res).toEqual(-1);
let uuint8Clamped = new Uint8ClampedArray([4, 6, 7, 120]); let uuint8Clamped = new Uint8ClampedArray([4, 6, 7, 120]);
res = uuint8Clamped.findIndex((value: number, _: number, _a: Uint8ClampedArray): boolean => value > 100); res = uuint8Clamped.findIndex((value : number, _ : number, _a : Uint8ClampedArray) : boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
// #END
} }
foreach() { foreach() {
new Uint8ClampedArray([0, 1, 2, 3]).forEach((value: number, index: number, _: Uint8ClampedArray) => { // #TEST Uint8ClampedArray.forEach
new Uint8ClampedArray([0, 1, 2, 3]).forEach((value : number, index : number, _ : Uint8ClampedArray) => {
console.log(`a[${index}] = ${value}`); console.log(`a[${index}] = ${value}`);
}); });
// #END
} }
iterator() { iterator() {
// #TEST Uint8ClampedArray.entries
let arr = new Uint8ClampedArray([10, 20, 30, 40, 50]); let arr = new Uint8ClampedArray([10, 20, 30, 40, 50]);
let entries = arr.entries(); let entries = arr.entries();
expect(entries.next().value[1]).toEqual(10); expect(entries.next().value[1]).toEqual(10);
// #END
} }
includes() { includes() {
// #TEST Uint8ClampedArray.includes
let uint8Clamped = new Uint8ClampedArray([1, 2, 3]); let uint8Clamped = new Uint8ClampedArray([1, 2, 3]);
let res = uint8Clamped.includes(2); let res = uint8Clamped.includes(2);
expect(res).toEqual(true); expect(res).toEqual(true);
...@@ -133,9 +155,11 @@ export class TUint8ClampedArray { ...@@ -133,9 +155,11 @@ export class TUint8ClampedArray {
res = uint8Clamped.includes(3, 3); res = uint8Clamped.includes(3, 3);
expect(res).toEqual(false); expect(res).toEqual(false);
// #END
} }
indexOf() { indexOf() {
// #TEST Uint8ClampedArray.indexOf
let uint8Clamped = new Uint8ClampedArray([2, 5, 9]); let uint8Clamped = new Uint8ClampedArray([2, 5, 9]);
let res = uint8Clamped.indexOf(2); let res = uint8Clamped.indexOf(2);
expect(res).toEqual(0); expect(res).toEqual(0);
...@@ -151,9 +175,10 @@ export class TUint8ClampedArray { ...@@ -151,9 +175,10 @@ export class TUint8ClampedArray {
res = uint8Clamped.indexOf(2, -3); res = uint8Clamped.indexOf(2, -3);
expect(res).toEqual(0); expect(res).toEqual(0);
// #END
} }
join() { join() {
// #TEST Uint8ClampedArray.join
let uint8Clamped = new Uint8ClampedArray([1, 2, 3]); let uint8Clamped = new Uint8ClampedArray([1, 2, 3]);
let res = uint8Clamped.join(); let res = uint8Clamped.join();
expect(res).toEqual("1,2,3"); expect(res).toEqual("1,2,3");
...@@ -163,52 +188,63 @@ export class TUint8ClampedArray { ...@@ -163,52 +188,63 @@ export class TUint8ClampedArray {
res = uint8Clamped.join(""); res = uint8Clamped.join("");
expect(res).toEqual("123"); expect(res).toEqual("123");
// #END
} }
keys() { keys() {
// #TEST Uint8ClampedArray.keys
let arr = new Uint8ClampedArray([10, 20, 30, 40, 50]); let arr = new Uint8ClampedArray([10, 20, 30, 40, 50]);
let keys = arr.keys(); let keys = arr.keys();
expect(keys.next().value).toEqual(0); expect(keys.next().value).toEqual(0);
// #END
} }
map() { map() {
// #TEST Uint8ClampedArray.map
let numbers = new Uint8ClampedArray([1, 4, 9]); let numbers = new Uint8ClampedArray([1, 4, 9]);
let doubles = numbers.map((value: number, _: number, _a: Uint8ClampedArray): number => value * 2); let doubles = numbers.map((value : number, _ : number, _a : Uint8ClampedArray) : number => value * 2);
expect(numbers.toString()).toEqual("1,4,9"); expect(numbers.toString()).toEqual("1,4,9");
expect(doubles.toString()).toEqual("2,8,18"); expect(doubles.toString()).toEqual("2,8,18");
// #END
} }
reduce() { reduce() {
// #TEST Uint8ClampedArray.reduce
let total = new Uint8ClampedArray([0, 1, 2, 3]); let total = new Uint8ClampedArray([0, 1, 2, 3]);
let res = total.reduce((accumulator: number, currentValue: number, _: number, _a: let res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Uint8ClampedArray) : number =>
Uint8ClampedArray): number => accumulator + currentValue); accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Uint8ClampedArray([0, 1, 2, 3]); total = new Uint8ClampedArray([0, 1, 2, 3]);
res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Uint8ClampedArray): res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Uint8ClampedArray) : number =>
number => accumulator + currentValue, 8); accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
// #END
} }
reduceRight() { reduceRight() {
// #TEST Uint8ClampedArray.reduceRight
let total = new Uint8ClampedArray([0, 1, 2, 3]); let total = new Uint8ClampedArray([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: let res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Uint8ClampedArray) : number =>
Uint8ClampedArray): number => accumulator + currentValue); accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Uint8ClampedArray([0, 1, 2, 3]); total = new Uint8ClampedArray([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Uint8ClampedArray) : number =>
Uint8ClampedArray): number => accumulator + currentValue, 8); accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
// #END
} }
reverse() { reverse() {
// #TEST Uint8ClampedArray.reverse
let uint8Clamped = new Uint8ClampedArray([1, 2, 3]); let uint8Clamped = new Uint8ClampedArray([1, 2, 3]);
uint8Clamped.reverse(); uint8Clamped.reverse();
expect(uint8Clamped.toString()).toEqual("3,2,1"); expect(uint8Clamped.toString()).toEqual("3,2,1");
// #END
} }
slice() { slice() {
// #TEST Uint8ClampedArray.slice
let uint8Clamped = new Uint8ClampedArray([1, 2, 3]); let uint8Clamped = new Uint8ClampedArray([1, 2, 3]);
let res = uint8Clamped.slice(1); let res = uint8Clamped.slice(1);
expect(res.toString()).toEqual("2,3"); expect(res.toString()).toEqual("2,3");
...@@ -221,18 +257,21 @@ export class TUint8ClampedArray { ...@@ -221,18 +257,21 @@ export class TUint8ClampedArray {
res = uint8Clamped.slice(0, 1); res = uint8Clamped.slice(0, 1);
expect(res.toString()).toEqual("1"); expect(res.toString()).toEqual("1");
// #END
} }
sort() { sort() {
// #TEST Uint8ClampedArray.sort
let numbers = new Uint8ClampedArray([40, 1, 5]); let numbers = new Uint8ClampedArray([40, 1, 5]);
numbers.sort(); numbers.sort();
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
numbers.sort((a, b): number => a - b); numbers.sort((a, b) : number => a - b);
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
// #END
} }
subarray() { subarray() {
// #TEST Uint8ClampedArray.subarray
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let uint8Clamped = new Uint8ClampedArray(buffer); let uint8Clamped = new Uint8ClampedArray(buffer);
uint8Clamped.set([1, 2, 3]); uint8Clamped.set([1, 2, 3]);
...@@ -240,16 +279,19 @@ export class TUint8ClampedArray { ...@@ -240,16 +279,19 @@ export class TUint8ClampedArray {
let sub = uint8Clamped.subarray(0, 4); let sub = uint8Clamped.subarray(0, 4);
expect(sub.toString()).toEqual("1,2,3,0"); expect(sub.toString()).toEqual("1,2,3,0");
// #END
} }
values() { values() {
// #TEST Uint8ClampedArray.values
let arr = new Uint8ClampedArray([1, 2, 3]); let arr = new Uint8ClampedArray([1, 2, 3]);
let values = arr.values(); let values = arr.values();
expect(values.next().value).toEqual(1); expect(values.next().value).toEqual(1);
// #END
} }
arrayBufferSlice() { arrayBufferSlice() {
// #TEST ArrayBuffer.slice with Uint8ClampedArray
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let uint8Clamped = new Uint8ClampedArray(buffer); let uint8Clamped = new Uint8ClampedArray(buffer);
uint8Clamped[4] = 42; uint8Clamped[4] = 42;
...@@ -258,5 +300,8 @@ export class TUint8ClampedArray { ...@@ -258,5 +300,8 @@ export class TUint8ClampedArray {
let res = buffer.slice(4, 12); let res = buffer.slice(4, 12);
let sliced = new Uint8ClampedArray(res); let sliced = new Uint8ClampedArray(res);
expect(sliced[0]).toEqual(42); expect(sliced[0]).toEqual(42);
// #END
} }
// #endif
} }
\ No newline at end of file
...@@ -34,7 +34,7 @@ export class TUint16Array { ...@@ -34,7 +34,7 @@ export class TUint16Array {
this.arrayBufferSlice(); this.arrayBufferSlice();
// #endif // #endif
} }
// #ifdef APP-ANDROID // #ifdef APP-ANDROID
testuint16() { testuint16() {
let uint16 = new Uint16Array(2); let uint16 = new Uint16Array(2);
...@@ -63,30 +63,36 @@ export class TUint16Array { ...@@ -63,30 +63,36 @@ export class TUint16Array {
} }
testSet() { testSet() {
// #TEST Uint16Array.set
let uint16 = new Uint16Array(8); let uint16 = new Uint16Array(8);
var array = [1, 2, 3] var array = [1, 2, 3]
uint16.set(array, 1); uint16.set(array, 1);
expect(uint16.toString()).toEqual("0,1,2,3,0,0,0,0"); expect(uint16.toString()).toEqual("0,1,2,3,0,0,0,0");
// #END
} }
testCopyWith() { testCopyWith() {
// #TEST Uint16Array.copyWith
console.log("testCopyWith 1") console.log("testCopyWith 1")
let uint16 = new Uint16Array(8); let uint16 = new Uint16Array(8);
uint16.set([1, 2, 3], 1); uint16.set([1, 2, 3], 1);
console.log("testCopyWith 1") console.log("testCopyWith 2")
uint16.copyWithin(3, 0, 3); uint16.copyWithin(3, 0, 3);
console.log("testCopyWith 1") console.log("testCopyWith 3")
expect(uint16.toString()).toEqual("0,1,2,0,1,2,0,0"); expect(uint16.toString()).toEqual("0,1,2,0,1,2,0,0");
// #END
} }
testEvery() { testEvery() {
// const isBelowThreshold = (currentValue: number, index: number, array:Uint16Array): boolean => currentValue < 40; // #TEST Uint16Array.every
let result = new Uint16Array([12, 5, 8, 130, 44]).every((value: number, _: number, _a: Uint16Array): // const isBelowThreshold = (currentValue: number, index: number, array: Uint16Array): boolean => currentValue < 40;
boolean => value < 40); // let result = new Uint16Array([12, 5, 8, 130, 44]).every((value : number, _ : number, _a : Uint16Array) :
boolean => value < 40);
expect(result).toEqual(false); expect(result).toEqual(false);
// #END
} }
testFill() { testFill() {
// #TEST Uint16Array.fill
let uint16 = new Uint16Array([1, 2, 3]).fill(4); let uint16 = new Uint16Array([1, 2, 3]).fill(4);
expect(uint16.toString()).toEqual("4,4,4"); expect(uint16.toString()).toEqual("4,4,4");
...@@ -101,46 +107,57 @@ export class TUint16Array { ...@@ -101,46 +107,57 @@ export class TUint16Array {
uint16 = new Uint16Array([1, 2, 3]).fill(4, -3, -2); uint16 = new Uint16Array([1, 2, 3]).fill(4, -3, -2);
expect(uint16.toString()).toEqual("4,2,3"); expect(uint16.toString()).toEqual("4,2,3");
// #END
} }
testFilter() { testFilter() {
// #TEST Uint16Array.filter
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
let uint16 = new Uint16Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Uint16Array) :
let uint16 = new Uint16Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Uint16Array):
boolean => value >= 10); boolean => value >= 10);
expect(uint16.toString()).toEqual("12,44"); expect(uint16.toString()).toEqual("12,44");
// #END
} }
find() { find() {
// #TEST Uint16Array.find
let uint16 = new Uint16Array([4, 5, 8, 12]); let uint16 = new Uint16Array([4, 5, 8, 12]);
let res = uint16.find((value: number, _: number, _a: Uint16Array): boolean => value > 5); let res = uint16.find((value : number, _ : number, _a : Uint16Array) : boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
// #END
} }
findIndex() { findIndex() {
// #TEST Uint16Array.findIndex
let uint16 = new Uint16Array([4, 6, 8, 12]); let uint16 = new Uint16Array([4, 6, 8, 12]);
let res = uint16.findIndex((value: number, _: number, _a: Uint16Array): boolean => value > 100); let res = uint16.findIndex((value : number, _ : number, _a : Uint16Array) : boolean => value > 100);
expect(res).toEqual(-1); expect(res).toEqual(-1);
let uuint16 = new Uint16Array([4, 6, 7, 120]); let uuint16 = new Uint16Array([4, 6, 7, 120]);
res = uuint16.findIndex((value: number, _: number, _a: Uint16Array): boolean => value > 100); res = uuint16.findIndex((value : number, _ : number, _a : Uint16Array) : boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
// #END
} }
foreach() { foreach() {
new Uint16Array([0, 1, 2, 3]).forEach((value: number, index: number, _a: Uint16Array) => { // #TEST Uint16Array.forEach
new Uint16Array([0, 1, 2, 3]).forEach((value : number, index : number, _a : Uint16Array) => {
console.log(`a[${index}] = ${value}`); console.log(`a[${index}] = ${value}`);
}); });
// #END
} }
iterator() { iterator() {
// #TEST Uint16Array.entries
let arr = new Uint16Array([10, 20, 30, 40, 50]); let arr = new Uint16Array([10, 20, 30, 40, 50]);
let entries = arr.entries(); let entries = arr.entries();
expect(entries.next().value[1]).toEqual(10); expect(entries.next().value[1]).toEqual(10);
// #END
} }
includes() { includes() {
// #TEST Uint16Array.includes
let uint16 = new Uint16Array([1, 2, 3]); let uint16 = new Uint16Array([1, 2, 3]);
let res = uint16.includes(2); let res = uint16.includes(2);
expect(res).toEqual(true); expect(res).toEqual(true);
...@@ -150,9 +167,10 @@ export class TUint16Array { ...@@ -150,9 +167,10 @@ export class TUint16Array {
res = uint16.includes(3, 3); res = uint16.includes(3, 3);
expect(res).toEqual(false); expect(res).toEqual(false);
// #END
} }
indexOf() { indexOf() {
// #TEST Uint16Array.indexOf
let uint16 = new Uint16Array([2, 5, 9]); let uint16 = new Uint16Array([2, 5, 9]);
let res = uint16.indexOf(2); let res = uint16.indexOf(2);
expect(res).toEqual(0); expect(res).toEqual(0);
...@@ -168,9 +186,11 @@ export class TUint16Array { ...@@ -168,9 +186,11 @@ export class TUint16Array {
res = uint16.indexOf(2, -3); res = uint16.indexOf(2, -3);
expect(res).toEqual(0); expect(res).toEqual(0);
// #END
} }
join() { join() {
// #TEST Uint16Array.join
let uint16 = new Uint16Array([1, 2, 3]); let uint16 = new Uint16Array([1, 2, 3]);
let res = uint16.join(); let res = uint16.join();
expect(res).toEqual("1,2,3"); expect(res).toEqual("1,2,3");
...@@ -180,52 +200,65 @@ export class TUint16Array { ...@@ -180,52 +200,65 @@ export class TUint16Array {
res = uint16.join(""); res = uint16.join("");
expect(res).toEqual("123"); expect(res).toEqual("123");
// #END
} }
keys() { keys() {
// #TEST Uint16Array.keys
let arr = new Uint16Array([10, 20, 30, 40, 50]); let arr = new Uint16Array([10, 20, 30, 40, 50]);
let keys = arr.keys(); let keys = arr.keys();
expect(keys.next().value).toEqual(0); expect(keys.next().value).toEqual(0);
// #END
} }
map() { map() {
// #TEST Uint16Array.map
let numbers = new Uint16Array([1, 4, 9]); let numbers = new Uint16Array([1, 4, 9]);
let doubles = numbers.map((value: number, _: number, _a: Uint16Array): number => value * 2); let doubles = numbers.map((value : number, _ : number, _a : Uint16Array) : number => value * 2);
expect(numbers.toString()).toEqual("1,4,9"); expect(numbers.toString()).toEqual("1,4,9");
expect(doubles.toString()).toEqual("2,8,18"); expect(doubles.toString()).toEqual("2,8,18");
// #END
} }
reduce() { reduce() {
// #TEST Uint16Array.reduce
let total = new Uint16Array([0, 1, 2, 3]); let total = new Uint16Array([0, 1, 2, 3]);
let res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Uint16Array): let res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Uint16Array) : number =>
number => accumulator + currentValue); accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Uint16Array([0, 1, 2, 3]); total = new Uint16Array([0, 1, 2, 3]);
res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Uint16Array): res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Uint16Array) : number =>
number => accumulator + currentValue, 8); accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
// #END
} }
reduceRight() { reduceRight() {
// #TEST Uint16Array.reduceRight
let total = new Uint16Array([0, 1, 2, 3]); let total = new Uint16Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Uint16Array): let res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Uint16Array) : number =>
number => accumulator + currentValue); accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Uint16Array([0, 1, 2, 3]); total = new Uint16Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Uint16Array): res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Uint16Array) : number =>
number => accumulator + currentValue, 8); accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
// #END
} }
reverse() { reverse() {
// #TEST Uint16Array.reverse
let uint16 = new Uint16Array([1, 2, 3]); let uint16 = new Uint16Array([1, 2, 3]);
uint16.reverse(); uint16.reverse();
expect(uint16.toString()).toEqual("3,2,1"); expect(uint16.toString()).toEqual("3,2,1");
// #END
} }
slice() { slice() {
// #TEST Uint16Array.slice
let uint16 = new Uint16Array([1, 2, 3]); let uint16 = new Uint16Array([1, 2, 3]);
let res = uint16.slice(1); let res = uint16.slice(1);
expect(res.toString()).toEqual("2,3"); expect(res.toString()).toEqual("2,3");
...@@ -238,18 +271,21 @@ export class TUint16Array { ...@@ -238,18 +271,21 @@ export class TUint16Array {
res = uint16.slice(0, 1); res = uint16.slice(0, 1);
expect(res.toString()).toEqual("1"); expect(res.toString()).toEqual("1");
// #END
} }
sort() { sort() {
// #TEST Uint16Array.sort
let numbers = new Uint16Array([40, 1, 5]); let numbers = new Uint16Array([40, 1, 5]);
numbers.sort(); numbers.sort();
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
numbers.sort((a, b): number => a - b); numbers.sort((a, b) : number => a - b);
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
// #END
} }
subarray() { subarray() {
// #TEST Uint16Array.subarray
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let uint16 = new Uint16Array(buffer); let uint16 = new Uint16Array(buffer);
uint16.set([1, 2, 3]); uint16.set([1, 2, 3]);
...@@ -257,16 +293,19 @@ export class TUint16Array { ...@@ -257,16 +293,19 @@ export class TUint16Array {
let sub = uint16.subarray(0, 4); let sub = uint16.subarray(0, 4);
expect(sub.toString()).toEqual("1,2,3,0"); expect(sub.toString()).toEqual("1,2,3,0");
// #END
} }
values() { values() {
// #TEST Uint16Array.values
let arr = new Uint16Array([1, 2, 3]); let arr = new Uint16Array([1, 2, 3]);
let values = arr.values(); let values = arr.values();
expect(values.next().value).toEqual(1); expect(values.next().value).toEqual(1);
// #END
} }
arrayBufferSlice() { arrayBufferSlice() {
// #TEST Uint16Array.arrayBufferSlice
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let uint16 = new Uint16Array(buffer); let uint16 = new Uint16Array(buffer);
uint16[4] = 42; uint16[4] = 42;
...@@ -275,7 +314,9 @@ export class TUint16Array { ...@@ -275,7 +314,9 @@ export class TUint16Array {
let res = buffer.slice(8); let res = buffer.slice(8);
let sliced = new Uint16Array(res); let sliced = new Uint16Array(res);
expect(sliced[0]).toEqual(42); expect(sliced[0]).toEqual(42);
// #END
} }
// #endif // #endif
} }
\ No newline at end of file
...@@ -35,7 +35,7 @@ export class TUint32Array { ...@@ -35,7 +35,7 @@ export class TUint32Array {
// #endif // #endif
} }
// #ifdef APP-ANDROID // #ifdef APP-ANDROID
testuint32() { testuint32() {
let uint32 = new Uint32Array(2); let uint32 = new Uint32Array(2);
uint32[0] = 42; uint32[0] = 42;
...@@ -63,30 +63,36 @@ export class TUint32Array { ...@@ -63,30 +63,36 @@ export class TUint32Array {
} }
testSet() { testSet() {
// #TEST Uint32Array.set
let uint32 = new Uint32Array(8); let uint32 = new Uint32Array(8);
var array = [1, 2, 3] var array = [1, 2, 3];
uint32.set(array, 1); uint32.set(array, 1);
expect(uint32.toString()).toEqual("0,1,2,3,0,0,0,0"); expect(uint32.toString()).toEqual("0,1,2,3,0,0,0,0");
// #END
} }
testCopyWith() { testCopyWith() {
console.log("testCopyWith 1") // #TEST Uint32Array.copyWithin
console.log("testCopyWith 1");
let uint32 = new Uint32Array(8); let uint32 = new Uint32Array(8);
uint32.set([1, 2, 3], 1); uint32.set([1, 2, 3], 1);
console.log("testCopyWith 1") console.log("testCopyWith 1");
uint32.copyWithin(3, 0, 3); uint32.copyWithin(3, 0, 3);
console.log("testCopyWith 1") console.log("testCopyWith 1");
expect(uint32.toString()).toEqual("0,1,2,0,1,2,0,0"); expect(uint32.toString()).toEqual("0,1,2,0,1,2,0,0");
// #END
} }
testEvery() { testEvery() {
// const isBelowThreshold = (currentValue: number, index: number, array:Uint32Array): boolean => currentValue < 40; // #TEST Uint32Array.every
let result = new Uint32Array([12, 5, 8, 130, 44]).every((value: number, _: number, _a: Uint32Array): // const isBelowThreshold = (currentValue: number, index: number, array: Uint32Array): boolean => currentValue < 40;
boolean => value < 40); // let result = new Uint32Array([12, 5, 8, 130, 44]).every((value : number, _ : number, _a : Uint32Array) : boolean => value < 40);
expect(result).toEqual(false); expect(result).toEqual(false);
// #END
} }
testFill() { testFill() {
// #TEST Uint32Array.fill
let uint32 = new Uint32Array([1, 2, 3]).fill(4); let uint32 = new Uint32Array([1, 2, 3]).fill(4);
expect(uint32.toString()).toEqual("4,4,4"); expect(uint32.toString()).toEqual("4,4,4");
...@@ -101,46 +107,53 @@ export class TUint32Array { ...@@ -101,46 +107,53 @@ export class TUint32Array {
uint32 = new Uint32Array([1, 2, 3]).fill(4, -3, -2); uint32 = new Uint32Array([1, 2, 3]).fill(4, -3, -2);
expect(uint32.toString()).toEqual("4,2,3"); expect(uint32.toString()).toEqual("4,2,3");
// #END
} }
testFilter() { testFilter() {
// #TEST Uint32Array.filter
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
let uint32 = new Uint32Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Uint32Array) : boolean => value >= 10);
let uint32 = new Uint32Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Uint32Array):
boolean => value >= 10);
expect(uint32.toString()).toEqual("12,44"); expect(uint32.toString()).toEqual("12,44");
// #END
} }
find() { find() {
// #TEST Uint32Array.find
let uint32 = new Uint32Array([4, 5, 8, 12]); let uint32 = new Uint32Array([4, 5, 8, 12]);
let res = uint32.find((value: number, _: number, _a: Uint32Array): boolean => value > 5); let res = uint32.find((value : number, _ : number, _a : Uint32Array) : boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
// #END
} }
findIndex() { findIndex() {
// #TEST Uint32Array.findIndex
let uint32 = new Uint32Array([4, 6, 8, 12]); let uint32 = new Uint32Array([4, 6, 8, 12]);
let res = uint32.findIndex((value: number, _: number, _a: Uint32Array): boolean => value > 100); let res = uint32.findIndex((value : number, _ : number, _a : Uint32Array) : boolean => value > 100);
expect(res).toEqual(-1); expect(res).toEqual(-1);
let uuint32 = new Uint32Array([4, 6, 7, 120]); let uuint32 = new Uint32Array([4, 6, 7, 120]);
res = uuint32.findIndex((value: number, _: number, _a: Uint32Array): boolean => value > 100); res = uuint32.findIndex((value : number, _ : number, _a : Uint32Array) : boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
// #END
} }
foreach() { foreach() {
new Uint32Array([0, 1, 2, 3]).forEach((value: number, index: number, _a: Uint32Array) => { // #TEST Uint32Array.forEach
new Uint32Array([0, 1, 2, 3]).forEach((value : number, index : number, _a : Uint32Array) => {
console.log(`a[${index}] = ${value}`); console.log(`a[${index}] = ${value}`);
}); });
// #END
} }
iterator() { iterator() {
// #TEST Uint32Array.entries
let arr = new Uint32Array([10, 20, 30, 40, 50]); let arr = new Uint32Array([10, 20, 30, 40, 50]);
let entries = arr.entries(); let entries = arr.entries();
expect(entries.next().value[1]).toEqual(10); expect(entries.next().value[1]).toEqual(10);
// #END
} }
includes() { includes() {
// #TEST Uint32Array.includes
let uint32 = new Uint32Array([1, 2, 3]); let uint32 = new Uint32Array([1, 2, 3]);
let res = uint32.includes(2); let res = uint32.includes(2);
expect(res).toEqual(true); expect(res).toEqual(true);
...@@ -150,9 +163,11 @@ export class TUint32Array { ...@@ -150,9 +163,11 @@ export class TUint32Array {
res = uint32.includes(3, 3); res = uint32.includes(3, 3);
expect(res).toEqual(false); expect(res).toEqual(false);
// #END
} }
indexOf() { indexOf() {
// #TEST Uint32Array.indexOf
let uint32 = new Uint32Array([2, 5, 9]); let uint32 = new Uint32Array([2, 5, 9]);
let res = uint32.indexOf(2); let res = uint32.indexOf(2);
expect(res).toEqual(0); expect(res).toEqual(0);
...@@ -168,9 +183,10 @@ export class TUint32Array { ...@@ -168,9 +183,10 @@ export class TUint32Array {
res = uint32.indexOf(2, -3); res = uint32.indexOf(2, -3);
expect(res).toEqual(0); expect(res).toEqual(0);
// #END
} }
join() { join() {
// #TEST Uint32Array.join
let uint32 = new Uint32Array([1, 2, 3]); let uint32 = new Uint32Array([1, 2, 3]);
let res = uint32.join(); let res = uint32.join();
expect(res).toEqual("1,2,3"); expect(res).toEqual("1,2,3");
...@@ -180,52 +196,63 @@ export class TUint32Array { ...@@ -180,52 +196,63 @@ export class TUint32Array {
res = uint32.join(""); res = uint32.join("");
expect(res).toEqual("123"); expect(res).toEqual("123");
// #END
} }
keys() { keys() {
// #TEST Uint32Array.keys
let arr = new Uint32Array([10, 20, 30, 40, 50]); let arr = new Uint32Array([10, 20, 30, 40, 50]);
let keys = arr.keys(); let keys = arr.keys();
expect(keys.next().value).toEqual(0); expect(keys.next().value).toEqual(0);
// #END
} }
map() { map() {
// #TEST Uint32Array.map
let numbers = new Uint32Array([1, 4, 9]); let numbers = new Uint32Array([1, 4, 9]);
let doubles = numbers.map((value: number, _: number, _a: Uint32Array): number => value * 2); let doubles = numbers.map((value : number, _ : number, _a : Uint32Array) : number => value * 2);
expect(numbers.toString()).toEqual("1,4,9"); expect(numbers.toString()).toEqual("1,4,9");
expect(doubles.toString()).toEqual("2,8,18"); expect(doubles.toString()).toEqual("2,8,18");
// #END
} }
reduce() { reduce() {
// #TEST Uint32Array.reduce
let total = new Uint32Array([0, 1, 2, 3]); let total = new Uint32Array([0, 1, 2, 3]);
let res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Uint32Array): let res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Uint32Array) :
number => accumulator + currentValue); number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Uint32Array([0, 1, 2, 3]); total = new Uint32Array([0, 1, 2, 3]);
res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Uint32Array): res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Uint32Array) :
number => accumulator + currentValue, 8); number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
// #END
} }
reduceRight() { reduceRight() {
// #TEST Uint32Array.reduceRight
let total = new Uint32Array([0, 1, 2, 3]); let total = new Uint32Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Uint32Array): let res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Uint32Array) :
number => accumulator + currentValue); number => accumulator + currentValue);
expect(res).toEqual(6); expect(res).toEqual(6);
total = new Uint32Array([0, 1, 2, 3]); total = new Uint32Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Uint32Array): res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Uint32Array) :
number => accumulator + currentValue, 8); number => accumulator + currentValue, 8);
expect(res).toEqual(14); expect(res).toEqual(14);
// #END
} }
reverse() { reverse() {
// #TEST Uint32Array.reverse
let uint32 = new Uint32Array([1, 2, 3]); let uint32 = new Uint32Array([1, 2, 3]);
uint32.reverse(); uint32.reverse();
expect(uint32.toString()).toEqual("3,2,1"); expect(uint32.toString()).toEqual("3,2,1");
// #END
} }
slice() { slice() {
// #TEST Uint32Array.slice
let uint32 = new Uint32Array([1, 2, 3]); let uint32 = new Uint32Array([1, 2, 3]);
let res = uint32.slice(1); let res = uint32.slice(1);
expect(res.toString()).toEqual("2,3"); expect(res.toString()).toEqual("2,3");
...@@ -238,18 +265,21 @@ export class TUint32Array { ...@@ -238,18 +265,21 @@ export class TUint32Array {
res = uint32.slice(0, 1); res = uint32.slice(0, 1);
expect(res.toString()).toEqual("1"); expect(res.toString()).toEqual("1");
// #END
} }
sort() { sort() {
// #TEST Uint32Array.sort
let numbers = new Uint32Array([40, 1, 5]); let numbers = new Uint32Array([40, 1, 5]);
numbers.sort(); numbers.sort();
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
numbers.sort((a, b): number => a - b); numbers.sort((a, b) : number => a - b);
expect(numbers.toString()).toEqual("1,5,40"); expect(numbers.toString()).toEqual("1,5,40");
// #END
} }
subarray() { subarray() {
// #TEST Uint32Array.subarray
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let uint32 = new Uint32Array(buffer); let uint32 = new Uint32Array(buffer);
uint32.set([1, 2, 3]); uint32.set([1, 2, 3]);
...@@ -257,16 +287,19 @@ export class TUint32Array { ...@@ -257,16 +287,19 @@ export class TUint32Array {
let sub = uint32.subarray(0, 4); let sub = uint32.subarray(0, 4);
expect(sub.toString()).toEqual("1,2,3,0"); expect(sub.toString()).toEqual("1,2,3,0");
// #END
} }
values() { values() {
// #TEST Uint32Array.values
let arr = new Uint32Array([1, 2, 3]); let arr = new Uint32Array([1, 2, 3]);
let values = arr.values(); let values = arr.values();
expect(values.next().value).toEqual(1); expect(values.next().value).toEqual(1);
// #END
} }
arrayBufferSlice() { arrayBufferSlice() {
// #TEST ArrayBuffer.slice
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let uint32 = new Uint32Array(buffer); let uint32 = new Uint32Array(buffer);
uint32[3] = 42; uint32[3] = 42;
...@@ -275,6 +308,8 @@ export class TUint32Array { ...@@ -275,6 +308,8 @@ export class TUint32Array {
let res = buffer.slice(8); let res = buffer.slice(8);
let sliced = new Uint32Array(res); let sliced = new Uint32Array(res);
expect(sliced[1]).toEqual(42); expect(sliced[1]).toEqual(42);
// #END
} }
// #endif // #endif
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册