diff --git a/uni_modules/uts-helloworld/utssdk/index.uts b/uni_modules/uts-helloworld/utssdk/index.uts index 33851b0c09e59cc63df4dfde440b5bb1f5da1049..101059d29abeb2471895fe57ed7b89fceb991894 100644 --- a/uni_modules/uts-helloworld/utssdk/index.uts +++ b/uni_modules/uts-helloworld/utssdk/index.uts @@ -53,7 +53,7 @@ export function onCallback(callback: (sth:string) => void) { let count = 1 let taskId = -1 taskId = setInterval(function() { - callback("第" + count + "次回调") + callback(`第 ${count} 次回调`) count++; console.log("count",count) if(count > 3){ diff --git a/uni_modules/uts-syntaxcase/utssdk/index.uts b/uni_modules/uts-syntaxcase/utssdk/index.uts index 113a951e7a60773d7ed6db588d68ba01ba4e87d8..a86c4b3883aab7af1c1266837e8f9046e3e52785 100644 --- a/uni_modules/uts-syntaxcase/utssdk/index.uts +++ b/uni_modules/uts-syntaxcase/utssdk/index.uts @@ -440,7 +440,7 @@ export function Scan1(timeMillis ?: Number):string { if(timeMillis == null){ return "null" } - return timeMillis.toString() + return timeMillis!.toString() } export function Scan2(timeMillis ?: Number | null):string { @@ -448,7 +448,7 @@ export function Scan2(timeMillis ?: Number | null):string { if(timeMillis == null){ return "null" } - return timeMillis.toString() + return timeMillis!.toString() } export class myClass { diff --git a/uni_modules/uts-tests/utssdk/Math.uts b/uni_modules/uts-tests/utssdk/Math.uts index ff91cff3f188ac6349e20735c4b3935bf954a47d..ab2764cc5413f4e5faddd6f3ba2110f82ce1b889 100644 --- a/uni_modules/uts-tests/utssdk/Math.uts +++ b/uni_modules/uts-tests/utssdk/Math.uts @@ -112,8 +112,9 @@ export function testMath() : Result { // #TEST Math.acos console.log(Math.acos(-1)); // expected output: 3.141592653589793 - + // #ifdef APP-ANDROID console.log(Math.acos(NaN)); + // #endif // expected output: NaN console.log(Math.acos(0)); @@ -133,8 +134,9 @@ export function testMath() : Result { // #TEST Math.acosh console.log(Math.acosh(1)); // expected output: 0 - + // #ifdef APP-ANDROID console.log(Math.acosh(NaN)); + // #endif // expected output: NaN console.log(Math.acosh(2)); @@ -152,7 +154,9 @@ export function testMath() : Result { test('asin', () => { // #TEST Math.asin + // #ifdef APP-ANDROID console.log(Math.asin(NaN)); + // #endif // expected output: NaN console.log(Math.asin(-1)); @@ -177,7 +181,9 @@ export function testMath() : Result { test('asinh', () => { // #TEST Math.asinh + // #ifdef APP-ANDROID console.log(Math.asinh(NaN)); + // #endif // expected output: NaN console.log(Math.asinh(1)); @@ -202,7 +208,9 @@ export function testMath() : Result { test('atan', () => { // #TEST Math.atan + // #ifdef APP-ANDROID console.log(Math.atan(NaN)); + // #endif // expected output: NaN console.log(Math.atan(1)); @@ -231,7 +239,9 @@ export function testMath() : Result { test('atanh', () => { // #TEST Math.atanh + // #ifdef APP-ANDROID console.log(Math.atanh(NaN)); + // #endif // expected output: NaN console.log(Math.atanh(0)); @@ -253,8 +263,9 @@ export function testMath() : Result { // #TEST Math.ceil console.log(Math.ceil(0.95)); // expected output: 1 - + // #ifdef APP-ANDROID console.log(Math.ceil(NaN)); + // #endif // expected output: NaN console.log(Math.ceil(4)); @@ -383,7 +394,9 @@ export function testMath() : Result { test('fround', () => { // #TEST Math.fround + // #ifdef APP-ANDROID console.log(Math.fround(NaN)); + // #endif // expected output: NaN console.log(Math.fround(1.5)); @@ -626,23 +639,28 @@ export function testMath() : Result { test('round', () => { // #TEST Math.round + // #ifdef APP-ANDROID console.log(Math.round(NaN)); + // #endif // expected output: NaN console.log(Math.round(Math.E)); // expected output: 3 - + + // #ifdef APP-ANDROID console.log(Math.round(Number.MAX_VALUE)); // expected output: 1.7976931348623157e+308 - + console.log(Math.round(Number.MIN_VALUE)); // expected output: 0 - + console.log(Math.round(Number.NEGATIVE_INFINITY)); // expected output: -Infinity - + console.log(Math.round(Number.POSITIVE_INFINITY)); // expected output: Infinity + + // #endif console.log(Math.round(0.9)); // expected output: 1 @@ -661,10 +679,14 @@ export function testMath() : Result { // #END expect(Math.round(NaN)).toEqual(NaN); expect(Math.round(Math.E)).toEqual(3); + + // #ifdef APP-ANDROID expectNumber(Math.round(Number.MAX_VALUE)).toEqualDouble(1.7976931348623157e+308); expect(Math.round(Number.MIN_VALUE)).toEqual(0); expect(Math.round(Number.NEGATIVE_INFINITY)).toEqual(-Infinity); expect(Math.round(Number.POSITIVE_INFINITY)).toEqual(Infinity); + // #endif + expect(Math.round(0.9)).toEqual(1); expect(Math.round(5.95)).toEqual(6); expect(Math.round(-5.05)).toEqual(-5); 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 eff9e2687dcccb249ae540daf42671aa1db575b8..f97827f15dcb8e8e5c051f034eee4f49917e5e52 100644 --- a/uni_modules/uts-tests/utssdk/UTSJSONObject.uts +++ b/uni_modules/uts-tests/utssdk/UTSJSONObject.uts @@ -170,7 +170,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 //增加或更新指定键对应的值。