14514f5e3Sopenharmony_ci/*
24514f5e3Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License.
54514f5e3Sopenharmony_ci * You may obtain a copy of the License at
64514f5e3Sopenharmony_ci *
74514f5e3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
84514f5e3Sopenharmony_ci *
94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and
134514f5e3Sopenharmony_ci * limitations under the License.
144514f5e3Sopenharmony_ci */
154514f5e3Sopenharmony_ci
164514f5e3Sopenharmony_ci#include "ecmascript/js_regexp.h"
174514f5e3Sopenharmony_ci
184514f5e3Sopenharmony_ci#include "ecmascript/builtins/builtins_regexp.h"
194514f5e3Sopenharmony_ci#include "ecmascript/ecma_runtime_call_info.h"
204514f5e3Sopenharmony_ci#include "ecmascript/ecma_string.h"
214514f5e3Sopenharmony_ci#include "ecmascript/ecma_vm.h"
224514f5e3Sopenharmony_ci#include "ecmascript/global_env.h"
234514f5e3Sopenharmony_ci#include "ecmascript/js_handle.h"
244514f5e3Sopenharmony_ci#include "ecmascript/js_hclass.h"
254514f5e3Sopenharmony_ci#include "ecmascript/js_object-inl.h"
264514f5e3Sopenharmony_ci#include "ecmascript/js_tagged_value.h"
274514f5e3Sopenharmony_ci#include "ecmascript/js_thread.h"
284514f5e3Sopenharmony_ci#include "ecmascript/regexp/regexp_parser_cache.h"
294514f5e3Sopenharmony_ci#include "ecmascript/object_factory.h"
304514f5e3Sopenharmony_ci#include "ecmascript/tests/ecma_test_common.h"
314514f5e3Sopenharmony_ci
324514f5e3Sopenharmony_ciusing namespace panda::ecmascript;
334514f5e3Sopenharmony_ciusing namespace panda::ecmascript::builtins;
344514f5e3Sopenharmony_ci
354514f5e3Sopenharmony_cinamespace panda::test {
364514f5e3Sopenharmony_ciclass BuiltinsRegExpTest : public BaseTestWithScope<false> {
374514f5e3Sopenharmony_ci};
384514f5e3Sopenharmony_ci
394514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, RegExpConstructor1)
404514f5e3Sopenharmony_ci{
414514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
424514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern = thread->GetEcmaVM()->GetFactory()->NewFromASCII("\\w+");
434514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags = thread->GetEcmaVM()->GetFactory()->NewFromASCII("i");
444514f5e3Sopenharmony_ci    JSTaggedValue result = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern, flags);
454514f5e3Sopenharmony_ci
464514f5e3Sopenharmony_ci    // ASSERT IsRegExp()
474514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> regexpObject(thread, result);
484514f5e3Sopenharmony_ci    ASSERT_TRUE(JSObject::IsRegExp(thread, regexpObject));
494514f5e3Sopenharmony_ci
504514f5e3Sopenharmony_ci    JSHandle<JSRegExp> jsRegexp(thread, JSRegExp::Cast(regexpObject->GetTaggedObject()));
514514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> originalSource(thread, jsRegexp->GetOriginalSource());
524514f5e3Sopenharmony_ci    uint8_t flagsBits = static_cast<uint8_t>(jsRegexp->GetOriginalFlags().GetInt());
534514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> originalFlags(thread, BuiltinsRegExp::FlagsBitsToString(thread, flagsBits));
544514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, JSHandle<EcmaString>(originalSource), pattern), 0);
554514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, JSHandle<EcmaString>(originalFlags), flags), 0);
564514f5e3Sopenharmony_ci}
574514f5e3Sopenharmony_ci
584514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, RegExpConstructor2)
594514f5e3Sopenharmony_ci{
604514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
614514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern = thread->GetEcmaVM()->GetFactory()->NewFromASCII("\\w+");
624514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags = thread->GetEcmaVM()->GetFactory()->NewFromASCII("i");
634514f5e3Sopenharmony_ci    JSTaggedValue result1 = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern, flags);
644514f5e3Sopenharmony_ci    JSHandle<JSRegExp> value(thread, reinterpret_cast<JSRegExp *>(result1.GetRawData()));
654514f5e3Sopenharmony_ci
664514f5e3Sopenharmony_ci    JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
674514f5e3Sopenharmony_ci    JSHandle<JSFunction> regexp(env->GetRegExpFunction());
684514f5e3Sopenharmony_ci    JSHandle<JSObject> globalObject(thread, env->GetGlobalObject());
694514f5e3Sopenharmony_ci
704514f5e3Sopenharmony_ci    auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*regexp), 8);
714514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetFunction(regexp.GetTaggedValue());
724514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetThis(globalObject.GetTaggedValue());
734514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetCallArg(0, value.GetTaggedValue());
744514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetCallArg(1, JSTaggedValue::Undefined());
754514f5e3Sopenharmony_ci
764514f5e3Sopenharmony_ci    [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo);
774514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
784514f5e3Sopenharmony_ci    JSTaggedValue result2 = BuiltinsRegExp::RegExpConstructor(ecmaRuntimeCallInfo);
794514f5e3Sopenharmony_ci    TestHelper::TearDownFrame(thread, prev);
804514f5e3Sopenharmony_ci
814514f5e3Sopenharmony_ci    // ASSERT IsRegExp()
824514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> regexpObject(thread, result2);
834514f5e3Sopenharmony_ci    ASSERT_TRUE(JSObject::IsRegExp(thread, regexpObject));
844514f5e3Sopenharmony_ci
854514f5e3Sopenharmony_ci    JSHandle<JSRegExp> jsRegexp(thread, JSRegExp::Cast(regexpObject->GetTaggedObject()));
864514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> originalSource(thread, jsRegexp->GetOriginalSource());
874514f5e3Sopenharmony_ci    uint8_t flagsBits = static_cast<uint8_t>(jsRegexp->GetOriginalFlags().GetInt());
884514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> originalFlags(thread, BuiltinsRegExp::FlagsBitsToString(thread, flagsBits));
894514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, JSHandle<EcmaString>(originalSource), pattern), 0);
904514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, JSHandle<EcmaString>(originalFlags), flags), 0);
914514f5e3Sopenharmony_ci}
924514f5e3Sopenharmony_ci
934514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, RegExpConstructor3)
944514f5e3Sopenharmony_ci{
954514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
964514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("\\w+");
974514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("i");
984514f5e3Sopenharmony_ci    JSTaggedValue result1 = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern1, flags1);
994514f5e3Sopenharmony_ci    JSHandle<JSRegExp> value(thread, reinterpret_cast<JSRegExp *>(result1.GetRawData()));
1004514f5e3Sopenharmony_ci
1014514f5e3Sopenharmony_ci    JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
1024514f5e3Sopenharmony_ci    JSHandle<JSFunction> regexp(env->GetRegExpFunction());
1034514f5e3Sopenharmony_ci    JSHandle<JSObject> globalObject(thread, env->GetGlobalObject());
1044514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags2 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("gi");
1054514f5e3Sopenharmony_ci
1064514f5e3Sopenharmony_ci    auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*regexp), 8);
1074514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetFunction(regexp.GetTaggedValue());
1084514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetThis(globalObject.GetTaggedValue());
1094514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetCallArg(0, value.GetTaggedValue());
1104514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetCallArg(1, flags2.GetTaggedValue());
1114514f5e3Sopenharmony_ci
1124514f5e3Sopenharmony_ci    [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo);
1134514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
1144514f5e3Sopenharmony_ci    JSTaggedValue result2 = BuiltinsRegExp::RegExpConstructor(ecmaRuntimeCallInfo);
1154514f5e3Sopenharmony_ci
1164514f5e3Sopenharmony_ci    // ASSERT IsRegExp()
1174514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> regexpObject(thread, result2);
1184514f5e3Sopenharmony_ci    ASSERT_TRUE(JSObject::IsRegExp(thread, regexpObject));
1194514f5e3Sopenharmony_ci
1204514f5e3Sopenharmony_ci    JSHandle<JSRegExp> jsRegexp(thread, JSRegExp::Cast(regexpObject->GetTaggedObject()));
1214514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> originalSource(thread, jsRegexp->GetOriginalSource());
1224514f5e3Sopenharmony_ci    uint8_t flagsBits = static_cast<uint8_t>(jsRegexp->GetOriginalFlags().GetInt());
1234514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> originalFlags(thread, BuiltinsRegExp::FlagsBitsToString(thread, flagsBits));
1244514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, JSHandle<EcmaString>(originalSource), pattern1), 0);
1254514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, JSHandle<EcmaString>(originalFlags), flags2), 0);
1264514f5e3Sopenharmony_ci}
1274514f5e3Sopenharmony_ci
1284514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, GetSource1)
1294514f5e3Sopenharmony_ci{
1304514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
1314514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("");
1324514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("i");
1334514f5e3Sopenharmony_ci    JSTaggedValue result1 = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern1, flags1);
1344514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> result1Handle(thread, result1);
1354514f5e3Sopenharmony_ci
1364514f5e3Sopenharmony_ci    // invoke GetSource method
1374514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> source(
1384514f5e3Sopenharmony_ci        thread, thread->GetEcmaVM()->GetFactory()->NewFromASCII("source").GetTaggedValue());
1394514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> sourceResult(JSObject::GetProperty(thread, result1Handle, source).GetValue());
1404514f5e3Sopenharmony_ci
1414514f5e3Sopenharmony_ci    JSHandle<EcmaString> expect = thread->GetEcmaVM()->GetFactory()->NewFromASCII("(?:)");
1424514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, JSHandle<EcmaString>(sourceResult), expect), 0);
1434514f5e3Sopenharmony_ci}
1444514f5e3Sopenharmony_ci
1454514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, GetSource2)
1464514f5e3Sopenharmony_ci{
1474514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
1484514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("/w+");
1494514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("i");
1504514f5e3Sopenharmony_ci    JSTaggedValue result1 = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern1, flags1);
1514514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> result1Handle(thread, result1);
1524514f5e3Sopenharmony_ci
1534514f5e3Sopenharmony_ci    // invoke GetSource method
1544514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> source(thread->GetEcmaVM()->GetFactory()->NewFromASCII("source"));
1554514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> sourceResult(JSObject::GetProperty(thread, result1Handle, source).GetValue());
1564514f5e3Sopenharmony_ci
1574514f5e3Sopenharmony_ci    JSHandle<EcmaString> expect = thread->GetEcmaVM()->GetFactory()->NewFromASCII("\\/w+");
1584514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, JSHandle<EcmaString>(sourceResult), expect), 0);
1594514f5e3Sopenharmony_ci}
1604514f5e3Sopenharmony_ci
1614514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, Get)
1624514f5e3Sopenharmony_ci{
1634514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
1644514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("\\w+");
1654514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("gimuy");
1664514f5e3Sopenharmony_ci    JSTaggedValue result1 = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern1, flags1);
1674514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> result1Handle(thread, result1);
1684514f5e3Sopenharmony_ci
1694514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> global(thread->GetEcmaVM()->GetFactory()->NewFromASCII("global"));
1704514f5e3Sopenharmony_ci    JSTaggedValue taggedGlobalResult =
1714514f5e3Sopenharmony_ci        JSTaggedValue(JSObject::GetProperty(thread, result1Handle, global).GetValue().GetTaggedValue());
1724514f5e3Sopenharmony_ci    ASSERT_EQ(taggedGlobalResult.GetRawData(), JSTaggedValue::True().GetRawData());
1734514f5e3Sopenharmony_ci
1744514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> ignoreCase(thread->GetEcmaVM()->GetFactory()->NewFromASCII("ignoreCase"));
1754514f5e3Sopenharmony_ci    JSTaggedValue taggedIgnoreCaseResult =
1764514f5e3Sopenharmony_ci        JSTaggedValue(JSObject::GetProperty(thread, result1Handle, ignoreCase).GetValue().GetTaggedValue());
1774514f5e3Sopenharmony_ci    ASSERT_EQ(taggedIgnoreCaseResult.GetRawData(), JSTaggedValue::True().GetRawData());
1784514f5e3Sopenharmony_ci
1794514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> multiline(thread->GetEcmaVM()->GetFactory()->NewFromASCII("multiline"));
1804514f5e3Sopenharmony_ci    JSTaggedValue taggedMultilineResult =
1814514f5e3Sopenharmony_ci        JSTaggedValue(JSObject::GetProperty(thread, result1Handle, multiline).GetValue().GetTaggedValue());
1824514f5e3Sopenharmony_ci    ASSERT_EQ(taggedMultilineResult.GetRawData(), JSTaggedValue::True().GetRawData());
1834514f5e3Sopenharmony_ci
1844514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> sticky(thread->GetEcmaVM()->GetFactory()->NewFromASCII("sticky"));
1854514f5e3Sopenharmony_ci    JSTaggedValue taggedStickyResult =
1864514f5e3Sopenharmony_ci        JSTaggedValue(JSObject::GetProperty(thread, result1Handle, sticky).GetValue().GetTaggedValue());
1874514f5e3Sopenharmony_ci    ASSERT_EQ(taggedStickyResult.GetRawData(), JSTaggedValue::True().GetRawData());
1884514f5e3Sopenharmony_ci
1894514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> unicode(thread->GetEcmaVM()->GetFactory()->NewFromASCII("unicode"));
1904514f5e3Sopenharmony_ci    JSTaggedValue taggedUnicodeResult =
1914514f5e3Sopenharmony_ci        JSTaggedValue(JSObject::GetProperty(thread, result1Handle, unicode).GetValue().GetTaggedValue());
1924514f5e3Sopenharmony_ci    ASSERT_EQ(taggedUnicodeResult.GetRawData(), JSTaggedValue::True().GetRawData());
1934514f5e3Sopenharmony_ci}
1944514f5e3Sopenharmony_ci
1954514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, GetFlags)
1964514f5e3Sopenharmony_ci{
1974514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
1984514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("\\w+");
1994514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("imuyg");
2004514f5e3Sopenharmony_ci    JSTaggedValue result1 = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern1, flags1);
2014514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> result1Handle(thread, result1);
2024514f5e3Sopenharmony_ci
2034514f5e3Sopenharmony_ci    // invoke GetFlags method
2044514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> flags(thread->GetEcmaVM()->GetFactory()->NewFromASCII("flags"));
2054514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> flagsResult(JSObject::GetProperty(thread, result1Handle, flags).GetValue());
2064514f5e3Sopenharmony_ci
2074514f5e3Sopenharmony_ci    JSHandle<EcmaString> expectResult = thread->GetEcmaVM()->GetFactory()->NewFromASCII("gimuy");
2084514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, JSHandle<EcmaString>(flagsResult), expectResult), 0);
2094514f5e3Sopenharmony_ci}
2104514f5e3Sopenharmony_ci
2114514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, toString)
2124514f5e3Sopenharmony_ci{
2134514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
2144514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("\\w+");
2154514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("imuyg");
2164514f5e3Sopenharmony_ci    JSTaggedValue result1 = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern1, flags1);
2174514f5e3Sopenharmony_ci    JSHandle<JSRegExp> value(thread, reinterpret_cast<JSRegExp *>(result1.GetRawData()));
2184514f5e3Sopenharmony_ci
2194514f5e3Sopenharmony_ci    auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4);
2204514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined());
2214514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetThis(value.GetTaggedValue());
2224514f5e3Sopenharmony_ci
2234514f5e3Sopenharmony_ci    [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo);
2244514f5e3Sopenharmony_ci    // invoke ToString method
2254514f5e3Sopenharmony_ci    JSTaggedValue toStringResult = BuiltinsRegExp::ToString(ecmaRuntimeCallInfo);
2264514f5e3Sopenharmony_ci    ASSERT_TRUE(toStringResult.IsString());
2274514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> toStringResultHandle(thread, toStringResult);
2284514f5e3Sopenharmony_ci    JSHandle<EcmaString> expectResult = thread->GetEcmaVM()->GetFactory()->NewFromASCII("/\\w+/gimuy");
2294514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance,
2304514f5e3Sopenharmony_ci        JSHandle<EcmaString>(toStringResultHandle), expectResult), 0);
2314514f5e3Sopenharmony_ci}
2324514f5e3Sopenharmony_ci
2334514f5e3Sopenharmony_civoid ExecCommon(JSThread* thread, EcmaVM* instance, JSHandle<JSTaggedValue>& execResult,
2344514f5e3Sopenharmony_ci    JSHandle<EcmaString>& inputString, std::vector<JSHandle<EcmaString>>& result)
2354514f5e3Sopenharmony_ci{
2364514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> input(thread->GetEcmaVM()->GetFactory()->NewFromASCII("input"));
2374514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> inputHandle(JSObject::GetProperty(thread, execResult, input).GetValue());
2384514f5e3Sopenharmony_ci    JSHandle<EcmaString> outputInput = JSTaggedValue::ToString(thread, inputHandle);
2394514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, outputInput, inputString), 0);
2404514f5e3Sopenharmony_ci
2414514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> zero(thread->GetEcmaVM()->GetFactory()->NewFromASCII("0"));
2424514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> zeroHandle(JSObject::GetProperty(thread, execResult, zero).GetValue());
2434514f5e3Sopenharmony_ci    JSHandle<EcmaString> outputZero = JSTaggedValue::ToString(thread, zeroHandle);
2444514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, outputZero, result[0]), 0);
2454514f5e3Sopenharmony_ci
2464514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> first(thread->GetEcmaVM()->GetFactory()->NewFromASCII("1"));
2474514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> oneHandle(JSObject::GetProperty(thread, execResult, first).GetValue());
2484514f5e3Sopenharmony_ci    JSHandle<EcmaString> outputOne = JSTaggedValue::ToString(thread, oneHandle);
2494514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, outputOne, result[1]), 0); // 1: second value
2504514f5e3Sopenharmony_ci
2514514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> second(thread->GetEcmaVM()->GetFactory()->NewFromASCII("2"));
2524514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> twoHandle(JSObject::GetProperty(thread, execResult, second).GetValue());
2534514f5e3Sopenharmony_ci    JSHandle<EcmaString> outputTwo = JSTaggedValue::ToString(thread, twoHandle);
2544514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, outputTwo, result[2]), 0); // 2: third value
2554514f5e3Sopenharmony_ci}
2564514f5e3Sopenharmony_ci
2574514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, Exec1)
2584514f5e3Sopenharmony_ci{
2594514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
2604514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern1 =
2614514f5e3Sopenharmony_ci        thread->GetEcmaVM()->GetFactory()->NewFromASCII("quick\\s(brown).+?(jumps)");
2624514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("ig");
2634514f5e3Sopenharmony_ci    JSTaggedValue result1 = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern1, flags1);
2644514f5e3Sopenharmony_ci    JSHandle<JSRegExp> value(thread, reinterpret_cast<JSRegExp *>(result1.GetRawData()));
2654514f5e3Sopenharmony_ci
2664514f5e3Sopenharmony_ci    JSHandle<EcmaString> inputString =
2674514f5e3Sopenharmony_ci        thread->GetEcmaVM()->GetFactory()->NewFromASCII("The Quick Brown Fox Jumps Over The Lazy Dog");
2684514f5e3Sopenharmony_ci    auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6);
2694514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined());
2704514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetThis(value.GetTaggedValue());
2714514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetCallArg(0, inputString.GetTaggedValue());
2724514f5e3Sopenharmony_ci
2734514f5e3Sopenharmony_ci    [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo);
2744514f5e3Sopenharmony_ci    // invoke Exec method
2754514f5e3Sopenharmony_ci    JSTaggedValue results = BuiltinsRegExp::Exec(ecmaRuntimeCallInfo);
2764514f5e3Sopenharmony_ci
2774514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> execResult(thread, results);
2784514f5e3Sopenharmony_ci    JSHandle<EcmaString> resultZero =
2794514f5e3Sopenharmony_ci        thread->GetEcmaVM()->GetFactory()->NewFromASCII("Quick Brown Fox Jumps");
2804514f5e3Sopenharmony_ci    JSHandle<EcmaString> resultOne = thread->GetEcmaVM()->GetFactory()->NewFromASCII("Brown");
2814514f5e3Sopenharmony_ci    JSHandle<EcmaString> resultTwo = thread->GetEcmaVM()->GetFactory()->NewFromASCII("Jumps");
2824514f5e3Sopenharmony_ci
2834514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> index(thread->GetEcmaVM()->GetFactory()->NewFromASCII("index"));
2844514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> indexHandle(JSObject::GetProperty(thread, execResult, index).GetValue());
2854514f5e3Sopenharmony_ci    uint32_t resultIndex = JSTaggedValue::ToUint32(thread, indexHandle);
2864514f5e3Sopenharmony_ci    ASSERT_TRUE(resultIndex == 4U);
2874514f5e3Sopenharmony_ci
2884514f5e3Sopenharmony_ci    std::vector<JSHandle<EcmaString>> result{resultZero, resultOne, resultTwo};
2894514f5e3Sopenharmony_ci    ExecCommon(thread, instance, execResult, inputString, result);
2904514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> regexp = JSHandle<JSTaggedValue>::Cast(value);
2914514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> lastIndexHandle(thread->GetEcmaVM()->GetFactory()->NewFromASCII("lastIndex"));
2924514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> lastIndexObj(JSObject::GetProperty(thread, regexp, lastIndexHandle).GetValue());
2934514f5e3Sopenharmony_ci    int lastIndex = lastIndexObj->GetInt();
2944514f5e3Sopenharmony_ci    ASSERT_TRUE(lastIndex == 25);
2954514f5e3Sopenharmony_ci}
2964514f5e3Sopenharmony_ci
2974514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, Exec2)
2984514f5e3Sopenharmony_ci{
2994514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
3004514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern1 =
3014514f5e3Sopenharmony_ci        thread->GetEcmaVM()->GetFactory()->NewFromASCII("((1)|(12))((3)|(23))");
3024514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("ig");
3034514f5e3Sopenharmony_ci    JSTaggedValue result1 = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern1, flags1);
3044514f5e3Sopenharmony_ci    JSHandle<JSRegExp> value(thread, reinterpret_cast<JSRegExp *>(result1.GetRawData()));
3054514f5e3Sopenharmony_ci
3064514f5e3Sopenharmony_ci    JSHandle<EcmaString> inputString = thread->GetEcmaVM()->GetFactory()->NewFromASCII("123");
3074514f5e3Sopenharmony_ci    auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6);
3084514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined());
3094514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetThis(value.GetTaggedValue());
3104514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetCallArg(0, inputString.GetTaggedValue());
3114514f5e3Sopenharmony_ci
3124514f5e3Sopenharmony_ci    [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo);
3134514f5e3Sopenharmony_ci    // invoke Exec method
3144514f5e3Sopenharmony_ci    JSTaggedValue results = BuiltinsRegExp::Exec(ecmaRuntimeCallInfo);
3154514f5e3Sopenharmony_ci
3164514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> execResult(thread, results);
3174514f5e3Sopenharmony_ci    JSHandle<EcmaString> resultZero = thread->GetEcmaVM()->GetFactory()->NewFromASCII("123");
3184514f5e3Sopenharmony_ci    JSHandle<EcmaString> resultOne = thread->GetEcmaVM()->GetFactory()->NewFromASCII("1");
3194514f5e3Sopenharmony_ci    JSHandle<EcmaString> resultTwo = thread->GetEcmaVM()->GetFactory()->NewFromASCII("1");
3204514f5e3Sopenharmony_ci    JSHandle<EcmaString> resultFour = thread->GetEcmaVM()->GetFactory()->NewFromASCII("23");
3214514f5e3Sopenharmony_ci    JSHandle<EcmaString> resultSix = thread->GetEcmaVM()->GetFactory()->NewFromASCII("23");
3224514f5e3Sopenharmony_ci
3234514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> index(thread->GetEcmaVM()->GetFactory()->NewFromASCII("index"));
3244514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> indexHandle(JSObject::GetProperty(thread, execResult, index).GetValue());
3254514f5e3Sopenharmony_ci    uint32_t resultIndex = JSTaggedValue::ToUint32(thread, indexHandle);
3264514f5e3Sopenharmony_ci    ASSERT_TRUE(resultIndex == 0U);
3274514f5e3Sopenharmony_ci
3284514f5e3Sopenharmony_ci    std::vector<JSHandle<EcmaString>> result{resultZero, resultOne, resultTwo};
3294514f5e3Sopenharmony_ci    ExecCommon(thread, instance, execResult, inputString, result);
3304514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> regexp = JSHandle<JSTaggedValue>::Cast(value);
3314514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> lastIndexHandle(thread->GetEcmaVM()->GetFactory()->NewFromASCII("lastIndex"));
3324514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> lastIndexObj(JSObject::GetProperty(thread, regexp, lastIndexHandle).GetValue());
3334514f5e3Sopenharmony_ci    int lastIndex = lastIndexObj->GetInt();
3344514f5e3Sopenharmony_ci    ASSERT_TRUE(lastIndex == 3);
3354514f5e3Sopenharmony_ci
3364514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> third(thread->GetEcmaVM()->GetFactory()->NewFromASCII("3"));
3374514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> thirdHandle(JSObject::GetProperty(thread, execResult, third).GetValue());
3384514f5e3Sopenharmony_ci    ASSERT_TRUE(thirdHandle->IsUndefined());
3394514f5e3Sopenharmony_ci
3404514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> four(thread->GetEcmaVM()->GetFactory()->NewFromASCII("4"));
3414514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> fourHandle(JSObject::GetProperty(thread, execResult, four).GetValue());
3424514f5e3Sopenharmony_ci    JSHandle<EcmaString> outputFour = JSTaggedValue::ToString(thread, fourHandle);
3434514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, outputFour, resultFour), 0);
3444514f5e3Sopenharmony_ci
3454514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> five(thread->GetEcmaVM()->GetFactory()->NewFromASCII("5"));
3464514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> fiveHandle(JSObject::GetProperty(thread, execResult, five).GetValue());
3474514f5e3Sopenharmony_ci    ASSERT_TRUE(fiveHandle->IsUndefined());
3484514f5e3Sopenharmony_ci
3494514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> six(thread->GetEcmaVM()->GetFactory()->NewFromASCII("6"));
3504514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> sixHandle(JSObject::GetProperty(thread, execResult, six).GetValue());
3514514f5e3Sopenharmony_ci    JSHandle<EcmaString> outputSix = JSTaggedValue::ToString(thread, sixHandle);
3524514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, outputSix, resultSix), 0);
3534514f5e3Sopenharmony_ci}
3544514f5e3Sopenharmony_ci
3554514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, Match1)
3564514f5e3Sopenharmony_ci{
3574514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
3584514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern1 =
3594514f5e3Sopenharmony_ci        thread->GetEcmaVM()->GetFactory()->NewFromASCII("quick\\s(brown).+?(jumps)");
3604514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("iug");
3614514f5e3Sopenharmony_ci    JSTaggedValue result1 = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern1, flags1);
3624514f5e3Sopenharmony_ci    JSHandle<JSRegExp> value(thread, reinterpret_cast<JSRegExp *>(result1.GetRawData()));
3634514f5e3Sopenharmony_ci
3644514f5e3Sopenharmony_ci    JSHandle<EcmaString> inputString =
3654514f5e3Sopenharmony_ci        thread->GetEcmaVM()->GetFactory()->NewFromASCII("The Quick Brown Fox Jumps Over The Lazy Dog");
3664514f5e3Sopenharmony_ci    std::vector<JSTaggedValue> args{inputString.GetTaggedValue()};
3674514f5e3Sopenharmony_ci    auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, args, 6, value.GetTaggedValue());
3684514f5e3Sopenharmony_ci
3694514f5e3Sopenharmony_ci    [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo);
3704514f5e3Sopenharmony_ci    // invoke Match method
3714514f5e3Sopenharmony_ci    JSTaggedValue matchResults = BuiltinsRegExp::Match(ecmaRuntimeCallInfo);
3724514f5e3Sopenharmony_ci
3734514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> matchResult(thread, matchResults);
3744514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> zero(thread->GetEcmaVM()->GetFactory()->NewFromASCII("0"));
3754514f5e3Sopenharmony_ci    JSHandle<EcmaString> resultZero =
3764514f5e3Sopenharmony_ci        thread->GetEcmaVM()->GetFactory()->NewFromASCII("Quick Brown Fox Jumps");
3774514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> zeroHandle(JSObject::GetProperty(thread, matchResult, zero).GetValue());
3784514f5e3Sopenharmony_ci    JSHandle<EcmaString> outputZero = JSTaggedValue::ToString(thread, zeroHandle);
3794514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, outputZero, resultZero), 0);
3804514f5e3Sopenharmony_ci}
3814514f5e3Sopenharmony_ci
3824514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, Test1)
3834514f5e3Sopenharmony_ci{
3844514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
3854514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern1 =
3864514f5e3Sopenharmony_ci        thread->GetEcmaVM()->GetFactory()->NewFromASCII("quick\\s(brown).+?(jumps)");
3874514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("iug");
3884514f5e3Sopenharmony_ci    JSTaggedValue result1 = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern1, flags1);
3894514f5e3Sopenharmony_ci    JSHandle<JSRegExp> value(thread, reinterpret_cast<JSRegExp *>(result1.GetRawData()));
3904514f5e3Sopenharmony_ci
3914514f5e3Sopenharmony_ci    JSHandle<EcmaString> inputString =
3924514f5e3Sopenharmony_ci        thread->GetEcmaVM()->GetFactory()->NewFromASCII("The Quick Brown Fox Jumps Over The Lazy Dog");
3934514f5e3Sopenharmony_ci    std::vector<JSTaggedValue> args{inputString.GetTaggedValue()};
3944514f5e3Sopenharmony_ci    auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, args, 6, value.GetTaggedValue());
3954514f5e3Sopenharmony_ci
3964514f5e3Sopenharmony_ci    [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo);
3974514f5e3Sopenharmony_ci    // invoke Test method
3984514f5e3Sopenharmony_ci    JSTaggedValue testResult = BuiltinsRegExp::Test(ecmaRuntimeCallInfo);
3994514f5e3Sopenharmony_ci    ASSERT_EQ(testResult.GetRawData(), JSTaggedValue::True().GetRawData());
4004514f5e3Sopenharmony_ci}
4014514f5e3Sopenharmony_ci
4024514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, Search1)
4034514f5e3Sopenharmony_ci{
4044514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
4054514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern1 =
4064514f5e3Sopenharmony_ci        thread->GetEcmaVM()->GetFactory()->NewFromASCII("quick\\s(brown).+?(jumps)");
4074514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("iug");
4084514f5e3Sopenharmony_ci    JSTaggedValue result1 = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern1, flags1);
4094514f5e3Sopenharmony_ci    JSHandle<JSRegExp> value(thread, reinterpret_cast<JSRegExp *>(result1.GetRawData()));
4104514f5e3Sopenharmony_ci
4114514f5e3Sopenharmony_ci    JSHandle<EcmaString> inputString =
4124514f5e3Sopenharmony_ci        thread->GetEcmaVM()->GetFactory()->NewFromASCII("The Quick Brown Fox Jumps Over The Lazy Dog");
4134514f5e3Sopenharmony_ci    std::vector<JSTaggedValue> args{inputString.GetTaggedValue()};
4144514f5e3Sopenharmony_ci    auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, args, 6, value.GetTaggedValue());
4154514f5e3Sopenharmony_ci
4164514f5e3Sopenharmony_ci    [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo);
4174514f5e3Sopenharmony_ci    // invoke Search method
4184514f5e3Sopenharmony_ci    JSTaggedValue searchResult = BuiltinsRegExp::Search(ecmaRuntimeCallInfo);
4194514f5e3Sopenharmony_ci    ASSERT_EQ(searchResult.GetRawData(), JSTaggedValue(4).GetRawData());
4204514f5e3Sopenharmony_ci}
4214514f5e3Sopenharmony_ci
4224514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, Split1)
4234514f5e3Sopenharmony_ci{
4244514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
4254514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("-");
4264514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("iug");
4274514f5e3Sopenharmony_ci    JSTaggedValue result1 = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern1, flags1);
4284514f5e3Sopenharmony_ci    JSHandle<JSRegExp> value(thread, reinterpret_cast<JSRegExp *>(result1.GetRawData()));
4294514f5e3Sopenharmony_ci
4304514f5e3Sopenharmony_ci    JSHandle<EcmaString> inputString = thread->GetEcmaVM()->GetFactory()->NewFromASCII("");
4314514f5e3Sopenharmony_ci
4324514f5e3Sopenharmony_ci    auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8);
4334514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined());
4344514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetThis(value.GetTaggedValue());
4354514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetCallArg(0, inputString.GetTaggedValue());
4364514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetCallArg(1, JSTaggedValue::Undefined());
4374514f5e3Sopenharmony_ci
4384514f5e3Sopenharmony_ci    [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo);
4394514f5e3Sopenharmony_ci    // invoke Split method
4404514f5e3Sopenharmony_ci    JSTaggedValue splitResults = BuiltinsRegExp::Split(ecmaRuntimeCallInfo);
4414514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> splitResult(thread, splitResults);
4424514f5e3Sopenharmony_ci
4434514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> zero(thread->GetEcmaVM()->GetFactory()->NewFromASCII("0"));
4444514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> zeroHandle(JSObject::GetProperty(thread, splitResult, zero).GetValue());
4454514f5e3Sopenharmony_ci    JSHandle<EcmaString> outputZero = JSTaggedValue::ToString(thread, zeroHandle);
4464514f5e3Sopenharmony_ci
4474514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, outputZero, inputString), 0);
4484514f5e3Sopenharmony_ci}
4494514f5e3Sopenharmony_ci
4504514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, Split2)
4514514f5e3Sopenharmony_ci{
4524514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
4534514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("-");
4544514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("iug");
4554514f5e3Sopenharmony_ci    JSTaggedValue result1 = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern1, flags1);
4564514f5e3Sopenharmony_ci    JSHandle<JSRegExp> value(thread, reinterpret_cast<JSRegExp *>(result1.GetRawData()));
4574514f5e3Sopenharmony_ci
4584514f5e3Sopenharmony_ci    JSHandle<EcmaString> inputString = thread->GetEcmaVM()->GetFactory()->NewFromASCII("a-b-c");
4594514f5e3Sopenharmony_ci
4604514f5e3Sopenharmony_ci    auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8);
4614514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined());
4624514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetThis(value.GetTaggedValue());
4634514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetCallArg(0, inputString.GetTaggedValue());
4644514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetCallArg(1, JSTaggedValue::Undefined());
4654514f5e3Sopenharmony_ci
4664514f5e3Sopenharmony_ci    [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo);
4674514f5e3Sopenharmony_ci    // invoke Split method
4684514f5e3Sopenharmony_ci    JSTaggedValue splitResults = BuiltinsRegExp::Split(ecmaRuntimeCallInfo);
4694514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> splitResult(thread, splitResults);
4704514f5e3Sopenharmony_ci    JSHandle<EcmaString> resultZero = thread->GetEcmaVM()->GetFactory()->NewFromASCII("a");
4714514f5e3Sopenharmony_ci    JSHandle<EcmaString> resultOne = thread->GetEcmaVM()->GetFactory()->NewFromASCII("b");
4724514f5e3Sopenharmony_ci    JSHandle<EcmaString> resultTwo = thread->GetEcmaVM()->GetFactory()->NewFromASCII("c");
4734514f5e3Sopenharmony_ci
4744514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> zero(thread->GetEcmaVM()->GetFactory()->NewFromASCII("0"));
4754514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> zeroHandle(JSObject::GetProperty(thread, splitResult, zero).GetValue());
4764514f5e3Sopenharmony_ci    JSHandle<EcmaString> outputZero = JSTaggedValue::ToString(thread, zeroHandle);
4774514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, outputZero, resultZero), 0);
4784514f5e3Sopenharmony_ci
4794514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> first(thread->GetEcmaVM()->GetFactory()->NewFromASCII("1"));
4804514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> oneHandle(JSObject::GetProperty(thread, splitResult, first).GetValue());
4814514f5e3Sopenharmony_ci    JSHandle<EcmaString> outputOne = JSTaggedValue::ToString(thread, oneHandle);
4824514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, outputOne, resultOne), 0);
4834514f5e3Sopenharmony_ci
4844514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> second(thread->GetEcmaVM()->GetFactory()->NewFromASCII("2"));
4854514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> twoHandle(JSObject::GetProperty(thread, splitResult, second).GetValue());
4864514f5e3Sopenharmony_ci    JSHandle<EcmaString> outputTwo = JSTaggedValue::ToString(thread, twoHandle);
4874514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, outputTwo, resultTwo), 0);
4884514f5e3Sopenharmony_ci}
4894514f5e3Sopenharmony_ci
4904514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, GetSpecies)
4914514f5e3Sopenharmony_ci{
4924514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
4934514f5e3Sopenharmony_ci    JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
4944514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> speciesSymbol = env->GetSpeciesSymbol();
4954514f5e3Sopenharmony_ci    EXPECT_TRUE(!speciesSymbol.GetTaggedValue().IsUndefined());
4964514f5e3Sopenharmony_ci
4974514f5e3Sopenharmony_ci    JSHandle<JSFunction> newTarget(env->GetRegExpFunction());
4984514f5e3Sopenharmony_ci
4994514f5e3Sopenharmony_ci    JSTaggedValue value =
5004514f5e3Sopenharmony_ci        JSObject::GetProperty(thread, JSHandle<JSTaggedValue>(newTarget), speciesSymbol).GetValue().GetTaggedValue();
5014514f5e3Sopenharmony_ci    EXPECT_EQ(value, newTarget.GetTaggedValue());
5024514f5e3Sopenharmony_ci}
5034514f5e3Sopenharmony_ci
5044514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, Replace1)
5054514f5e3Sopenharmony_ci{
5064514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
5074514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern1 =
5084514f5e3Sopenharmony_ci        thread->GetEcmaVM()->GetFactory()->NewFromASCII("quick\\s(brown).+?(jumps)");
5094514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags1 = thread->GetEcmaVM()->GetFactory()->NewFromASCII("iug");
5104514f5e3Sopenharmony_ci    JSTaggedValue result1 = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern1, flags1);
5114514f5e3Sopenharmony_ci    JSHandle<JSRegExp> value(thread, reinterpret_cast<JSRegExp *>(result1.GetRawData()));
5124514f5e3Sopenharmony_ci
5134514f5e3Sopenharmony_ci    JSHandle<EcmaString> inputString =
5144514f5e3Sopenharmony_ci        thread->GetEcmaVM()->GetFactory()->NewFromASCII("The Quick Brown Fox Jumps Over The Lazy Dog");
5154514f5e3Sopenharmony_ci    JSHandle<EcmaString> replaceString =
5164514f5e3Sopenharmony_ci        thread->GetEcmaVM()->GetFactory()->NewFromASCII("$&a $` $\' $2 $01 $$1 $21 $32 a");
5174514f5e3Sopenharmony_ci    auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8);
5184514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined());
5194514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetThis(value.GetTaggedValue());
5204514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetCallArg(0, inputString.GetTaggedValue());
5214514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetCallArg(1, replaceString.GetTaggedValue());
5224514f5e3Sopenharmony_ci
5234514f5e3Sopenharmony_ci    [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo);
5244514f5e3Sopenharmony_ci    // invoke replace method
5254514f5e3Sopenharmony_ci    JSTaggedValue results = BuiltinsRegExp::Replace(ecmaRuntimeCallInfo);
5264514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> replaceResult(thread, results);
5274514f5e3Sopenharmony_ci    JSHandle<EcmaString> resultZero = thread->GetEcmaVM()->GetFactory()->NewFromASCII(
5284514f5e3Sopenharmony_ci        "The Quick Brown Fox Jumpsa The   Over The Lazy Dog Jumps Brown $1 Jumps1 $32 a Over The Lazy Dog");
5294514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, JSHandle<EcmaString>(replaceResult), resultZero), 0);
5304514f5e3Sopenharmony_ci}
5314514f5e3Sopenharmony_ci
5324514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, Replace2)
5334514f5e3Sopenharmony_ci{
5344514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
5354514f5e3Sopenharmony_ci    ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
5364514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern1 = factory->NewFromASCII("b(c)(z)?(.)");
5374514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags1 = factory->NewFromASCII("");
5384514f5e3Sopenharmony_ci    JSTaggedValue result1 = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern1, flags1);
5394514f5e3Sopenharmony_ci    JSHandle<JSRegExp> value(thread, reinterpret_cast<JSRegExp *>(result1.GetRawData()));
5404514f5e3Sopenharmony_ci
5414514f5e3Sopenharmony_ci    JSHandle<EcmaString> inputString = factory->NewFromASCII("abcde");
5424514f5e3Sopenharmony_ci    JSHandle<EcmaString> replaceString = factory->NewFromASCII("[$01$02$03$04$00]");
5434514f5e3Sopenharmony_ci    auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8);
5444514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined());
5454514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetThis(value.GetTaggedValue());
5464514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetCallArg(0, inputString.GetTaggedValue());
5474514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetCallArg(1, replaceString.GetTaggedValue());
5484514f5e3Sopenharmony_ci
5494514f5e3Sopenharmony_ci    [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo);
5504514f5e3Sopenharmony_ci    // invoke replace method
5514514f5e3Sopenharmony_ci    JSTaggedValue results = BuiltinsRegExp::Replace(ecmaRuntimeCallInfo);
5524514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> replaceResult(thread, results);
5534514f5e3Sopenharmony_ci    JSHandle<EcmaString> resultZero = factory->NewFromASCII("a[cd$04$00]e");
5544514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, JSHandle<EcmaString>(replaceResult), resultZero), 0);
5554514f5e3Sopenharmony_ci}
5564514f5e3Sopenharmony_ci
5574514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, Replace3)
5584514f5e3Sopenharmony_ci{
5594514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
5604514f5e3Sopenharmony_ci    ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
5614514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern1 = factory->NewFromASCII("abc");
5624514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags1 = factory->NewFromASCII("g");
5634514f5e3Sopenharmony_ci    JSTaggedValue result1 = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern1, flags1);
5644514f5e3Sopenharmony_ci    JSHandle<JSRegExp> value(thread, reinterpret_cast<JSRegExp *>(result1.GetRawData()));
5654514f5e3Sopenharmony_ci
5664514f5e3Sopenharmony_ci    JSHandle<EcmaString> inputString = factory->NewFromASCII("abcde");
5674514f5e3Sopenharmony_ci    JSHandle<EcmaString> replaceString = factory->NewFromASCII("");
5684514f5e3Sopenharmony_ci    auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8);
5694514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined());
5704514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetThis(value.GetTaggedValue());
5714514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetCallArg(0, inputString.GetTaggedValue());
5724514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetCallArg(1, replaceString.GetTaggedValue());
5734514f5e3Sopenharmony_ci
5744514f5e3Sopenharmony_ci    [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo);
5754514f5e3Sopenharmony_ci    // invoke replace method
5764514f5e3Sopenharmony_ci    JSTaggedValue results = BuiltinsRegExp::Replace(ecmaRuntimeCallInfo);
5774514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> replaceResult(thread, results);
5784514f5e3Sopenharmony_ci    JSHandle<EcmaString> resultZero = factory->NewFromASCII("de");
5794514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, JSHandle<EcmaString>(replaceResult), resultZero), 0);
5804514f5e3Sopenharmony_ci}
5814514f5e3Sopenharmony_ci
5824514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, RegExpParseCache)
5834514f5e3Sopenharmony_ci{
5844514f5e3Sopenharmony_ci    RegExpParserCache *regExpParserCache = thread->GetCurrentEcmaContext()->GetRegExpParserCache();
5854514f5e3Sopenharmony_ci    ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
5864514f5e3Sopenharmony_ci    JSHandle<EcmaString> string1 = factory->NewFromASCII("abc");
5874514f5e3Sopenharmony_ci    JSHandle<EcmaString> string2 = factory->NewFromASCII("abcd");
5884514f5e3Sopenharmony_ci    CVector<CString> vec;
5894514f5e3Sopenharmony_ci    regExpParserCache->SetCache(*string1, 0, JSTaggedValue::True(), 2, vec);
5904514f5e3Sopenharmony_ci    ASSERT_TRUE(regExpParserCache->GetCache(*string1, 0, vec).first.IsTrue());
5914514f5e3Sopenharmony_ci    ASSERT_TRUE(regExpParserCache->GetCache(*string1, 0, vec).second == 2U);
5924514f5e3Sopenharmony_ci    ASSERT_TRUE(regExpParserCache->GetCache(*string1,
5934514f5e3Sopenharmony_ci                                            RegExpParserCache::CACHE_SIZE, vec).first.IsHole());
5944514f5e3Sopenharmony_ci    ASSERT_TRUE(regExpParserCache->GetCache(*string2, 0, vec).first.IsHole());
5954514f5e3Sopenharmony_ci    ASSERT_TRUE(regExpParserCache->GetCache(*string2, UINT32_MAX, vec).first.IsHole());
5964514f5e3Sopenharmony_ci}
5974514f5e3Sopenharmony_ci
5984514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsRegExpTest, FlagD)
5994514f5e3Sopenharmony_ci{
6004514f5e3Sopenharmony_ci    ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
6014514f5e3Sopenharmony_ci    // invoke RegExpConstructor method
6024514f5e3Sopenharmony_ci    JSHandle<EcmaString> pattern1 = factory->NewFromASCII("(?<groupname>a)");
6034514f5e3Sopenharmony_ci    JSHandle<EcmaString> flags1 = factory->NewFromASCII("gd");
6044514f5e3Sopenharmony_ci    JSTaggedValue result1 = TestCommon::CreateJSRegexpByPatternAndFlags(thread, pattern1, flags1);
6054514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> result1Handle(thread, result1);
6064514f5e3Sopenharmony_ci
6074514f5e3Sopenharmony_ci    // invoke GetFlags method
6084514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> flags(factory->NewFromASCII("flags"));
6094514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> flagsResult(JSObject::GetProperty(thread, result1Handle, flags).GetValue());
6104514f5e3Sopenharmony_ci    JSHandle<EcmaString> expectResult = factory->NewFromASCII("dg");
6114514f5e3Sopenharmony_ci    ASSERT_EQ(EcmaStringAccessor::Compare(instance, JSHandle<EcmaString>(flagsResult), expectResult), 0);
6124514f5e3Sopenharmony_ci
6134514f5e3Sopenharmony_ci    // invoke GetHasIndices method
6144514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> hasIndices(factory->NewFromASCII("hasIndices"));
6154514f5e3Sopenharmony_ci    JSTaggedValue taggedHasIndicesResult =
6164514f5e3Sopenharmony_ci        JSObject::GetProperty(thread, result1Handle, hasIndices).GetValue().GetTaggedValue();
6174514f5e3Sopenharmony_ci    ASSERT_EQ(taggedHasIndicesResult.GetRawData(), JSTaggedValue::True().GetRawData());
6184514f5e3Sopenharmony_ci
6194514f5e3Sopenharmony_ci    JSHandle<EcmaString> inputString = factory->NewFromASCII("babcae");
6204514f5e3Sopenharmony_ci    auto ecmaRuntimeCallInfo =
6214514f5e3Sopenharmony_ci        TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); // 6 means 1 call arg
6224514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined());
6234514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetThis(result1Handle.GetTaggedValue());
6244514f5e3Sopenharmony_ci    ecmaRuntimeCallInfo->SetCallArg(0, inputString.GetTaggedValue());
6254514f5e3Sopenharmony_ci
6264514f5e3Sopenharmony_ci    [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo);
6274514f5e3Sopenharmony_ci    // invoke Exec method
6284514f5e3Sopenharmony_ci    JSTaggedValue results = BuiltinsRegExp::Exec(ecmaRuntimeCallInfo);
6294514f5e3Sopenharmony_ci    TestHelper::TearDownFrame(thread, prev);
6304514f5e3Sopenharmony_ci
6314514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> execResult(thread, results);
6324514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> indices(factory->NewFromASCII("indices"));
6334514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> indicesArr = JSObject::GetProperty(thread, execResult, indices).GetValue();
6344514f5e3Sopenharmony_ci    EXPECT_TRUE(indicesArr->IsJSArray());
6354514f5e3Sopenharmony_ci
6364514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> indices0 = JSObject::GetProperty(thread, indicesArr, 0).GetValue();
6374514f5e3Sopenharmony_ci    EXPECT_TRUE(indices0->IsJSArray());
6384514f5e3Sopenharmony_ci    // indices[0] [1, 2]
6394514f5e3Sopenharmony_ci    EXPECT_EQ(JSObject::GetProperty(thread, indices0, 0).GetValue()->GetInt(), 1);
6404514f5e3Sopenharmony_ci    EXPECT_EQ(JSObject::GetProperty(thread, indices0, 1).GetValue()->GetInt(), 2);
6414514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> indices1 = JSObject::GetProperty(thread, indicesArr, 1).GetValue();
6424514f5e3Sopenharmony_ci    EXPECT_TRUE(indices1->IsJSArray());
6434514f5e3Sopenharmony_ci    // indices[1] [1, 2]
6444514f5e3Sopenharmony_ci    EXPECT_EQ(JSObject::GetProperty(thread, indices1, 0).GetValue()->GetInt(), 1);
6454514f5e3Sopenharmony_ci    EXPECT_EQ(JSObject::GetProperty(thread, indices1, 1).GetValue()->GetInt(), 2);
6464514f5e3Sopenharmony_ci
6474514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> groups(factory->NewFromASCII("groups"));
6484514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> groupsObj = JSObject::GetProperty(thread, indicesArr, groups).GetValue();
6494514f5e3Sopenharmony_ci    EXPECT_TRUE(groupsObj->IsJSObject());
6504514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> groupName(factory->NewFromASCII("groupname"));
6514514f5e3Sopenharmony_ci    JSHandle<JSTaggedValue> groupNameArr = JSObject::GetProperty(thread, groupsObj, groupName).GetValue();
6524514f5e3Sopenharmony_ci    EXPECT_TRUE(groupNameArr->IsJSArray());
6534514f5e3Sopenharmony_ci    // {groupname: [1,2]]}
6544514f5e3Sopenharmony_ci    EXPECT_EQ(JSObject::GetProperty(thread, groupNameArr, 0).GetValue()->GetInt(), 1);
6554514f5e3Sopenharmony_ci    EXPECT_EQ(JSObject::GetProperty(thread, groupNameArr, 1).GetValue()->GetInt(), 2);
6564514f5e3Sopenharmony_ci}
6574514f5e3Sopenharmony_ci}  // namespace panda::test
658