import { testArray } from './Array.uts' import { testDate } from './Date.uts' import { testString } from './String.uts' import { testError } from './Error.uts' import { testKeyWord } from './KeyWord.uts' import { testJSON } from './JSON.uts' import { testJSONLarge } from './JSON_large.uts' import { testUTSJSONObject } from './UTSJSONObject.uts' import { testConsole } from './console.uts' import { testNumber } from './Number.uts' import { testMap } from './Map.uts' import { testSet } from './Set.uts' import { testOperators } from './Operators.uts' import { testMath } from './Math.uts' import { testRegExp } from './RegExp.uts' import { testForLoop } from './ForLoop.uts' import { testGlobal } from './Global.uts' import { testType } from './Type.uts' export { Result } from './tests.uts' import { testArrayBuffer } from './ArrayBuffer.uts' import { testNativeCode } from './NativeCode.uts' // Promise、Proxy、Reflect、Weakmap、WeakSet 不支持 export function runTests() : UTSJSONObject { const ArrayRes = testArray(); const DateRes = testDate(); const StringRes = testString(); const ErrorRes = testError(); const JsonRes = testJSON(); const NumberRes = testNumber(); const MapRes = testMap(); const SetRes = testSet(); const OperatorsRes = testOperators(); const MathRes = testMath(); const RegExpRes = testRegExp(); const KeyWordRes = testKeyWord(); const ForLoopRes = testForLoop(); const GlobalRes = testGlobal(); const TypeRes = testType(); const JSONLargeRes = testJSONLarge(); const consoleRes = testConsole(); const UTSJSONObjectRes = testUTSJSONObject(); // #ifdef APP-ANDROID || WEB const ArrayBufferRes = testArrayBuffer(); // #endif const NativeCodeRes = testNativeCode(); return { Array: ArrayRes, Date: DateRes, String: StringRes, Error: ErrorRes, Json: JsonRes, JSONLarge: JSONLargeRes, Number: NumberRes, Map: MapRes, Set: SetRes, Operators: OperatorsRes, Math: MathRes, RegExp: RegExpRes, KeyWord: KeyWordRes, ForLoop: ForLoopRes, Global: GlobalRes, Type: TypeRes, console: consoleRes, UTSJSONObject: UTSJSONObjectRes, // #ifdef APP-ANDROID || WEB ArrayBuffer: ArrayBufferRes, // #endif NativeCode: NativeCodeRes } } // #ifdef APP-IOS import { expect } from './tests.uts' export type TestKeepAliveCallback = (res: string) => void export function onTest1(callback: TestKeepAliveCallback) { callback("1") setTimeout(()=> { callback("2") expect(callback != null).toEqual(true) }, 20) } @UTSJS.keepAlive export function testKeepAlive(callback: TestKeepAliveCallback) { callback("3") setTimeout(()=> { callback("4") expect(callback != null).toEqual(true) }, 22) } export type TestKeepAliveOption = { a: string success: TestKeepAliveCallback | null } @UTSJS.keepAlive export function testKeepAliveOption(option: TestKeepAliveOption) { console.log(option.a); option.success?.("11") setTimeout(() => { option.success?.("22") expect(option.success != null).toEqual(true) }, 30) } export class TestKeepAliveClass { constructor() { } onTest(callback: TestKeepAliveCallback) { callback("1") setTimeout(()=> { callback("2") expect(callback != null).toEqual(true) }, 40) } @UTSJS.keepAlive testKeepAlive(callback: TestKeepAliveCallback) { callback("3") setTimeout(()=> { callback("4") expect(callback != null).toEqual(true) }, 42) } @UTSJS.keepAlive testKeepAliveOption(option: TestKeepAliveOption) { console.log(option.a); option.success?.("11") setTimeout(() => { option.success?.("22") expect(option.success != null).toEqual(true) }, 45) } static onTestStatic(callback: TestKeepAliveCallback) { callback("1") setTimeout(()=> { callback("2") expect(callback != null).toEqual(true) }, 40) } @UTSJS.keepAlive static testKeepAliveStatic(callback: TestKeepAliveCallback) { callback("3") setTimeout(()=> { callback("4") expect(callback != null).toEqual(true) }, 50) } @UTSJS.keepAlive testKeepAliveOptionStatic(option: TestKeepAliveOption) { console.log(option.a); option.success?.("11") setTimeout(() => { option.success?.("22") expect(option.success != null).toEqual(true) }, 52) } } // #endif