1/** 2 * Copyright (c) 2021-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 16//! CHECKER Check string interop JIT (slow) 17//! RUN force_jit: true, entry: "testString", options: "--compiler-regex=ETSGLOBAL::testString --compiler-enable-fast-interop=false" 18//! METHOD "testString" 19//! PASS_AFTER "IrBuilder" 20//! INST /CallStatic.*jscall::invoke/ 21//! INST_NEXT "Intrinsic.JSRuntimeGetValueString" 22//! INST_NEXT "Intrinsic.StdCoreStringEquals" 23 24//! CHECKER Check string interop JIT (fast) 25//! RUN force_jit: true, entry: "testString", options: "--compiler-regex=ETSGLOBAL::testString" 26//! METHOD "testString" 27//! PASS_AFTER "IrBuilder" 28//! INST_NOT /CallStatic.*jscall::invoke/ 29//! INST "Intrinsic.CompilerCreateLocalScope" 30//! INST_NEXT "Intrinsic.CompilerConvertJSValueToLocal" 31//! INST_NEXT "Intrinsic.CompilerResolveQualifiedJSCall" 32//! INST_NOT /LoadImmediate.*string/ 33//! INST_NEXT "Intrinsic.CompilerLoadResolvedJSFunction" 34//! INST_NEXT "Intrinsic.CompilerJSCallCheck" 35//! INST_NEXT "Intrinsic.CompilerConvertRefTypeToLocal" 36//! INST_NEXT "Intrinsic.CompilerJSCallFunction" 37//! INST_NEXT "Intrinsic.CompilerConvertLocalToJSValue" 38//! INST_NEXT "Intrinsic.CompilerDestroyLocalScope" 39//! INST_NEXT "Intrinsic.JSRuntimeGetValueString" 40//! INST_NEXT "Intrinsic.StdCoreStringEquals" 41 42//! CHECKER Check string interop AOT (slow) 43//! RUN_AOT options: "--compiler-regex=ETSGLOBAL::testString --compiler-enable-fast-interop=false" 44//! METHOD "testString" 45//! PASS_AFTER "IrBuilder" 46//! INST /CallStatic.*jscall::invoke/ 47//! INST_NEXT "Intrinsic.JSRuntimeGetValueString" 48//! INST_NEXT "Intrinsic.StdCoreStringEquals" 49//! RUN entry: "testString" 50//! EVENT /AotManager,.*,ADDED/ 51 52//! CHECKER Check string interop AOT (fast) 53//! RUN_PAOC options: "--compiler-regex=ETSGLOBAL::testString" 54//! METHOD "testString" 55//! PASS_AFTER "IrBuilder" 56//! INST_NOT /CallStatic.*jscall::invoke/ 57//! INST "Intrinsic.CompilerCreateLocalScope" 58//! INST_NEXT "Intrinsic.CompilerConvertJSValueToLocal" 59//! INST_NEXT "Intrinsic.CompilerResolveQualifiedJSCall" 60//! INST_NOT /LoadImmediate.*PandaFileOffset/ 61//! INST_NEXT "Intrinsic.CompilerLoadResolvedJSFunction" 62//! INST_NEXT "Intrinsic.CompilerJSCallCheck" 63//! INST_NEXT "Intrinsic.CompilerConvertRefTypeToLocal" 64//! INST_NEXT "Intrinsic.CompilerJSCallFunction" 65//! INST_NEXT "Intrinsic.CompilerConvertLocalToJSValue" 66//! INST_NEXT "Intrinsic.CompilerDestroyLocalScope" 67//! INST_NEXT "Intrinsic.JSRuntimeGetValueString" 68//! INST_NEXT "Intrinsic.StdCoreStringEquals" 69//! RUN entry: "testString" 70//! EVENT /AotManager,.*,ADDED/ 71 72import { addString } from "/plugins/ets/tests/interop_js/tests/checked/example/strings.js" 73 74function testString(): int { 75 let res = addString("abc"); 76 if (JSRuntime.getValueString(res) != "abc abc") { 77 return 1; 78 } 79 return 0; 80} 81