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/builtins/builtins_errors.h" 174514f5e3Sopenharmony_ci 184514f5e3Sopenharmony_ci#include "ecmascript/base/error_helper.h" 194514f5e3Sopenharmony_ci#include "ecmascript/ecma_string.h" 204514f5e3Sopenharmony_ci#include "ecmascript/ecma_vm.h" 214514f5e3Sopenharmony_ci#include "ecmascript/global_env.h" 224514f5e3Sopenharmony_ci 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-inl.h" 274514f5e3Sopenharmony_ci 284514f5e3Sopenharmony_ci#include "ecmascript/js_thread.h" 294514f5e3Sopenharmony_ci#include "ecmascript/object_factory.h" 304514f5e3Sopenharmony_ci#include "ecmascript/tests/test_helper.h" 314514f5e3Sopenharmony_ci 324514f5e3Sopenharmony_ciusing namespace panda::ecmascript; 334514f5e3Sopenharmony_ciusing namespace panda::ecmascript::builtins; 344514f5e3Sopenharmony_ci 354514f5e3Sopenharmony_cinamespace panda::test { 364514f5e3Sopenharmony_ciusing Error = ecmascript::builtins::BuiltinsError; 374514f5e3Sopenharmony_ciusing RangeError = builtins::BuiltinsRangeError; 384514f5e3Sopenharmony_ciusing ReferenceError = builtins::BuiltinsReferenceError; 394514f5e3Sopenharmony_ciusing TypeError = builtins::BuiltinsTypeError; 404514f5e3Sopenharmony_ciusing URIError = builtins::BuiltinsURIError; 414514f5e3Sopenharmony_ciusing EvalError = builtins::BuiltinsEvalError; 424514f5e3Sopenharmony_ciusing SyntaxError = builtins::BuiltinsSyntaxError; 434514f5e3Sopenharmony_ciusing AggregateError = builtins::BuiltinsAggregateError; 444514f5e3Sopenharmony_ciusing JSType = ecmascript::JSType; 454514f5e3Sopenharmony_ci 464514f5e3Sopenharmony_ciclass BuiltinsErrorsTest : public BaseTestWithScope<false> { 474514f5e3Sopenharmony_ci}; 484514f5e3Sopenharmony_ci 494514f5e3Sopenharmony_ci/* 504514f5e3Sopenharmony_ci * @tc.name: GetJSErrorObject 514514f5e3Sopenharmony_ci * @tc.desc: get JSError Object 524514f5e3Sopenharmony_ci * @tc.type: FUNC 534514f5e3Sopenharmony_ci */ 544514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, GetJSErrorObject) 554514f5e3Sopenharmony_ci{ 564514f5e3Sopenharmony_ci /** 574514f5e3Sopenharmony_ci * @tc.steps: step1. Create JSError object 584514f5e3Sopenharmony_ci */ 594514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 604514f5e3Sopenharmony_ci 614514f5e3Sopenharmony_ci JSHandle<JSObject> handleObj = factory->GetJSError(ErrorType::TYPE_ERROR); 624514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgKey(factory->NewFromASCII("message")); 634514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameKey = thread->GlobalConstants()->GetHandledNameString(); 644514f5e3Sopenharmony_ci 654514f5e3Sopenharmony_ci /** 664514f5e3Sopenharmony_ci * @tc.steps: step2. obtain JSError object prototype chain name property and message property 674514f5e3Sopenharmony_ci */ 684514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgValue( 694514f5e3Sopenharmony_ci JSObject::GetProperty(thread, JSHandle<JSTaggedValue>(handleObj), msgKey).GetValue()); 704514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, 714514f5e3Sopenharmony_ci JSHandle<EcmaString>(msgValue), factory->NewFromASCII("")), 0); 724514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameValue( 734514f5e3Sopenharmony_ci JSObject::GetProperty(thread, JSHandle<JSTaggedValue>(handleObj), nameKey).GetValue()); 744514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 754514f5e3Sopenharmony_ci factory->NewFromASCII("TypeError"), JSHandle<EcmaString>(nameValue)), 0); 764514f5e3Sopenharmony_ci} 774514f5e3Sopenharmony_ci 784514f5e3Sopenharmony_ci/* 794514f5e3Sopenharmony_ci * @tc.name: GetJSErrorWithMessage 804514f5e3Sopenharmony_ci * @tc.desc: Obtains the TypeError object. 814514f5e3Sopenharmony_ci * @tc.type: FUNC 824514f5e3Sopenharmony_ci */ 834514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, GetJSErrorWithMessage) 844514f5e3Sopenharmony_ci{ 854514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 864514f5e3Sopenharmony_ci 874514f5e3Sopenharmony_ci JSHandle<JSObject> handleObj = factory->GetJSError(ErrorType::TYPE_ERROR, "I am type error"); 884514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgKey(factory->NewFromASCII("message")); 894514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameKey = thread->GlobalConstants()->GetHandledNameString(); 904514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgValue( 914514f5e3Sopenharmony_ci JSObject::GetProperty(thread, JSHandle<JSTaggedValue>(handleObj), msgKey).GetValue()); 924514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 934514f5e3Sopenharmony_ci factory->NewFromASCII("I am type error"), JSHandle<EcmaString>(msgValue)), 0); 944514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameValue( 954514f5e3Sopenharmony_ci JSObject::GetProperty(thread, JSHandle<JSTaggedValue>(handleObj), nameKey).GetValue()); 964514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 974514f5e3Sopenharmony_ci factory->NewFromASCII("TypeError"), JSHandle<EcmaString>(nameValue)), 0); 984514f5e3Sopenharmony_ci} 994514f5e3Sopenharmony_ci 1004514f5e3Sopenharmony_ci/* 1014514f5e3Sopenharmony_ci * @tc.name: ErrorNoParameterConstructor 1024514f5e3Sopenharmony_ci * @tc.desc: new Error() 1034514f5e3Sopenharmony_ci * @tc.type: FUNC 1044514f5e3Sopenharmony_ci */ 1054514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, ErrorNoParameterConstructor) 1064514f5e3Sopenharmony_ci{ 1074514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 1084514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 1094514f5e3Sopenharmony_ci 1104514f5e3Sopenharmony_ci JSHandle<JSFunction> error(env->GetErrorFunction()); 1114514f5e3Sopenharmony_ci 1124514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 4); 1134514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(error.GetTaggedValue()); 1144514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 1154514f5e3Sopenharmony_ci 1164514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 1174514f5e3Sopenharmony_ci JSTaggedValue result = Error::ErrorConstructor(ecmaRuntimeCallInfo); 1184514f5e3Sopenharmony_ci 1194514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsECMAObject()); 1204514f5e3Sopenharmony_ci 1214514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject(thread, reinterpret_cast<TaggedObject *>(result.GetRawData())); 1224514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgKey(factory->NewFromASCII("message")); 1234514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameKey = thread->GlobalConstants()->GetHandledNameString(); 1244514f5e3Sopenharmony_ci 1254514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgValue(JSObject::GetProperty(thread, errorObject, msgKey).GetValue()); 1264514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 1274514f5e3Sopenharmony_ci factory->NewFromASCII(""), JSHandle<EcmaString>(msgValue)), 0); 1284514f5e3Sopenharmony_ci 1294514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameValue(JSObject::GetProperty(thread, errorObject, nameKey).GetValue()); 1304514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 1314514f5e3Sopenharmony_ci factory->NewFromASCII("Error"), JSHandle<EcmaString>(nameValue)), 0); 1324514f5e3Sopenharmony_ci} 1334514f5e3Sopenharmony_ci 1344514f5e3Sopenharmony_ci/* 1354514f5e3Sopenharmony_ci * @tc.name: ErrorParameterConstructor 1364514f5e3Sopenharmony_ci * @tc.desc: new Error("Hello Error!") 1374514f5e3Sopenharmony_ci * @tc.type: FUNC 1384514f5e3Sopenharmony_ci */ 1394514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, ErrorParameterConstructor) 1404514f5e3Sopenharmony_ci{ 1414514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 1424514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 1434514f5e3Sopenharmony_ci 1444514f5e3Sopenharmony_ci JSHandle<JSFunction> error(env->GetErrorFunction()); 1454514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> paramMsg(factory->NewFromASCII("Hello Error!")); 1464514f5e3Sopenharmony_ci 1474514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 6); 1484514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(error.GetTaggedValue()); 1494514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 1504514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, paramMsg.GetTaggedValue()); 1514514f5e3Sopenharmony_ci 1524514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 1534514f5e3Sopenharmony_ci JSTaggedValue result = Error::ErrorConstructor(ecmaRuntimeCallInfo); 1544514f5e3Sopenharmony_ci 1554514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsECMAObject()); 1564514f5e3Sopenharmony_ci 1574514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject(thread, reinterpret_cast<TaggedObject *>(result.GetRawData())); 1584514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgKey(factory->NewFromASCII("message")); 1594514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameKey = thread->GlobalConstants()->GetHandledNameString(); 1604514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgValue(JSObject::GetProperty(thread, errorObject, msgKey).GetValue()); 1614514f5e3Sopenharmony_ci 1624514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 1634514f5e3Sopenharmony_ci factory->NewFromASCII("Hello Error!"), JSHandle<EcmaString>(msgValue)), 0); 1644514f5e3Sopenharmony_ci 1654514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameValue(JSObject::GetProperty(thread, errorObject, nameKey).GetValue()); 1664514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 1674514f5e3Sopenharmony_ci factory->NewFromASCII("Error"), JSHandle<EcmaString>(nameValue)), 0); 1684514f5e3Sopenharmony_ci} 1694514f5e3Sopenharmony_ci 1704514f5e3Sopenharmony_ci/* 1714514f5e3Sopenharmony_ci * @tc.name: ErrorNoParameterToString 1724514f5e3Sopenharmony_ci * @tc.desc: new Error().toString() 1734514f5e3Sopenharmony_ci * @tc.type: FUNC 1744514f5e3Sopenharmony_ci */ 1754514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, ErrorNoParameterToString) 1764514f5e3Sopenharmony_ci{ 1774514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 1784514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 1794514f5e3Sopenharmony_ci 1804514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject = env->GetErrorFunction(); 1814514f5e3Sopenharmony_ci JSHandle<JSObject> error = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(errorObject), errorObject); 1824514f5e3Sopenharmony_ci 1834514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); 1844514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 1854514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 1864514f5e3Sopenharmony_ci 1874514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 1884514f5e3Sopenharmony_ci JSTaggedValue result = Error::ToString(ecmaRuntimeCallInfo); 1894514f5e3Sopenharmony_ci 1904514f5e3Sopenharmony_ci JSHandle<EcmaString> resultHandle(thread, reinterpret_cast<EcmaString *>(result.GetRawData())); 1914514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsString()); 1924514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, factory->NewFromASCII("Error"), resultHandle), 0); 1934514f5e3Sopenharmony_ci} 1944514f5e3Sopenharmony_ci 1954514f5e3Sopenharmony_ci/* 1964514f5e3Sopenharmony_ci * @tc.name: ErrorToString 1974514f5e3Sopenharmony_ci * @tc.desc: new Error("This is Error!").toString() 1984514f5e3Sopenharmony_ci * @tc.type: FUNC 1994514f5e3Sopenharmony_ci */ 2004514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, ErrorToString) 2014514f5e3Sopenharmony_ci{ 2024514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 2034514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 2044514f5e3Sopenharmony_ci 2054514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject = env->GetErrorFunction(); 2064514f5e3Sopenharmony_ci JSHandle<JSObject> error = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(errorObject), errorObject); 2074514f5e3Sopenharmony_ci 2084514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> handleMsgKey(factory->NewFromASCII("message")); 2094514f5e3Sopenharmony_ci JSObject::SetProperty( 2104514f5e3Sopenharmony_ci thread, JSHandle<JSTaggedValue>(error), handleMsgKey, 2114514f5e3Sopenharmony_ci JSHandle<JSTaggedValue>(thread, factory->NewFromASCII("This is Error!").GetTaggedValue())); 2124514f5e3Sopenharmony_ci 2134514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); 2144514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 2154514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 2164514f5e3Sopenharmony_ci 2174514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 2184514f5e3Sopenharmony_ci JSTaggedValue result = Error::ToString(ecmaRuntimeCallInfo); 2194514f5e3Sopenharmony_ci 2204514f5e3Sopenharmony_ci JSHandle<EcmaString> resultHandle(thread, reinterpret_cast<EcmaString *>(result.GetRawData())); 2214514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsString()); 2224514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, factory->NewFromASCII("Error: This is Error!"), resultHandle), 0); 2234514f5e3Sopenharmony_ci} 2244514f5e3Sopenharmony_ci 2254514f5e3Sopenharmony_ci/* 2264514f5e3Sopenharmony_ci * @tc.name: RangeErrorNoParameterConstructor 2274514f5e3Sopenharmony_ci * @tc.desc: new RangeError() 2284514f5e3Sopenharmony_ci * @tc.type: FUNC 2294514f5e3Sopenharmony_ci */ 2304514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, RangeErrorNoParameterConstructor) 2314514f5e3Sopenharmony_ci{ 2324514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 2334514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 2344514f5e3Sopenharmony_ci 2354514f5e3Sopenharmony_ci JSHandle<JSFunction> error(env->GetRangeErrorFunction()); 2364514f5e3Sopenharmony_ci 2374514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); 2384514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(error.GetTaggedValue()); 2394514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 2404514f5e3Sopenharmony_ci 2414514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 2424514f5e3Sopenharmony_ci JSTaggedValue result = RangeError::RangeErrorConstructor(ecmaRuntimeCallInfo); 2434514f5e3Sopenharmony_ci 2444514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsECMAObject()); 2454514f5e3Sopenharmony_ci 2464514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject(thread, reinterpret_cast<TaggedObject *>(result.GetRawData())); 2474514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgKey(factory->NewFromASCII("message")); 2484514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameKey = thread->GlobalConstants()->GetHandledNameString(); 2494514f5e3Sopenharmony_ci 2504514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgValue(JSObject::GetProperty(thread, errorObject, msgKey).GetValue()); 2514514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 2524514f5e3Sopenharmony_ci factory->NewFromASCII(""), JSHandle<EcmaString>(msgValue)), 0); 2534514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameValue(JSObject::GetProperty(thread, errorObject, nameKey).GetValue()); 2544514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 2554514f5e3Sopenharmony_ci factory->NewFromASCII("RangeError"), JSHandle<EcmaString>(nameValue)), 0); 2564514f5e3Sopenharmony_ci} 2574514f5e3Sopenharmony_ci 2584514f5e3Sopenharmony_ci/* 2594514f5e3Sopenharmony_ci * @tc.name: RangeErrorParameterConstructor 2604514f5e3Sopenharmony_ci * @tc.desc: new RangeError("Hello RangeError!") 2614514f5e3Sopenharmony_ci * @tc.type: FUNC 2624514f5e3Sopenharmony_ci */ 2634514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, RangeErrorParameterConstructor) 2644514f5e3Sopenharmony_ci{ 2654514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 2664514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 2674514f5e3Sopenharmony_ci 2684514f5e3Sopenharmony_ci JSHandle<JSFunction> error(env->GetRangeErrorFunction()); 2694514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> paramMsg(factory->NewFromASCII("Hello RangeError!")); 2704514f5e3Sopenharmony_ci 2714514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 6); 2724514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(error.GetTaggedValue()); 2734514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 2744514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, paramMsg.GetTaggedValue()); 2754514f5e3Sopenharmony_ci 2764514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 2774514f5e3Sopenharmony_ci JSTaggedValue result = RangeError::RangeErrorConstructor(ecmaRuntimeCallInfo); 2784514f5e3Sopenharmony_ci 2794514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsECMAObject()); 2804514f5e3Sopenharmony_ci 2814514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject(thread, reinterpret_cast<TaggedObject *>(result.GetRawData())); 2824514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgKey(factory->NewFromASCII("message")); 2834514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameKey = thread->GlobalConstants()->GetHandledNameString(); 2844514f5e3Sopenharmony_ci 2854514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgValue(JSObject::GetProperty(thread, errorObject, msgKey).GetValue()); 2864514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 2874514f5e3Sopenharmony_ci factory->NewFromASCII("Hello RangeError!"), JSHandle<EcmaString>(msgValue)), 0); 2884514f5e3Sopenharmony_ci 2894514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameValue(JSObject::GetProperty(thread, errorObject, nameKey).GetValue()); 2904514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 2914514f5e3Sopenharmony_ci factory->NewFromASCII("RangeError"), JSHandle<EcmaString>(nameValue)), 0); 2924514f5e3Sopenharmony_ci} 2934514f5e3Sopenharmony_ci 2944514f5e3Sopenharmony_ci/* 2954514f5e3Sopenharmony_ci * @tc.name: RangeErrorNoParameterToString 2964514f5e3Sopenharmony_ci * @tc.desc: new RangeError().toString() 2974514f5e3Sopenharmony_ci * @tc.type: FUNC 2984514f5e3Sopenharmony_ci */ 2994514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, RangeErrorNoParameterToString) 3004514f5e3Sopenharmony_ci{ 3014514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 3024514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 3034514f5e3Sopenharmony_ci 3044514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject = env->GetRangeErrorFunction(); 3054514f5e3Sopenharmony_ci JSHandle<JSObject> error = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(errorObject), errorObject); 3064514f5e3Sopenharmony_ci 3074514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); 3084514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 3094514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 3104514f5e3Sopenharmony_ci 3114514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 3124514f5e3Sopenharmony_ci JSTaggedValue result = RangeError::ToString(ecmaRuntimeCallInfo); 3134514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> resultHandle(thread, result); 3144514f5e3Sopenharmony_ci 3154514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsString()); 3164514f5e3Sopenharmony_ci 3174514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, 3184514f5e3Sopenharmony_ci factory->NewFromASCII("RangeError"), JSHandle<EcmaString>(resultHandle)), 0); 3194514f5e3Sopenharmony_ci} 3204514f5e3Sopenharmony_ci 3214514f5e3Sopenharmony_ci/* 3224514f5e3Sopenharmony_ci * @tc.name: RangeErrorToString 3234514f5e3Sopenharmony_ci * @tc.desc: new RangeError("This is RangeError!").toString() 3244514f5e3Sopenharmony_ci * @tc.type: FUNC 3254514f5e3Sopenharmony_ci */ 3264514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, RangeErrorToString) 3274514f5e3Sopenharmony_ci{ 3284514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 3294514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 3304514f5e3Sopenharmony_ci 3314514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject = env->GetRangeErrorFunction(); 3324514f5e3Sopenharmony_ci JSHandle<JSObject> error = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(errorObject), errorObject); 3334514f5e3Sopenharmony_ci 3344514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> handleMsgKey(factory->NewFromASCII("message")); 3354514f5e3Sopenharmony_ci JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(error), handleMsgKey, 3364514f5e3Sopenharmony_ci JSHandle<JSTaggedValue>(factory->NewFromASCII("This is RangeError!"))); 3374514f5e3Sopenharmony_ci 3384514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); 3394514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 3404514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 3414514f5e3Sopenharmony_ci 3424514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 3434514f5e3Sopenharmony_ci JSTaggedValue result = RangeError::ToString(ecmaRuntimeCallInfo); 3444514f5e3Sopenharmony_ci 3454514f5e3Sopenharmony_ci JSHandle<EcmaString> resultHandle(thread, reinterpret_cast<EcmaString *>(result.GetRawData())); 3464514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsString()); 3474514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, 3484514f5e3Sopenharmony_ci factory->NewFromASCII("RangeError: This is RangeError!"), resultHandle), 0); 3494514f5e3Sopenharmony_ci} 3504514f5e3Sopenharmony_ci 3514514f5e3Sopenharmony_ci// new ReferenceError() 3524514f5e3Sopenharmony_ci/* 3534514f5e3Sopenharmony_ci * @tc.name: ReferenceErrorNoParameterConstructor 3544514f5e3Sopenharmony_ci * @tc.desc: new ReferenceError() 3554514f5e3Sopenharmony_ci * @tc.type: FUNC 3564514f5e3Sopenharmony_ci */ 3574514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, ReferenceErrorNoParameterConstructor) 3584514f5e3Sopenharmony_ci{ 3594514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 3604514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 3614514f5e3Sopenharmony_ci 3624514f5e3Sopenharmony_ci JSHandle<JSFunction> error(env->GetReferenceErrorFunction()); 3634514f5e3Sopenharmony_ci 3644514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 4); 3654514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(error.GetTaggedValue()); 3664514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 3674514f5e3Sopenharmony_ci 3684514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 3694514f5e3Sopenharmony_ci JSTaggedValue result = ReferenceError::ReferenceErrorConstructor(ecmaRuntimeCallInfo); 3704514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsECMAObject()); 3714514f5e3Sopenharmony_ci 3724514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject(thread, reinterpret_cast<TaggedObject *>(result.GetRawData())); 3734514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgKey(factory->NewFromASCII("message")); 3744514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameKey = thread->GlobalConstants()->GetHandledNameString(); 3754514f5e3Sopenharmony_ci 3764514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgValue(JSObject::GetProperty(thread, errorObject, msgKey).GetValue()); 3774514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 3784514f5e3Sopenharmony_ci factory->NewFromASCII(""), JSHandle<EcmaString>(msgValue)), 0); 3794514f5e3Sopenharmony_ci 3804514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameValue(JSObject::GetProperty(thread, errorObject, nameKey).GetValue()); 3814514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 3824514f5e3Sopenharmony_ci factory->NewFromASCII("ReferenceError"), JSHandle<EcmaString>(nameValue)), 0); 3834514f5e3Sopenharmony_ci} 3844514f5e3Sopenharmony_ci 3854514f5e3Sopenharmony_ci/* 3864514f5e3Sopenharmony_ci * @tc.name: ReferenceErrorParameterConstructor 3874514f5e3Sopenharmony_ci * @tc.desc: new ReferenceError("Hello RangeError!") 3884514f5e3Sopenharmony_ci * @tc.type: FUNC 3894514f5e3Sopenharmony_ci */ 3904514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, ReferenceErrorParameterConstructor) 3914514f5e3Sopenharmony_ci{ 3924514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 3934514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 3944514f5e3Sopenharmony_ci 3954514f5e3Sopenharmony_ci JSHandle<JSFunction> error(env->GetReferenceErrorFunction()); 3964514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> paramMsg(factory->NewFromASCII("Hello ReferenceError!")); 3974514f5e3Sopenharmony_ci 3984514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 6); 3994514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(error.GetTaggedValue()); 4004514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 4014514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, paramMsg.GetTaggedValue()); 4024514f5e3Sopenharmony_ci 4034514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 4044514f5e3Sopenharmony_ci JSTaggedValue result = ReferenceError::ReferenceErrorConstructor(ecmaRuntimeCallInfo); 4054514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsECMAObject()); 4064514f5e3Sopenharmony_ci 4074514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject(thread, reinterpret_cast<TaggedObject *>(result.GetRawData())); 4084514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgKey(factory->NewFromASCII("message")); 4094514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameKey = thread->GlobalConstants()->GetHandledNameString(); 4104514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgValue(JSObject::GetProperty(thread, errorObject, msgKey).GetValue()); 4114514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 4124514f5e3Sopenharmony_ci factory->NewFromASCII("Hello ReferenceError!"), JSHandle<EcmaString>(msgValue)), 0); 4134514f5e3Sopenharmony_ci 4144514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameValue(JSObject::GetProperty(thread, errorObject, nameKey).GetValue()); 4154514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 4164514f5e3Sopenharmony_ci factory->NewFromASCII("ReferenceError"), JSHandle<EcmaString>(nameValue)), 0); 4174514f5e3Sopenharmony_ci} 4184514f5e3Sopenharmony_ci 4194514f5e3Sopenharmony_ci/* 4204514f5e3Sopenharmony_ci * @tc.name: ReferenceErrorNoParameterToString 4214514f5e3Sopenharmony_ci * @tc.desc: new ReferenceError().toString() 4224514f5e3Sopenharmony_ci * @tc.type: FUNC 4234514f5e3Sopenharmony_ci */ 4244514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, ReferenceErrorNoParameterToString) 4254514f5e3Sopenharmony_ci{ 4264514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 4274514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 4284514f5e3Sopenharmony_ci 4294514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject = env->GetReferenceErrorFunction(); 4304514f5e3Sopenharmony_ci JSHandle<JSObject> error = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(errorObject), errorObject); 4314514f5e3Sopenharmony_ci 4324514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); 4334514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 4344514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 4354514f5e3Sopenharmony_ci 4364514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 4374514f5e3Sopenharmony_ci JSTaggedValue result = ReferenceError::ToString(ecmaRuntimeCallInfo); 4384514f5e3Sopenharmony_ci JSHandle<EcmaString> resultHandle(thread, reinterpret_cast<EcmaString *>(result.GetRawData())); 4394514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsString()); 4404514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, factory->NewFromASCII("ReferenceError"), resultHandle), 0); 4414514f5e3Sopenharmony_ci} 4424514f5e3Sopenharmony_ci 4434514f5e3Sopenharmony_ci/* 4444514f5e3Sopenharmony_ci * @tc.name: ReferenceErrorToString 4454514f5e3Sopenharmony_ci * @tc.desc: new ReferenceError("This is ReferenceError!").toString() 4464514f5e3Sopenharmony_ci * @tc.type: FUNC 4474514f5e3Sopenharmony_ci */ 4484514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, ReferenceErrorToString) 4494514f5e3Sopenharmony_ci{ 4504514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 4514514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 4524514f5e3Sopenharmony_ci 4534514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject = env->GetReferenceErrorFunction(); 4544514f5e3Sopenharmony_ci JSHandle<JSObject> error = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(errorObject), errorObject); 4554514f5e3Sopenharmony_ci 4564514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> handleMsgKey(factory->NewFromASCII("message")); 4574514f5e3Sopenharmony_ci JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(error), handleMsgKey, 4584514f5e3Sopenharmony_ci JSHandle<JSTaggedValue>(factory->NewFromASCII("This is ReferenceError!"))); 4594514f5e3Sopenharmony_ci 4604514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); 4614514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 4624514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 4634514f5e3Sopenharmony_ci 4644514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 4654514f5e3Sopenharmony_ci JSTaggedValue result = ReferenceError::ToString(ecmaRuntimeCallInfo); 4664514f5e3Sopenharmony_ci JSHandle<EcmaString> resultHandle(thread, reinterpret_cast<EcmaString *>(result.GetRawData())); 4674514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsString()); 4684514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, 4694514f5e3Sopenharmony_ci factory->NewFromASCII("ReferenceError: This is ReferenceError!"), resultHandle), 0); 4704514f5e3Sopenharmony_ci} 4714514f5e3Sopenharmony_ci 4724514f5e3Sopenharmony_ci/* 4734514f5e3Sopenharmony_ci * @tc.name: TypeErrorNoParameterConstructor 4744514f5e3Sopenharmony_ci * @tc.desc: new TypeError() 4754514f5e3Sopenharmony_ci * @tc.type: FUNC 4764514f5e3Sopenharmony_ci */ 4774514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, TypeErrorNoParameterConstructor) 4784514f5e3Sopenharmony_ci{ 4794514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 4804514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 4814514f5e3Sopenharmony_ci 4824514f5e3Sopenharmony_ci JSHandle<JSFunction> error(env->GetTypeErrorFunction()); 4834514f5e3Sopenharmony_ci 4844514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 4); 4854514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(error.GetTaggedValue()); 4864514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 4874514f5e3Sopenharmony_ci 4884514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 4894514f5e3Sopenharmony_ci JSTaggedValue result = TypeError::TypeErrorConstructor(ecmaRuntimeCallInfo); 4904514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsECMAObject()); 4914514f5e3Sopenharmony_ci 4924514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject(thread, reinterpret_cast<TaggedObject *>(result.GetRawData())); 4934514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgKey(factory->NewFromASCII("message")); 4944514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameKey = thread->GlobalConstants()->GetHandledNameString(); 4954514f5e3Sopenharmony_ci 4964514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgValue(JSObject::GetProperty(thread, errorObject, msgKey).GetValue()); 4974514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 4984514f5e3Sopenharmony_ci factory->NewFromASCII(""), JSHandle<EcmaString>(msgValue)), 0); 4994514f5e3Sopenharmony_ci 5004514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameValue(JSObject::GetProperty(thread, errorObject, nameKey).GetValue()); 5014514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, 5024514f5e3Sopenharmony_ci JSHandle<EcmaString>(nameValue), JSHandle<EcmaString>(nameValue)), 0); 5034514f5e3Sopenharmony_ci} 5044514f5e3Sopenharmony_ci 5054514f5e3Sopenharmony_ci/* 5064514f5e3Sopenharmony_ci * @tc.name: TypeErrorParameterConstructor 5074514f5e3Sopenharmony_ci * @tc.desc: new TypeError("Hello RangeError!") 5084514f5e3Sopenharmony_ci * @tc.type: FUNC 5094514f5e3Sopenharmony_ci */ 5104514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, TypeErrorParameterConstructor) 5114514f5e3Sopenharmony_ci{ 5124514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 5134514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 5144514f5e3Sopenharmony_ci 5154514f5e3Sopenharmony_ci JSHandle<JSFunction> error(env->GetTypeErrorFunction()); 5164514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> paramMsg(factory->NewFromASCII("Hello TypeError!")); 5174514f5e3Sopenharmony_ci 5184514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 6); 5194514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(error.GetTaggedValue()); 5204514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 5214514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, paramMsg.GetTaggedValue()); 5224514f5e3Sopenharmony_ci 5234514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 5244514f5e3Sopenharmony_ci JSTaggedValue result = TypeError::TypeErrorConstructor(ecmaRuntimeCallInfo); 5254514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsECMAObject()); 5264514f5e3Sopenharmony_ci 5274514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject(thread, reinterpret_cast<TaggedObject *>(result.GetRawData())); 5284514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgKey(factory->NewFromASCII("message")); 5294514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameKey = thread->GlobalConstants()->GetHandledNameString(); 5304514f5e3Sopenharmony_ci 5314514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgValue(JSObject::GetProperty(thread, errorObject, msgKey).GetValue()); 5324514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 5334514f5e3Sopenharmony_ci factory->NewFromASCII("Hello TypeError!"), JSHandle<EcmaString>(msgValue)), 0); 5344514f5e3Sopenharmony_ci 5354514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameValue(JSObject::GetProperty(thread, errorObject, nameKey).GetValue()); 5364514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 5374514f5e3Sopenharmony_ci factory->NewFromASCII("TypeError"), JSHandle<EcmaString>(nameValue)), 0); 5384514f5e3Sopenharmony_ci} 5394514f5e3Sopenharmony_ci 5404514f5e3Sopenharmony_ci/* 5414514f5e3Sopenharmony_ci * @tc.name: TypeErrorNoParameterToString 5424514f5e3Sopenharmony_ci * @tc.desc: new TypeError().toString() 5434514f5e3Sopenharmony_ci * @tc.type: FUNC 5444514f5e3Sopenharmony_ci */ 5454514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, TypeErrorNoParameterToString) 5464514f5e3Sopenharmony_ci{ 5474514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 5484514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 5494514f5e3Sopenharmony_ci 5504514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject = env->GetTypeErrorFunction(); 5514514f5e3Sopenharmony_ci JSHandle<JSObject> error = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(errorObject), errorObject); 5524514f5e3Sopenharmony_ci 5534514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); 5544514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 5554514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 5564514f5e3Sopenharmony_ci 5574514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 5584514f5e3Sopenharmony_ci JSTaggedValue result = TypeError::ToString(ecmaRuntimeCallInfo); 5594514f5e3Sopenharmony_ci JSHandle<EcmaString> resultHandle(thread, reinterpret_cast<EcmaString *>(result.GetRawData())); 5604514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsString()); 5614514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, factory->NewFromASCII("TypeError"), resultHandle), 0); 5624514f5e3Sopenharmony_ci} 5634514f5e3Sopenharmony_ci 5644514f5e3Sopenharmony_ci/* 5654514f5e3Sopenharmony_ci * @tc.name: TypeErrorToString 5664514f5e3Sopenharmony_ci * @tc.desc: new TypeError("This is TypeError!").toString() 5674514f5e3Sopenharmony_ci * @tc.type: FUNC 5684514f5e3Sopenharmony_ci */ 5694514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, TypeErrorToString) 5704514f5e3Sopenharmony_ci{ 5714514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 5724514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 5734514f5e3Sopenharmony_ci 5744514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject = env->GetTypeErrorFunction(); 5754514f5e3Sopenharmony_ci JSHandle<JSObject> error = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(errorObject), errorObject); 5764514f5e3Sopenharmony_ci 5774514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value(factory->NewFromASCII("This is TypeError!")); 5784514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> handleMsgKey(factory->NewFromASCII("message")); 5794514f5e3Sopenharmony_ci JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(error), handleMsgKey, value); 5804514f5e3Sopenharmony_ci 5814514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); 5824514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 5834514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 5844514f5e3Sopenharmony_ci 5854514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 5864514f5e3Sopenharmony_ci JSTaggedValue result = TypeError::ToString(ecmaRuntimeCallInfo); 5874514f5e3Sopenharmony_ci JSHandle<EcmaString> resultHandle(thread, reinterpret_cast<EcmaString *>(result.GetRawData())); 5884514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsString()); 5894514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, 5904514f5e3Sopenharmony_ci factory->NewFromASCII("TypeError: This is TypeError!"), resultHandle), 0); 5914514f5e3Sopenharmony_ci} 5924514f5e3Sopenharmony_ci 5934514f5e3Sopenharmony_ci/* 5944514f5e3Sopenharmony_ci * @tc.name: URIErrorNoParameterConstructor 5954514f5e3Sopenharmony_ci * @tc.desc: new URIError() 5964514f5e3Sopenharmony_ci * @tc.type: FUNC 5974514f5e3Sopenharmony_ci */ 5984514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, URIErrorNoParameterConstructor) 5994514f5e3Sopenharmony_ci{ 6004514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 6014514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 6024514f5e3Sopenharmony_ci 6034514f5e3Sopenharmony_ci JSHandle<JSFunction> error(env->GetURIErrorFunction()); 6044514f5e3Sopenharmony_ci 6054514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 4); 6064514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(error.GetTaggedValue()); 6074514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 6084514f5e3Sopenharmony_ci 6094514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 6104514f5e3Sopenharmony_ci JSTaggedValue result = URIError::URIErrorConstructor(ecmaRuntimeCallInfo); 6114514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsECMAObject()); 6124514f5e3Sopenharmony_ci 6134514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject(thread, reinterpret_cast<TaggedObject *>(result.GetRawData())); 6144514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgKey(factory->NewFromASCII("message")); 6154514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameKey = thread->GlobalConstants()->GetHandledNameString(); 6164514f5e3Sopenharmony_ci 6174514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgValue(JSObject::GetProperty(thread, errorObject, msgKey).GetValue()); 6184514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 6194514f5e3Sopenharmony_ci factory->NewFromASCII(""), JSHandle<EcmaString>(msgValue)), 0); 6204514f5e3Sopenharmony_ci 6214514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameValue(JSObject::GetProperty(thread, errorObject, nameKey).GetValue()); 6224514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 6234514f5e3Sopenharmony_ci factory->NewFromASCII("URIError"), JSHandle<EcmaString>(nameValue)), 0); 6244514f5e3Sopenharmony_ci} 6254514f5e3Sopenharmony_ci 6264514f5e3Sopenharmony_ci/* 6274514f5e3Sopenharmony_ci * @tc.name: URIErrorParameterConstructor 6284514f5e3Sopenharmony_ci * @tc.desc: new URIError("Hello RangeError!") 6294514f5e3Sopenharmony_ci * @tc.type: FUNC 6304514f5e3Sopenharmony_ci */ 6314514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, URIErrorParameterConstructor) 6324514f5e3Sopenharmony_ci{ 6334514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 6344514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 6354514f5e3Sopenharmony_ci 6364514f5e3Sopenharmony_ci JSHandle<JSFunction> error(env->GetURIErrorFunction()); 6374514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> paramMsg(factory->NewFromASCII("Hello URIError!")); 6384514f5e3Sopenharmony_ci 6394514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 6); 6404514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(error.GetTaggedValue()); 6414514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 6424514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, paramMsg.GetTaggedValue()); 6434514f5e3Sopenharmony_ci 6444514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 6454514f5e3Sopenharmony_ci JSTaggedValue result = URIError::URIErrorConstructor(ecmaRuntimeCallInfo); 6464514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsECMAObject()); 6474514f5e3Sopenharmony_ci 6484514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject(thread, reinterpret_cast<TaggedObject *>(result.GetRawData())); 6494514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgKey(factory->NewFromASCII("message")); 6504514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameKey = thread->GlobalConstants()->GetHandledNameString(); 6514514f5e3Sopenharmony_ci 6524514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgValue(JSObject::GetProperty(thread, errorObject, msgKey).GetValue()); 6534514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 6544514f5e3Sopenharmony_ci factory->NewFromASCII("Hello URIError!"), JSHandle<EcmaString>(msgValue)), 0); 6554514f5e3Sopenharmony_ci 6564514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameValue(JSObject::GetProperty(thread, errorObject, nameKey).GetValue()); 6574514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 6584514f5e3Sopenharmony_ci factory->NewFromASCII("URIError"), JSHandle<EcmaString>(nameValue)), 0); 6594514f5e3Sopenharmony_ci} 6604514f5e3Sopenharmony_ci 6614514f5e3Sopenharmony_ci/* 6624514f5e3Sopenharmony_ci * @tc.name: URIErrorNoParameterToString 6634514f5e3Sopenharmony_ci * @tc.desc: new URIError().toString() 6644514f5e3Sopenharmony_ci * @tc.type: FUNC 6654514f5e3Sopenharmony_ci */ 6664514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, URIErrorNoParameterToString) 6674514f5e3Sopenharmony_ci{ 6684514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 6694514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 6704514f5e3Sopenharmony_ci 6714514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject = env->GetURIErrorFunction(); 6724514f5e3Sopenharmony_ci JSHandle<JSObject> error = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(errorObject), errorObject); 6734514f5e3Sopenharmony_ci 6744514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); 6754514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 6764514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 6774514f5e3Sopenharmony_ci 6784514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 6794514f5e3Sopenharmony_ci JSTaggedValue result = URIError::ToString(ecmaRuntimeCallInfo); 6804514f5e3Sopenharmony_ci JSHandle<EcmaString> resultHandle(thread, reinterpret_cast<EcmaString *>(result.GetRawData())); 6814514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsString()); 6824514f5e3Sopenharmony_ci 6834514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, factory->NewFromASCII("URIError"), resultHandle), 0); 6844514f5e3Sopenharmony_ci} 6854514f5e3Sopenharmony_ci 6864514f5e3Sopenharmony_ci/* 6874514f5e3Sopenharmony_ci * @tc.name: URIErrorToString 6884514f5e3Sopenharmony_ci * @tc.desc: new URIError("This is URIError!").toString() 6894514f5e3Sopenharmony_ci * @tc.type: FUNC 6904514f5e3Sopenharmony_ci */ 6914514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, URIErrorToString) 6924514f5e3Sopenharmony_ci{ 6934514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 6944514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 6954514f5e3Sopenharmony_ci 6964514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject = env->GetURIErrorFunction(); 6974514f5e3Sopenharmony_ci JSHandle<JSObject> error = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(errorObject), errorObject); 6984514f5e3Sopenharmony_ci 6994514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> handleMsgKey(factory->NewFromASCII("message")); 7004514f5e3Sopenharmony_ci JSObject::SetProperty( 7014514f5e3Sopenharmony_ci thread, JSHandle<JSTaggedValue>(error), handleMsgKey, 7024514f5e3Sopenharmony_ci JSHandle<JSTaggedValue>(thread, factory->NewFromASCII("This is URIError!").GetTaggedValue())); 7034514f5e3Sopenharmony_ci 7044514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); 7054514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 7064514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 7074514f5e3Sopenharmony_ci 7084514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 7094514f5e3Sopenharmony_ci JSTaggedValue result = URIError::ToString(ecmaRuntimeCallInfo); 7104514f5e3Sopenharmony_ci JSHandle<EcmaString> resultHandle(thread, reinterpret_cast<EcmaString *>(result.GetRawData())); 7114514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsString()); 7124514f5e3Sopenharmony_ci 7134514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, 7144514f5e3Sopenharmony_ci factory->NewFromASCII("URIError: This is URIError!"), resultHandle), 0); 7154514f5e3Sopenharmony_ci} 7164514f5e3Sopenharmony_ci 7174514f5e3Sopenharmony_ci/* 7184514f5e3Sopenharmony_ci * @tc.name: SyntaxErrorNoParameterConstructor 7194514f5e3Sopenharmony_ci * @tc.desc: new SyntaxError() 7204514f5e3Sopenharmony_ci * @tc.type: FUNC 7214514f5e3Sopenharmony_ci */ 7224514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, SyntaxErrorNoParameterConstructor) 7234514f5e3Sopenharmony_ci{ 7244514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 7254514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 7264514f5e3Sopenharmony_ci 7274514f5e3Sopenharmony_ci JSHandle<JSFunction> error(env->GetSyntaxErrorFunction()); 7284514f5e3Sopenharmony_ci 7294514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 4); 7304514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(error.GetTaggedValue()); 7314514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 7324514f5e3Sopenharmony_ci 7334514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 7344514f5e3Sopenharmony_ci JSTaggedValue result = SyntaxError::SyntaxErrorConstructor(ecmaRuntimeCallInfo); 7354514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsECMAObject()); 7364514f5e3Sopenharmony_ci 7374514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject(thread, reinterpret_cast<TaggedObject *>(result.GetRawData())); 7384514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgKey(factory->NewFromASCII("message")); 7394514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameKey = thread->GlobalConstants()->GetHandledNameString(); 7404514f5e3Sopenharmony_ci 7414514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgValue(JSObject::GetProperty(thread, errorObject, msgKey).GetValue()); 7424514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 7434514f5e3Sopenharmony_ci factory->NewFromASCII(""), JSHandle<EcmaString>(msgValue)), 0); 7444514f5e3Sopenharmony_ci 7454514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameValue(JSObject::GetProperty(thread, errorObject, nameKey).GetValue()); 7464514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 7474514f5e3Sopenharmony_ci factory->NewFromASCII("SyntaxError"), JSHandle<EcmaString>(nameValue)), 0); 7484514f5e3Sopenharmony_ci} 7494514f5e3Sopenharmony_ci 7504514f5e3Sopenharmony_ci/* 7514514f5e3Sopenharmony_ci * @tc.name: SyntaxErrorParameterConstructor 7524514f5e3Sopenharmony_ci * @tc.desc: new SyntaxError("Hello RangeError!") 7534514f5e3Sopenharmony_ci * @tc.type: FUNC 7544514f5e3Sopenharmony_ci */ 7554514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, SyntaxErrorParameterConstructor) 7564514f5e3Sopenharmony_ci{ 7574514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 7584514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 7594514f5e3Sopenharmony_ci 7604514f5e3Sopenharmony_ci JSHandle<JSFunction> error(env->GetSyntaxErrorFunction()); 7614514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> paramMsg(factory->NewFromASCII("Hello SyntaxError!")); 7624514f5e3Sopenharmony_ci 7634514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 6); 7644514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(error.GetTaggedValue()); 7654514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 7664514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, paramMsg.GetTaggedValue()); 7674514f5e3Sopenharmony_ci 7684514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 7694514f5e3Sopenharmony_ci JSTaggedValue result = SyntaxError::SyntaxErrorConstructor(ecmaRuntimeCallInfo); 7704514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsECMAObject()); 7714514f5e3Sopenharmony_ci 7724514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject(thread, reinterpret_cast<TaggedObject *>(result.GetRawData())); 7734514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgKey(factory->NewFromASCII("message")); 7744514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameKey = thread->GlobalConstants()->GetHandledNameString(); 7754514f5e3Sopenharmony_ci 7764514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgValue(JSObject::GetProperty(thread, errorObject, msgKey).GetValue()); 7774514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 7784514f5e3Sopenharmony_ci factory->NewFromASCII("Hello SyntaxError!"), JSHandle<EcmaString>(msgValue)), 0); 7794514f5e3Sopenharmony_ci 7804514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameValue(JSObject::GetProperty(thread, errorObject, nameKey).GetValue()); 7814514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 7824514f5e3Sopenharmony_ci factory->NewFromASCII("SyntaxError"), JSHandle<EcmaString>(nameValue)), 0); 7834514f5e3Sopenharmony_ci} 7844514f5e3Sopenharmony_ci 7854514f5e3Sopenharmony_ci/* 7864514f5e3Sopenharmony_ci * @tc.name: SyntaxErrorNoParameterToString 7874514f5e3Sopenharmony_ci * @tc.desc: new SyntaxError().toString() 7884514f5e3Sopenharmony_ci * @tc.type: FUNC 7894514f5e3Sopenharmony_ci */ 7904514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, SyntaxErrorNoParameterToString) 7914514f5e3Sopenharmony_ci{ 7924514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 7934514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 7944514f5e3Sopenharmony_ci 7954514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject = env->GetSyntaxErrorFunction(); 7964514f5e3Sopenharmony_ci JSHandle<JSObject> error = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(errorObject), errorObject); 7974514f5e3Sopenharmony_ci 7984514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); 7994514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 8004514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 8014514f5e3Sopenharmony_ci 8024514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 8034514f5e3Sopenharmony_ci JSTaggedValue result = SyntaxError::ToString(ecmaRuntimeCallInfo); 8044514f5e3Sopenharmony_ci JSHandle<EcmaString> resultHandle(thread, reinterpret_cast<EcmaString *>(result.GetRawData())); 8054514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsString()); 8064514f5e3Sopenharmony_ci 8074514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, factory->NewFromASCII("SyntaxError"), resultHandle), 0); 8084514f5e3Sopenharmony_ci} 8094514f5e3Sopenharmony_ci 8104514f5e3Sopenharmony_ci/* 8114514f5e3Sopenharmony_ci * @tc.name: SyntaxErrorToString 8124514f5e3Sopenharmony_ci * @tc.desc: new SyntaxError("This is SyntaxError!").toString() 8134514f5e3Sopenharmony_ci * @tc.type: FUNC 8144514f5e3Sopenharmony_ci */ 8154514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, SyntaxErrorToString) 8164514f5e3Sopenharmony_ci{ 8174514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 8184514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 8194514f5e3Sopenharmony_ci 8204514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject = env->GetSyntaxErrorFunction(); 8214514f5e3Sopenharmony_ci JSHandle<JSObject> error = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(errorObject), errorObject); 8224514f5e3Sopenharmony_ci 8234514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> handleMsgKey(factory->NewFromASCII("message")); 8244514f5e3Sopenharmony_ci JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(error), handleMsgKey, 8254514f5e3Sopenharmony_ci JSHandle<JSTaggedValue>(factory->NewFromASCII("This is SyntaxError!"))); 8264514f5e3Sopenharmony_ci 8274514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); 8284514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 8294514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 8304514f5e3Sopenharmony_ci 8314514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 8324514f5e3Sopenharmony_ci JSTaggedValue result = SyntaxError::ToString(ecmaRuntimeCallInfo); 8334514f5e3Sopenharmony_ci JSHandle<EcmaString> resultHandle(thread, reinterpret_cast<EcmaString *>(result.GetRawData())); 8344514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsString()); 8354514f5e3Sopenharmony_ci 8364514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, 8374514f5e3Sopenharmony_ci factory->NewFromASCII("SyntaxError: This is SyntaxError!"), resultHandle), 0); 8384514f5e3Sopenharmony_ci} 8394514f5e3Sopenharmony_ci 8404514f5e3Sopenharmony_ci/* 8414514f5e3Sopenharmony_ci * @tc.name: EvalErrorNoParameterConstructor 8424514f5e3Sopenharmony_ci * @tc.desc: new EvalError() 8434514f5e3Sopenharmony_ci * @tc.type: FUNC 8444514f5e3Sopenharmony_ci */ 8454514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, EvalErrorNoParameterConstructor) 8464514f5e3Sopenharmony_ci{ 8474514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 8484514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 8494514f5e3Sopenharmony_ci 8504514f5e3Sopenharmony_ci JSHandle<JSFunction> error(env->GetEvalErrorFunction()); 8514514f5e3Sopenharmony_ci 8524514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 4); 8534514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(error.GetTaggedValue()); 8544514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 8554514f5e3Sopenharmony_ci 8564514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 8574514f5e3Sopenharmony_ci JSTaggedValue result = EvalError::EvalErrorConstructor(ecmaRuntimeCallInfo); 8584514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsECMAObject()); 8594514f5e3Sopenharmony_ci 8604514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject(thread, reinterpret_cast<TaggedObject *>(result.GetRawData())); 8614514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgKey(factory->NewFromASCII("message")); 8624514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameKey = thread->GlobalConstants()->GetHandledNameString(); 8634514f5e3Sopenharmony_ci 8644514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgValue(JSObject::GetProperty(thread, errorObject, msgKey).GetValue()); 8654514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 8664514f5e3Sopenharmony_ci factory->NewFromASCII(""), JSHandle<EcmaString>(msgValue)), 0); 8674514f5e3Sopenharmony_ci 8684514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameValue(JSObject::GetProperty(thread, errorObject, nameKey).GetValue()); 8694514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 8704514f5e3Sopenharmony_ci factory->NewFromASCII("EvalError"), JSHandle<EcmaString>(nameValue)), 0); 8714514f5e3Sopenharmony_ci} 8724514f5e3Sopenharmony_ci 8734514f5e3Sopenharmony_ci/* 8744514f5e3Sopenharmony_ci * @tc.name: EvalErrorParameterConstructor 8754514f5e3Sopenharmony_ci * @tc.desc: new EvalError("Hello RangeError!") 8764514f5e3Sopenharmony_ci * @tc.type: FUNC 8774514f5e3Sopenharmony_ci */ 8784514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, EvalErrorParameterConstructor) 8794514f5e3Sopenharmony_ci{ 8804514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 8814514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 8824514f5e3Sopenharmony_ci 8834514f5e3Sopenharmony_ci JSHandle<JSFunction> error(env->GetEvalErrorFunction()); 8844514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> paramMsg(factory->NewFromASCII("Hello EvalError!")); 8854514f5e3Sopenharmony_ci 8864514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 6); 8874514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(error.GetTaggedValue()); 8884514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 8894514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, paramMsg.GetTaggedValue()); 8904514f5e3Sopenharmony_ci 8914514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 8924514f5e3Sopenharmony_ci JSTaggedValue result = EvalError::EvalErrorConstructor(ecmaRuntimeCallInfo); 8934514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsECMAObject()); 8944514f5e3Sopenharmony_ci 8954514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject(thread, reinterpret_cast<TaggedObject *>(result.GetRawData())); 8964514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgKey(factory->NewFromASCII("message")); 8974514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameKey = thread->GlobalConstants()->GetHandledNameString(); 8984514f5e3Sopenharmony_ci 8994514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgValue(JSObject::GetProperty(thread, errorObject, msgKey).GetValue()); 9004514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 9014514f5e3Sopenharmony_ci factory->NewFromASCII("Hello EvalError!"), JSHandle<EcmaString>(msgValue)), 0); 9024514f5e3Sopenharmony_ci 9034514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameValue(JSObject::GetProperty(thread, errorObject, nameKey).GetValue()); 9044514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 9054514f5e3Sopenharmony_ci factory->NewFromASCII("EvalError"), JSHandle<EcmaString>(nameValue)), 0); 9064514f5e3Sopenharmony_ci} 9074514f5e3Sopenharmony_ci 9084514f5e3Sopenharmony_ci/* 9094514f5e3Sopenharmony_ci * @tc.name: EvalErrorNoParameterToString 9104514f5e3Sopenharmony_ci * @tc.desc: new EvalError().toString() 9114514f5e3Sopenharmony_ci * @tc.type: FUNC 9124514f5e3Sopenharmony_ci */ 9134514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, EvalErrorNoParameterToString) 9144514f5e3Sopenharmony_ci{ 9154514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 9164514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 9174514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject = env->GetEvalErrorFunction(); 9184514f5e3Sopenharmony_ci JSHandle<JSObject> error = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(errorObject), errorObject); 9194514f5e3Sopenharmony_ci 9204514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); 9214514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 9224514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 9234514f5e3Sopenharmony_ci 9244514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 9254514f5e3Sopenharmony_ci JSTaggedValue result = EvalError::ToString(ecmaRuntimeCallInfo); 9264514f5e3Sopenharmony_ci JSHandle<EcmaString> resultHandle(thread, reinterpret_cast<EcmaString *>(result.GetRawData())); 9274514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsString()); 9284514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, factory->NewFromASCII("EvalError"), resultHandle), 0); 9294514f5e3Sopenharmony_ci} 9304514f5e3Sopenharmony_ci 9314514f5e3Sopenharmony_ci/* 9324514f5e3Sopenharmony_ci * @tc.name: EvalErrorToString 9334514f5e3Sopenharmony_ci * @tc.desc: new EvalError("This is EvalError!").toString() 9344514f5e3Sopenharmony_ci * @tc.type: FUNC 9354514f5e3Sopenharmony_ci */ 9364514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, EvalErrorToString) 9374514f5e3Sopenharmony_ci{ 9384514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 9394514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 9404514f5e3Sopenharmony_ci 9414514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject = env->GetEvalErrorFunction(); 9424514f5e3Sopenharmony_ci JSHandle<JSObject> error = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(errorObject), errorObject); 9434514f5e3Sopenharmony_ci 9444514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> handleMsgKey(factory->NewFromASCII("message")); 9454514f5e3Sopenharmony_ci JSObject::SetProperty( 9464514f5e3Sopenharmony_ci thread, JSHandle<JSTaggedValue>(error), handleMsgKey, 9474514f5e3Sopenharmony_ci JSHandle<JSTaggedValue>(thread, factory->NewFromASCII("This is EvalError!").GetTaggedValue())); 9484514f5e3Sopenharmony_ci 9494514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); 9504514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 9514514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 9524514f5e3Sopenharmony_ci 9534514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 9544514f5e3Sopenharmony_ci JSTaggedValue result = EvalError::ToString(ecmaRuntimeCallInfo); 9554514f5e3Sopenharmony_ci JSHandle<EcmaString> resultHandle(thread, reinterpret_cast<EcmaString *>(result.GetRawData())); 9564514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsString()); 9574514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, 9584514f5e3Sopenharmony_ci factory->NewFromASCII("EvalError: This is EvalError!"), resultHandle), 0); 9594514f5e3Sopenharmony_ci} 9604514f5e3Sopenharmony_ci 9614514f5e3Sopenharmony_ci/* 9624514f5e3Sopenharmony_ci * @tc.name: AggregateErrorParameterConstructor 9634514f5e3Sopenharmony_ci * @tc.desc: new AggregateError([], "Hello AggregateError", {cause: "error cause"}) 9644514f5e3Sopenharmony_ci * @tc.type: FUNC 9654514f5e3Sopenharmony_ci */ 9664514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsErrorsTest, AggregateErrorParameterConstructor) 9674514f5e3Sopenharmony_ci{ 9684514f5e3Sopenharmony_ci ObjectFactory *factory = instance->GetFactory(); 9694514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = instance->GetGlobalEnv(); 9704514f5e3Sopenharmony_ci 9714514f5e3Sopenharmony_ci JSHandle<JSFunction> error(env->GetAggregateErrorFunction()); 9724514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> paramMsg(factory->NewFromASCII("Hello AggregateError!")); 9734514f5e3Sopenharmony_ci 9744514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errayFunc = env->GetArrayFunction(); 9754514f5e3Sopenharmony_ci JSHandle<JSObject> newArray = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(errayFunc), errayFunc); 9764514f5e3Sopenharmony_ci 9774514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> causeKey = thread->GlobalConstants()->GetHandledCauseString(); 9784514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> objFun = env->GetObjectFunction(); 9794514f5e3Sopenharmony_ci JSHandle<JSObject> optionsObj = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(objFun), objFun); 9804514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> causeValue(factory->NewFromASCII("error cause")); // test error cause 9814514f5e3Sopenharmony_ci JSObject::SetProperty(thread, optionsObj, causeKey, causeValue); 9824514f5e3Sopenharmony_ci 9834514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = 9844514f5e3Sopenharmony_ci TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 10); // 10 means 3 call args 9854514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(error.GetTaggedValue()); 9864514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue(*error)); 9874514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, newArray.GetTaggedValue()); 9884514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(1, paramMsg.GetTaggedValue()); 9894514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(2, optionsObj.GetTaggedValue()); // 2 means the options arg 9904514f5e3Sopenharmony_ci 9914514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 9924514f5e3Sopenharmony_ci JSTaggedValue result = AggregateError::AggregateErrorConstructor(ecmaRuntimeCallInfo); 9934514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsECMAObject()); 9944514f5e3Sopenharmony_ci 9954514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errorObject(thread, reinterpret_cast<TaggedObject *>(result.GetRawData())); 9964514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgKey(factory->NewFromASCII("message")); 9974514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameKey = thread->GlobalConstants()->GetHandledNameString(); 9984514f5e3Sopenharmony_ci 9994514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> msgValue(JSObject::GetProperty(thread, errorObject, msgKey).GetValue()); 10004514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 10014514f5e3Sopenharmony_ci factory->NewFromASCII("Hello AggregateError!"), JSHandle<EcmaString>(msgValue)), 0); 10024514f5e3Sopenharmony_ci 10034514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> nameValue(JSObject::GetProperty(thread, errorObject, nameKey).GetValue()); 10044514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 10054514f5e3Sopenharmony_ci factory->NewFromASCII("AggregateError"), JSHandle<EcmaString>(nameValue)), 0); 10064514f5e3Sopenharmony_ci 10074514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> errCauseValue(JSObject::GetProperty(thread, errorObject, causeKey).GetValue()); 10084514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 10094514f5e3Sopenharmony_ci factory->NewFromASCII("error cause"), JSHandle<EcmaString>(errCauseValue)), 0); 10104514f5e3Sopenharmony_ci} 10114514f5e3Sopenharmony_ci} // namespace panda::test 1012