Signed-off-by: zhangmenghan <zhangmenghan@kaihong.com>
This commit is contained in:
zhangmenghan 2024-10-28 17:33:10 +08:00
parent 9cbaf73440
commit 90e11e98a5
2 changed files with 5 additions and 2 deletions

View File

@ -33,6 +33,8 @@ struct napiwrap {
@State testcont: string = ' // 测试 N-API napi_wrap \n'
+ ' const result = testNapi.testNapiWrap(); \n'
+ ' console.log(result); \n'
+ ' const ret = result.Tyof(1024); \n'
+ ' console.log(ret);\n'
controller: TextAreaController = new TextAreaController()
@ -84,8 +86,9 @@ struct napiwrap {
.id('napi_wrap')
.onClick(() => {
let node: testNapi.testNapiWrap = new testNapi.testNapiWrap();
console.log(`Node.Tyof('1024') is ${node.Tyof(1024)}`);
let ret = node.Tyof(1024);
this.testcont = this.testcont.replace('log(result)', 'log(## type of node is ' + typeof (node) + ' ##)');
this.testcont = this.testcont.replace('log(ret)', 'log(## ' + ret + ' ##)');
})
}
.width('100%')

View File

@ -45,11 +45,11 @@ export default function abilityTestJsObjectWrap() {
let ret: testNapi.testNapiWrap = new testNapi.testNapiWrap();
hilog.info(0x0000, 'testTag', `type of napi_wrap() is = ${typeof (ret)}`);
expect(typeof (ret)).assertEqual('object');
let ret1 = ret.Tyof('');
hilog.info(0x0000, 'testTag', `type of ret.Tyof('') is = ${typeof (ret1)}`);
expect(ret1).assertEqual('string');
let ret2 = ret.Tyof(false);
hilog.info(0x0000, 'testTag', `type of ret.Tyof(false) is = ${typeof (ret2)}`);
expect(ret2).assertEqual('boolean');