diff --git a/pages/SyntaxCase/index.uvue b/pages/SyntaxCase/index.uvue
index 8d16dba3931955677ebc26df98b09e4e1dfe91e8..8857a339149a6a092139c0916a9923bea3cda3ef 100644
--- a/pages/SyntaxCase/index.uvue
+++ b/pages/SyntaxCase/index.uvue
@@ -52,7 +52,8 @@
测试complete:{{ format(testUtsClassInstanceResult['complete']) }}
测试callback:{{ format(testUtsClassInstanceResult['callback']) }}
- 测试setter:{{ format(testUtsClassSetterResult) }}
+ 测试setter:{{ format(testUtsClassSetterResult) }}
+ 测试promise返回值:{{ format(testUtsReturnPromiseResult) }}
@@ -74,7 +75,8 @@
testAsyncParam3,
Test,
request,
- SetterTest,
+ SetterTest,
+ PromiseReturnDemo,
} from "../../uni_modules/uts-syntaxcase";
// #endif
// #ifdef APP-IOS
@@ -143,7 +145,8 @@
complete: null,
callback: null
},
- testUtsClassSetterResult: null,
+ testUtsClassSetterResult: null,
+ testUtsReturnPromiseResult: null,
}
},
methods: {
@@ -169,7 +172,8 @@
this.testUtsClassSyncWithCallback();
this.testUtsClassAsync();
this.testUtsClassInstance();
- this.testUtsClassSetter();
+ this.testUtsClassSetter();
+ this.testUtsReturnPromise();
},
testUtsSync() {
this.testUtsSyncResult = false;
@@ -450,6 +454,20 @@
console.error("testUtsClassSetter", e);
}
},
+
+ testUtsReturnPromise() {
+ this.testUtsReturnPromiseResult = false;
+ try {
+ let demo = new PromiseReturnDemo();
+ demo.test1();
+ demo.test2();
+ if (demo.recordRet == 2) {
+ this.testUtsReturnPromiseResult = true;
+ }
+ } catch (e) {
+ console.error("testUtsClassSetter", e);
+ }
+ },
// #ifdef APP-IOS
testPromiseStaticMethod() {
testPromiseStaticMethod()
diff --git a/pages/SyntaxCase/index.vue b/pages/SyntaxCase/index.vue
index 19404648542fe84742d75e31f5003a62832ab72b..f3aa5b083aa76647dba541500446cee715e96407 100644
--- a/pages/SyntaxCase/index.vue
+++ b/pages/SyntaxCase/index.vue
@@ -51,7 +51,8 @@
测试complete:{{ format(testUtsClassInstanceResult.complete) }}
测试callback:{{ format(testUtsClassInstanceResult.callback) }}
- 测试setter:{{ format(testUtsClassSetterResult) }}
+ 测试setter:{{ format(testUtsClassSetterResult) }}
+ 测试promise返回值:{{ format(testUtsReturnPromiseResult) }}
@@ -65,7 +66,8 @@
testAsyncParam3,
Test,
request,
- SetterTest,
+ SetterTest,
+ PromiseReturnDemo,
} from "../../uni_modules/uts-syntaxcase";
// #endif
let test
@@ -129,7 +131,8 @@
complete: null,
callback: null
},
- testUtsClassSetterResult: null,
+ testUtsClassSetterResult: null,
+ testUtsReturnPromiseResult: null,
}
},
methods: {
@@ -149,7 +152,8 @@
this.testUtsClassSyncWithCallback();
this.testUtsClassAsync();
this.testUtsClassInstance();
- this.testUtsClassSetter();
+ this.testUtsClassSetter();
+ this.testUtsReturnPromise();
},
testUtsSync() {
this.testUtsSyncResult = false;
@@ -422,6 +426,20 @@
} catch (e) {
console.error("testUtsClassSetter", e);
}
+
+ },
+ testUtsReturnPromise() {
+ this.testUtsReturnPromiseResult = false;
+ try {
+ let demo = new PromiseReturnDemo();
+ demo.test1();
+ demo.test2();
+ if (demo.recordRet == 2) {
+ this.testUtsReturnPromiseResult = true;
+ }
+ } catch (e) {
+ console.error("testUtsClassSetter", e);
+ }
},
}
}
diff --git a/uni_modules/uts-syntaxcase/utssdk/index.uts b/uni_modules/uts-syntaxcase/utssdk/index.uts
index a86c4b3883aab7af1c1266837e8f9046e3e52785..19342ab21a073a5067c78487d33ee605672dc1cd 100644
--- a/uni_modules/uts-syntaxcase/utssdk/index.uts
+++ b/uni_modules/uts-syntaxcase/utssdk/index.uts
@@ -468,4 +468,20 @@ export class myClass {
console.log(name);
return name!
}
-}
\ No newline at end of file
+}
+
+export class PromiseReturnDemo {
+
+ recordRet:number = 0
+
+ constructor() { }
+ test1() : Promise {
+ this.recordRet += 1
+ console.log('test1',this.recordRet)
+ return Promise.resolve(true);
+ }
+ test2() : void {
+ this.recordRet += 1
+ console.log('test2',this.recordRet)
+ }
+}
diff --git a/uni_modules/uts-tests/utssdk/JSON.uts b/uni_modules/uts-tests/utssdk/JSON.uts
index 3ff104a5b81c2a22a0fbe8918f7d8ad02f768126..6b0b468ebbd4ec919a50afe1f8d1a3cb2daf819b 100644
--- a/uni_modules/uts-tests/utssdk/JSON.uts
+++ b/uni_modules/uts-tests/utssdk/JSON.uts
@@ -80,18 +80,59 @@ class A6 implements IJSONStringify{
}
// #endif
+class A1 implements IJSONStringify{
+ toJSON():any|null{
+ let jsonRet = {
+ 'name': "zhangsan",
+ 'age': 12,
+ }
+ return jsonRet
+ }
+}
+
+class A2 implements IJSONStringify{
+ toJSON():any|null{
+ return 2
+ }
+}
+
+class A3 implements IJSONStringify{
+ toJSON():any|null{
+ return "json"
+ }
+}
+
+class A4 implements IJSONStringify{
+ toJSON():any|null{
+ return null
+ }
+}
+
+class A5 implements IJSONStringify{
+ toJSON():any|null{
+ return new A1()
+ }
+}
+
+class A6 implements IJSONStringify{
+ toJSON():any|null{
+ return new A5()
+ }
+}
+
+
export function testJSON() : Result {
return describe("JSON", () => {
test('custom-stringify', () => {
- // #ifdef APP-ANDROID
- expect(JSON.stringify(new A1()).length).toEqual(28)
+
+ expect(JSON.stringify(new A1())!.length).toEqual(28)
expect(JSON.stringify(new A2())).toEqual("2")
expect(JSON.stringify(new A3())).toEqual('"json"')
expect(JSON.stringify(new A4())).toEqual('null')
- expect(JSON.stringify(new A5()).length).toEqual(28)
- expect(JSON.stringify(new A6()).length).toEqual(28)
- // #endif
+ expect(JSON.stringify(new A5())!.length).toEqual(28)
+ expect(JSON.stringify(new A6())!.length).toEqual(28)
+
})
test('parse', () => {