Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
eb772373
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
eb772373
编写于
2月 28, 2023
作者:
O
openharmony_ci
提交者:
Gitee
2月 28, 2023
浏览文件
操作
浏览文件
下载
差异文件
!7761 【ACE子系统】修改napi 测试用例
Merge pull request !7761 from hekun/master
上级
1ff6903f
c8c1a11d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
1351 addition
and
1180 deletion
+1351
-1180
arkui/ace_napi_test/entry/src/main/cpp/napi/napi_test.cpp
arkui/ace_napi_test/entry/src/main/cpp/napi/napi_test.cpp
+458
-324
arkui/ace_napi_test/entry/src/main/ets/test/List.test.ets
arkui/ace_napi_test/entry/src/main/ets/test/List.test.ets
+0
-2
arkui/ace_napi_test/entry/src/main/ets/test/NapiEtsTest.ets
arkui/ace_napi_test/entry/src/main/ets/test/NapiEtsTest.ets
+0
-849
arkui/ace_napi_test/entry/src/main/ets/test/NativeApiStringTest.ets
...napi_test/entry/src/main/ets/test/NativeApiStringTest.ets
+893
-5
未找到文件。
arkui/ace_napi_test/entry/src/main/cpp/napi/napi_test.cpp
浏览文件 @
eb772373
...
...
@@ -25,8 +25,6 @@
static
bool
exceptionWasPending
=
false
;
static
napi_ref
test_reference
=
NULL
;
static
int
test_value
=
1
;
static
napi_deferred
deferred
=
NULL
;
static
void
add_returned_status
(
napi_env
env
,
const
char
*
key
,
...
...
@@ -86,7 +84,9 @@ static napi_value getLastErrorInfo(napi_env env, napi_callback_info info) {
"Last error info code should match last status"
);
NAPI_ASSERT
(
env
,
error_info
->
error_message
,
"Last error info message should not be null"
);
return
NULL
;
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
error_info
->
error_code
,
&
_value
));
return
_value
;
}
static
napi_value
cleanUpErrorInfo
(
napi_env
env
,
napi_callback_info
info
)
{
...
...
@@ -101,27 +101,75 @@ static napi_value cleanUpErrorInfo(napi_env env, napi_callback_info info) {
}
static
napi_value
throwExistingError
(
napi_env
env
,
napi_callback_info
info
)
{
napi_value
message
;
napi_value
error
;
NAPI_CALL
(
env
,
napi_create_string_utf8
(
env
,
"existing error"
,
NAPI_AUTO_LENGTH
,
&
message
));
NAPI_CALL
(
env
,
napi_create_error
(
env
,
NULL
,
message
,
&
error
));
napi_value
code
=
nullptr
;
napi_value
message
=
nullptr
;
napi_create_string_latin1
(
env
,
"600"
,
NAPI_AUTO_LENGTH
,
&
code
);
napi_create_string_latin1
(
env
,
"test error"
,
NAPI_AUTO_LENGTH
,
&
message
);
napi_value
error
=
nullptr
;
napi_create_error
(
env
,
code
,
message
,
&
error
);
NAPI_ASSERT
(
env
,
error
!=
nullptr
,
"error succes"
);
bool
isError
=
false
;
napi_is_error
(
env
,
error
,
&
isError
);
NAPI_ASSERT
(
env
,
isError
,
"error succes"
);
NAPI_CALL
(
env
,
napi_throw
(
env
,
error
));
return
NULL
;
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
throwError
(
napi_env
env
,
napi_callback_info
info
)
{
NAPI_CALL
(
env
,
napi_throw_error
(
env
,
NULL
,
"error"
));
return
NULL
;
napi_value
code
=
nullptr
;
napi_value
message
=
nullptr
;
napi_create_string_latin1
(
env
,
"600"
,
NAPI_AUTO_LENGTH
,
&
code
);
napi_create_string_latin1
(
env
,
"test error"
,
NAPI_AUTO_LENGTH
,
&
message
);
napi_value
error
=
nullptr
;
napi_create_error
(
env
,
code
,
message
,
&
error
);
NAPI_ASSERT
(
env
,
error
!=
nullptr
,
"error succes"
);
bool
isError
=
false
;
napi_is_error
(
env
,
error
,
&
isError
);
NAPI_ASSERT
(
env
,
isError
,
"error succes"
);
napi_throw_error
(
env
,
"500"
,
"Common error"
);
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
throwTypeError
(
napi_env
env
,
napi_callback_info
info
)
{
NAPI_CALL
(
env
,
napi_throw_type_error
(
env
,
NULL
,
"type error"
));
return
NULL
;
napi_value
code
=
nullptr
;
napi_value
message
=
nullptr
;
napi_create_string_latin1
(
env
,
"500"
,
NAPI_AUTO_LENGTH
,
&
code
);
napi_create_string_latin1
(
env
,
"type error1"
,
NAPI_AUTO_LENGTH
,
&
message
);
napi_value
error
=
nullptr
;
napi_create_type_error
(
env
,
code
,
message
,
&
error
);
NAPI_ASSERT
(
env
,
error
!=
nullptr
,
"error succes"
);
bool
isError
=
false
;
napi_is_error
(
env
,
error
,
&
isError
);
NAPI_ASSERT
(
env
,
isError
,
"error succes"
);
napi_throw_type_error
(
env
,
NULL
,
"type error1"
);
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
throwRangeError
(
napi_env
env
,
napi_callback_info
info
)
{
NAPI_CALL
(
env
,
napi_throw_range_error
(
env
,
NULL
,
"range error"
));
return
NULL
;
napi_value
code
=
nullptr
;
napi_value
message
=
nullptr
;
napi_create_string_latin1
(
env
,
"500"
,
NAPI_AUTO_LENGTH
,
&
code
);
napi_create_string_latin1
(
env
,
"range error"
,
NAPI_AUTO_LENGTH
,
&
message
);
napi_value
error
=
nullptr
;
napi_create_range_error
(
env
,
code
,
message
,
&
error
);
NAPI_ASSERT
(
env
,
error
!=
nullptr
,
"error succes"
);
bool
isError
=
false
;
napi_is_error
(
env
,
error
,
&
isError
);
NAPI_ASSERT
(
env
,
isError
,
"error succes"
);
napi_throw_range_error
(
env
,
NULL
,
"range error"
);
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
isError
(
napi_env
env
,
napi_callback_info
info
)
{
...
...
@@ -139,27 +187,48 @@ static napi_value isError(napi_env env, napi_callback_info info) {
}
static
napi_value
createError
(
napi_env
env
,
napi_callback_info
info
)
{
napi_value
result
;
napi_value
message
;
NAPI_CALL
(
env
,
napi_create_string_utf8
(
env
,
"error"
,
NAPI_AUTO_LENGTH
,
&
message
));
NAPI_CALL
(
env
,
napi_create_error
(
env
,
NULL
,
message
,
&
result
));
return
result
;
napi_value
code
=
nullptr
;
napi_value
message
=
nullptr
;
napi_create_string_latin1
(
env
,
"500"
,
NAPI_AUTO_LENGTH
,
&
code
);
napi_create_string_latin1
(
env
,
"common error"
,
NAPI_AUTO_LENGTH
,
&
message
);
napi_value
error
=
nullptr
;
napi_create_error
(
env
,
code
,
message
,
&
error
);
NAPI_ASSERT
(
env
,
error
!=
nullptr
,
"error succes"
);
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
createTypeError
(
napi_env
env
,
napi_callback_info
info
)
{
napi_value
result
;
napi_value
message
;
NAPI_CALL
(
env
,
napi_create_string_utf8
(
env
,
"type error"
,
NAPI_AUTO_LENGTH
,
&
message
));
NAPI_CALL
(
env
,
napi_create_type_error
(
env
,
NULL
,
message
,
&
result
));
return
result
;
napi_value
code
=
nullptr
;
napi_value
message
=
nullptr
;
napi_create_string_latin1
(
env
,
"500"
,
NAPI_AUTO_LENGTH
,
&
code
);
napi_create_string_latin1
(
env
,
"type error"
,
NAPI_AUTO_LENGTH
,
&
message
);
napi_value
error
=
nullptr
;
napi_create_type_error
(
env
,
code
,
message
,
&
error
);
NAPI_ASSERT
(
env
,
error
!=
nullptr
,
"error succes"
);
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
createRangeError
(
napi_env
env
,
napi_callback_info
info
)
{
napi_value
result
;
napi_value
message
;
NAPI_CALL
(
env
,
napi_create_string_utf8
(
env
,
"range error"
,
NAPI_AUTO_LENGTH
,
&
message
));
NAPI_CALL
(
env
,
napi_create_range_error
(
env
,
NULL
,
message
,
&
result
));
return
result
;
napi_value
code
=
nullptr
;
napi_value
message
=
nullptr
;
napi_create_string_latin1
(
env
,
"500"
,
NAPI_AUTO_LENGTH
,
&
code
);
napi_create_string_latin1
(
env
,
"range error"
,
NAPI_AUTO_LENGTH
,
&
message
);
napi_value
error
=
nullptr
;
napi_create_range_error
(
env
,
code
,
message
,
&
error
);
NAPI_ASSERT
(
env
,
error
!=
nullptr
,
"error succes"
);
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
getAndClearLastException
(
napi_env
env
,
napi_callback_info
info
)
{
...
...
@@ -177,22 +246,29 @@ static napi_value getAndClearLastException(napi_env env, napi_callback_info info
NAPI_CALL
(
env
,
napi_get_and_clear_last_exception
(
env
,
&
ex
));
return
ex
;
}
return
NULL
;
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
isExceptionPending
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
1
;
napi_value
args
[
1
];
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
args
,
NULL
,
NULL
));
napi_value
code
=
nullptr
;
napi_value
message
=
nullptr
;
napi_create_string_latin1
(
env
,
"500"
,
NAPI_AUTO_LENGTH
,
&
code
);
napi_create_string_latin1
(
env
,
"range error"
,
NAPI_AUTO_LENGTH
,
&
message
);
napi_value
error
=
nullptr
;
napi_create_range_error
(
env
,
code
,
message
,
&
error
);
napi_value
global
;
NAPI_CALL
(
env
,
napi_get_global
(
env
,
&
global
));
NAPI_ASSERT
(
env
,
error
!=
nullptr
,
"error succes"
);
napi_value
result
;
napi_call_function
(
env
,
global
,
args
[
0
],
0
,
0
,
&
result
);
napi_is_exception_pending
(
env
,
&
exceptionWasPending
);
NAPI_CALL
(
env
,
napi_is_exception_pending
(
env
,
&
exceptionWasPending
));
return
NULL
;
NAPI_ASSERT
(
env
,
exceptionWasPending
,
"error succes"
);
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
openAndCloseHandleScope
(
napi_env
env
,
napi_callback_info
info
)
{
...
...
@@ -218,24 +294,14 @@ static napi_value openAndCloseEscapableHandleScope(napi_env env, napi_callback_i
}
static
napi_value
createReference
(
napi_env
env
,
napi_callback_info
info
)
{
NAPI_ASSERT
(
env
,
test_reference
==
NULL
,
"The test allows only one reference at a time."
);
size_t
argc
=
2
;
napi_value
args
[
2
];
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
args
,
NULL
,
NULL
));
NAPI_ASSERT
(
env
,
argc
==
2
,
"Expected two arguments."
);
uint32_t
initial_refcount
;
NAPI_CALL
(
env
,
napi_get_value_uint32
(
env
,
args
[
1
],
&
initial_refcount
));
NAPI_CALL
(
env
,
napi_create_reference
(
env
,
args
[
0
],
initial_refcount
,
&
test_reference
));
NAPI_ASSERT
(
env
,
test_reference
!=
NULL
,
"A reference should have been created."
);
napi_value
result
=
nullptr
;
napi_ref
resultRef
=
nullptr
;
return
NULL
;
napi_create_object
(
env
,
&
result
);
NAPI_CALL
(
env
,
napi_create_reference
(
env
,
result
,
1
,
&
resultRef
));
napi_value
value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
value
));
return
value
;
}
static
napi_value
deleteReference
(
napi_env
env
,
napi_callback_info
info
)
{
...
...
@@ -260,37 +326,53 @@ static napi_value referenceRef(napi_env env, napi_callback_info info) {
napi_value
refValue
=
nullptr
;
napi_get_reference_value
(
env
,
resultRef
,
&
refValue
);
NAPI_ASSERT
(
env
,
refValue
!=
NULL
,
NAPI_ASSERT
(
env
,
refValue
!=
NULL
,
"A reference must have been created."
);
napi_delete_reference
(
env
,
resultRef
);
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
return
_value
;
}
static
napi_value
referenceUnref
(
napi_env
env
,
napi_callback_info
info
)
{
NAPI_ASSERT
(
env
,
test_reference
!=
NULL
,
"A reference must have been created."
)
;
napi_value
result
=
nullptr
;
napi_ref
resultRef
=
nullptr
;
uint32_t
refcount
;
NAPI_CALL
(
env
,
napi_reference_unref
(
env
,
test_reference
,
&
refcount
)
);
napi_create_object
(
env
,
&
result
)
;
napi_create_reference
(
env
,
result
,
1
,
&
resultRef
);
napi_value
result
;
NAPI_CALL
(
env
,
napi_create_uint32
(
env
,
refcount
,
&
result
));
return
result
;
uint32_t
resultRefCount
=
0
;
napi_reference_ref
(
env
,
resultRef
,
&
resultRefCount
);
NAPI_CALL
(
env
,
napi_reference_unref
(
env
,
resultRef
,
&
resultRefCount
));
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
getReferenceValue
(
napi_env
env
,
napi_callback_info
info
)
{
NAPI_ASSERT
(
env
,
test_reference
!=
NULL
,
napi_value
result
=
nullptr
;
napi_ref
resultRef
=
nullptr
;
napi_create_object
(
env
,
&
result
);
napi_create_reference
(
env
,
result
,
1
,
&
resultRef
);
uint32_t
resultRefCount
=
0
;
napi_reference_ref
(
env
,
resultRef
,
&
resultRefCount
);
napi_reference_unref
(
env
,
resultRef
,
&
resultRefCount
);
napi_value
refValue
=
nullptr
;
napi_get_reference_value
(
env
,
resultRef
,
&
refValue
);
NAPI_ASSERT
(
env
,
refValue
!=
NULL
,
"A reference must have been created."
);
napi_value
result
;
NAPI_CALL
(
env
,
napi_get_reference_value
(
env
,
test_reference
,
&
result
));
return
result
;
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
createArrayAndGetLength
(
napi_env
env
,
napi_callback_info
info
)
{
...
...
@@ -331,57 +413,61 @@ static napi_value getArrayWithLength(napi_env env, napi_callback_info info) {
napi_valuetype
valuetype0
;
NAPI_CALL
(
env
,
napi_typeof
(
env
,
args
[
0
],
&
valuetype0
));
NAPI_ASSERT
(
env
,
valuetype0
==
napi_
number
,
NAPI_ASSERT
(
env
,
valuetype0
==
napi_
object
,
"Wrong type of arguments. Expects an integer the first argument."
);
int32_t
array_length
;
NAPI_CALL
(
env
,
napi_get_
value_int32
(
env
,
args
[
0
],
&
array_length
));
u
int32_t
array_length
;
NAPI_CALL
(
env
,
napi_get_
array_length
(
env
,
args
[
0
],
&
array_length
));
napi_value
ret
;
NAPI_CALL
(
env
,
napi_create_array_with_length
(
env
,
array_length
,
&
ret
));
return
ret
;
}
static
void
finalizer
(
napi_env
env
,
void
*
data
,
void
*
hint
)
{
NAPI_CALL_RETURN_VOID
(
env
,
napi_throw_error
(
env
,
NULL
,
"Error during Finalize"
));
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
createExternal
(
napi_env
env
,
napi_callback_info
info
)
{
napi_value
external
;
NAPI_CALL
(
env
,
napi_create_external
(
env
,
NULL
,
finalizer
,
NULL
,
&
external
));
return
external
;
const
char
testStr
[]
=
"test"
;
napi_value
external
=
nullptr
;
napi_create_external
(
env
,
(
void
*
)
testStr
,
[](
napi_env
env
,
void
*
data
,
void
*
hint
)
{},
(
void
*
)
testStr
,
&
external
);
void
*
tempExternal
=
nullptr
;
NAPI_CALL
(
env
,
napi_get_value_external
(
env
,
external
,
&
tempExternal
));
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
createExternalArraybuffer
(
napi_env
env
,
napi_callback_info
info
)
{
static
void
*
data
=
NULL
;
napi_value
arraybuffer
;
NAPI_CALL
(
env
,
napi_create_external_arraybuffer
(
env
,
data
,
0
,
NULL
,
NULL
,
&
arraybuffer
));
return
arraybuffer
;
const
char
testStr
[]
=
"test"
;
napi_value
external
=
nullptr
;
size_t
arrayBufferSize
=
1024
;
napi_create_external_arraybuffer
(
env
,
(
void
*
)
testStr
,
arrayBufferSize
,
[](
napi_env
env
,
void
*
data
,
void
*
hint
)
{},
(
void
*
)
testStr
,
&
external
);
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
createObject
(
napi_env
env
,
napi_callback_info
info
)
{
napi_value
ret
;
NAPI_CALL
(
env
,
napi_create_object
(
env
,
&
ret
));
napi_value
num
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
987654321
,
&
num
));
NAPI_CALL
(
env
,
napi_set_named_property
(
env
,
ret
,
"test_number"
,
num
));
napi_value
str
;
const
char
*
str_val
=
"test string"
;
size_t
str_len
=
strlen
(
str_val
);
NAPI_CALL
(
env
,
napi_create_string_utf8
(
env
,
str_val
,
str_len
,
&
str
));
NAPI_CALL
(
env
,
napi_set_named_property
(
env
,
ret
,
"test_string"
,
str
));
napi_value
result
=
nullptr
;
NAPI_CALL
(
env
,
napi_create_object
(
env
,
&
result
));
NAPI_ASSERT
(
env
,
result
!=
nullptr
,
"napi_create_object"
);
return
ret
;
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
createSymbol
(
napi_env
env
,
napi_callback_info
info
)
{
...
...
@@ -415,72 +501,44 @@ static napi_value createSymbol(napi_env env, napi_callback_info info) {
}
static
napi_value
createTypeArray
(
napi_env
env
,
napi_callback_info
info
)
{
static
int8_t
externalData
[]
=
{
0
,
1
,
2
};
napi_value
output_buffer
;
NAPI_CALL
(
env
,
napi_create_external_arraybuffer
(
env
,
externalData
,
sizeof
(
externalData
),
NULL
,
// finalize_callback
NULL
,
// finalize_hint
&
output_buffer
));
napi_value
arrayBuffer
=
nullptr
;
void
*
arrayBufferPtr
=
nullptr
;
size_t
arrayBufferSize
=
1024
;
napi_create_arraybuffer
(
env
,
arrayBufferSize
,
&
arrayBufferPtr
,
&
arrayBuffer
);
napi_value
output_array
;
NAPI_CALL
(
env
,
napi_create_typedarray
(
env
,
napi_int8_array
,
sizeof
(
externalData
)
/
sizeof
(
int8_t
),
output_buffer
,
0
,
&
output_array
));
void
*
tmpArrayBufferPtr
=
nullptr
;
size_t
arrayBufferLength
=
0
;
napi_get_arraybuffer_info
(
env
,
arrayBuffer
,
&
tmpArrayBufferPtr
,
&
arrayBufferLength
);
NAPI_ASSERT
(
env
,
arrayBufferPtr
==
tmpArrayBufferPtr
,
"napi_get_arraybuffer_info success"
);
NAPI_ASSERT
(
env
,
arrayBufferSize
==
arrayBufferLength
,
"napi_create_arraybuffer success"
);
return
output_array
;
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
createDataView
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
3
;
napi_value
args
[
3
];
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
args
,
NULL
,
NULL
));
NAPI_ASSERT
(
env
,
argc
==
3
,
"Wrong number of arguments"
);
napi_valuetype
valuetype0
;
napi_value
arraybuffer
=
args
[
0
];
NAPI_CALL
(
env
,
napi_typeof
(
env
,
arraybuffer
,
&
valuetype0
));
NAPI_ASSERT
(
env
,
valuetype0
==
napi_object
,
"Wrong type of arguments. Expects a ArrayBuffer as the first "
"argument."
);
bool
is_arraybuffer
;
NAPI_CALL
(
env
,
napi_is_arraybuffer
(
env
,
arraybuffer
,
&
is_arraybuffer
));
NAPI_ASSERT
(
env
,
is_arraybuffer
,
"Wrong type of arguments. Expects a ArrayBuffer as the first "
"argument."
);
napi_valuetype
valuetype1
;
NAPI_CALL
(
env
,
napi_typeof
(
env
,
args
[
1
],
&
valuetype1
));
NAPI_ASSERT
(
env
,
valuetype1
==
napi_number
,
"Wrong type of arguments. Expects a number as second argument."
);
size_t
byte_offset
=
0
;
NAPI_CALL
(
env
,
napi_get_value_uint32
(
env
,
args
[
1
],
(
uint32_t
*
)(
&
byte_offset
)));
napi_valuetype
valuetype2
;
NAPI_CALL
(
env
,
napi_typeof
(
env
,
args
[
2
],
&
valuetype2
));
NAPI_ASSERT
(
env
,
valuetype2
==
napi_number
,
"Wrong type of arguments. Expects a number as third argument."
);
napi_value
arrayBuffer
=
nullptr
;
void
*
arrayBufferPtr
=
nullptr
;
size_t
arrayBufferSize
=
1024
;
napi_create_arraybuffer
(
env
,
arrayBufferSize
,
&
arrayBufferPtr
,
&
arrayBuffer
);
NAPI_ASSERT
(
env
,
arrayBufferPtr
!=
nullptr
,
"napi_create_arraybuffer success"
);
bool
isArrayBuffer
=
false
;
napi_is_arraybuffer
(
env
,
arrayBuffer
,
&
isArrayBuffer
);
NAPI_ASSERT
(
env
,
isArrayBuffer
,
" napi_is_arraybuffer success"
);
size_t
length
=
0
;
NAPI_CALL
(
env
,
napi_
get_value_uint32
(
env
,
args
[
2
],
(
uint32_t
*
)(
&
length
)
));
napi_value
result
=
nullptr
;
NAPI_CALL
(
env
,
napi_
create_dataview
(
env
,
arrayBufferSize
,
arrayBuffer
,
0
,
&
result
));
napi_value
output_dataview
;
NAPI_CALL
(
env
,
napi_create_dataview
(
env
,
length
,
arraybuffer
,
byte_offset
,
&
output_dataview
));
bool
isDataView
=
false
;
napi_is_dataview
(
env
,
result
,
&
isDataView
);
return
output_dataview
;
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
createAndGetInt32
(
napi_env
env
,
napi_callback_info
info
)
{
...
...
@@ -592,14 +650,20 @@ static napi_value createAndGetStringUtf8(napi_env env, napi_callback_info info)
}
static
napi_value
getPrototype
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
1
;
napi_value
args
[
1
];
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
args
,
NULL
,
NULL
));
napi_value
testWrapClass
=
nullptr
;
napi_define_class
(
env
,
"TestWrapClass"
,
NAPI_AUTO_LENGTH
,
[](
napi_env
env
,
napi_callback_info
info
)
->
napi_value
{
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
nullptr
,
nullptr
,
&
thisVar
,
nullptr
);
return
thisVar
;
},
nullptr
,
0
,
nullptr
,
&
testWrapClass
);
napi_value
result
;
NAPI_CALL
(
env
,
napi_get_prototype
(
env
,
args
[
0
],
&
result
));
napi_value
customClassPrototype
=
nullptr
;
NAPI_CALL
(
env
,
napi_get_prototype
(
env
,
testWrapClass
,
&
customClassPrototype
));
return
result
;
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
getDataViewInfo
(
napi_env
env
,
napi_callback_info
info
)
{
...
...
@@ -665,36 +729,43 @@ static napi_value getValueDouble(napi_env env, napi_callback_info info) {
}
static
napi_value
getValueExternal
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
1
;
napi_value
arg
;
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
&
arg
,
NULL
,
NULL
));
NAPI_ASSERT
(
env
,
argc
==
1
,
"Expected one argument."
);
napi_valuetype
argtype
;
NAPI_CALL
(
env
,
napi_typeof
(
env
,
arg
,
&
argtype
));
NAPI_ASSERT
(
env
,
argtype
==
napi_external
,
"Expected an external value."
);
const
char
testStr
[]
=
"test"
;
napi_value
external
=
nullptr
;
napi_create_external
(
env
,
(
void
*
)
testStr
,
[](
napi_env
env
,
void
*
data
,
void
*
hint
)
{},
(
void
*
)
testStr
,
&
external
);
void
*
tempExternal
=
nullptr
;
napi_get_value_external
(
env
,
external
,
&
tempExternal
);
void
*
data
;
NAPI_CALL
(
env
,
napi_get_value_external
(
env
,
arg
,
&
data
));
NAPI_ASSERT
(
env
,
tempExternal
,
"napi_get_value_external true"
);
NAPI_ASSERT
(
env
,
data
!=
NULL
&&
*
(
int
*
)
data
==
test_value
,
"An external data value of 1 was expected."
);
return
NULL
;
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
)
);
return
_value
;
}
static
napi_value
getNull
(
napi_env
env
,
napi_callback_info
info
)
{
napi_value
result
;
napi_value
result
=
nullptr
;
NAPI_CALL
(
env
,
napi_get_null
(
env
,
&
result
));
return
result
;
NAPI_ASSERT
(
env
,
result
!=
nullptr
,
"napi_get_null success"
);
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
getUndefined
(
napi_env
env
,
napi_callback_info
info
)
{
napi_value
result
;
napi_value
result
=
nullptr
;
NAPI_CALL
(
env
,
napi_get_undefined
(
env
,
&
result
));
return
result
;
NAPI_ASSERT
(
env
,
result
!=
nullptr
,
"napi_get_undefined success"
);
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
coerceToBool
(
napi_env
env
,
napi_callback_info
info
)
{
...
...
@@ -742,60 +813,42 @@ static napi_value coerceToString(napi_env env, napi_callback_info info) {
}
static
napi_value
instanceOf
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
2
;
napi_value
args
[
2
];
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
args
,
NULL
,
NULL
));
napi_value
customClass
=
nullptr
;
bool
instanceof
;
NAPI_CALL
(
env
,
napi_instanceof
(
env
,
args
[
0
],
args
[
1
],
&
instanceof
));
napi_define_class
(
env
,
"TestWrapClass"
,
NAPI_AUTO_LENGTH
,
[](
napi_env
env
,
napi_callback_info
info
)
->
napi_value
{
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
nullptr
,
nullptr
,
&
thisVar
,
nullptr
);
return
thisVar
;
},
nullptr
,
0
,
nullptr
,
&
customClass
);
napi_value
customClassPrototype
=
nullptr
;
napi_get_prototype
(
env
,
customClass
,
&
customClassPrototype
);
napi_value
customInstance
=
nullptr
;
NAPI_CALL
(
env
,
napi_new_instance
(
env
,
customClass
,
0
,
nullptr
,
&
customInstance
));
bool
isInstanceOf
=
false
;
NAPI_CALL
(
env
,
napi_instanceof
(
env
,
customInstance
,
customClass
,
&
isInstanceOf
));
NAPI_ASSERT
(
env
,
isInstanceOf
,
"isInstanceOf success"
);
napi_value
result
;
NAPI_CALL
(
env
,
napi_get_boolean
(
env
,
i
nstanceo
f
,
&
result
));
NAPI_CALL
(
env
,
napi_get_boolean
(
env
,
i
sInstanceO
f
,
&
result
));
return
result
;
}
static
napi_value
isArray
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
2
;
napi_value
args
[
2
];
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
args
,
NULL
,
NULL
));
NAPI_ASSERT
(
env
,
argc
>=
2
,
"Wrong number of arguments"
);
napi_valuetype
valuetype0
;
NAPI_CALL
(
env
,
napi_typeof
(
env
,
args
[
0
],
&
valuetype0
));
NAPI_ASSERT
(
env
,
valuetype0
==
napi_object
,
"Wrong type of arguments. Expects an array as first argument."
);
napi_valuetype
valuetype1
;
NAPI_CALL
(
env
,
napi_typeof
(
env
,
args
[
1
],
&
valuetype1
));
NAPI_ASSERT
(
env
,
valuetype1
==
napi_number
,
"Wrong type of arguments. Expects an integer as second argument."
);
napi_value
array
=
args
[
0
];
int32_t
index
;
NAPI_CALL
(
env
,
napi_get_value_int32
(
env
,
args
[
1
],
&
index
));
NAPI_ASSERT
(
env
,
index
>=
0
,
"Invalid index. Expects a positive integer."
);
napi_value
array
=
nullptr
;
napi_create_array
(
env
,
&
array
);
NAPI_ASSERT
(
env
,
array
!=
nullptr
,
"napi_get_undefined success"
);
bool
isArray
=
false
;
napi_is_array
(
env
,
array
,
&
isArray
);
NAPI_ASSERT
(
env
,
isArray
,
"napi_is_arrayd success"
);
bool
isarray
;
NAPI_CALL
(
env
,
napi_is_array
(
env
,
array
,
&
isarray
));
if
(
!
isarray
)
{
return
NULL
;
}
uint32_t
length
;
NAPI_CALL
(
env
,
napi_get_array_length
(
env
,
array
,
&
length
));
NAPI_ASSERT
(
env
,
((
uint32_t
)
index
<
length
),
"Index out of bounds!"
);
napi_value
ret
;
NAPI_CALL
(
env
,
napi_get_element
(
env
,
array
,
index
,
&
ret
));
return
ret
;
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
isDate
(
napi_env
env
,
napi_callback_info
info
)
{
...
...
@@ -811,35 +864,45 @@ static napi_value isDate(napi_env env, napi_callback_info info) {
}
static
napi_value
strictEquals
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
2
;
napi_value
args
[
2
];
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
args
,
NULL
,
NULL
));
const
char
*
testStringStr
=
"test"
;
napi_value
testString
=
nullptr
;
napi_create_string_utf8
(
env
,
testStringStr
,
strlen
(
testStringStr
),
&
testString
);
bool
isStrictEquals
=
false
;
napi_strict_equals
(
env
,
testString
,
testString
,
&
isStrictEquals
);
NAPI_ASSERT
(
env
,
isStrictEquals
,
"napi_strict_equals success"
);
napi_value
testObject
=
nullptr
;
napi_create_object
(
env
,
&
testObject
);
isStrictEquals
=
false
;
napi_strict_equals
(
env
,
testObject
,
testObject
,
&
isStrictEquals
);
NAPI_ASSERT
(
env
,
isStrictEquals
,
"napi_strict_equals success"
);
bool
bool_result
;
napi_value
result
;
NAPI_CALL
(
env
,
napi_strict_equals
(
env
,
args
[
0
],
args
[
1
],
&
bool_result
));
NAPI_CALL
(
env
,
napi_get_boolean
(
env
,
bool_result
,
&
result
));
return
result
;
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
getPropertyNames
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
1
;
napi_value
args
[
1
];
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
args
,
NULL
,
NULL
));
napi_value
result
=
nullptr
;
NAPI_CALL
(
env
,
napi_create_object
(
env
,
&
result
));
NAPI_ASSERT
(
env
,
argc
>=
1
,
"Wrong number of argument
s"
);
NAPI_ASSERT
(
env
,
result
!=
nullptr
,
"napi_create_object succes
s"
);
napi_valuetype
value_type0
;
NAPI_CALL
(
env
,
napi_typeof
(
env
,
args
[
0
],
&
value_type0
))
;
const
char
testStr
[]
=
"1234567"
;
napi_value
strAttribute
=
nullptr
;
NAPI_
ASSERT
(
env
,
value_type0
==
napi_object
,
"Wrong type of arguments. Expects an object as first argument.
"
);
NAPI_
CALL
(
env
,
napi_create_string_utf8
(
env
,
testStr
,
strlen
(
testStr
),
&
strAttribute
));
NAPI_ASSERT
(
env
,
strAttribute
!=
nullptr
,
"napi_create_string_utf8 success
"
);
napi_value
output
;
NAPI_CALL
(
env
,
napi_get_property_names
(
env
,
args
[
0
],
&
output
));
NAPI_CALL
(
env
,
napi_set_named_property
(
env
,
result
,
"strAttribute"
,
strAttribute
));
return
output
;
napi_value
retStrAttribute
=
nullptr
;
NAPI_CALL
(
env
,
napi_get_named_property
(
env
,
result
,
"strAttribute"
,
&
retStrAttribute
));
NAPI_ASSERT
(
env
,
retStrAttribute
!=
nullptr
,
"napi_get_named_property success"
);
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
setProperty
(
napi_env
env
,
...
...
@@ -913,31 +976,53 @@ static napi_value getProperty(napi_env env,
}
static
napi_value
hasProperty
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
2
;
napi_value
args
[
2
];
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
args
,
NULL
,
NULL
));
napi_value
result
=
nullptr
;
NAPI_CALL
(
env
,
napi_create_object
(
env
,
&
result
));
NAPI_ASSERT
(
env
,
argc
>=
2
,
"Wrong number of arguments"
);
const
char
testStr
[]
=
"1234567"
;
napi_value
strAttribute
=
nullptr
;
NAPI_CALL
(
env
,
napi_create_string_utf8
(
env
,
testStr
,
strlen
(
testStr
),
&
strAttribute
));
NAPI_CALL
(
env
,
napi_set_named_property
(
env
,
result
,
"strAttribute"
,
strAttribute
));
napi_value
type
valuetype0
;
NAPI_CALL
(
env
,
napi_
typeof
(
env
,
args
[
0
],
&
valuetype0
));
napi_value
retStrAttribute
=
nullptr
;
NAPI_CALL
(
env
,
napi_
get_named_property
(
env
,
result
,
"strAttribute"
,
&
retStrAttribute
));
NAPI_ASSERT
(
env
,
valuetype0
==
napi_object
,
"Wrong type of arguments. Expects an object as first argument."
);
int32_t
testNumber
=
12345
;
napi_value
numberAttribute
=
nullptr
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
testNumber
,
&
numberAttribute
));
NAPI_CALL
(
env
,
napi_set_named_property
(
env
,
result
,
"numberAttribute"
,
numberAttribute
));
napi_valuetype
valuetype1
;
NAPI_CALL
(
env
,
napi_typeof
(
env
,
args
[
1
],
&
valuetype1
));
napi_value
propNames
=
nullptr
;
NAPI_CALL
(
env
,
napi_get_property_names
(
env
,
result
,
&
propNames
));
NAPI_ASSERT
(
env
,
propNames
!=
nullptr
,
"napi_get_property_names success"
);
NAPI_ASSERT
(
env
,
valuetype1
==
napi_string
||
valuetype1
==
napi_symbol
,
"Wrong type of arguments. Expects a string or symbol as second."
);
bool
isArray
=
false
;
NAPI_CALL
(
env
,
napi_is_array
(
env
,
propNames
,
&
isArray
));
NAPI_ASSERT
(
env
,
isArray
,
"napi_is_array success"
);
bool
has_property
;
NAPI_CALL
(
env
,
napi_
has_property
(
env
,
args
[
0
],
args
[
1
],
&
has_property
));
uint32_t
arrayLength
=
0
;
NAPI_CALL
(
env
,
napi_
get_array_length
(
env
,
propNames
,
&
arrayLength
));
napi_value
ret
;
NAPI_CALL
(
env
,
napi_get_boolean
(
env
,
has_property
,
&
ret
));
for
(
uint32_t
i
=
0
;
i
<
arrayLength
;
i
++
)
{
bool
hasElement
=
false
;
NAPI_CALL
(
env
,
napi_has_element
(
env
,
propNames
,
i
,
&
hasElement
));
return
ret
;
napi_value
propName
=
nullptr
;
NAPI_CALL
(
env
,
napi_get_element
(
env
,
propNames
,
i
,
&
propName
));
NAPI_ASSERT
(
env
,
propName
!=
nullptr
,
"napi_get_element success"
);
bool
hasProperty
=
false
;
napi_has_property
(
env
,
result
,
propName
,
&
hasProperty
);
NAPI_ASSERT
(
env
,
hasProperty
,
"napi_get_element success"
);
napi_value
propValue
=
nullptr
;
napi_get_property
(
env
,
result
,
propName
,
&
propValue
);
NAPI_ASSERT
(
env
,
propValue
!=
nullptr
,
"napi_get_property success"
);
}
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
deleteProperty
(
napi_env
env
,
napi_callback_info
info
)
{
...
...
@@ -1218,41 +1303,90 @@ static napi_value getNewTarget(napi_env env, napi_callback_info info) {
NAPI_CALL
(
env
,
napi_strict_equals
(
env
,
newTargetArg
,
undefined
,
&
result
));
NAPI_ASSERT
(
env
,
!
result
,
"new.target !== undefined"
);
return
thisArg
;
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
wrap
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
1
;
napi_value
arg
;
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
&
arg
,
NULL
,
NULL
));
napi_value
testClass
=
nullptr
;
napi_define_class
(
env
,
"TestClass"
,
NAPI_AUTO_LENGTH
,
[](
napi_env
env
,
napi_callback_info
info
)
->
napi_value
{
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
nullptr
,
nullptr
,
&
thisVar
,
nullptr
);
NAPI_CALL
(
env
,
napi_wrap
(
env
,
arg
,
&
test_value
,
NULL
,
NULL
,
NULL
));
return
NULL
;
return
thisVar
;
},
nullptr
,
0
,
nullptr
,
&
testClass
);
napi_value
instanceValue
=
nullptr
;
napi_new_instance
(
env
,
testClass
,
0
,
nullptr
,
&
instanceValue
);
const
char
*
testStr
=
"test"
;
napi_wrap
(
env
,
instanceValue
,
(
void
*
)
testStr
,
[](
napi_env
env
,
void
*
data
,
void
*
hint
)
{},
nullptr
,
nullptr
);
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
unwrap
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
1
;
napi_value
arg
;
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
&
arg
,
NULL
,
NULL
));
napi_value
testClass
=
nullptr
;
napi_define_class
(
env
,
"TestClass"
,
NAPI_AUTO_LENGTH
,
[](
napi_env
env
,
napi_callback_info
info
)
->
napi_value
{
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
nullptr
,
nullptr
,
&
thisVar
,
nullptr
);
void
*
data
;
NAPI_CALL
(
env
,
napi_unwrap
(
env
,
arg
,
&
data
));
return
thisVar
;
},
nullptr
,
0
,
nullptr
,
&
testClass
);
bool
is_expected
=
(
data
!=
NULL
&&
*
(
int
*
)
data
==
3
);
napi_value
result
;
NAPI_CALL
(
env
,
napi_get_boolean
(
env
,
is_expected
,
&
result
));
return
result
;
napi_value
instanceValue
=
nullptr
;
napi_new_instance
(
env
,
testClass
,
0
,
nullptr
,
&
instanceValue
);
const
char
*
testStr
=
"test"
;
napi_wrap
(
env
,
instanceValue
,
(
void
*
)
testStr
,
[](
napi_env
env
,
void
*
data
,
void
*
hint
)
{},
nullptr
,
nullptr
);
const
char
*
tmpTestStr
=
nullptr
;
NAPI_CALL
(
env
,
napi_unwrap
(
env
,
instanceValue
,
(
void
**
)
&
tmpTestStr
));
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
removeWrap
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
1
;
napi_value
wrapped
;
void
*
data
;
napi_value
testClass
=
nullptr
;
napi_define_class
(
env
,
"TestClass"
,
NAPI_AUTO_LENGTH
,
[](
napi_env
env
,
napi_callback_info
info
)
->
napi_value
{
napi_value
thisVar
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
nullptr
,
nullptr
,
&
thisVar
,
nullptr
);
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
&
wrapped
,
NULL
,
NULL
));
NAPI_CALL
(
env
,
napi_remove_wrap
(
env
,
wrapped
,
&
data
));
return
thisVar
;
},
nullptr
,
0
,
nullptr
,
&
testClass
);
return
NULL
;
napi_value
instanceValue
=
nullptr
;
napi_new_instance
(
env
,
testClass
,
0
,
nullptr
,
&
instanceValue
);
const
char
*
testStr
=
"test"
;
napi_wrap
(
env
,
instanceValue
,
(
void
*
)
testStr
,
[](
napi_env
env
,
void
*
data
,
void
*
hint
)
{},
nullptr
,
nullptr
);
const
char
*
tmpTestStr
=
nullptr
;
NAPI_CALL
(
env
,
napi_unwrap
(
env
,
instanceValue
,
(
void
**
)
&
tmpTestStr
));
const
char
*
tmpTestStr1
=
nullptr
;
napi_remove_wrap
(
env
,
instanceValue
,
(
void
**
)
&
tmpTestStr1
);
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
getVersion
(
napi_env
env
,
napi_callback_info
info
)
{
...
...
@@ -1264,46 +1398,46 @@ static napi_value getVersion(napi_env env, napi_callback_info info) {
}
static
napi_value
createPromise
(
napi_env
env
,
napi_callback_info
info
)
{
napi_value
promise
;
// We do not overwrite an existing deferred.
if
(
deferred
!=
NULL
)
{
return
NULL
;
}
NAPI_CALL
(
env
,
napi_create_promise
(
env
,
&
deferred
,
&
promise
));
return
promise
;
napi_deferred
deferred
=
nullptr
;
napi_value
promise
=
nullptr
;
napi_create_promise
(
env
,
&
deferred
,
&
promise
);
NAPI_ASSERT
(
env
,
deferred
!=
nullptr
,
"create promise success"
);
NAPI_ASSERT
(
env
,
promise
!=
nullptr
,
"create promise success"
);
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
resolveAndRejectDeferred
(
napi_env
env
,
napi_callback_info
info
)
{
napi_value
argv
[
2
];
size_t
argc
=
2
;
bool
resolution
;
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
NULL
,
NULL
));
NAPI_CALL
(
env
,
napi_get_value_bool
(
env
,
argv
[
1
],
&
resolution
));
if
(
resolution
)
{
NAPI_CALL
(
env
,
napi_resolve_deferred
(
env
,
deferred
,
argv
[
0
]));
}
else
{
NAPI_CALL
(
env
,
napi_reject_deferred
(
env
,
deferred
,
argv
[
0
]));
}
napi_deferred
deferred
=
nullptr
;
napi_value
promise
=
nullptr
;
NAPI_CALL
(
env
,
napi_create_promise
(
env
,
&
deferred
,
&
promise
));
deferred
=
NULL
;
bool
isPromise
=
false
;
napi_is_promise
(
env
,
promise
,
&
isPromise
);
return
NULL
;
napi_value
undefined
=
nullptr
;
napi_get_undefined
(
env
,
&
undefined
);
NAPI_CALL
(
env
,
napi_resolve_deferred
(
env
,
deferred
,
undefined
));
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
isPromise
(
napi_env
env
,
napi_callback_info
info
)
{
napi_
value
promise
,
result
;
size_t
argc
=
1
;
bool
is_promise
;
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
&
promise
,
NULL
,
NULL
))
;
NAPI_CALL
(
env
,
napi_is_promise
(
env
,
promise
,
&
is
_p
romise
));
NAPI_
CALL
(
env
,
napi_get_boolean
(
env
,
is_promise
,
&
result
)
);
napi_
deferred
deferred
=
nullptr
;
napi_value
promise
=
nullptr
;
NAPI_CALL
(
env
,
napi_create_promise
(
env
,
&
deferred
,
&
promise
))
;
bool
isPromise
=
false
;
NAPI_CALL
(
env
,
napi_is_promise
(
env
,
promise
,
&
is
P
romise
));
NAPI_
ASSERT
(
env
,
isPromise
,
"napi_is_promise success"
);
return
result
;
napi_value
_value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
0
,
&
_value
));
return
_value
;
}
static
napi_value
runScript
(
napi_env
env
,
napi_callback_info
info
)
{
...
...
arkui/ace_napi_test/entry/src/main/ets/test/List.test.ets
浏览文件 @
eb772373
...
...
@@ -13,9 +13,7 @@
* limitations under the License.
*/
import napiStringTest from './NativeApiStringTest';
import aceNapiEtsTest from './NapiEtsTest'
export default function testsuite() {
napiStringTest()
aceNapiEtsTest()
}
\ No newline at end of file
arkui/ace_napi_test/entry/src/main/ets/test/NapiEtsTest.ets
已删除
100644 → 0
浏览文件 @
1ff6903f
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import napitest from 'libnapitest.so'
export default function aceNapiEtsTest() {
describe('aceNapiEtsTest', function () {
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0100
* @tc.name aceNapiTest001
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest001', 0, async function (done) {
console.info('aceNapiTest001 START');
napitest.add_returned_status()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0110
* @tc.name aceNapiTest002
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest002', 0, async function (done) {
console.info('aceNapiTest002 START');
napitest.add_last_status()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0120
* @tc.name aceNapiTest003
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest003', 0, async function (done) {
console.info('aceNapiTest003 START');
napitest.getLastErrorInfo()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0130
* @tc.name aceNapiTest004
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest004', 0, async function (done) {
console.info('aceNapiTest004 START');
napitest.cleanUpErrorInfo()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0140
* @tc.name aceNapiTest005
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest005', 0, async function (done) {
console.info('aceNapiTest005 START');
napitest.throwExistingError()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0150
* @tc.name aceNapiTest006
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest006', 0, async function (done) {
console.info('aceNapiTest006 START');
napitest.throwError()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0160
* @tc.name aceNapiTest007
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest007', 0, async function (done) {
console.info('aceNapiTest007 START');
napitest.throwTypeError()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0170
* @tc.name aceNapiTest008
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest008', 0, async function (done) {
console.info('aceNapiTest008 START');
napitest.throwRangeError()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0180
* @tc.name aceNapiTest009
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest009', 0, async function (done) {
console.info('aceNapiTest009 START');
napitest.isError()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0190
* @tc.name aceNapiTest010
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest010', 0, async function (done) {
console.info('aceNapiTest010 START');
napitest.createError()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0200
* @tc.name aceNapiTest011
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest011', 0, async function (done) {
console.info('aceNapiTest011 START');
napitest.createTypeError()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0210
* @tc.name aceNapiTest012
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest012', 0, async function (done) {
console.info('aceNapiTest012 START');
napitest.createRangeError()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0220
* @tc.name aceNapiTest013
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest013', 0, async function (done) {
console.info('aceNapiTest013 START');
napitest.getAndClearLastException()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0230
* @tc.name aceNapiTest014
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest014', 0, async function (done) {
console.info('aceNapiTest014 START');
napitest.isExceptionPending()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0240
* @tc.name aceNapiTest015
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest015', 0, async function (done) {
console.info('aceNapiTest015 START');
napitest.openAndCloseHandleScope()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0250
* @tc.name aceNapiTest016
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest016', 0, async function (done) {
console.info('aceNapiTest016 START');
napitest.openAndCloseEscapableHandleScope()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0260
* @tc.name aceNapiTest017
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest017', 0, async function (done) {
console.info('aceNapiTest017 START');
napitest.createReference()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0270
* @tc.name aceNapiTest018
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest018', 0, async function (done) {
console.info('aceNapiTest018 START');
napitest.deleteReference()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0280
* @tc.name aceNapiTest019
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest019', 0, async function (done) {
console.info('aceNapiTest019 START');
napitest.referenceRef()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0290
* @tc.name aceNapiTest020
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest020', 0, async function (done) {
console.info('aceNapiTest020 START');
napitest.referenceUnref()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0300
* @tc.name aceNapiTest021
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest021', 0, async function (done) {
console.info('aceNapiTest021 START');
napitest.getReferenceValue()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0310
* @tc.name aceNapiTest022
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest022', 0, async function (done) {
console.info('aceNapiTest022 START');
napitest.createArrayAndGetLength()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0320
* @tc.name aceNapiTest023
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest023', 0, async function (done) {
console.info('aceNapiTest023 START');
napitest.getArrayWithLength()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0330
* @tc.name aceNapiTest024
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest024', 0, async function (done) {
console.info('aceNapiTest024 START');
napitest.finalizer()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0340
* @tc.name aceNapiTest025
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest025', 0, async function (done) {
console.info('aceNapiTest025 START');
napitest.createExternal()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0350
* @tc.name aceNapiTest026
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest026', 0, async function (done) {
console.info('aceNapiTest026 START');
napitest.createExternalArraybuffer()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0360
* @tc.name aceNapiTest027
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest027', 0, async function (done) {
console.info('aceNapiTest027 START');
napitest.createObject()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0370
* @tc.name aceNapiTest028
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest028', 0, async function (done) {
console.info('aceNapiTest028 START');
napitest.createSymbol()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0380
* @tc.name aceNapiTest029
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest029', 0, async function (done) {
console.info('aceNapiTest029 START');
napitest.createTypeArray()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0390
* @tc.name aceNapiTest030
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest030', 0, async function (done) {
console.info('aceNapiTest030 START');
napitest.createDataView()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0400
* @tc.name aceNapiTest031
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest031', 0, async function (done) {
console.info('aceNapiTest031 START');
napitest.createAndGetInt32()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0410
* @tc.name aceNapiTest032
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest032', 0, async function (done) {
console.info('aceNapiTest032 START');
napitest.createAndGetUInt32()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0420
* @tc.name aceNapiTest033
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest033', 0, async function (done) {
console.info('aceNapiTest033 START');
napitest.createAndGetInt64()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0430
* @tc.name aceNapiTest034
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest034', 0, async function (done) {
console.info('aceNapiTest034 START');
napitest.createDouble()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0440
* @tc.name aceNapiTest035
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest035', 0, async function (done) {
console.info('aceNapiTest035 START');
napitest.createAndGetStringLatin1()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0450
* @tc.name aceNapiTest036
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest036', 0, async function (done) {
console.info('aceNapiTest036 START');
napitest.createAndGetStringUtf8()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0460
* @tc.name aceNapiTest037
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest037', 0, async function (done) {
console.info('aceNapiTest037 START');
napitest.getPrototype()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0470
* @tc.name aceNapiTest038
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest038', 0, async function (done) {
console.info('aceNapiTest038 START');
napitest.getTypedArrayInfo()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0480
* @tc.name aceNapiTest039
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest039', 0, async function (done) {
console.info('aceNapiTest039 START');
napitest.getDataViewInfo()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0490
* @tc.name aceNapiTest040
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest040', 0, async function (done) {
console.info('aceNapiTest040 START');
napitest.getValueBool()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0500
* @tc.name aceNapiTest041
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest041', 0, async function (done) {
console.info('aceNapiTest041 START');
napitest.getValueDouble()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0510
* @tc.name aceNapiTest042
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest042', 0, async function (done) {
console.info('aceNapiTest042 START');
napitest.getValueExternal()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0520
* @tc.name aceNapiTest043
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest043', 0, async function (done) {
console.info('aceNapiTest043 START');
napitest.getNull()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0530
* @tc.name aceNapiTest044
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest044', 0, async function (done) {
console.info('aceNapiTest044 START');
napitest.getUndefined()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0540
* @tc.name aceNapiTest045
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest045', 0, async function (done) {
console.info('aceNapiTest045 START');
napitest.coerceToBool()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0550
* @tc.name aceNapiTest046
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest046', 0, async function (done) {
console.info('aceNapiTest046 START');
napitest.coerceToNumber()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0560
* @tc.name aceNapiTest047
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest047', 0, async function (done) {
console.info('aceNapiTest047 START');
napitest.coerceToObject()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0570
* @tc.name aceNapiTest048
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest048', 0, async function (done) {
console.info('aceNapiTest048 START');
napitest.coerceToString()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0580
* @tc.name aceNapiTest049
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest049', 0, async function (done) {
console.info('aceNapiTest049 START');
napitest.instanceOf()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0590
* @tc.name aceNapiTest050
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest050', 0, async function (done) {
console.info('aceNapiTest050 START');
napitest.isArray()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0600
* @tc.name aceNapiTest051
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest051', 0, async function (done) {
console.info('aceNapiTest051 START');
napitest.isDate()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0610
* @tc.name aceNapiTest052
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest052', 0, async function (done) {
console.info('aceNapiTest052 START');
napitest.strictEquals()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0620
* @tc.name aceNapiTest053
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest053', 0, async function (done) {
console.info('aceNapiTest053 START');
napitest.getPropertyNames()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0630
* @tc.name aceNapiTest054
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest054', 0, async function (done) {
console.info('aceNapiTest054 START');
napitest.setProperty()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0640
* @tc.name aceNapiTest055
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest055', 0, async function (done) {
console.info('aceNapiTest055 START');
napitest.getProperty()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0650
* @tc.name aceNapiTest056
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest056', 0, async function (done) {
console.info('aceNapiTest056 START');
napitest.hasProperty()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0660
* @tc.name aceNapiTest057
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest057', 0, async function (done) {
console.info('aceNapiTest057 START');
napitest.deleteProperty()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0670
* @tc.name aceNapiTest058
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest058', 0, async function (done) {
console.info('aceNapiTest058 START');
napitest.hasOwnProperty()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0680
* @tc.name aceNapiTest059
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest059', 0, async function (done) {
console.info('aceNapiTest059 START');
napitest.setNamedProperty()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0690
* @tc.name aceNapiTest060
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest060', 0, async function (done) {
console.info('aceNapiTest060 START');
napitest.getNamedProperty()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0700
* @tc.name aceNapiTest061
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest061', 0, async function (done) {
console.info('aceNapiTest061 START');
napitest.hasNamedProperty()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0710
* @tc.name aceNapiTest062
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest062', 0, async function (done) {
console.info('aceNapiTest062 START');
napitest.setElement()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0720
* @tc.name aceNapiTest063
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest063', 0, async function (done) {
console.info('aceNapiTest063 START');
napitest.getElement()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0730
* @tc.name aceNapiTest064
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest064', 0, async function (done) {
console.info('aceNapiTest064 START');
napitest.hasElement()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0740
* @tc.name aceNapiTest065
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest065', 0, async function (done) {
console.info('aceNapiTest065 START');
napitest.deleteElement()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0750
* @tc.name aceNapiTest066
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest066', 0, async function (done) {
console.info('aceNapiTest066 START');
napitest.defineProperties()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0760
* @tc.name aceNapiTest067
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest067', 0, async function (done) {
console.info('aceNapiTest067 START');
napitest.getNewTarget()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0770
* @tc.name aceNapiTest068
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest068', 0, async function (done) {
console.info('aceNapiTest068 START');
napitest.wrap()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0780
* @tc.name aceNapiTest069
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest069', 0, async function (done) {
console.info('aceNapiTest069 START');
napitest.unwrap()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0790
* @tc.name aceNapiTest070
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest070', 0, async function (done) {
console.info('aceNapiTest070 START');
napitest.removeWrap()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0800
* @tc.name aceNapiTest071
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest071', 0, async function (done) {
console.info('aceNapiTest071 START');
napitest.getVersion()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0810
* @tc.name aceNapiTest072
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest072', 0, async function (done) {
console.info('aceNapiTest072 START');
napitest.createPromise()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0820
* @tc.name aceNapiTest073
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest073', 0, async function (done) {
console.info('aceNapiTest073 START');
napitest.resolveAndRejectDeferred()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0830
* @tc.name aceNapiTest074
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest074', 0, async function (done) {
console.info('aceNapiTest074 START');
napitest.isPromise()
done();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0840
* @tc.name aceNapiTest075
* @tc.desc aceNapiEtsTest
*/
it('aceNapiTest075', 0, async function (done) {
console.info('aceNapiTest075 START');
napitest.runScript()
done();
});
})
}
\ No newline at end of file
arkui/ace_napi_test/entry/src/main/ets/test/NativeApiStringTest.ets
浏览文件 @
eb772373
// @ts-nocheck
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
...
...
@@ -28,7 +27,7 @@ export default function nativeApiStringJsunit() {
async
function
sleep
(
time
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
resolve
()
resolve
(
"ok"
)
},
time
)
})
.
then
(()
=>
{
console
.
info
(
`sleep ${time} over...`
)
...
...
@@ -275,7 +274,7 @@ export default function nativeApiStringJsunit() {
console
.
info
(
'aceNapiTest013 START'
);
let
value
=
napitest
.
getAndClearLastException
();
console
.
info
(
'aceNapiTest013 testString result is: '
+
JSON
.
stringify
(
value
)
+
"--"
+
value
);
expect
(
value
==
undefined
)
.
assertTrue
();
expect
(
value
==
0
)
.
assertTrue
();
done
();
});
...
...
@@ -314,7 +313,7 @@ export default function nativeApiStringJsunit() {
console
.
info
(
'aceNapiTest033 START'
);
let
value
=
napitest
.
createAndGetInt64
(
6
);
console
.
info
(
'aceNapiTest033 testString result is: '
+
value
+
"---"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
6
)
expect
(
value
)
.
assertEqual
(
6
)
;
done
();
});
...
...
@@ -329,9 +328,898 @@ export default function nativeApiStringJsunit() {
let
dView
=
new
DataView
(
buffer
)
.
setInt16
(
0
,
256
,
true
);
let
value
=
napitest
.
getDataViewInfo
(
dView
);
console
.
info
(
'napigetDataView039 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
)
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0120
* @tc.name aceNapiTest003
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest003'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest003 START'
);
let
value
=
napitest
.
getLastErrorInfo
();
console
.
info
(
'aceNapiTest003 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
6
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0130
* @tc.name aceNapiTest004
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest004'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest004 START'
);
let
value
=
napitest
.
cleanUpErrorInfo
();
console
.
info
(
'aceNapiTest004 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertTrue
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0140
* @tc.name aceNapiTest005
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest005'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest005 START'
);
try
{
let
value
=
napitest
.
throwExistingError
();
console
.
info
(
'aceNapiTest005 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
}
catch
(
err
)
{
console
.
info
(
'aceNapiTest005 testString result is err: '
+
err
+
"--"
+
JSON
.
stringify
(
err
));
let
er
=
JSON
.
stringify
(
err
)
expect
(
er
)
.
assertEqual
(
'{"code":"600"}'
);
done
();
}
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0150
* @tc.name aceNapiTest006
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest006'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest006 START'
);
try
{
let
value
=
napitest
.
throwError
();
console
.
info
(
'aceNapiTest006 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
}
catch
(
err
)
{
console
.
info
(
'aceNapiTest006 testString result is err: '
+
err
+
"--"
+
JSON
.
stringify
(
err
));
let
er
=
JSON
.
stringify
(
err
)
expect
(
er
)
.
assertEqual
(
'{"code":"500"}'
);
done
();
}
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0160
* @tc.name aceNapiTest007
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest007'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest007 START'
);
try
{
let
value
=
napitest
.
throwTypeError
();
console
.
info
(
'aceNapiTest007 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
}
catch
(
err
)
{
console
.
info
(
'aceNapiTest007 testString result is err: '
+
err
+
"--"
+
JSON
.
stringify
(
err
));
expect
(
err
instanceof
TypeError
)
.
assertTrue
();
done
();
}
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0170
* @tc.name aceNapiTest008
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest008'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest008 START'
);
try
{
let
value
=
napitest
.
throwRangeError
();
console
.
info
(
'aceNapiTest008 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
}
catch
(
err
)
{
console
.
info
(
'aceNapiTest008 testString result is err: '
+
err
+
"--"
+
JSON
.
stringify
(
err
));
expect
(
err
instanceof
RangeError
)
.
assertTrue
();
done
();
}
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0180
* @tc.name aceNapiTest009
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest009'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest009 START'
);
let
value
=
napitest
.
isError
(
false
);
console
.
info
(
'aceNapiTest009 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertFalse
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0190
* @tc.name aceNapiTest010
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest010'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest010 START'
);
let
value
=
napitest
.
createError
();
console
.
info
(
'aceNapiTest010 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0200
* @tc.name aceNapiTest011
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest011'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest011 START'
);
let
value
=
napitest
.
createTypeError
();
console
.
info
(
'aceNapiTest011 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0210
* @tc.name aceNapiTest012
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest012'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest012 START'
);
let
value
=
napitest
.
createRangeError
();
console
.
info
(
'aceNapiTest012 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0230
* @tc.name aceNapiTest014
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest014'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest014 START'
);
let
value
=
napitest
.
isExceptionPending
();
console
.
info
(
'aceNapiTest014 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0240
* @tc.name aceNapiTest015
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest015'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest015 START'
);
let
value
=
napitest
.
openAndCloseHandleScope
();
console
.
info
(
'aceNapiTest015 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
==
undefined
)
.
assertTrue
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0260
* @tc.name aceNapiTest017
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest017'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest017 START'
);
let
value
=
napitest
.
createReference
();
console
.
info
(
'aceNapiTest017 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0290
* @tc.name aceNapiTest020
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest020'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest020 START'
);
let
value
=
napitest
.
referenceUnref
();
console
.
info
(
'aceNapiTest020 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0300
* @tc.name aceNapiTest021
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest021'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest021 START'
);
let
value
=
napitest
.
getReferenceValue
();
console
.
info
(
'aceNapiTest021 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0310
* @tc.name aceNapiTest022
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest022'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest022 START'
);
var
array
=
[
1
,
2
];
let
value
=
napitest
.
createArrayAndGetLength
(
array
);
console
.
info
(
'aceNapiTest022 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
let
obj
=
JSON
.
stringify
(
value
);
expect
(
obj
)
.
assertEqual
(
'[1,2]'
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0320
* @tc.name aceNapiTest023
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest023'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest023 START'
);
let
value
=
napitest
.
getArrayWithLength
([
1
,
2
]);
console
.
info
(
'aceNapiTest023 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0340
* @tc.name aceNapiTest025
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest025'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest025 START'
);
let
value
=
napitest
.
createExternal
();
console
.
info
(
'aceNapiTest025 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0350
* @tc.name aceNapiTest026
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest026'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest026 START'
);
let
value
=
napitest
.
createExternalArraybuffer
();
console
.
info
(
'aceNapiTest026 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0360
* @tc.name aceNapiTest027
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest027'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest027 START'
);
let
value
=
napitest
.
createObject
();
console
.
info
(
'aceNapiTest027 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0370
* @tc.name aceNapiTest028
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest028'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest028 START'
);
let
value
=
napitest
.
createSymbol
(
"teststr"
);
console
.
info
(
'aceNapiTest028 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0380
* @tc.name aceNapiTest029
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest029'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest029 START'
);
let
value
=
napitest
.
createTypeArray
();
console
.
info
(
'aceNapiTest029 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0390
* @tc.name aceNapiTest030
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest030'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest030 START'
);
let
value
=
napitest
.
createDataView
();
console
.
info
(
'aceNapiTest030 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0400
* @tc.name aceNapiTest031
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest031'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest031 START'
);
let
value
=
napitest
.
createAndGetInt32
(
32
);
console
.
info
(
'aceNapiTest031 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
32
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0410
* @tc.name aceNapiTest032
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest032'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest032 START'
);
let
value
=
napitest
.
createAndGetUInt32
(
12
);
console
.
info
(
'aceNapiTest032 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
12
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0420
* @tc.name aceNapiTest033
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest033'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest033 START'
);
let
value
=
napitest
.
createAndGetInt64
(
23
);
console
.
info
(
'aceNapiTest033 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
23
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0430
* @tc.name aceNapiTest034
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest034'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest034 START'
);
let
value
=
napitest
.
createDouble
(
24.67
);
console
.
info
(
'aceNapiTest034 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
24.67
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0440
* @tc.name aceNapiTest035
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest035'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest035 START'
);
let
value
=
napitest
.
createAndGetStringLatin1
(
"tst"
);
console
.
info
(
'aceNapiTest035 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
"tst"
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0450
* @tc.name aceNapiTest036
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest036'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest036 START'
);
let
value
=
napitest
.
createAndGetStringUtf8
(
'he'
);
console
.
info
(
'aceNapiTest036 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
'he'
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0460
* @tc.name aceNapiTest037
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest037'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest037 START'
);
let
value
=
napitest
.
getPrototype
();
console
.
info
(
'aceNapiTest037 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0490
* @tc.name aceNapiTest040
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest040'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest040 START'
);
let
value
=
napitest
.
getValueBool
(
false
);
console
.
info
(
'aceNapiTest040 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertFalse
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0500
* @tc.name aceNapiTest041
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest041'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest041 START'
);
let
value
=
napitest
.
getValueDouble
(
25.0
);
console
.
info
(
'aceNapiTest041 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
25
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0510
* @tc.name aceNapiTest042
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest042'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest042 START'
);
let
value
=
napitest
.
getValueExternal
();
console
.
info
(
'aceNapiTest042 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0520
* @tc.name aceNapiTest043
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest043'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest043 START'
);
let
value
=
napitest
.
getNull
();
console
.
info
(
'aceNapiTest043 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0530
* @tc.name aceNapiTest044
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest044'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest044 START'
);
let
value
=
napitest
.
getUndefined
();
console
.
info
(
'aceNapiTest044 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0540
* @tc.name aceNapiTest045
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest045'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest045 START'
);
let
value
=
napitest
.
coerceToBool
(
false
);
console
.
info
(
'aceNapiTest045 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertFalse
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0550
* @tc.name aceNapiTest046
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest046'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest046 START'
);
let
value
=
napitest
.
coerceToNumber
(
12
);
console
.
info
(
'aceNapiTest046 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
12
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0560
* @tc.name aceNapiTest047
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest047'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest047 START'
);
let
value
=
napitest
.
coerceToObject
([
2
,
3
]);
console
.
info
(
'aceNapiTest047 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
let
obj
=
JSON
.
stringify
(
value
);
expect
(
obj
)
.
assertEqual
(
'[2,3]'
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0570
* @tc.name aceNapiTest048
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest048'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest048 START'
);
let
value
=
napitest
.
coerceToString
(
"he"
);
console
.
info
(
'aceNapiTest048 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
'he'
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0580
* @tc.name aceNapiTest049
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest049'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest049 START'
);
let
value
=
napitest
.
instanceOf
();
console
.
info
(
'aceNapiTest049 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertTrue
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0590
* @tc.name aceNapiTest050
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest050'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest050 START'
);
let
value
=
napitest
.
isArray
();
console
.
info
(
'aceNapiTest050 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/* @tc.number SUB_ACE_BASIC_ETS_NAPI_0600
* @tc.name aceNapiTest051
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest051'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest051 START'
);
let
value
=
napitest
.
isDate
(
"2023-12-15"
);
console
.
info
(
'aceNapiTest051 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertFalse
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0610
* @tc.name aceNapiTest052
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest052'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest052 START'
);
let
value
=
napitest
.
strictEquals
();
console
.
info
(
'aceNapiTest052 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0620
* @tc.name aceNapiTest053
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest053'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest053 START'
);
let
value
=
napitest
.
getPropertyNames
();
console
.
info
(
'aceNapiTest053 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0630
* @tc.name aceNapiTest054
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest054'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest054 START'
);
let
value
=
napitest
.
setProperty
();
console
.
info
(
'aceNapiTest054 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
instanceof
Object
)
.
assertTrue
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0640
* @tc.name aceNapiTest055
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest055'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest055 START'
);
let
value
=
napitest
.
getProperty
();
console
.
info
(
'aceNapiTest055 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
instanceof
Object
)
.
assertTrue
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0650
* @tc.name aceNapiTest056
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest056'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest056 START'
);
let
value
=
napitest
.
hasProperty
();
console
.
info
(
'aceNapiTest056 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0660
* @tc.name aceNapiTest057
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest057'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest057 START'
);
let
value
=
napitest
.
deleteProperty
([
1
,
2
],
"hhe"
);
console
.
info
(
'aceNapiTest057 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertTrue
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0670
* @tc.name aceNapiTest058
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest058'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest058 START'
);
let
value
=
napitest
.
hasOwnProperty
([
1
,
2
],
"hhe"
);
console
.
info
(
'aceNapiTest058 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertFalse
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0680
* @tc.name aceNapiTest059
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest059'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest059 START'
);
let
value
=
napitest
.
setNamedProperty
([
1
,
2
],
"e"
,
false
);
console
.
info
(
'aceNapiTest059 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertTrue
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0690
* @tc.name aceNapiTest060
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest060'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest060 START'
);
let
obj
=
{
foo
:
"bar"
,
age
:
42
,
baz
:
{
myProp
:
12
},
};
let
value
=
napitest
.
getNamedProperty
(
obj
,
"foo"
);
console
.
info
(
'aceNapiTest060 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
'bar'
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0700
* @tc.name aceNapiTest061
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest061'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest061 START'
);
let
obj
=
{
foo
:
"bar"
,
age
:
42
,
baz
:
{
myProp
:
12
},
};
let
value
=
napitest
.
hasNamedProperty
(
obj
,
"foo"
);
console
.
info
(
'aceNapiTest061 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertTrue
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0710
* @tc.name aceNapiTest062
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest062'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest062 START'
);
let
value
=
napitest
.
setElement
();
console
.
info
(
'aceNapiTest062 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
instanceof
Object
)
.
assertTrue
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0720
* @tc.name aceNapiTest063
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest063'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest063 START'
);
let
value
=
napitest
.
getElement
();
console
.
info
(
'aceNapiTest063 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
let
fi
=
value
.
envIsNull
;
expect
(
value
instanceof
Object
)
.
assertTrue
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0730
* @tc.name aceNapiTest064
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest064'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest064 START'
);
let
value
=
napitest
.
hasElement
();
console
.
info
(
'aceNapiTest064 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
instanceof
Object
)
.
assertTrue
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0740
* @tc.name aceNapiTest065
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest065'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest065 START'
);
let
value
=
napitest
.
deleteElement
();
console
.
info
(
'aceNapiTest065 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
instanceof
Object
)
.
assertTrue
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0750
* @tc.name aceNapiTest066
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest066'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest066 START'
);
let
value
=
napitest
.
defineProperties
();
console
.
info
(
'aceNapiTest066 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
instanceof
Object
)
.
assertTrue
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0770
* @tc.name aceNapiTest068
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest068'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest068 START'
);
let
value
=
napitest
.
wrap
();
console
.
info
(
'aceNapiTest068 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0780
* @tc.name aceNapiTest069
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest069'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest069 START'
);
let
value
=
napitest
.
unwrap
();
console
.
info
(
'aceNapiTest069 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0790
* @tc.name aceNapiTest070
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest070'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest070 START'
);
let
value
=
napitest
.
removeWrap
();
console
.
info
(
'aceNapiTest070 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0800
* @tc.name aceNapiTest071
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest071'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest071 START'
);
let
value
=
napitest
.
getVersion
();
console
.
info
(
'aceNapiTest071 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
2147483647
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0810
* @tc.name aceNapiTest072
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest072'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest072 START'
);
let
value
=
napitest
.
createPromise
();
console
.
info
(
'aceNapiTest072 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0820
* @tc.name aceNapiTest073
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest073'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest073 START'
);
let
value
=
napitest
.
resolveAndRejectDeferred
();
console
.
info
(
'aceNapiTest073 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0830
* @tc.name aceNapiTest074
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest074'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest074 START'
);
let
value
=
napitest
.
isPromise
();
console
.
info
(
'aceNapiTest074 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0840
* @tc.name aceNapiTest075
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest075'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest075 START'
);
let
value
=
napitest
.
runScript
(
"25"
);
console
.
info
(
'aceNapiTest075 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
==
undefined
)
.
assertTrue
();
done
();
});
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录