1 /*
2  * Copyright (c) 2020 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "jstest_module.h"
16 #if ((JSFWK_TEST == 1) && (OHOS_ACELITE_PRODUCT_WATCH == 1))
17 #include <stdlib.h>
18 #include "ace_mem_base.h"
19 #include "test_fwk.h"
20 namespace OHOS {
21 namespace ACELite {
Init()22 void JSTestModule::Init()
23 {
24     const char * const funcName = "jstestPrint";
25     CreateNamedFunction(funcName, JSTestPrint);
26 }
27 
JSTestPrint(const jerry_value_t func,const jerry_value_t context,const jerry_value_t * args,const jerry_length_t argsNum)28 jerry_value_t JSTestModule::JSTestPrint(const jerry_value_t func,
29                                         const jerry_value_t context,
30                                         const jerry_value_t *args,
31                                         const jerry_length_t argsNum)
32 {
33     if (argsNum == 0) {
34         return UNDEFINED;
35     }
36 
37     char *msg = MallocStringOf(args[0]);
38 
39     if (msg != nullptr) {
40         LiteTestPrint(msg);
41         ace_free(msg);
42         msg = nullptr;
43     }
44 
45     return UNDEFINED;
46 }
47 } // namespace ACELite
48 } // namespace OHOS
49 #endif
50