• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 #ifdef TEST_WRAPPER_OBJECT
16 #include "jsvmtest.h"
17 
TEST(NumberObject)18 TEST(NumberObject)
19 {
20     JSVM_Value result = jsvm::Run("new Number(42)");
21     bool isNumberObject = false;
22     JSVMTEST_CALL(OH_JSVM_IsNumberObject(env, result, &isNumberObject));
23     CHECK(isNumberObject);
24 }
25 
TEST(BooleanObject)26 TEST(BooleanObject)
27 {
28     JSVM_Value result = jsvm::Run("new Boolean(true)");
29     bool isBooleanObject = false;
30     JSVMTEST_CALL(OH_JSVM_IsBooleanObject(env, result, &isBooleanObject));
31     CHECK(isBooleanObject);
32 }
33 
TEST(BigIntObject)34 TEST(BigIntObject)
35 {
36     JSVM_Value result = jsvm::Run("new Object(42n)");
37     bool isBigIntObject = false;
38     JSVMTEST_CALL(OH_JSVM_IsBigIntObject(env, result, &isBigIntObject));
39     CHECK(isBigIntObject);
40 }
41 
TEST(StringObject)42 TEST(StringObject)
43 {
44     JSVM_Value result = jsvm::Run("new String(\"test\")");
45     bool isStringObject = false;
46     JSVMTEST_CALL(OH_JSVM_IsStringObject(env, result, &isStringObject));
47     CHECK(isStringObject);
48 }
49 
TEST(SymbolObject)50 TEST(SymbolObject)
51 {
52     JSVM_Value result = jsvm::Run("Object(Symbol('foo'))");
53     bool isSymbolObject = false;
54     JSVMTEST_CALL(OH_JSVM_IsSymbolObject(env, result, &isSymbolObject));
55     CHECK(isSymbolObject);
56 }
57 #endif
58 
59