提交 48a4d1f4 编写于 作者: lizhongyi_'s avatar lizhongyi_

新增class setter方法测试例

(cherry picked from commit 676064be)
上级 ddf58715
...@@ -51,6 +51,8 @@ ...@@ -51,6 +51,8 @@
<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>
...@@ -69,6 +71,7 @@ ...@@ -69,6 +71,7 @@
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: {
...@@ -157,6 +161,7 @@ ...@@ -157,6 +161,7 @@
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
...@@ -50,6 +50,8 @@ ...@@ -50,6 +50,8 @@
<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>
...@@ -63,6 +65,7 @@ ...@@ -63,6 +65,7 @@
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: {
...@@ -145,6 +149,7 @@ ...@@ -145,6 +149,7 @@
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
...@@ -101,6 +101,7 @@ export async function testAsyncParam3(id : number, name : string, opts : AsyncOp ...@@ -101,6 +101,7 @@ 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;
...@@ -123,6 +124,21 @@ export class Test { ...@@ -123,6 +124,21 @@ export class Test {
} }
} }
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 {
url : string url : string
constructor(url : string) { constructor(url : string) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册