提交 1ed4b2ab 编写于 作者: M mahaifeng

[arraybuffer]1.0支持arraybuffer

上级 b8fbad5c
...@@ -9,7 +9,7 @@ import { TUint8Array } from './TUInt8Array.uts' ...@@ -9,7 +9,7 @@ import { TUint8Array } from './TUInt8Array.uts'
import { TUint8ClampedArray } from './TUInt8ClampedArray.uts' import { TUint8ClampedArray } from './TUInt8ClampedArray.uts'
import { TUint16Array } from './TUint16Array.uts' import { TUint16Array } from './TUint16Array.uts'
import { TUint32Array } from './TUint32Array.uts' import { TUint32Array } from './TUint32Array.uts'
// #ifdef UNI-APP-X && APP-ANDROID // #ifdef APP-ANDROID
import ByteBuffer from 'java.nio.ByteBuffer'; import ByteBuffer from 'java.nio.ByteBuffer';
// #endif // #endif
...@@ -26,7 +26,7 @@ const int16 = new TInt16Array() ...@@ -26,7 +26,7 @@ const int16 = new TInt16Array()
export function testArrayBuffer() : Result { export function testArrayBuffer() : Result {
return describe("ArrayBuffer", () => { return describe("ArrayBuffer", () => {
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef APP-ANDROID || WEB
test('arraybuffer_isview', () => { test('arraybuffer_isview', () => {
// #TEST ArrayBuffer.isView // #TEST ArrayBuffer.isView
var arrayBuffer = new ArrayBuffer(16) var arrayBuffer = new ArrayBuffer(16)
...@@ -42,7 +42,7 @@ export function testArrayBuffer() : Result { ...@@ -42,7 +42,7 @@ export function testArrayBuffer() : Result {
expect(isViewA).toEqual(false); expect(isViewA).toEqual(false);
}) })
// #ifdef UNI-APP-X && APP-ANDROID // #ifdef APP-ANDROID
test('arraybuffer_toByteBuffer', () => { test('arraybuffer_toByteBuffer', () => {
// #TEST ArrayBuffer.fromByteBuffer,ArrayBuffer.toByteBuffer // #TEST ArrayBuffer.fromByteBuffer,ArrayBuffer.toByteBuffer
var byteBuffer = ByteBuffer.allocate(100) var byteBuffer = ByteBuffer.allocate(100)
......
...@@ -18,7 +18,7 @@ export class TDataView { ...@@ -18,7 +18,7 @@ export class TDataView {
// this.setUint8(); // this.setUint8();
// this.testMix(); // this.testMix();
} }
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef 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() {
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef 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
} }
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef 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');
...@@ -399,4 +399,4 @@ export class TFloat32Array { ...@@ -399,4 +399,4 @@ export class TFloat32Array {
} }
// #endif // #endif
} }
\ No newline at end of file
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
export class TFloat64Array { export class TFloat64Array {
test() { test() {
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef 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
} }
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef 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() {
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef APP-ANDROID || WEB
this.testConstructor(); this.testConstructor();
this.testSet(); this.testSet();
this.testCopyWith(); this.testCopyWith();
...@@ -34,7 +34,7 @@ export class TInt16Array { ...@@ -34,7 +34,7 @@ export class TInt16Array {
// #endif // #endif
} }
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef APP-ANDROID || WEB
testConstructor() { testConstructor() {
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
......
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
export class TInt32Array { export class TInt32Array {
test() { test() {
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef APP-ANDROID || WEB
this.testInt32Array(); this.testInt32Array();
this.testConstructor(); this.testConstructor();
...@@ -36,7 +36,7 @@ export class TInt32Array { ...@@ -36,7 +36,7 @@ export class TInt32Array {
// #endif // #endif
} }
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef APP-ANDROID || WEB
testInt32Array() { testInt32Array() {
let int32 = new Int32Array(2); let int32 = new Int32Array(2);
...@@ -103,7 +103,7 @@ export class TInt32Array { ...@@ -103,7 +103,7 @@ export class TInt32Array {
int32 = new Int32Array([1, 2, 3]).fill(4, 1); int32 = new Int32Array([1, 2, 3]).fill(4, 1);
console.log(int32.toString()); // "1,4,4" console.log(int32.toString()); // "1,4,4"
// expect(int32.toString()).toEqual("1,4,4"); // expect(int32.toString()).toEqual("1,4,4");
int32 = new Int32Array([1, 2, 3]).fill(4, 1, 2); int32 = new Int32Array([1, 2, 3]).fill(4, 1, 2);
...@@ -113,7 +113,7 @@ export class TInt32Array { ...@@ -113,7 +113,7 @@ export class TInt32Array {
int32 = new Int32Array([1, 2, 3]).fill(4, 1, 1); int32 = new Int32Array([1, 2, 3]).fill(4, 1, 1);
console.log(int32.toString()); // "1,2,3" console.log(int32.toString()); // "1,2,3"
// expect(int32.toString()).toEqual("1,2,3"); // expect(int32.toString()).toEqual("1,2,3");
int32 = new Int32Array([1, 2, 3]).fill(4, -3, -2); int32 = new Int32Array([1, 2, 3]).fill(4, -3, -2);
...@@ -182,7 +182,7 @@ export class TInt32Array { ...@@ -182,7 +182,7 @@ export class TInt32Array {
res = int32.includes(4); res = int32.includes(4);
console.log(res); // false console.log(res); // false
// expect(res).toEqual(false); // expect(res).toEqual(false);
res = int32.includes(3, 3); res = int32.includes(3, 3);
...@@ -196,7 +196,7 @@ export class TInt32Array { ...@@ -196,7 +196,7 @@ export class TInt32Array {
let int32 = new Int32Array([2, 5, 9]); let int32 = new Int32Array([2, 5, 9]);
let res = int32.indexOf(2); let res = int32.indexOf(2);
console.log(res); // 0 console.log(res); // 0
// expect(res).toEqual(0); // expect(res).toEqual(0);
res = int32.indexOf(7); res = int32.indexOf(7);
...@@ -225,12 +225,12 @@ export class TInt32Array { ...@@ -225,12 +225,12 @@ export class TInt32Array {
let int32 = new Int32Array([1, 2, 3]); let int32 = new Int32Array([1, 2, 3]);
let res = int32.join(); let res = int32.join();
console.log(res); // "1,2,3" console.log(res); // "1,2,3"
// expect(res).toEqual("1,2,3"); // expect(res).toEqual("1,2,3");
res = int32.join(" / "); res = int32.join(" / ");
console.log(res); // "1 / 2 / 3" console.log(res); // "1 / 2 / 3"
// expect(res).toEqual("1 / 2 / 3"); // expect(res).toEqual("1 / 2 / 3");
res = int32.join(""); res = int32.join("");
...@@ -265,7 +265,7 @@ export class TInt32Array { ...@@ -265,7 +265,7 @@ export class TInt32Array {
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);
console.log(res); // 6 console.log(res); // 6
// expect(res).toEqual(6); // expect(res).toEqual(6);
total = new Int32Array([0, 1, 2, 3]); total = new Int32Array([0, 1, 2, 3]);
...@@ -279,7 +279,7 @@ export class TInt32Array { ...@@ -279,7 +279,7 @@ export class TInt32Array {
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);
console.log(res); // 6 console.log(res); // 6
// expect(res).toEqual(6); // expect(res).toEqual(6);
total = new Int32Array([0, 1, 2, 3]); total = new Int32Array([0, 1, 2, 3]);
...@@ -303,17 +303,17 @@ export class TInt32Array { ...@@ -303,17 +303,17 @@ export class TInt32Array {
let int32 = new Int32Array([1, 2, 3]); let int32 = new Int32Array([1, 2, 3]);
let res = int32.slice(1); let res = int32.slice(1);
console.log(res.toString()); // "2,3" console.log(res.toString()); // "2,3"
// expect(res.toString()).toEqual("2,3"); // expect(res.toString()).toEqual("2,3");
res = int32.slice(2); res = int32.slice(2);
console.log(res.toString()); // "3" console.log(res.toString()); // "3"
// expect(res.toString()).toEqual("3"); // expect(res.toString()).toEqual("3");
res = int32.slice(-2); res = int32.slice(-2);
console.log(res.toString()); // "2,3" console.log(res.toString()); // "2,3"
// expect(res.toString()).toEqual("2,3"); // expect(res.toString()).toEqual("2,3");
res = int32.slice(0, 1); res = int32.slice(0, 1);
...@@ -327,7 +327,7 @@ export class TInt32Array { ...@@ -327,7 +327,7 @@ export class TInt32Array {
let numbers = new Int32Array([40, 1, 5]); let numbers = new Int32Array([40, 1, 5]);
numbers.sort(); numbers.sort();
console.log(numbers.toString()); // "1,5,40" console.log(numbers.toString()); // "1,5,40"
// 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);
...@@ -379,7 +379,7 @@ export class TInt32Array { ...@@ -379,7 +379,7 @@ export class TInt32Array {
const positives = new Int32Array([10, 20, 30, 40, 50]); const positives = new Int32Array([10, 20, 30, 40, 50]);
console.log(int32.some((element : number, index : number, array : Int32Array) : boolean => element < 0)); // true console.log(int32.some((element : number, index : number, array : Int32Array) : boolean => element < 0)); // true
// expect(int32.some((element : number, index : number, array : Int32Array) : boolean => element < 0)).toEqual(true); // expect(int32.some((element : number, index : number, array : Int32Array) : boolean => element < 0)).toEqual(true);
console.log(positives.some((element : number, index : number, array : Int32Array) : boolean => element < 0)); // false console.log(positives.some((element : number, index : number, array : Int32Array) : boolean => element < 0)); // false
......
...@@ -8,7 +8,7 @@ import { ...@@ -8,7 +8,7 @@ import {
export class TInt8Array { export class TInt8Array {
test() { test() {
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef APP-ANDROID || WEB
this.testConstructor(); this.testConstructor();
this.testSet(); this.testSet();
...@@ -36,7 +36,7 @@ export class TInt8Array { ...@@ -36,7 +36,7 @@ export class TInt8Array {
//#endif //#endif
} }
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef APP-ANDROID || WEB
testConstructor() { testConstructor() {
let buffer = new ArrayBuffer(16); let buffer = new ArrayBuffer(16);
......
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
export class TUint8Array { export class TUint8Array {
test() { test() {
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef APP-ANDROID || WEB
this.testMAX(); this.testMAX();
this.testConstructor(); this.testConstructor();
...@@ -35,7 +35,7 @@ export class TUint8Array { ...@@ -35,7 +35,7 @@ export class TUint8Array {
this.arrayBufferSlice(); this.arrayBufferSlice();
// #endif // #endif
} }
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef APP-ANDROID || WEB
from() { from() {
var s = new Set([1, 2, 3]); var s = new Set([1, 2, 3]);
......
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
export class TUint8ClampedArray { export class TUint8ClampedArray {
test() { test() {
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef APP-ANDROID || WEB
this.testMAX(); this.testMAX();
this.testConstructor(); this.testConstructor();
...@@ -36,7 +36,7 @@ export class TUint8ClampedArray { ...@@ -36,7 +36,7 @@ export class TUint8ClampedArray {
// #endif // #endif
} }
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef APP-ANDROID || WEB
testMAX() { testMAX() {
let uint8Clamped = new Uint8ClampedArray(16); let uint8Clamped = new Uint8ClampedArray(16);
......
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
export class TUint16Array { export class TUint16Array {
test() { test() {
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef 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
} }
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef APP-ANDROID || WEB
testuint16() { testuint16() {
let uint16 = new Uint16Array(2); let uint16 = new Uint16Array(2);
uint16[0] = 42; uint16[0] = 42;
......
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
export class TUint32Array { export class TUint32Array {
test() { test() {
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef APP-ANDROID || WEB
this.testuint32(); this.testuint32();
this.testConstructor(); this.testConstructor();
...@@ -36,7 +36,7 @@ export class TUint32Array { ...@@ -36,7 +36,7 @@ export class TUint32Array {
// #endif // #endif
} }
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef APP-ANDROID || WEB
testuint32() { testuint32() {
let uint32 = new Uint32Array(2); let uint32 = new Uint32Array(2);
uint32[0] = 42; uint32[0] = 42;
......
...@@ -3,10 +3,10 @@ import { testDate } from './Date.uts' ...@@ -3,10 +3,10 @@ import { testDate } from './Date.uts'
import { testString } from './String.uts' import { testString } from './String.uts'
import { testError } from './Error.uts' import { testError } from './Error.uts'
import { testKeyWord } from './KeyWord.uts' import { testKeyWord } from './KeyWord.uts'
import { testJSON } from './JSON.uts' import { testJSON } from './JSON.uts'
import { testJSONLarge } from './JSON_large.uts' import { testJSONLarge } from './JSON_large.uts'
import { testUTSJSONObject } from './UTSJSONObject.uts' import { testUTSJSONObject } from './UTSJSONObject.uts'
import { testConsole } from './console.uts' import { testConsole } from './console.uts'
import { testNumber } from './Number.uts' import { testNumber } from './Number.uts'
import { testMap } from './Map.uts' import { testMap } from './Map.uts'
import { testSet } from './Set.uts' import { testSet } from './Set.uts'
...@@ -16,9 +16,9 @@ import { testRegExp } from './RegExp.uts' ...@@ -16,9 +16,9 @@ import { testRegExp } from './RegExp.uts'
import { testForLoop } from './ForLoop.uts' import { testForLoop } from './ForLoop.uts'
import { testGlobal } from './Global.uts' import { testGlobal } from './Global.uts'
import { testType } from './Type.uts' import { testType } from './Type.uts'
export { Result } from './tests.uts' export { Result } from './tests.uts'
import { testArrayBuffer } from './ArrayBuffer.uts' import { testArrayBuffer } from './ArrayBuffer.uts'
import { testNativeCode } from './NativeCode.uts' import { testNativeCode } from './NativeCode.uts'
// Promise、Proxy、Reflect、Weakmap、WeakSet 不支持 // Promise、Proxy、Reflect、Weakmap、WeakSet 不支持
...@@ -37,22 +37,22 @@ export function runTests() : UTSJSONObject { ...@@ -37,22 +37,22 @@ export function runTests() : UTSJSONObject {
const KeyWordRes = testKeyWord(); const KeyWordRes = testKeyWord();
const ForLoopRes = testForLoop(); const ForLoopRes = testForLoop();
const GlobalRes = testGlobal(); const GlobalRes = testGlobal();
const TypeRes = testType(); const TypeRes = testType();
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 // #ifdef APP-ANDROID || WEB
const ArrayBufferRes = testArrayBuffer(); const ArrayBufferRes = testArrayBuffer();
// #endif // #endif
const NativeCodeRes = testNativeCode(); const NativeCodeRes = testNativeCode();
return { return {
Array: ArrayRes, Array: ArrayRes,
Date: DateRes, Date: DateRes,
String: StringRes, String: StringRes,
Error: ErrorRes, Error: ErrorRes,
Json: JsonRes, Json: JsonRes,
JSONLarge:JSONLargeRes, JSONLarge: JSONLargeRes,
Number: NumberRes, Number: NumberRes,
Map: MapRes, Map: MapRes,
Set: SetRes, Set: SetRes,
...@@ -61,13 +61,13 @@ export function runTests() : UTSJSONObject { ...@@ -61,13 +61,13 @@ export function runTests() : UTSJSONObject {
RegExp: RegExpRes, RegExp: RegExpRes,
KeyWord: KeyWordRes, KeyWord: KeyWordRes,
ForLoop: ForLoopRes, ForLoop: ForLoopRes,
Global: GlobalRes, Global: GlobalRes,
Type: TypeRes, Type: TypeRes,
console:consoleRes, console: consoleRes,
UTSJSONObject:UTSJSONObjectRes, UTSJSONObject: UTSJSONObjectRes,
// #ifdef (UNI-APP-X && APP-ANDROID) || WEB // #ifdef APP-ANDROID || WEB
ArrayBuffer:ArrayBufferRes, ArrayBuffer: ArrayBufferRes,
// #endif // #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.
先完成此消息的编辑!
想要评论请 注册