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

新增class setter方法测试例

(cherry picked from commit 676064be)
上级 ddf58715
......@@ -51,6 +51,8 @@
<view>测试success:{{ format(testUtsClassInstanceResult['success']) }}</view>
<view>测试complete:{{ format(testUtsClassInstanceResult['complete']) }}</view>
<view>测试callback:{{ format(testUtsClassInstanceResult['callback']) }}</view>
<button @click="testUtsClassSetter">点击测试class 示例setter方法</button>
<view>测试setter:{{ format(testUtsClassSetterResult) }}</view>
<button @click="testAll">点击测试所有</button>
</view>
<view style="height: 20px;"></view>
......@@ -69,6 +71,7 @@
testAsyncParam3,
Test,
request,
SetterTest,
} from "../../uni_modules/uts-syntaxcase";
// #endif
let test:Test|null = null
......@@ -131,7 +134,8 @@
fail: null,
complete: null,
callback: null
}
},
testUtsClassSetterResult: null,
}
},
methods: {
......@@ -157,6 +161,7 @@
this.testUtsClassSyncWithCallback();
this.testUtsClassAsync();
this.testUtsClassInstance();
this.testUtsClassSetter();
},
testUtsSync() {
this.testUtsSyncResult = false;
......@@ -424,7 +429,19 @@
if (res === 'sync') {
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>
\ No newline at end of file
......@@ -50,6 +50,8 @@
<view>测试success:{{ format(testUtsClassInstanceResult.success) }}</view>
<view>测试complete:{{ format(testUtsClassInstanceResult.complete) }}</view>
<view>测试callback:{{ format(testUtsClassInstanceResult.callback) }}</view>
<button @click="testUtsClassSetter">点击测试class 示例setter方法</button>
<view>测试setter:{{ format(testUtsClassSetterResult) }}</view>
<button @click="testAll">点击测试所有</button>
</view>
</template>
......@@ -63,6 +65,7 @@
testAsyncParam3,
Test,
request,
SetterTest,
} from "../../uni_modules/uts-syntaxcase";
// #endif
let test
......@@ -125,7 +128,8 @@
fail: null,
complete: null,
callback: null
}
},
testUtsClassSetterResult: null,
}
},
methods: {
......@@ -145,6 +149,7 @@
this.testUtsClassSyncWithCallback();
this.testUtsClassAsync();
this.testUtsClassInstance();
this.testUtsClassSetter();
},
testUtsSync() {
this.testUtsSyncResult = false;
......@@ -405,7 +410,19 @@
if (res === 'sync') {
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>
\ No newline at end of file
......@@ -101,6 +101,7 @@ export async function testAsyncParam3(id : number, name : string, opts : AsyncOp
export class Test {
id : number;
name : string;
static type : string = "Test";
constructor(id : number, options : TestOptions) {
this.id = id;
......@@ -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 {
url : string
constructor(url : string) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册