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 */ 15 16'use static' 17let GeneratedImportVar_1 = ESValue.load('./interop_not_have_property_js'); 18let foo = GeneratedImportVar_1.getProperty('foo'); 19let person = GeneratedImportVar_1.getProperty('person'); 20let TestHelper = GeneratedImportVar_1.getProperty('TestHelper'); 21let Machine = GeneratedImportVar_1.getProperty('Machine'); 22let User = GeneratedImportVar_1.getProperty('User'); 23let Person = GeneratedImportVar_1.getProperty('Person'); 24let Employee = GeneratedImportVar_1.getProperty('Employee'); 25 26 27foo.getProperty("name") 28foo.setProperty("name", ESValue.wrap("456")) 29person.setProperty("age", ESValue.wrap(23.0)) 30person.setProperty("male", ESValue.wrap([2.0, 3.0])) 31foo.setProperty("age", ESValue.wrap(12.0)) 32if (foo.setProperty("name", ESValue.wrap("456"))) { print("true") } 33 34let a = foo.instantiate() 35a.setProperty("age", ESValue.wrap(12.0)) 36 37let test_helper = TestHelper.instantiate(ESValue.wrap("TEST_INSTANTIATE_JS_OBJECT")); 38test_helper.invokeMethod("test", ESValue.wrap(() => { 39 let machine = new Machine(); 40 return machine.name === "machine"; // arkts-interop-js2s-access-js-prop 41}), ESValue.wrap("machine.name === 'machine'")); 42 43test_helper.invokeMethod("test", ESValue.wrap(() => { 44 let user = new User("Bob"); 45 return user.id === "Bob"; // arkts-interop-js2s-access-js-prop 46}), ESValue.wrap("user.id === 'Bob'")); 47 48test_helper.invokeMethod("test", ESValue.wrap(() => { 49let user = new User(10.0); 50return user.id === 10.0;// arkts-interop-js2s-access-js-prop 51}), ESValue.wrap("user.id === 10")); 52 53test_helper.invokeMethod("test", ESValue.wrap(() => { 54 let user = new User(123n); 55 return user.id === 123n; // arkts-interop-js2s-access-js-prop 56}), ESValue.wrap("user.id === 123n")); 57 58test_helper.invokeMethod("test", ESValue.wrap(() => { 59 let user = new User(true); 60 return user.id === true;// arkts-interop-js2s-access-js-prop 61}), ESValue.wrap("user.id === true")); 62 63test_helper.invokeMethod("test", ESValue.wrap(() => { 64 let machine = new Person("John", 10.0); 65 return machine.name === "machine"; // arkts-interop-js2s-access-js-prop 66}), ESValue.wrap("machine.name === 'machine'")); 67 68test_helper.invokeMethod("test", ESValue.wrap(() => { 69 let employee = new Employee(); 70 return employee.name === "employee"; // arkts-interop-js2s-access-js-prop 71}), ESValue.wrap("employee.name === 'employee'"));