提交 0d70f8e2 编写于 作者: M mahaifeng

[arraybuffer]修改测试用例

上级 905b5874
......@@ -203,24 +203,24 @@ export class TFloat32Array {
let total = new Float32Array([0, 1, 2, 3]);
let res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Float32Array):
number => accumulator + currentValue);
expect(res).toEqual(6.0);
expect(res).toEqual(6);
total = new Float32Array([0, 1, 2, 3]);
res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Float32Array):
number => accumulator + currentValue, 8);
expect(res).toEqual(14.0);
expect(res).toEqual(14);
}
reduceRight() {
let total = new Float32Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array:
Float32Array): number => accumulator + currentValue);
expect(res).toEqual(6.0);
expect(res).toEqual(6);
total = new Float32Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array: Float32Array):
number => accumulator + currentValue, 8);
expect(res).toEqual(14.0);
expect(res).toEqual(14);
}
reverse() {
......
......@@ -198,24 +198,24 @@ export class TFloat64Array {
let total = new Float64Array([0, 1, 2, 3]);
let res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Float64Array):
number => accumulator + currentValue);
expect(res).toEqual(6.0);
expect(res).toEqual(6);
total = new Float64Array([0, 1, 2, 3]);
res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Float64Array):
number => accumulator + currentValue, 8);
expect(res).toEqual(14.0);
expect(res).toEqual(14);
}
reduceRight() {
let total = new Float64Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array:
Float64Array): number => accumulator + currentValue);
expect(res).toEqual(6.0);
expect(res).toEqual(6);
total = new Float64Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array: Float64Array):
number => accumulator + currentValue, 8);
expect(res).toEqual(14.0);
expect(res).toEqual(14);
}
reverse() {
......
......@@ -177,21 +177,21 @@ export class TInt16Array {
reduce() {
let total = new Int16Array([0, 1, 2, 3]);
let res = total.reduce((accumulator : number, currentValue : number, currentIndex : number, array : Int16Array): number => accumulator + currentValue);
expect(res).toEqual(6.0);
expect(res).toEqual(6);
total = new Int16Array([0, 1, 2, 3]);
res = total.reduce((accumulator : number, currentValue : number, currentIndex : number, array : Int16Array): number => accumulator + currentValue, 8);
expect(res).toEqual(14.0);
expect(res).toEqual(14);
}
reduceRight() {
let total = new Int16Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue : number, currentIndex : number, array : Int16Array): number => accumulator + currentValue);
expect(res).toEqual(6.0);
expect(res).toEqual(6);
total = new Int16Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue : number, currentIndex : number, array : Int16Array): number => accumulator + currentValue, 8);
expect(res).toEqual(14.0);
expect(res).toEqual(14);
}
reverse() {
......
......@@ -2,6 +2,7 @@ import {
describe,
test,
expect,
expectNumber,
Result
} from './tests.uts'
......@@ -181,25 +182,25 @@ export class TInt8Array {
let total = new Int8Array([0, 1, 2, 3]);
let res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Int8Array):
number => accumulator + currentValue);
expect(res).toEqual(6.0);
expect(res).toEqual(6);
total = new Int8Array([0, 1, 2, 3]);
res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Int8Array): number =>
accumulator + currentValue, 8);
expect(res).toEqual(14.0);
expect(res).toEqual(14);
}
reduceRight() {
let total = new Int8Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array: Int8Array):
number => accumulator + currentValue);
expect(res).toEqual(6.0);
expect(res).toEqual(6);
total = new Int8Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array: Int8Array):
number => accumulator + currentValue, 8);
expect(res).toEqual(14.0);
expect(res).toEqual(14);
}
reverse() {
......
......@@ -123,13 +123,13 @@ export class TUint8Array {
includes() {
let float32 = new Uint8Array([1, 2, 3]);
let res = float32.includes(2.0);
let res = float32.includes(2);
expect(res).toEqual(true);
res = float32.includes(4.0);
res = float32.includes(4);
expect(res).toEqual(false);
res = float32.includes(3.0, 3);
res = float32.includes(3, 3);
expect(res).toEqual(false);
}
......@@ -179,21 +179,21 @@ export class TUint8Array {
reduce() {
let total = new Uint8Array([0, 1, 2, 3]);
let res = total.reduce((accumulator : number, currentValue : number, currentIndex : number, array : Uint8Array): number => accumulator + currentValue);
expect(res).toEqual(6.0);
expect(res).toEqual(6);
total = new Uint8Array([0, 1, 2, 3]);
res = total.reduce((accumulator : number, currentValue : number, currentIndex : number, array : Uint8Array): number => accumulator + currentValue, 8);
expect(res).toEqual(14.0);
expect(res).toEqual(14);
}
reduceRight() {
let total = new Uint8Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue : number, currentIndex : number, array : Uint8Array): number => accumulator + currentValue);
expect(res).toEqual(6.0);
expect(res).toEqual(6);
total = new Uint8Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue : number, currentIndex : number, array : Uint8Array): number => accumulator + currentValue, 8);
expect(res).toEqual(14.0);
expect(res).toEqual(14);
}
reverse() {
......
......@@ -125,13 +125,13 @@ export class TUint8ClampedArray {
includes() {
let float32 = new Uint8ClampedArray([1, 2, 3]);
let res = float32.includes(2.0);
let res = float32.includes(2);
expect(res).toEqual(true);
res = float32.includes(4.0);
res = float32.includes(4);
expect(res).toEqual(false);
res = float32.includes(3.0, 3);
res = float32.includes(3, 3);
expect(res).toEqual(false);
}
......@@ -182,24 +182,24 @@ export class TUint8ClampedArray {
let total = new Uint8ClampedArray([0, 1, 2, 3]);
let res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array:
Uint8ClampedArray): number => accumulator + currentValue);
expect(res).toEqual(6.0);
expect(res).toEqual(6);
total = new Uint8ClampedArray([0, 1, 2, 3]);
res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray):
number => accumulator + currentValue, 8);
expect(res).toEqual(14.0);
expect(res).toEqual(14);
}
reduceRight() {
let total = new Uint8ClampedArray([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array:
Uint8ClampedArray): number => accumulator + currentValue);
expect(res).toEqual(6.0);
expect(res).toEqual(6);
total = new Uint8ClampedArray([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array:
Uint8ClampedArray): number => accumulator + currentValue, 8);
expect(res).toEqual(14.0);
expect(res).toEqual(14);
}
reverse() {
......
......@@ -139,13 +139,13 @@ export class TUint16Array {
includes() {
let float32 = new Uint16Array([1, 2, 3]);
let res = float32.includes(2.0);
let res = float32.includes(2);
expect(res).toEqual(true);
res = float32.includes(4.0);
res = float32.includes(4);
expect(res).toEqual(false);
res = float32.includes(3.0, 3);
res = float32.includes(3, 3);
expect(res).toEqual(false);
}
......@@ -196,24 +196,24 @@ export class TUint16Array {
let total = new Uint16Array([0, 1, 2, 3]);
let res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Uint16Array):
number => accumulator + currentValue);
expect(res).toEqual(6.0);
expect(res).toEqual(6);
total = new Uint16Array([0, 1, 2, 3]);
res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Uint16Array):
number => accumulator + currentValue, 8);
expect(res).toEqual(14.0);
expect(res).toEqual(14);
}
reduceRight() {
let total = new Uint16Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array: Uint16Array):
number => accumulator + currentValue);
expect(res).toEqual(6.0);
expect(res).toEqual(6);
total = new Uint16Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array: Uint16Array):
number => accumulator + currentValue, 8);
expect(res).toEqual(14.0);
expect(res).toEqual(14);
}
reverse() {
......@@ -266,8 +266,8 @@ export class TUint16Array {
arrayBufferSlice() {
let buffer = new ArrayBuffer(16);
let float32 = new Uint16Array(buffer);
float32[3] = 42;
expect(float32.toString()).toEqual("0,0,0,42,0,0,0,0");
float32[4] = 42;
expect(float32.toString()).toEqual("0,0,0,0,42,0,0,0");
let res = buffer.slice(8);
let sliced = new Uint16Array(res);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册