提交 9ec11da2 编写于 作者: 杜庆泉's avatar 杜庆泉

增加 UTS方法返回值是promise的语法测试

上级 3a4ff0fa
......@@ -53,6 +53,7 @@
<view>测试callback:{{ format(testUtsClassInstanceResult['callback']) }}</view>
<button @click="testUtsClassSetter">点击测试class 示例setter方法</button>
<view>测试setter:{{ format(testUtsClassSetterResult) }}</view>
<view>测试promise返回值:{{ format(testUtsReturnPromiseResult) }}</view>
<button @click="testAll">点击测试所有</button>
<!-- #ifdef APP-IOS -->
<button @click="testPromiseStaticMethod">点击测试promise静态方法</button>
......@@ -75,6 +76,7 @@
Test,
request,
SetterTest,
PromiseReturnDemo,
} from "../../uni_modules/uts-syntaxcase";
// #endif
// #ifdef APP-IOS
......@@ -144,6 +146,7 @@
callback: null
},
testUtsClassSetterResult: null,
testUtsReturnPromiseResult: null,
}
},
methods: {
......@@ -170,6 +173,7 @@
this.testUtsClassAsync();
this.testUtsClassInstance();
this.testUtsClassSetter();
this.testUtsReturnPromise();
},
testUtsSync() {
this.testUtsSyncResult = false;
......@@ -450,6 +454,19 @@
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()
......
......@@ -52,6 +52,7 @@
<view>测试callback:{{ format(testUtsClassInstanceResult.callback) }}</view>
<button @click="testUtsClassSetter">点击测试class 示例setter方法</button>
<view>测试setter:{{ format(testUtsClassSetterResult) }}</view>
<view>测试promise返回值:{{ format(testUtsReturnPromiseResult) }}</view>
<button @click="testAll">点击测试所有</button>
</view>
</template>
......@@ -66,6 +67,7 @@
Test,
request,
SetterTest,
PromiseReturnDemo,
} from "../../uni_modules/uts-syntaxcase";
// #endif
let test
......@@ -130,6 +132,7 @@
callback: null
},
testUtsClassSetterResult: null,
testUtsReturnPromiseResult: null,
}
},
methods: {
......@@ -150,6 +153,7 @@
this.testUtsClassAsync();
this.testUtsClassInstance();
this.testUtsClassSetter();
this.testUtsReturnPromise();
},
testUtsSync() {
this.testUtsSyncResult = false;
......@@ -423,6 +427,19 @@
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);
}
},
}
}
</script>
\ No newline at end of file
......@@ -469,3 +469,19 @@ export class myClass {
return name!
}
}
export class PromiseReturnDemo {
recordRet:number = 0
constructor() { }
test1() : Promise<boolean> {
this.recordRet += 1
console.log('test1',this.recordRet)
return Promise.resolve(true);
}
test2() : void {
this.recordRet += 1
console.log('test2',this.recordRet)
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册