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_reflect.h" 174514f5e3Sopenharmony_ci 184514f5e3Sopenharmony_ci#include "ecmascript/ecma_runtime_call_info.h" 194514f5e3Sopenharmony_ci#include "ecmascript/ecma_string.h" 204514f5e3Sopenharmony_ci#include "ecmascript/ecma_vm.h" 214514f5e3Sopenharmony_ci#include "ecmascript/global_env.h" 224514f5e3Sopenharmony_ci#include "ecmascript/js_array.h" 234514f5e3Sopenharmony_ci#include "ecmascript/js_function.h" 244514f5e3Sopenharmony_ci#include "ecmascript/js_object-inl.h" 254514f5e3Sopenharmony_ci#include "ecmascript/js_primitive_ref.h" 264514f5e3Sopenharmony_ci#include "ecmascript/tagged_array-inl.h" 274514f5e3Sopenharmony_ci#include "ecmascript/object_factory.h" 284514f5e3Sopenharmony_ci#include "ecmascript/tests/test_helper.h" 294514f5e3Sopenharmony_ci 304514f5e3Sopenharmony_ciusing namespace panda::ecmascript; 314514f5e3Sopenharmony_ciusing namespace panda::ecmascript::builtins; 324514f5e3Sopenharmony_ciusing BuiltinsBase = panda::ecmascript::base::BuiltinsBase; 334514f5e3Sopenharmony_ciusing JSArray = panda::ecmascript::JSArray; 344514f5e3Sopenharmony_ci 354514f5e3Sopenharmony_cinamespace panda::test { 364514f5e3Sopenharmony_ciclass BuiltinsReflectTest : public BaseTestWithScope<false> { 374514f5e3Sopenharmony_ci}; 384514f5e3Sopenharmony_ci 394514f5e3Sopenharmony_ci// use for create a JSObject of test 404514f5e3Sopenharmony_cistatic JSHandle<JSFunction> TestObjectCreate(JSThread *thread) 414514f5e3Sopenharmony_ci{ 424514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv(); 434514f5e3Sopenharmony_ci return JSHandle<JSFunction>::Cast(env->GetObjectFunction()); 444514f5e3Sopenharmony_ci} 454514f5e3Sopenharmony_ci 464514f5e3Sopenharmony_ci// native function for test Reflect.apply 474514f5e3Sopenharmony_ciJSTaggedValue TestReflectApply(EcmaRuntimeCallInfo *argv) 484514f5e3Sopenharmony_ci{ 494514f5e3Sopenharmony_ci auto thread = argv->GetThread(); 504514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 514514f5e3Sopenharmony_ci 524514f5e3Sopenharmony_ci int result = 0; 534514f5e3Sopenharmony_ci for (uint32_t index = 0; index < argv->GetArgsNumber(); ++index) { 544514f5e3Sopenharmony_ci result += BuiltinsBase::GetCallArg(argv, index).GetTaggedValue().GetInt(); 554514f5e3Sopenharmony_ci } 564514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> thisValue = BuiltinsBase::GetThis(argv); 574514f5e3Sopenharmony_ci 584514f5e3Sopenharmony_ci JSTaggedValue testA = JSObject::GetProperty(thread, thisValue, 594514f5e3Sopenharmony_ci JSHandle<JSTaggedValue>(factory->NewFromASCII("test_reflect_apply_a"))).GetValue().GetTaggedValue(); 604514f5e3Sopenharmony_ci JSTaggedValue testB = JSObject::GetProperty(thread, thisValue, 614514f5e3Sopenharmony_ci JSHandle<JSTaggedValue>(factory->NewFromASCII("test_reflect_apply_b"))).GetValue().GetTaggedValue(); 624514f5e3Sopenharmony_ci 634514f5e3Sopenharmony_ci result = result + testA.GetInt() + testB.GetInt(); 644514f5e3Sopenharmony_ci return BuiltinsBase::GetTaggedInt(result); 654514f5e3Sopenharmony_ci} 664514f5e3Sopenharmony_ci 674514f5e3Sopenharmony_ci// Reflect.apply (target, thisArgument, argumentsList) 684514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsReflectTest, ReflectApply) 694514f5e3Sopenharmony_ci{ 704514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv(); 714514f5e3Sopenharmony_ci 724514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 734514f5e3Sopenharmony_ci 744514f5e3Sopenharmony_ci // target 754514f5e3Sopenharmony_ci JSHandle<JSFunction> target = factory->NewJSFunction(env, reinterpret_cast<void *>(TestReflectApply)); 764514f5e3Sopenharmony_ci // thisArgument 774514f5e3Sopenharmony_ci JSHandle<JSObject> thisArgument = 784514f5e3Sopenharmony_ci factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle<JSTaggedValue>(TestObjectCreate(thread))); 794514f5e3Sopenharmony_ci JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(thisArgument), 804514f5e3Sopenharmony_ci JSHandle<JSTaggedValue>(factory->NewFromASCII("test_reflect_apply_a")), 814514f5e3Sopenharmony_ci JSHandle<JSTaggedValue>(thread, JSTaggedValue(11))); 824514f5e3Sopenharmony_ci JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(thisArgument), 834514f5e3Sopenharmony_ci JSHandle<JSTaggedValue>(factory->NewFromASCII("test_reflect_apply_b")), 844514f5e3Sopenharmony_ci JSHandle<JSTaggedValue>(thread, JSTaggedValue(22))); 854514f5e3Sopenharmony_ci // argumentsList 864514f5e3Sopenharmony_ci JSHandle<JSObject> argumentsList(JSArray::ArrayCreate(thread, JSTaggedNumber(2))); 874514f5e3Sopenharmony_ci PropertyDescriptor desc(thread, JSHandle<JSTaggedValue>(thread, JSTaggedValue(33))); 884514f5e3Sopenharmony_ci JSArray::DefineOwnProperty(thread, argumentsList, JSHandle<JSTaggedValue>(thread, JSTaggedValue(0)), desc); 894514f5e3Sopenharmony_ci 904514f5e3Sopenharmony_ci PropertyDescriptor desc1(thread, JSHandle<JSTaggedValue>(thread, JSTaggedValue(44))); 914514f5e3Sopenharmony_ci JSArray::DefineOwnProperty(thread, argumentsList, JSHandle<JSTaggedValue>(thread, JSTaggedValue(1)), desc1); 924514f5e3Sopenharmony_ci 934514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); 944514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 954514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue::Undefined()); 964514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, target.GetTaggedValue()); 974514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(1, JSTaggedValue(*thisArgument)); 984514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(2, JSTaggedValue(*argumentsList)); 994514f5e3Sopenharmony_ci 1004514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 1014514f5e3Sopenharmony_ci JSTaggedValue result = BuiltinsReflect::ReflectApply(ecmaRuntimeCallInfo); 1024514f5e3Sopenharmony_ci ASSERT_EQ(result.GetRawData(), JSTaggedValue(110).GetRawData()); 1034514f5e3Sopenharmony_ci 1044514f5e3Sopenharmony_ci JSObject::DeleteProperty(thread, (thisArgument), 1054514f5e3Sopenharmony_ci JSHandle<JSTaggedValue>(factory->NewFromASCII("test_reflect_apply_a"))); 1064514f5e3Sopenharmony_ci JSObject::DeleteProperty(thread, (thisArgument), 1074514f5e3Sopenharmony_ci JSHandle<JSTaggedValue>(factory->NewFromASCII("test_reflect_apply_b"))); 1084514f5e3Sopenharmony_ci TestHelper::TearDownFrame(thread, prev); 1094514f5e3Sopenharmony_ci} 1104514f5e3Sopenharmony_ci 1114514f5e3Sopenharmony_ci// Reflect.construct (target, argumentsList [ , newTarget]) 1124514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsReflectTest, ReflectConstruct) 1134514f5e3Sopenharmony_ci{ 1144514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv(); 1154514f5e3Sopenharmony_ci 1164514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 1174514f5e3Sopenharmony_ci 1184514f5e3Sopenharmony_ci // target 1194514f5e3Sopenharmony_ci JSHandle<JSFunction> target = JSHandle<JSFunction>::Cast(env->GetStringFunction()); 1204514f5e3Sopenharmony_ci // argumentsList 1214514f5e3Sopenharmony_ci JSHandle<JSObject> argumentsList(JSArray::ArrayCreate(thread, JSTaggedNumber(1))); 1224514f5e3Sopenharmony_ci PropertyDescriptor desc(thread, 1234514f5e3Sopenharmony_ci JSHandle<JSTaggedValue>::Cast(factory->NewFromASCII("ReflectConstruct"))); 1244514f5e3Sopenharmony_ci JSArray::DefineOwnProperty(thread, argumentsList, JSHandle<JSTaggedValue>(thread, JSTaggedValue(0)), desc); 1254514f5e3Sopenharmony_ci 1264514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); 1274514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 1284514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue::Undefined()); 1294514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, target.GetTaggedValue()); 1304514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(1, JSTaggedValue(*argumentsList)); 1314514f5e3Sopenharmony_ci 1324514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 1334514f5e3Sopenharmony_ci JSTaggedValue result = BuiltinsReflect::ReflectConstruct(ecmaRuntimeCallInfo); 1344514f5e3Sopenharmony_ci 1354514f5e3Sopenharmony_ci ASSERT_TRUE(result.IsECMAObject()); 1364514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> taggedResult(thread, result); 1374514f5e3Sopenharmony_ci JSHandle<JSPrimitiveRef> refResult = JSHandle<JSPrimitiveRef>::Cast(taggedResult); 1384514f5e3Sopenharmony_ci JSHandle<EcmaString> ruler = factory->NewFromASCII("ReflectConstruct"); 1394514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 1404514f5e3Sopenharmony_ci JSHandle<EcmaString>(thread, EcmaString::Cast(refResult->GetValue())), ruler), 0); 1414514f5e3Sopenharmony_ci TestHelper::TearDownFrame(thread, prev); 1424514f5e3Sopenharmony_ci} 1434514f5e3Sopenharmony_ci 1444514f5e3Sopenharmony_ci// Reflect.defineProperty (target, propertyKey, attributes) 1454514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsReflectTest, ReflectDefineProperty) 1464514f5e3Sopenharmony_ci{ 1474514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 1484514f5e3Sopenharmony_ci 1494514f5e3Sopenharmony_ci // target 1504514f5e3Sopenharmony_ci JSHandle<JSObject> target = 1514514f5e3Sopenharmony_ci factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle<JSTaggedValue>(TestObjectCreate(thread))); 1524514f5e3Sopenharmony_ci // propertyKey 1534514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> key(factory->NewFromASCII("test_reflect_define_property")); 1544514f5e3Sopenharmony_ci // attributes 1554514f5e3Sopenharmony_ci JSHandle<JSObject> attributes = 1564514f5e3Sopenharmony_ci factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle<JSTaggedValue>(TestObjectCreate(thread))); 1574514f5e3Sopenharmony_ci // attributes value 1584514f5e3Sopenharmony_ci auto globalConst = thread->GlobalConstants(); 1594514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> valueKey = globalConst->GetHandledValueString(); 1604514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value(thread, JSTaggedValue(100)); 1614514f5e3Sopenharmony_ci JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(attributes), valueKey, value); 1624514f5e3Sopenharmony_ci // attributes writable 1634514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> writableKey = globalConst->GetHandledWritableString(); 1644514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> writable(thread, JSTaggedValue::True()); 1654514f5e3Sopenharmony_ci JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(attributes), writableKey, writable); 1664514f5e3Sopenharmony_ci // attributes enumerable 1674514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> enumerableKey = globalConst->GetHandledEnumerableString(); 1684514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> enumerable(thread, JSTaggedValue::False()); 1694514f5e3Sopenharmony_ci JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(attributes), enumerableKey, enumerable); 1704514f5e3Sopenharmony_ci // attributes configurable 1714514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> configurableKey = globalConst->GetHandledConfigurableString(); 1724514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> configurable(thread, JSTaggedValue::True()); 1734514f5e3Sopenharmony_ci JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(attributes), configurableKey, configurable); 1744514f5e3Sopenharmony_ci 1754514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); 1764514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 1774514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue::Undefined()); 1784514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, target.GetTaggedValue()); 1794514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(1, key.GetTaggedValue()); 1804514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(2, JSTaggedValue(*attributes)); 1814514f5e3Sopenharmony_ci 1824514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 1834514f5e3Sopenharmony_ci JSTaggedValue result = BuiltinsReflect::ReflectDefineProperty(ecmaRuntimeCallInfo); 1844514f5e3Sopenharmony_ci ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); 1854514f5e3Sopenharmony_ci 1864514f5e3Sopenharmony_ci PropertyDescriptor descRuler(thread); 1874514f5e3Sopenharmony_ci JSObject::GetOwnProperty(thread, target, key, descRuler); 1884514f5e3Sopenharmony_ci ASSERT_EQ(descRuler.GetValue()->GetInt(), 100); 1894514f5e3Sopenharmony_ci ASSERT_EQ(descRuler.IsWritable(), true); 1904514f5e3Sopenharmony_ci ASSERT_EQ(descRuler.IsEnumerable(), false); 1914514f5e3Sopenharmony_ci ASSERT_EQ(descRuler.IsConfigurable(), true); 1924514f5e3Sopenharmony_ci TestHelper::TearDownFrame(thread, prev); 1934514f5e3Sopenharmony_ci} 1944514f5e3Sopenharmony_ci 1954514f5e3Sopenharmony_ci// Reflect.deleteProperty (target, propertyKey) 1964514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsReflectTest, ReflectDeleteProperty) 1974514f5e3Sopenharmony_ci{ 1984514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 1994514f5e3Sopenharmony_ci 2004514f5e3Sopenharmony_ci // target 2014514f5e3Sopenharmony_ci JSHandle<JSObject> target = 2024514f5e3Sopenharmony_ci factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle<JSTaggedValue>(TestObjectCreate(thread))); 2034514f5e3Sopenharmony_ci // propertyKey 2044514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> key(factory->NewFromASCII("test_reflect_delete_property")); 2054514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value(thread, JSTaggedValue(101)); 2064514f5e3Sopenharmony_ci JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(target), key, value); 2074514f5e3Sopenharmony_ci 2084514f5e3Sopenharmony_ci PropertyDescriptor desc(thread); 2094514f5e3Sopenharmony_ci ASSERT_EQ(JSObject::GetOwnProperty(thread, target, key, desc), true); 2104514f5e3Sopenharmony_ci 2114514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); 2124514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 2134514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue::Undefined()); 2144514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, target.GetTaggedValue()); 2154514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(1, key.GetTaggedValue()); 2164514f5e3Sopenharmony_ci 2174514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 2184514f5e3Sopenharmony_ci JSTaggedValue result = BuiltinsReflect::ReflectDeleteProperty(ecmaRuntimeCallInfo); 2194514f5e3Sopenharmony_ci ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); 2204514f5e3Sopenharmony_ci ASSERT_EQ(JSObject::GetOwnProperty(thread, target, key, desc), false); 2214514f5e3Sopenharmony_ci TestHelper::TearDownFrame(thread, prev); 2224514f5e3Sopenharmony_ci} 2234514f5e3Sopenharmony_ci 2244514f5e3Sopenharmony_ci// Reflect.get (target, propertyKey [ , receiver]) 2254514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsReflectTest, ReflectGet) 2264514f5e3Sopenharmony_ci{ 2274514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 2284514f5e3Sopenharmony_ci 2294514f5e3Sopenharmony_ci // target 2304514f5e3Sopenharmony_ci JSHandle<JSObject> target = 2314514f5e3Sopenharmony_ci factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle<JSTaggedValue>(TestObjectCreate(thread))); 2324514f5e3Sopenharmony_ci // propertyKey 2334514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> key(factory->NewFromASCII("test_reflect_get")); 2344514f5e3Sopenharmony_ci // set property 2354514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value(thread, JSTaggedValue(101.5)); 2364514f5e3Sopenharmony_ci JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(target), key, value); 2374514f5e3Sopenharmony_ci 2384514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); 2394514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 2404514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue::Undefined()); 2414514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, target.GetTaggedValue()); 2424514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(1, key.GetTaggedValue()); 2434514f5e3Sopenharmony_ci 2444514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 2454514f5e3Sopenharmony_ci JSTaggedValue result = BuiltinsReflect::ReflectGet(ecmaRuntimeCallInfo); 2464514f5e3Sopenharmony_ci 2474514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> resultValue(thread, result); 2484514f5e3Sopenharmony_ci ASSERT_EQ(resultValue->GetDouble(), 101.5); 2494514f5e3Sopenharmony_ci TestHelper::TearDownFrame(thread, prev); 2504514f5e3Sopenharmony_ci} 2514514f5e3Sopenharmony_ci 2524514f5e3Sopenharmony_ci// Reflect.getOwnPropertyDescriptor ( target, propertyKey ) 2534514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsReflectTest, ReflectGetOwnPropertyDescriptor) 2544514f5e3Sopenharmony_ci{ 2554514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 2564514f5e3Sopenharmony_ci 2574514f5e3Sopenharmony_ci // target 2584514f5e3Sopenharmony_ci JSHandle<JSObject> target = 2594514f5e3Sopenharmony_ci factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle<JSTaggedValue>(TestObjectCreate(thread))); 2604514f5e3Sopenharmony_ci // propertyKey 2614514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> key(factory->NewFromASCII("test_reflect_get_property_descriptor")); 2624514f5e3Sopenharmony_ci PropertyDescriptor desc(thread, JSHandle<JSTaggedValue>(thread, JSTaggedValue(102)), true, false, true); 2634514f5e3Sopenharmony_ci ASSERT_EQ(JSTaggedValue::DefinePropertyOrThrow(thread, JSHandle<JSTaggedValue>(target), key, desc), true); 2644514f5e3Sopenharmony_ci 2654514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); 2664514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 2674514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue::Undefined()); 2684514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, target.GetTaggedValue()); 2694514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(1, key.GetTaggedValue()); 2704514f5e3Sopenharmony_ci 2714514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 2724514f5e3Sopenharmony_ci JSTaggedValue result = BuiltinsReflect::ReflectGetOwnPropertyDescriptor(ecmaRuntimeCallInfo); 2734514f5e3Sopenharmony_ci 2744514f5e3Sopenharmony_ci ASSERT_TRUE(result.IsECMAObject()); 2754514f5e3Sopenharmony_ci 2764514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> resultObj(thread, result); 2774514f5e3Sopenharmony_ci // test value 2784514f5e3Sopenharmony_ci auto globalConst = thread->GlobalConstants(); 2794514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> valueKey = globalConst->GetHandledValueString(); 2804514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> resultValue = JSObject::GetProperty(thread, resultObj, valueKey).GetValue(); 2814514f5e3Sopenharmony_ci ASSERT_EQ(resultValue->GetInt(), 102); 2824514f5e3Sopenharmony_ci // test writable 2834514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> writableKey = globalConst->GetHandledWritableString(); 2844514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> resultWritable = JSObject::GetProperty(thread, resultObj, writableKey).GetValue(); 2854514f5e3Sopenharmony_ci ASSERT_EQ(resultWritable->ToBoolean(), true); 2864514f5e3Sopenharmony_ci // test enumerable 2874514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> enumerableKey = globalConst->GetHandledEnumerableString(); 2884514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> resultEnumerable = JSObject::GetProperty(thread, resultObj, enumerableKey).GetValue(); 2894514f5e3Sopenharmony_ci ASSERT_EQ(resultEnumerable->ToBoolean(), false); 2904514f5e3Sopenharmony_ci // test configurable 2914514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> configurableKey = globalConst->GetHandledConfigurableString(); 2924514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> resultConfigurable = JSObject::GetProperty(thread, resultObj, configurableKey).GetValue(); 2934514f5e3Sopenharmony_ci ASSERT_EQ(resultConfigurable->ToBoolean(), true); 2944514f5e3Sopenharmony_ci TestHelper::TearDownFrame(thread, prev); 2954514f5e3Sopenharmony_ci} 2964514f5e3Sopenharmony_ci 2974514f5e3Sopenharmony_ci// Reflect.getPrototypeOf (target) 2984514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsReflectTest, ReflectGetPrototypeOf) 2994514f5e3Sopenharmony_ci{ 3004514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 3014514f5e3Sopenharmony_ci 3024514f5e3Sopenharmony_ci JSHandle<JSObject> target = 3034514f5e3Sopenharmony_ci factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle<JSTaggedValue>(TestObjectCreate(thread))); 3044514f5e3Sopenharmony_ci JSHandle<JSObject> proto = 3054514f5e3Sopenharmony_ci factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle<JSTaggedValue>(TestObjectCreate(thread))); 3064514f5e3Sopenharmony_ci 3074514f5e3Sopenharmony_ci ASSERT_EQ(JSObject::SetPrototype(thread, target, JSHandle<JSTaggedValue>(proto)), true); 3084514f5e3Sopenharmony_ci 3094514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); 3104514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 3114514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue::Undefined()); 3124514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, target.GetTaggedValue()); 3134514f5e3Sopenharmony_ci 3144514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 3154514f5e3Sopenharmony_ci JSTaggedValue result = BuiltinsReflect::ReflectGetPrototypeOf(ecmaRuntimeCallInfo); 3164514f5e3Sopenharmony_ci ASSERT_TRUE(result.IsECMAObject()); 3174514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> resultObj(thread, JSTaggedValue(reinterpret_cast<TaggedObject *>(result.GetRawData()))); 3184514f5e3Sopenharmony_ci ASSERT_EQ(JSTaggedValue::SameValue(resultObj.GetTaggedValue(), proto.GetTaggedValue()), true); 3194514f5e3Sopenharmony_ci TestHelper::TearDownFrame(thread, prev); 3204514f5e3Sopenharmony_ci} 3214514f5e3Sopenharmony_ci 3224514f5e3Sopenharmony_ci// Reflect.has (target, propertyKey) 3234514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsReflectTest, ReflectHas) 3244514f5e3Sopenharmony_ci{ 3254514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 3264514f5e3Sopenharmony_ci 3274514f5e3Sopenharmony_ci // target 3284514f5e3Sopenharmony_ci JSHandle<JSObject> target = 3294514f5e3Sopenharmony_ci factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle<JSTaggedValue>(TestObjectCreate(thread))); 3304514f5e3Sopenharmony_ci // propertyKey 3314514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> key(factory->NewFromASCII("test_reflect_has")); 3324514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value(thread, JSTaggedValue(103)); 3334514f5e3Sopenharmony_ci ASSERT_EQ(JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(target), key, value), true); 3344514f5e3Sopenharmony_ci 3354514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); 3364514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 3374514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue::Undefined()); 3384514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, target.GetTaggedValue()); 3394514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(1, key.GetTaggedValue()); 3404514f5e3Sopenharmony_ci 3414514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 3424514f5e3Sopenharmony_ci JSTaggedValue result = BuiltinsReflect::ReflectHas(ecmaRuntimeCallInfo); 3434514f5e3Sopenharmony_ci 3444514f5e3Sopenharmony_ci ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); 3454514f5e3Sopenharmony_ci TestHelper::TearDownFrame(thread, prev); 3464514f5e3Sopenharmony_ci} 3474514f5e3Sopenharmony_ci 3484514f5e3Sopenharmony_ci// Reflect.isExtensible (target) 3494514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsReflectTest, ReflectIsExtensible) 3504514f5e3Sopenharmony_ci{ 3514514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 3524514f5e3Sopenharmony_ci 3534514f5e3Sopenharmony_ci // target 3544514f5e3Sopenharmony_ci JSHandle<JSObject> target = 3554514f5e3Sopenharmony_ci factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle<JSTaggedValue>(TestObjectCreate(thread))); 3564514f5e3Sopenharmony_ci target->GetJSHClass()->SetExtensible(false); 3574514f5e3Sopenharmony_ci 3584514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); 3594514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 3604514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue::Undefined()); 3614514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, target.GetTaggedValue()); 3624514f5e3Sopenharmony_ci 3634514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 3644514f5e3Sopenharmony_ci JSTaggedValue result = BuiltinsReflect::ReflectIsExtensible(ecmaRuntimeCallInfo); 3654514f5e3Sopenharmony_ci 3664514f5e3Sopenharmony_ci ASSERT_EQ(result.GetRawData(), JSTaggedValue::False().GetRawData()); 3674514f5e3Sopenharmony_ci TestHelper::TearDownFrame(thread, prev); 3684514f5e3Sopenharmony_ci} 3694514f5e3Sopenharmony_ci 3704514f5e3Sopenharmony_ci// Reflect.ownKeys (target) 3714514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsReflectTest, ReflectOwnKeys) 3724514f5e3Sopenharmony_ci{ 3734514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 3744514f5e3Sopenharmony_ci 3754514f5e3Sopenharmony_ci // target 3764514f5e3Sopenharmony_ci JSHandle<JSObject> target = 3774514f5e3Sopenharmony_ci factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle<JSTaggedValue>(TestObjectCreate(thread))); 3784514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> key0(factory->NewFromASCII("test_reflect_own_keys1")); 3794514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value0(thread, JSTaggedValue(104)); 3804514f5e3Sopenharmony_ci ASSERT_EQ(JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(target), key0, value0), true); 3814514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> key1(factory->NewFromASCII("test_reflect_own_keys2")); 3824514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value1(thread, JSTaggedValue(105)); 3834514f5e3Sopenharmony_ci ASSERT_EQ(JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(target), key1, value1), true); 3844514f5e3Sopenharmony_ci 3854514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); 3864514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 3874514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue::Undefined()); 3884514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, target.GetTaggedValue()); 3894514f5e3Sopenharmony_ci 3904514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 3914514f5e3Sopenharmony_ci JSTaggedValue result = BuiltinsReflect::ReflectOwnKeys(ecmaRuntimeCallInfo); 3924514f5e3Sopenharmony_ci 3934514f5e3Sopenharmony_ci ASSERT_TRUE(result.IsECMAObject()); 3944514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> resultTaggedValue(thread, reinterpret_cast<TaggedObject *>(result.GetRawData())); 3954514f5e3Sopenharmony_ci JSHandle<JSArray> resultArray = JSHandle<JSArray>::Cast(resultTaggedValue); 3964514f5e3Sopenharmony_ci // test length 3974514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> resultLengthKey = thread->GlobalConstants()->GetHandledLengthString(); 3984514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> resultLength = 3994514f5e3Sopenharmony_ci JSObject::GetProperty(thread, JSHandle<JSTaggedValue>(resultArray), resultLengthKey).GetValue(); 4004514f5e3Sopenharmony_ci ASSERT_EQ(resultLength->GetInt(), 2); 4014514f5e3Sopenharmony_ci // test array[0] 4024514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> resultKey0(thread, JSTaggedValue(0)); 4034514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> resultValue0 = 4044514f5e3Sopenharmony_ci JSObject::GetProperty(thread, JSHandle<JSTaggedValue>(resultArray), resultKey0).GetValue(); 4054514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 4064514f5e3Sopenharmony_ci JSHandle<EcmaString>(resultValue0), 4074514f5e3Sopenharmony_ci JSHandle<EcmaString>(key0)), 4084514f5e3Sopenharmony_ci 0); 4094514f5e3Sopenharmony_ci // test array[1] 4104514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> resultKey1(thread, JSTaggedValue(1)); 4114514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> resultValue1 = 4124514f5e3Sopenharmony_ci JSObject::GetProperty(thread, JSHandle<JSTaggedValue>(resultArray), resultKey1).GetValue(); 4134514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, 4144514f5e3Sopenharmony_ci JSHandle<EcmaString>(resultValue1), 4154514f5e3Sopenharmony_ci JSHandle<EcmaString>(key1)), 4164514f5e3Sopenharmony_ci 0); 4174514f5e3Sopenharmony_ci TestHelper::TearDownFrame(thread, prev); 4184514f5e3Sopenharmony_ci} 4194514f5e3Sopenharmony_ci 4204514f5e3Sopenharmony_ci// Reflect.preventExtensions (target) 4214514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsReflectTest, ReflectPreventExtensions) 4224514f5e3Sopenharmony_ci{ 4234514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 4244514f5e3Sopenharmony_ci 4254514f5e3Sopenharmony_ci // target 4264514f5e3Sopenharmony_ci JSHandle<JSObject> target = 4274514f5e3Sopenharmony_ci factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle<JSTaggedValue>(TestObjectCreate(thread))); 4284514f5e3Sopenharmony_ci target->GetJSHClass()->SetExtensible(true); 4294514f5e3Sopenharmony_ci 4304514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); 4314514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 4324514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue::Undefined()); 4334514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, target.GetTaggedValue()); 4344514f5e3Sopenharmony_ci 4354514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 4364514f5e3Sopenharmony_ci JSTaggedValue result = BuiltinsReflect::ReflectPreventExtensions(ecmaRuntimeCallInfo); 4374514f5e3Sopenharmony_ci 4384514f5e3Sopenharmony_ci ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); 4394514f5e3Sopenharmony_ci ASSERT_EQ(target->IsExtensible(), false); 4404514f5e3Sopenharmony_ci TestHelper::TearDownFrame(thread, prev); 4414514f5e3Sopenharmony_ci} 4424514f5e3Sopenharmony_ci 4434514f5e3Sopenharmony_ci// Reflect.set (target, propertyKey, V [ , receiver]) 4444514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsReflectTest, ReflectSet) 4454514f5e3Sopenharmony_ci{ 4464514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 4474514f5e3Sopenharmony_ci 4484514f5e3Sopenharmony_ci // target 4494514f5e3Sopenharmony_ci JSHandle<JSObject> target = 4504514f5e3Sopenharmony_ci factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle<JSTaggedValue>(TestObjectCreate(thread))); 4514514f5e3Sopenharmony_ci // propertyKey 4524514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> key(factory->NewFromASCII("test_reflect_set")); 4534514f5e3Sopenharmony_ci // value 4544514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value(thread, JSTaggedValue(106)); 4554514f5e3Sopenharmony_ci 4564514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); 4574514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 4584514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue::Undefined()); 4594514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, target.GetTaggedValue()); 4604514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(1, key.GetTaggedValue()); 4614514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(2, value.GetTaggedValue()); 4624514f5e3Sopenharmony_ci 4634514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 4644514f5e3Sopenharmony_ci JSTaggedValue result = BuiltinsReflect::ReflectSet(ecmaRuntimeCallInfo); 4654514f5e3Sopenharmony_ci 4664514f5e3Sopenharmony_ci ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); 4674514f5e3Sopenharmony_ci 4684514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> ruler = JSObject::GetProperty(thread, JSHandle<JSTaggedValue>(target), key).GetValue(); 4694514f5e3Sopenharmony_ci ASSERT_EQ(JSTaggedValue::ToInt32(thread, ruler), 106); 4704514f5e3Sopenharmony_ci TestHelper::TearDownFrame(thread, prev); 4714514f5e3Sopenharmony_ci} 4724514f5e3Sopenharmony_ci 4734514f5e3Sopenharmony_ci// Reflect.setPrototypeOf (target, proto) 4744514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsReflectTest, ReflectSetPrototypeOf) 4754514f5e3Sopenharmony_ci{ 4764514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 4774514f5e3Sopenharmony_ci 4784514f5e3Sopenharmony_ci JSHandle<JSObject> target = 4794514f5e3Sopenharmony_ci factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle<JSTaggedValue>(TestObjectCreate(thread))); 4804514f5e3Sopenharmony_ci JSHandle<JSObject> proto = 4814514f5e3Sopenharmony_ci factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle<JSTaggedValue>(TestObjectCreate(thread))); 4824514f5e3Sopenharmony_ci 4834514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); 4844514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 4854514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(JSTaggedValue::Undefined()); 4864514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(0, target.GetTaggedValue()); 4874514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(1, proto.GetTaggedValue()); 4884514f5e3Sopenharmony_ci 4894514f5e3Sopenharmony_ci [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 4904514f5e3Sopenharmony_ci JSTaggedValue result = BuiltinsReflect::ReflectSetPrototypeOf(ecmaRuntimeCallInfo); 4914514f5e3Sopenharmony_ci 4924514f5e3Sopenharmony_ci ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); 4934514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> resultObj(thread, target->GetJSHClass()->GetPrototype()); 4944514f5e3Sopenharmony_ci ASSERT_EQ(JSTaggedValue::SameValue(resultObj.GetTaggedValue(), proto.GetTaggedValue()), true); 4954514f5e3Sopenharmony_ci TestHelper::TearDownFrame(thread, prev); 4964514f5e3Sopenharmony_ci} 4974514f5e3Sopenharmony_ci} // namespace panda::test 498