提交 b0135fde 编写于 作者: M mahaifeng

[array-buffer]修改测试用例,将Int,Number类型去掉

上级 7f44bb89
...@@ -45,7 +45,7 @@ export class TDataView { ...@@ -45,7 +45,7 @@ export class TDataView {
// Create an ArrayBuffer with a size in bytes // Create an ArrayBuffer with a size in bytes
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let view = new DataView(buffer); let view = new DataView(buffer);
view.setFloat32(1, Math.PI.toFloat()); view.setFloat32(1,3.1415927);
expect(this.numberEquals(3.1415927, view.getFloat32(1).toFloat())).toEqual(true); expect(this.numberEquals(3.1415927, view.getFloat32(1).toFloat())).toEqual(true);
} }
...@@ -97,7 +97,7 @@ export class TDataView { ...@@ -97,7 +97,7 @@ export class TDataView {
expect(this.numberEquals(255, view.getUint8(1))).toEqual(true); expect(this.numberEquals(255, view.getUint8(1))).toEqual(true);
} }
numberEquals(a: Number, b: Number): Boolean { numberEquals(a: number, b: number): Boolean {
return a == b return a == b
} }
...@@ -138,10 +138,10 @@ export class TDataView { ...@@ -138,10 +138,10 @@ export class TDataView {
} }
} }
makeBuffer(size: Int, littleEndian: boolean): ArrayBuffer { makeBuffer(size: number, littleEndian: boolean): ArrayBuffer {
var buffer = new ArrayBuffer(size * 14); var buffer = new ArrayBuffer(1000 * 14);
var view = new DataView(buffer); var view = new DataView(buffer);
for (var i = 0; i < size; ++i) { for (var i = 0; i < 1000; ++i) {
view.setInt8(i * 14, i); view.setInt8(i * 14, i);
view.setUint8(i * 14 + 1, i); view.setUint8(i * 14 + 1, i);
view.setInt16(i * 14 + 2, i * i, littleEndian); view.setInt16(i * 14 + 2, i * i, littleEndian);
...@@ -180,21 +180,21 @@ export class TDataView { ...@@ -180,21 +180,21 @@ export class TDataView {
} }
expect(xor).toEqual(0); expect(xor).toEqual(0);
} else { } else {
var reader = new BigEndian(buffer); var reader1 = new BigEndian(buffer);
for (var i = 0; i < buffer.byteLength; i += 14) { for (var i = 0; i < buffer.byteLength; i += 14) {
xor ^= reader.getInt8(i); xor ^= reader1.getInt8(i);
xor ^= reader.getUint8(i + 1); xor ^= reader1.getUint8(i + 1);
xor ^= reader.getInt16(i + 2); xor ^= reader1.getInt16(i + 2);
xor ^= reader.getUint16(i + 4); xor ^= reader1.getUint16(i + 4);
xor ^= reader.getInt32(i + 6); xor ^= reader1.getInt32(i + 6);
xor ^= reader.getUint32(i + 10); xor ^= reader1.getUint32(i + 10);
} }
} }
} }
doFloatIterations(dataView: boolean) { doFloatIterations(dataView: boolean) {
var buffer = makeFloatBuffer(1000); var buffer = this.makeFloatBuffer();
var iterations = 10; var iterations = 10;
if (dataView) { if (dataView) {
for (var i = 0; i < iterations; i++) for (var i = 0; i < iterations; i++)
...@@ -205,10 +205,10 @@ export class TDataView { ...@@ -205,10 +205,10 @@ export class TDataView {
} }
} }
makeFloatBuffer(size: Int): ArrayBuffer { makeFloatBuffer(): ArrayBuffer {
var buffer = new ArrayBuffer(size * 16); var buffer = new ArrayBuffer(1000 * 16);
var view = new DataView(buffer); var view = new DataView(buffer);
for (var i = 0; i < size; i++) { for (var i = 0; i < 1000; i++) {
view.setFloat64(i * 16, Math.log10(i + 1)); view.setFloat64(i * 16, Math.log10(i + 1));
view.setFloat32(i * 16 + 8, Math.sqrt(i)); view.setFloat32(i * 16 + 8, Math.sqrt(i));
view.setFloat32(i * 16 + 12, Math.cos(i)); view.setFloat32(i * 16 + 12, Math.cos(i));
......
...@@ -253,7 +253,7 @@ export class TFloat32Array { ...@@ -253,7 +253,7 @@ export class TFloat32Array {
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");
} }
......
...@@ -244,7 +244,7 @@ export class TFloat64Array { ...@@ -244,7 +244,7 @@ export class TFloat64Array {
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");
} }
......
...@@ -220,7 +220,7 @@ export class TInt16Array { ...@@ -220,7 +220,7 @@ export class TInt16Array {
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");
} }
......
...@@ -236,7 +236,7 @@ export class TInt32Array { ...@@ -236,7 +236,7 @@ export class TInt32Array {
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");
} }
......
...@@ -229,7 +229,7 @@ export class TInt8Array { ...@@ -229,7 +229,7 @@ export class TInt8Array {
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");
} }
......
...@@ -233,7 +233,7 @@ export class TUint8Array { ...@@ -233,7 +233,7 @@ export class TUint8Array {
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");
} }
......
...@@ -228,7 +228,7 @@ export class TUint8ClampedArray { ...@@ -228,7 +228,7 @@ export class TUint8ClampedArray {
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");
} }
......
...@@ -242,7 +242,7 @@ export class TUint16Array { ...@@ -242,7 +242,7 @@ export class TUint16Array {
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");
} }
......
...@@ -242,7 +242,7 @@ export class TUint32Array { ...@@ -242,7 +242,7 @@ export class TUint32Array {
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");
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册