diff --git a/uni_modules/uts-syntaxcase/utssdk/index.uts b/uni_modules/uts-syntaxcase/utssdk/index.uts index 60350dd8f86bf013b0b3b79ab27ffe8a8fa92d9c..d84bac0718444c8b4ab33843e855bf5180ba97a5 100644 --- a/uni_modules/uts-syntaxcase/utssdk/index.uts +++ b/uni_modules/uts-syntaxcase/utssdk/index.uts @@ -52,14 +52,11 @@ export function testSyncWithCallback(opts : AsyncOptions) : SyntaxResult { async function testAwaitPromise(res : SyntaxResult) : Promise { - // #ifdef APP-ANDROID return await new Promise(function (resolve : (res : SyntaxResult) => void) { - resolve(res) + setTimeout(() => { + resolve(res) + }, 2000) }) - // #endif - // #ifndef APP-ANDROID - return res - // #endif } /** * 导出一个异步方法 @@ -100,7 +97,7 @@ export async function testAsyncParam3(id : number, name : string, opts : AsyncOp export class Test { id : number; - name : string; + name : string; static type : string = "Test"; constructor(id : number, options : TestOptions) { @@ -122,21 +119,21 @@ export class Test { const res = await testAsync(opts); return res; } -} - -export class SetterTest { - - private _nickName: string = ''; - - get nickName (): string { - console.log('get nickName'); - return this._nickName; - } - set nickName (value: string) { - console.log('set nickName'); - this._nickName = value; - } - +} + +export class SetterTest { + + private _nickName: string = ''; + + get nickName (): string { + console.log('get nickName'); + return this._nickName; + } + set nickName (value: string) { + console.log('set nickName'); + this._nickName = value; + } + } class RequestTaskImpl implements RequestTask { @@ -161,15 +158,15 @@ export function request(url : string) : RequestTask | null { return new RequestTaskImpl(url) } // #ifdef APP-ANDROID -// #ifdef UNI-APP-X +// #ifdef UNI-APP-X export function callKotlinMethodGetInfo():String { return NativeCode.getPhoneInfo() -} - +} + export function callJavaMethodGetInfo():String { return new JavaUser("jack",12).name -} - +} + import KeyEvent from 'android.view.KeyEvent'; import Configuration from 'android.content.res.Configuration'; diff --git a/uni_modules/uts-tests/utssdk/String.uts b/uni_modules/uts-tests/utssdk/String.uts index 2d4894233d191431034ba05a84c2c7b6d21e9a2f..5560cd86460c6601959313797ef02062a8ecb3e1 100644 --- a/uni_modules/uts-tests/utssdk/String.uts +++ b/uni_modules/uts-tests/utssdk/String.uts @@ -7,10 +7,10 @@ export function testString() : Result { const x = "Mozilla"; const e = ""; - console.log("Mozilla is " + x.length + " code units long"); + console.log("Mozilla is " + `${x.length}` + " code units long"); /* "Mozilla is 7 code units long" */ - console.log("The empty string is has a length of " + e.length); + console.log("The empty string is has a length of " + `${e.length}`); /* "The e string is has a length of 0" */ // #END @@ -335,6 +335,7 @@ export function testString() : Result { // #TEST String.replace_1 + // #ifdef APP-ANDROID // 不包含捕捉组的示例 let a = "The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?" let b = a.replace(RegExp("fox"), function (match : string, offset : number, string : string) : string { @@ -344,7 +345,7 @@ export function testString() : Result { return "cat" }) console.log("b:", b) - + // 包含一个捕获组的示例。注意,目前android仅支持最多五个捕获组 let a1 = "The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?" let b1 = a1.replace(RegExp("(fox)"), function (match : string, p1 : string, offset : number, string : string) : string { @@ -355,6 +356,8 @@ export function testString() : Result { return "cat" }) console.log("b1", b1) + // #endif + // #END // const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|SSS/g @@ -374,10 +377,12 @@ export function testString() : Result { // #TEST String.search const paragraph = 'The quick brown fox jumps over the lazy dog. If the dog barked, was it really lazy?'; const regex = /[^\w\s]/g; + // #ifdef APP-ANDROID console.log(paragraph.search(regex)); // expected output: 43 console.log(paragraph[paragraph.search(regex)]); // expected output: "." + // #endif // #END expect(paragraph.search(regex)).toEqual(43); diff --git a/uni_modules/uts-tests/utssdk/UTSJSONObject.uts b/uni_modules/uts-tests/utssdk/UTSJSONObject.uts index 2aa51f8febb679dc9aa5bce2ad8250b12618e813..2d3b967632143be1d5a5468d059532dc946d778b 100644 --- a/uni_modules/uts-tests/utssdk/UTSJSONObject.uts +++ b/uni_modules/uts-tests/utssdk/UTSJSONObject.uts @@ -163,7 +163,7 @@ export function testUTSJSONObject() : Result { } } //返回指定键对应的值,如果对象中不存在此键则返回 null。 - let name : string = person.get('name') as string + let name : string = person["name"] as String //get 方法可以简化为使用下标运算符 `[]` 访问 name = person['name'] as string //增加或更新指定键对应的值。