1/* 2 * Copyright (c) 2025 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 */ 15import {BusinessError} from "@ohos.base"; 16import * as test from "opaque_test"; 17 18loadLibrary("ani_opaque"); 19 20class A { 21 constructor() {} 22} 23 24function test_is_string_with_object() { 25 const a = new A(); 26 const result = test.is_string(a); 27 assertEQ(result, false) 28} 29 30function test_is_string_with_string() { 31 const result = test.is_string("hello"); 32 assertEQ(result, true) 33} 34 35function test_get_object() { 36 const obj = test.get_object(); 37 assertEQ(obj, "BBB") 38} 39 40function test_is_object_with_union() { 41 const a: test.Person = {name: "aaa"}; 42 assertEQ(test.is_opaque(a), true); 43 assertEQ(test.is_opaque("bbb"), false); 44} 45 46function test_get_objects() { 47 const objs = test.get_objects(); 48 assertEQ(objs[0], "AAA"); 49 assertEQ(objs[1], undefined); 50} 51 52function main() { 53 console.log("##############start#############"); 54 const suite = new ArkTestsuite("Test Suite"); 55 const objs = test.get_objects(); 56 console.log(objs); 57 58 suite.addTest("test is_string with object", test_is_string_with_object); 59 suite.addTest("test is_string with string", test_is_string_with_string); 60 suite.addTest("test is_string with union", test_is_object_with_union); 61 suite.addTest("test get_object", test_get_object); 62 suite.addTest("test get_objects", test_get_objects); 63 64 exit(suite.run()); 65} 66