提交 ba58c133 编写于 作者: M mahaifeng

[arraybuffer]修改1.0编译失败

上级 48a4d1f4
...@@ -23,8 +23,7 @@ const int16 = new TInt16Array() ...@@ -23,8 +23,7 @@ const int16 = new TInt16Array()
export function testArrayBuffer() : Result { export function testArrayBuffer() : Result {
return describe("ArrayBuffer", () => { return describe("ArrayBuffer", () => {
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
//dataview start //dataview start
test('dataview_constructor', () => { test('dataview_constructor', () => {
tDataView.setConstructor() tDataView.setConstructor()
......
...@@ -18,7 +18,7 @@ export class TDataView { ...@@ -18,7 +18,7 @@ export class TDataView {
// this.setUint8(); // this.setUint8();
// this.testMix(); // this.testMix();
} }
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
setConstructor() { setConstructor() {
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let dataview = new DataView(buffer); let dataview = new DataView(buffer);
......
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
export class TFloat32Array { export class TFloat32Array {
test() { test() {
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
this.testfloat32(); this.testfloat32();
this.testConstructor(); this.testConstructor();
this.testSet(); this.testSet();
...@@ -34,7 +34,7 @@ export class TFloat32Array { ...@@ -34,7 +34,7 @@ export class TFloat32Array {
this.arrayBufferSlice(); this.arrayBufferSlice();
// #endif // #endif
} }
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
from() { from() {
var float32Array = Float32Array.from([1, 2, 3], (v : number, _ : number) : number => v + v); var float32Array = Float32Array.from([1, 2, 3], (v : number, _ : number) : number => v + v);
expect(float32Array.toString()).toEqual('2,4,6'); expect(float32Array.toString()).toEqual('2,4,6');
......
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
export class TFloat64Array { export class TFloat64Array {
test() { test() {
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
this.testfloat64(); this.testfloat64();
this.testConstructor(); this.testConstructor();
this.testSet(); this.testSet();
...@@ -34,7 +34,7 @@ export class TFloat64Array { ...@@ -34,7 +34,7 @@ export class TFloat64Array {
this.arrayBufferSlice(); this.arrayBufferSlice();
// #endif // #endif
} }
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
testfloat64() { testfloat64() {
let float64 = new Float64Array(2); let float64 = new Float64Array(2);
float64[0] = 42; float64[0] = 42;
......
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
export class TInt16Array { export class TInt16Array {
test() { test() {
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
this.testConstructor(); this.testConstructor();
this.testSet(); this.testSet();
this.testCopyWith(); this.testCopyWith();
...@@ -34,7 +34,8 @@ export class TInt16Array { ...@@ -34,7 +34,8 @@ export class TInt16Array {
// #endif // #endif
} }
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
testConstructor() { testConstructor() {
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let int16 = new Int16Array(buffer); let int16 = new Int16Array(buffer);
...@@ -62,7 +63,7 @@ export class TInt16Array { ...@@ -62,7 +63,7 @@ export class TInt16Array {
testEvery() { testEvery() {
// #TEST Int16Array.every // #TEST Int16Array.every
let result = new Int16Array([12, 5, 8, 130, 44]).every((value, _, _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 // #END
} }
...@@ -88,7 +89,7 @@ export class TInt16Array { ...@@ -88,7 +89,7 @@ export class TInt16Array {
testFilter() { testFilter() {
// #TEST Int16Array.filter // #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, _, _a : Int16Array) : boolean => value >= 10);
expect(int16.toString()).toEqual("12,44"); expect(int16.toString()).toEqual("12,44");
// #END // #END
} }
...@@ -96,7 +97,7 @@ export class TInt16Array { ...@@ -96,7 +97,7 @@ export class TInt16Array {
find() { find() {
// #TEST Int16Array.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, _, _a:Int16Array):boolean => value > 5); let res = int16.find((value, _, _a : Int16Array) : boolean => value > 5);
expect(res).toEqual(8); expect(res).toEqual(8);
// #END // #END
} }
...@@ -104,18 +105,18 @@ export class TInt16Array { ...@@ -104,18 +105,18 @@ export class TInt16Array {
findIndex() { findIndex() {
// #TEST Int16Array.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, _, _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, _, _a:Int16Array):boolean => value > 100); res = int16.findIndex((value, _, _a : Int16Array) : boolean => value > 100);
expect(res).toEqual(3); expect(res).toEqual(3);
// #END // #END
} }
foreach() { foreach() {
// #TEST Int16Array.forEach // #TEST Int16Array.forEach
new Int16Array([0, 1, 2, 3]).forEach((value, index, _:Int16Array) => { new Int16Array([0, 1, 2, 3]).forEach((value, index, _ : Int16Array) => {
console.log(`a[${index}] = ${value}`); console.log(`a[${index}] = ${value}`);
}); });
// #END // #END
...@@ -192,7 +193,7 @@ export class TInt16Array { ...@@ -192,7 +193,7 @@ export class TInt16Array {
map() { map() {
// #TEST Int16Array.map // #TEST Int16Array.map
let numbers = new Int16Array([1, 4, 9]); let numbers = new Int16Array([1, 4, 9]);
let doubles = numbers.map((value, _, _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 // #END
...@@ -201,11 +202,11 @@ export class TInt16Array { ...@@ -201,11 +202,11 @@ export class TInt16Array {
reduce() { reduce() {
// #TEST Int16Array.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, currentValue, _, _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, currentValue, _, _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 // #END
} }
...@@ -213,11 +214,11 @@ export class TInt16Array { ...@@ -213,11 +214,11 @@ export class TInt16Array {
reduceRight() { reduceRight() {
// #TEST Int16Array.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, currentValue, _, _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, currentValue, _, _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 // #END
} }
...@@ -253,7 +254,7 @@ export class TInt16Array { ...@@ -253,7 +254,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");
// #END // #END
} }
......
...@@ -7,7 +7,8 @@ import { ...@@ -7,7 +7,8 @@ import {
export class TInt32Array { export class TInt32Array {
test() { test() {
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
this.testInt32Array(); this.testInt32Array();
this.testConstructor(); this.testConstructor();
this.testSet(); this.testSet();
...@@ -35,7 +36,8 @@ export class TInt32Array { ...@@ -35,7 +36,8 @@ export class TInt32Array {
// #endif // #endif
} }
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
testInt32Array() { testInt32Array() {
let int32 = new Int32Array(2); let int32 = new Int32Array(2);
int32[0] = 42; int32[0] = 42;
......
...@@ -8,7 +8,8 @@ import { ...@@ -8,7 +8,8 @@ import {
export class TInt8Array { export class TInt8Array {
test() { test() {
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
this.testConstructor(); this.testConstructor();
this.testSet(); this.testSet();
this.testCopyWith(); this.testCopyWith();
...@@ -35,7 +36,8 @@ export class TInt8Array { ...@@ -35,7 +36,8 @@ export class TInt8Array {
//#endif //#endif
} }
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
testConstructor() { testConstructor() {
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
let int8View = new Int8Array(buffer); let int8View = new Int8Array(buffer);
......
...@@ -7,7 +7,8 @@ import { ...@@ -7,7 +7,8 @@ import {
export class TUint8Array { export class TUint8Array {
test() { test() {
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
this.testMAX(); this.testMAX();
this.testConstructor(); this.testConstructor();
this.testSet(); this.testSet();
...@@ -34,7 +35,8 @@ export class TUint8Array { ...@@ -34,7 +35,8 @@ export class TUint8Array {
this.arrayBufferSlice(); this.arrayBufferSlice();
// #endif // #endif
} }
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
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);
...@@ -314,11 +316,11 @@ export class TUint8Array { ...@@ -314,11 +316,11 @@ export class TUint8Array {
element < 10 element < 10
) )
expect(res).toEqual(true); expect(res).toEqual(true);
console.log('uint8',res) console.log('uint8', res)
res = positives.some((element : number, index : number, array : Uint8Array) : boolean => res = positives.some((element : number, index : number, array : Uint8Array) : boolean =>
element < 0 element < 0
) )
console.log('uint8',res) console.log('uint8', res)
expect(res).toEqual(false); expect(res).toEqual(false);
// #END // #END
} }
......
...@@ -7,7 +7,8 @@ import { ...@@ -7,7 +7,8 @@ import {
export class TUint8ClampedArray { export class TUint8ClampedArray {
test() { test() {
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
this.testMAX(); this.testMAX();
this.testConstructor(); this.testConstructor();
this.testSet(); this.testSet();
...@@ -35,7 +36,8 @@ export class TUint8ClampedArray { ...@@ -35,7 +36,8 @@ export class TUint8ClampedArray {
// #endif // #endif
} }
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
testMAX() { testMAX() {
let uint8Clamped = new Uint8ClampedArray(16); let uint8Clamped = new Uint8ClampedArray(16);
uint8Clamped[0] = 255; uint8Clamped[0] = 255;
......
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
export class TUint16Array { export class TUint16Array {
test() { test() {
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
this.testuint16(); this.testuint16();
this.testConstructor(); this.testConstructor();
this.testSet(); this.testSet();
...@@ -35,7 +35,7 @@ export class TUint16Array { ...@@ -35,7 +35,7 @@ export class TUint16Array {
// #endif // #endif
} }
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
testuint16() { testuint16() {
let uint16 = new Uint16Array(2); let uint16 = new Uint16Array(2);
uint16[0] = 42; uint16[0] = 42;
...@@ -334,5 +334,4 @@ export class TUint16Array { ...@@ -334,5 +334,4 @@ export class TUint16Array {
// #END // #END
} }
// #endif // #endif
} }
\ No newline at end of file
...@@ -7,7 +7,8 @@ import { ...@@ -7,7 +7,8 @@ import {
export class TUint32Array { export class TUint32Array {
test() { test() {
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
this.testuint32(); this.testuint32();
this.testConstructor(); this.testConstructor();
this.testSet(); this.testSet();
...@@ -35,7 +36,7 @@ export class TUint32Array { ...@@ -35,7 +36,7 @@ export class TUint32Array {
// #endif // #endif
} }
// #ifndef APP-IOS // #ifdef (UNI-APP-X && APP-ANDROID) || WEB
testuint32() { testuint32() {
let uint32 = new Uint32Array(2); let uint32 = new Uint32Array(2);
uint32[0] = 42; uint32[0] = 42;
......
...@@ -41,7 +41,10 @@ export function runTests() : UTSJSONObject { ...@@ -41,7 +41,10 @@ export function runTests() : UTSJSONObject {
const JSONLargeRes = testJSONLarge(); const JSONLargeRes = testJSONLarge();
const consoleRes = testConsole(); const consoleRes = testConsole();
const UTSJSONObjectRes = testUTSJSONObject(); const UTSJSONObjectRes = testUTSJSONObject();
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB
const ArrayBufferRes = testArrayBuffer(); const ArrayBufferRes = testArrayBuffer();
// #endif
const NativeCodeRes = testNativeCode(); const NativeCodeRes = testNativeCode();
return { return {
Array: ArrayRes, Array: ArrayRes,
...@@ -62,7 +65,9 @@ export function runTests() : UTSJSONObject { ...@@ -62,7 +65,9 @@ export function runTests() : UTSJSONObject {
Type: TypeRes, Type: TypeRes,
console:consoleRes, console:consoleRes,
UTSJSONObject:UTSJSONObjectRes, UTSJSONObject:UTSJSONObjectRes,
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB
ArrayBuffer:ArrayBufferRes, ArrayBuffer:ArrayBufferRes,
// #endif
NativeCode:NativeCodeRes NativeCode:NativeCodeRes
} }
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册