提交 676064be 编写于 作者: lizhongyi_'s avatar lizhongyi_

新增class setter方法测试例

上级 d66859f6
...@@ -50,7 +50,9 @@ ...@@ -50,7 +50,9 @@
<view>测试return:{{ format(testUtsClassInstanceResult['return']) }}</view> <view>测试return:{{ format(testUtsClassInstanceResult['return']) }}</view>
<view>测试success:{{ format(testUtsClassInstanceResult['success']) }}</view> <view>测试success:{{ format(testUtsClassInstanceResult['success']) }}</view>
<view>测试complete:{{ format(testUtsClassInstanceResult['complete']) }}</view> <view>测试complete:{{ format(testUtsClassInstanceResult['complete']) }}</view>
<view>测试callback:{{ format(testUtsClassInstanceResult['callback']) }}</view> <view>测试callback:{{ format(testUtsClassInstanceResult['callback']) }}</view>
<button @click="testUtsClassSetter">点击测试class 示例setter方法</button>
<view>测试setter:{{ format(testUtsClassSetterResult) }}</view>
<button @click="testAll">点击测试所有</button> <button @click="testAll">点击测试所有</button>
</view> </view>
<view style="height: 20px;"></view> <view style="height: 20px;"></view>
...@@ -68,7 +70,8 @@ ...@@ -68,7 +70,8 @@
SyncOptions, SyncOptions,
testAsyncParam3, testAsyncParam3,
Test, Test,
request, request,
SetterTest,
} from "../../uni_modules/uts-syntaxcase"; } from "../../uni_modules/uts-syntaxcase";
// #endif // #endif
let test:Test|null = null let test:Test|null = null
...@@ -131,7 +134,8 @@ ...@@ -131,7 +134,8 @@
fail: null, fail: null,
complete: null, complete: null,
callback: null callback: null
} },
testUtsClassSetterResult: null,
} }
}, },
methods: { methods: {
...@@ -156,7 +160,8 @@ ...@@ -156,7 +160,8 @@
this.testUtsClassProp(); this.testUtsClassProp();
this.testUtsClassSyncWithCallback(); this.testUtsClassSyncWithCallback();
this.testUtsClassAsync(); this.testUtsClassAsync();
this.testUtsClassInstance(); this.testUtsClassInstance();
this.testUtsClassSetter();
}, },
testUtsSync() { testUtsSync() {
this.testUtsSyncResult = false; this.testUtsSyncResult = false;
...@@ -424,7 +429,19 @@ ...@@ -424,7 +429,19 @@
if (res === 'sync') { if (res === 'sync') {
this.testUtsClassInstanceResult['return'] = true; this.testUtsClassInstanceResult['return'] = true;
} }
} },
testUtsClassSetter() {
this.testUtsClassSetterResult = false;
try {
let obj = new SetterTest()
obj.nickName = "Tom";
if (obj.nickName == "Tom") {
this.testUtsClassSetterResult = true;
}
} catch (e) {
console.error("testUtsClassSetter", e);
}
},
} }
} }
</script> </script>
\ No newline at end of file
...@@ -49,7 +49,9 @@ ...@@ -49,7 +49,9 @@
<view>测试return:{{ format(testUtsClassInstanceResult.return) }}</view> <view>测试return:{{ format(testUtsClassInstanceResult.return) }}</view>
<view>测试success:{{ format(testUtsClassInstanceResult.success) }}</view> <view>测试success:{{ format(testUtsClassInstanceResult.success) }}</view>
<view>测试complete:{{ format(testUtsClassInstanceResult.complete) }}</view> <view>测试complete:{{ format(testUtsClassInstanceResult.complete) }}</view>
<view>测试callback:{{ format(testUtsClassInstanceResult.callback) }}</view> <view>测试callback:{{ format(testUtsClassInstanceResult.callback) }}</view>
<button @click="testUtsClassSetter">点击测试class 示例setter方法</button>
<view>测试setter:{{ format(testUtsClassSetterResult) }}</view>
<button @click="testAll">点击测试所有</button> <button @click="testAll">点击测试所有</button>
</view> </view>
</template> </template>
...@@ -62,7 +64,8 @@ ...@@ -62,7 +64,8 @@
testAsync, testAsync,
testAsyncParam3, testAsyncParam3,
Test, Test,
request, request,
SetterTest,
} from "../../uni_modules/uts-syntaxcase"; } from "../../uni_modules/uts-syntaxcase";
// #endif // #endif
let test let test
...@@ -125,7 +128,8 @@ ...@@ -125,7 +128,8 @@
fail: null, fail: null,
complete: null, complete: null,
callback: null callback: null
} },
testUtsClassSetterResult: null,
} }
}, },
methods: { methods: {
...@@ -144,7 +148,8 @@ ...@@ -144,7 +148,8 @@
this.testUtsClassProp(); this.testUtsClassProp();
this.testUtsClassSyncWithCallback(); this.testUtsClassSyncWithCallback();
this.testUtsClassAsync(); this.testUtsClassAsync();
this.testUtsClassInstance(); this.testUtsClassInstance();
this.testUtsClassSetter();
}, },
testUtsSync() { testUtsSync() {
this.testUtsSyncResult = false; this.testUtsSyncResult = false;
...@@ -405,7 +410,19 @@ ...@@ -405,7 +410,19 @@
if (res === 'sync') { if (res === 'sync') {
this.testUtsClassInstanceResult.return = true; this.testUtsClassInstanceResult.return = true;
} }
} },
testUtsClassSetter() {
this.testUtsClassSetterResult = false;
try {
let obj = new SetterTest()
obj.nickName = "Tom";
if (obj.nickName == "Tom") {
this.testUtsClassSetterResult = true;
}
} catch (e) {
console.error("testUtsClassSetter", e);
}
},
} }
} }
</script> </script>
\ No newline at end of file
...@@ -100,7 +100,8 @@ export async function testAsyncParam3(id : number, name : string, opts : AsyncOp ...@@ -100,7 +100,8 @@ export async function testAsyncParam3(id : number, name : string, opts : AsyncOp
export class Test { export class Test {
id : number; id : number;
name : string; name : string;
static type : string = "Test"; static type : string = "Test";
constructor(id : number, options : TestOptions) { constructor(id : number, options : TestOptions) {
this.id = id; this.id = id;
...@@ -121,6 +122,21 @@ export class Test { ...@@ -121,6 +122,21 @@ export class Test {
const res = await testAsync(opts); const res = await testAsync(opts);
return res; 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;
}
} }
class RequestTaskImpl implements RequestTask { class RequestTaskImpl implements RequestTask {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册