diff --git a/tests/runtime/builtins/builtins_array_test.cpp b/tests/runtime/builtins/builtins_array_test.cpp index 7ba67a3868609521d4774d2b7761e909f693e91d..41fda17c84128eee3484f6c86af367bfa1dbf0bf 100644 --- a/tests/runtime/builtins/builtins_array_test.cpp +++ b/tests/runtime/builtins/builtins_array_test.cpp @@ -33,9 +33,12 @@ #include "plugins/ecmascript/tests/runtime/common/test_helper.h" #include "utils/bit_utils.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; -using namespace panda::ecmascript::base; + +// NOLINTBEGIN(readability-magic-numbers) namespace panda::test { class BuiltinsArrayTest : public testing::Test { @@ -52,18 +55,14 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; - class TestClass { public: static JSTaggedValue TestForEachFunc(EcmaRuntimeCallInfo *argv) @@ -165,9 +164,17 @@ public: return builtins_common::GetTaggedInt(accumulator); } }; + +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; -JSTaggedValue CreateBuiltinsJSObject(JSThread *thread, const PandaString key_c_str) +JSTaggedValue CreateBuiltinsJSObject(JSThread *thread, const PandaString &key_c_str) { EcmaVM *ecma_vm = thread->GetEcmaVM(); JSHandle global_env = ecma_vm->GetGlobalEnv(); @@ -184,611 +191,618 @@ JSTaggedValue CreateBuiltinsJSObject(JSThread *thread, const PandaString key_c_s TEST_F(BuiltinsArrayTest, ArrayConstructor) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle array(env->GetArrayFunction()); - JSHandle global_object(thread, env->GetGlobalObject()); + JSHandle global_object(thread_, env->GetGlobalObject()); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info1->SetFunction(array.GetTaggedValue()); ecma_runtime_call_info1->SetThis(global_object.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(static_cast(1))); ecma_runtime_call_info1->SetCallArg(1, JSTaggedValue(static_cast(3))); ecma_runtime_call_info1->SetCallArg(2, JSTaggedValue(static_cast(5))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::ArrayConstructor(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); JSTaggedValue value(static_cast(result.GetRawData())); ASSERT_TRUE(value.IsECMAObject()); - PropertyDescriptor desc_res(thread); - JSHandle value_handle(thread, value); - JSHandle key0(thread, JSTaggedValue(0)); - JSHandle key1(thread, JSTaggedValue(1)); - JSHandle key2(thread, JSTaggedValue(2)); - JSObject::GetOwnProperty(thread, value_handle, key0, desc_res); + PropertyDescriptor desc_res(thread_); + JSHandle value_handle(thread_, value); + JSHandle key0(thread_, JSTaggedValue(0)); + JSHandle key1(thread_, JSTaggedValue(1)); + JSHandle key2(thread_, JSTaggedValue(2)); + JSObject::GetOwnProperty(thread_, value_handle, key0, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(1)); - JSObject::GetOwnProperty(thread, value_handle, key1, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key1, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(3)); - JSObject::GetOwnProperty(thread, value_handle, key2, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key2, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(5)); } // 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) TEST_F(BuiltinsArrayTest, From) { - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0))->GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0))->GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - JSHandle key3(thread, JSTaggedValue(3)); - PropertyDescriptor desc3(thread, JSHandle(thread, JSTaggedValue(4)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key3, desc3); - JSHandle key4(thread, JSTaggedValue(4)); - PropertyDescriptor desc4(thread, JSHandle(thread, JSTaggedValue(5)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key4, desc4); - - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + JSHandle key3(thread_, JSTaggedValue(3)); + PropertyDescriptor desc3(thread_, JSHandle(thread_, JSTaggedValue(4)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key3, desc3); + JSHandle key4(thread_, JSTaggedValue(4)); + PropertyDescriptor desc4(thread_, JSHandle(thread_, JSTaggedValue(5)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key4, desc4); + + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::From(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); JSTaggedValue value(static_cast(result.GetRawData())); ASSERT_TRUE(value.IsECMAObject()); - PropertyDescriptor desc_res(thread); - JSHandle value_handle(thread, value); - JSObject::GetOwnProperty(thread, value_handle, key0, desc_res); + PropertyDescriptor desc_res(thread_); + JSHandle value_handle(thread_, value); + JSObject::GetOwnProperty(thread_, value_handle, key0, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(1)); - JSObject::GetOwnProperty(thread, value_handle, key1, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key1, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(2)); - JSObject::GetOwnProperty(thread, value_handle, key2, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key2, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(3)); - JSObject::GetOwnProperty(thread, value_handle, key3, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key3, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(4)); - JSObject::GetOwnProperty(thread, value_handle, key4, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key4, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(5)); } // 22.1.2.2 Array.isArray(arg) TEST_F(BuiltinsArrayTest, IsArray) { - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetCallArg(0, obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::IsArray(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetCallArg(0, JSTaggedValue(static_cast(1))); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); result = array::IsArray(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue::False().GetRawData()); } TEST_F(BuiltinsArrayTest, Of) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle array(env->GetArrayFunction()); - JSHandle global_object(thread, env->GetGlobalObject()); + JSHandle global_object(thread_, env->GetGlobalObject()); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info1->SetFunction(array.GetTaggedValue()); ecma_runtime_call_info1->SetThis(global_object.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(static_cast(1))); ecma_runtime_call_info1->SetCallArg(1, JSTaggedValue(static_cast(3))); ecma_runtime_call_info1->SetCallArg(2, JSTaggedValue(static_cast(5))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::Of(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); JSTaggedValue value(static_cast(result.GetRawData())); ASSERT_TRUE(value.IsECMAObject()); - PropertyDescriptor desc_res(thread); - JSHandle value_handle(thread, value); - JSHandle key0(thread, JSTaggedValue(0)); - JSHandle key1(thread, JSTaggedValue(1)); - JSHandle key2(thread, JSTaggedValue(2)); + PropertyDescriptor desc_res(thread_); + JSHandle value_handle(thread_, value); + JSHandle key0(thread_, JSTaggedValue(0)); + JSHandle key1(thread_, JSTaggedValue(1)); + JSHandle key2(thread_, JSTaggedValue(2)); - JSObject::GetOwnProperty(thread, value_handle, key0, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key0, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(1)); - JSObject::GetOwnProperty(thread, value_handle, key1, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key1, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(3)); - JSObject::GetOwnProperty(thread, value_handle, key2, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key2, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(5)); } TEST_F(BuiltinsArrayTest, Species) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle array(env->GetArrayFunction()); - JSHandle global_object(thread, env->GetGlobalObject()); + JSHandle global_object(thread_, env->GetGlobalObject()); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info1->SetFunction(array.GetTaggedValue()); ecma_runtime_call_info1->SetThis(global_object.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::GetSpecies(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsECMAObject()); } TEST_F(BuiltinsArrayTest, Concat) { - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - - JSArray *arr1 = JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetObject(); + JSHandle obj(thread_, arr); + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + + auto *arr1 = JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetObject(); EXPECT_TRUE(arr1 != nullptr); - JSHandle obj1(thread, arr1); - JSHandle key4(thread, JSTaggedValue(0)); - PropertyDescriptor desc4(thread, JSHandle(thread, JSTaggedValue(4)), true, true, true); - JSArray::DefineOwnProperty(thread, obj1, key4, desc4); - JSHandle key5(thread, JSTaggedValue(1)); - PropertyDescriptor desc5(thread, JSHandle(thread, JSTaggedValue(5)), true, true, true); - JSArray::DefineOwnProperty(thread, obj1, key5, desc5); - JSHandle key6(thread, JSTaggedValue(2)); - PropertyDescriptor desc6(thread, JSHandle(thread, JSTaggedValue(6)), true, true, true); - JSArray::DefineOwnProperty(thread, obj1, key6, desc6); - - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle obj1(thread_, arr1); + JSHandle key4(thread_, JSTaggedValue(0)); + PropertyDescriptor desc4(thread_, JSHandle(thread_, JSTaggedValue(4)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj1, key4, desc4); + JSHandle key5(thread_, JSTaggedValue(1)); + PropertyDescriptor desc5(thread_, JSHandle(thread_, JSTaggedValue(5)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj1, key5, desc5); + JSHandle key6(thread_, JSTaggedValue(2)); + PropertyDescriptor desc6(thread_, JSHandle(thread_, JSTaggedValue(6)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj1, key6, desc6); + + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, obj1.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::Concat(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); JSTaggedValue value(static_cast(result.GetRawData())); ASSERT_TRUE(value.IsECMAObject()); - PropertyDescriptor desc_res(thread); - JSHandle value_handle(thread, value); - JSHandle key7(thread, JSTaggedValue(5)); + PropertyDescriptor desc_res(thread_); + JSHandle value_handle(thread_, value); + JSHandle key7(thread_, JSTaggedValue(5)); EXPECT_EQ( - JSArray::GetProperty(thread, JSHandle(value_handle), length_key_handle).GetValue()->GetInt(), 6); - JSObject::GetOwnProperty(thread, value_handle, key7, desc_res); + JSArray::GetProperty(thread_, JSHandle(value_handle), length_key_handle).GetValue()->GetInt(), + 6); + JSObject::GetOwnProperty(thread_, value_handle, key7, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(6)); } // 22.1.3.3 new Array(1,2,3,4,5).CopyWithin(0,3,5) TEST_F(BuiltinsArrayTest, CopyWithin) { - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - JSHandle key3(thread, JSTaggedValue(3)); - PropertyDescriptor desc3(thread, JSHandle(thread, JSTaggedValue(4)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key3, desc3); - JSHandle key4(thread, JSTaggedValue(4)); - PropertyDescriptor desc4(thread, JSHandle(thread, JSTaggedValue(5)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key4, desc4); - - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + JSHandle key3(thread_, JSTaggedValue(3)); + PropertyDescriptor desc3(thread_, JSHandle(thread_, JSTaggedValue(4)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key3, desc3); + JSHandle key4(thread_, JSTaggedValue(4)); + PropertyDescriptor desc4(thread_, JSHandle(thread_, JSTaggedValue(5)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key4, desc4); + + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(static_cast(0))); ecma_runtime_call_info1->SetCallArg(1, JSTaggedValue(static_cast(3))); ecma_runtime_call_info1->SetCallArg(2, JSTaggedValue(static_cast(5))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::CopyWithin(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); JSTaggedValue value(static_cast(result.GetRawData())); ASSERT_TRUE(value.IsECMAObject()); - PropertyDescriptor desc_res(thread); - JSHandle value_handle(thread, value); - JSObject::GetOwnProperty(thread, value_handle, key0, desc_res); + PropertyDescriptor desc_res(thread_); + JSHandle value_handle(thread_, value); + JSObject::GetOwnProperty(thread_, value_handle, key0, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(4)); - JSObject::GetOwnProperty(thread, value_handle, key1, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key1, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(5)); - JSObject::GetOwnProperty(thread, value_handle, key2, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key2, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(3)); - JSObject::GetOwnProperty(thread, value_handle, key3, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key3, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(4)); - JSObject::GetOwnProperty(thread, value_handle, key4, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key4, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(5)); } TEST_F(BuiltinsArrayTest, Every) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - auto ecma_vm = thread->GetEcmaVM(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(100)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(100)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(200)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(300)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(200)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(300)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); JSHandle js_array = factory->NewJSArray(); JSHandle func = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestEveryFunc)); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, func.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(1, js_array.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result2 = array::proto::Every(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result2.GetRawData(), JSTaggedValue::True().GetRawData()); } TEST_F(BuiltinsArrayTest, Map) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); ObjectFactory *factory = ecma_vm->GetFactory(); - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(50)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(200)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - JSHandle js_array(JSArray::ArrayCreate(thread, JSTaggedNumber(0))); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(50)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(200)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + JSHandle js_array(JSArray::ArrayCreate(thread_, JSTaggedNumber(0))); JSHandle func = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestMapFunc)); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, func.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(1, js_array.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::Map(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); JSTaggedValue value(static_cast(result.GetRawData())); ASSERT_TRUE(value.IsECMAObject()); - PropertyDescriptor desc_res(thread); - JSHandle value_handle(thread, value); + PropertyDescriptor desc_res(thread_); + JSHandle value_handle(thread_, value); EXPECT_EQ( - JSArray::GetProperty(thread, JSHandle(value_handle), length_key_handle).GetValue()->GetInt(), 3); - JSObject::GetOwnProperty(thread, value_handle, key0, desc_res); + JSArray::GetProperty(thread_, JSHandle(value_handle), length_key_handle).GetValue()->GetInt(), + 3); + JSObject::GetOwnProperty(thread_, value_handle, key0, desc_res); ASSERT_EQ(desc_res.GetValue()->GetInt(), 100); - JSObject::GetOwnProperty(thread, value_handle, key1, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key1, desc_res); ASSERT_EQ(desc_res.GetValue()->GetInt(), 400); - JSObject::GetOwnProperty(thread, value_handle, key2, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key2, desc_res); ASSERT_EQ(desc_res.GetValue()->GetInt(), 6); } TEST_F(BuiltinsArrayTest, Reverse) { - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(50)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(200)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(50)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(200)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::Reverse(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); JSTaggedValue value(static_cast(result.GetRawData())); ASSERT_TRUE(value.IsECMAObject()); - PropertyDescriptor desc_res(thread); - JSHandle value_handle(thread, value); + PropertyDescriptor desc_res(thread_); + JSHandle value_handle(thread_, value); EXPECT_EQ( - JSArray::GetProperty(thread, JSHandle(value_handle), length_key_handle).GetValue()->GetInt(), 3); - JSObject::GetOwnProperty(thread, value_handle, key0, desc_res); + JSArray::GetProperty(thread_, JSHandle(value_handle), length_key_handle).GetValue()->GetInt(), + 3); + JSObject::GetOwnProperty(thread_, value_handle, key0, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(3)); - JSObject::GetOwnProperty(thread, value_handle, key1, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key1, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(200)); - JSObject::GetOwnProperty(thread, value_handle, key2, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key2, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(50)); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 3); - JSObject::GetOwnProperty(thread, obj, key0, desc_res); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 3); + JSObject::GetOwnProperty(thread_, obj, key0, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(3)); - JSObject::GetOwnProperty(thread, obj, key1, desc_res); + JSObject::GetOwnProperty(thread_, obj, key1, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(200)); - JSObject::GetOwnProperty(thread, obj, key2, desc_res); + JSObject::GetOwnProperty(thread_, obj, key2, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(50)); } TEST_F(BuiltinsArrayTest, Slice) { - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - JSHandle key3(thread, JSTaggedValue(3)); - PropertyDescriptor desc3(thread, JSHandle(thread, JSTaggedValue(4)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key3, desc3); - JSHandle key4(thread, JSTaggedValue(4)); - PropertyDescriptor desc4(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key4, desc4); - - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + JSHandle key3(thread_, JSTaggedValue(3)); + PropertyDescriptor desc3(thread_, JSHandle(thread_, JSTaggedValue(4)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key3, desc3); + JSHandle key4(thread_, JSTaggedValue(4)); + PropertyDescriptor desc4(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key4, desc4); + + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(static_cast(1))); ecma_runtime_call_info1->SetCallArg(1, JSTaggedValue(static_cast(4))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::Slice(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); JSTaggedValue value(static_cast(result.GetRawData())); ASSERT_TRUE(value.IsECMAObject()); - PropertyDescriptor desc_res(thread); - JSHandle value_handle(thread, value); + PropertyDescriptor desc_res(thread_); + JSHandle value_handle(thread_, value); EXPECT_EQ( - JSArray::GetProperty(thread, JSHandle(value_handle), length_key_handle).GetValue()->GetInt(), 3); - JSObject::GetOwnProperty(thread, value_handle, key0, desc_res); + JSArray::GetProperty(thread_, JSHandle(value_handle), length_key_handle).GetValue()->GetInt(), + 3); + JSObject::GetOwnProperty(thread_, value_handle, key0, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(2)); - JSObject::GetOwnProperty(thread, value_handle, key1, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key1, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(3)); - JSObject::GetOwnProperty(thread, value_handle, key2, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key2, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(4)); } TEST_F(BuiltinsArrayTest, Splice) { - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - JSHandle key3(thread, JSTaggedValue(3)); - PropertyDescriptor desc3(thread, JSHandle(thread, JSTaggedValue(4)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key3, desc3); - JSHandle key4(thread, JSTaggedValue(4)); - PropertyDescriptor desc4(thread, JSHandle(thread, JSTaggedValue(5)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key4, desc4); - - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + JSHandle key3(thread_, JSTaggedValue(3)); + PropertyDescriptor desc3(thread_, JSHandle(thread_, JSTaggedValue(4)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key3, desc3); + JSHandle key4(thread_, JSTaggedValue(4)); + PropertyDescriptor desc4(thread_, JSHandle(thread_, JSTaggedValue(5)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key4, desc4); + + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(static_cast(1))); ecma_runtime_call_info1->SetCallArg(1, JSTaggedValue(static_cast(2))); ecma_runtime_call_info1->SetCallArg(2, JSTaggedValue(static_cast(100))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::Splice(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); JSTaggedValue value(static_cast(result.GetRawData())); ASSERT_TRUE(value.IsECMAObject()); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 4); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 4); - PropertyDescriptor desc_res(thread); - JSHandle value_handle(thread, value); + PropertyDescriptor desc_res(thread_); + JSHandle value_handle(thread_, value); EXPECT_EQ( - JSArray::GetProperty(thread, JSHandle(value_handle), length_key_handle).GetValue()->GetInt(), 2); - JSObject::GetOwnProperty(thread, value_handle, key0, desc_res); + JSArray::GetProperty(thread_, JSHandle(value_handle), length_key_handle).GetValue()->GetInt(), + 2); + JSObject::GetOwnProperty(thread_, value_handle, key0, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(2)); } // ES2019 22.1.3.10 Builtin Array.flat() TEST_F(BuiltinsArrayTest, Flat) { - ASSERT_NE(thread, nullptr); - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); + ASSERT_NE(thread_, nullptr); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); - JSArray *arr1 = JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetObject(); - JSArray *arr2 = JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetObject(); - JSArray *arr3 = JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetObject(); + auto *arr1 = JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetObject(); + auto *arr2 = JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetObject(); + auto *arr3 = JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetObject(); EXPECT_TRUE(arr1 != nullptr); EXPECT_TRUE(arr2 != nullptr); EXPECT_TRUE(arr3 != nullptr); - JSHandle obj1(thread, arr1); - JSHandle obj2(thread, arr2); - JSHandle obj3(thread, arr3); + JSHandle obj1(thread_, arr1); + JSHandle obj2(thread_, arr2); + JSHandle obj3(thread_, arr3); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj1), length_key_handle).GetValue()->GetInt(), 0); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj2), length_key_handle).GetValue()->GetInt(), 0); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj3), length_key_handle).GetValue()->GetInt(), 0); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj1), length_key_handle).GetValue()->GetInt(), 0); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj2), length_key_handle).GetValue()->GetInt(), 0); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj3), length_key_handle).GetValue()->GetInt(), 0); - JSHandle key0(thread, JSTaggedValue(0)); - JSHandle key1(thread, JSTaggedValue(1)); - JSHandle key2(thread, JSTaggedValue(2)); + JSHandle key0(thread_, JSTaggedValue(0)); + JSHandle key1(thread_, JSTaggedValue(1)); + JSHandle key2(thread_, JSTaggedValue(2)); // arr1 = [0, 1, arr2] - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(0)), true, true, true); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - PropertyDescriptor desc_nested1(thread, JSHandle(thread, obj2.GetTaggedValue()), true, true, true); - JSArray::DefineOwnProperty(thread, obj1, key0, desc0); - JSArray::DefineOwnProperty(thread, obj1, key1, desc1); - JSArray::DefineOwnProperty(thread, obj1, key2, desc_nested1); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(0)), true, true, true); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + PropertyDescriptor desc_nested1(thread_, JSHandle(thread_, obj2.GetTaggedValue()), true, true, true); + JSArray::DefineOwnProperty(thread_, obj1, key0, desc0); + JSArray::DefineOwnProperty(thread_, obj1, key1, desc1); + JSArray::DefineOwnProperty(thread_, obj1, key2, desc_nested1); // arr2 = [2, 3, arr3] - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - PropertyDescriptor desc3(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - PropertyDescriptor desc_nested2(thread, JSHandle(thread, obj3.GetTaggedValue()), true, true, true); - JSArray::DefineOwnProperty(thread, obj2, key0, desc2); - JSArray::DefineOwnProperty(thread, obj2, key1, desc3); - JSArray::DefineOwnProperty(thread, obj2, key2, desc_nested2); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + PropertyDescriptor desc3(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + PropertyDescriptor desc_nested2(thread_, JSHandle(thread_, obj3.GetTaggedValue()), true, true, true); + JSArray::DefineOwnProperty(thread_, obj2, key0, desc2); + JSArray::DefineOwnProperty(thread_, obj2, key1, desc3); + JSArray::DefineOwnProperty(thread_, obj2, key2, desc_nested2); // arr3 = [4, 5] - PropertyDescriptor desc4(thread, JSHandle(thread, JSTaggedValue(4)), true, true, true); - PropertyDescriptor desc5(thread, JSHandle(thread, JSTaggedValue(5)), true, true, true); - JSArray::DefineOwnProperty(thread, obj3, key0, desc4); - JSArray::DefineOwnProperty(thread, obj3, key1, desc5); + PropertyDescriptor desc4(thread_, JSHandle(thread_, JSTaggedValue(4)), true, true, true); + PropertyDescriptor desc5(thread_, JSHandle(thread_, JSTaggedValue(5)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj3, key0, desc4); + JSArray::DefineOwnProperty(thread_, obj3, key1, desc5); // [0, 1, [2, 3, [4, 5]]].flat(2) = [0, 1, 2, 3, 4, 5] - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj1.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(static_cast(2))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::Flat(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - PropertyDescriptor desc_res(thread); + PropertyDescriptor desc_res(thread_); JSTaggedValue value(static_cast(result.GetRawData())); - JSHandle value_handle(thread, value); + JSHandle value_handle(thread_, value); EXPECT_EQ( - JSArray::GetProperty(thread, JSHandle(value_handle), length_key_handle).GetValue()->GetInt(), 6); + JSArray::GetProperty(thread_, JSHandle(value_handle), length_key_handle).GetValue()->GetInt(), + 6); - JSHandle key3(thread, JSTaggedValue(3)); - JSHandle key4(thread, JSTaggedValue(4)); - JSHandle key5(thread, JSTaggedValue(5)); + JSHandle key3(thread_, JSTaggedValue(3)); + JSHandle key4(thread_, JSTaggedValue(4)); + JSHandle key5(thread_, JSTaggedValue(5)); - JSObject::GetOwnProperty(thread, value_handle, key0, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key0, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(0)); - JSObject::GetOwnProperty(thread, value_handle, key1, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key1, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(1)); - JSObject::GetOwnProperty(thread, value_handle, key2, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key2, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(2)); - JSObject::GetOwnProperty(thread, value_handle, key3, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key3, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(3)); - JSObject::GetOwnProperty(thread, value_handle, key4, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key4, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(4)); - JSObject::GetOwnProperty(thread, value_handle, key5, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key5, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(5)); // [0, 1, [2, 3, [4, 5]]].flat() = [0, 1, 2, 3, [4, 5]] - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(obj1.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); result = array::proto::Flat(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); JSTaggedValue value2(static_cast(result.GetRawData())); - JSHandle value_handle2(thread, value2); + JSHandle value_handle2(thread_, value2); EXPECT_EQ( - JSArray::GetProperty(thread, JSHandle(value_handle2), length_key_handle).GetValue()->GetInt(), + JSArray::GetProperty(thread_, JSHandle(value_handle2), length_key_handle).GetValue()->GetInt(), 5); - JSObject::GetOwnProperty(thread, value_handle2, key0, desc_res); + JSObject::GetOwnProperty(thread_, value_handle2, key0, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(0)); - JSObject::GetOwnProperty(thread, value_handle2, key1, desc_res); + JSObject::GetOwnProperty(thread_, value_handle2, key1, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(1)); - JSObject::GetOwnProperty(thread, value_handle2, key2, desc_res); + JSObject::GetOwnProperty(thread_, value_handle2, key2, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(2)); - JSObject::GetOwnProperty(thread, value_handle2, key3, desc_res); + JSObject::GetOwnProperty(thread_, value_handle2, key3, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(3)); - JSObject::GetOwnProperty(thread, value_handle2, key4, desc_res); + JSObject::GetOwnProperty(thread_, value_handle2, key4, desc_res); ASSERT_TRUE(desc_res.GetValue().GetTaggedValue().IsECMAObject()); JSTaggedValue inner_arr_value(desc_res.GetValue().GetTaggedValue()); - JSHandle inner_arr_handle(thread, inner_arr_value); + JSHandle inner_arr_handle(thread_, inner_arr_value); - EXPECT_EQ( - JSArray::GetProperty(thread, JSHandle(inner_arr_handle), length_key_handle).GetValue()->GetInt(), - 2); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(inner_arr_handle), length_key_handle) + .GetValue() + ->GetInt(), + 2); - JSObject::GetOwnProperty(thread, inner_arr_handle, key0, desc_res); + JSObject::GetOwnProperty(thread_, inner_arr_handle, key0, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(4)); - JSObject::GetOwnProperty(thread, inner_arr_handle, key1, desc_res); + JSObject::GetOwnProperty(thread_, inner_arr_handle, key1, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(5)); } @@ -796,242 +810,243 @@ TEST_F(BuiltinsArrayTest, Flat) TEST_F(BuiltinsArrayTest, FlatMap) { // [[1], [2], [4]].flatMap(x => [x*2]) = [2, 4, 8] - ASSERT_NE(thread, nullptr); - auto ecma_vm = thread->GetEcmaVM(); + ASSERT_NE(thread_, nullptr); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); ObjectFactory *factory = ecma_vm->GetFactory(); - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetObject(); - JSArray *arr1 = JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetObject(); - JSArray *arr2 = JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetObject(); - JSArray *arr3 = JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetObject(); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + auto *arr = JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetObject(); + auto *arr1 = JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetObject(); + auto *arr2 = JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetObject(); + auto *arr3 = JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetObject(); EXPECT_TRUE(arr != nullptr); EXPECT_TRUE(arr1 != nullptr); EXPECT_TRUE(arr2 != nullptr); EXPECT_TRUE(arr3 != nullptr); - JSHandle obj(thread, arr); - JSHandle obj1(thread, arr1); - JSHandle obj2(thread, arr2); - JSHandle obj3(thread, arr3); + JSHandle obj(thread_, arr); + JSHandle obj1(thread_, arr1); + JSHandle obj2(thread_, arr2); + JSHandle obj3(thread_, arr3); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj1), length_key_handle).GetValue()->GetInt(), 0); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj2), length_key_handle).GetValue()->GetInt(), 0); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj3), length_key_handle).GetValue()->GetInt(), 0); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj1), length_key_handle).GetValue()->GetInt(), 0); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj2), length_key_handle).GetValue()->GetInt(), 0); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj3), length_key_handle).GetValue()->GetInt(), 0); // create [1], [2], [4] elements - JSHandle key0(thread, JSTaggedNumber(0)); - JSHandle key1(thread, JSTaggedNumber(1)); - JSHandle key2(thread, JSTaggedNumber(2)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - PropertyDescriptor desc4(thread, JSHandle(thread, JSTaggedValue(4)), true, true, true); - JSObject::DefineOwnProperty(thread, obj1, key0, desc1); - JSObject::DefineOwnProperty(thread, obj2, key0, desc2); - JSObject::DefineOwnProperty(thread, obj3, key0, desc4); + JSHandle key0(thread_, JSTaggedNumber(0)); + JSHandle key1(thread_, JSTaggedNumber(1)); + JSHandle key2(thread_, JSTaggedNumber(2)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + PropertyDescriptor desc4(thread_, JSHandle(thread_, JSTaggedValue(4)), true, true, true); + JSObject::DefineOwnProperty(thread_, obj1, key0, desc1); + JSObject::DefineOwnProperty(thread_, obj2, key0, desc2); + JSObject::DefineOwnProperty(thread_, obj3, key0, desc4); // arr = [[1], [2], [4]] - PropertyDescriptor obj_desc1(thread, JSHandle(thread, obj1.GetTaggedValue()), true, true, true); - PropertyDescriptor obj_desc2(thread, JSHandle(thread, obj2.GetTaggedValue()), true, true, true); - PropertyDescriptor obj_desc4(thread, JSHandle(thread, obj3.GetTaggedValue()), true, true, true); - JSObject::DefineOwnProperty(thread, obj, key0, obj_desc1); - JSObject::DefineOwnProperty(thread, obj, key1, obj_desc2); - JSObject::DefineOwnProperty(thread, obj, key2, obj_desc4); - - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj1), length_key_handle).GetValue()->GetInt(), 1); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj2), length_key_handle).GetValue()->GetInt(), 1); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj3), length_key_handle).GetValue()->GetInt(), 1); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 3); + PropertyDescriptor obj_desc1(thread_, JSHandle(thread_, obj1.GetTaggedValue()), true, true, true); + PropertyDescriptor obj_desc2(thread_, JSHandle(thread_, obj2.GetTaggedValue()), true, true, true); + PropertyDescriptor obj_desc4(thread_, JSHandle(thread_, obj3.GetTaggedValue()), true, true, true); + JSObject::DefineOwnProperty(thread_, obj, key0, obj_desc1); + JSObject::DefineOwnProperty(thread_, obj, key1, obj_desc2); + JSObject::DefineOwnProperty(thread_, obj, key2, obj_desc4); + + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj1), length_key_handle).GetValue()->GetInt(), 1); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj2), length_key_handle).GetValue()->GetInt(), 1); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj3), length_key_handle).GetValue()->GetInt(), 1); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 3); JSHandle cb = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestFlatMapFunc)); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, cb.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::FlatMap(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - PropertyDescriptor res_desc(thread); + PropertyDescriptor res_desc(thread_); JSTaggedValue value(static_cast(result.GetRawData())); - JSHandle value_handle(thread, value); + JSHandle value_handle(thread_, value); EXPECT_EQ( - JSArray::GetProperty(thread, JSHandle(value_handle), length_key_handle).GetValue()->GetInt(), 3); + JSArray::GetProperty(thread_, JSHandle(value_handle), length_key_handle).GetValue()->GetInt(), + 3); - JSObject::GetOwnProperty(thread, value_handle, key0, res_desc); + JSObject::GetOwnProperty(thread_, value_handle, key0, res_desc); ASSERT_EQ(res_desc.GetValue().GetTaggedValue(), JSTaggedValue(2)); - JSObject::GetOwnProperty(thread, value_handle, key1, res_desc); + JSObject::GetOwnProperty(thread_, value_handle, key1, res_desc); ASSERT_EQ(res_desc.GetValue().GetTaggedValue(), JSTaggedValue(4)); - JSObject::GetOwnProperty(thread, value_handle, key2, res_desc); + JSObject::GetOwnProperty(thread_, value_handle, key2, res_desc); ASSERT_EQ(res_desc.GetValue().GetTaggedValue(), JSTaggedValue(8)); } // 22.1.3.6 new Array(1,2,3,4,5).Fill(0,1,3) TEST_F(BuiltinsArrayTest, Fill) { - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - JSHandle key3(thread, JSTaggedValue(3)); - PropertyDescriptor desc3(thread, JSHandle(thread, JSTaggedValue(4)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key3, desc3); - JSHandle key4(thread, JSTaggedValue(4)); - PropertyDescriptor desc4(thread, JSHandle(thread, JSTaggedValue(5)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key4, desc4); - - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + JSHandle key3(thread_, JSTaggedValue(3)); + PropertyDescriptor desc3(thread_, JSHandle(thread_, JSTaggedValue(4)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key3, desc3); + JSHandle key4(thread_, JSTaggedValue(4)); + PropertyDescriptor desc4(thread_, JSHandle(thread_, JSTaggedValue(5)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key4, desc4); + + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(static_cast(0))); ecma_runtime_call_info1->SetCallArg(1, JSTaggedValue(static_cast(1))); ecma_runtime_call_info1->SetCallArg(2, JSTaggedValue(static_cast(3))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::Fill(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); JSTaggedValue value(static_cast(result.GetRawData())); ASSERT_TRUE(value.IsECMAObject()); - PropertyDescriptor desc_res(thread); - JSHandle value_handle(thread, value); - JSObject::GetOwnProperty(thread, value_handle, key0, desc_res); + PropertyDescriptor desc_res(thread_); + JSHandle value_handle(thread_, value); + JSObject::GetOwnProperty(thread_, value_handle, key0, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(1)); - JSObject::GetOwnProperty(thread, value_handle, key1, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key1, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(0)); - JSObject::GetOwnProperty(thread, value_handle, key2, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key2, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(0)); - JSObject::GetOwnProperty(thread, value_handle, key3, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key3, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(4)); - JSObject::GetOwnProperty(thread, value_handle, key4, desc_res); + JSObject::GetOwnProperty(thread_, value_handle, key4, desc_res); ASSERT_EQ(desc_res.GetValue().GetTaggedValue(), JSTaggedValue(5)); } TEST_F(BuiltinsArrayTest, Find) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); ObjectFactory *factory = ecma_vm->GetFactory(); - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(102)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - JSHandle js_array(JSArray::ArrayCreate(thread, JSTaggedNumber(0))); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(102)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + JSHandle js_array(JSArray::ArrayCreate(thread_, JSTaggedNumber(0))); JSHandle func = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestFindFunc)); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, func.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(1, js_array.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result2 = array::proto::Find(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_EQ(result2.GetRawData(), JSTaggedValue(102).GetRawData()); } TEST_F(BuiltinsArrayTest, FindIndex) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); ObjectFactory *factory = ecma_vm->GetFactory(); - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(30)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(30)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); - JSHandle js_array(JSArray::ArrayCreate(thread, JSTaggedNumber(0))); + JSHandle js_array(JSArray::ArrayCreate(thread_, JSTaggedNumber(0))); JSHandle func = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestFindIndexFunc)); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, func.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(1, js_array.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result2 = array::proto::FindIndex(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_EQ(result2.GetRawData(), JSTaggedValue(static_cast(2)).GetRawData()); } TEST_F(BuiltinsArrayTest, ForEach) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); ObjectFactory *factory = ecma_vm->GetFactory(); - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - - JSHandle js_array(JSArray::ArrayCreate(thread, JSTaggedNumber(0))); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + + JSHandle js_array(JSArray::ArrayCreate(thread_, JSTaggedNumber(0))); JSHandle func = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestForEachFunc)); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, func.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(1, js_array.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result2 = array::proto::ForEach(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_EQ(result2.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); EXPECT_EQ(js_array->GetArrayLength(), 3); } @@ -1039,652 +1054,652 @@ TEST_F(BuiltinsArrayTest, ForEach) // ES2021 23.1.3.13 new Array(1,2,3,4,3).includes(searchElement [ , fromIndex ]) TEST_F(BuiltinsArrayTest, Includes1) { - ASSERT_NE(thread, nullptr); + ASSERT_NE(thread_, nullptr); - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetHeapObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetHeapObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - JSHandle key3(thread, JSTaggedValue(3)); - PropertyDescriptor desc3(thread, JSHandle(thread, JSTaggedValue(4)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key3, desc3); - JSHandle key4(thread, JSTaggedValue(4)); - PropertyDescriptor desc4(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key4, desc4); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + JSHandle key3(thread_, JSTaggedValue(3)); + PropertyDescriptor desc3(thread_, JSHandle(thread_, JSTaggedValue(4)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key3, desc3); + JSHandle key4(thread_, JSTaggedValue(4)); + PropertyDescriptor desc4(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key4, desc4); // new Array(1,2,3,4,3).includes(1,0) - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(1))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(0))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = array::proto::Includes(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue(true).GetRawData()); } // ES2021 23.1.3.13 new Array(1,2,3,4,3).includes(searchElement [ , fromIndex ]) TEST_F(BuiltinsArrayTest, Includes2) { - ASSERT_NE(thread, nullptr); + ASSERT_NE(thread_, nullptr); - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetHeapObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetHeapObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - JSHandle key3(thread, JSTaggedValue(3)); - PropertyDescriptor desc3(thread, JSHandle(thread, JSTaggedValue(4)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key3, desc3); - JSHandle key4(thread, JSTaggedValue(4)); - PropertyDescriptor desc4(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key4, desc4); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + JSHandle key3(thread_, JSTaggedValue(3)); + PropertyDescriptor desc3(thread_, JSHandle(thread_, JSTaggedValue(4)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key3, desc3); + JSHandle key4(thread_, JSTaggedValue(4)); + PropertyDescriptor desc4(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key4, desc4); // new Array(1,2,3,4,3).includes(1,3) - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(1))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(3))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = array::proto::Includes(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue(false).GetRawData()); } // ES2021 23.1.3.13 new Array(1,2,3,4,3).includes(searchElement [ , fromIndex ]) TEST_F(BuiltinsArrayTest, Includes3) { - ASSERT_NE(thread, nullptr); + ASSERT_NE(thread_, nullptr); - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetHeapObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetHeapObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - JSHandle key3(thread, JSTaggedValue(3)); - PropertyDescriptor desc3(thread, JSHandle(thread, JSTaggedValue(4)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key3, desc3); - JSHandle key4(thread, JSTaggedValue(4)); - PropertyDescriptor desc4(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key4, desc4); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + JSHandle key3(thread_, JSTaggedValue(3)); + PropertyDescriptor desc3(thread_, JSHandle(thread_, JSTaggedValue(4)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key3, desc3); + JSHandle key4(thread_, JSTaggedValue(4)); + PropertyDescriptor desc4(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key4, desc4); // new Array(1,2,3,4,3).includes(5,0) - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(5))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(0))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = array::proto::Includes(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue(false).GetRawData()); } // ES2021 23.1.3.13 new Array(1,2,3,4,3).includes(searchElement [ , fromIndex ]) TEST_F(BuiltinsArrayTest, Includes4) { - ASSERT_NE(thread, nullptr); + ASSERT_NE(thread_, nullptr); - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetHeapObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetHeapObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - JSHandle key3(thread, JSTaggedValue(3)); - PropertyDescriptor desc3(thread, JSHandle(thread, JSTaggedValue(4)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key3, desc3); - JSHandle key4(thread, JSTaggedValue(4)); - PropertyDescriptor desc4(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key4, desc4); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + JSHandle key3(thread_, JSTaggedValue(3)); + PropertyDescriptor desc3(thread_, JSHandle(thread_, JSTaggedValue(4)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key3, desc3); + JSHandle key4(thread_, JSTaggedValue(4)); + PropertyDescriptor desc4(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key4, desc4); // new Array(1,2,3,4,3).includes(1) - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(1))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = array::proto::Includes(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue(true).GetRawData()); } // ES2021 23.1.3.13 new Array(1,2,3,4,3).includes(searchElement [ , fromIndex ]) TEST_F(BuiltinsArrayTest, Includes5) { - ASSERT_NE(thread, nullptr); + ASSERT_NE(thread_, nullptr); - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetHeapObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetHeapObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - JSHandle key3(thread, JSTaggedValue(3)); - PropertyDescriptor desc3(thread, JSHandle(thread, JSTaggedValue(4)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key3, desc3); - JSHandle key4(thread, JSTaggedValue(4)); - PropertyDescriptor desc4(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key4, desc4); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + JSHandle key3(thread_, JSTaggedValue(3)); + PropertyDescriptor desc3(thread_, JSHandle(thread_, JSTaggedValue(4)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key3, desc3); + JSHandle key4(thread_, JSTaggedValue(4)); + PropertyDescriptor desc4(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key4, desc4); // new Array(1,2,3,4,3).includes(5) - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(5))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = array::proto::Includes(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue(false).GetRawData()); } // 22.1.3.11 new Array(1,2,3,4,3).IndexOf(searchElement [ , fromIndex ]) TEST_F(BuiltinsArrayTest, IndexOf) { - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - JSHandle key3(thread, JSTaggedValue(3)); - PropertyDescriptor desc3(thread, JSHandle(thread, JSTaggedValue(4)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key3, desc3); - JSHandle key4(thread, JSTaggedValue(4)); - PropertyDescriptor desc4(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key4, desc4); - - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + JSHandle key3(thread_, JSTaggedValue(3)); + PropertyDescriptor desc3(thread_, JSHandle(thread_, JSTaggedValue(4)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key3, desc3); + JSHandle key4(thread_, JSTaggedValue(4)); + PropertyDescriptor desc4(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key4, desc4); + + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(static_cast(3))); ecma_runtime_call_info1->SetCallArg(1, JSTaggedValue(static_cast(0))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::IndexOf(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue(static_cast(2)).GetRawData()); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(0, JSTaggedValue(static_cast(3))); ecma_runtime_call_info2->SetCallArg(1, JSTaggedValue(static_cast(3))); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); result = array::proto::IndexOf(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue(static_cast(4)).GetRawData()); - auto ecma_runtime_call_info3 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info3 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info3->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info3->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info3->SetCallArg(0, JSTaggedValue(static_cast(5))); ecma_runtime_call_info3->SetCallArg(1, JSTaggedValue(static_cast(0))); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info3.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info3.get()); result = array::proto::IndexOf(ecma_runtime_call_info3.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue(-1).GetRawData()); - auto ecma_runtime_call_info4 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info4 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info4->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info4->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info4->SetCallArg(0, JSTaggedValue(static_cast(3))); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info4.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info4.get()); result = array::proto::IndexOf(ecma_runtime_call_info4.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue(static_cast(2)).GetRawData()); } // 22.1.3.14 new Array(1,2,3,4,3).LastIndexOf(searchElement [ , fromIndex ]) TEST_F(BuiltinsArrayTest, LastIndexOf) { - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - JSHandle key3(thread, JSTaggedValue(3)); - PropertyDescriptor desc3(thread, JSHandle(thread, JSTaggedValue(4)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key3, desc3); - JSHandle key4(thread, JSTaggedValue(4)); - PropertyDescriptor desc4(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key4, desc4); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + JSHandle key3(thread_, JSTaggedValue(3)); + PropertyDescriptor desc3(thread_, JSHandle(thread_, JSTaggedValue(4)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key3, desc3); + JSHandle key4(thread_, JSTaggedValue(4)); + PropertyDescriptor desc4(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key4, desc4); // new Array(1,2,3,4,3).LastIndexOf(3,4) - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(static_cast(3))); ecma_runtime_call_info1->SetCallArg(1, JSTaggedValue(static_cast(4))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::LastIndexOf(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue(static_cast(4)).GetRawData()); // new Array(1,2,3,4,3).LastIndexOf(3,3) - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(0, JSTaggedValue(static_cast(3))); ecma_runtime_call_info2->SetCallArg(1, JSTaggedValue(static_cast(3))); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); result = array::proto::LastIndexOf(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue(static_cast(2)).GetRawData()); // new Array(1,2,3,4,3).LastIndexOf(5,4) - auto ecma_runtime_call_info3 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info3 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info3->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info3->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info3->SetCallArg(0, JSTaggedValue(static_cast(5))); ecma_runtime_call_info3->SetCallArg(1, JSTaggedValue(static_cast(4))); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info3.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info3.get()); result = array::proto::LastIndexOf(ecma_runtime_call_info3.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue(-1).GetRawData()); // new Array(1,2,3,4,3).LastIndexOf(3) - auto ecma_runtime_call_info4 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info4 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info4->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info4->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info4->SetCallArg(0, JSTaggedValue(static_cast(3))); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info4.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info4.get()); result = array::proto::LastIndexOf(ecma_runtime_call_info4.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue(static_cast(4)).GetRawData()); } // 22.1.3.11 new Array().Pop() TEST_F(BuiltinsArrayTest, Pop) { - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::Pop(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); ASSERT_EQ(result.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(obj.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); result = array::proto::Pop(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue(3).GetRawData()); } // 22.1.3.11 new Array(1,2,3).Push(...items) TEST_F(BuiltinsArrayTest, Push) { - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(static_cast(4))); ecma_runtime_call_info1->SetCallArg(1, JSTaggedValue(static_cast(5))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::Push(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetNumber(), 5); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 5); - JSHandle key3(thread, JSTaggedValue(3)); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), key3).GetValue()->GetInt(), 4); - JSHandle key4(thread, JSTaggedValue(4)); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), key4).GetValue()->GetInt(), 5); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 5); + JSHandle key3(thread_, JSTaggedValue(3)); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), key3).GetValue()->GetInt(), 4); + JSHandle key4(thread_, JSTaggedValue(4)); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), key4).GetValue()->GetInt(), 5); } TEST_F(BuiltinsArrayTest, Reduce) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); ObjectFactory *factory = ecma_vm->GetFactory(); - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); JSHandle func = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestReduceFunc)); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, func.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(1, JSTaggedValue(static_cast(10))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::Reduce(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue(16).GetRawData()); } TEST_F(BuiltinsArrayTest, ReduceRight) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); ObjectFactory *factory = ecma_vm->GetFactory(); - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); JSHandle func = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestReduceRightFunc)); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, func.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(1, JSTaggedValue(static_cast(10))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::ReduceRight(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue(16).GetRawData()); } TEST_F(BuiltinsArrayTest, Shift) { - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::Shift(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue(1).GetRawData()); } TEST_F(BuiltinsArrayTest, Some) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); ObjectFactory *factory = ecma_vm->GetFactory(); - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(20)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - - JSHandle js_array(JSArray::ArrayCreate(thread, JSTaggedNumber(0))); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(20)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + + JSHandle js_array(JSArray::ArrayCreate(thread_, JSTaggedNumber(0))); JSHandle func = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestSomeFunc)); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, func.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(1, js_array.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result2 = array::proto::Some(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result2.GetRawData(), JSTaggedValue::True().GetRawData()); } TEST_F(BuiltinsArrayTest, Sort) { - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result2 = array::proto::Sort(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(result2.IsECMAObject()); JSHandle result_arr = - JSHandle(thread, JSTaggedValue(static_cast(result2.GetRawData()))); - EXPECT_EQ(JSArray::GetProperty(thread, result_arr, key0).GetValue()->GetInt(), 1); - EXPECT_EQ(JSArray::GetProperty(thread, result_arr, key1).GetValue()->GetInt(), 2); - EXPECT_EQ(JSArray::GetProperty(thread, result_arr, key2).GetValue()->GetInt(), 3); + JSHandle(thread_, JSTaggedValue(static_cast(result2.GetRawData()))); + EXPECT_EQ(JSArray::GetProperty(thread_, result_arr, key0).GetValue()->GetInt(), 1); + EXPECT_EQ(JSArray::GetProperty(thread_, result_arr, key1).GetValue()->GetInt(), 2); + EXPECT_EQ(JSArray::GetProperty(thread_, result_arr, key2).GetValue()->GetInt(), 3); } TEST_F(BuiltinsArrayTest, Unshift) { - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); - - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(3)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 0); + + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(3)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(static_cast(4))); ecma_runtime_call_info1->SetCallArg(1, JSTaggedValue(static_cast(5))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::Unshift(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue(static_cast(5)).GetRawData()); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 5); - JSHandle key3(thread, JSTaggedValue(0)); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), key3).GetValue()->GetInt(), 4); - JSHandle key4(thread, JSTaggedValue(1)); - EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(obj), key4).GetValue()->GetInt(), 5); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), length_key_handle).GetValue()->GetInt(), 5); + JSHandle key3(thread_, JSTaggedValue(0)); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), key3).GetValue()->GetInt(), 4); + JSHandle key4(thread_, JSTaggedValue(1)); + EXPECT_EQ(JSArray::GetProperty(thread_, JSHandle(obj), key4).GetValue()->GetInt(), 5); } TEST_F(BuiltinsArrayTest, Join) { - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, obj, length_key_handle).GetValue()->GetInt(), 0); - - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(2))); - JSArray::DefineOwnProperty(thread, JSHandle(obj), key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(3))); - JSArray::DefineOwnProperty(thread, JSHandle(obj), key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(4))); - JSArray::DefineOwnProperty(thread, JSHandle(obj), key2, desc2); - - JSHandle str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2,3,4"); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, obj, length_key_handle).GetValue()->GetInt(), 0); + + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(2))); + JSArray::DefineOwnProperty(thread_, JSHandle(obj), key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(3))); + JSArray::DefineOwnProperty(thread_, JSHandle(obj), key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(4))); + JSArray::DefineOwnProperty(thread_, JSHandle(obj), key2, desc2); + + JSHandle str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2,3,4"); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::Join(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + TestHelper::TearDownFrame(thread_, prev); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); [[maybe_unused]] auto *res = EcmaString::Cast(result_handle.GetTaggedValue().GetTaggedObject()); ASSERT_EQ(res->Compare(*str), 0); @@ -1692,33 +1707,35 @@ TEST_F(BuiltinsArrayTest, Join) TEST_F(BuiltinsArrayTest, ToString) { - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, obj, length_key_handle).GetValue()->GetInt(), 0); - - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(2))); - JSArray::DefineOwnProperty(thread, JSHandle(obj), key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(3))); - JSArray::DefineOwnProperty(thread, JSHandle(obj), key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(4))); - JSArray::DefineOwnProperty(thread, JSHandle(obj), key2, desc2); - - JSHandle str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2,3,4"); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, obj, length_key_handle).GetValue()->GetInt(), 0); + + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(2))); + JSArray::DefineOwnProperty(thread_, JSHandle(obj), key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(3))); + JSArray::DefineOwnProperty(thread_, JSHandle(obj), key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(4))); + JSArray::DefineOwnProperty(thread_, JSHandle(obj), key2, desc2); + + JSHandle str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2,3,4"); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = array::proto::Join(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + TestHelper::TearDownFrame(thread_, prev); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); [[maybe_unused]] auto *res = EcmaString::Cast(result_handle.GetTaggedValue().GetTaggedObject()); ASSERT_EQ(res->Compare(*str), 0); } } // namespace panda::test + +// NOLINTEND(readability-magic-numbers) diff --git a/tests/runtime/builtins/builtins_arraybuffer_test.cpp b/tests/runtime/builtins/builtins_arraybuffer_test.cpp index ed11e264182cb354c466e28a9b328d5eaf03591d..498a4a81453af32736320f800f8c5fa44d4066c9 100644 --- a/tests/runtime/builtins/builtins_arraybuffer_test.cpp +++ b/tests/runtime/builtins/builtins_arraybuffer_test.cpp @@ -23,8 +23,8 @@ #include "plugins/ecmascript/runtime/js_tagged_value.h" #include "plugins/ecmascript/tests/runtime/common/test_helper.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; -using namespace panda::ecmascript::builtins; namespace panda::test { class BuiltinsArrayBufferTest : public testing::Test { @@ -41,17 +41,21 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; JSTaggedValue CreateBuiltinsArrayBuffer(JSThread *thread, int32_t length) @@ -73,15 +77,15 @@ JSTaggedValue CreateBuiltinsArrayBuffer(JSThread *thread, int32_t length) // new ArrayBuffer(8) TEST_F(BuiltinsArrayBufferTest, Constructor1) { - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); - JSHandle array_buffer(thread, env->GetArrayBufferFunction().GetTaggedValue()); - JSHandle global_object(thread, env->GetGlobalObject()); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, array_buffer.GetTaggedValue(), 6); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); + JSHandle array_buffer(thread_, env->GetArrayBufferFunction().GetTaggedValue()); + JSHandle global_object(thread_, env->GetGlobalObject()); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, array_buffer.GetTaggedValue(), 6); ecma_runtime_call_info->SetFunction(array_buffer.GetTaggedValue()); ecma_runtime_call_info->SetThis(global_object.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(8))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = builtins::array_buffer::ArrayBufferConstructor(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsECMAObject()); } @@ -89,13 +93,14 @@ TEST_F(BuiltinsArrayBufferTest, Constructor1) // (new ArrayBuffer(5)).byteLength TEST_F(BuiltinsArrayBufferTest, byteLength1) { - JSTaggedValue tagged = CreateBuiltinsArrayBuffer(thread, 5); - JSHandle arr_buf(thread, JSArrayBuffer::Cast(reinterpret_cast(tagged.GetRawData()))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + JSTaggedValue tagged = CreateBuiltinsArrayBuffer(thread_, 5); + JSHandle arr_buf(thread_, + JSArrayBuffer::Cast(reinterpret_cast(tagged.GetRawData()))); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(arr_buf.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = builtins::array_buffer::proto::GetByteLength(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(5).GetRawData()); } @@ -103,23 +108,25 @@ TEST_F(BuiltinsArrayBufferTest, byteLength1) // (new ArrayBuffer(10)).slice(1, 5).bytelength TEST_F(BuiltinsArrayBufferTest, slice1) { - JSTaggedValue tagged = CreateBuiltinsArrayBuffer(thread, 10); - JSHandle arr_buf(thread, JSArrayBuffer::Cast(reinterpret_cast(tagged.GetRawData()))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + // NOLINTNEXTLINE(readability-magic-numbers) + JSTaggedValue tagged = CreateBuiltinsArrayBuffer(thread_, 10); + JSHandle arr_buf(thread_, + JSArrayBuffer::Cast(reinterpret_cast(tagged.GetRawData()))); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(arr_buf.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(1))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(5))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = builtins::array_buffer::proto::Slice(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); - JSHandle arr_buf1(thread, + TestHelper::TearDownFrame(thread_, prev); + JSHandle arr_buf1(thread_, JSArrayBuffer::Cast(reinterpret_cast(result1.GetRawData()))); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(arr_buf1.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result2 = builtins::array_buffer::proto::GetByteLength(ecma_runtime_call_info1.get()); ASSERT_EQ(result2.GetRawData(), JSTaggedValue(4).GetRawData()); diff --git a/tests/runtime/builtins/builtins_bigint_test.cpp b/tests/runtime/builtins/builtins_bigint_test.cpp index 53d45231eceb205b91c0f56b080f94ff61e8834f..e7c10e14e8b556b63767ab60b1cb527facd5817f 100644 --- a/tests/runtime/builtins/builtins_bigint_test.cpp +++ b/tests/runtime/builtins/builtins_bigint_test.cpp @@ -19,7 +19,11 @@ #include "plugins/ecmascript/runtime/js_primitive_ref.h" #include "plugins/ecmascript/tests/runtime/common/test_helper.h" +// NOLINTBEGIN(readability-magic-numbers) + +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; namespace panda::test { @@ -38,34 +42,36 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; private: ecmascript::JSHandle method_function_; + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; // new BigInt(123) TEST_F(BuiltinsBigIntTest, BigIntConstructor1) { - JSHandle numeric_value(thread, JSTaggedValue(123)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle numeric_value(thread_, JSTaggedValue(123)); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, numeric_value.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = big_int::BigIntConstructor(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(result.IsBigInt()); } @@ -73,17 +79,17 @@ TEST_F(BuiltinsBigIntTest, BigIntConstructor1) // new BigInt("456") TEST_F(BuiltinsBigIntTest, BigIntConstructor2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle numeric_value = factory->NewFromCanBeCompressString("456"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, numeric_value.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = big_int::BigIntConstructor(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(result.IsBigInt()); } @@ -91,23 +97,23 @@ TEST_F(BuiltinsBigIntTest, BigIntConstructor2) // AsIntN(64, (2 ^ 63 - 1)) TEST_F(BuiltinsBigIntTest, AsIntN1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle numeric_value = factory->NewFromCanBeCompressString("9223372036854775807"); int bit = 64; // 64-bit - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(bit))); ecma_runtime_call_info->SetCallArg(1, numeric_value.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = big_int::AsIntN(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(result.IsBigInt()); - JSHandle big_int_handle(thread, result); - JSHandle result_str = BigInt::ToString(thread, big_int_handle); + JSHandle big_int_handle(thread_, result); + JSHandle result_str = BigInt::ToString(thread_, big_int_handle); JSHandle str = factory->NewFromCanBeCompressString("9223372036854775807"); EXPECT_EQ(result_str->Compare(*str), 0); } @@ -115,23 +121,23 @@ TEST_F(BuiltinsBigIntTest, AsIntN1) // AsIntN(64, (2 ^ 63)) TEST_F(BuiltinsBigIntTest, AsIntN2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle numeric_value = factory->NewFromCanBeCompressString("9223372036854775808"); int bit = 64; // 64-bit - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(bit))); ecma_runtime_call_info->SetCallArg(1, numeric_value.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = big_int::AsIntN(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(result.IsBigInt()); - JSHandle big_int_handle(thread, result); - JSHandle result_str = BigInt::ToString(thread, big_int_handle); + JSHandle big_int_handle(thread_, result); + JSHandle result_str = BigInt::ToString(thread_, big_int_handle); JSHandle str = factory->NewFromCanBeCompressString("-9223372036854775808"); EXPECT_EQ(result_str->Compare(*str), 0); } @@ -139,23 +145,23 @@ TEST_F(BuiltinsBigIntTest, AsIntN2) // AsUintN(64, (2 ^ 64 - 1)) TEST_F(BuiltinsBigIntTest, AsUintN1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle numeric_value = factory->NewFromCanBeCompressString("18446744073709551615"); int bit = 64; // 64-bit - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(bit))); ecma_runtime_call_info->SetCallArg(1, numeric_value.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = big_int::AsUintN(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(result.IsBigInt()); - JSHandle big_int_handle(thread, result); - JSHandle result_str = BigInt::ToString(thread, big_int_handle); + JSHandle big_int_handle(thread_, result); + JSHandle result_str = BigInt::ToString(thread_, big_int_handle); JSHandle str = factory->NewFromCanBeCompressString("18446744073709551615"); EXPECT_EQ(result_str->Compare(*str), 0); } @@ -163,23 +169,23 @@ TEST_F(BuiltinsBigIntTest, AsUintN1) // AsUintN(64, (2 ^ 64)) TEST_F(BuiltinsBigIntTest, AsUintN2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle numeric_value = factory->NewFromCanBeCompressString("18446744073709551616"); int bit = 64; // 64-bit - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(bit))); ecma_runtime_call_info->SetCallArg(1, numeric_value.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = big_int::AsUintN(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(result.IsBigInt()); - JSHandle big_int_handle(thread, result); - JSHandle result_str = BigInt::ToString(thread, big_int_handle); + JSHandle big_int_handle(thread_, result); + JSHandle result_str = BigInt::ToString(thread_, big_int_handle); JSHandle str = factory->NewFromCanBeCompressString("0"); EXPECT_EQ(result_str->Compare(*str), 0); } @@ -187,33 +193,33 @@ TEST_F(BuiltinsBigIntTest, AsUintN2) // using locale TEST_F(BuiltinsBigIntTest, ToLocaleString1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle numeric_value = factory->NewFromCanBeCompressString("123456789123456789"); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetCallArg(0, numeric_value.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result1 = big_int::BigIntConstructor(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - JSHandle big_int_handle(thread, result1); + JSHandle big_int_handle(thread_, result1); JSHandle locale = factory->NewFromCanBeCompressString("de-DE"); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(big_int_handle.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(0, locale.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(1, JSTaggedValue::Undefined()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue result2 = big_int::proto::ToLocaleString(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(result2.IsString()); - JSHandle ecma_str_handle(thread, result2); + JSHandle ecma_str_handle(thread_, result2); JSHandle result_str = factory->NewFromCanBeCompressString("123.456.789.123.456.789"); EXPECT_EQ(ecma_str_handle->Compare(*result_str), 0); } @@ -221,265 +227,265 @@ TEST_F(BuiltinsBigIntTest, ToLocaleString1) // using locale and options TEST_F(BuiltinsBigIntTest, ToLocaleString2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle obj_fun = env->GetObjectFunction(); JSHandle options_obj = factory->NewJSObjectByConstructor(JSHandle(obj_fun), obj_fun); JSHandle numeric_value = factory->NewFromCanBeCompressString("123456789123456789"); - JSHandle format_style = thread->GlobalConstants()->GetHandledStyleString(); + JSHandle format_style = thread_->GlobalConstants()->GetHandledStyleString(); JSHandle style_key(factory->NewFromCanBeCompressString("currency")); JSHandle style_value(factory->NewFromCanBeCompressString("EUR")); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetCallArg(0, numeric_value.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result1 = big_int::BigIntConstructor(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - JSHandle big_int_handle(thread, result1); + JSHandle big_int_handle(thread_, result1); JSHandle locale = factory->NewFromCanBeCompressString("de-DE"); - JSObject::SetProperty(thread, options_obj, format_style, style_key); - JSObject::SetProperty(thread, options_obj, style_key, style_value); + JSObject::SetProperty(thread_, options_obj, format_style, style_key); + JSObject::SetProperty(thread_, options_obj, style_key, style_value); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(big_int_handle.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(0, locale.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(1, options_obj.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue result2 = big_int::proto::ToLocaleString(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(result2.IsString()); - JSHandle ecma_str_handle(thread, result2); + JSHandle ecma_str_handle(thread_, result2); EXPECT_STREQ("123.456.789.123.456.789,00 €", PandaString(ecma_str_handle->GetCString().get()).c_str()); } // 17.ToStirng() TEST_F(BuiltinsBigIntTest, ToString1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle numeric_value = factory->NewFromCanBeCompressString("17"); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetCallArg(0, numeric_value.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result1 = big_int::BigIntConstructor(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - JSHandle big_int_handle(thread, result1); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle big_int_handle(thread_, result1); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(big_int_handle.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(0, JSTaggedValue::Undefined()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue result2 = big_int::proto::ToString(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(result2.IsString()); - JSHandle ecma_str_handle(thread, result2); + JSHandle ecma_str_handle(thread_, result2); EXPECT_STREQ("17", PandaString(ecma_str_handle->GetCString().get()).c_str()); } // -0.ToStirng() TEST_F(BuiltinsBigIntTest, ToString2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle numeric_value = factory->NewFromCanBeCompressString("-0"); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetCallArg(0, numeric_value.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result1 = big_int::BigIntConstructor(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - JSHandle big_int_handle(thread, result1); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle big_int_handle(thread_, result1); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(big_int_handle.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(0, JSTaggedValue::Undefined()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue result2 = big_int::proto::ToString(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(result2.IsString()); - JSHandle ecma_str_handle(thread, result2); + JSHandle ecma_str_handle(thread_, result2); EXPECT_STREQ("0", PandaString(ecma_str_handle->GetCString().get()).c_str()); } // -10.ToStirng(2) TEST_F(BuiltinsBigIntTest, ToString3) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle numeric_value = factory->NewFromCanBeCompressString("-10"); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetCallArg(0, numeric_value.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result1 = big_int::BigIntConstructor(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - JSHandle big_int_handle(thread, result1); - JSHandle radix(thread, JSTaggedValue(2)); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle big_int_handle(thread_, result1); + JSHandle radix(thread_, JSTaggedValue(2)); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(big_int_handle.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(0, radix.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue result2 = big_int::proto::ToString(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(result2.IsString()); - JSHandle ecma_str_handle(thread, result2); + JSHandle ecma_str_handle(thread_, result2); EXPECT_STREQ("-1010", PandaString(ecma_str_handle->GetCString().get()).c_str()); } // 254.ToStirng(16) TEST_F(BuiltinsBigIntTest, ToString4) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle numeric_value = factory->NewFromCanBeCompressString("254"); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetCallArg(0, numeric_value.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result1 = big_int::BigIntConstructor(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - JSHandle big_int_handle(thread, result1); - JSHandle radix(thread, JSTaggedValue(16)); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle big_int_handle(thread_, result1); + JSHandle radix(thread_, JSTaggedValue(16)); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(big_int_handle.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(0, radix.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue result2 = big_int::proto::ToString(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(result2.IsString()); - JSHandle ecma_str_handle(thread, result2); + JSHandle ecma_str_handle(thread_, result2); EXPECT_STREQ("fe", PandaString(ecma_str_handle->GetCString().get()).c_str()); } // BigInt.ValueOf TEST_F(BuiltinsBigIntTest, ValueOf1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle numeric_value = factory->NewFromCanBeCompressString("-65536"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, numeric_value.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = big_int::BigIntConstructor(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - JSHandle big_int_handle(thread, result1); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + JSHandle big_int_handle(thread_, result1); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(big_int_handle.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue result2 = big_int::proto::ValueOf(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - EXPECT_EQ(BigInt::SameValue(thread, result1, result2), true); + EXPECT_EQ(BigInt::SameValue(thread_, result1, result2), true); } // Object.ValueOf TEST_F(BuiltinsBigIntTest, ValueOf2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle numeric_value = factory->NewFromCanBeCompressString("65535"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, numeric_value.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = big_int::BigIntConstructor(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - JSHandle big_int_handle(thread, result1); + JSHandle big_int_handle(thread_, result1); JSHandle big_int_obj(big_int_handle); JSHandle js_primitive_ref = factory->NewJSPrimitiveRef(PrimitiveType::PRIMITIVE_BIGINT, big_int_obj); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(js_primitive_ref.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue result2 = big_int::proto::ValueOf(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - EXPECT_EQ(BigInt::SameValue(thread, big_int_handle.GetTaggedValue(), result2), true); + EXPECT_EQ(BigInt::SameValue(thread_, big_int_handle.GetTaggedValue(), result2), true); } // testcases of NumberToBigint() TEST_F(BuiltinsBigIntTest, NumberToBigint) { - JSHandle number(thread, JSTaggedValue::Undefined()); - JSHandle bigint(thread, JSTaggedValue::Undefined()); + JSHandle number(thread_, JSTaggedValue::Undefined()); + JSHandle bigint(thread_, JSTaggedValue::Undefined()); - number = JSHandle(thread, JSTaggedValue(base::MAX_VALUE)); - bigint = JSHandle(thread, BigInt::NumberToBigInt(thread, number)); + number = JSHandle(thread_, JSTaggedValue(base::MAX_VALUE)); + bigint = JSHandle(thread_, BigInt::NumberToBigInt(thread_, number)); ASSERT_TRUE(bigint->IsBigInt()); - bool compare_res = JSTaggedValue::Equal(thread, number, bigint); + bool compare_res = JSTaggedValue::Equal(thread_, number, bigint); ASSERT_TRUE(compare_res); - number = JSHandle(thread, JSTaggedValue(-base::MAX_VALUE)); - bigint = JSHandle(thread, BigInt::NumberToBigInt(thread, number)); + number = JSHandle(thread_, JSTaggedValue(-base::MAX_VALUE)); + bigint = JSHandle(thread_, BigInt::NumberToBigInt(thread_, number)); ASSERT_TRUE(bigint->IsBigInt()); - compare_res = JSTaggedValue::Equal(thread, number, bigint); + compare_res = JSTaggedValue::Equal(thread_, number, bigint); ASSERT_TRUE(JSHandle::Cast(bigint)->GetSign()); ASSERT_TRUE(compare_res); - number = JSHandle(thread, JSTaggedValue(-0xffffffff)); - bigint = JSHandle(thread, BigInt::NumberToBigInt(thread, number)); + number = JSHandle(thread_, JSTaggedValue(-0xffffffff)); + bigint = JSHandle(thread_, BigInt::NumberToBigInt(thread_, number)); ASSERT_TRUE(bigint->IsBigInt()); - compare_res = JSTaggedValue::Equal(thread, number, bigint); + compare_res = JSTaggedValue::Equal(thread_, number, bigint); ASSERT_TRUE(compare_res); - number = JSHandle(thread, JSTaggedValue(0)); - bigint = JSHandle(thread, BigInt::NumberToBigInt(thread, number)); + number = JSHandle(thread_, JSTaggedValue(0)); + bigint = JSHandle(thread_, BigInt::NumberToBigInt(thread_, number)); ASSERT_TRUE(bigint->IsBigInt()); - compare_res = JSTaggedValue::Equal(thread, number, bigint); + compare_res = JSTaggedValue::Equal(thread_, number, bigint); ASSERT_TRUE(compare_res); } // testcases of BigintToNumber() TEST_F(BuiltinsBigIntTest, BigintToNumber) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle bigint(thread, JSTaggedValue::Undefined()); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle bigint(thread_, JSTaggedValue::Undefined()); JSTaggedNumber number(0); JSHandle parma(factory->NewFromCanBeCompressString("0xffff")); - bigint = JSHandle(thread, JSTaggedValue::ToBigInt(thread, parma)); + bigint = JSHandle(thread_, JSTaggedValue::ToBigInt(thread_, parma)); ASSERT_TRUE(bigint->IsBigInt()); number = BigInt::BigIntToNumber(JSHandle::Cast(bigint)); ASSERT_EQ(number.GetNumber(), static_cast(0xffff)); @@ -489,26 +495,26 @@ TEST_F(BuiltinsBigIntTest, BigintToNumber) "0000000000000000000000000000000000000000000000000000000000000000000" "0000000000000000000000000000000000000000000000000000000000000000000" "000000000000000000000000000000000000000000000000000000000")); - bigint = JSHandle(thread, JSTaggedValue::ToBigInt(thread, parma)); + bigint = JSHandle(thread_, JSTaggedValue::ToBigInt(thread_, parma)); ASSERT_TRUE(bigint->IsBigInt()); number = BigInt::BigIntToNumber(JSHandle::Cast(bigint)); ASSERT_EQ(number.GetNumber(), base::MAX_VALUE); - parma = JSHandle(thread, JSTaggedValue::False()); - bigint = JSHandle(thread, JSTaggedValue::ToBigInt(thread, parma)); + parma = JSHandle(thread_, JSTaggedValue::False()); + bigint = JSHandle(thread_, JSTaggedValue::ToBigInt(thread_, parma)); ASSERT_TRUE(bigint->IsBigInt()); ASSERT_TRUE(JSHandle::Cast(bigint)->IsZero()); number = BigInt::BigIntToNumber(JSHandle::Cast(bigint)); ASSERT_EQ(number.GetNumber(), 0.0); - parma = JSHandle(thread, JSTaggedValue(base::MAX_VALUE)); - bigint = JSHandle(thread, BigInt::NumberToBigInt(thread, parma)); + parma = JSHandle(thread_, JSTaggedValue(base::MAX_VALUE)); + bigint = JSHandle(thread_, BigInt::NumberToBigInt(thread_, parma)); ASSERT_TRUE(bigint->IsBigInt()); number = BigInt::BigIntToNumber(JSHandle::Cast(bigint)); ASSERT_EQ(number.GetNumber(), base::MAX_VALUE); - parma = JSHandle(thread, JSTaggedValue(-base::MAX_VALUE)); - bigint = JSHandle(thread, BigInt::NumberToBigInt(thread, parma)); + parma = JSHandle(thread_, JSTaggedValue(-base::MAX_VALUE)); + bigint = JSHandle(thread_, BigInt::NumberToBigInt(thread_, parma)); ASSERT_TRUE(bigint->IsBigInt()); number = BigInt::BigIntToNumber(JSHandle::Cast(bigint)); ASSERT_EQ(number.GetNumber(), -base::MAX_VALUE); @@ -526,93 +532,96 @@ TEST_F(BuiltinsBigIntTest, BigintToNumber) // testcases of StringToBigInt(EcmaString) TEST_F(BuiltinsBigIntTest, StringToBigInt) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle bigint; JSHandle str; JSHandle parma; // hex string parma = JSHandle(factory->NewFromCanBeCompressString("0xffff")); - bigint = JSHandle(thread, base::NumberHelper::StringToBigInt(thread, parma)); + bigint = JSHandle(thread_, base::NumberHelper::StringToBigInt(thread_, parma)); ASSERT_TRUE(bigint->IsBigInt()); - str = BigInt::ToString(thread, JSHandle::Cast(bigint), BigInt::HEXADECIMAL); + str = BigInt::ToString(thread_, JSHandle::Cast(bigint), BigInt::HEXADECIMAL); parma = JSHandle(factory->NewFromCanBeCompressString("ffff")); ASSERT_EQ(str->Compare(reinterpret_cast(parma->GetRawData())), 0); parma = JSHandle(factory->NewFromCanBeCompressString("0XFFFF")); - bigint = JSHandle(thread, base::NumberHelper::StringToBigInt(thread, parma)); + bigint = JSHandle(thread_, base::NumberHelper::StringToBigInt(thread_, parma)); ASSERT_TRUE(bigint->IsBigInt()); - str = BigInt::ToString(thread, JSHandle::Cast(bigint), BigInt::HEXADECIMAL); + str = BigInt::ToString(thread_, JSHandle::Cast(bigint), BigInt::HEXADECIMAL); parma = JSHandle(factory->NewFromCanBeCompressString("ffff")); ASSERT_EQ(str->Compare(reinterpret_cast(parma->GetRawData())), 0); // binary string parma = JSHandle(factory->NewFromCanBeCompressString("0b11111111")); - bigint = JSHandle(thread, base::NumberHelper::StringToBigInt(thread, parma)); + bigint = JSHandle(thread_, base::NumberHelper::StringToBigInt(thread_, parma)); ASSERT_TRUE(bigint->IsBigInt()); - str = BigInt::ToString(thread, JSHandle::Cast(bigint), BigInt::BINARY); + str = BigInt::ToString(thread_, JSHandle::Cast(bigint), BigInt::BINARY); parma = JSHandle(factory->NewFromCanBeCompressString("11111111")); ASSERT_EQ(str->Compare(reinterpret_cast(parma->GetRawData())), 0); parma = JSHandle(factory->NewFromCanBeCompressString("0B11111111")); - bigint = JSHandle(thread, base::NumberHelper::StringToBigInt(thread, parma)); + bigint = JSHandle(thread_, base::NumberHelper::StringToBigInt(thread_, parma)); ASSERT_TRUE(bigint->IsBigInt()); - str = BigInt::ToString(thread, JSHandle::Cast(bigint), BigInt::BINARY); + str = BigInt::ToString(thread_, JSHandle::Cast(bigint), BigInt::BINARY); parma = JSHandle(factory->NewFromCanBeCompressString("11111111")); ASSERT_EQ(str->Compare(reinterpret_cast(parma->GetRawData())), 0); // octal string parma = JSHandle(factory->NewFromCanBeCompressString("0o123456")); - bigint = JSHandle(thread, base::NumberHelper::StringToBigInt(thread, parma)); + bigint = JSHandle(thread_, base::NumberHelper::StringToBigInt(thread_, parma)); ASSERT_TRUE(bigint->IsBigInt()); - str = BigInt::ToString(thread, JSHandle::Cast(bigint), BigInt::OCTAL); + str = BigInt::ToString(thread_, JSHandle::Cast(bigint), BigInt::OCTAL); parma = JSHandle(factory->NewFromCanBeCompressString("123456")); ASSERT_EQ(str->Compare(reinterpret_cast(parma->GetRawData())), 0); parma = JSHandle(factory->NewFromCanBeCompressString("0O123456")); - bigint = JSHandle(thread, base::NumberHelper::StringToBigInt(thread, parma)); + bigint = JSHandle(thread_, base::NumberHelper::StringToBigInt(thread_, parma)); ASSERT_TRUE(bigint->IsBigInt()); - str = BigInt::ToString(thread, JSHandle::Cast(bigint), BigInt::OCTAL); + str = BigInt::ToString(thread_, JSHandle::Cast(bigint), BigInt::OCTAL); parma = JSHandle(factory->NewFromCanBeCompressString("123456")); ASSERT_EQ(str->Compare(reinterpret_cast(parma->GetRawData())), 0); // decimal string parma = JSHandle(factory->NewFromCanBeCompressString("999999999")); - bigint = JSHandle(thread, base::NumberHelper::StringToBigInt(thread, parma)); + bigint = JSHandle(thread_, base::NumberHelper::StringToBigInt(thread_, parma)); ASSERT_TRUE(bigint->IsBigInt()); - str = BigInt::ToString(thread, JSHandle::Cast(bigint)); + str = BigInt::ToString(thread_, JSHandle::Cast(bigint)); ASSERT_EQ(str->Compare(reinterpret_cast(parma->GetRawData())), 0); // string has space parma = JSHandle(factory->NewFromCanBeCompressString(" 123 ")); - bigint = JSHandle(thread, base::NumberHelper::StringToBigInt(thread, parma)); + bigint = JSHandle(thread_, base::NumberHelper::StringToBigInt(thread_, parma)); ASSERT_TRUE(bigint->IsBigInt()); - JSHandle number(thread, JSTaggedValue(static_cast(123))); - bool compare_res = JSTaggedValue::Equal(thread, bigint, number); + JSHandle number(thread_, JSTaggedValue(static_cast(123))); + bool compare_res = JSTaggedValue::Equal(thread_, bigint, number); ASSERT_TRUE(compare_res); parma = JSHandle(factory->NewFromCanBeCompressString("123 ")); - bigint = JSHandle(thread, base::NumberHelper::StringToBigInt(thread, parma)); + bigint = JSHandle(thread_, base::NumberHelper::StringToBigInt(thread_, parma)); ASSERT_TRUE(bigint->IsBigInt()); - number = JSHandle(thread, JSTaggedValue(static_cast(123))); - compare_res = JSTaggedValue::Equal(thread, bigint, number); + number = JSHandle(thread_, JSTaggedValue(static_cast(123))); + compare_res = JSTaggedValue::Equal(thread_, bigint, number); ASSERT_TRUE(compare_res); parma = JSHandle(factory->NewFromCanBeCompressString(" 123")); - bigint = JSHandle(thread, base::NumberHelper::StringToBigInt(thread, parma)); + bigint = JSHandle(thread_, base::NumberHelper::StringToBigInt(thread_, parma)); ASSERT_TRUE(bigint->IsBigInt()); - number = JSHandle(thread, JSTaggedValue(static_cast(123))); - compare_res = JSTaggedValue::Equal(thread, bigint, number); + number = JSHandle(thread_, JSTaggedValue(static_cast(123))); + compare_res = JSTaggedValue::Equal(thread_, bigint, number); ASSERT_TRUE(compare_res); parma = JSHandle(factory->NewFromCanBeCompressString("")); - bigint = JSHandle(thread, base::NumberHelper::StringToBigInt(thread, parma)); + bigint = JSHandle(thread_, base::NumberHelper::StringToBigInt(thread_, parma)); ASSERT_TRUE(bigint->IsBigInt()); ASSERT_TRUE(JSHandle::Cast(bigint)->IsZero()); parma = JSHandle(factory->NewFromCanBeCompressString(" ")); - bigint = JSHandle(thread, base::NumberHelper::StringToBigInt(thread, parma)); + bigint = JSHandle(thread_, base::NumberHelper::StringToBigInt(thread_, parma)); ASSERT_TRUE(bigint->IsBigInt()); ASSERT_TRUE(JSHandle::Cast(bigint)->IsZero()); } + +// NOLINTEND(readability-magic-numbers) + } // namespace panda::test diff --git a/tests/runtime/builtins/builtins_boolean_test.cpp b/tests/runtime/builtins/builtins_boolean_test.cpp index 2a0cd4067125b540987b56693a0ad5b33d02e030..57024684845043dfa617e725616e27d1f0f934bf 100644 --- a/tests/runtime/builtins/builtins_boolean_test.cpp +++ b/tests/runtime/builtins/builtins_boolean_test.cpp @@ -24,7 +24,9 @@ #include "plugins/ecmascript/runtime/object_factory.h" #include "plugins/ecmascript/tests/runtime/common/test_helper.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; namespace panda::test { @@ -42,33 +44,38 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; // new Boolean(123) TEST_F(BuiltinsBooleanTest, BooleanConstructor) { - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle boolean(env->GetBooleanFunction()); - JSHandle global_object(thread, env->GetGlobalObject()); + JSHandle global_object(thread_, env->GetGlobalObject()); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*boolean), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*boolean), 6); ecma_runtime_call_info->SetFunction(boolean.GetTaggedValue()); ecma_runtime_call_info->SetThis(global_object.GetTaggedValue()); + // NOLINTNEXTLINE(readability-magic-numbers) ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(123))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = boolean::BooleanConstructor(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsECMAObject()); @@ -78,17 +85,17 @@ TEST_F(BuiltinsBooleanTest, BooleanConstructor) // new Boolean(undefined) TEST_F(BuiltinsBooleanTest, BooleanConstructor1) { - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle boolean(env->GetBooleanFunction()); - JSHandle global_object(thread, env->GetGlobalObject()); + JSHandle global_object(thread_, env->GetGlobalObject()); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*boolean), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*boolean), 6); ecma_runtime_call_info->SetFunction(boolean.GetTaggedValue()); ecma_runtime_call_info->SetThis(global_object.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue::Undefined()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = boolean::BooleanConstructor(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsECMAObject()); @@ -98,18 +105,18 @@ TEST_F(BuiltinsBooleanTest, BooleanConstructor1) // Boolean("helloworld") TEST_F(BuiltinsBooleanTest, BooleanConstructor2) { - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle boolean(env->GetBooleanFunction()); - JSHandle global_object(thread, env->GetGlobalObject()); - JSHandle str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("helloworld"); + JSHandle global_object(thread_, env->GetGlobalObject()); + JSHandle str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("helloworld"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(boolean.GetTaggedValue()); ecma_runtime_call_info->SetThis(global_object.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = boolean::BooleanConstructor(ecma_runtime_call_info.get()); JSTaggedValue ruler = builtins_common::GetTaggedBoolean(true); @@ -119,48 +126,48 @@ TEST_F(BuiltinsBooleanTest, BooleanConstructor2) // false.toString() TEST_F(BuiltinsBooleanTest, BooleanPrototypeToString) { - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::False()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = boolean::proto::ToString(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle res(thread, reinterpret_cast(result.GetRawData())); - auto ruler = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("false"); + JSHandle res(thread_, reinterpret_cast(result.GetRawData())); + auto ruler = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("false"); ASSERT_EQ(res->Compare(*ruler), 0); } // (new Boolean(true)).toString() TEST_F(BuiltinsBooleanTest, BooleanPrototypeToString1) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle boolean_object(env->GetBooleanFunction()); - JSHandle value(thread, JSTaggedValue::True()); - JSHandle boolean = thread->GetEcmaVM()->GetFactory()->NewJSPrimitiveRef(boolean_object, value); + JSHandle value(thread_, JSTaggedValue::True()); + JSHandle boolean = thread_->GetEcmaVM()->GetFactory()->NewJSPrimitiveRef(boolean_object, value); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(boolean.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = boolean::proto::ToString(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle res(thread, reinterpret_cast(result.GetRawData())); - auto ruler = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("true"); + JSHandle res(thread_, reinterpret_cast(result.GetRawData())); + auto ruler = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("true"); ASSERT_EQ(res->Compare(*ruler), 0); } // true.valueOf() TEST_F(BuiltinsBooleanTest, BooleanPrototypeValueOf) { - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::True()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = boolean::proto::ValueOf(ecma_runtime_call_info.get()); JSTaggedValue ruler = builtins_common::GetTaggedBoolean(true); @@ -170,18 +177,18 @@ TEST_F(BuiltinsBooleanTest, BooleanPrototypeValueOf) // (new Boolean(false)).valueOf() TEST_F(BuiltinsBooleanTest, BooleanPrototypeValueOf1) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle boolean_object(env->GetBooleanFunction()); - JSHandle value(thread, JSTaggedValue::False()); - JSHandle boolean = thread->GetEcmaVM()->GetFactory()->NewJSPrimitiveRef(boolean_object, value); + JSHandle value(thread_, JSTaggedValue::False()); + JSHandle boolean = thread_->GetEcmaVM()->GetFactory()->NewJSPrimitiveRef(boolean_object, value); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(boolean.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = boolean::proto::ValueOf(ecma_runtime_call_info.get()); JSTaggedValue ruler = builtins_common::GetTaggedBoolean(false); diff --git a/tests/runtime/builtins/builtins_dataview_test.cpp b/tests/runtime/builtins/builtins_dataview_test.cpp index ff610b0696261b187855c418421f52c8e1c1c2b1..e4cfb53325b58b1e90a4e453067f8e70984950ed 100644 --- a/tests/runtime/builtins/builtins_dataview_test.cpp +++ b/tests/runtime/builtins/builtins_dataview_test.cpp @@ -23,9 +23,13 @@ #include "plugins/ecmascript/runtime/js_tagged_value.h" #include "plugins/ecmascript/tests/runtime/common/test_helper.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; +// NOLINTBEGIN(readability-magic-numbers) + namespace panda::test { using DataViewType = ecmascript::DataViewType; class BuiltinsDataViewTest : public testing::Test { @@ -42,17 +46,21 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; JSTaggedValue CreateBuiltinsArrayBuffer(JSThread *thread, int32_t length) @@ -105,18 +113,19 @@ void SetUint8(JSThread *thread, const JSHandle &view, int32_t offset // new DataView(new ArrayBuffer(10), 1) TEST_F(BuiltinsDataViewTest, Constructor) { - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); - JSHandle data_view(thread, env->GetDataViewFunction().GetTaggedValue()); - JSHandle global_object(thread, env->GetGlobalObject()); - JSTaggedValue tagged = CreateBuiltinsArrayBuffer(thread, 10); - JSHandle arr_buf(thread, JSArrayBuffer::Cast(reinterpret_cast(tagged.GetRawData()))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*data_view), 8); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); + JSHandle data_view(thread_, env->GetDataViewFunction().GetTaggedValue()); + JSHandle global_object(thread_, env->GetGlobalObject()); + JSTaggedValue tagged = CreateBuiltinsArrayBuffer(thread_, 10); + JSHandle arr_buf(thread_, + JSArrayBuffer::Cast(reinterpret_cast(tagged.GetRawData()))); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*data_view), 8); ecma_runtime_call_info->SetFunction(data_view.GetTaggedValue()); ecma_runtime_call_info->SetThis(global_object.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, arr_buf.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(1)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = data_view::DataViewConstructor(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsECMAObject()); } @@ -124,13 +133,13 @@ TEST_F(BuiltinsDataViewTest, Constructor) // new DataView(new ArrayBuffer(10), 1).byteOffset TEST_F(BuiltinsDataViewTest, byteOffset) { - JSTaggedValue tagged = CreateBuiltinsDataView(thread, 10, 1); - JSHandle view(thread, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + JSTaggedValue tagged = CreateBuiltinsDataView(thread_, 10, 1); + JSHandle view(thread_, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(view.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = data_view::proto::GetByteOffset(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(1).GetRawData()); } @@ -138,13 +147,13 @@ TEST_F(BuiltinsDataViewTest, byteOffset) // new DataView(new ArrayBuffer(10), 2).byteLength TEST_F(BuiltinsDataViewTest, byteLength) { - JSTaggedValue tagged = CreateBuiltinsDataView(thread, 10, 2); - JSHandle view(thread, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + JSTaggedValue tagged = CreateBuiltinsDataView(thread_, 10, 2); + JSHandle view(thread_, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(view.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = data_view::proto::GetByteLength(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(8).GetRawData()); } @@ -152,13 +161,13 @@ TEST_F(BuiltinsDataViewTest, byteLength) // new DataView(new ArrayBuffer(10), 1).buffer TEST_F(BuiltinsDataViewTest, buffer) { - JSTaggedValue tagged = CreateBuiltinsDataView(thread, 10, 1); - JSHandle view(thread, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + JSTaggedValue tagged = CreateBuiltinsDataView(thread_, 10, 1); + JSHandle view(thread_, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(view.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = data_view::proto::GetBuffer(ecma_runtime_call_info.get()); ASSERT_EQ(result.IsArrayBuffer(), true); } @@ -166,20 +175,20 @@ TEST_F(BuiltinsDataViewTest, buffer) // new DataView(new ArrayBuffer(8), 0).SetUint16/GetUint16 TEST_F(BuiltinsDataViewTest, getUint16) { - JSTaggedValue tagged = CreateBuiltinsDataView(thread, 8, 0); - JSHandle view(thread, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + JSTaggedValue tagged = CreateBuiltinsDataView(thread_, 8, 0); + JSHandle view(thread_, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(view.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(0)); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(-1870724872)); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue::False()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = data_view::proto::SetUint16(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(view.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(0)); @@ -192,20 +201,20 @@ TEST_F(BuiltinsDataViewTest, getUint16) // new DataView(new ArrayBuffer(8), 0).SetInt16/GetInt16 TEST_F(BuiltinsDataViewTest, getInt16) { - JSTaggedValue tagged = CreateBuiltinsDataView(thread, 8, 0); - JSHandle view(thread, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + JSTaggedValue tagged = CreateBuiltinsDataView(thread_, 8, 0); + JSHandle view(thread_, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(view.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(0)); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(-1870724872)); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue::False()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = data_view::proto::SetInt16(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(view.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(0)); @@ -218,20 +227,20 @@ TEST_F(BuiltinsDataViewTest, getInt16) // new DataView(new ArrayBuffer(8), 0).SetUint8/GetUint32 TEST_F(BuiltinsDataViewTest, GetUint32) { - JSTaggedValue tagged = CreateBuiltinsDataView(thread, 8, 0); - JSHandle view(thread, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); - SetUint8(thread, view, 0, JSTaggedValue(127)); - SetUint8(thread, view, 1, JSTaggedValue(255)); - SetUint8(thread, view, 2, JSTaggedValue(255)); - SetUint8(thread, view, 3, JSTaggedValue(255)); - - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + JSTaggedValue tagged = CreateBuiltinsDataView(thread_, 8, 0); + JSHandle view(thread_, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); + SetUint8(thread_, view, 0, JSTaggedValue(127)); + SetUint8(thread_, view, 1, JSTaggedValue(255)); + SetUint8(thread_, view, 2, JSTaggedValue(255)); + SetUint8(thread_, view, 3, JSTaggedValue(255)); + + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(view.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(0)); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue::False()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = data_view::proto::GetUint32(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(2147483647).GetRawData()); } @@ -239,20 +248,20 @@ TEST_F(BuiltinsDataViewTest, GetUint32) // new DataView(new ArrayBuffer(8), 0).SetUint8/GetInt32 TEST_F(BuiltinsDataViewTest, GetInt32) { - JSTaggedValue tagged = CreateBuiltinsDataView(thread, 8, 0); - JSHandle view(thread, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); - SetUint8(thread, view, 0, JSTaggedValue(127)); - SetUint8(thread, view, 1, JSTaggedValue(255)); - SetUint8(thread, view, 2, JSTaggedValue(255)); - SetUint8(thread, view, 3, JSTaggedValue(255)); - - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + JSTaggedValue tagged = CreateBuiltinsDataView(thread_, 8, 0); + JSHandle view(thread_, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); + SetUint8(thread_, view, 0, JSTaggedValue(127)); + SetUint8(thread_, view, 1, JSTaggedValue(255)); + SetUint8(thread_, view, 2, JSTaggedValue(255)); + SetUint8(thread_, view, 3, JSTaggedValue(255)); + + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(view.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(0)); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue::False()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = data_view::proto::GetInt32(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(2147483647).GetRawData()); } @@ -260,16 +269,16 @@ TEST_F(BuiltinsDataViewTest, GetInt32) // new DataView(new ArrayBuffer(8), 0).SetUint8/GetInt8 TEST_F(BuiltinsDataViewTest, GetInt8) { - JSTaggedValue tagged = CreateBuiltinsDataView(thread, 8, 0); - JSHandle view(thread, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); - SetUint8(thread, view, 0, JSTaggedValue(255)); + JSTaggedValue tagged = CreateBuiltinsDataView(thread_, 8, 0); + JSHandle view(thread_, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); + SetUint8(thread_, view, 0, JSTaggedValue(255)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(view.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(0)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = data_view::proto::GetInt8(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(-1).GetRawData()); } @@ -277,16 +286,16 @@ TEST_F(BuiltinsDataViewTest, GetInt8) // new DataView(new ArrayBuffer(8), 0).SetUint8/GetUint8 TEST_F(BuiltinsDataViewTest, GetUint8) { - JSTaggedValue tagged = CreateBuiltinsDataView(thread, 8, 0); - JSHandle view(thread, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); - SetUint8(thread, view, 0, JSTaggedValue(127)); + JSTaggedValue tagged = CreateBuiltinsDataView(thread_, 8, 0); + JSHandle view(thread_, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); + SetUint8(thread_, view, 0, JSTaggedValue(127)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(view.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(0)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = data_view::proto::GetUint8(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(127).GetRawData()); } @@ -294,20 +303,20 @@ TEST_F(BuiltinsDataViewTest, GetUint8) // new DataView(new ArrayBuffer(8), 4).SetUint8/GetFloat32 TEST_F(BuiltinsDataViewTest, GetFloat32) { - JSTaggedValue tagged = CreateBuiltinsDataView(thread, 8, 0); - JSHandle view(thread, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); - SetUint8(thread, view, 4, JSTaggedValue(75)); - SetUint8(thread, view, 5, JSTaggedValue(75)); - SetUint8(thread, view, 6, JSTaggedValue(75)); - SetUint8(thread, view, 7, JSTaggedValue(75)); - - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + JSTaggedValue tagged = CreateBuiltinsDataView(thread_, 8, 0); + JSHandle view(thread_, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); + SetUint8(thread_, view, 4, JSTaggedValue(75)); + SetUint8(thread_, view, 5, JSTaggedValue(75)); + SetUint8(thread_, view, 6, JSTaggedValue(75)); + SetUint8(thread_, view, 7, JSTaggedValue(75)); + + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(view.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(4)); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue::False()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = data_view::proto::GetFloat32(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(static_cast(13323083)).GetRawData()); } @@ -315,24 +324,24 @@ TEST_F(BuiltinsDataViewTest, GetFloat32) // new DataView(new ArrayBuffer(12), 4).SetUint8/GetFloat64 TEST_F(BuiltinsDataViewTest, GetFloat64) { - JSTaggedValue tagged = CreateBuiltinsDataView(thread, 12, 0); - JSHandle view(thread, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); - SetUint8(thread, view, 4, JSTaggedValue(67)); - SetUint8(thread, view, 5, JSTaggedValue(67)); - SetUint8(thread, view, 6, JSTaggedValue(68)); - SetUint8(thread, view, 7, JSTaggedValue(68)); - SetUint8(thread, view, 8, JSTaggedValue(67)); - SetUint8(thread, view, 9, JSTaggedValue(67)); - SetUint8(thread, view, 10, JSTaggedValue(68)); - SetUint8(thread, view, 11, JSTaggedValue(68)); - - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + JSTaggedValue tagged = CreateBuiltinsDataView(thread_, 12, 0); + JSHandle view(thread_, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); + SetUint8(thread_, view, 4, JSTaggedValue(67)); + SetUint8(thread_, view, 5, JSTaggedValue(67)); + SetUint8(thread_, view, 6, JSTaggedValue(68)); + SetUint8(thread_, view, 7, JSTaggedValue(68)); + SetUint8(thread_, view, 8, JSTaggedValue(67)); + SetUint8(thread_, view, 9, JSTaggedValue(67)); + SetUint8(thread_, view, 10, JSTaggedValue(68)); + SetUint8(thread_, view, 11, JSTaggedValue(68)); + + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(view.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(4)); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue::False()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = data_view::proto::GetFloat64(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(static_cast(10846169068898440)).GetRawData()); } @@ -340,20 +349,20 @@ TEST_F(BuiltinsDataViewTest, GetFloat64) // new DataView(new ArrayBuffer(8), 0).SetUint32/GetUint32 TEST_F(BuiltinsDataViewTest, SetUint32) { - JSTaggedValue tagged = CreateBuiltinsDataView(thread, 8, 0); - JSHandle view(thread, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + JSTaggedValue tagged = CreateBuiltinsDataView(thread_, 8, 0); + JSHandle view(thread_, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(view.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(0)); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(0x907f00f8)); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue::True()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = data_view::proto::SetUint32(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(view.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(0)); @@ -366,20 +375,20 @@ TEST_F(BuiltinsDataViewTest, SetUint32) // new DataView(new ArrayBuffer(8), 0).SetInt32/GetInt32 TEST_F(BuiltinsDataViewTest, SetInt32) { - JSTaggedValue tagged = CreateBuiltinsDataView(thread, 8, 0); - JSHandle view(thread, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + JSTaggedValue tagged = CreateBuiltinsDataView(thread_, 8, 0); + JSHandle view(thread_, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(view.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(0)); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(-1870724872)); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue::True()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = data_view::proto::SetInt32(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(view.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(0)); @@ -392,18 +401,18 @@ TEST_F(BuiltinsDataViewTest, SetInt32) // new DataView(new ArrayBuffer(8), 0).SetInt8/GetUint8 TEST_F(BuiltinsDataViewTest, SetInt8) { - JSTaggedValue tagged = CreateBuiltinsDataView(thread, 8, 0); - JSHandle view(thread, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + JSTaggedValue tagged = CreateBuiltinsDataView(thread_, 8, 0); + JSHandle view(thread_, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(view.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(0)); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(-1)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = data_view::proto::SetInt8(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(view.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(0)); @@ -414,20 +423,20 @@ TEST_F(BuiltinsDataViewTest, SetInt8) // new DataView(new ArrayBuffer(4), 0).SetFloat32/GetFloat32 TEST_F(BuiltinsDataViewTest, SetFloat32) { - JSTaggedValue tagged = CreateBuiltinsDataView(thread, 4, 0); - JSHandle view(thread, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + JSTaggedValue tagged = CreateBuiltinsDataView(thread_, 4, 0); + JSHandle view(thread_, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(view.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(0)); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(42)); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue::True()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = data_view::proto::SetFloat32(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(view.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(0)); @@ -440,20 +449,20 @@ TEST_F(BuiltinsDataViewTest, SetFloat32) // new DataView(new ArrayBuffer(8), 0).SetFloat64/GetFloat64 TEST_F(BuiltinsDataViewTest, SetFloat64) { - JSTaggedValue tagged = CreateBuiltinsDataView(thread, 8, 0); - JSHandle view(thread, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + JSTaggedValue tagged = CreateBuiltinsDataView(thread_, 8, 0); + JSHandle view(thread_, JSDataView::Cast(reinterpret_cast(tagged.GetRawData()))); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(view.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(0)); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(42)); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue::True()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = data_view::proto::SetFloat64(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(view.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(0)); @@ -463,3 +472,5 @@ TEST_F(BuiltinsDataViewTest, SetFloat64) ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(8.759e-320)).GetRawData()); } } // namespace panda::test + +// NOLINTEND(readability-magic-numbers) diff --git a/tests/runtime/builtins/builtins_date_test.cpp b/tests/runtime/builtins/builtins_date_test.cpp index b0b9e0313f85831061ed9ebcd7408a8d115df1a6..a0e52d544f1f136fbbb8599f2bd5532069a195b5 100644 --- a/tests/runtime/builtins/builtins_date_test.cpp +++ b/tests/runtime/builtins/builtins_date_test.cpp @@ -23,8 +23,13 @@ #include "plugins/ecmascript/tests/runtime/common/test_helper.h" #include "utils/bit_utils.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; + +// NOLINTBEGIN(readability-magic-numbers) + namespace panda::test { const char NEG = '-'; const char PLUS = '+'; @@ -47,17 +52,21 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; JSHandle JSDateCreateTest(JSThread *thread) @@ -83,12 +92,12 @@ static std::unique_ptr CreateAndSetRuntimeCallInfo(JSThread TEST_F(BuiltinsDateTest, SetGetDate) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 6, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 6, js_date.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(2))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); [[maybe_unused]] JSTaggedValue result1 = date::proto::SetDate(ecma_runtime_call_info.get()); JSTaggedValue result2 = date::proto::GetDate(ecma_runtime_call_info.get()); ASSERT_EQ(result2.GetRawData(), JSTaggedValue(static_cast(2)).GetRawData()); @@ -96,12 +105,12 @@ TEST_F(BuiltinsDateTest, SetGetDate) TEST_F(BuiltinsDateTest, SetGetUTCDate) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 6, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 6, js_date.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(2))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); [[maybe_unused]] JSTaggedValue result3 = date::proto::SetUTCDate(ecma_runtime_call_info.get()); JSTaggedValue result4 = date::proto::GetUTCDate(ecma_runtime_call_info.get()); ASSERT_EQ(result4.GetRawData(), JSTaggedValue(static_cast(2)).GetRawData()); @@ -109,12 +118,12 @@ TEST_F(BuiltinsDateTest, SetGetUTCDate) TEST_F(BuiltinsDateTest, SetGetMinusUTCDate) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 6, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 6, js_date.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(-2))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); [[maybe_unused]] JSTaggedValue result3 = date::proto::SetUTCDate(ecma_runtime_call_info.get()); JSTaggedValue result4 = date::proto::GetUTCDate(ecma_runtime_call_info.get()); ASSERT_EQ(result4.GetRawData(), JSTaggedValue(static_cast(29)).GetRawData()); @@ -122,9 +131,9 @@ TEST_F(BuiltinsDateTest, SetGetMinusUTCDate) TEST_F(BuiltinsDateTest, SetGetFullYear) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 10, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 10, js_date.GetTaggedValue()); // 2018 : test case ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(2018))); // 10 : test case @@ -132,7 +141,7 @@ TEST_F(BuiltinsDateTest, SetGetFullYear) // 2, 6 : test case ecma_runtime_call_info->SetCallArg(2, JSTaggedValue(static_cast(6))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); date::proto::SetFullYear(ecma_runtime_call_info.get()); JSTaggedValue result1 = date::proto::GetFullYear(ecma_runtime_call_info.get()); // 2018 : test case @@ -149,9 +158,9 @@ TEST_F(BuiltinsDateTest, SetGetFullYear) TEST_F(BuiltinsDateTest, SetGetUTCFullYear) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 10, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 10, js_date.GetTaggedValue()); // 2018 : test case ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(2018))); // 10 : test case @@ -159,7 +168,7 @@ TEST_F(BuiltinsDateTest, SetGetUTCFullYear) // 2, 6 : test case ecma_runtime_call_info->SetCallArg(2, JSTaggedValue(static_cast(6))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); date::proto::SetUTCFullYear(ecma_runtime_call_info.get()); JSTaggedValue result4 = date::proto::GetUTCFullYear(ecma_runtime_call_info.get()); // 2018 : test case @@ -176,13 +185,13 @@ TEST_F(BuiltinsDateTest, SetGetUTCFullYear) TEST_F(BuiltinsDateTest, SetGetMinusFullYear) { - JSHandle js_date = JSDateCreateTest(thread); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 10, js_date.GetTaggedValue()); + JSHandle js_date = JSDateCreateTest(thread_); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 10, js_date.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(-2018))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(-10))); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue(static_cast(-6))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); date::proto::SetFullYear(ecma_runtime_call_info.get()); JSTaggedValue result1 = date::proto::GetFullYear(ecma_runtime_call_info.get()); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(-2019)).GetRawData()); @@ -196,14 +205,14 @@ TEST_F(BuiltinsDateTest, SetGetMinusFullYear) TEST_F(BuiltinsDateTest, SetGetMinusUTCFullYear) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 10, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 10, js_date.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(-2018))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(-10))); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue(static_cast(-6))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); date::proto::SetUTCFullYear(ecma_runtime_call_info.get()); JSTaggedValue result4 = date::proto::GetUTCFullYear(ecma_runtime_call_info.get()); ASSERT_EQ(result4.GetRawData(), JSTaggedValue(static_cast(-2019)).GetRawData()); @@ -217,15 +226,15 @@ TEST_F(BuiltinsDateTest, SetGetMinusUTCFullYear) TEST_F(BuiltinsDateTest, SetGetHours) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 12, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 12, js_date.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(18))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(10))); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue(static_cast(6))); ecma_runtime_call_info->SetCallArg(3, JSTaggedValue(static_cast(111))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); date::proto::SetHours(ecma_runtime_call_info.get()); JSTaggedValue result1 = date::proto::GetHours(ecma_runtime_call_info.get()); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(18)).GetRawData()); @@ -242,15 +251,15 @@ TEST_F(BuiltinsDateTest, SetGetHours) TEST_F(BuiltinsDateTest, SetGetUTCHours) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 12, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 12, js_date.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(18))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(10))); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue(static_cast(6))); ecma_runtime_call_info->SetCallArg(3, JSTaggedValue(static_cast(111))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); date::proto::SetUTCHours(ecma_runtime_call_info.get()); JSTaggedValue result5 = date::proto::GetUTCHours(ecma_runtime_call_info.get()); ASSERT_EQ(result5.GetRawData(), JSTaggedValue(static_cast(18)).GetRawData()); @@ -267,15 +276,15 @@ TEST_F(BuiltinsDateTest, SetGetUTCHours) TEST_F(BuiltinsDateTest, SetGetMinusHours) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 12, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 12, js_date.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(-18))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(-10))); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue(static_cast(-6))); ecma_runtime_call_info->SetCallArg(3, JSTaggedValue(static_cast(-111))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); date::proto::SetHours(ecma_runtime_call_info.get()); JSTaggedValue result1 = date::proto::GetHours(ecma_runtime_call_info.get()); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(5)).GetRawData()); @@ -292,15 +301,15 @@ TEST_F(BuiltinsDateTest, SetGetMinusHours) TEST_F(BuiltinsDateTest, SetGetMinusUTCHours) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 12, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 12, js_date.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(-18))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(-10))); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue(static_cast(-6))); ecma_runtime_call_info->SetCallArg(3, JSTaggedValue(static_cast(-111))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); date::proto::SetUTCHours(ecma_runtime_call_info.get()); JSTaggedValue result5 = date::proto::GetUTCHours(ecma_runtime_call_info.get()); ASSERT_EQ(result5.GetRawData(), JSTaggedValue(static_cast(5)).GetRawData()); @@ -317,12 +326,12 @@ TEST_F(BuiltinsDateTest, SetGetMinusUTCHours) TEST_F(BuiltinsDateTest, SetGetMilliseconds) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 6, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 6, js_date.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(100))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = date::proto::SetMilliseconds(ecma_runtime_call_info.get()); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(100)).GetRawData()); @@ -332,12 +341,12 @@ TEST_F(BuiltinsDateTest, SetGetMilliseconds) TEST_F(BuiltinsDateTest, SetGetUTCMilliseconds) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 6, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 6, js_date.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(100))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result3 = date::proto::SetUTCMilliseconds(ecma_runtime_call_info.get()); ASSERT_EQ(result3.GetRawData(), JSTaggedValue(static_cast(100)).GetRawData()); @@ -347,14 +356,14 @@ TEST_F(BuiltinsDateTest, SetGetUTCMilliseconds) TEST_F(BuiltinsDateTest, SetGetMinutes) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 10, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 10, js_date.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(10))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(6))); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue(static_cast(111))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); date::proto::SetMinutes(ecma_runtime_call_info.get()); JSTaggedValue result1 = date::proto::GetMinutes(ecma_runtime_call_info.get()); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(10)).GetRawData()); @@ -368,14 +377,14 @@ TEST_F(BuiltinsDateTest, SetGetMinutes) TEST_F(BuiltinsDateTest, SetGetUTCMinutes) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 10, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 10, js_date.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(10))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(6))); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue(static_cast(111))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); date::proto::SetUTCMinutes(ecma_runtime_call_info.get()); JSTaggedValue result4 = date::proto::GetUTCMinutes(ecma_runtime_call_info.get()); ASSERT_EQ(result4.GetRawData(), JSTaggedValue(static_cast(10)).GetRawData()); @@ -389,13 +398,13 @@ TEST_F(BuiltinsDateTest, SetGetUTCMinutes) TEST_F(BuiltinsDateTest, SetGetMonth) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 8, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 8, js_date.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(8))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(3))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); date::proto::SetMonth(ecma_runtime_call_info.get()); JSTaggedValue result1 = date::proto::GetMonth(ecma_runtime_call_info.get()); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(8)).GetRawData()); @@ -406,13 +415,13 @@ TEST_F(BuiltinsDateTest, SetGetMonth) TEST_F(BuiltinsDateTest, SetGetUTCMonth) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 8, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 8, js_date.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(8))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(3))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); date::proto::SetUTCMonth(ecma_runtime_call_info.get()); JSTaggedValue result3 = date::proto::GetUTCMonth(ecma_runtime_call_info.get()); ASSERT_EQ(result3.GetRawData(), JSTaggedValue(static_cast(8)).GetRawData()); @@ -423,13 +432,13 @@ TEST_F(BuiltinsDateTest, SetGetUTCMonth) TEST_F(BuiltinsDateTest, SetGetSeconds) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 8, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 8, js_date.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(59))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(123))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); date::proto::SetSeconds(ecma_runtime_call_info.get()); JSTaggedValue result1 = date::proto::GetSeconds(ecma_runtime_call_info.get()); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(59)).GetRawData()); @@ -440,13 +449,13 @@ TEST_F(BuiltinsDateTest, SetGetSeconds) TEST_F(BuiltinsDateTest, SetGetUTCSeconds) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 8, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 8, js_date.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(59))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(123))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); date::proto::SetUTCSeconds(ecma_runtime_call_info.get()); JSTaggedValue result3 = date::proto::GetUTCSeconds(ecma_runtime_call_info.get()); ASSERT_EQ(result3.GetRawData(), JSTaggedValue(static_cast(59)).GetRawData()); @@ -457,12 +466,12 @@ TEST_F(BuiltinsDateTest, SetGetUTCSeconds) TEST_F(BuiltinsDateTest, SetGetTime) { - JSHandle js_date = JSDateCreateTest(thread); + JSHandle js_date = JSDateCreateTest(thread_); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 6, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 6, js_date.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(2))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = date::proto::SetTime(ecma_runtime_call_info.get()); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(2)).GetRawData()); @@ -472,18 +481,18 @@ TEST_F(BuiltinsDateTest, SetGetTime) TEST_F(BuiltinsDateTest, UTC) { - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 12, JSTaggedValue::Undefined()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 12, JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(2020.982)); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(10.23)); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue(4.32)); ecma_runtime_call_info->SetCallArg(3, JSTaggedValue(11.32)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = date::UTC(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(1604487600000)).GetRawData()); - auto ecma_runtime_call_info1 = CreateAndSetRuntimeCallInfo(thread, 18, JSTaggedValue::Undefined()); + auto ecma_runtime_call_info1 = CreateAndSetRuntimeCallInfo(thread_, 18, JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(2020.982)); ecma_runtime_call_info1->SetCallArg(1, JSTaggedValue(10.23)); ecma_runtime_call_info1->SetCallArg(2, JSTaggedValue(4.32)); @@ -492,35 +501,35 @@ TEST_F(BuiltinsDateTest, UTC) ecma_runtime_call_info1->SetCallArg(5, JSTaggedValue(34.321)); ecma_runtime_call_info1->SetCallArg(6, JSTaggedValue(static_cast(231))); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); result1 = date::UTC(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(1604490334231)).GetRawData()); - auto ecma_runtime_call_info2 = CreateAndSetRuntimeCallInfo(thread, 10, JSTaggedValue::Undefined()); + auto ecma_runtime_call_info2 = CreateAndSetRuntimeCallInfo(thread_, 10, JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetCallArg(0, JSTaggedValue(10.23)); ecma_runtime_call_info2->SetCallArg(1, JSTaggedValue(4.32)); ecma_runtime_call_info2->SetCallArg(2, JSTaggedValue(11.32)); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); result1 = date::UTC(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(-1882224000000)).GetRawData()); - auto ecma_runtime_call_info3 = CreateAndSetRuntimeCallInfo(thread, 6, JSTaggedValue::Undefined()); + auto ecma_runtime_call_info3 = CreateAndSetRuntimeCallInfo(thread_, 6, JSTaggedValue::Undefined()); ecma_runtime_call_info3->SetCallArg(0, JSTaggedValue(1994.982)); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info3.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info3.get()); result1 = date::UTC(ecma_runtime_call_info3.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(757382400000)).GetRawData()); - auto ecma_runtime_call_info4 = CreateAndSetRuntimeCallInfo(thread, 6, JSTaggedValue::Undefined()); + auto ecma_runtime_call_info4 = CreateAndSetRuntimeCallInfo(thread_, 6, JSTaggedValue::Undefined()); ecma_runtime_call_info4->SetCallArg(0, JSTaggedValue(19999944.982)); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info4.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info4.get()); result1 = date::UTC(ecma_runtime_call_info4.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(base::NAN_VALUE)).GetRawData()); } @@ -608,74 +617,74 @@ void SetAll2(JSThread *thread, const JSHandle &js_date) TEST_F(BuiltinsDateTest, parse) { JSHandle str = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2020-11-19T12:18:18.132Z"); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 6, JSTaggedValue::Undefined()); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2020-11-19T12:18:18.132Z"); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 6, JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = date::Parse(ecma_runtime_call_info.get()); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(1605788298132)).GetRawData()); - JSHandle str1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2020-11-19Z"); - auto ecma_runtime_call_info1 = CreateAndSetRuntimeCallInfo(thread, 6, JSTaggedValue::Undefined()); + JSHandle str1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2020-11-19Z"); + auto ecma_runtime_call_info1 = CreateAndSetRuntimeCallInfo(thread_, 6, JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetCallArg(0, str1.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); result1 = date::Parse(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(1605744000000)).GetRawData()); JSHandle str2 = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2020-11T12:18:17.231+08:00"); - auto ecma_runtime_call_info2 = CreateAndSetRuntimeCallInfo(thread, 6, JSTaggedValue::Undefined()); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2020-11T12:18:17.231+08:00"); + auto ecma_runtime_call_info2 = CreateAndSetRuntimeCallInfo(thread_, 6, JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetCallArg(0, str2.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); result1 = date::Parse(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(1604204297231)).GetRawData()); JSHandle str3 = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Thu Nov 19 2020 20:18:18 GMT+0800"); - auto ecma_runtime_call_info3 = CreateAndSetRuntimeCallInfo(thread, 6, JSTaggedValue::Undefined()); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Thu Nov 19 2020 20:18:18 GMT+0800"); + auto ecma_runtime_call_info3 = CreateAndSetRuntimeCallInfo(thread_, 6, JSTaggedValue::Undefined()); ecma_runtime_call_info3->SetCallArg(0, str3.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info3.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info3.get()); result1 = date::Parse(ecma_runtime_call_info3.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(1605788298000)).GetRawData()); JSHandle str4 = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Thu 03 Jun 2093 04:18 GMT"); - auto ecma_runtime_call_info4 = CreateAndSetRuntimeCallInfo(thread, 6, JSTaggedValue::Undefined()); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Thu 03 Jun 2093 04:18 GMT"); + auto ecma_runtime_call_info4 = CreateAndSetRuntimeCallInfo(thread_, 6, JSTaggedValue::Undefined()); ecma_runtime_call_info4->SetCallArg(0, str4.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info4.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info4.get()); result1 = date::Parse(ecma_runtime_call_info4.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(3894841080000)).GetRawData()); - auto ecma_runtime_call_info5 = CreateAndSetRuntimeCallInfo(thread, 6, JSTaggedValue::Undefined()); + auto ecma_runtime_call_info5 = CreateAndSetRuntimeCallInfo(thread_, 6, JSTaggedValue::Undefined()); ecma_runtime_call_info5->SetCallArg(0, JSTaggedValue::Null()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info5.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info5.get()); result1 = date::Parse(ecma_runtime_call_info5.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(base::NAN_VALUE)).GetRawData()); } TEST_F(BuiltinsDateTest, ToDateString) { JSHandle expect_value = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Tue Nov 06 2018"); - JSHandle js_date = JSDateCreateTest(thread); - SetAllYearAndHours(thread, js_date); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Tue Nov 06 2018"); + JSHandle js_date = JSDateCreateTest(thread_); + SetAllYearAndHours(thread_, js_date); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 4, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 4, js_date.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = date::proto::ToDateString(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsString()); ASSERT_TRUE(EcmaString::StringsAreEqual(reinterpret_cast(result.GetRawData()), *expect_value)); @@ -684,14 +693,14 @@ TEST_F(BuiltinsDateTest, ToDateString) TEST_F(BuiltinsDateTest, ToISOString) { JSHandle expect_value = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2020-11-19T12:18:18.132Z"); - JSHandle js_date = JSDateCreateTest(thread); - JSDate::Cast(js_date.GetTaggedValue().GetTaggedObject())->SetTimeValue(thread, JSTaggedValue(1605788298132.0)); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 4, js_date.GetTaggedValue()); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2020-11-19T12:18:18.132Z"); + JSHandle js_date = JSDateCreateTest(thread_); + JSDate::Cast(js_date.GetTaggedValue().GetTaggedObject())->SetTimeValue(thread_, JSTaggedValue(1605788298132.0)); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 4, js_date.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = date::proto::ToISOString(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result1.IsString()); ASSERT_TRUE(EcmaString::StringsAreEqual(reinterpret_cast(result1.GetRawData()), *expect_value)); } @@ -699,15 +708,15 @@ TEST_F(BuiltinsDateTest, ToISOString) TEST_F(BuiltinsDateTest, ToISOStringMinus) { JSHandle expect_value = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("1831-12-02T21:47:18.382Z"); - JSHandle js_date = JSDateCreateTest(thread); - JSDate::Cast(js_date.GetTaggedValue().GetTaggedObject())->SetTimeValue(thread, JSTaggedValue(-4357419161618.0)); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("1831-12-02T21:47:18.382Z"); + JSHandle js_date = JSDateCreateTest(thread_); + JSDate::Cast(js_date.GetTaggedValue().GetTaggedObject())->SetTimeValue(thread_, JSTaggedValue(-4357419161618.0)); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 4, js_date.GetTaggedValue()); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 4, js_date.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = date::proto::ToISOString(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result1.IsString()); ASSERT_TRUE(EcmaString::StringsAreEqual(reinterpret_cast(result1.GetRawData()), *expect_value)); } @@ -716,14 +725,14 @@ TEST_F(BuiltinsDateTest, ToISOStringMinus) TEST_F(BuiltinsDateTest, ToJSON) { JSHandle expect_value = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2020-11-19T12:18:18.132Z"); - JSHandle js_date = JSDateCreateTest(thread); - js_date->SetTimeValue(thread, JSTaggedValue(1605788298132.0)); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 4, js_date.GetTaggedValue()); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2020-11-19T12:18:18.132Z"); + JSHandle js_date = JSDateCreateTest(thread_); + js_date->SetTimeValue(thread_, JSTaggedValue(1605788298132.0)); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 4, js_date.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = date::proto::ToJSON(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result1.IsString()); ASSERT_TRUE(EcmaString::StringsAreEqual(reinterpret_cast(result1.GetRawData()), *expect_value)); } @@ -731,12 +740,12 @@ TEST_F(BuiltinsDateTest, ToJSON) TEST_F(BuiltinsDateTest, ToJSONMinus) { JSHandle expect_value = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("1831-12-02T21:47:18.382Z"); - JSHandle js_date = JSDateCreateTest(thread); - js_date->SetTimeValue(thread, JSTaggedValue(-4357419161618.0)); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 4, js_date.GetTaggedValue()); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("1831-12-02T21:47:18.382Z"); + JSHandle js_date = JSDateCreateTest(thread_); + js_date->SetTimeValue(thread_, JSTaggedValue(-4357419161618.0)); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 4, js_date.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = date::proto::ToJSON(ecma_runtime_call_info.get()); ASSERT_TRUE(result1.IsString()); ASSERT_TRUE(EcmaString::StringsAreEqual(reinterpret_cast(result1.GetRawData()), *expect_value)); @@ -744,7 +753,7 @@ TEST_F(BuiltinsDateTest, ToJSONMinus) static PandaString GetLocalTime(JSHandle js_date, int64_t local_min) { - PandaString local_time = ""; + PandaString local_time; local_min = JSDate::GetLocalOffsetFromOS(local_min, true); if (static_cast(JSDate::Cast(js_date.GetTaggedValue().GetTaggedObject())->GetTimeValue().GetDouble()) < CHINA_BEFORE_1900_MS && @@ -766,47 +775,47 @@ TEST_F(BuiltinsDateTest, ToString) int local_min = 0; PandaString local_time; - JSHandle js_date = JSDateCreateTest(thread); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 4, js_date.GetTaggedValue()); + JSHandle js_date = JSDateCreateTest(thread_); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 4, js_date.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); - SetAllYearAndHours(thread, js_date); + SetAllYearAndHours(thread_, js_date); local_time = GetLocalTime(js_date, local_min); JSTaggedValue result1 = date::proto::ToString(ecma_runtime_call_info.get()); ASSERT_TRUE(result1.IsString()); - TestHelper::TearDownFrame(thread, prev); - JSHandle result1_val(thread, reinterpret_cast(result1.GetRawData())); + TestHelper::TearDownFrame(thread_, prev); + JSHandle result1_val(thread_, reinterpret_cast(result1.GetRawData())); PandaString str = "Tue Nov 06 2018 18:10:06 GMT" + local_time; - JSHandle str_handle = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(str); + JSHandle str_handle = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(str); ASSERT_TRUE(EcmaString::StringsAreEqual(*result1_val, *str_handle)); - JSHandle js_date1 = JSDateCreateTest(thread); - auto ecma_runtime_call_info1 = CreateAndSetRuntimeCallInfo(thread, 4, js_date1.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + JSHandle js_date1 = JSDateCreateTest(thread_); + auto ecma_runtime_call_info1 = CreateAndSetRuntimeCallInfo(thread_, 4, js_date1.GetTaggedValue()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); - SetAll1(thread, js_date1); + SetAll1(thread_, js_date1); local_time = GetLocalTime(js_date1, local_min); JSTaggedValue result2 = date::proto::ToString(ecma_runtime_call_info1.get()); ASSERT_TRUE(result2.IsString()); - TestHelper::TearDownFrame(thread, prev); - JSHandle result2_val(thread, reinterpret_cast(result2.GetRawData())); + TestHelper::TearDownFrame(thread_, prev); + JSHandle result2_val(thread_, reinterpret_cast(result2.GetRawData())); str = "Mon Dec 31 1900 23:54:16 GMT" + local_time; - str_handle = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(str); + str_handle = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(str); ASSERT_TRUE(EcmaString::StringsAreEqual(*result2_val, *str_handle)); - JSHandle js_date2 = JSDateCreateTest(thread); - auto ecma_runtime_call_info2 = CreateAndSetRuntimeCallInfo(thread, 4, js_date2.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + JSHandle js_date2 = JSDateCreateTest(thread_); + auto ecma_runtime_call_info2 = CreateAndSetRuntimeCallInfo(thread_, 4, js_date2.GetTaggedValue()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); - SetAll2(thread, js_date2); + SetAll2(thread_, js_date2); local_time = GetLocalTime(js_date, local_min); JSTaggedValue result3 = date::proto::ToString(ecma_runtime_call_info2.get()); ASSERT_TRUE(result3.IsString()); - TestHelper::TearDownFrame(thread, prev); - JSHandle result3_val(thread, reinterpret_cast(result3.GetRawData())); + TestHelper::TearDownFrame(thread_, prev); + JSHandle result3_val(thread_, reinterpret_cast(result3.GetRawData())); str = "Tue Jan 01 1901 00:03:21 GMT" + local_time; - str_handle = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(str); + str_handle = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(str); ASSERT_TRUE(EcmaString::StringsAreEqual(*result3_val, *str_handle)); } @@ -815,53 +824,53 @@ TEST_F(BuiltinsDateTest, ToTimeString) int local_min = 0; PandaString local_time; - JSHandle js_date = JSDateCreateTest(thread); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 4, js_date.GetTaggedValue()); + JSHandle js_date = JSDateCreateTest(thread_); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 4, js_date.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); - SetAllYearAndHours(thread, js_date); + SetAllYearAndHours(thread_, js_date); local_time = GetLocalTime(js_date, local_min); JSTaggedValue result1 = date::proto::ToTimeString(ecma_runtime_call_info.get()); ASSERT_TRUE(result1.IsString()); - JSHandle result1_val(thread, reinterpret_cast(result1.GetRawData())); + JSHandle result1_val(thread_, reinterpret_cast(result1.GetRawData())); PandaString str = "18:10:06 GMT" + local_time; - JSHandle str_handle = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(str); + JSHandle str_handle = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(str); ASSERT_TRUE(EcmaString::StringsAreEqual(*result1_val, *str_handle)); - JSHandle js_date1 = JSDateCreateTest(thread); - auto ecma_runtime_call_info1 = CreateAndSetRuntimeCallInfo(thread, 4, js_date1.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); - SetAll1(thread, js_date1); + JSHandle js_date1 = JSDateCreateTest(thread_); + auto ecma_runtime_call_info1 = CreateAndSetRuntimeCallInfo(thread_, 4, js_date1.GetTaggedValue()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); + SetAll1(thread_, js_date1); local_time = GetLocalTime(js_date1, local_min); JSTaggedValue result2 = date::proto::ToTimeString(ecma_runtime_call_info1.get()); ASSERT_TRUE(result2.IsString()); - JSHandle result2_val(thread, reinterpret_cast(result2.GetRawData())); + JSHandle result2_val(thread_, reinterpret_cast(result2.GetRawData())); str = "23:54:16 GMT" + local_time; - str_handle = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(str); + str_handle = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(str); ASSERT_TRUE(EcmaString::StringsAreEqual(*result2_val, *str_handle)); - JSHandle js_date2 = JSDateCreateTest(thread); - auto ecma_runtime_call_info2 = CreateAndSetRuntimeCallInfo(thread, 4, js_date2.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); - SetAll2(thread, js_date2); + JSHandle js_date2 = JSDateCreateTest(thread_); + auto ecma_runtime_call_info2 = CreateAndSetRuntimeCallInfo(thread_, 4, js_date2.GetTaggedValue()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); + SetAll2(thread_, js_date2); local_time = GetLocalTime(js_date, local_min); JSTaggedValue result3 = date::proto::ToTimeString(ecma_runtime_call_info2.get()); ASSERT_TRUE(result3.IsString()); - JSHandle result3_val(thread, reinterpret_cast(result3.GetRawData())); + JSHandle result3_val(thread_, reinterpret_cast(result3.GetRawData())); str = "00:03:21 GMT" + local_time; - str_handle = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(str); + str_handle = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(str); ASSERT_TRUE(EcmaString::StringsAreEqual(*result3_val, *str_handle)); } TEST_F(BuiltinsDateTest, ToUTCString) { JSHandle expect_value = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Thu, 19 Nov 2020 12:18:18 GMT"); - JSHandle js_date = JSDateCreateTest(thread); - JSDate::Cast(js_date.GetTaggedValue().GetTaggedObject())->SetTimeValue(thread, JSTaggedValue(1605788298132.0)); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 4, js_date.GetTaggedValue()); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Thu, 19 Nov 2020 12:18:18 GMT"); + JSHandle js_date = JSDateCreateTest(thread_); + JSDate::Cast(js_date.GetTaggedValue().GetTaggedObject())->SetTimeValue(thread_, JSTaggedValue(1605788298132.0)); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 4, js_date.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = date::proto::ToUTCString(ecma_runtime_call_info.get()); ASSERT_TRUE(result1.IsString()); ASSERT_TRUE(EcmaString::StringsAreEqual(reinterpret_cast(result1.GetRawData()), *expect_value)); @@ -870,12 +879,12 @@ TEST_F(BuiltinsDateTest, ToUTCString) TEST_F(BuiltinsDateTest, ToUTCStringMinus) { JSHandle expect_value = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Fri, 02 Dec 1831 21:47:18 GMT"); - JSHandle js_date = JSDateCreateTest(thread); - JSDate::Cast(js_date.GetTaggedValue().GetTaggedObject())->SetTimeValue(thread, JSTaggedValue(-4357419161618.0)); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 4, js_date.GetTaggedValue()); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Fri, 02 Dec 1831 21:47:18 GMT"); + JSHandle js_date = JSDateCreateTest(thread_); + JSDate::Cast(js_date.GetTaggedValue().GetTaggedObject())->SetTimeValue(thread_, JSTaggedValue(-4357419161618.0)); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 4, js_date.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = date::proto::ToUTCString(ecma_runtime_call_info.get()); ASSERT_TRUE(result1.IsString()); ASSERT_TRUE(EcmaString::StringsAreEqual(reinterpret_cast(result1.GetRawData()), *expect_value)); @@ -883,22 +892,22 @@ TEST_F(BuiltinsDateTest, ToUTCStringMinus) TEST_F(BuiltinsDateTest, ValueOf) { - JSHandle js_date = JSDateCreateTest(thread); - JSDate::Cast(js_date.GetTaggedValue().GetTaggedObject())->SetTimeValue(thread, JSTaggedValue(1605788298132.0)); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 4, js_date.GetTaggedValue()); + JSHandle js_date = JSDateCreateTest(thread_); + JSDate::Cast(js_date.GetTaggedValue().GetTaggedObject())->SetTimeValue(thread_, JSTaggedValue(1605788298132.0)); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 4, js_date.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = date::proto::ValueOf(ecma_runtime_call_info.get()); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(1605788298132)).GetRawData()); } TEST_F(BuiltinsDateTest, ValueOfMinus) { - JSHandle js_date = JSDateCreateTest(thread); - JSDate::Cast(js_date.GetTaggedValue().GetTaggedObject())->SetTimeValue(thread, JSTaggedValue(-4357419161618.0)); - auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread, 4, js_date.GetTaggedValue()); + JSHandle js_date = JSDateCreateTest(thread_); + JSDate::Cast(js_date.GetTaggedValue().GetTaggedObject())->SetTimeValue(thread_, JSTaggedValue(-4357419161618.0)); + auto ecma_runtime_call_info = CreateAndSetRuntimeCallInfo(thread_, 4, js_date.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = date::proto::ValueOf(ecma_runtime_call_info.get()); ASSERT_EQ(result1.GetRawData(), JSTaggedValue(static_cast(-4357419161618)).GetRawData()); } @@ -906,35 +915,35 @@ TEST_F(BuiltinsDateTest, ValueOfMinus) TEST_F(BuiltinsDateTest, DateConstructor) { // case1: test new target is undefined. - JSHandle js_date = JSDateCreateTest(thread); - JSHandle global_env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle js_date = JSDateCreateTest(thread_); + JSHandle global_env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle date_func(global_env->GetDateFunction()); - auto ecma_runtime_call_info1 = CreateAndSetRuntimeCallInfo(thread, 4, JSTaggedValue::Undefined()); + auto ecma_runtime_call_info1 = CreateAndSetRuntimeCallInfo(thread_, 4, JSTaggedValue::Undefined()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result1 = date::DateConstructor(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result1.IsString()); // case2: length == 0 - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, js_date.GetTaggedValue(), 4); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, js_date.GetTaggedValue(), 4); ecma_runtime_call_info2->SetFunction(date_func.GetTaggedValue()); ecma_runtime_call_info2->SetThis(js_date.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue result2 = date::DateConstructor(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result2.IsObject()); // case3: length == 1 - auto ecma_runtime_call_info3 = TestHelper::CreateEcmaRuntimeCallInfo(thread, js_date.GetTaggedValue(), 6); + auto ecma_runtime_call_info3 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, js_date.GetTaggedValue(), 6); ecma_runtime_call_info3->SetFunction(date_func.GetTaggedValue()); ecma_runtime_call_info3->SetThis(js_date.GetTaggedValue()); ecma_runtime_call_info3->SetCallArg(0, JSTaggedValue(static_cast(2018))); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info3.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info3.get()); JSTaggedValue result3 = date::DateConstructor(ecma_runtime_call_info3.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result3.IsObject()); date::proto::SetFullYear(ecma_runtime_call_info3.get()); @@ -942,17 +951,17 @@ TEST_F(BuiltinsDateTest, DateConstructor) ASSERT_EQ(result4.GetRawData(), JSTaggedValue(static_cast(2018)).GetRawData()); // case3: length > 1 - auto ecma_runtime_call_info4 = TestHelper::CreateEcmaRuntimeCallInfo(thread, js_date.GetTaggedValue(), 8); + auto ecma_runtime_call_info4 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, js_date.GetTaggedValue(), 8); ecma_runtime_call_info4->SetFunction(date_func.GetTaggedValue()); ecma_runtime_call_info4->SetThis(js_date.GetTaggedValue()); ecma_runtime_call_info4->SetCallArg(0, JSTaggedValue(static_cast(2018))); ecma_runtime_call_info4->SetCallArg(1, JSTaggedValue(static_cast(10))); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info4.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info4.get()); JSTaggedValue result5 = date::DateConstructor(ecma_runtime_call_info4.get()); ASSERT_TRUE(result5.IsObject()); - SetAllYearAndHours(thread, js_date); + SetAllYearAndHours(thread_, js_date); date::proto::SetFullYear(ecma_runtime_call_info4.get()); JSTaggedValue result6 = date::proto::GetFullYear(ecma_runtime_call_info4.get()); ASSERT_EQ(result6.GetRawData(), JSTaggedValue(static_cast(2018)).GetRawData()); @@ -960,3 +969,5 @@ TEST_F(BuiltinsDateTest, DateConstructor) ASSERT_EQ(result7.GetRawData(), JSTaggedValue(static_cast(10)).GetRawData()); } } // namespace panda::test + +// NOLINTEND(readability-magic-numbers) diff --git a/tests/runtime/builtins/builtins_errors_test.cpp b/tests/runtime/builtins/builtins_errors_test.cpp index 4a7ec1aa8e9b77f7692b336ec5c5ed91d1344db3..775698bfef374a3ad9741329cc08ff27af0f984a 100644 --- a/tests/runtime/builtins/builtins_errors_test.cpp +++ b/tests/runtime/builtins/builtins_errors_test.cpp @@ -30,7 +30,9 @@ #include "plugins/ecmascript/tests/runtime/common/test_helper.h" #include "utils/bit_utils.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; namespace panda::test { @@ -50,17 +52,22 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + PandaVM *instance_ {nullptr}; + +private: + EcmaHandleScope *scope_ {nullptr}; }; /* @@ -73,23 +80,23 @@ TEST_F(BuiltinsErrorsTest, GetJSErrorObject) /** * @tc.steps: step1. Create JSError object */ - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); JSHandle handle_obj = factory->GetJSError(ErrorType::TYPE_ERROR); JSHandle msg_key(factory->NewFromCanBeCompressString("message")); - JSHandle name_key = thread->GlobalConstants()->GetHandledNameString(); + JSHandle name_key = thread_->GlobalConstants()->GetHandledNameString(); /** * @tc.steps: step2. obtain JSError object prototype chain name property and message property */ JSHandle msg_value( - JSObject::GetProperty(thread, JSHandle(handle_obj), msg_key).GetValue()); + JSObject::GetProperty(thread_, JSHandle(handle_obj), msg_key).GetValue()); EXPECT_EQ(reinterpret_cast(msg_value->GetRawData()) ->Compare(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("")).GetRawData())), 0); JSHandle name_value( - JSObject::GetProperty(thread, JSHandle(handle_obj), name_key).GetValue()); + JSObject::GetProperty(thread_, JSHandle(handle_obj), name_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("TypeError")).GetRawData()) ->Compare(reinterpret_cast(name_value->GetRawData())), @@ -103,19 +110,19 @@ TEST_F(BuiltinsErrorsTest, GetJSErrorObject) */ TEST_F(BuiltinsErrorsTest, GetJSErrorWithMessage) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); JSHandle handle_obj = factory->GetJSError(ErrorType::TYPE_ERROR, "I am type error"); JSHandle msg_key(factory->NewFromCanBeCompressString("message")); - JSHandle name_key = thread->GlobalConstants()->GetHandledNameString(); + JSHandle name_key = thread_->GlobalConstants()->GetHandledNameString(); JSHandle msg_value( - JSObject::GetProperty(thread, JSHandle(handle_obj), msg_key).GetValue()); + JSObject::GetProperty(thread_, JSHandle(handle_obj), msg_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("I am type error")).GetRawData()) ->Compare(reinterpret_cast(msg_value->GetRawData())), 0); JSHandle name_value( - JSObject::GetProperty(thread, JSHandle(handle_obj), name_key).GetValue()); + JSObject::GetProperty(thread_, JSHandle(handle_obj), name_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("TypeError")).GetRawData()) ->Compare(reinterpret_cast(name_value->GetRawData())), @@ -129,31 +136,31 @@ TEST_F(BuiltinsErrorsTest, GetJSErrorWithMessage) */ TEST_F(BuiltinsErrorsTest, ErrorNoParameterConstructor) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error(env->GetErrorFunction()); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*error), 4); ecma_runtime_call_info->SetFunction(error.GetTaggedValue()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = error::ErrorConstructor(ecma_runtime_call_info.get()); EXPECT_TRUE(result.IsECMAObject()); - JSHandle error_object(thread, reinterpret_cast(result.GetRawData())); + JSHandle error_object(thread_, reinterpret_cast(result.GetRawData())); JSHandle msg_key(factory->NewFromCanBeCompressString("message")); - JSHandle name_key = thread->GlobalConstants()->GetHandledNameString(); + JSHandle name_key = thread_->GlobalConstants()->GetHandledNameString(); - JSHandle msg_value(JSObject::GetProperty(thread, error_object, msg_key).GetValue()); + JSHandle msg_value(JSObject::GetProperty(thread_, error_object, msg_key).GetValue()); ASSERT_EQ( reinterpret_cast(ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("")).GetRawData()) ->Compare(reinterpret_cast(msg_value->GetRawData())), 0); - JSHandle name_value(JSObject::GetProperty(thread, error_object, name_key).GetValue()); + JSHandle name_value(JSObject::GetProperty(thread_, error_object, name_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("Error")).GetRawData()) ->Compare(reinterpret_cast(name_value->GetRawData())), @@ -167,33 +174,33 @@ TEST_F(BuiltinsErrorsTest, ErrorNoParameterConstructor) */ TEST_F(BuiltinsErrorsTest, ErrorParameterConstructor) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error(env->GetErrorFunction()); JSHandle param_msg(factory->NewFromCanBeCompressString("Hello Error!")); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*error), 6); ecma_runtime_call_info->SetFunction(error.GetTaggedValue()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); ecma_runtime_call_info->SetCallArg(0, param_msg.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = error::ErrorConstructor(ecma_runtime_call_info.get()); EXPECT_TRUE(result.IsECMAObject()); - JSHandle error_object(thread, reinterpret_cast(result.GetRawData())); + JSHandle error_object(thread_, reinterpret_cast(result.GetRawData())); JSHandle msg_key(factory->NewFromCanBeCompressString("message")); - JSHandle name_key = thread->GlobalConstants()->GetHandledNameString(); - JSHandle msg_value(JSObject::GetProperty(thread, error_object, msg_key).GetValue()); + JSHandle name_key = thread_->GlobalConstants()->GetHandledNameString(); + JSHandle msg_value(JSObject::GetProperty(thread_, error_object, msg_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("Hello Error!")).GetRawData()) ->Compare(reinterpret_cast(msg_value->GetRawData())), 0); - JSHandle name_value(JSObject::GetProperty(thread, error_object, name_key).GetValue()); + JSHandle name_value(JSObject::GetProperty(thread_, error_object, name_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("Error")).GetRawData()) ->Compare(reinterpret_cast(name_value->GetRawData())), @@ -207,20 +214,20 @@ TEST_F(BuiltinsErrorsTest, ErrorParameterConstructor) */ TEST_F(BuiltinsErrorsTest, ErrorNoParameterToString) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error_object = env->GetErrorFunction(); JSHandle error = factory->NewJSObjectByConstructor(JSHandle(error_object), error_object); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = error::proto::ToString(ecma_runtime_call_info.get()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); EXPECT_TRUE(result.IsString()); EXPECT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("Error")).GetRawData()) @@ -235,25 +242,25 @@ TEST_F(BuiltinsErrorsTest, ErrorNoParameterToString) */ TEST_F(BuiltinsErrorsTest, ErrorToString) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error_object = env->GetErrorFunction(); JSHandle error = factory->NewJSObjectByConstructor(JSHandle(error_object), error_object); JSHandle handle_msg_key(factory->NewFromCanBeCompressString("message")); JSObject::SetProperty( - thread, JSHandle(error), handle_msg_key, - JSHandle(thread, factory->NewFromCanBeCompressString("This is Error!").GetTaggedValue())); + thread_, JSHandle(error), handle_msg_key, + JSHandle(thread_, factory->NewFromCanBeCompressString("This is Error!").GetTaggedValue())); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = error::proto::ToString(ecma_runtime_call_info.get()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); EXPECT_TRUE(result.IsString()); EXPECT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("Error: This is Error!")).GetRawData()) @@ -268,30 +275,30 @@ TEST_F(BuiltinsErrorsTest, ErrorToString) */ TEST_F(BuiltinsErrorsTest, RangeErrorNoParameterConstructor) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error(env->GetRangeErrorFunction()); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(error.GetTaggedValue()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = range_error::RangeErrorConstructor(ecma_runtime_call_info.get()); EXPECT_TRUE(result.IsECMAObject()); - JSHandle error_object(thread, reinterpret_cast(result.GetRawData())); + JSHandle error_object(thread_, reinterpret_cast(result.GetRawData())); JSHandle msg_key(factory->NewFromCanBeCompressString("message")); - JSHandle name_key = thread->GlobalConstants()->GetHandledNameString(); + JSHandle name_key = thread_->GlobalConstants()->GetHandledNameString(); - JSHandle msg_value(JSObject::GetProperty(thread, error_object, msg_key).GetValue()); + JSHandle msg_value(JSObject::GetProperty(thread_, error_object, msg_key).GetValue()); ASSERT_EQ( reinterpret_cast(ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("")).GetRawData()) ->Compare(reinterpret_cast(JSTaggedValue(msg_value.GetTaggedValue()).GetRawData())), 0); - JSHandle name_value(JSObject::GetProperty(thread, error_object, name_key).GetValue()); + JSHandle name_value(JSObject::GetProperty(thread_, error_object, name_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("RangeError")).GetRawData()) ->Compare(reinterpret_cast(JSTaggedValue(name_value.GetTaggedValue()).GetRawData())), @@ -305,33 +312,33 @@ TEST_F(BuiltinsErrorsTest, RangeErrorNoParameterConstructor) */ TEST_F(BuiltinsErrorsTest, RangeErrorParameterConstructor) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error(env->GetRangeErrorFunction()); JSHandle param_msg(factory->NewFromCanBeCompressString("Hello RangeError!")); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*error), 6); ecma_runtime_call_info->SetFunction(error.GetTaggedValue()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); ecma_runtime_call_info->SetCallArg(0, param_msg.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = range_error::RangeErrorConstructor(ecma_runtime_call_info.get()); EXPECT_TRUE(result.IsECMAObject()); - JSHandle error_object(thread, reinterpret_cast(result.GetRawData())); + JSHandle error_object(thread_, reinterpret_cast(result.GetRawData())); JSHandle msg_key(factory->NewFromCanBeCompressString("message")); - JSHandle name_key = thread->GlobalConstants()->GetHandledNameString(); + JSHandle name_key = thread_->GlobalConstants()->GetHandledNameString(); - JSHandle msg_value(JSObject::GetProperty(thread, error_object, msg_key).GetValue()); + JSHandle msg_value(JSObject::GetProperty(thread_, error_object, msg_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("Hello RangeError!")).GetRawData()) ->Compare(reinterpret_cast(msg_value->GetRawData())), 0); - JSHandle name_value(JSObject::GetProperty(thread, error_object, name_key).GetValue()); + JSHandle name_value(JSObject::GetProperty(thread_, error_object, name_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("RangeError")).GetRawData()) ->Compare(reinterpret_cast(name_value->GetRawData())), @@ -345,19 +352,19 @@ TEST_F(BuiltinsErrorsTest, RangeErrorParameterConstructor) */ TEST_F(BuiltinsErrorsTest, RangeErrorNoParameterToString) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error_object = env->GetRangeErrorFunction(); JSHandle error = factory->NewJSObjectByConstructor(JSHandle(error_object), error_object); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = range_error::proto::ToString(ecma_runtime_call_info.get()); - JSHandle result_handle(thread, result); + JSHandle result_handle(thread_, result); EXPECT_TRUE(result.IsString()); @@ -374,24 +381,24 @@ TEST_F(BuiltinsErrorsTest, RangeErrorNoParameterToString) */ TEST_F(BuiltinsErrorsTest, RangeErrorToString) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error_object = env->GetRangeErrorFunction(); JSHandle error = factory->NewJSObjectByConstructor(JSHandle(error_object), error_object); JSHandle handle_msg_key(factory->NewFromCanBeCompressString("message")); - JSObject::SetProperty(thread, JSHandle(error), handle_msg_key, + JSObject::SetProperty(thread_, JSHandle(error), handle_msg_key, JSHandle(factory->NewFromCanBeCompressString("This is RangeError!"))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = range_error::proto::ToString(ecma_runtime_call_info.get()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); EXPECT_TRUE(result.IsString()); EXPECT_EQ(factory->NewFromCanBeCompressString("RangeError: This is RangeError!")->Compare(*result_handle), 0); } @@ -404,30 +411,30 @@ TEST_F(BuiltinsErrorsTest, RangeErrorToString) */ TEST_F(BuiltinsErrorsTest, ReferenceErrorNoParameterConstructor) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error(env->GetReferenceErrorFunction()); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*error), 4); ecma_runtime_call_info->SetFunction(error.GetTaggedValue()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = reference_error::ReferenceErrorConstructor(ecma_runtime_call_info.get()); EXPECT_TRUE(result.IsECMAObject()); - JSHandle error_object(thread, reinterpret_cast(result.GetRawData())); + JSHandle error_object(thread_, reinterpret_cast(result.GetRawData())); JSHandle msg_key(factory->NewFromCanBeCompressString("message")); - JSHandle name_key = thread->GlobalConstants()->GetHandledNameString(); + JSHandle name_key = thread_->GlobalConstants()->GetHandledNameString(); - JSHandle msg_value(JSObject::GetProperty(thread, error_object, msg_key).GetValue()); + JSHandle msg_value(JSObject::GetProperty(thread_, error_object, msg_key).GetValue()); ASSERT_EQ( reinterpret_cast(ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("")).GetRawData()) ->Compare(reinterpret_cast(msg_value->GetRawData())), 0); - JSHandle name_value(JSObject::GetProperty(thread, error_object, name_key).GetValue()); + JSHandle name_value(JSObject::GetProperty(thread_, error_object, name_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("ReferenceError")).GetRawData()) ->Compare(reinterpret_cast(name_value->GetRawData())), @@ -441,31 +448,31 @@ TEST_F(BuiltinsErrorsTest, ReferenceErrorNoParameterConstructor) */ TEST_F(BuiltinsErrorsTest, ReferenceErrorParameterConstructor) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error(env->GetReferenceErrorFunction()); JSHandle param_msg(factory->NewFromCanBeCompressString("Hello ReferenceError!")); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*error), 6); ecma_runtime_call_info->SetFunction(error.GetTaggedValue()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); ecma_runtime_call_info->SetCallArg(0, param_msg.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = reference_error::ReferenceErrorConstructor(ecma_runtime_call_info.get()); EXPECT_TRUE(result.IsECMAObject()); - JSHandle error_object(thread, reinterpret_cast(result.GetRawData())); + JSHandle error_object(thread_, reinterpret_cast(result.GetRawData())); JSHandle msg_key(factory->NewFromCanBeCompressString("message")); - JSHandle name_key = thread->GlobalConstants()->GetHandledNameString(); - JSHandle msg_value(JSObject::GetProperty(thread, error_object, msg_key).GetValue()); + JSHandle name_key = thread_->GlobalConstants()->GetHandledNameString(); + JSHandle msg_value(JSObject::GetProperty(thread_, error_object, msg_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("Hello ReferenceError!")).GetRawData()) ->Compare(reinterpret_cast(msg_value->GetRawData())), 0); - JSHandle name_value(JSObject::GetProperty(thread, error_object, name_key).GetValue()); + JSHandle name_value(JSObject::GetProperty(thread_, error_object, name_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("ReferenceError")).GetRawData()) ->Compare(reinterpret_cast(name_value->GetRawData())), @@ -479,19 +486,19 @@ TEST_F(BuiltinsErrorsTest, ReferenceErrorParameterConstructor) */ TEST_F(BuiltinsErrorsTest, ReferenceErrorNoParameterToString) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error_object = env->GetReferenceErrorFunction(); JSHandle error = factory->NewJSObjectByConstructor(JSHandle(error_object), error_object); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = reference_error::proto::ToString(ecma_runtime_call_info.get()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); EXPECT_TRUE(result.IsString()); EXPECT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("ReferenceError")).GetRawData()) @@ -506,23 +513,23 @@ TEST_F(BuiltinsErrorsTest, ReferenceErrorNoParameterToString) */ TEST_F(BuiltinsErrorsTest, ReferenceErrorToString) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error_object = env->GetReferenceErrorFunction(); JSHandle error = factory->NewJSObjectByConstructor(JSHandle(error_object), error_object); JSHandle handle_msg_key(factory->NewFromCanBeCompressString("message")); - JSObject::SetProperty(thread, JSHandle(error), handle_msg_key, + JSObject::SetProperty(thread_, JSHandle(error), handle_msg_key, JSHandle(factory->NewFromCanBeCompressString("This is ReferenceError!"))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = reference_error::proto::ToString(ecma_runtime_call_info.get()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); EXPECT_TRUE(result.IsString()); EXPECT_EQ(factory->NewFromCanBeCompressString("ReferenceError: This is ReferenceError!")->Compare(*result_handle), 0); @@ -535,30 +542,30 @@ TEST_F(BuiltinsErrorsTest, ReferenceErrorToString) */ TEST_F(BuiltinsErrorsTest, TypeErrorNoParameterConstructor) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error(env->GetTypeErrorFunction()); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*error), 4); ecma_runtime_call_info->SetFunction(error.GetTaggedValue()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = type_error::TypeErrorConstructor(ecma_runtime_call_info.get()); EXPECT_TRUE(result.IsECMAObject()); - JSHandle error_object(thread, reinterpret_cast(result.GetRawData())); + JSHandle error_object(thread_, reinterpret_cast(result.GetRawData())); JSHandle msg_key(factory->NewFromCanBeCompressString("message")); - JSHandle name_key = thread->GlobalConstants()->GetHandledNameString(); + JSHandle name_key = thread_->GlobalConstants()->GetHandledNameString(); - JSHandle msg_value(JSObject::GetProperty(thread, error_object, msg_key).GetValue()); + JSHandle msg_value(JSObject::GetProperty(thread_, error_object, msg_key).GetValue()); ASSERT_EQ( reinterpret_cast(ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("")).GetRawData()) ->Compare(reinterpret_cast(msg_value->GetRawData())), 0); - JSHandle name_value(JSObject::GetProperty(thread, error_object, name_key).GetValue()); + JSHandle name_value(JSObject::GetProperty(thread_, error_object, name_key).GetValue()); EXPECT_EQ(reinterpret_cast(JSTaggedValue(name_value.GetTaggedValue()).GetRawData()) ->Compare(reinterpret_cast(JSTaggedValue(name_value.GetTaggedValue()).GetRawData())), 0); @@ -571,32 +578,32 @@ TEST_F(BuiltinsErrorsTest, TypeErrorNoParameterConstructor) */ TEST_F(BuiltinsErrorsTest, TypeErrorParameterConstructor) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error(env->GetTypeErrorFunction()); JSHandle param_msg(factory->NewFromCanBeCompressString("Hello TypeError!")); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*error), 6); ecma_runtime_call_info->SetFunction(error.GetTaggedValue()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); ecma_runtime_call_info->SetCallArg(0, param_msg.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = type_error::TypeErrorConstructor(ecma_runtime_call_info.get()); EXPECT_TRUE(result.IsECMAObject()); - JSHandle error_object(thread, reinterpret_cast(result.GetRawData())); + JSHandle error_object(thread_, reinterpret_cast(result.GetRawData())); JSHandle msg_key(factory->NewFromCanBeCompressString("message")); - JSHandle name_key = thread->GlobalConstants()->GetHandledNameString(); + JSHandle name_key = thread_->GlobalConstants()->GetHandledNameString(); - JSHandle msg_value(JSObject::GetProperty(thread, error_object, msg_key).GetValue()); + JSHandle msg_value(JSObject::GetProperty(thread_, error_object, msg_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("Hello TypeError!")).GetRawData()) ->Compare(reinterpret_cast(msg_value->GetRawData())), 0); - JSHandle name_value(JSObject::GetProperty(thread, error_object, name_key).GetValue()); + JSHandle name_value(JSObject::GetProperty(thread_, error_object, name_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("TypeError")).GetRawData()) ->Compare(reinterpret_cast(name_value->GetRawData())), @@ -610,19 +617,19 @@ TEST_F(BuiltinsErrorsTest, TypeErrorParameterConstructor) */ TEST_F(BuiltinsErrorsTest, TypeErrorNoParameterToString) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error_object = env->GetTypeErrorFunction(); JSHandle error = factory->NewJSObjectByConstructor(JSHandle(error_object), error_object); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = type_error::proto::ToString(ecma_runtime_call_info.get()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); EXPECT_TRUE(result.IsString()); EXPECT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("TypeError")).GetRawData()) @@ -637,23 +644,23 @@ TEST_F(BuiltinsErrorsTest, TypeErrorNoParameterToString) */ TEST_F(BuiltinsErrorsTest, TypeErrorToString) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error_object = env->GetTypeErrorFunction(); JSHandle error = factory->NewJSObjectByConstructor(JSHandle(error_object), error_object); JSHandle value(factory->NewFromCanBeCompressString("This is TypeError!")); JSHandle handle_msg_key(factory->NewFromCanBeCompressString("message")); - JSObject::SetProperty(thread, JSHandle(error), handle_msg_key, value); + JSObject::SetProperty(thread_, JSHandle(error), handle_msg_key, value); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = type_error::proto::ToString(ecma_runtime_call_info.get()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); EXPECT_TRUE(result.IsString()); EXPECT_EQ(factory->NewFromCanBeCompressString("TypeError: This is TypeError!")->Compare(*result_handle), 0); } @@ -665,30 +672,30 @@ TEST_F(BuiltinsErrorsTest, TypeErrorToString) */ TEST_F(BuiltinsErrorsTest, URIErrorNoParameterConstructor) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error(env->GetURIErrorFunction()); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*error), 4); ecma_runtime_call_info->SetFunction(error.GetTaggedValue()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = uri_error::URIErrorConstructor(ecma_runtime_call_info.get()); EXPECT_TRUE(result.IsECMAObject()); - JSHandle error_object(thread, reinterpret_cast(result.GetRawData())); + JSHandle error_object(thread_, reinterpret_cast(result.GetRawData())); JSHandle msg_key(factory->NewFromCanBeCompressString("message")); - JSHandle name_key = thread->GlobalConstants()->GetHandledNameString(); + JSHandle name_key = thread_->GlobalConstants()->GetHandledNameString(); - JSHandle msg_value(JSObject::GetProperty(thread, error_object, msg_key).GetValue()); + JSHandle msg_value(JSObject::GetProperty(thread_, error_object, msg_key).GetValue()); ASSERT_EQ( reinterpret_cast(ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("")).GetRawData()) ->Compare(reinterpret_cast(msg_value->GetRawData())), 0); - JSHandle name_value(JSObject::GetProperty(thread, error_object, name_key).GetValue()); + JSHandle name_value(JSObject::GetProperty(thread_, error_object, name_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("URIError")).GetRawData()) ->Compare(reinterpret_cast(name_value->GetRawData())), @@ -702,32 +709,32 @@ TEST_F(BuiltinsErrorsTest, URIErrorNoParameterConstructor) */ TEST_F(BuiltinsErrorsTest, URIErrorParameterConstructor) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error(env->GetURIErrorFunction()); JSHandle param_msg(factory->NewFromCanBeCompressString("Hello URIError!")); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*error), 6); ecma_runtime_call_info->SetFunction(error.GetTaggedValue()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); ecma_runtime_call_info->SetCallArg(0, param_msg.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = uri_error::URIErrorConstructor(ecma_runtime_call_info.get()); EXPECT_TRUE(result.IsECMAObject()); - JSHandle error_object(thread, reinterpret_cast(result.GetRawData())); + JSHandle error_object(thread_, reinterpret_cast(result.GetRawData())); JSHandle msg_key(factory->NewFromCanBeCompressString("message")); - JSHandle name_key = thread->GlobalConstants()->GetHandledNameString(); + JSHandle name_key = thread_->GlobalConstants()->GetHandledNameString(); - JSHandle msg_value(JSObject::GetProperty(thread, error_object, msg_key).GetValue()); + JSHandle msg_value(JSObject::GetProperty(thread_, error_object, msg_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("Hello URIError!")).GetRawData()) ->Compare(reinterpret_cast(msg_value->GetRawData())), 0); - JSHandle name_value(JSObject::GetProperty(thread, error_object, name_key).GetValue()); + JSHandle name_value(JSObject::GetProperty(thread_, error_object, name_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("URIError")).GetRawData()) ->Compare(reinterpret_cast(name_value->GetRawData())), @@ -741,19 +748,19 @@ TEST_F(BuiltinsErrorsTest, URIErrorParameterConstructor) */ TEST_F(BuiltinsErrorsTest, URIErrorNoParameterToString) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error_object = env->GetURIErrorFunction(); JSHandle error = factory->NewJSObjectByConstructor(JSHandle(error_object), error_object); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = uri_error::proto::ToString(ecma_runtime_call_info.get()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); EXPECT_TRUE(result.IsString()); EXPECT_EQ(reinterpret_cast( @@ -769,24 +776,24 @@ TEST_F(BuiltinsErrorsTest, URIErrorNoParameterToString) */ TEST_F(BuiltinsErrorsTest, URIErrorToString) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error_object = env->GetURIErrorFunction(); JSHandle error = factory->NewJSObjectByConstructor(JSHandle(error_object), error_object); JSHandle handle_msg_key(factory->NewFromCanBeCompressString("message")); JSObject::SetProperty( - thread, JSHandle(error), handle_msg_key, - JSHandle(thread, factory->NewFromCanBeCompressString("This is URIError!").GetTaggedValue())); + thread_, JSHandle(error), handle_msg_key, + JSHandle(thread_, factory->NewFromCanBeCompressString("This is URIError!").GetTaggedValue())); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = uri_error::proto::ToString(ecma_runtime_call_info.get()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); EXPECT_TRUE(result.IsString()); EXPECT_EQ( @@ -803,30 +810,30 @@ TEST_F(BuiltinsErrorsTest, URIErrorToString) */ TEST_F(BuiltinsErrorsTest, SyntaxErrorNoParameterConstructor) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error(env->GetSyntaxErrorFunction()); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*error), 4); ecma_runtime_call_info->SetFunction(error.GetTaggedValue()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = syntax_error::SyntaxErrorConstructor(ecma_runtime_call_info.get()); EXPECT_TRUE(result.IsECMAObject()); - JSHandle error_object(thread, reinterpret_cast(result.GetRawData())); + JSHandle error_object(thread_, reinterpret_cast(result.GetRawData())); JSHandle msg_key(factory->NewFromCanBeCompressString("message")); - JSHandle name_key = thread->GlobalConstants()->GetHandledNameString(); + JSHandle name_key = thread_->GlobalConstants()->GetHandledNameString(); - JSHandle msg_value(JSObject::GetProperty(thread, error_object, msg_key).GetValue()); + JSHandle msg_value(JSObject::GetProperty(thread_, error_object, msg_key).GetValue()); ASSERT_EQ( reinterpret_cast(ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("")).GetRawData()) ->Compare(reinterpret_cast(msg_value->GetRawData())), 0); - JSHandle name_value(JSObject::GetProperty(thread, error_object, name_key).GetValue()); + JSHandle name_value(JSObject::GetProperty(thread_, error_object, name_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("SyntaxError")).GetRawData()) ->Compare(reinterpret_cast(name_value->GetRawData())), @@ -840,32 +847,32 @@ TEST_F(BuiltinsErrorsTest, SyntaxErrorNoParameterConstructor) */ TEST_F(BuiltinsErrorsTest, SyntaxErrorParameterConstructor) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error(env->GetSyntaxErrorFunction()); JSHandle param_msg(factory->NewFromCanBeCompressString("Hello SyntaxError!")); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*error), 6); ecma_runtime_call_info->SetFunction(error.GetTaggedValue()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); ecma_runtime_call_info->SetCallArg(0, param_msg.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = syntax_error::SyntaxErrorConstructor(ecma_runtime_call_info.get()); EXPECT_TRUE(result.IsECMAObject()); - JSHandle error_object(thread, reinterpret_cast(result.GetRawData())); + JSHandle error_object(thread_, reinterpret_cast(result.GetRawData())); JSHandle msg_key(factory->NewFromCanBeCompressString("message")); - JSHandle name_key = thread->GlobalConstants()->GetHandledNameString(); + JSHandle name_key = thread_->GlobalConstants()->GetHandledNameString(); - JSHandle msg_value(JSObject::GetProperty(thread, error_object, msg_key).GetValue()); + JSHandle msg_value(JSObject::GetProperty(thread_, error_object, msg_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("Hello SyntaxError!")).GetRawData()) ->Compare(reinterpret_cast(msg_value->GetRawData())), 0); - JSHandle name_value(JSObject::GetProperty(thread, error_object, name_key).GetValue()); + JSHandle name_value(JSObject::GetProperty(thread_, error_object, name_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("SyntaxError")).GetRawData()) ->Compare(reinterpret_cast(name_value->GetRawData())), @@ -879,19 +886,19 @@ TEST_F(BuiltinsErrorsTest, SyntaxErrorParameterConstructor) */ TEST_F(BuiltinsErrorsTest, SyntaxErrorNoParameterToString) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error_object = env->GetSyntaxErrorFunction(); JSHandle error = factory->NewJSObjectByConstructor(JSHandle(error_object), error_object); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = syntax_error::proto::ToString(ecma_runtime_call_info.get()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); EXPECT_TRUE(result.IsString()); EXPECT_EQ(reinterpret_cast( @@ -907,23 +914,23 @@ TEST_F(BuiltinsErrorsTest, SyntaxErrorNoParameterToString) */ TEST_F(BuiltinsErrorsTest, SyntaxErrorToString) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error_object = env->GetSyntaxErrorFunction(); JSHandle error = factory->NewJSObjectByConstructor(JSHandle(error_object), error_object); JSHandle handle_msg_key(factory->NewFromCanBeCompressString("message")); - JSObject::SetProperty(thread, JSHandle(error), handle_msg_key, + JSObject::SetProperty(thread_, JSHandle(error), handle_msg_key, JSHandle(factory->NewFromCanBeCompressString("This is SyntaxError!"))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = syntax_error::proto::ToString(ecma_runtime_call_info.get()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); EXPECT_TRUE(result.IsString()); EXPECT_EQ(factory->NewFromCanBeCompressString("SyntaxError: This is SyntaxError!")->Compare(*result_handle), 0); @@ -936,30 +943,30 @@ TEST_F(BuiltinsErrorsTest, SyntaxErrorToString) */ TEST_F(BuiltinsErrorsTest, EvalErrorNoParameterConstructor) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error(env->GetEvalErrorFunction()); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*error), 4); ecma_runtime_call_info->SetFunction(error.GetTaggedValue()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = eval_error::EvalErrorConstructor(ecma_runtime_call_info.get()); EXPECT_TRUE(result.IsECMAObject()); - JSHandle error_object(thread, reinterpret_cast(result.GetRawData())); + JSHandle error_object(thread_, reinterpret_cast(result.GetRawData())); JSHandle msg_key(factory->NewFromCanBeCompressString("message")); - JSHandle name_key = thread->GlobalConstants()->GetHandledNameString(); + JSHandle name_key = thread_->GlobalConstants()->GetHandledNameString(); - JSHandle msg_value(JSObject::GetProperty(thread, error_object, msg_key).GetValue()); + JSHandle msg_value(JSObject::GetProperty(thread_, error_object, msg_key).GetValue()); ASSERT_EQ( reinterpret_cast(ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("")).GetRawData()) ->Compare(reinterpret_cast(msg_value->GetRawData())), 0); - JSHandle name_value(JSObject::GetProperty(thread, error_object, name_key).GetValue()); + JSHandle name_value(JSObject::GetProperty(thread_, error_object, name_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("EvalError")).GetRawData()) ->Compare(reinterpret_cast(name_value->GetRawData())), @@ -973,32 +980,32 @@ TEST_F(BuiltinsErrorsTest, EvalErrorNoParameterConstructor) */ TEST_F(BuiltinsErrorsTest, EvalErrorParameterConstructor) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error(env->GetEvalErrorFunction()); JSHandle param_msg(factory->NewFromCanBeCompressString("Hello EvalError!")); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*error), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*error), 6); ecma_runtime_call_info->SetFunction(error.GetTaggedValue()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); ecma_runtime_call_info->SetCallArg(0, param_msg.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = eval_error::EvalErrorConstructor(ecma_runtime_call_info.get()); EXPECT_TRUE(result.IsECMAObject()); - JSHandle error_object(thread, reinterpret_cast(result.GetRawData())); + JSHandle error_object(thread_, reinterpret_cast(result.GetRawData())); JSHandle msg_key(factory->NewFromCanBeCompressString("message")); - JSHandle name_key = thread->GlobalConstants()->GetHandledNameString(); + JSHandle name_key = thread_->GlobalConstants()->GetHandledNameString(); - JSHandle msg_value(JSObject::GetProperty(thread, error_object, msg_key).GetValue()); + JSHandle msg_value(JSObject::GetProperty(thread_, error_object, msg_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("Hello EvalError!")).GetRawData()) ->Compare(reinterpret_cast(msg_value->GetRawData())), 0); - JSHandle name_value(JSObject::GetProperty(thread, error_object, name_key).GetValue()); + JSHandle name_value(JSObject::GetProperty(thread_, error_object, name_key).GetValue()); ASSERT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("EvalError")).GetRawData()) ->Compare(reinterpret_cast(name_value->GetRawData())), @@ -1012,18 +1019,18 @@ TEST_F(BuiltinsErrorsTest, EvalErrorParameterConstructor) */ TEST_F(BuiltinsErrorsTest, EvalErrorNoParameterToString) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error_object = env->GetEvalErrorFunction(); JSHandle error = factory->NewJSObjectByConstructor(JSHandle(error_object), error_object); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = eval_error::proto::ToString(ecma_runtime_call_info.get()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); EXPECT_TRUE(result.IsString()); EXPECT_EQ(reinterpret_cast( ecmascript::JSTaggedValue(*factory->NewFromCanBeCompressString("EvalError")).GetRawData()) @@ -1038,24 +1045,24 @@ TEST_F(BuiltinsErrorsTest, EvalErrorNoParameterToString) */ TEST_F(BuiltinsErrorsTest, EvalErrorToString) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle error_object = env->GetEvalErrorFunction(); JSHandle error = factory->NewJSObjectByConstructor(JSHandle(error_object), error_object); JSHandle handle_msg_key(factory->NewFromCanBeCompressString("message")); JSObject::SetProperty( - thread, JSHandle(error), handle_msg_key, - JSHandle(thread, factory->NewFromCanBeCompressString("This is EvalError!").GetTaggedValue())); + thread_, JSHandle(error), handle_msg_key, + JSHandle(thread_, factory->NewFromCanBeCompressString("This is EvalError!").GetTaggedValue())); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue(*error)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = eval_error::proto::ToString(ecma_runtime_call_info.get()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); EXPECT_TRUE(result.IsString()); EXPECT_EQ(factory->NewFromCanBeCompressString("EvalError: This is EvalError!")->Compare(*result_handle), 0); } diff --git a/tests/runtime/builtins/builtins_function_test.cpp b/tests/runtime/builtins/builtins_function_test.cpp index e3083888bf66777b6ae84ec9c548b8be9f39f77f..4784e56ced5adc8807d4d57a9776ae08aa4220f6 100644 --- a/tests/runtime/builtins/builtins_function_test.cpp +++ b/tests/runtime/builtins/builtins_function_test.cpp @@ -27,9 +27,12 @@ #include "plugins/ecmascript/runtime/tagged_array-inl.h" #include "plugins/ecmascript/tests/runtime/common/test_helper.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; -using JSArray = panda::ecmascript::JSArray; + +// NOLINTBEGIN(readability-magic-numbers) namespace panda::test { class BuiltinsFunctionTest : public testing::Test { @@ -46,17 +49,21 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; // native function for test apply and call @@ -90,162 +97,162 @@ JSTaggedValue TestFunctionApplyAndCall(EcmaRuntimeCallInfo *argv) // func.apply(thisArg) TEST_F(BuiltinsFunctionTest, FunctionPrototypeApply) { - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // ecma 19.2.3.1: func JSHandle func = factory->NewJSFunction(env, reinterpret_cast(TestFunctionApplyAndCall)); // ecma 19.2.3.1: thisArg - JSHandle this_arg(thread, env->GetGlobalObject()); - JSObject::SetProperty(thread, JSHandle(this_arg), + JSHandle this_arg(thread_, env->GetGlobalObject()); + JSObject::SetProperty(thread_, JSHandle(this_arg), JSHandle(factory->NewFromCanBeCompressString("test_builtins_function_a")), - JSHandle(thread, JSTaggedValue(1))); - JSObject::SetProperty(thread, JSHandle(this_arg), + JSHandle(thread_, JSTaggedValue(1))); + JSObject::SetProperty(thread_, JSHandle(this_arg), JSHandle(factory->NewFromCanBeCompressString("test_builtins_function_b")), - JSHandle(thread, JSTaggedValue(2))); + JSHandle(thread_, JSTaggedValue(2))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(func.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, (this_arg.GetTaggedValue())); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = function::proto::Apply(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(3).GetRawData()); - JSObject::DeleteProperty(thread, (this_arg), + JSObject::DeleteProperty(thread_, (this_arg), JSHandle(factory->NewFromCanBeCompressString("test_builtins_function_a"))); - JSObject::DeleteProperty(thread, (this_arg), + JSObject::DeleteProperty(thread_, (this_arg), JSHandle(factory->NewFromCanBeCompressString("test_builtins_function_b"))); } // func.apply(thisArg, argArray) TEST_F(BuiltinsFunctionTest, FunctionPrototypeApply1) { - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // ecma 19.2.3.1: func JSHandle func = factory->NewJSFunction(env, reinterpret_cast(TestFunctionApplyAndCall)); // ecma 19.2.3.1: thisArg - JSHandle this_arg(thread, env->GetGlobalObject()); - JSObject::SetProperty(thread, JSHandle(this_arg), + JSHandle this_arg(thread_, env->GetGlobalObject()); + JSObject::SetProperty(thread_, JSHandle(this_arg), JSHandle(factory->NewFromCanBeCompressString("test_builtins_function_a")), - JSHandle(thread, JSTaggedValue(10))); - JSObject::SetProperty(thread, JSHandle(this_arg), + JSHandle(thread_, JSTaggedValue(10))); + JSObject::SetProperty(thread_, JSHandle(this_arg), JSHandle(factory->NewFromCanBeCompressString("test_builtins_function_b")), - JSHandle(thread, JSTaggedValue(20))); + JSHandle(thread_, JSTaggedValue(20))); // ecma 19.2.3.1: argArray - JSHandle array(JSArray::ArrayCreate(thread, JSTaggedNumber(2))); - PropertyDescriptor desc(thread, JSHandle(thread, JSTaggedValue(30))); - JSArray::DefineOwnProperty(thread, array, JSHandle(thread, JSTaggedValue(0)), desc); + JSHandle array(JSArray::ArrayCreate(thread_, JSTaggedNumber(2))); + PropertyDescriptor desc(thread_, JSHandle(thread_, JSTaggedValue(30))); + JSArray::DefineOwnProperty(thread_, array, JSHandle(thread_, JSTaggedValue(0)), desc); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(40))); - JSArray::DefineOwnProperty(thread, array, JSHandle(thread, JSTaggedValue(1)), desc1); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(40))); + JSArray::DefineOwnProperty(thread_, array, JSHandle(thread_, JSTaggedValue(1)), desc1); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(func.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, (this_arg.GetTaggedValue())); ecma_runtime_call_info->SetCallArg(1, array.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = function::proto::Apply(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(100).GetRawData()); - JSObject::DeleteProperty(thread, (this_arg), + JSObject::DeleteProperty(thread_, (this_arg), JSHandle(factory->NewFromCanBeCompressString("test_builtins_function_a"))); - JSObject::DeleteProperty(thread, (this_arg), + JSObject::DeleteProperty(thread_, (this_arg), JSHandle(factory->NewFromCanBeCompressString("test_builtins_function_b"))); } // target.bind(thisArg) TEST_F(BuiltinsFunctionTest, FunctionPrototypeBind) { - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle target = factory->NewJSFunction(env); - JSFunction::SetFunctionName(thread, JSHandle(target), + JSFunction::SetFunctionName(thread_, JSHandle(target), JSHandle(factory->NewFromCanBeCompressString("target")), - JSHandle(thread, JSTaggedValue::Undefined())); - JSFunction::SetFunctionLength(thread, target, JSTaggedValue(2)); + JSHandle(thread_, JSTaggedValue::Undefined())); + JSFunction::SetFunctionLength(thread_, target, JSTaggedValue(2)); - JSHandle this_arg(thread, env->GetGlobalObject()); + JSHandle this_arg(thread_, env->GetGlobalObject()); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(target.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, (this_arg.GetTaggedValue())); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = function::proto::Bind(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsECMAObject()); - JSHandle result_func(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_func(thread_, reinterpret_cast(result.GetRawData())); // test BoundTarget ASSERT_EQ(result_func->GetBoundTarget(), target.GetTaggedValue()); // test BoundThis ASSERT_EQ(result_func->GetBoundThis(), this_arg.GetTaggedValue()); // test BoundArguments - JSHandle array(thread, result_func->GetBoundArguments()); + JSHandle array(thread_, result_func->GetBoundArguments()); ASSERT_EQ(array->GetLength(), 0); // test name property - auto global_const = thread->GlobalConstants(); + auto global_const = thread_->GlobalConstants(); JSHandle name_key = global_const->GetHandledNameString(); - JSHandle result_func_handle(thread, *result_func); - JSHandle result_name(JSObject::GetProperty(thread, result_func_handle, name_key).GetValue()); + JSHandle result_func_handle(thread_, *result_func); + JSHandle result_name(JSObject::GetProperty(thread_, result_func_handle, name_key).GetValue()); JSHandle bound_target = factory->NewFromCanBeCompressString("bound target"); ASSERT_EQ(result_name->Compare(*bound_target), 0); // test length property JSHandle length_key = global_const->GetHandledLengthString(); - JSHandle result_length(JSObject::GetProperty(thread, result_func_handle, length_key).GetValue()); - ASSERT_EQ(JSTaggedValue::ToNumber(thread, result_length).GetNumber(), 2.0); + JSHandle result_length(JSObject::GetProperty(thread_, result_func_handle, length_key).GetValue()); + ASSERT_EQ(JSTaggedValue::ToNumber(thread_, result_length).GetNumber(), 2.0); } // target.bind(thisArg, 123, "helloworld") TEST_F(BuiltinsFunctionTest, FunctionPrototypeBind1) { - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle target = factory->NewJSFunction(env); - JSFunction::SetFunctionName(thread, JSHandle(target), + JSFunction::SetFunctionName(thread_, JSHandle(target), JSHandle(factory->NewFromCanBeCompressString("target1")), - JSHandle(thread, JSTaggedValue::Undefined())); - JSFunction::SetFunctionLength(thread, target, JSTaggedValue(5)); + JSHandle(thread_, JSTaggedValue::Undefined())); + JSFunction::SetFunctionLength(thread_, target, JSTaggedValue(5)); - JSHandle this_arg(thread, env->GetGlobalObject()); + JSHandle this_arg(thread_, env->GetGlobalObject()); JSHandle str = factory->NewFromCanBeCompressString("helloworld"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(target.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, this_arg.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(123))); ecma_runtime_call_info->SetCallArg(2, str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = function::proto::Bind(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsECMAObject()); - JSHandle result_func(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_func(thread_, reinterpret_cast(result.GetRawData())); // test BoundTarget ASSERT_EQ(result_func->GetBoundTarget(), target.GetTaggedValue()); // test BoundThis ASSERT_EQ(result_func->GetBoundThis(), this_arg.GetTaggedValue()); // test BoundArguments - JSHandle array(thread, result_func->GetBoundArguments()); + JSHandle array(thread_, result_func->GetBoundArguments()); ASSERT_EQ(array->GetLength(), 2); JSTaggedValue elem = array->Get(0); JSTaggedValue elem1 = array->Get(1); @@ -254,54 +261,54 @@ TEST_F(BuiltinsFunctionTest, FunctionPrototypeBind1) ASSERT_EQ(elem1.GetRawData(), str.GetTaggedType()); ASSERT_TRUE(elem1.IsString()); // test name property - auto global_const = thread->GlobalConstants(); + auto global_const = thread_->GlobalConstants(); JSHandle name_key = global_const->GetHandledNameString(); - JSHandle result_func_handle(thread, *result_func); - JSHandle result_name(JSObject::GetProperty(thread, result_func_handle, name_key).GetValue()); + JSHandle result_func_handle(thread_, *result_func); + JSHandle result_name(JSObject::GetProperty(thread_, result_func_handle, name_key).GetValue()); JSHandle ruler_name = factory->NewFromCanBeCompressString("bound target1"); ASSERT_EQ(result_name->Compare(*ruler_name), 0); // test length property JSHandle length_key = global_const->GetHandledLengthString(); - JSHandle result_length(JSObject::GetProperty(thread, result_func_handle, length_key).GetValue()); + JSHandle result_length(JSObject::GetProperty(thread_, result_func_handle, length_key).GetValue()); // target.length is 5, (...args) length is 2 - ASSERT_EQ(JSTaggedValue::ToNumber(thread, result_length).GetNumber(), 3.0); + ASSERT_EQ(JSTaggedValue::ToNumber(thread_, result_length).GetNumber(), 3.0); } // target.bind(thisArg, 123, "helloworld") set target_name = EmptyString() TEST_F(BuiltinsFunctionTest, FunctionPrototypeBind2) { - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle target = factory->NewJSFunction(env); - PropertyDescriptor name_desc(thread, JSHandle(thread, JSTaggedValue(123)), false, false, true); - JSTaggedValue::DefinePropertyOrThrow(thread, JSHandle(target), - thread->GlobalConstants()->GetHandledNameString(), name_desc); - JSFunction::SetFunctionLength(thread, target, JSTaggedValue(5)); + PropertyDescriptor name_desc(thread_, JSHandle(thread_, JSTaggedValue(123)), false, false, true); + JSTaggedValue::DefinePropertyOrThrow(thread_, JSHandle(target), + thread_->GlobalConstants()->GetHandledNameString(), name_desc); + JSFunction::SetFunctionLength(thread_, target, JSTaggedValue(5)); - JSHandle this_arg(thread, env->GetGlobalObject()); + JSHandle this_arg(thread_, env->GetGlobalObject()); JSHandle str = factory->NewFromCanBeCompressString("helloworld"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(target.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, (this_arg.GetTaggedValue())); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(123))); ecma_runtime_call_info->SetCallArg(2, str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = function::proto::Bind(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsECMAObject()); - JSHandle result_func(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_func(thread_, reinterpret_cast(result.GetRawData())); // test BoundTarget ASSERT_EQ(result_func->GetBoundTarget(), target.GetTaggedValue()); // test BoundThis ASSERT_EQ(result_func->GetBoundThis(), this_arg.GetTaggedValue()); // test BoundArguments - JSHandle array(thread, result_func->GetBoundArguments()); + JSHandle array(thread_, result_func->GetBoundArguments()); ASSERT_EQ(array->GetLength(), 2); JSTaggedValue elem = array->Get(0); JSTaggedValue elem1 = array->Get(1); @@ -310,75 +317,75 @@ TEST_F(BuiltinsFunctionTest, FunctionPrototypeBind2) ASSERT_EQ(elem1.GetRawData(), str.GetTaggedType()); ASSERT_TRUE(elem1.IsString()); // test name property - auto global_const = thread->GlobalConstants(); + auto global_const = thread_->GlobalConstants(); JSHandle name_key = global_const->GetHandledNameString(); JSHandle result_func_handle(result_func); - JSHandle result_name(JSObject::GetProperty(thread, result_func_handle, name_key).GetValue()); + JSHandle result_name(JSObject::GetProperty(thread_, result_func_handle, name_key).GetValue()); JSHandle ruler_name = factory->NewFromCanBeCompressString("bound "); ASSERT_EQ(result_name->Compare(*ruler_name), 0); // test length property JSHandle length_key = global_const->GetHandledLengthString(); - JSHandle result_length(JSObject::GetProperty(thread, result_func_handle, length_key).GetValue()); + JSHandle result_length(JSObject::GetProperty(thread_, result_func_handle, length_key).GetValue()); // target.length is 5, (...args) length is 2 - ASSERT_EQ(JSTaggedValue::ToNumber(thread, result_length).GetNumber(), 3.0); + ASSERT_EQ(JSTaggedValue::ToNumber(thread_, result_length).GetNumber(), 3.0); } // func.call(thisArg) TEST_F(BuiltinsFunctionTest, FunctionPrototypeCall) { - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // ecma 19.2.3.3: func JSHandle func = factory->NewJSFunction(env, reinterpret_cast(TestFunctionApplyAndCall)); // ecma 19.2.3.3: thisArg - JSHandle this_arg(thread, env->GetGlobalObject()); - JSObject::SetProperty(thread, JSHandle(this_arg), + JSHandle this_arg(thread_, env->GetGlobalObject()); + JSObject::SetProperty(thread_, JSHandle(this_arg), JSHandle(factory->NewFromCanBeCompressString("test_builtins_function_a")), - JSHandle(thread, JSTaggedValue(1))); - JSObject::SetProperty(thread, JSHandle(this_arg), + JSHandle(thread_, JSTaggedValue(1))); + JSObject::SetProperty(thread_, JSHandle(this_arg), JSHandle(factory->NewFromCanBeCompressString("test_builtins_function_b")), - JSHandle(thread, JSTaggedValue(2))); + JSHandle(thread_, JSTaggedValue(2))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(func.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, (this_arg.GetTaggedValue())); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = function::proto::Call(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(3).GetRawData()); - JSObject::DeleteProperty(thread, (this_arg), + JSObject::DeleteProperty(thread_, (this_arg), JSHandle(factory->NewFromCanBeCompressString("test_builtins_function_a"))); - JSObject::DeleteProperty(thread, (this_arg), + JSObject::DeleteProperty(thread_, (this_arg), JSHandle(factory->NewFromCanBeCompressString("test_builtins_function_b"))); } // func.call(thisArg, 123, 456, 789) TEST_F(BuiltinsFunctionTest, FunctionPrototypeCall1) { - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // ecma 19.2.3.3: func JSHandle func = factory->NewJSFunction(env, reinterpret_cast(TestFunctionApplyAndCall)); // ecma 19.2.3.3: thisArg - JSHandle this_arg(thread, env->GetGlobalObject()); - JSObject::SetProperty(thread, JSHandle(this_arg), + JSHandle this_arg(thread_, env->GetGlobalObject()); + JSObject::SetProperty(thread_, JSHandle(this_arg), JSHandle(factory->NewFromCanBeCompressString("test_builtins_function_a")), - JSHandle(thread, JSTaggedValue(1))); - JSObject::SetProperty(thread, JSHandle(this_arg), + JSHandle(thread_, JSTaggedValue(1))); + JSObject::SetProperty(thread_, JSHandle(this_arg), JSHandle(factory->NewFromCanBeCompressString("test_builtins_function_b")), - JSHandle(thread, JSTaggedValue(2))); + JSHandle(thread_, JSTaggedValue(2))); // func thisArg ...args - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 12); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 12); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(func.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, (this_arg.GetTaggedValue())); @@ -386,41 +393,44 @@ TEST_F(BuiltinsFunctionTest, FunctionPrototypeCall1) ecma_runtime_call_info->SetCallArg(2, JSTaggedValue(static_cast(456))); ecma_runtime_call_info->SetCallArg(3, JSTaggedValue(static_cast(789))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = function::proto::Call(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(1371).GetRawData()); - JSObject::DeleteProperty(thread, (this_arg), + JSObject::DeleteProperty(thread_, (this_arg), JSHandle(factory->NewFromCanBeCompressString("test_builtins_function_a"))); - JSObject::DeleteProperty(thread, (this_arg), + JSObject::DeleteProperty(thread_, (this_arg), JSHandle(factory->NewFromCanBeCompressString("test_builtins_function_b"))); } TEST_F(BuiltinsFunctionTest, FunctionPrototypeHasInstance) { - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle boolean_ctor(env->GetBooleanFunction()); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*boolean_ctor), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*boolean_ctor), 6); ecma_runtime_call_info1->SetFunction(boolean_ctor.GetTaggedValue()); ecma_runtime_call_info1->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetCallArg(0, JSTaggedValue(static_cast(123))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = boolean::BooleanConstructor(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - JSHandle boolean_instance(thread, result); + JSHandle boolean_instance(thread_, result); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(boolean_ctor.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(0, boolean_instance.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); EXPECT_TRUE(function::proto::HasInstance(ecma_runtime_call_info2.get()).GetRawData()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); } + +// NOLINTEND(readability-magic-numbers) + } // namespace panda::test diff --git a/tests/runtime/builtins/builtins_iterator_test.cpp b/tests/runtime/builtins/builtins_iterator_test.cpp index 09e9a7ac1538221baa714ae9a20e110e2b4b3bb0..43cd7a474a9a532d1a82dafc01d13a04ad6424cd 100644 --- a/tests/runtime/builtins/builtins_iterator_test.cpp +++ b/tests/runtime/builtins/builtins_iterator_test.cpp @@ -23,7 +23,9 @@ #include "plugins/ecmascript/runtime/object_factory.h" #include "plugins/ecmascript/tests/runtime/common/test_helper.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; namespace panda::test { @@ -41,16 +43,20 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; } // namespace panda::test diff --git a/tests/runtime/builtins/builtins_json_test.cpp b/tests/runtime/builtins/builtins_json_test.cpp index 1f90f7ea2cb8bc08bd8981da2c79338e215d4555..b01049d584a9fbf802a75fbc9d4bf50a9e2e710c 100644 --- a/tests/runtime/builtins/builtins_json_test.cpp +++ b/tests/runtime/builtins/builtins_json_test.cpp @@ -34,9 +34,13 @@ #include "plugins/ecmascript/runtime/object_factory.h" #include "plugins/ecmascript/tests/runtime/common/test_helper.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; +// NOLINTBEGIN(readability-magic-numbers) + namespace panda::test { class BuiltinsJsonTest : public testing::Test { public: @@ -52,18 +56,14 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; - class TestClass { public: static JSTaggedValue TestForParse(EcmaRuntimeCallInfo *argv) @@ -109,9 +109,17 @@ public: return JSTaggedValue::Undefined(); } }; + +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; -JSTaggedValue CreateBuiltinJSObject1(JSThread *thread, const PandaString key_c_str) +JSTaggedValue CreateBuiltinJSObject1(JSThread *thread, const PandaString &key_c_str) { EcmaVM *ecma_vm = thread->GetEcmaVM(); JSHandle global_env = ecma_vm->GetGlobalEnv(); @@ -141,266 +149,268 @@ JSTaggedValue CreateBuiltinJSObject1(JSThread *thread, const PandaString key_c_s TEST_F(BuiltinsJsonTest, Parse10) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle msg(factory->NewFromCanBeCompressString( "\t\r \n{\t\r \n \"property\"\t\r \n:\t\r \n{\t\r \n}\t\r \n,\t\r \n \"prop2\"\t\r \n:\t\r \n [\t\r \ntrue\t\r " "\n,\t\r \nnull\t\r \n,123.456\t\r \n] \t\r \n}\t\r \n")); - JSHandle str(JSTaggedValue::ToString(thread, msg)); + JSHandle str(JSTaggedValue::ToString(thread_, msg)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = json::Parse(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsECMAObject()); } TEST_F(BuiltinsJsonTest, Parse21) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle msg(factory->NewFromCanBeCompressString("[100,2.5,\"abc\"]")); JSHandle handle_func = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestForParse)); - JSHandle str(JSTaggedValue::ToString(thread, msg)); + JSHandle str(JSTaggedValue::ToString(thread_, msg)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, handle_func.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = json::Parse(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsECMAObject()); } TEST_F(BuiltinsJsonTest, Parse) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle length_key_handle = thread->GlobalConstants()->GetHandledLengthString(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle length_key_handle = thread_->GlobalConstants()->GetHandledLengthString(); JSHandle msg(factory->NewFromCanBeCompressString("[100,2.5,\"abc\"]")); - JSHandle str(JSTaggedValue::ToString(thread, msg)); + JSHandle str(JSTaggedValue::ToString(thread_, msg)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = json::Parse(ecma_runtime_call_info.get()); JSTaggedValue value(static_cast(result.GetRawData())); ASSERT_TRUE(value.IsECMAObject()); - JSHandle value_handle(thread, value); + JSHandle value_handle(thread_, value); JSHandle len_result = - JSObject::GetProperty(thread, JSHandle(value_handle), length_key_handle).GetValue(); - uint32_t length = JSTaggedValue::ToLength(thread, len_result).ToUint32(); + JSObject::GetProperty(thread_, JSHandle(value_handle), length_key_handle).GetValue(); + uint32_t length = JSTaggedValue::ToLength(thread_, len_result).ToUint32(); EXPECT_EQ(length, 3); } TEST_F(BuiltinsJsonTest, Parse2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle msg(factory->NewFromCanBeCompressString("{\"epf\":100,\"key1\":200}")); - JSHandle str(JSTaggedValue::ToString(thread, msg)); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle msg(factory->NewFromCanBeCompressString(R"({"epf":100,"key1":200})")); + JSHandle str(JSTaggedValue::ToString(thread_, msg)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = json::Parse(ecma_runtime_call_info.get()); JSTaggedValue value(static_cast(result.GetRawData())); ASSERT_TRUE(value.IsECMAObject()); - JSHandle value_handle(thread, value); + JSHandle value_handle(thread_, value); - JSHandle name_list(JSObject::EnumerableOwnNames(thread, value_handle)); - JSHandle name_result = JSArray::CreateArrayFromList(thread, name_list); + JSHandle name_list(JSObject::EnumerableOwnNames(thread_, value_handle)); + JSHandle name_result = JSArray::CreateArrayFromList(thread_, name_list); JSHandle handle_key(name_result); JSHandle length_key(factory->NewFromCanBeCompressString("length")); - JSHandle len_result = JSObject::GetProperty(thread, handle_key, length_key).GetValue(); - uint32_t length = JSTaggedValue::ToLength(thread, len_result).ToUint32(); + JSHandle len_result = JSObject::GetProperty(thread_, handle_key, length_key).GetValue(); + uint32_t length = JSTaggedValue::ToLength(thread_, len_result).ToUint32(); ASSERT_EQ(length, 2); } TEST_F(BuiltinsJsonTest, Stringify11) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); - JSHandle obj = JSHandle(thread, CreateBuiltinJSObject1(thread, "x")); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); + JSHandle obj = JSHandle(thread_, CreateBuiltinJSObject1(thread_, "x")); JSHandle handle_func = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestForStringfy)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, handle_func.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = json::Stringify(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); } TEST_F(BuiltinsJsonTest, Stringify12) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle obj = JSHandle(thread, CreateBuiltinJSObject1(thread, "x")); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle obj = JSHandle(thread_, CreateBuiltinJSObject1(thread_, "x")); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle handle_func = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestForStringfy)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, handle_func.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue(static_cast(10))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = json::Stringify(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); } TEST_F(BuiltinsJsonTest, Stringify13) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle obj = JSHandle(thread, CreateBuiltinJSObject1(thread, "x")); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle obj = JSHandle(thread_, CreateBuiltinJSObject1(thread_, "x")); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle handle_func = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestForStringfy)); JSHandle msg(factory->NewFromCanBeCompressString("tttt")); - JSHandle str(JSTaggedValue::ToString(thread, msg)); + JSHandle str(JSTaggedValue::ToString(thread_, msg)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, handle_func.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(2, str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = json::Stringify(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); } TEST_F(BuiltinsJsonTest, Stringify14) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle obj = JSHandle(thread, CreateBuiltinJSObject1(thread, "x")); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle obj = JSHandle(thread_, CreateBuiltinJSObject1(thread_, "x")); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); - JSHandle obj1(thread, arr); - JSHandle key0(thread, JSTaggedValue(0)); + JSHandle obj1(thread_, arr); + JSHandle key0(thread_, JSTaggedValue(0)); JSHandle value0(factory->NewFromCanBeCompressString("x")); - JSObject::SetProperty(thread, JSHandle(obj), key0, value0); - JSHandle key1(thread, JSTaggedValue(1)); + JSObject::SetProperty(thread_, JSHandle(obj), key0, value0); + JSHandle key1(thread_, JSTaggedValue(1)); JSHandle value1(factory->NewFromCanBeCompressString("z")); - JSObject::SetProperty(thread, JSHandle(obj), key1, value1); + JSObject::SetProperty(thread_, JSHandle(obj), key1, value1); JSHandle msg(factory->NewFromCanBeCompressString("tttt")); - JSHandle str(JSTaggedValue::ToString(thread, msg)); + JSHandle str(JSTaggedValue::ToString(thread_, msg)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, obj1.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(2, str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = json::Stringify(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); } TEST_F(BuiltinsJsonTest, Stringify) { - JSHandle obj = JSHandle(thread, CreateBuiltinJSObject1(thread, "x")); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle obj = JSHandle(thread_, CreateBuiltinJSObject1(thread_, "x")); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = json::Stringify(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); } TEST_F(BuiltinsJsonTest, Stringify1) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); ObjectFactory *factory = ecma_vm->GetFactory(); JSHandle env = ecma_vm->GetGlobalEnv(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - JSHandle key0(thread, JSTaggedValue(0)); + JSHandle obj(thread_, arr); + JSHandle key0(thread_, JSTaggedValue(0)); JSHandle value(factory->NewFromCanBeCompressString("def")); - JSObject::SetProperty(thread, JSHandle(obj), key0, value); + JSObject::SetProperty(thread_, JSHandle(obj), key0, value); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(200)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(200)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); + JSHandle key2(thread_, JSTaggedValue(2)); JSHandle value2(factory->NewFromCanBeCompressString("abc")); - JSObject::SetProperty(thread, JSHandle(obj), key2, value2); + JSObject::SetProperty(thread_, JSHandle(obj), key2, value2); JSHandle handle_func = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestForStringfy)); JSHandle msg(factory->NewFromCanBeCompressString("tttt")); - JSHandle str(JSTaggedValue::ToString(thread, msg)); + JSHandle str(JSTaggedValue::ToString(thread_, msg)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, handle_func.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(2, str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = json::Stringify(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); } TEST_F(BuiltinsJsonTest, Stringify2) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); ObjectFactory *factory = ecma_vm->GetFactory(); - JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); + JSArray *arr = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetTaggedObject()); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); + JSHandle obj(thread_, arr); - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); // 2.5 : test case - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(2.5)), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(2.5)), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); // 2 : test case - JSHandle key2(thread, JSTaggedValue(2)); + JSHandle key2(thread_, JSTaggedValue(2)); JSHandle value2(factory->NewFromCanBeCompressString("abc")); - JSObject::SetProperty(thread, JSHandle(obj), key2, value2); + JSObject::SetProperty(thread_, JSHandle(obj), key2, value2); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = json::Stringify(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); } } // namespace panda::test + +// NOLINTEND(readability-magic-numbers) diff --git a/tests/runtime/builtins/builtins_map_test.cpp b/tests/runtime/builtins/builtins_map_test.cpp index 1cbd1235859c292c5605ebfa6f7e6088224c784a..f1465edabf6710d3ab7daec67d64ed2122d3224c 100644 --- a/tests/runtime/builtins/builtins_map_test.cpp +++ b/tests/runtime/builtins/builtins_map_test.cpp @@ -31,9 +31,13 @@ #include "plugins/ecmascript/tests/runtime/common/test_helper.h" #include "utils/bit_utils.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; +// NOLINTBEGIN(readability-magic-numbers,modernize-avoid-c-arrays) + namespace panda::test { using JSMap = ecmascript::JSMap; @@ -51,18 +55,14 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; - class TestClass { public: static JSTaggedValue TestFunc(EcmaRuntimeCallInfo *argv) @@ -74,6 +74,14 @@ public: return JSTaggedValue::Undefined(); } }; + +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; JSMap *CreateBuiltinsMap(JSThread *thread) @@ -95,18 +103,18 @@ JSMap *CreateBuiltinsMap(JSThread *thread) // new Map("abrupt").toString() TEST_F(BuiltinsMapTest, CreateAndGetSize) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle new_target(env->GetMapFunction()); - JSHandle map(thread, CreateBuiltinsMap(thread)); + JSHandle map(thread_, CreateBuiltinsMap(thread_)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(map.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue::Undefined()); { - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = map::proto::GetSize(ecma_runtime_call_info.get()); EXPECT_EQ(result.GetRawData(), JSTaggedValue(0).GetRawData()); @@ -114,19 +122,19 @@ TEST_F(BuiltinsMapTest, CreateAndGetSize) JSHandle array(factory->NewTaggedArray(5)); for (int i = 0; i < 5; i++) { JSHandle internal_array(factory->NewTaggedArray(2)); - internal_array->Set(thread, 0, JSTaggedValue(i)); - internal_array->Set(thread, 1, JSTaggedValue(i)); - auto arr = JSArray::CreateArrayFromList(thread, internal_array); - array->Set(thread, i, arr); + internal_array->Set(thread_, 0, JSTaggedValue(i)); + internal_array->Set(thread_, 1, JSTaggedValue(i)); + auto arr = JSArray::CreateArrayFromList(thread_, internal_array); + array->Set(thread_, i, arr); } - JSHandle values = JSArray::CreateArrayFromList(thread, array); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle values = JSArray::CreateArrayFromList(thread_, array); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(new_target.GetTaggedValue()); ecma_runtime_call_info1->SetThis(map.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, values.GetTaggedValue()); ecma_runtime_call_info1->SetNewTarget(new_target.GetTaggedValue()); { - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result1 = map::MapConstructor(ecma_runtime_call_info1.get()); EXPECT_EQ(JSMap::Cast(reinterpret_cast(result1.GetRawData()))->GetSize(), 5); @@ -135,12 +143,12 @@ TEST_F(BuiltinsMapTest, CreateAndGetSize) TEST_F(BuiltinsMapTest, SetAndHas) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // create jsMap - JSHandle map(thread, CreateBuiltinsMap(thread)); + JSHandle map(thread_, CreateBuiltinsMap(thread_)); JSHandle key(factory->NewFromCanBeCompressString("key")); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(map.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); @@ -148,7 +156,7 @@ TEST_F(BuiltinsMapTest, SetAndHas) JSMap *js_map; { - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = map::proto::Has(ecma_runtime_call_info.get()); EXPECT_EQ(result1.GetRawData(), JSTaggedValue::False().GetRawData()); @@ -162,13 +170,13 @@ TEST_F(BuiltinsMapTest, SetAndHas) } // test Has() - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(JSTaggedValue(js_map)); ecma_runtime_call_info1->SetCallArg(0, key.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(1, JSTaggedValue(static_cast(1))); { - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result3 = map::proto::Has(ecma_runtime_call_info1.get()); EXPECT_EQ(result3.GetRawData(), JSTaggedValue::True().GetRawData()); @@ -178,36 +186,36 @@ TEST_F(BuiltinsMapTest, SetAndHas) TEST_F(BuiltinsMapTest, ForEach) { // generate a map has 5 entries{key1:0,key2:1,key3:2,key4:3,key5:4} - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); - JSHandle map(thread, CreateBuiltinsMap(thread)); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); + JSHandle map(thread_, CreateBuiltinsMap(thread_)); char key_array[] = "key0"; for (int i = 0; i < 5; i++) { key_array[3] = '1' + i; JSHandle key(factory->NewFromCanBeCompressString(key_array)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(map.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(i))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = map::proto::Set(ecma_runtime_call_info.get()); EXPECT_TRUE(result1.IsECMAObject()); JSMap *js_map = JSMap::Cast(reinterpret_cast(result1.GetRawData())); EXPECT_EQ(js_map->GetSize(), i + 1); } // test foreach; - JSHandle js_array(JSArray::ArrayCreate(thread, JSTaggedNumber(0))); + JSHandle js_array(JSArray::ArrayCreate(thread_, JSTaggedNumber(0))); JSHandle func = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestFunc)); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(map.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, func.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(1, js_array.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result2 = map::proto::ForEach(ecma_runtime_call_info1.get()); EXPECT_EQ(result2.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); @@ -216,22 +224,22 @@ TEST_F(BuiltinsMapTest, ForEach) TEST_F(BuiltinsMapTest, DeleteAndRemove) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // create jsMap - JSHandle map(thread, CreateBuiltinsMap(thread)); + JSHandle map(thread_, CreateBuiltinsMap(thread_)); // add 40 keys char key_array[] = "key0"; for (int i = 0; i < 40; i++) { key_array[3] = '1' + i; - JSHandle key(thread, factory->NewFromCanBeCompressString(key_array).GetTaggedValue()); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + JSHandle key(thread_, factory->NewFromCanBeCompressString(key_array).GetTaggedValue()); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(map.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(i))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = map::proto::Set(ecma_runtime_call_info.get()); EXPECT_TRUE(result1.IsECMAObject()); @@ -242,12 +250,12 @@ TEST_F(BuiltinsMapTest, DeleteAndRemove) key_array[3] = '1' + 8; JSHandle delete_key(factory->NewFromCanBeCompressString(key_array)); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(map.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, delete_key.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result2 = map::proto::Has(ecma_runtime_call_info1.get()); EXPECT_EQ(result2.GetRawData(), JSTaggedValue::True().GetRawData()); @@ -273,9 +281,9 @@ TEST_F(BuiltinsMapTest, DeleteAndRemove) TEST_F(BuiltinsMapTest, Species) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); - JSHandle map(thread, CreateBuiltinsMap(thread)); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); + JSHandle map(thread_, CreateBuiltinsMap(thread_)); // test species JSHandle species_symbol = env->GetSpeciesSymbol(); @@ -284,74 +292,76 @@ TEST_F(BuiltinsMapTest, Species) JSHandle new_target(env->GetMapFunction()); JSTaggedValue value = - JSObject::GetProperty(thread, JSHandle(new_target), species_symbol).GetValue().GetTaggedValue(); - JSHandle value_handle(thread, value); + JSObject::GetProperty(thread_, JSHandle(new_target), species_symbol).GetValue().GetTaggedValue(); + JSHandle value_handle(thread_, value); EXPECT_EQ(value, new_target.GetTaggedValue()); // to string tag JSHandle to_string_tag_symbol = env->GetToStringTagSymbol(); - JSHandle string_tag(JSObject::GetProperty(thread, map, to_string_tag_symbol).GetValue()); + JSHandle string_tag(JSObject::GetProperty(thread_, map, to_string_tag_symbol).GetValue()); JSHandle str = factory->NewFromCanBeCompressString("Map"); EXPECT_TRUE(!string_tag.GetTaggedValue().IsUndefined()); EXPECT_TRUE(EcmaString::StringsAreEqual(*str, *string_tag)); - JSHandle constructor = JSHandle::Cast(JSTaggedValue::ToObject(thread, value_handle)); - EXPECT_EQ(JSHandle(map)->GetPrototype(thread), constructor->GetFunctionPrototype()); + JSHandle constructor = JSHandle::Cast(JSTaggedValue::ToObject(thread_, value_handle)); + EXPECT_EQ(JSHandle(map)->GetPrototype(thread_), constructor->GetFunctionPrototype()); JSHandle key1(factory->NewFromCanBeCompressString("set")); - JSTaggedValue value1 = JSObject::GetProperty(thread, map, key1).GetValue().GetTaggedValue(); + JSTaggedValue value1 = JSObject::GetProperty(thread_, map, key1).GetValue().GetTaggedValue(); EXPECT_FALSE(value1.IsUndefined()); JSHandle key2(factory->NewFromCanBeCompressString("has")); - JSTaggedValue value2 = JSObject::GetProperty(thread, map, key1).GetValue().GetTaggedValue(); + JSTaggedValue value2 = JSObject::GetProperty(thread_, map, key1).GetValue().GetTaggedValue(); EXPECT_FALSE(value2.IsUndefined()); JSHandle key3(factory->NewFromCanBeCompressString("clear")); - JSTaggedValue value3 = JSObject::GetProperty(thread, map, key1).GetValue().GetTaggedValue(); + JSTaggedValue value3 = JSObject::GetProperty(thread_, map, key1).GetValue().GetTaggedValue(); EXPECT_FALSE(value3.IsUndefined()); JSHandle key4(factory->NewFromCanBeCompressString("size")); - JSTaggedValue value4 = JSObject::GetProperty(thread, map, key1).GetValue().GetTaggedValue(); + JSTaggedValue value4 = JSObject::GetProperty(thread_, map, key1).GetValue().GetTaggedValue(); EXPECT_FALSE(value4.IsUndefined()); JSHandle key5(factory->NewFromCanBeCompressString("delete")); - JSTaggedValue value5 = JSObject::GetProperty(thread, map, key1).GetValue().GetTaggedValue(); + JSTaggedValue value5 = JSObject::GetProperty(thread_, map, key1).GetValue().GetTaggedValue(); EXPECT_FALSE(value5.IsUndefined()); JSHandle key6(factory->NewFromCanBeCompressString("forEach")); - JSTaggedValue value6 = JSObject::GetProperty(thread, map, key1).GetValue().GetTaggedValue(); + JSTaggedValue value6 = JSObject::GetProperty(thread_, map, key1).GetValue().GetTaggedValue(); EXPECT_FALSE(value6.IsUndefined()); JSHandle key7(factory->NewFromCanBeCompressString("get")); - JSTaggedValue value7 = JSObject::GetProperty(thread, map, key1).GetValue().GetTaggedValue(); + JSTaggedValue value7 = JSObject::GetProperty(thread_, map, key1).GetValue().GetTaggedValue(); EXPECT_FALSE(value7.IsUndefined()); } TEST_F(BuiltinsMapTest, GetIterator) { - JSHandle map(thread, CreateBuiltinsMap(thread)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + JSHandle map(thread_, CreateBuiltinsMap(thread_)); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(map.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); // test Values() JSTaggedValue result = map::proto::Values(ecma_runtime_call_info.get()); - JSHandle iter(thread, result); + JSHandle iter(thread_, result); EXPECT_TRUE(iter->IsJSMapIterator()); EXPECT_EQ(IterationKind::VALUE, IterationKind(iter->GetIterationKind().GetInt())); EXPECT_EQ(JSMap::Cast(map.GetTaggedValue().GetTaggedObject())->GetLinkedMap(), iter->GetIteratedMap()); // test Keys() JSTaggedValue result1 = map::proto::Keys(ecma_runtime_call_info.get()); - JSHandle iter1(thread, result1); + JSHandle iter1(thread_, result1); EXPECT_TRUE(iter1->IsJSMapIterator()); EXPECT_EQ(IterationKind::KEY, IterationKind(iter1->GetIterationKind().GetInt())); // test entries() JSTaggedValue result2 = map::proto::Entries(ecma_runtime_call_info.get()); - JSHandle iter2(thread, result2); + JSHandle iter2(thread_, result2); EXPECT_TRUE(iter2->IsJSMapIterator()); EXPECT_EQ(IterationKind::KEY_AND_VALUE, IterationKind(iter2->GetIterationKind().GetInt())); } } // namespace panda::test + +// NOLINTEND(readability-magic-numbers,modernize-avoid-c-arrays) diff --git a/tests/runtime/builtins/builtins_math_test.cpp b/tests/runtime/builtins/builtins_math_test.cpp index 570e30f86ccf8552602e8e26745e5d0d696ae4fe..ac033ed05f56b36c2e048189452af396285b1f1e 100644 --- a/tests/runtime/builtins/builtins_math_test.cpp +++ b/tests/runtime/builtins/builtins_math_test.cpp @@ -23,9 +23,12 @@ #include "plugins/ecmascript/runtime/object_factory.h" #include "plugins/ecmascript/tests/runtime/common/test_helper.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; -using namespace panda::ecmascript::base; + +// NOLINTBEGIN(readability-magic-numbers) namespace panda::test { class BuiltinsMathTest : public testing::Test { @@ -3922,3 +3925,5 @@ TEST_F(BuiltinsMathTest, Trunc_6) ASSERT_EQ(result.GetRawData(), expect.GetRawData()); } } // namespace panda::test + +// NOLINTEND(readability-magic-numbers) diff --git a/tests/runtime/builtins/builtins_number_test.cpp b/tests/runtime/builtins/builtins_number_test.cpp index 35f1a223c3da2b98e3b1a4846afbd9d9eca5619c..87b78e2f69f18fe5a11b64d9735317990d00901e 100644 --- a/tests/runtime/builtins/builtins_number_test.cpp +++ b/tests/runtime/builtins/builtins_number_test.cpp @@ -32,9 +32,13 @@ #include "plugins/ecmascript/runtime/object_factory.h" #include "plugins/ecmascript/tests/runtime/common/test_helper.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; +// NOLINTBEGIN(readability-magic-numbers) + namespace panda::test { class BuiltinsNumberTest : public testing::Test { public: @@ -50,33 +54,37 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; // new Number(10) TEST_F(BuiltinsNumberTest, NumberConstructor) { - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle number(env->GetNumberFunction()); - JSHandle global_object(thread, env->GetGlobalObject()); + JSHandle global_object(thread_, env->GetGlobalObject()); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*number), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*number), 6); ecma_runtime_call_info->SetFunction(number.GetTaggedValue()); ecma_runtime_call_info->SetThis(global_object.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(5))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::NumberConstructor(ecma_runtime_call_info.get()); JSTaggedValue value(static_cast(result.GetRawData())); ASSERT_TRUE(value.IsECMAObject()); @@ -88,12 +96,12 @@ TEST_F(BuiltinsNumberTest, NumberConstructor) TEST_F(BuiltinsNumberTest, IsFinite) { const double value = -10; - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(value))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::IsFinite(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); } @@ -101,12 +109,12 @@ TEST_F(BuiltinsNumberTest, IsFinite) // Number.isFinite(Number.MAX_VALUE) TEST_F(BuiltinsNumberTest, IsFinite1) { - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(base::MAX_VALUE)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::IsFinite(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); } @@ -114,13 +122,13 @@ TEST_F(BuiltinsNumberTest, IsFinite1) // Number.isFinite("helloworld") TEST_F(BuiltinsNumberTest, IsFinite2) { - JSHandle test = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("helloworld"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle test = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("helloworld"); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, test.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::IsFinite(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::False().GetRawData()); } @@ -128,12 +136,12 @@ TEST_F(BuiltinsNumberTest, IsFinite2) // Number.isFinite(NaN) TEST_F(BuiltinsNumberTest, IsFinite3) { - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(base::NAN_VALUE)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::IsFinite(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::False().GetRawData()); } @@ -141,12 +149,12 @@ TEST_F(BuiltinsNumberTest, IsFinite3) // Number.isFinite(Infinity) TEST_F(BuiltinsNumberTest, IsFinite4) { - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(base::POSITIVE_INFINITY)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::IsFinite(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::False().GetRawData()); } @@ -154,12 +162,12 @@ TEST_F(BuiltinsNumberTest, IsFinite4) // Number.isFinite(undefined) TEST_F(BuiltinsNumberTest, IsFinite5) { - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue::Undefined()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::IsFinite(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::False().GetRawData()); } @@ -167,12 +175,12 @@ TEST_F(BuiltinsNumberTest, IsFinite5) // Number.isFinite(null) TEST_F(BuiltinsNumberTest, IsFinite6) { - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue::Null()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::IsFinite(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::False().GetRawData()); } @@ -180,12 +188,12 @@ TEST_F(BuiltinsNumberTest, IsFinite6) // Number.isInteger(0.1) TEST_F(BuiltinsNumberTest, IsInteger) { - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(0.1)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::IsInteger(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::False().GetRawData()); } @@ -193,12 +201,12 @@ TEST_F(BuiltinsNumberTest, IsInteger) // Number.isNaN(0.1) TEST_F(BuiltinsNumberTest, IsNaN) { - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(0.1)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::IsNaN(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::False().GetRawData()); } @@ -206,23 +214,23 @@ TEST_F(BuiltinsNumberTest, IsNaN) // new Number(123.456).toString(7) TEST_F(BuiltinsNumberTest, ToString) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - auto ecma_vm = thread->GetEcmaVM(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle number_object(env->GetNumberFunction()); - JSHandle value(thread, JSTaggedValue(123.456)); - JSHandle number = thread->GetEcmaVM()->GetFactory()->NewJSPrimitiveRef(number_object, value); + JSHandle value(thread_, JSTaggedValue(123.456)); + JSHandle number = thread_->GetEcmaVM()->GetFactory()->NewJSPrimitiveRef(number_object, value); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(number.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(7.0)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::proto::ToString(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle res(thread, reinterpret_cast(result.GetRawData())); + JSHandle res(thread_, reinterpret_cast(result.GetRawData())); JSHandle correct_result = factory->NewFromCanBeCompressString("234.312256641535441"); PandaVector test(res->GetLength() + 1); res->CopyDataUtf8(test.data(), res->GetLength()); @@ -232,23 +240,23 @@ TEST_F(BuiltinsNumberTest, ToString) // new Number(123.456).toExponential(5) TEST_F(BuiltinsNumberTest, IsExponential) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - auto ecma_vm = thread->GetEcmaVM(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle number_object(env->GetNumberFunction()); - JSHandle value(thread, JSTaggedValue(123.456)); + JSHandle value(thread_, JSTaggedValue(123.456)); JSHandle number = factory->NewJSPrimitiveRef(number_object, value); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(number.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(5.0)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::proto::ToExponential(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle res(thread, reinterpret_cast(result.GetRawData())); + JSHandle res(thread_, reinterpret_cast(result.GetRawData())); JSHandle correct_result = factory->NewFromCanBeCompressString("1.23456e+2"); PandaVector test(res->GetLength() + 1); res->CopyDataUtf8(test.data(), res->GetLength()); @@ -258,23 +266,23 @@ TEST_F(BuiltinsNumberTest, IsExponential) // new Number(123.456).toFixed(10) TEST_F(BuiltinsNumberTest, ToFixed) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - auto ecma_vm = thread->GetEcmaVM(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle number_object(env->GetNumberFunction()); - JSHandle value(thread, JSTaggedValue(123.456)); + JSHandle value(thread_, JSTaggedValue(123.456)); JSHandle number = factory->NewJSPrimitiveRef(number_object, value); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(number.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(10.0)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::proto::ToFixed(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle res(thread, reinterpret_cast(result.GetRawData())); + JSHandle res(thread_, reinterpret_cast(result.GetRawData())); JSHandle correct_result = factory->NewFromCanBeCompressString("123.4560000000"); ASSERT_TRUE(EcmaString::StringsAreEqual(*res, *correct_result)); } @@ -282,23 +290,23 @@ TEST_F(BuiltinsNumberTest, ToFixed) // new Number(123.456).toFixed(30) TEST_F(BuiltinsNumberTest, ToFixed1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - auto ecma_vm = thread->GetEcmaVM(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle number_object(env->GetNumberFunction()); - JSHandle value(thread, JSTaggedValue(123.456)); + JSHandle value(thread_, JSTaggedValue(123.456)); JSHandle number = factory->NewJSPrimitiveRef(number_object, value); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(number.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(30.0)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::proto::ToFixed(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle res(thread, reinterpret_cast(result.GetRawData())); + JSHandle res(thread_, reinterpret_cast(result.GetRawData())); JSHandle correct_result = factory->NewFromCanBeCompressString("123.456000000000003069544618483633"); ASSERT_TRUE(EcmaString::StringsAreEqual(*res, *correct_result)); } @@ -306,23 +314,23 @@ TEST_F(BuiltinsNumberTest, ToFixed1) // new Number(1e21).toFixed(20) TEST_F(BuiltinsNumberTest, ToFixed2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - auto ecma_vm = thread->GetEcmaVM(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle number_object(env->GetNumberFunction()); - JSHandle value(thread, JSTaggedValue(1e21)); + JSHandle value(thread_, JSTaggedValue(1e21)); JSHandle number = factory->NewJSPrimitiveRef(number_object, value); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(number.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(20.0)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::proto::ToFixed(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle res(thread, reinterpret_cast(result.GetRawData())); + JSHandle res(thread_, reinterpret_cast(result.GetRawData())); JSHandle correct_result = factory->NewFromCanBeCompressString("1e+21"); PandaVector test(res->GetLength() + 1); res->CopyDataUtf8(test.data(), res->GetLength()); @@ -333,23 +341,23 @@ TEST_F(BuiltinsNumberTest, ToFixed2) // new Number(123.456).toPrecision(8) TEST_F(BuiltinsNumberTest, ToPrecision) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - auto ecma_vm = thread->GetEcmaVM(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle number_object(env->GetNumberFunction()); - JSHandle value(thread, JSTaggedValue(123.456)); + JSHandle value(thread_, JSTaggedValue(123.456)); JSHandle number = factory->NewJSPrimitiveRef(number_object, value); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(number.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(8.0)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::proto::ToPrecision(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle res(thread, reinterpret_cast(result.GetRawData())); + JSHandle res(thread_, reinterpret_cast(result.GetRawData())); JSHandle correct_result = factory->NewFromCanBeCompressString("123.45600"); ASSERT_TRUE(EcmaString::StringsAreEqual(*res, *correct_result)); } @@ -357,13 +365,13 @@ TEST_F(BuiltinsNumberTest, ToPrecision) // Number.parseFloat(0x123) TEST_F(BuiltinsNumberTest, parseFloat) { - JSHandle param = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0x123"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle param = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0x123"); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, param.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::ParseFloat(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(static_cast(0)).GetRawData()); } @@ -371,13 +379,13 @@ TEST_F(BuiltinsNumberTest, parseFloat) // Number.parseFloat(0x123xx) TEST_F(BuiltinsNumberTest, parseFloat1) { - JSHandle param = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0x123xx"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle param = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0x123xx"); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, param.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::ParseFloat(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(static_cast(0)).GetRawData()); } @@ -387,14 +395,14 @@ TEST_F(BuiltinsNumberTest, parseInt) { const char *number = "0x123"; - JSHandle param = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(number); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + JSHandle param = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(number); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, param.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(16.0)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = number::ParseInt(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(static_cast(291)).GetRawData()); } @@ -407,74 +415,74 @@ TEST_F(BuiltinsNumberTest, StringToDoubleFlags) // flags of IGNORE_TRAILING - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0a"); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0a"); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::IGNORE_TRAILING), 0); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0b"); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0b"); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::IGNORE_TRAILING), 0); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0o"); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0o"); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::IGNORE_TRAILING), 0); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 00x"); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 00x"); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::IGNORE_TRAILING), 0); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 000.4_"); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 000.4_"); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::IGNORE_TRAILING), 0.4); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 0010.s "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 0010.s "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::IGNORE_TRAILING), 10); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 0010e2"); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 0010e2"); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::IGNORE_TRAILING), 1000); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 0010e+3_0"); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 0010e+3_0"); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::IGNORE_TRAILING), 10000); // flags of ALLOW_HEX - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0x"); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0x"); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_TRUE(std::isnan(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::ALLOW_HEX))); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 0x10 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 0x10 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::ALLOW_HEX), 16); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0x1g"); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0x1g"); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::ALLOW_HEX + base::IGNORE_TRAILING), 1); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0xh"); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0xh"); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_TRUE(std::isnan( base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::ALLOW_HEX + base::IGNORE_TRAILING))); // flags of ALLOW_OCTAL - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0O"); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0O"); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_TRUE(std::isnan(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::ALLOW_OCTAL))); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 0o10 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 0o10 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::ALLOW_OCTAL), 8); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0o1d"); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0o1d"); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::ALLOW_OCTAL | base::IGNORE_TRAILING), 1); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0o8"); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0o8"); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_TRUE(std::isnan( base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::ALLOW_OCTAL | base::IGNORE_TRAILING))); // flags of ALLOW_BINARY - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0b"); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0b"); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_TRUE(std::isnan(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::ALLOW_BINARY))); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 0b10 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 0b10 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::ALLOW_BINARY), 2); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0b1d"); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0b1d"); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::ALLOW_BINARY | base::IGNORE_TRAILING), 1); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0b2"); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0b2"); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_TRUE(std::isnan( base::NumberHelper::StringToDouble(sp.begin(), sp.end(), 0, base::ALLOW_BINARY | base::IGNORE_TRAILING))); @@ -488,124 +496,130 @@ TEST_F(BuiltinsNumberTest, StringToDoubleRadix) int radix; radix = 0; // default 10 - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 100); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100.3e2 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100.3e2 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 10030); radix = 1; - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 0000 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 0000 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 0); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 0001 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 0001 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_TRUE(std::isnan(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS))); radix = 2; - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 4); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 11 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 11 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 3); radix = 3; - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 9); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 21 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 21 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 7); radix = 4; - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 16); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 31 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 31 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 13); radix = 8; - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 64); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 71 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 71 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 57); radix = 10; - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 100); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 0020 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 0020 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 20); radix = 16; - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 256); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 1e "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 1e "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 30); radix = 18; - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 324); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 1g "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 1g "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 34); radix = 25; - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 625); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 1g "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 1g "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 41); radix = 36; - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 100 "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 1296); - str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 1z "); + str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(" 1z "); sp = Span(str->GetDataUtf8(), str->GetUtf8Length() - 1); ASSERT_EQ(base::NumberHelper::StringToDouble(sp.begin(), sp.end(), radix, base::NO_FLAGS), 71); } TEST_F(BuiltinsNumberTest, NumberToString) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle res = factory->NewFromCanBeCompressString("100"); - ASSERT_EQ(base::NumberHelper::NumberToString(thread, JSTaggedValue(100))->Compare(*res), 0); + ASSERT_EQ(base::NumberHelper::NumberToString(thread_, JSTaggedValue(100))->Compare(*res), 0); res = factory->NewFromCanBeCompressString("11223344"); - ASSERT_EQ(base::NumberHelper::NumberToString(thread, JSTaggedValue(11223344))->Compare(*res), 0); + ASSERT_EQ(base::NumberHelper::NumberToString(thread_, JSTaggedValue(11223344))->Compare(*res), 0); res = factory->NewFromCanBeCompressString("1234567890"); - ASSERT_EQ(base::NumberHelper::NumberToString(thread, JSTaggedValue(1234567890))->Compare(*res), 0); + ASSERT_EQ(base::NumberHelper::NumberToString(thread_, JSTaggedValue(1234567890))->Compare(*res), 0); res = factory->NewFromCanBeCompressString("100"); - ASSERT_EQ(base::NumberHelper::NumberToString(thread, JSTaggedValue(double(100.0)))->Compare(*res), 0); + ASSERT_EQ(base::NumberHelper::NumberToString(thread_, JSTaggedValue(double(100.0)))->Compare(*res), 0); res = factory->NewFromCanBeCompressString("100.5"); - ASSERT_EQ(base::NumberHelper::NumberToString(thread, JSTaggedValue(double(100.5)))->Compare(*res), 0); + ASSERT_EQ(base::NumberHelper::NumberToString(thread_, JSTaggedValue(double(100.5)))->Compare(*res), 0); res = factory->NewFromCanBeCompressString("100.25"); - ASSERT_EQ(base::NumberHelper::NumberToString(thread, JSTaggedValue(double(100.25)))->Compare(*res), 0); + ASSERT_EQ(base::NumberHelper::NumberToString(thread_, JSTaggedValue(double(100.25)))->Compare(*res), 0); res = factory->NewFromCanBeCompressString("100.125"); - ASSERT_EQ(base::NumberHelper::NumberToString(thread, JSTaggedValue(double(100.125)))->Compare(*res), 0); + ASSERT_EQ(base::NumberHelper::NumberToString(thread_, JSTaggedValue(double(100.125)))->Compare(*res), 0); res = factory->NewFromCanBeCompressString("100.6125"); - ASSERT_EQ(base::NumberHelper::NumberToString(thread, JSTaggedValue(double(100.6125)))->Compare(*res), 0); + ASSERT_EQ(base::NumberHelper::NumberToString(thread_, JSTaggedValue(double(100.6125)))->Compare(*res), 0); res = factory->NewFromCanBeCompressString("0.0006125"); - ASSERT_EQ(base::NumberHelper::NumberToString(thread, JSTaggedValue(double(0.0006125)))->Compare(*res), 0); + ASSERT_EQ(base::NumberHelper::NumberToString(thread_, JSTaggedValue(double(0.0006125)))->Compare(*res), 0); res = factory->NewFromCanBeCompressString("-0.0006125"); - ASSERT_EQ(base::NumberHelper::NumberToString(thread, JSTaggedValue(double(-0.0006125)))->Compare(*res), 0); + ASSERT_EQ(base::NumberHelper::NumberToString(thread_, JSTaggedValue(double(-0.0006125)))->Compare(*res), 0); res = factory->NewFromCanBeCompressString("-1234567890.0006125"); - ASSERT_EQ(base::NumberHelper::NumberToString(thread, JSTaggedValue(double(-1234567890.0006125)))->Compare(*res), 0); + ASSERT_EQ(base::NumberHelper::NumberToString(thread_, JSTaggedValue(double(-1234567890.0006125)))->Compare(*res), + 0); res = factory->NewFromCanBeCompressString("1234567890.0006125"); - ASSERT_EQ(base::NumberHelper::NumberToString(thread, JSTaggedValue(double(1234567890.0006125)))->Compare(*res), 0); + ASSERT_EQ(base::NumberHelper::NumberToString(thread_, JSTaggedValue(double(1234567890.0006125)))->Compare(*res), 0); res = factory->NewFromCanBeCompressString("11234567890.000612"); - ASSERT_EQ(base::NumberHelper::NumberToString(thread, JSTaggedValue(double(11234567890.0006125)))->Compare(*res), 0); + ASSERT_EQ(base::NumberHelper::NumberToString(thread_, JSTaggedValue(double(11234567890.0006125)))->Compare(*res), + 0); res = factory->NewFromCanBeCompressString("4.185580496821356"); - ASSERT_EQ(base::NumberHelper::NumberToString(thread, JSTaggedValue(double(4.1855804968213567)))->Compare(*res), 0); + ASSERT_EQ(base::NumberHelper::NumberToString(thread_, JSTaggedValue(double(4.1855804968213567)))->Compare(*res), 0); res = factory->NewFromCanBeCompressString("3.929201589819414"); ASSERT_EQ( - base::NumberHelper::NumberToString(thread, JSTaggedValue(double(3.9292015898194142585311918)))->Compare(*res), + base::NumberHelper::NumberToString(thread_, JSTaggedValue(double(3.9292015898194142585311918)))->Compare(*res), 0); res = factory->NewFromCanBeCompressString("0.9999999999999999"); - ASSERT_EQ(base::NumberHelper::NumberToString(thread, JSTaggedValue(double(0.9999999999999999)))->Compare(*res), 0); + ASSERT_EQ(base::NumberHelper::NumberToString(thread_, JSTaggedValue(double(0.9999999999999999)))->Compare(*res), 0); res = factory->NewFromCanBeCompressString("1"); - ASSERT_EQ(base::NumberHelper::NumberToString(thread, JSTaggedValue(double(0.99999999999999999)))->Compare(*res), 0); + ASSERT_EQ(base::NumberHelper::NumberToString(thread_, JSTaggedValue(double(0.99999999999999999)))->Compare(*res), + 0); res = factory->NewFromCanBeCompressString("0.7777777777777778"); - ASSERT_EQ(base::NumberHelper::NumberToString(thread, JSTaggedValue(double(0.77777777777777777)))->Compare(*res), 0); + ASSERT_EQ(base::NumberHelper::NumberToString(thread_, JSTaggedValue(double(0.77777777777777777)))->Compare(*res), + 0); } } // namespace panda::test + +// NOLINTEND(readability-magic-numbers) diff --git a/tests/runtime/builtins/builtins_object_test.cpp b/tests/runtime/builtins/builtins_object_test.cpp index 78612747a1b8b361b4fbdf7a3a2fa2bc8f1f9df8..54648f91ca9f4507d9b495fe38e85e69e44c8eb7 100644 --- a/tests/runtime/builtins/builtins_object_test.cpp +++ b/tests/runtime/builtins/builtins_object_test.cpp @@ -29,9 +29,13 @@ #include "file_items.h" #include "utils/bit_utils.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; +// NOLINTBEGIN(readability-magic-numbers) + namespace panda::test { class BuiltinsObjectTest : public testing::Test { public: @@ -47,20 +51,24 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; -JSTaggedValue CreateBuiltinJSObject(JSThread *thread, const PandaString key_c_str) +JSTaggedValue CreateBuiltinJSObject(JSThread *thread, const PandaString &key_c_str) { EcmaVM *ecma_vm = thread->GetEcmaVM(); JSHandle global_env = ecma_vm->GetGlobalEnv(); @@ -93,60 +101,60 @@ JSObject *TestNewJSObject(JSThread *thread, const JSHandle &dyn_class) // 19.1.1.1Object ( [ value ] ) TEST_F(BuiltinsObjectTest, ObjectConstructor) { - JSHandle function(thread, BuiltinsObjectTestCreate(thread)); - JSHandle object_func(thread, BuiltinsObjectTestCreate(thread)); - JSHandle global_env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle function(thread_, BuiltinsObjectTestCreate(thread_)); + JSHandle object_func(thread_, BuiltinsObjectTestCreate(thread_)); + JSHandle global_env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle obj_fun(global_env->GetObjectFunction()); - auto obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); obj_call_info->SetFunction(JSTaggedValue::Undefined()); obj_call_info->SetThis(JSTaggedValue::Undefined()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, obj_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, obj_call_info.get()); JSTaggedValue result = object::ObjectConstructor(obj_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsECMAObject()); - JSHandle jt_handle(thread, JSTaggedValue(reinterpret_cast(result.GetRawData()))); - JSTaggedValue result_proto = jt_handle->GetPrototype(thread); + JSHandle jt_handle(thread_, JSTaggedValue(reinterpret_cast(result.GetRawData()))); + JSTaggedValue result_proto = jt_handle->GetPrototype(thread_); JSTaggedValue func_proto = object_func->GetFunctionPrototype(); ASSERT_EQ(result_proto, func_proto); ASSERT_TRUE(jt_handle->IsExtensible()); // num_args = 0 JSHandle object = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle::Cast(function), function); - auto tg_obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*object), 4); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle::Cast(function), function); + auto tg_obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*object), 4); tg_obj_call_info->SetFunction(JSTaggedValue(*obj_fun)); tg_obj_call_info->SetThis(JSTaggedValue::Undefined()); tg_obj_call_info->SetNewTarget(JSTaggedValue(*obj_fun)); - prev = TestHelper::SetupFrame(thread, tg_obj_call_info.get()); + prev = TestHelper::SetupFrame(thread_, tg_obj_call_info.get()); JSTaggedValue result_tg = object::ObjectConstructor(tg_obj_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result_tg.IsObject()); - JSHandle jt_handle_tg(thread, JSTaggedValue(reinterpret_cast(result_tg.GetRawData()))); - JSTaggedValue result_proto_tg = jt_handle_tg->GetPrototype(thread); + JSHandle jt_handle_tg(thread_, JSTaggedValue(reinterpret_cast(result_tg.GetRawData()))); + JSTaggedValue result_proto_tg = jt_handle_tg->GetPrototype(thread_); JSTaggedValue func_proto_tg = object_func->GetFunctionPrototype(); ASSERT_EQ(result_proto_tg, func_proto_tg); ASSERT_TRUE(jt_handle_tg->IsExtensible()); // value is null JSHandle object_vn = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle::Cast(function), function); - auto vn_obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*object_vn), 6); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle::Cast(function), function); + auto vn_obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*object_vn), 6); vn_obj_call_info->SetFunction(JSTaggedValue(*obj_fun)); vn_obj_call_info->SetThis(JSTaggedValue::Undefined()); vn_obj_call_info->SetCallArg(0, JSTaggedValue::Null()); vn_obj_call_info->SetNewTarget(JSTaggedValue(*obj_fun)); - prev = TestHelper::SetupFrame(thread, vn_obj_call_info.get()); + prev = TestHelper::SetupFrame(thread_, vn_obj_call_info.get()); JSTaggedValue result_vn = object::ObjectConstructor(vn_obj_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result_vn.IsObject()); - JSHandle jt_handle_vn(thread, JSTaggedValue(reinterpret_cast(result_vn.GetRawData()))); - JSTaggedValue result_proto_vn = jt_handle_vn->GetPrototype(thread); + JSHandle jt_handle_vn(thread_, JSTaggedValue(reinterpret_cast(result_vn.GetRawData()))); + JSTaggedValue result_proto_vn = jt_handle_vn->GetPrototype(thread_); JSTaggedValue func_proto_vn = object_func->GetFunctionPrototype(); ASSERT_EQ(result_proto_vn, func_proto_vn); ASSERT_TRUE(jt_handle_vn->IsExtensible()); @@ -155,197 +163,197 @@ TEST_F(BuiltinsObjectTest, ObjectConstructor) // 19.1.2.1Object.assign ( target, ...sources ) TEST_F(BuiltinsObjectTest, Assign) { - JSHandle function(thread, BuiltinsObjectTestCreate(thread)); + JSHandle function(thread_, BuiltinsObjectTestCreate(thread_)); JSHandle obj_handle1 = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); JSHandle obj_handle2 = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); - JSHandle key1(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("x")); - JSHandle value1(thread, JSTaggedValue(1)); - JSObject::SetProperty(thread, JSHandle(obj_handle1), key1, value1); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj_handle1), key1).GetValue()->GetInt(), 1); + JSHandle key1(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("x")); + JSHandle value1(thread_, JSTaggedValue(1)); + JSObject::SetProperty(thread_, JSHandle(obj_handle1), key1, value1); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj_handle1), key1).GetValue()->GetInt(), 1); - JSHandle key2(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("y")); - JSHandle value2(thread, JSTaggedValue(2)); - JSObject::SetProperty(thread, JSHandle(obj_handle2), key2, value2); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj_handle2), key2).GetValue()->GetInt(), 2); + JSHandle key2(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("y")); + JSHandle value2(thread_, JSTaggedValue(2)); + JSObject::SetProperty(thread_, JSHandle(obj_handle2), key2, value2); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj_handle2), key2).GetValue()->GetInt(), 2); - auto assign_obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto assign_obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); assign_obj_call_info->SetFunction(JSTaggedValue::Undefined()); assign_obj_call_info->SetThis(JSTaggedValue::Undefined()); assign_obj_call_info->SetCallArg(0, obj_handle1.GetTaggedValue()); assign_obj_call_info->SetCallArg(1, obj_handle2.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, assign_obj_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, assign_obj_call_info.get()); JSTaggedValue result = object::Assign(assign_obj_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsECMAObject()); - JSHandle jt_handle(thread, JSTaggedValue(reinterpret_cast(result.GetRawData()))); - EXPECT_EQ(JSObject::GetProperty(thread, jt_handle, key1).GetValue()->GetInt(), 1); - EXPECT_EQ(JSObject::GetProperty(thread, jt_handle, key2).GetValue()->GetInt(), 2); + JSHandle jt_handle(thread_, JSTaggedValue(reinterpret_cast(result.GetRawData()))); + EXPECT_EQ(JSObject::GetProperty(thread_, jt_handle, key1).GetValue()->GetInt(), 1); + EXPECT_EQ(JSObject::GetProperty(thread_, jt_handle, key2).GetValue()->GetInt(), 2); } // 19.1.2.2Object.create ( O [ , Properties ] ) TEST_F(BuiltinsObjectTest, Create) { - JSHandle function(thread, BuiltinsObjectTestCreate(thread)); - JSHandle object_func(thread, BuiltinsObjectTestCreate(thread)); - JSHandle func_proto(thread, object_func->GetFunctionPrototype()); + JSHandle function(thread_, BuiltinsObjectTestCreate(thread_)); + JSHandle object_func(thread_, BuiltinsObjectTestCreate(thread_)); + JSHandle func_proto(thread_, object_func->GetFunctionPrototype()); // no prop - auto obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); obj_call_info->SetFunction(JSTaggedValue::Undefined()); obj_call_info->SetThis(JSTaggedValue::Undefined()); obj_call_info->SetCallArg(0, func_proto.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, obj_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, obj_call_info.get()); JSTaggedValue result = object::Create(obj_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsECMAObject()); - JSHandle jt_handle(thread, JSTaggedValue(reinterpret_cast(result.GetRawData()))); - JSTaggedValue result_proto = jt_handle->GetPrototype(thread); + JSHandle jt_handle(thread_, JSTaggedValue(reinterpret_cast(result.GetRawData()))); + JSTaggedValue result_proto = jt_handle->GetPrototype(thread_); ASSERT_EQ(result_proto, func_proto.GetTaggedValue()); // has prop - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("prop")); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("prop")); JSHandle obj_handle = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle::Cast(function), function); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle::Cast(function), function); EXPECT_TRUE(*obj_handle != nullptr); - PropertyDescriptor desc(thread); + PropertyDescriptor desc(thread_); desc.SetWritable(false); - JSHandle desc_handle(JSObject::FromPropertyDescriptor(thread, desc)); + JSHandle desc_handle(JSObject::FromPropertyDescriptor(thread_, desc)); - PropertyDescriptor desc_nw(thread, JSHandle::Cast(desc_handle), true, true, true); - JSObject::DefineOwnProperty(thread, obj_handle, key, desc_nw); + PropertyDescriptor desc_nw(thread_, JSHandle::Cast(desc_handle), true, true, true); + JSObject::DefineOwnProperty(thread_, obj_handle, key, desc_nw); - auto hp_obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto hp_obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); hp_obj_call_info->SetFunction(JSTaggedValue::Undefined()); hp_obj_call_info->SetThis(JSTaggedValue::Undefined()); hp_obj_call_info->SetCallArg(0, func_proto.GetTaggedValue()); hp_obj_call_info->SetCallArg(1, obj_handle.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, hp_obj_call_info.get()); + prev = TestHelper::SetupFrame(thread_, hp_obj_call_info.get()); JSTaggedValue result_hp = object::Create(hp_obj_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result_hp.IsObject()); - PropertyDescriptor desc_res(thread); - bool success = JSObject::GetOwnProperty(thread, JSHandle(thread, result_hp), key, desc_res); + PropertyDescriptor desc_res(thread_); + bool success = JSObject::GetOwnProperty(thread_, JSHandle(thread_, result_hp), key, desc_res); EXPECT_TRUE(success); EXPECT_TRUE(!desc_res.IsWritable()); // undefined - auto un_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto un_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); un_call_info->SetFunction(JSTaggedValue::Undefined()); un_call_info->SetThis(JSTaggedValue::Undefined()); un_call_info->SetCallArg(0, JSTaggedValue::Undefined()); - prev = TestHelper::SetupFrame(thread, un_call_info.get()); + prev = TestHelper::SetupFrame(thread_, un_call_info.get()); JSTaggedValue result_un = object::Create(un_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result_un.GetRawData(), JSTaggedValue::VALUE_EXCEPTION); } // 19.1.2.3Object.defineProperties ( O, Properties ) TEST_F(BuiltinsObjectTest, DefineProperties) { - JSHandle function(thread, BuiltinsObjectTestCreate(thread)); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle function(thread_, BuiltinsObjectTestCreate(thread_)); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle obj_func(env->GetObjectFunction()); JSHandle obj_handle = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("prop")); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("prop")); JSHandle jsobj_handle = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); - PropertyDescriptor desc(thread); + PropertyDescriptor desc(thread_); desc.SetWritable(false); - JSHandle desc_handle(JSObject::FromPropertyDescriptor(thread, desc)); + JSHandle desc_handle(JSObject::FromPropertyDescriptor(thread_, desc)); - PropertyDescriptor desc_nw(thread, JSHandle::Cast(desc_handle), true, true, true); - JSObject::DefineOwnProperty(thread, jsobj_handle, key, desc_nw); + PropertyDescriptor desc_nw(thread_, JSHandle::Cast(desc_handle), true, true, true); + JSObject::DefineOwnProperty(thread_, jsobj_handle, key, desc_nw); - auto obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); obj_call_info->SetFunction(JSTaggedValue::Undefined()); obj_call_info->SetThis(JSTaggedValue::Undefined()); obj_call_info->SetCallArg(0, obj_handle.GetTaggedValue()); obj_call_info->SetCallArg(1, jsobj_handle.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, obj_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, obj_call_info.get()); JSTaggedValue result = object::DefineProperties(obj_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsECMAObject()); JSTaggedValue res(reinterpret_cast(result.GetRawData())); - PropertyDescriptor desc_res(thread); - JSObject::GetOwnProperty(thread, JSHandle(thread, res), key, desc_res); + PropertyDescriptor desc_res(thread_); + JSObject::GetOwnProperty(thread_, JSHandle(thread_, res), key, desc_res); EXPECT_TRUE(!desc_res.IsWritable()); } // 19.1.2.4Object.defineProperty ( O, P, Attributes ) TEST_F(BuiltinsObjectTest, DefineProperty) { - JSHandle function(thread, BuiltinsObjectTestCreate(thread)); + JSHandle function(thread_, BuiltinsObjectTestCreate(thread_)); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle obj_func(env->GetObjectFunction()); JSHandle att_handle = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); JSHandle obj_handle = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); - PropertyDescriptor desc(thread); + PropertyDescriptor desc(thread_); desc.SetWritable(true); - JSHandle writable_str = thread->GlobalConstants()->GetHandledWritableString(); - JSHandle writable(thread, JSTaggedValue(desc.IsWritable())); - JSObject::CreateDataProperty(thread, att_handle, writable_str, writable); + JSHandle writable_str = thread_->GlobalConstants()->GetHandledWritableString(); + JSHandle writable(thread_, JSTaggedValue(desc.IsWritable())); + JSObject::CreateDataProperty(thread_, att_handle, writable_str, writable); - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("x")); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("x")); - PropertyDescriptor desc_nw(thread); - JSObject::GetOwnProperty(thread, obj_handle, key, desc_nw); + PropertyDescriptor desc_nw(thread_); + JSObject::GetOwnProperty(thread_, obj_handle, key, desc_nw); EXPECT_TRUE(!desc_nw.HasWritable()); - auto obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + auto obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); obj_call_info->SetFunction(JSTaggedValue::Undefined()); obj_call_info->SetThis(JSTaggedValue::Undefined()); obj_call_info->SetCallArg(0, obj_handle.GetTaggedValue()); obj_call_info->SetCallArg(1, key.GetTaggedValue()); obj_call_info->SetCallArg(2, att_handle.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, obj_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, obj_call_info.get()); JSTaggedValue result = object::DefineProperty(obj_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsECMAObject()); JSTaggedValue res(reinterpret_cast(result.GetRawData())); - PropertyDescriptor desc_res(thread); - JSObject::GetOwnProperty(thread, JSHandle(thread, res), key, desc_res); + PropertyDescriptor desc_res(thread_); + JSObject::GetOwnProperty(thread_, JSHandle(thread_, res), key, desc_res); EXPECT_TRUE(desc_res.HasWritable()); } // B.2.2.2 Object.prototype.__defineGetter__ ( P, getter ) TEST_F(BuiltinsObjectTest, DefineGetter) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); - JSHandle obj(thread, CreateBuiltinJSObject(thread, "prop")); + JSHandle obj(thread_, CreateBuiltinJSObject(thread_, "prop")); JSHandle key(factory->NewFromString("prop")); - JSHandle getter(factory->NewJSFunction(thread->GetEcmaVM()->GetGlobalEnv())); + JSHandle getter(factory->NewJSFunction(thread_->GetEcmaVM()->GetGlobalEnv())); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, getter.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = object::proto::__defineGetter__(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); } @@ -353,21 +361,21 @@ TEST_F(BuiltinsObjectTest, DefineGetter) // B.2.2.3 Object.prototype.__defineSetter__ ( P, setter ) TEST_F(BuiltinsObjectTest, DefineSetter) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); - JSHandle obj(thread, CreateBuiltinJSObject(thread, "prop")); + JSHandle obj(thread_, CreateBuiltinJSObject(thread_, "prop")); JSHandle key(factory->NewFromString("prop")); - JSHandle setter(factory->NewJSFunction(thread->GetEcmaVM()->GetGlobalEnv())); + JSHandle setter(factory->NewJSFunction(thread_->GetEcmaVM()->GetGlobalEnv())); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, setter.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = object::proto::__defineSetter__(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); } @@ -375,46 +383,46 @@ TEST_F(BuiltinsObjectTest, DefineSetter) // B.2.2.4 Object.prototype.__lookupGetter__ ( P ) TEST_F(BuiltinsObjectTest, LookupGetter) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); - JSHandle obj(thread, CreateBuiltinJSObject(thread, "prop")); + JSHandle obj(thread_, CreateBuiltinJSObject(thread_, "prop")); JSHandle key(factory->NewFromString("prop")); - JSHandle getter(factory->NewJSFunction(thread->GetEcmaVM()->GetGlobalEnv())); + JSHandle getter(factory->NewJSFunction(thread_->GetEcmaVM()->GetGlobalEnv())); // First - getter should not be defined. - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = object::proto::__lookupGetter__(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); // Second - set a getter function. - ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, getter.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); result = object::proto::__defineGetter__(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); // Third - check the getter function if it really exists. - ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); result = object::proto::__lookupGetter__(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result, getter.GetTaggedValue()); } @@ -422,46 +430,46 @@ TEST_F(BuiltinsObjectTest, LookupGetter) // B.2.2.5 Object.prototype.__lookupSetter__ ( P ) TEST_F(BuiltinsObjectTest, LookupSetter) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); - JSHandle obj(thread, CreateBuiltinJSObject(thread, "prop")); + JSHandle obj(thread_, CreateBuiltinJSObject(thread_, "prop")); JSHandle key(factory->NewFromString("prop")); - JSHandle setter(factory->NewJSFunction(thread->GetEcmaVM()->GetGlobalEnv())); + JSHandle setter(factory->NewJSFunction(thread_->GetEcmaVM()->GetGlobalEnv())); // First - setter should not be defined. - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = object::proto::__lookupSetter__(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); // Second - set a setter function. - ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, setter.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); result = object::proto::__defineSetter__(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); // Third - check the setter function if it really exists. - ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); result = object::proto::__lookupSetter__(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result, setter.GetTaggedValue()); } @@ -469,69 +477,69 @@ TEST_F(BuiltinsObjectTest, LookupSetter) // 19.1.2.5Object.freeze ( O ) TEST_F(BuiltinsObjectTest, Freeze) { - JSHandle function(thread, BuiltinsObjectTestCreate(thread)); + JSHandle function(thread_, BuiltinsObjectTestCreate(thread_)); // An object is extensible by default, so it is also non-frozen. JSHandle empty_obj = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); empty_obj->GetJSHClass()->SetExtensible(true); - auto nofreeze_obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto nofreeze_obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); nofreeze_obj_call_info->SetFunction(JSTaggedValue::Undefined()); nofreeze_obj_call_info->SetThis(JSTaggedValue::Undefined()); nofreeze_obj_call_info->SetCallArg(0, empty_obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, nofreeze_obj_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, nofreeze_obj_call_info.get()); JSTaggedValue result = object::IsFrozen(nofreeze_obj_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::False().GetRawData()); object::Freeze(nofreeze_obj_call_info.get()); JSTaggedValue result_is = object::IsFrozen(nofreeze_obj_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result_is.GetRawData(), JSTaggedValue::True().GetRawData()); } // ES2021 20.1.2.7 Object.fromEntries ( iterable ) TEST_F(BuiltinsObjectTest, FromEntries) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); - JSArray *arr1 = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetHeapObject()); + JSArray *arr1 = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetHeapObject()); EXPECT_TRUE(arr1 != nullptr); - JSArray *arr2 = JSArray::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue().GetHeapObject()); + JSArray *arr2 = JSArray::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetTaggedValue().GetHeapObject()); EXPECT_TRUE(arr2 != nullptr); - JSHandle obj(thread, arr1); + JSHandle obj(thread_, arr1); - JSHandle prop(thread, arr2); + JSHandle prop(thread_, arr2); JSHandle foo_str = JSHandle(factory->NewFromString("foo")); JSHandle bar_str = JSHandle(factory->NewFromString("bar")); - PropertyDescriptor desc0(thread, foo_str, true, true, true); - PropertyDescriptor desc1(thread, bar_str, true, true, true); + PropertyDescriptor desc0(thread_, foo_str, true, true, true); + PropertyDescriptor desc1(thread_, bar_str, true, true, true); - JSHandle key0(thread, JSTaggedValue(0)); - JSHandle key1(thread, JSTaggedValue(1)); + JSHandle key0(thread_, JSTaggedValue(0)); + JSHandle key1(thread_, JSTaggedValue(1)); - JSArray::DefineOwnProperty(thread, prop, key0, desc0); - JSArray::DefineOwnProperty(thread, prop, key1, desc1); + JSArray::DefineOwnProperty(thread_, prop, key0, desc0); + JSArray::DefineOwnProperty(thread_, prop, key1, desc1); - PropertyDescriptor desc_prop(thread, JSHandle(prop), true, true, true); - JSArray::DefineOwnProperty(thread, obj, key0, desc_prop); + PropertyDescriptor desc_prop(thread_, JSHandle(prop), true, true, true); + JSArray::DefineOwnProperty(thread_, obj, key0, desc_prop); - auto obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); obj_call_info->SetFunction(JSTaggedValue::Undefined()); obj_call_info->SetThis(JSTaggedValue::Undefined()); obj_call_info->SetCallArg(0, obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, obj_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, obj_call_info.get()); JSTaggedValue result = object::FromEntries(obj_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsECMAObject()); - PropertyDescriptor desc(thread); - JSObject::GetOwnProperty(thread, JSHandle(thread, result), foo_str, desc); + PropertyDescriptor desc(thread_); + JSObject::GetOwnProperty(thread_, JSHandle(thread_, result), foo_str, desc); ASSERT_TRUE(JSTaggedValue::SameValue(desc.GetValue().GetTaggedValue(), bar_str.GetTaggedValue())); } @@ -539,94 +547,94 @@ TEST_F(BuiltinsObjectTest, FromEntries) // 19.1.2.6 Object.getOwnPropertyDescriptor ( O, P ) TEST_F(BuiltinsObjectTest, GetOwnPropertyDescriptor) { - JSHandle function(thread, BuiltinsObjectTestCreate(thread)); + JSHandle function(thread_, BuiltinsObjectTestCreate(thread_)); JSHandle obj_handle = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("x")); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("x")); - PropertyDescriptor desc_enum(thread); + PropertyDescriptor desc_enum(thread_); desc_enum.SetWritable(true); - JSTaggedValue::DefinePropertyOrThrow(thread, JSHandle(obj_handle), key, desc_enum); + JSTaggedValue::DefinePropertyOrThrow(thread_, JSHandle(obj_handle), key, desc_enum); - auto obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); obj_call_info->SetFunction(JSTaggedValue::Undefined()); obj_call_info->SetThis(JSTaggedValue::Undefined()); obj_call_info->SetCallArg(0, obj_handle.GetTaggedValue()); obj_call_info->SetCallArg(1, key.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, obj_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, obj_call_info.get()); JSTaggedValue result = object::GetOwnPropertyDescriptor(obj_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsECMAObject()); - JSHandle writable_str = thread->GlobalConstants()->GetHandledWritableString(); + JSHandle writable_str = thread_->GlobalConstants()->GetHandledWritableString(); JSTaggedValue jt(reinterpret_cast(result.GetRawData())); - PropertyDescriptor desc(thread); - JSObject::GetOwnProperty(thread, JSHandle(thread, jt), writable_str, desc); + PropertyDescriptor desc(thread_); + JSObject::GetOwnProperty(thread_, JSHandle(thread_, jt), writable_str, desc); ASSERT_TRUE(JSTaggedValue::SameValue(desc.GetValue().GetTaggedValue(), JSTaggedValue(true))); } // ES2021 20.1.2.9 Object.getOwnPropertyDescriptors ( O ) TEST_F(BuiltinsObjectTest, GetOwnPropertyDescriptors) { - JSHandle function(thread, BuiltinsObjectTestCreate(thread)); + JSHandle function(thread_, BuiltinsObjectTestCreate(thread_)); JSHandle obj_handle = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); - JSHandle key_x(thread->GetEcmaVM()->GetFactory()->NewFromString("x")); - JSHandle value(thread, JSTaggedValue(22)); + JSHandle key_x(thread_->GetEcmaVM()->GetFactory()->NewFromString("x")); + JSHandle value(thread_, JSTaggedValue(22)); - JSObject::SetProperty(thread, obj_handle, key_x, value); + JSObject::SetProperty(thread_, obj_handle, key_x, value); - auto obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); obj_call_info->SetFunction(JSTaggedValue::Undefined()); obj_call_info->SetThis(JSTaggedValue::Undefined()); obj_call_info->SetCallArg(0, obj_handle.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, obj_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, obj_call_info.get()); JSTaggedValue result = object::GetOwnPropertyDescriptors(obj_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsECMAObject()); - JSHandle handle(thread, result); + JSHandle handle(thread_, result); - JSHandle prop = JSObject::GetProperty(thread, handle, key_x).GetValue(); + JSHandle prop = JSObject::GetProperty(thread_, handle, key_x).GetValue(); - JSHandle value_str = thread->GlobalConstants()->GetHandledValueString(); - ASSERT_EQ(JSObject::GetProperty(thread, prop, value_str).GetValue()->GetInt(), 22); + JSHandle value_str = thread_->GlobalConstants()->GetHandledValueString(); + ASSERT_EQ(JSObject::GetProperty(thread_, prop, value_str).GetValue()->GetInt(), 22); - JSHandle enumerable_str = thread->GlobalConstants()->GetHandledEnumerableString(); - ASSERT_EQ(JSObject::GetProperty(thread, prop, enumerable_str).GetValue().GetTaggedValue(), JSTaggedValue(true)); + JSHandle enumerable_str = thread_->GlobalConstants()->GetHandledEnumerableString(); + ASSERT_EQ(JSObject::GetProperty(thread_, prop, enumerable_str).GetValue().GetTaggedValue(), JSTaggedValue(true)); - JSHandle configurable_str = thread->GlobalConstants()->GetHandledConfigurableString(); - ASSERT_EQ(JSObject::GetProperty(thread, prop, configurable_str).GetValue().GetTaggedValue(), JSTaggedValue(true)); + JSHandle configurable_str = thread_->GlobalConstants()->GetHandledConfigurableString(); + ASSERT_EQ(JSObject::GetProperty(thread_, prop, configurable_str).GetValue().GetTaggedValue(), JSTaggedValue(true)); - JSHandle writable_str = thread->GlobalConstants()->GetHandledWritableString(); - ASSERT_EQ(JSObject::GetProperty(thread, prop, writable_str).GetValue().GetTaggedValue(), JSTaggedValue(true)); + JSHandle writable_str = thread_->GlobalConstants()->GetHandledWritableString(); + ASSERT_EQ(JSObject::GetProperty(thread_, prop, writable_str).GetValue().GetTaggedValue(), JSTaggedValue(true)); } // 19.1.2.7 Object.getOwnPropertyNames ( O ) TEST_F(BuiltinsObjectTest, GetOwnPropertyNames) { - JSHandle function(thread, BuiltinsObjectTestCreate(thread)); + JSHandle function(thread_, BuiltinsObjectTestCreate(thread_)); JSHandle obj_handle = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("x")); - JSHandle value(thread, JSTaggedValue(1)); - JSObject::SetProperty(thread, JSHandle(obj_handle), key, value); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("x")); + JSHandle value(thread_, JSTaggedValue(1)); + JSObject::SetProperty(thread_, JSHandle(obj_handle), key, value); - auto obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); obj_call_info->SetFunction(JSTaggedValue::Undefined()); obj_call_info->SetThis(JSTaggedValue::Undefined()); obj_call_info->SetCallArg(0, obj_handle.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, obj_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, obj_call_info.get()); JSTaggedValue result = object::GetOwnPropertyNames(obj_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsECMAObject()); } @@ -634,23 +642,23 @@ TEST_F(BuiltinsObjectTest, GetOwnPropertyNames) // 19.1.2.8 Object.getOwnPropertySymbols ( O ) TEST_F(BuiltinsObjectTest, GetOwnPropertySymbols) { - JSHandle function(thread, BuiltinsObjectTestCreate(thread)); + JSHandle function(thread_, BuiltinsObjectTestCreate(thread_)); JSHandle obj_handle = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); - JSHandle symbol_key = thread->GetEcmaVM()->GetFactory()->NewJSSymbol(); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); + JSHandle symbol_key = thread_->GetEcmaVM()->GetFactory()->NewJSSymbol(); JSHandle key(symbol_key); - JSHandle value(thread, JSTaggedValue(1)); - JSObject::SetProperty(thread, JSHandle(obj_handle), key, value); - thread->ClearException(); + JSHandle value(thread_, JSTaggedValue(1)); + JSObject::SetProperty(thread_, JSHandle(obj_handle), key, value); + thread_->ClearException(); - auto obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); obj_call_info->SetFunction(JSTaggedValue::Undefined()); obj_call_info->SetThis(JSTaggedValue::Undefined()); obj_call_info->SetCallArg(0, obj_handle.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, obj_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, obj_call_info.get()); JSTaggedValue result = object::GetOwnPropertySymbols(obj_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsECMAObject()); } @@ -659,22 +667,22 @@ TEST_F(BuiltinsObjectTest, GetOwnPropertySymbols) TEST_F(BuiltinsObjectTest, Is) { // js object compare - JSHandle function(thread, BuiltinsObjectTestCreate(thread)); + JSHandle function(thread_, BuiltinsObjectTestCreate(thread_)); JSHandle obj1 = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); JSHandle obj2 = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); - auto obj_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto obj_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); obj_call_info1->SetFunction(JSTaggedValue::Undefined()); obj_call_info1->SetThis(JSTaggedValue::Undefined()); obj_call_info1->SetCallArg(0, obj1.GetTaggedValue()); obj_call_info1->SetCallArg(1, obj2.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, obj_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, obj_call_info1.get()); JSTaggedValue obj_result1 = object::Is(obj_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(obj_result1.GetRawData(), JSTaggedValue::False().GetRawData()); @@ -683,69 +691,69 @@ TEST_F(BuiltinsObjectTest, Is) ASSERT_EQ(obj_result2.GetRawData(), JSTaggedValue::True().GetRawData()); // string compare - JSHandle test_str_value1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("helloworld"); - JSHandle test_str_value2 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("helloworld"); + JSHandle test_str_value1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("helloworld"); + JSHandle test_str_value2 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("helloworld"); - auto str_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto str_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); str_call_info->SetFunction(JSTaggedValue::Undefined()); str_call_info->SetThis(JSTaggedValue::Undefined()); str_call_info->SetCallArg(0, test_str_value1.GetTaggedValue()); str_call_info->SetCallArg(1, test_str_value2.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, str_call_info.get()); + prev = TestHelper::SetupFrame(thread_, str_call_info.get()); JSTaggedValue str_result = object::Is(str_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(str_result.GetRawData(), JSTaggedValue::True().GetRawData()); // bool compare - auto bool_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto bool_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); bool_call_info->SetFunction(JSTaggedValue::Undefined()); bool_call_info->SetThis(JSTaggedValue::Undefined()); bool_call_info->SetCallArg(0, JSTaggedValue::True()); bool_call_info->SetCallArg(1, JSTaggedValue::False()); - prev = TestHelper::SetupFrame(thread, bool_call_info.get()); + prev = TestHelper::SetupFrame(thread_, bool_call_info.get()); JSTaggedValue bool_result = object::Is(bool_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(bool_result.GetRawData(), JSTaggedValue::False().GetRawData()); // number compare - auto num_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto num_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); num_call_info->SetFunction(JSTaggedValue::Undefined()); num_call_info->SetThis(JSTaggedValue::Undefined()); num_call_info->SetCallArg(0, JSTaggedValue(static_cast(0))); num_call_info->SetCallArg(1, JSTaggedValue(-0.0)); - prev = TestHelper::SetupFrame(thread, num_call_info.get()); + prev = TestHelper::SetupFrame(thread_, num_call_info.get()); JSTaggedValue num_result = object::Is(num_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(num_result.GetRawData(), JSTaggedValue::False().GetRawData()); // undefined or null compare - auto null_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto null_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); null_call_info->SetFunction(JSTaggedValue::Undefined()); null_call_info->SetThis(JSTaggedValue::Undefined()); null_call_info->SetCallArg(0, JSTaggedValue::Null()); null_call_info->SetCallArg(1, JSTaggedValue::Null()); - prev = TestHelper::SetupFrame(thread, null_call_info.get()); + prev = TestHelper::SetupFrame(thread_, null_call_info.get()); JSTaggedValue null_result = object::Is(null_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(null_result.GetRawData(), JSTaggedValue::True().GetRawData()); - auto undefine_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto undefine_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); undefine_call_info->SetFunction(JSTaggedValue::Undefined()); undefine_call_info->SetThis(JSTaggedValue::Undefined()); undefine_call_info->SetCallArg(0, JSTaggedValue::Undefined()); undefine_call_info->SetCallArg(1, JSTaggedValue::Undefined()); - prev = TestHelper::SetupFrame(thread, undefine_call_info.get()); + prev = TestHelper::SetupFrame(thread_, undefine_call_info.get()); JSTaggedValue undefine_result = object::Is(undefine_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(undefine_result.GetRawData(), JSTaggedValue::True().GetRawData()); } @@ -753,20 +761,20 @@ TEST_F(BuiltinsObjectTest, Is) // 19.1.2.11 Object.isExtensible ( O ) TEST_F(BuiltinsObjectTest, IsExtensible) { - JSHandle function(thread, BuiltinsObjectTestCreate(thread)); + JSHandle function(thread_, BuiltinsObjectTestCreate(thread_)); // New objects can be extended by default. JSHandle empty_obj = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); empty_obj->GetJSHClass()->SetExtensible(true); - auto empty_obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto empty_obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); empty_obj_call_info->SetFunction(JSTaggedValue::Undefined()); empty_obj_call_info->SetThis(JSTaggedValue::Undefined()); empty_obj_call_info->SetCallArg(0, empty_obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, empty_obj_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, empty_obj_call_info.get()); JSTaggedValue result = object::IsExtensible(empty_obj_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); @@ -778,20 +786,20 @@ TEST_F(BuiltinsObjectTest, IsExtensible) // 19.1.2.12 Object.isFrozen ( O ) TEST_F(BuiltinsObjectTest, IsFrozen) { - JSHandle function(thread, BuiltinsObjectTestCreate(thread)); - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromString("x")); - JSHandle value(thread, JSTaggedValue(1)); + JSHandle function(thread_, BuiltinsObjectTestCreate(thread_)); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromString("x")); + JSHandle value(thread_, JSTaggedValue(1)); // An object is extensible by default, so it is also non-frozen. JSHandle obj = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle::Cast(function), function); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle::Cast(function), function); obj->GetJSHClass()->SetExtensible(true); - auto empty_obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto empty_obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); empty_obj_call_info->SetFunction(JSTaggedValue::Undefined()); empty_obj_call_info->SetThis(JSTaggedValue::Undefined()); empty_obj_call_info->SetCallArg(0, obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, empty_obj_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, empty_obj_call_info.get()); JSTaggedValue result = object::IsFrozen(empty_obj_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::False().GetRawData()); @@ -799,37 +807,37 @@ TEST_F(BuiltinsObjectTest, IsFrozen) JSTaggedValue result_nex = object::IsFrozen(empty_obj_call_info.get()); ASSERT_EQ(result_nex.GetRawData(), JSTaggedValue::True().GetRawData()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - PropertyDescriptor desc_enum(thread); + PropertyDescriptor desc_enum(thread_); desc_enum.SetConfigurable(true); desc_enum.SetWritable(false); obj->GetJSHClass()->SetExtensible(true); - JSTaggedValue::DefinePropertyOrThrow(thread, JSHandle(obj), key, desc_enum); + JSTaggedValue::DefinePropertyOrThrow(thread_, JSHandle(obj), key, desc_enum); obj->GetJSHClass()->SetExtensible(false); - auto empty_obj_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto empty_obj_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); empty_obj_call_info2->SetFunction(JSTaggedValue::Undefined()); empty_obj_call_info2->SetThis(JSTaggedValue::Undefined()); empty_obj_call_info2->SetCallArg(0, obj.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, empty_obj_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, empty_obj_call_info2.get()); JSTaggedValue result_nw = object::IsFrozen(empty_obj_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result_nw.GetRawData(), JSTaggedValue::False().GetRawData()); desc_enum.SetConfigurable(false); obj->GetJSHClass()->SetExtensible(true); - JSTaggedValue::DefinePropertyOrThrow(thread, JSHandle(obj), key, desc_enum); + JSTaggedValue::DefinePropertyOrThrow(thread_, JSHandle(obj), key, desc_enum); obj->GetJSHClass()->SetExtensible(false); - auto empty_obj_call_info3 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto empty_obj_call_info3 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); empty_obj_call_info3->SetFunction(JSTaggedValue::Undefined()); empty_obj_call_info3->SetThis(JSTaggedValue::Undefined()); empty_obj_call_info3->SetCallArg(0, obj.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, empty_obj_call_info3.get()); + prev = TestHelper::SetupFrame(thread_, empty_obj_call_info3.get()); JSTaggedValue result_nc = object::IsFrozen(empty_obj_call_info3.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result_nc.GetRawData(), JSTaggedValue::True().GetRawData()); } @@ -837,20 +845,20 @@ TEST_F(BuiltinsObjectTest, IsFrozen) // 19.1.2.13 Object.isSealed ( O ) TEST_F(BuiltinsObjectTest, IsSealed) { - JSHandle function(thread, BuiltinsObjectTestCreate(thread)); + JSHandle function(thread_, BuiltinsObjectTestCreate(thread_)); // An object is extensible by default, so it is also non-frozen. JSHandle empty_obj = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(function), function); empty_obj->GetJSHClass()->SetExtensible(true); - auto empty_obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto empty_obj_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); empty_obj_call_info->SetFunction(JSTaggedValue::Undefined()); empty_obj_call_info->SetThis(JSTaggedValue::Undefined()); empty_obj_call_info->SetCallArg(0, empty_obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, empty_obj_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, empty_obj_call_info.get()); JSTaggedValue result = object::IsSealed(empty_obj_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue::False().GetRawData()); } @@ -858,15 +866,15 @@ TEST_F(BuiltinsObjectTest, IsSealed) // Object.keys(obj) TEST_F(BuiltinsObjectTest, Keys) { - JSHandle obj(thread, CreateBuiltinJSObject(thread, "x")); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle obj(thread_, CreateBuiltinJSObject(thread_, "x")); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = object::Keys(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsECMAObject()); } @@ -874,33 +882,33 @@ TEST_F(BuiltinsObjectTest, Keys) // Object.preventExtensions(obj) TEST_F(BuiltinsObjectTest, PreventExtensions) { - JSHandle obj = JSHandle(thread, CreateBuiltinJSObject(thread, "x")); + JSHandle obj = JSHandle(thread_, CreateBuiltinJSObject(thread_, "x")); obj->GetJSHClass()->SetExtensible(true); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = object::PreventExtensions(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsECMAObject()); JSTaggedValue jt(reinterpret_cast(result.GetRawData())); - JSHandle jt_handle(thread, jt); + JSHandle jt_handle(thread_, jt); ASSERT_TRUE(!jt_handle->IsExtensible()); } // Object.seal(obj) TEST_F(BuiltinsObjectTest, Seal) { - JSHandle obj(thread, CreateBuiltinJSObject(thread, "x")); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle obj(thread_, CreateBuiltinJSObject(thread_, "x")); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = object::Seal(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsECMAObject()); @@ -908,77 +916,77 @@ TEST_F(BuiltinsObjectTest, Seal) // test isSealed(). JSTaggedValue res = object::IsSealed(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(res.GetRawData(), JSTaggedValue::True().GetRawData()); } // Object.setPrototypeOf(obj, prototype) TEST_F(BuiltinsObjectTest, SetPrototypeOf) { - JSHandle obj(thread, CreateBuiltinJSObject(thread, "x")); - JSHandle obj_father(thread, CreateBuiltinJSObject(thread, "y")); + JSHandle obj(thread_, CreateBuiltinJSObject(thread_, "x")); + JSHandle obj_father(thread_, CreateBuiltinJSObject(thread_, "y")); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, obj_father.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = object::SetPrototypeOf(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsECMAObject()); ASSERT_EQ(result.GetRawData(), obj.GetTaggedValue().GetRawData()); // test obj has property "y". - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("y")); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj), key).GetValue()->GetInt(), 1); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("y")); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj), key).GetValue()->GetInt(), 1); } // Object.values(obj) TEST_F(BuiltinsObjectTest, Values) { - JSHandle obj(thread, CreateBuiltinJSObject(thread, "x")); - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromString("y")); - JSHandle value(thread, JSTaggedValue(22)); + JSHandle obj(thread_, CreateBuiltinJSObject(thread_, "x")); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromString("y")); + JSHandle value(thread_, JSTaggedValue(22)); - JSObject::SetProperty(thread, obj, key, value); + JSObject::SetProperty(thread_, obj, key, value); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = object::Values(ecma_runtime_call_info.get()); EXPECT_TRUE(result.IsECMAObject()); - JSHandle handle(thread, result); - JSHandle index0(thread, JSTaggedValue(0)); - JSHandle index1(thread, JSTaggedValue(1)); + JSHandle handle(thread_, result); + JSHandle index0(thread_, JSTaggedValue(0)); + JSHandle index1(thread_, JSTaggedValue(1)); - ASSERT_EQ(JSObject::GetProperty(thread, JSHandle(handle), index0).GetValue()->GetInt(), 1); - ASSERT_EQ(JSObject::GetProperty(thread, JSHandle(handle), index1).GetValue()->GetInt(), 22); + ASSERT_EQ(JSObject::GetProperty(thread_, JSHandle(handle), index0).GetValue()->GetInt(), 1); + ASSERT_EQ(JSObject::GetProperty(thread_, JSHandle(handle), index1).GetValue()->GetInt(), 22); } // obj.hasOwnProperty(prop) TEST_F(BuiltinsObjectTest, HasOwnProperty) { - JSHandle obj(thread, CreateBuiltinJSObject(thread, "x")); + JSHandle obj(thread_, CreateBuiltinJSObject(thread_, "x")); PandaString key_c_str = "x"; - JSHandle key_string = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(&key_c_str[0]); + JSHandle key_string = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(&key_c_str[0]); JSHandle key(key_string); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = object::proto::HasOwnProperty(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); } @@ -986,47 +994,47 @@ TEST_F(BuiltinsObjectTest, HasOwnProperty) // prototypeObj.isPrototypeOf(object) TEST_F(BuiltinsObjectTest, IsPrototypeOfFalse) { - JSHandle obj(thread, CreateBuiltinJSObject(thread, "x")); - JSHandle obj_father(thread, CreateBuiltinJSObject(thread, "y")); + JSHandle obj(thread_, CreateBuiltinJSObject(thread_, "x")); + JSHandle obj_father(thread_, CreateBuiltinJSObject(thread_, "y")); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj_father.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = object::proto::IsPrototypeOf(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result1.GetRawData(), JSTaggedValue::False().GetRawData()); } TEST_F(BuiltinsObjectTest, IsPrototypeOfTrue) { - JSHandle obj(thread, CreateBuiltinJSObject(thread, "x")); - JSHandle obj_father(thread, CreateBuiltinJSObject(thread, "y")); + JSHandle obj(thread_, CreateBuiltinJSObject(thread_, "x")); + JSHandle obj_father(thread_, CreateBuiltinJSObject(thread_, "y")); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetCallArg(0, obj.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(1, obj_father.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result1 = object::SetPrototypeOf(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result1.IsObject()); ASSERT_EQ(result1.GetRawData(), obj->GetRawData()); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(obj_father.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(0, obj.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue result2 = object::proto::IsPrototypeOf(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result2.GetRawData(), JSTaggedValue::True().GetRawData()); } @@ -1034,17 +1042,17 @@ TEST_F(BuiltinsObjectTest, IsPrototypeOfTrue) // obj.propertyIsEnumerable(prop) TEST_F(BuiltinsObjectTest, PropertyIsEnumerable) { - JSHandle obj(thread, CreateBuiltinJSObject(thread, "x")); - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("x")); + JSHandle obj(thread_, CreateBuiltinJSObject(thread_, "x")); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("x")); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = object::proto::PropertyIsEnumerable(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); } @@ -1052,24 +1060,24 @@ TEST_F(BuiltinsObjectTest, PropertyIsEnumerable) // obj.toLocaleString() TEST_F(BuiltinsObjectTest, ToLocaleString) { - JSHandle obj(thread, CreateBuiltinJSObject(thread, "x")); - JSHandle callee_func = thread->GetEcmaVM()->GetFactory()->NewJSFunction( - thread->GetEcmaVM()->GetGlobalEnv(), reinterpret_cast(object::proto::ToString)); + JSHandle obj(thread_, CreateBuiltinJSObject(thread_, "x")); + JSHandle callee_func = thread_->GetEcmaVM()->GetFactory()->NewJSFunction( + thread_->GetEcmaVM()->GetGlobalEnv(), reinterpret_cast(object::proto::ToString)); JSHandle callee_value(callee_func); - JSHandle callee_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("toString")); - JSObject::SetProperty(thread, obj, callee_key, callee_value); + JSHandle callee_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("toString")); + JSObject::SetProperty(thread_, obj, callee_key, callee_value); JSHandle result_value = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("[object Object]"); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("[object Object]"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = object::proto::ToLocaleString(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsString()); ASSERT_EQ(result_value->Compare(reinterpret_cast(result.GetRawData())), 0); @@ -1078,112 +1086,112 @@ TEST_F(BuiltinsObjectTest, ToLocaleString) // obj.toString() TEST_F(BuiltinsObjectTest, ToString) { - JSHandle obj = JSHandle(thread, CreateBuiltinJSObject(thread, "x")); + JSHandle obj = JSHandle(thread_, CreateBuiltinJSObject(thread_, "x")); // object JSHandle result_value = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("[object Object]"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("[object Object]"); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = object::proto::ToString(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsString()); ASSERT_EQ(result_value->Compare(reinterpret_cast(result.GetRawData())), 0); // array - JSHandle arr = thread->GetEcmaVM()->GetFactory()->NewJSArray(); + JSHandle arr = thread_->GetEcmaVM()->GetFactory()->NewJSArray(); JSHandle result_arr_value = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("[object Array]"); - auto arr_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("[object Array]"); + auto arr_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); arr_ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); arr_ecma_runtime_call_info->SetThis(arr.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, arr_ecma_runtime_call_info.get()); + prev = TestHelper::SetupFrame(thread_, arr_ecma_runtime_call_info.get()); JSTaggedValue result_arr = object::proto::ToString(arr_ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result_arr.IsString()); ASSERT_EQ(result_arr_value->Compare(reinterpret_cast(result_arr.GetRawData())), 0); // string - JSHandle str = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("hello"); + JSHandle str = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("hello"); JSHandle result_str_value = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("[object String]"); - auto str_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("[object String]"); + auto str_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); str_ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); str_ecma_runtime_call_info->SetThis(str.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, str_ecma_runtime_call_info.get()); + prev = TestHelper::SetupFrame(thread_, str_ecma_runtime_call_info.get()); JSTaggedValue result_str = object::proto::ToString(str_ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result_str.IsString()); ASSERT_EQ(result_str_value->Compare(reinterpret_cast(result_str.GetRawData())), 0); // function - JSHandle func = thread->GetEcmaVM()->GetFactory()->NewJSFunction(thread->GetEcmaVM()->GetGlobalEnv()); + JSHandle func = thread_->GetEcmaVM()->GetFactory()->NewJSFunction(thread_->GetEcmaVM()->GetGlobalEnv()); JSHandle result_func_value = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("[object Function]"); - auto func_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("[object Function]"); + auto func_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); func_ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); func_ecma_runtime_call_info->SetThis(func.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, func_ecma_runtime_call_info.get()); + prev = TestHelper::SetupFrame(thread_, func_ecma_runtime_call_info.get()); JSTaggedValue result_func = object::proto::ToString(func_ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result_func.IsString()); ASSERT_EQ(result_func_value->Compare(reinterpret_cast(result_func.GetRawData())), 0); // error - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle error_object = env->GetErrorFunction(); JSHandle error = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(error_object), error_object); - JSHandle error_value = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("[object Error]"); - auto error_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(error_object), error_object); + JSHandle error_value = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("[object Error]"); + auto error_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); error_ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); error_ecma_runtime_call_info->SetThis(error.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, error_ecma_runtime_call_info.get()); + prev = TestHelper::SetupFrame(thread_, error_ecma_runtime_call_info.get()); JSTaggedValue result_error = object::proto::ToString(error_ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result_error.IsString()); ASSERT_EQ(error_value->Compare(reinterpret_cast(result_error.GetRawData())), 0); // boolean - JSHandle value(thread, JSTaggedValue::False()); + JSHandle value(thread_, JSTaggedValue::False()); JSHandle boolean_object(env->GetBooleanFunction()); - JSHandle boolean = thread->GetEcmaVM()->GetFactory()->NewJSPrimitiveRef(boolean_object, value); + JSHandle boolean = thread_->GetEcmaVM()->GetFactory()->NewJSPrimitiveRef(boolean_object, value); JSHandle result_bool_value = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("[object Boolean]"); - auto bool_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("[object Boolean]"); + auto bool_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); bool_ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); bool_ecma_runtime_call_info->SetThis(boolean.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, bool_ecma_runtime_call_info.get()); + prev = TestHelper::SetupFrame(thread_, bool_ecma_runtime_call_info.get()); JSTaggedValue result_bool = object::proto::ToString(bool_ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result_bool.IsString()); ASSERT_EQ(result_bool_value->Compare(reinterpret_cast(result_bool.GetRawData())), 0); // number JSHandle result_num_value = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("[object Number]"); - auto num_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("[object Number]"); + auto num_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); num_ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); num_ecma_runtime_call_info->SetThis(JSTaggedValue(static_cast(0))); - prev = TestHelper::SetupFrame(thread, num_ecma_runtime_call_info.get()); + prev = TestHelper::SetupFrame(thread_, num_ecma_runtime_call_info.get()); JSTaggedValue result_num = object::proto::ToString(num_ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result_num.IsString()); ASSERT_EQ(result_num_value->Compare(reinterpret_cast(result_num.GetRawData())), 0); @@ -1192,16 +1200,18 @@ TEST_F(BuiltinsObjectTest, ToString) // object.valueOf() TEST_F(BuiltinsObjectTest, ValueOf) { - JSHandle obj(thread, CreateBuiltinJSObject(thread, "x")); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle obj(thread_, CreateBuiltinJSObject(thread_, "x")); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, obj.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = object::proto::ValueOf(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsECMAObject()); } -} // namespace panda::test \ No newline at end of file +} // namespace panda::test + +// NOLINTEND(readability-magic-numbers) diff --git a/tests/runtime/builtins/builtins_promise_test.cpp b/tests/runtime/builtins/builtins_promise_test.cpp index 63c5dcd907060ddfa62479d158b3e92129731586..5f88c9d007293b3b0bd264ff9be76e6e3f3191ce 100644 --- a/tests/runtime/builtins/builtins_promise_test.cpp +++ b/tests/runtime/builtins/builtins_promise_test.cpp @@ -27,9 +27,13 @@ #include "plugins/ecmascript/tests/runtime/common/test_helper.h" #include "utils/bit_utils.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; +// NOLINTBEGIN(readability-magic-numbers) + namespace panda::test { using JSArray = panda::ecmascript::JSArray; @@ -47,17 +51,22 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + PandaVM *instance_ {nullptr}; + +private: + EcmaHandleScope *scope_ {nullptr}; }; // native function for race2 then_on_rejected() @@ -129,12 +138,12 @@ JSTaggedValue TestPromiseThenOnRejected(EcmaRuntimeCallInfo *argv) */ TEST_F(BuiltinsPromiseTest, Reject1) { - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle promise = JSHandle::Cast(env->GetPromiseFunction()); - JSHandle param_msg(thread, JSTaggedValue(3)); + JSHandle param_msg(thread_, JSTaggedValue(3)); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*promise), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*promise), 6); ecma_runtime_call_info1->SetFunction(promise.GetTaggedValue()); ecma_runtime_call_info1->SetThis(promise.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, param_msg.GetTaggedValue()); @@ -142,9 +151,9 @@ TEST_F(BuiltinsPromiseTest, Reject1) /** * @tc.steps: var p1 = Promise.reject(3). */ - [[maybe_unused]] auto prev_reject = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev_reject = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = promise::Reject(ecma_runtime_call_info1.get()); - JSHandle reject_promise(thread, result); + JSHandle reject_promise(thread_, result); EXPECT_EQ(JSTaggedValue::SameValue(reject_promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::REJECTED))), true); @@ -158,8 +167,8 @@ TEST_F(BuiltinsPromiseTest, Reject1) */ TEST_F(BuiltinsPromiseTest, Reject2) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); // constructor promise1 JSHandle promise = JSHandle::Cast(env->GetPromiseFunction()); @@ -169,14 +178,14 @@ TEST_F(BuiltinsPromiseTest, Reject2) /** * @tc.steps: step1. var p1 = Promise.reject("Promise reject") */ - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, promise.GetTaggedValue(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, promise.GetTaggedValue(), 6); ecma_runtime_call_info->SetFunction(promise.GetTaggedValue()); ecma_runtime_call_info->SetThis(promise.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, param_msg1.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = promise::Reject(ecma_runtime_call_info.get()); - JSHandle promise1(thread, result); + JSHandle promise1(thread_, result); EXPECT_EQ(JSTaggedValue::SameValue(promise1->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::REJECTED))), true); @@ -185,14 +194,14 @@ TEST_F(BuiltinsPromiseTest, Reject2) /** * @tc.steps: step2. var p2 = Promise.reject(p1) */ - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, promise.GetTaggedValue(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, promise.GetTaggedValue(), 6); ecma_runtime_call_info1->SetFunction(promise.GetTaggedValue()); ecma_runtime_call_info1->SetThis(promise.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, promise1.GetTaggedValue()); - [[maybe_unused]] auto prev1 = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev1 = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result1 = promise::Reject(ecma_runtime_call_info1.get()); - JSHandle promise2(thread, result1); + JSHandle promise2(thread_, result1); EXPECT_NE(*promise1, *promise2); EXPECT_EQ(JSTaggedValue::SameValue(promise2->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::REJECTED))), @@ -209,22 +218,22 @@ TEST_F(BuiltinsPromiseTest, Reject2) */ TEST_F(BuiltinsPromiseTest, Resolve1) { - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle promise = JSHandle::Cast(env->GetPromiseFunction()); - JSHandle param_msg(thread, JSTaggedValue(5)); + JSHandle param_msg(thread_, JSTaggedValue(5)); /** * @tc.steps: step1. var p1 = Promise.resolve(12345) */ - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*promise), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*promise), 6); ecma_runtime_call_info1->SetFunction(promise.GetTaggedValue()); ecma_runtime_call_info1->SetThis(promise.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, param_msg.GetTaggedValue()); - [[maybe_unused]] auto prev_reject = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev_reject = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = promise::Resolve(ecma_runtime_call_info1.get()); - JSHandle reject_promise(thread, result); + JSHandle reject_promise(thread_, result); EXPECT_EQ(JSTaggedValue::SameValue(reject_promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::FULFILLED))), true); @@ -238,8 +247,8 @@ TEST_F(BuiltinsPromiseTest, Resolve1) */ TEST_F(BuiltinsPromiseTest, Resolve2) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); // constructor promise1 JSHandle promise = JSHandle::Cast(env->GetPromiseFunction()); @@ -249,14 +258,14 @@ TEST_F(BuiltinsPromiseTest, Resolve2) /** * @tc.steps: step1. var p1 = Promise.reject("Promise reject") */ - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, promise.GetTaggedValue(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, promise.GetTaggedValue(), 6); ecma_runtime_call_info->SetFunction(promise.GetTaggedValue()); ecma_runtime_call_info->SetThis(promise.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, param_msg1.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = promise::Reject(ecma_runtime_call_info.get()); - JSHandle promise1(thread, result); + JSHandle promise1(thread_, result); EXPECT_EQ(JSTaggedValue::SameValue(promise1->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::REJECTED))), true); @@ -266,14 +275,14 @@ TEST_F(BuiltinsPromiseTest, Resolve2) /** * @tc.steps: step2. var p2 = Promise.resolve(p1) */ - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, promise.GetTaggedValue(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, promise.GetTaggedValue(), 6); ecma_runtime_call_info1->SetFunction(promise.GetTaggedValue()); ecma_runtime_call_info1->SetThis(promise.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, promise1.GetTaggedValue()); - [[maybe_unused]] auto prev1 = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev1 = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result1 = promise::Resolve(ecma_runtime_call_info1.get()); - JSHandle promise2(thread, result1); + JSHandle promise2(thread_, result1); EXPECT_EQ(*promise1, *promise2); EXPECT_EQ(JSTaggedValue::SameValue(promise2->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::REJECTED))), @@ -288,23 +297,23 @@ TEST_F(BuiltinsPromiseTest, Resolve2) */ TEST_F(BuiltinsPromiseTest, Race1) { - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle promise = JSHandle::Cast(env->GetPromiseFunction()); - JSHandle param_msg1(thread, JSTaggedValue(12345)); - JSHandle param_msg2(thread, JSTaggedValue(6789)); + JSHandle param_msg1(thread_, JSTaggedValue(12345)); + JSHandle param_msg2(thread_, JSTaggedValue(6789)); /** * @tc.steps: step1. var p1 = Promise.reject(12345) */ - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*promise), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*promise), 6); ecma_runtime_call_info1->SetFunction(promise.GetTaggedValue()); ecma_runtime_call_info1->SetThis(promise.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, param_msg1.GetTaggedValue()); - [[maybe_unused]] auto prev_reject = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev_reject = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result1 = promise::Reject(ecma_runtime_call_info1.get()); - JSHandle reject_promise(thread, result1); + JSHandle reject_promise(thread_, result1); EXPECT_EQ(JSTaggedValue::SameValue(reject_promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::REJECTED))), true); @@ -313,14 +322,14 @@ TEST_F(BuiltinsPromiseTest, Race1) /** * @tc.steps: step2. var p2 = Promise.resolve(6789) */ - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*promise), 6); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*promise), 6); ecma_runtime_call_info2->SetFunction(promise.GetTaggedValue()); ecma_runtime_call_info2->SetThis(promise.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(0, param_msg2.GetTaggedValue()); - [[maybe_unused]] auto prev_resolve = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + [[maybe_unused]] auto prev_resolve = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue result2 = promise::Resolve(ecma_runtime_call_info2.get()); - JSHandle resolve_promise(thread, result2); + JSHandle resolve_promise(thread_, result2); EXPECT_EQ(JSTaggedValue::SameValue(resolve_promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::FULFILLED))), true); @@ -329,24 +338,24 @@ TEST_F(BuiltinsPromiseTest, Race1) /** * @tc.steps: step3. Construct an array with two elements p1 and p2. array = [p1. p2] */ - JSHandle array(JSArray::ArrayCreate(thread, JSTaggedNumber(2))); - PropertyDescriptor desc(thread, JSHandle::Cast(reject_promise)); - JSArray::DefineOwnProperty(thread, array, JSHandle(thread, JSTaggedValue(0)), desc); + JSHandle array(JSArray::ArrayCreate(thread_, JSTaggedNumber(2))); + PropertyDescriptor desc(thread_, JSHandle::Cast(reject_promise)); + JSArray::DefineOwnProperty(thread_, array, JSHandle(thread_, JSTaggedValue(0)), desc); - PropertyDescriptor desc1(thread, JSHandle::Cast(resolve_promise)); - JSArray::DefineOwnProperty(thread, array, JSHandle(thread, JSTaggedValue(1)), desc1); + PropertyDescriptor desc1(thread_, JSHandle::Cast(resolve_promise)); + JSArray::DefineOwnProperty(thread_, array, JSHandle(thread_, JSTaggedValue(1)), desc1); /** * @tc.steps: step4. var p3 = Promise.race([p1,p2]); */ - auto ecma_runtime_call_info4 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*promise), 6); + auto ecma_runtime_call_info4 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*promise), 6); ecma_runtime_call_info4->SetFunction(promise.GetTaggedValue()); ecma_runtime_call_info4->SetThis(promise.GetTaggedValue()); ecma_runtime_call_info4->SetCallArg(0, array.GetTaggedValue()); - [[maybe_unused]] auto prev4 = TestHelper::SetupFrame(thread, ecma_runtime_call_info4.get()); + [[maybe_unused]] auto prev4 = TestHelper::SetupFrame(thread_, ecma_runtime_call_info4.get()); JSTaggedValue result4 = promise::Race(ecma_runtime_call_info4.get()); - JSHandle race_promise(thread, result4); + JSHandle race_promise(thread_, result4); EXPECT_EQ(JSTaggedValue::SameValue(race_promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::PENDING))), true); @@ -361,24 +370,24 @@ TEST_F(BuiltinsPromiseTest, Race1) */ TEST_F(BuiltinsPromiseTest, Race2) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle promise = JSHandle::Cast(env->GetPromiseFunction()); - JSHandle param_msg1(thread, JSTaggedValue(12345)); - JSHandle param_msg2(thread, JSTaggedValue(6789)); + JSHandle param_msg1(thread_, JSTaggedValue(12345)); + JSHandle param_msg2(thread_, JSTaggedValue(6789)); /** * @tc.steps: step1. var p1 = Promise.reject(12345) */ - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*promise), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*promise), 6); ecma_runtime_call_info1->SetFunction(promise.GetTaggedValue()); ecma_runtime_call_info1->SetThis(promise.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, param_msg1.GetTaggedValue()); - [[maybe_unused]] auto prev_reject = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev_reject = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result1 = promise::Reject(ecma_runtime_call_info1.get()); - JSHandle reject_promise(thread, result1); + JSHandle reject_promise(thread_, result1); EXPECT_EQ(JSTaggedValue::SameValue(reject_promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::REJECTED))), true); @@ -387,14 +396,14 @@ TEST_F(BuiltinsPromiseTest, Race2) /** * @tc.steps: step2. var p2 = Promise.resolve(6789) */ - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*promise), 6); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*promise), 6); ecma_runtime_call_info2->SetFunction(promise.GetTaggedValue()); ecma_runtime_call_info2->SetThis(promise.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(0, param_msg2.GetTaggedValue()); - [[maybe_unused]] auto prev_resolve = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + [[maybe_unused]] auto prev_resolve = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue result2 = promise::Resolve(ecma_runtime_call_info2.get()); - JSHandle resolve_promise(thread, result2); + JSHandle resolve_promise(thread_, result2); EXPECT_EQ(JSTaggedValue::SameValue(resolve_promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::FULFILLED))), true); @@ -403,24 +412,24 @@ TEST_F(BuiltinsPromiseTest, Race2) /** * @tc.steps: step3. Construct an array with two elements p1 and p2. array = [p1. p2] */ - JSHandle array(JSArray::ArrayCreate(thread, JSTaggedNumber(2))); - PropertyDescriptor desc(thread, JSHandle::Cast(reject_promise)); - JSArray::DefineOwnProperty(thread, array, JSHandle(thread, JSTaggedValue(0)), desc); + JSHandle array(JSArray::ArrayCreate(thread_, JSTaggedNumber(2))); + PropertyDescriptor desc(thread_, JSHandle::Cast(reject_promise)); + JSArray::DefineOwnProperty(thread_, array, JSHandle(thread_, JSTaggedValue(0)), desc); - PropertyDescriptor desc1(thread, JSHandle::Cast(resolve_promise)); - JSArray::DefineOwnProperty(thread, array, JSHandle(thread, JSTaggedValue(1)), desc1); + PropertyDescriptor desc1(thread_, JSHandle::Cast(resolve_promise)); + JSArray::DefineOwnProperty(thread_, array, JSHandle(thread_, JSTaggedValue(1)), desc1); /** * @tc.steps: step4. var p3 = Promise.race([p1,p2]); */ - auto ecma_runtime_call_info4 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*promise), 6); + auto ecma_runtime_call_info4 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*promise), 6); ecma_runtime_call_info4->SetFunction(promise.GetTaggedValue()); ecma_runtime_call_info4->SetThis(promise.GetTaggedValue()); ecma_runtime_call_info4->SetCallArg(0, array.GetTaggedValue()); - [[maybe_unused]] auto prev4 = TestHelper::SetupFrame(thread, ecma_runtime_call_info4.get()); + [[maybe_unused]] auto prev4 = TestHelper::SetupFrame(thread_, ecma_runtime_call_info4.get()); JSTaggedValue result4 = promise::Race(ecma_runtime_call_info4.get()); - JSHandle race_promise(thread, result4); + JSHandle race_promise(thread_, result4); EXPECT_EQ(JSTaggedValue::SameValue(race_promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::PENDING))), true); @@ -431,15 +440,15 @@ TEST_F(BuiltinsPromiseTest, Race2) */ JSHandle native_func_race_then_onrejected = factory->NewJSFunction(env, reinterpret_cast(TestPromiseRaceThenOnRejectd)); - auto ecma_runtime_call_info5 = TestHelper::CreateEcmaRuntimeCallInfo(thread, race_promise.GetTaggedValue(), 8); + auto ecma_runtime_call_info5 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, race_promise.GetTaggedValue(), 8); ecma_runtime_call_info5->SetFunction(race_promise.GetTaggedValue()); ecma_runtime_call_info5->SetThis(race_promise.GetTaggedValue()); ecma_runtime_call_info5->SetCallArg(0, JSTaggedValue::Undefined()); ecma_runtime_call_info5->SetCallArg(1, native_func_race_then_onrejected.GetTaggedValue()); - [[maybe_unused]] auto prev5 = TestHelper::SetupFrame(thread, ecma_runtime_call_info5.get()); + [[maybe_unused]] auto prev5 = TestHelper::SetupFrame(thread_, ecma_runtime_call_info5.get()); JSTaggedValue then_result = promise::proto::Then(ecma_runtime_call_info5.get()); - JSHandle then_promise(thread, then_result); + JSHandle then_promise(thread_, then_result); EXPECT_TRUE(JSTaggedValue::SameValue(then_promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::PENDING)))); @@ -448,9 +457,9 @@ TEST_F(BuiltinsPromiseTest, Race2) /** * @tc.steps: step6. execute promise queue */ - auto micro_job_queue = EcmaVM::Cast(instance)->GetMicroJobQueue(); - if (LIKELY(!thread->HasPendingException())) { - job::MicroJobQueue::ExecutePendingJob(thread, micro_job_queue); + auto micro_job_queue = EcmaVM::Cast(instance_)->GetMicroJobQueue(); + if (LIKELY(!thread_->HasPendingException())) { + job::MicroJobQueue::ExecutePendingJob(thread_, micro_job_queue); } } @@ -462,24 +471,24 @@ TEST_F(BuiltinsPromiseTest, Race2) */ TEST_F(BuiltinsPromiseTest, All) { - ObjectFactory *factory = EcmaVM::Cast(instance)->GetFactory(); - JSHandle env = EcmaVM::Cast(instance)->GetGlobalEnv(); + ObjectFactory *factory = EcmaVM::Cast(instance_)->GetFactory(); + JSHandle env = EcmaVM::Cast(instance_)->GetGlobalEnv(); JSHandle promise = JSHandle::Cast(env->GetPromiseFunction()); - JSHandle param_msg1(thread, JSTaggedValue(111)); - JSHandle param_msg2(thread, JSTaggedValue(222)); + JSHandle param_msg1(thread_, JSTaggedValue(111)); + JSHandle param_msg2(thread_, JSTaggedValue(222)); /** * @tc.steps: step1. var p1 = Promise.resolve(111) */ - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*promise), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*promise), 6); ecma_runtime_call_info1->SetFunction(promise.GetTaggedValue()); ecma_runtime_call_info1->SetThis(promise.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, param_msg1.GetTaggedValue()); - [[maybe_unused]] auto prev_reject = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev_reject = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result1 = promise::Resolve(ecma_runtime_call_info1.get()); - JSHandle resolve_promise1(thread, result1); + JSHandle resolve_promise1(thread_, result1); EXPECT_EQ(JSTaggedValue::SameValue(resolve_promise1->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::FULFILLED))), true); @@ -488,14 +497,14 @@ TEST_F(BuiltinsPromiseTest, All) /** * @tc.steps: step2. var p2 = Promise.resolve(222) */ - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*promise), 6); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*promise), 6); ecma_runtime_call_info2->SetFunction(promise.GetTaggedValue()); ecma_runtime_call_info2->SetThis(promise.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(0, param_msg2.GetTaggedValue()); - [[maybe_unused]] auto prev_resolve = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + [[maybe_unused]] auto prev_resolve = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue result2 = promise::Resolve(ecma_runtime_call_info2.get()); - JSHandle resolve_promise2(thread, result2); + JSHandle resolve_promise2(thread_, result2); EXPECT_EQ(JSTaggedValue::SameValue(resolve_promise2->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::FULFILLED))), true); @@ -504,24 +513,24 @@ TEST_F(BuiltinsPromiseTest, All) /** * @tc.steps: step3. Construct an array with two elements p1 and p2. array = [p1. p2] */ - JSHandle array(JSArray::ArrayCreate(thread, JSTaggedNumber(2))); - PropertyDescriptor desc(thread, JSHandle::Cast(resolve_promise1)); - JSArray::DefineOwnProperty(thread, array, JSHandle(thread, JSTaggedValue(0)), desc); + JSHandle array(JSArray::ArrayCreate(thread_, JSTaggedNumber(2))); + PropertyDescriptor desc(thread_, JSHandle::Cast(resolve_promise1)); + JSArray::DefineOwnProperty(thread_, array, JSHandle(thread_, JSTaggedValue(0)), desc); - PropertyDescriptor desc1(thread, JSHandle::Cast(resolve_promise2)); - JSArray::DefineOwnProperty(thread, array, JSHandle(thread, JSTaggedValue(1)), desc1); + PropertyDescriptor desc1(thread_, JSHandle::Cast(resolve_promise2)); + JSArray::DefineOwnProperty(thread_, array, JSHandle(thread_, JSTaggedValue(1)), desc1); /** * @tc.steps: step4. var p3 = Promise.all([p1,p2]); */ - auto ecma_runtime_call_info4 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*promise), 6); + auto ecma_runtime_call_info4 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*promise), 6); ecma_runtime_call_info4->SetFunction(promise.GetTaggedValue()); ecma_runtime_call_info4->SetThis(promise.GetTaggedValue()); ecma_runtime_call_info4->SetCallArg(0, array.GetTaggedValue()); - [[maybe_unused]] auto prev4 = TestHelper::SetupFrame(thread, ecma_runtime_call_info4.get()); + [[maybe_unused]] auto prev4 = TestHelper::SetupFrame(thread_, ecma_runtime_call_info4.get()); JSTaggedValue result4 = promise::All(ecma_runtime_call_info4.get()); - JSHandle all_promise(thread, result4); + JSHandle all_promise(thread_, result4); EXPECT_EQ(JSTaggedValue::SameValue(all_promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::PENDING))), true); @@ -532,15 +541,15 @@ TEST_F(BuiltinsPromiseTest, All) */ JSHandle native_func_race_then_on_resolved = factory->NewJSFunction(env, reinterpret_cast(TestPromiseAllThenOnResolved)); - auto ecma_runtime_call_info5 = TestHelper::CreateEcmaRuntimeCallInfo(thread, all_promise.GetTaggedValue(), 8); + auto ecma_runtime_call_info5 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, all_promise.GetTaggedValue(), 8); ecma_runtime_call_info5->SetFunction(all_promise.GetTaggedValue()); ecma_runtime_call_info5->SetThis(all_promise.GetTaggedValue()); ecma_runtime_call_info5->SetCallArg(0, native_func_race_then_on_resolved.GetTaggedValue()); ecma_runtime_call_info5->SetCallArg(1, native_func_race_then_on_resolved.GetTaggedValue()); - [[maybe_unused]] auto prev5 = TestHelper::SetupFrame(thread, ecma_runtime_call_info5.get()); + [[maybe_unused]] auto prev5 = TestHelper::SetupFrame(thread_, ecma_runtime_call_info5.get()); JSTaggedValue then_result = promise::proto::Then(ecma_runtime_call_info5.get()); - JSHandle then_promise(thread, then_result); + JSHandle then_promise(thread_, then_result); EXPECT_TRUE(JSTaggedValue::SameValue(then_promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::PENDING)))); @@ -549,9 +558,9 @@ TEST_F(BuiltinsPromiseTest, All) /** * @tc.steps: step6. execute promise queue */ - auto micro_job_queue = EcmaVM::Cast(instance)->GetMicroJobQueue(); - if (LIKELY(!thread->HasPendingException())) { - job::MicroJobQueue::ExecutePendingJob(thread, micro_job_queue); + auto micro_job_queue = EcmaVM::Cast(instance_)->GetMicroJobQueue(); + if (LIKELY(!thread_->HasPendingException())) { + job::MicroJobQueue::ExecutePendingJob(thread_, micro_job_queue); } } @@ -562,23 +571,23 @@ TEST_F(BuiltinsPromiseTest, All) */ TEST_F(BuiltinsPromiseTest, Catch) { - auto env = EcmaVM::Cast(instance)->GetGlobalEnv(); - auto factory = EcmaVM::Cast(instance)->GetFactory(); + auto env = EcmaVM::Cast(instance_)->GetGlobalEnv(); + auto factory = EcmaVM::Cast(instance_)->GetFactory(); JSHandle promise = JSHandle::Cast(env->GetPromiseFunction()); - JSHandle param_msg1(thread, JSTaggedValue(3)); + JSHandle param_msg1(thread_, JSTaggedValue(3)); /** * @tc.steps: step1. var p1 = Promise.reject(3) */ - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*promise), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*promise), 6); ecma_runtime_call_info1->SetFunction(promise.GetTaggedValue()); ecma_runtime_call_info1->SetThis(promise.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, param_msg1.GetTaggedValue()); - [[maybe_unused]] auto prev_reject = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev_reject = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = promise::Reject(ecma_runtime_call_info1.get()); - JSHandle reject_promise(thread, result); + JSHandle reject_promise(thread_, result); EXPECT_EQ(JSTaggedValue::SameValue(reject_promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::REJECTED))), true); @@ -588,14 +597,14 @@ TEST_F(BuiltinsPromiseTest, Catch) * @tc.steps: step2. p1 invokes catch() */ JSHandle test_promise_catch = factory->NewJSFunction(env, reinterpret_cast(TestPromiseCatch)); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, reject_promise.GetTaggedValue(), 6); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, reject_promise.GetTaggedValue(), 6); ecma_runtime_call_info2->SetFunction(reject_promise.GetTaggedValue()); ecma_runtime_call_info2->SetThis(reject_promise.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(0, test_promise_catch.GetTaggedValue()); - [[maybe_unused]] auto prev_catch = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + [[maybe_unused]] auto prev_catch = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue catch_result = promise::proto::Catch(ecma_runtime_call_info2.get()); - JSHandle catch_promise(thread, catch_result); + JSHandle catch_promise(thread_, catch_result); EXPECT_EQ(JSTaggedValue::SameValue(catch_promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::PENDING))), @@ -605,9 +614,9 @@ TEST_F(BuiltinsPromiseTest, Catch) /** * @tc.steps: step3. execute promise queue */ - auto micro_job_queue = EcmaVM::Cast(instance)->GetMicroJobQueue(); - if (LIKELY(!thread->HasPendingException())) { - job::MicroJobQueue::ExecutePendingJob(thread, micro_job_queue); + auto micro_job_queue = EcmaVM::Cast(instance_)->GetMicroJobQueue(); + if (LIKELY(!thread_->HasPendingException())) { + job::MicroJobQueue::ExecutePendingJob(thread_, micro_job_queue); } } @@ -618,8 +627,8 @@ TEST_F(BuiltinsPromiseTest, Catch) */ TEST_F(BuiltinsPromiseTest, ThenResolve) { - auto env = EcmaVM::Cast(instance)->GetGlobalEnv(); - auto factory = EcmaVM::Cast(instance)->GetFactory(); + auto env = EcmaVM::Cast(instance_)->GetGlobalEnv(); + auto factory = EcmaVM::Cast(instance_)->GetFactory(); JSHandle promise = JSHandle::Cast(env->GetPromiseFunction()); JSHandle param_msg = JSHandle::Cast(factory->NewFromCanBeCompressString("resolve")); @@ -627,14 +636,14 @@ TEST_F(BuiltinsPromiseTest, ThenResolve) /** * @tc.steps: step1. var p1 = Promise.resolve("resolve") */ - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*promise), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*promise), 6); ecma_runtime_call_info1->SetFunction(promise.GetTaggedValue()); ecma_runtime_call_info1->SetThis(promise.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, param_msg.GetTaggedValue()); - [[maybe_unused]] auto prev_reject = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev_reject = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = promise::Resolve(ecma_runtime_call_info1.get()); - JSHandle resolve_promise(thread, result); + JSHandle resolve_promise(thread_, result); EXPECT_EQ(JSTaggedValue::SameValue(resolve_promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::FULFILLED))), true); @@ -645,15 +654,15 @@ TEST_F(BuiltinsPromiseTest, ThenResolve) */ JSHandle test_promise_then_on_resolved = factory->NewJSFunction(env, reinterpret_cast(TestPromiseThenOnResolved)); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, resolve_promise.GetTaggedValue(), 8); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, resolve_promise.GetTaggedValue(), 8); ecma_runtime_call_info2->SetFunction(resolve_promise.GetTaggedValue()); ecma_runtime_call_info2->SetThis(resolve_promise.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(0, test_promise_then_on_resolved.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(1, JSTaggedValue::Undefined()); - [[maybe_unused]] auto prev_then = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + [[maybe_unused]] auto prev_then = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue then_result = promise::proto::Then(ecma_runtime_call_info2.get()); - JSHandle then_promise(thread, then_result); + JSHandle then_promise(thread_, then_result); EXPECT_EQ(JSTaggedValue::SameValue(then_promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::PENDING))), @@ -663,9 +672,9 @@ TEST_F(BuiltinsPromiseTest, ThenResolve) /** * @tc.steps: step3. execute promise queue */ - auto micro_job_queue = EcmaVM::Cast(instance)->GetMicroJobQueue(); - if (LIKELY(!thread->HasPendingException())) { - job::MicroJobQueue::ExecutePendingJob(thread, micro_job_queue); + auto micro_job_queue = EcmaVM::Cast(instance_)->GetMicroJobQueue(); + if (LIKELY(!thread_->HasPendingException())) { + job::MicroJobQueue::ExecutePendingJob(thread_, micro_job_queue); } } @@ -676,8 +685,8 @@ TEST_F(BuiltinsPromiseTest, ThenResolve) */ TEST_F(BuiltinsPromiseTest, ThenReject) { - auto env = EcmaVM::Cast(instance)->GetGlobalEnv(); - auto factory = EcmaVM::Cast(instance)->GetFactory(); + auto env = EcmaVM::Cast(instance_)->GetGlobalEnv(); + auto factory = EcmaVM::Cast(instance_)->GetFactory(); JSHandle promise = JSHandle::Cast(env->GetPromiseFunction()); JSHandle param_msg = JSHandle::Cast(factory->NewFromCanBeCompressString("reject")); @@ -685,14 +694,14 @@ TEST_F(BuiltinsPromiseTest, ThenReject) /** * @tc.steps: step1. var p1 = Promise.Reject(5) */ - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*promise), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*promise), 6); ecma_runtime_call_info1->SetFunction(promise.GetTaggedValue()); ecma_runtime_call_info1->SetThis(promise.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, param_msg.GetTaggedValue()); - [[maybe_unused]] auto prev_reject = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev_reject = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result = promise::Reject(ecma_runtime_call_info1.get()); - JSHandle reject_promise(thread, result); + JSHandle reject_promise(thread_, result); EXPECT_EQ(JSTaggedValue::SameValue(reject_promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::REJECTED))), true); @@ -703,15 +712,15 @@ TEST_F(BuiltinsPromiseTest, ThenReject) */ JSHandle test_promise_then_on_rejected = factory->NewJSFunction(env, reinterpret_cast(TestPromiseThenOnRejected)); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, reject_promise.GetTaggedValue(), 8); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, reject_promise.GetTaggedValue(), 8); ecma_runtime_call_info2->SetFunction(reject_promise.GetTaggedValue()); ecma_runtime_call_info2->SetThis(reject_promise.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(0, test_promise_then_on_rejected.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(1, test_promise_then_on_rejected.GetTaggedValue()); - [[maybe_unused]] auto prev_then = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + [[maybe_unused]] auto prev_then = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue then_result = promise::proto::Then(ecma_runtime_call_info2.get()); - JSHandle then_promise(thread, then_result); + JSHandle then_promise(thread_, then_result); EXPECT_EQ(JSTaggedValue::SameValue(then_promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::PENDING))), @@ -720,9 +729,11 @@ TEST_F(BuiltinsPromiseTest, ThenReject) /** * @tc.steps: step3. execute promise queue */ - auto micro_job_queue = EcmaVM::Cast(instance)->GetMicroJobQueue(); - if (LIKELY(!thread->HasPendingException())) { - job::MicroJobQueue::ExecutePendingJob(thread, micro_job_queue); + auto micro_job_queue = EcmaVM::Cast(instance_)->GetMicroJobQueue(); + if (LIKELY(!thread_->HasPendingException())) { + job::MicroJobQueue::ExecutePendingJob(thread_, micro_job_queue); } } } // namespace panda::test + +// NOLINTEND(readability-magic-numbers) diff --git a/tests/runtime/builtins/builtins_proxy_test.cpp b/tests/runtime/builtins/builtins_proxy_test.cpp index ce112cc162f00ee0e2b40e2ae5005cc585ecf56c..f02b8ccd9c4f089dc1e8ffeb63c072b8d35dfcbf 100644 --- a/tests/runtime/builtins/builtins_proxy_test.cpp +++ b/tests/runtime/builtins/builtins_proxy_test.cpp @@ -27,7 +27,9 @@ #include "file_items.h" #include "utils/bit_utils.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; namespace panda::test { @@ -45,17 +47,21 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; JSHandle BuiltinsTestProxyCreate(JSThread *thread) @@ -72,52 +78,52 @@ JSHandle BuiltinsTestProxyCreate(JSThread *thread) // 26.2.1.1 Proxy( [ value ] ) TEST_F(BuiltinsProxyTest, ProxyConstructor) { - JSHandle target = BuiltinsTestProxyCreate(thread); - JSHandle handler = BuiltinsTestProxyCreate(thread); + JSHandle target = BuiltinsTestProxyCreate(thread_); + JSHandle handler = BuiltinsTestProxyCreate(thread_); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Null(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Null(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, target.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, handler.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = proxy::ProxyConstructor(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsECMAObject()); - JSHandle result_handle(thread, result); + JSHandle result_handle(thread_, result); EXPECT_TRUE(result_handle->IsJSProxy()); } // 26.2.2.1 Proxy.revocable ( target, handler ) TEST_F(BuiltinsProxyTest, Revocable) { - JSHandle target = BuiltinsTestProxyCreate(thread); - JSHandle handler = BuiltinsTestProxyCreate(thread); + JSHandle target = BuiltinsTestProxyCreate(thread_); + JSHandle handler = BuiltinsTestProxyCreate(thread_); - JSHandle global_env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle global_env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle proxy_fun(global_env->GetProxyFunction()); - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("prop")); - PropertyDescriptor desc(thread); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("prop")); + PropertyDescriptor desc(thread_); desc.SetWritable(false); - JSObject::DefineOwnProperty(thread, handler, key, desc); + JSObject::DefineOwnProperty(thread_, handler, key, desc); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, target.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, handler.GetTaggedValue()); ecma_runtime_call_info->SetNewTarget(JSTaggedValue(*proxy_fun)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = proxy::Revocable(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsECMAObject()); - JSHandle result_handle(thread, result); + JSHandle result_handle(thread_, result); - auto global_const = thread->GlobalConstants(); + auto global_const = thread_->GlobalConstants(); JSHandle proxy_key = global_const->GetHandledProxyString(); JSHandle revoke_key = global_const->GetHandledRevokeString(); - JSHandle keys = JSObject::GetOwnPropertyKeys(thread, result_handle); + JSHandle keys = JSObject::GetOwnPropertyKeys(thread_, result_handle); bool pflag = false; bool rflag = false; for (uint32_t i = 0; i < keys->GetLength(); i++) { @@ -131,8 +137,8 @@ TEST_F(BuiltinsProxyTest, Revocable) EXPECT_TRUE(pflag); EXPECT_TRUE(rflag); - PropertyDescriptor desc_res(thread); - JSObject::GetOwnProperty(thread, result_handle, revoke_key, desc_res); + PropertyDescriptor desc_res(thread_); + JSObject::GetOwnProperty(thread_, result_handle, revoke_key, desc_res); EXPECT_TRUE(desc_res.GetValue()->IsProxyRevocFunction()); } } // namespace panda::test diff --git a/tests/runtime/builtins/builtins_reflect_test.cpp b/tests/runtime/builtins/builtins_reflect_test.cpp index 0a0c80e7c4ad8d2975aa1a793f9402c72173b129..9791befd208ec9370251ab678ce9e575305425b0 100644 --- a/tests/runtime/builtins/builtins_reflect_test.cpp +++ b/tests/runtime/builtins/builtins_reflect_test.cpp @@ -27,9 +27,12 @@ #include "plugins/ecmascript/runtime/object_factory.h" #include "plugins/ecmascript/tests/runtime/common/test_helper.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; -using JSArray = panda::ecmascript::JSArray; + +// NOLINTBEGIN(readability-magic-numbers) namespace panda::test { class BuiltinsReflectTest : public testing::Test { @@ -46,17 +49,21 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; // use for create a JSObject of test @@ -97,72 +104,72 @@ JSTaggedValue TestReflectApply(EcmaRuntimeCallInfo *argv) // Reflect.apply (target, thisArgument, argumentsList) TEST_F(BuiltinsReflectTest, ReflectApply) { - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // target JSHandle target = factory->NewJSFunction(env, reinterpret_cast(TestReflectApply)); // thisArgument - JSHandle this_argument = - factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle(TestObjectCreate(thread))); - JSObject::SetProperty(thread, JSHandle(this_argument), + JSHandle this_argument = factory->NewJSObjectByConstructor( + TestObjectCreate(thread_), JSHandle(TestObjectCreate(thread_))); + JSObject::SetProperty(thread_, JSHandle(this_argument), JSHandle(factory->NewFromCanBeCompressString("test_reflect_apply_a")), - JSHandle(thread, JSTaggedValue(11))); - JSObject::SetProperty(thread, JSHandle(this_argument), + JSHandle(thread_, JSTaggedValue(11))); + JSObject::SetProperty(thread_, JSHandle(this_argument), JSHandle(factory->NewFromCanBeCompressString("test_reflect_apply_b")), - JSHandle(thread, JSTaggedValue(22))); + JSHandle(thread_, JSTaggedValue(22))); // argumentsList - JSHandle arguments_list(JSArray::ArrayCreate(thread, JSTaggedNumber(2))); - PropertyDescriptor desc(thread, JSHandle(thread, JSTaggedValue(33))); - JSArray::DefineOwnProperty(thread, arguments_list, JSHandle(thread, JSTaggedValue(0)), desc); + JSHandle arguments_list(JSArray::ArrayCreate(thread_, JSTaggedNumber(2))); + PropertyDescriptor desc(thread_, JSHandle(thread_, JSTaggedValue(33))); + JSArray::DefineOwnProperty(thread_, arguments_list, JSHandle(thread_, JSTaggedValue(0)), desc); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(44))); - JSArray::DefineOwnProperty(thread, arguments_list, JSHandle(thread, JSTaggedValue(1)), desc1); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(44))); + JSArray::DefineOwnProperty(thread_, arguments_list, JSHandle(thread_, JSTaggedValue(1)), desc1); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, target.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(*this_argument)); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue(*arguments_list)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = reflect::Apply(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(110).GetRawData()); - JSObject::DeleteProperty(thread, (this_argument), + JSObject::DeleteProperty(thread_, (this_argument), JSHandle(factory->NewFromCanBeCompressString("test_reflect_apply_a"))); - JSObject::DeleteProperty(thread, (this_argument), + JSObject::DeleteProperty(thread_, (this_argument), JSHandle(factory->NewFromCanBeCompressString("test_reflect_apply_b"))); } // Reflect.construct (target, argumentsList [ , new_target]) TEST_F(BuiltinsReflectTest, ReflectConstruct) { - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // target JSHandle target = JSHandle::Cast(env->GetStringFunction()); // argumentsList - JSHandle arguments_list(JSArray::ArrayCreate(thread, JSTaggedNumber(1))); - PropertyDescriptor desc(thread, + JSHandle arguments_list(JSArray::ArrayCreate(thread_, JSTaggedNumber(1))); + PropertyDescriptor desc(thread_, JSHandle::Cast(factory->NewFromCanBeCompressString("ReflectConstruct"))); - JSArray::DefineOwnProperty(thread, arguments_list, JSHandle(thread, JSTaggedValue(0)), desc); + JSArray::DefineOwnProperty(thread_, arguments_list, JSHandle(thread_, JSTaggedValue(0)), desc); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, target.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(*arguments_list)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = reflect::Construct(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsECMAObject()); - JSHandle tagged_result(thread, result); + JSHandle tagged_result(thread_, result); JSHandle ref_result = JSHandle::Cast(tagged_result); JSHandle ruler = factory->NewFromCanBeCompressString("ReflectConstruct"); ASSERT_EQ(EcmaString::Cast(ref_result->GetValue().GetTaggedObject())->Compare(*ruler), 0); @@ -171,47 +178,47 @@ TEST_F(BuiltinsReflectTest, ReflectConstruct) // Reflect.defineProperty (target, propertyKey, attributes) TEST_F(BuiltinsReflectTest, ReflectDefineProperty) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // target - JSHandle target = - factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle(TestObjectCreate(thread))); + JSHandle target = factory->NewJSObjectByConstructor(TestObjectCreate(thread_), + JSHandle(TestObjectCreate(thread_))); // propertyKey JSHandle key(factory->NewFromCanBeCompressString("test_reflect_define_property")); // attributes - JSHandle attributes = - factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle(TestObjectCreate(thread))); + JSHandle attributes = factory->NewJSObjectByConstructor( + TestObjectCreate(thread_), JSHandle(TestObjectCreate(thread_))); // attributes value - auto global_const = thread->GlobalConstants(); + auto global_const = thread_->GlobalConstants(); JSHandle value_key = global_const->GetHandledValueString(); - JSHandle value(thread, JSTaggedValue(100)); - JSObject::SetProperty(thread, JSHandle(attributes), value_key, value); + JSHandle value(thread_, JSTaggedValue(100)); + JSObject::SetProperty(thread_, JSHandle(attributes), value_key, value); // attributes writable JSHandle writable_key = global_const->GetHandledWritableString(); - JSHandle writable(thread, JSTaggedValue::True()); - JSObject::SetProperty(thread, JSHandle(attributes), writable_key, writable); + JSHandle writable(thread_, JSTaggedValue::True()); + JSObject::SetProperty(thread_, JSHandle(attributes), writable_key, writable); // attributes enumerable JSHandle enumerable_key = global_const->GetHandledEnumerableString(); - JSHandle enumerable(thread, JSTaggedValue::False()); - JSObject::SetProperty(thread, JSHandle(attributes), enumerable_key, enumerable); + JSHandle enumerable(thread_, JSTaggedValue::False()); + JSObject::SetProperty(thread_, JSHandle(attributes), enumerable_key, enumerable); // attributes configurable JSHandle configurable_key = global_const->GetHandledConfigurableString(); - JSHandle configurable(thread, JSTaggedValue::True()); - JSObject::SetProperty(thread, JSHandle(attributes), configurable_key, configurable); + JSHandle configurable(thread_, JSTaggedValue::True()); + JSObject::SetProperty(thread_, JSHandle(attributes), configurable_key, configurable); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, target.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, key.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue(*attributes)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = reflect::DefineProperty(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); - PropertyDescriptor desc_ruler(thread); - JSObject::GetOwnProperty(thread, target, key, desc_ruler); + PropertyDescriptor desc_ruler(thread_); + JSObject::GetOwnProperty(thread_, target, key, desc_ruler); ASSERT_EQ(desc_ruler.GetValue()->GetInt(), 100); ASSERT_EQ(desc_ruler.IsWritable(), true); ASSERT_EQ(desc_ruler.IsEnumerable(), false); @@ -221,147 +228,147 @@ TEST_F(BuiltinsReflectTest, ReflectDefineProperty) // Reflect.deleteProperty (target, propertyKey) TEST_F(BuiltinsReflectTest, ReflectDeleteProperty) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // target - JSHandle target = - factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle(TestObjectCreate(thread))); + JSHandle target = factory->NewJSObjectByConstructor(TestObjectCreate(thread_), + JSHandle(TestObjectCreate(thread_))); // propertyKey JSHandle key(factory->NewFromCanBeCompressString("test_reflect_delete_property")); - JSHandle value(thread, JSTaggedValue(101)); - JSObject::SetProperty(thread, JSHandle(target), key, value); + JSHandle value(thread_, JSTaggedValue(101)); + JSObject::SetProperty(thread_, JSHandle(target), key, value); - PropertyDescriptor desc(thread); - ASSERT_EQ(JSObject::GetOwnProperty(thread, target, key, desc), true); + PropertyDescriptor desc(thread_); + ASSERT_EQ(JSObject::GetOwnProperty(thread_, target, key, desc), true); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, target.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, key.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = reflect::DeleteProperty(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); - ASSERT_EQ(JSObject::GetOwnProperty(thread, target, key, desc), false); + ASSERT_EQ(JSObject::GetOwnProperty(thread_, target, key, desc), false); } // Reflect.get (target, propertyKey [ , receiver]) TEST_F(BuiltinsReflectTest, ReflectGet) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // target - JSHandle target = - factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle(TestObjectCreate(thread))); + JSHandle target = factory->NewJSObjectByConstructor(TestObjectCreate(thread_), + JSHandle(TestObjectCreate(thread_))); // propertyKey JSHandle key(factory->NewFromCanBeCompressString("test_reflect_get")); // set property - JSHandle value(thread, JSTaggedValue(101.5)); - JSObject::SetProperty(thread, JSHandle(target), key, value); + JSHandle value(thread_, JSTaggedValue(101.5)); + JSObject::SetProperty(thread_, JSHandle(target), key, value); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, target.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, key.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = reflect::Get(ecma_runtime_call_info.get()); - JSHandle result_value(thread, result); + JSHandle result_value(thread_, result); ASSERT_EQ(result_value->GetDouble(), 101.5); } // Reflect.getOwnPropertyDescriptor ( target, propertyKey ) TEST_F(BuiltinsReflectTest, ReflectGetOwnPropertyDescriptor) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // target - JSHandle target = - factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle(TestObjectCreate(thread))); + JSHandle target = factory->NewJSObjectByConstructor(TestObjectCreate(thread_), + JSHandle(TestObjectCreate(thread_))); // propertyKey JSHandle key(factory->NewFromCanBeCompressString("test_reflect_get_property_descriptor")); - PropertyDescriptor desc(thread, JSHandle(thread, JSTaggedValue(102)), true, false, true); - ASSERT_EQ(JSTaggedValue::DefinePropertyOrThrow(thread, JSHandle(target), key, desc), true); + PropertyDescriptor desc(thread_, JSHandle(thread_, JSTaggedValue(102)), true, false, true); + ASSERT_EQ(JSTaggedValue::DefinePropertyOrThrow(thread_, JSHandle(target), key, desc), true); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, target.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, key.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = reflect::GetOwnPropertyDescriptor(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsECMAObject()); - JSHandle result_obj(thread, result); + JSHandle result_obj(thread_, result); // test value - auto global_const = thread->GlobalConstants(); + auto global_const = thread_->GlobalConstants(); JSHandle value_key = global_const->GetHandledValueString(); - JSHandle result_value = JSObject::GetProperty(thread, result_obj, value_key).GetValue(); + JSHandle result_value = JSObject::GetProperty(thread_, result_obj, value_key).GetValue(); ASSERT_EQ(result_value->GetInt(), 102); // test writable JSHandle writable_key = global_const->GetHandledWritableString(); - JSHandle result_writable = JSObject::GetProperty(thread, result_obj, writable_key).GetValue(); + JSHandle result_writable = JSObject::GetProperty(thread_, result_obj, writable_key).GetValue(); ASSERT_EQ(result_writable->ToBoolean(), true); // test enumerable JSHandle enumerable_key = global_const->GetHandledEnumerableString(); - JSHandle result_enumerable = JSObject::GetProperty(thread, result_obj, enumerable_key).GetValue(); + JSHandle result_enumerable = JSObject::GetProperty(thread_, result_obj, enumerable_key).GetValue(); ASSERT_EQ(result_enumerable->ToBoolean(), false); // test configurable JSHandle configurable_key = global_const->GetHandledConfigurableString(); JSHandle result_configurable = - JSObject::GetProperty(thread, result_obj, configurable_key).GetValue(); + JSObject::GetProperty(thread_, result_obj, configurable_key).GetValue(); ASSERT_EQ(result_configurable->ToBoolean(), true); } // Reflect.getPrototypeOf (target) TEST_F(BuiltinsReflectTest, ReflectGetPrototypeOf) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); - JSHandle target = - factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle(TestObjectCreate(thread))); - JSHandle proto = - factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle(TestObjectCreate(thread))); + JSHandle target = factory->NewJSObjectByConstructor(TestObjectCreate(thread_), + JSHandle(TestObjectCreate(thread_))); + JSHandle proto = factory->NewJSObjectByConstructor(TestObjectCreate(thread_), + JSHandle(TestObjectCreate(thread_))); - ASSERT_EQ(JSObject::SetPrototype(thread, target, JSHandle(proto)), true); + ASSERT_EQ(JSObject::SetPrototype(thread_, target, JSHandle(proto)), true); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, target.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = reflect::GetPrototypeOf(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsECMAObject()); - JSHandle result_obj(thread, JSTaggedValue(reinterpret_cast(result.GetRawData()))); + JSHandle result_obj(thread_, JSTaggedValue(reinterpret_cast(result.GetRawData()))); ASSERT_EQ(JSTaggedValue::SameValue(result_obj.GetTaggedValue(), proto.GetTaggedValue()), true); } // Reflect.has (target, propertyKey) TEST_F(BuiltinsReflectTest, ReflectHas) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // target - JSHandle target = - factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle(TestObjectCreate(thread))); + JSHandle target = factory->NewJSObjectByConstructor(TestObjectCreate(thread_), + JSHandle(TestObjectCreate(thread_))); // propertyKey JSHandle key(factory->NewFromCanBeCompressString("test_reflect_has")); - JSHandle value(thread, JSTaggedValue(103)); - ASSERT_EQ(JSObject::SetProperty(thread, JSHandle(target), key, value), true); + JSHandle value(thread_, JSTaggedValue(103)); + ASSERT_EQ(JSObject::SetProperty(thread_, JSHandle(target), key, value), true); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, target.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, key.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = reflect::Has(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); @@ -370,19 +377,19 @@ TEST_F(BuiltinsReflectTest, ReflectHas) // Reflect.isExtensible (target) TEST_F(BuiltinsReflectTest, ReflectIsExtensible) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // target - JSHandle target = - factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle(TestObjectCreate(thread))); + JSHandle target = factory->NewJSObjectByConstructor(TestObjectCreate(thread_), + JSHandle(TestObjectCreate(thread_))); target->GetJSHClass()->SetExtensible(false); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, target.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = reflect::IsExtensible(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::False().GetRawData()); @@ -391,45 +398,45 @@ TEST_F(BuiltinsReflectTest, ReflectIsExtensible) // Reflect.ownKeys (target) TEST_F(BuiltinsReflectTest, ReflectOwnKeys) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // target - JSHandle target = - factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle(TestObjectCreate(thread))); + JSHandle target = factory->NewJSObjectByConstructor(TestObjectCreate(thread_), + JSHandle(TestObjectCreate(thread_))); JSHandle key0(factory->NewFromCanBeCompressString("test_reflect_own_keys1")); - JSHandle value0(thread, JSTaggedValue(104)); - ASSERT_EQ(JSObject::SetProperty(thread, JSHandle(target), key0, value0), true); + JSHandle value0(thread_, JSTaggedValue(104)); + ASSERT_EQ(JSObject::SetProperty(thread_, JSHandle(target), key0, value0), true); JSHandle key1(factory->NewFromCanBeCompressString("test_reflect_own_keys2")); - JSHandle value1(thread, JSTaggedValue(105)); - ASSERT_EQ(JSObject::SetProperty(thread, JSHandle(target), key1, value1), true); + JSHandle value1(thread_, JSTaggedValue(105)); + ASSERT_EQ(JSObject::SetProperty(thread_, JSHandle(target), key1, value1), true); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, target.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = reflect::OwnKeys(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsECMAObject()); - JSHandle result_tagged_value(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_tagged_value(thread_, reinterpret_cast(result.GetRawData())); JSHandle result_array = JSHandle::Cast(result_tagged_value); // test length - JSHandle result_length_key = thread->GlobalConstants()->GetHandledLengthString(); + JSHandle result_length_key = thread_->GlobalConstants()->GetHandledLengthString(); JSHandle result_length = - JSObject::GetProperty(thread, JSHandle(result_array), result_length_key).GetValue(); + JSObject::GetProperty(thread_, JSHandle(result_array), result_length_key).GetValue(); ASSERT_EQ(result_length->GetInt(), 2); // test array[0] - JSHandle result_key0(thread, JSTaggedValue(0)); + JSHandle result_key0(thread_, JSTaggedValue(0)); JSHandle result_value0 = - JSObject::GetProperty(thread, JSHandle(result_array), result_key0).GetValue(); + JSObject::GetProperty(thread_, JSHandle(result_array), result_key0).GetValue(); ASSERT_EQ(reinterpret_cast(result_value0.GetTaggedValue().GetTaggedObject()) ->Compare(reinterpret_cast(key0.GetTaggedValue().GetTaggedObject())), 0); // test array[1] - JSHandle result_key1(thread, JSTaggedValue(1)); + JSHandle result_key1(thread_, JSTaggedValue(1)); JSHandle result_value1 = - JSObject::GetProperty(thread, JSHandle(result_array), result_key1).GetValue(); + JSObject::GetProperty(thread_, JSHandle(result_array), result_key1).GetValue(); ASSERT_EQ(reinterpret_cast(result_value1.GetTaggedValue().GetTaggedObject()) ->Compare(reinterpret_cast(key1.GetTaggedValue().GetTaggedObject())), 0); @@ -438,19 +445,19 @@ TEST_F(BuiltinsReflectTest, ReflectOwnKeys) // Reflect.preventExtensions (target) TEST_F(BuiltinsReflectTest, ReflectPreventExtensions) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // target - JSHandle target = - factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle(TestObjectCreate(thread))); + JSHandle target = factory->NewJSObjectByConstructor(TestObjectCreate(thread_), + JSHandle(TestObjectCreate(thread_))); target->GetJSHClass()->SetExtensible(true); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, target.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = reflect::PreventExtensions(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); @@ -460,53 +467,55 @@ TEST_F(BuiltinsReflectTest, ReflectPreventExtensions) // Reflect.set (target, propertyKey, V [ , receiver]) TEST_F(BuiltinsReflectTest, ReflectSet) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // target - JSHandle target = - factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle(TestObjectCreate(thread))); + JSHandle target = factory->NewJSObjectByConstructor(TestObjectCreate(thread_), + JSHandle(TestObjectCreate(thread_))); // propertyKey JSHandle key(factory->NewFromCanBeCompressString("test_reflect_set")); // value - JSHandle value(thread, JSTaggedValue(106)); + JSHandle value(thread_, JSTaggedValue(106)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, target.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, key.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(2, value.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = reflect::Set(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); - JSHandle ruler = JSObject::GetProperty(thread, JSHandle(target), key).GetValue(); - ASSERT_EQ(JSTaggedValue::ToInt32(thread, ruler), 106); + JSHandle ruler = JSObject::GetProperty(thread_, JSHandle(target), key).GetValue(); + ASSERT_EQ(JSTaggedValue::ToInt32(thread_, ruler), 106); } // Reflect.setPrototypeOf (target, proto) TEST_F(BuiltinsReflectTest, ReflectSetPrototypeOf) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); - JSHandle target = - factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle(TestObjectCreate(thread))); - JSHandle proto = - factory->NewJSObjectByConstructor(TestObjectCreate(thread), JSHandle(TestObjectCreate(thread))); + JSHandle target = factory->NewJSObjectByConstructor(TestObjectCreate(thread_), + JSHandle(TestObjectCreate(thread_))); + JSHandle proto = factory->NewJSObjectByConstructor(TestObjectCreate(thread_), + JSHandle(TestObjectCreate(thread_))); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, target.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, proto.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = reflect::SetPrototypeOf(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); - JSHandle result_obj(thread, target->GetJSHClass()->GetPrototype()); + JSHandle result_obj(thread_, target->GetJSHClass()->GetPrototype()); ASSERT_EQ(JSTaggedValue::SameValue(result_obj.GetTaggedValue(), proto.GetTaggedValue()), true); } } // namespace panda::test + +// NOLINTEND(readability-magic-numbers) diff --git a/tests/runtime/builtins/builtins_regexp_test.cpp b/tests/runtime/builtins/builtins_regexp_test.cpp index 8558f56aec7e8056d116f4062ee0f2e4f9db5593..45683e4ceb61df3f5fff19fd07230427a73d226f 100644 --- a/tests/runtime/builtins/builtins_regexp_test.cpp +++ b/tests/runtime/builtins/builtins_regexp_test.cpp @@ -31,7 +31,9 @@ #include "plugins/ecmascript/tests/runtime/common/test_helper.h" #include "utils/bit_utils.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; namespace panda::test { @@ -49,17 +51,21 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; JSTaggedValue CreateBuiltinsRegExpObjByPatternAndFlags(JSThread *thread, const JSHandle &pattern, @@ -85,18 +91,18 @@ JSTaggedValue CreateBuiltinsRegExpObjByPatternAndFlags(JSThread *thread, const J TEST_F(BuiltinsRegExpTest, RegExpConstructor1) { // invoke RegExpConstructor method - JSHandle pattern = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("\\w+"); - JSHandle flags = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("i"); - JSTaggedValue result = CreateBuiltinsRegExpObjByPatternAndFlags(thread, pattern, flags); + JSHandle pattern = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("\\w+"); + JSHandle flags = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("i"); + JSTaggedValue result = CreateBuiltinsRegExpObjByPatternAndFlags(thread_, pattern, flags); // ASSERT IsRegExp() - JSHandle regexp_object(thread, result); - ASSERT_TRUE(JSObject::IsRegExp(thread, regexp_object)); + JSHandle regexp_object(thread_, result); + ASSERT_TRUE(JSObject::IsRegExp(thread_, regexp_object)); - JSHandle js_regexp(thread, JSRegExp::Cast(regexp_object->GetTaggedObject())); - JSHandle original_source(thread, js_regexp->GetOriginalSource()); + JSHandle js_regexp(thread_, JSRegExp::Cast(regexp_object->GetTaggedObject())); + JSHandle original_source(thread_, js_regexp->GetOriginalSource()); uint8_t flags_bits = static_cast(js_regexp->GetOriginalFlags().GetInt()); - JSHandle original_flags(thread, reg_exp::FlagsBitsToString(thread, flags_bits)); + JSHandle original_flags(thread_, reg_exp::FlagsBitsToString(thread_, flags_bits)); ASSERT_EQ(static_cast(original_source->GetTaggedObject())->Compare(*pattern), 0); ASSERT_EQ(static_cast(original_flags->GetTaggedObject())->Compare(*flags), 0); } @@ -104,34 +110,34 @@ TEST_F(BuiltinsRegExpTest, RegExpConstructor1) TEST_F(BuiltinsRegExpTest, RegExpConstructor2) { // invoke RegExpConstructor method - JSHandle pattern = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("\\w+"); - JSHandle flags = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("i"); - JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread, pattern, flags); - JSHandle value(thread, reinterpret_cast(result1.GetRawData())); + JSHandle pattern = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("\\w+"); + JSHandle flags = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("i"); + JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread_, pattern, flags); + JSHandle value(thread_, reinterpret_cast(result1.GetRawData())); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle regexp(env->GetRegExpFunction()); - JSHandle global_object(thread, env->GetGlobalObject()); + JSHandle global_object(thread_, env->GetGlobalObject()); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*regexp), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*regexp), 8); ecma_runtime_call_info->SetFunction(regexp.GetTaggedValue()); ecma_runtime_call_info->SetThis(global_object.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, value.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue::Undefined()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); // invoke RegExpConstructor method JSTaggedValue result2 = reg_exp::RegExpConstructor(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); // ASSERT IsRegExp() - JSHandle regexp_object(thread, result2); - ASSERT_TRUE(JSObject::IsRegExp(thread, regexp_object)); + JSHandle regexp_object(thread_, result2); + ASSERT_TRUE(JSObject::IsRegExp(thread_, regexp_object)); - JSHandle js_regexp(thread, JSRegExp::Cast(regexp_object->GetTaggedObject())); - JSHandle original_source(thread, js_regexp->GetOriginalSource()); + JSHandle js_regexp(thread_, JSRegExp::Cast(regexp_object->GetTaggedObject())); + JSHandle original_source(thread_, js_regexp->GetOriginalSource()); uint8_t flags_bits = static_cast(js_regexp->GetOriginalFlags().GetInt()); - JSHandle original_flags(thread, reg_exp::FlagsBitsToString(thread, flags_bits)); + JSHandle original_flags(thread_, reg_exp::FlagsBitsToString(thread_, flags_bits)); ASSERT_EQ(static_cast(original_source->GetTaggedObject())->Compare(*pattern), 0); ASSERT_EQ(static_cast(original_flags->GetTaggedObject())->Compare(*flags), 0); } @@ -139,34 +145,34 @@ TEST_F(BuiltinsRegExpTest, RegExpConstructor2) TEST_F(BuiltinsRegExpTest, RegExpConstructor3) { // invoke RegExpConstructor method - JSHandle pattern1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("\\w+"); - JSHandle flags1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("i"); - JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread, pattern1, flags1); - JSHandle value(thread, reinterpret_cast(result1.GetRawData())); + JSHandle pattern1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("\\w+"); + JSHandle flags1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("i"); + JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread_, pattern1, flags1); + JSHandle value(thread_, reinterpret_cast(result1.GetRawData())); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle regexp(env->GetRegExpFunction()); - JSHandle global_object(thread, env->GetGlobalObject()); - JSHandle flags2 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("gi"); + JSHandle global_object(thread_, env->GetGlobalObject()); + JSHandle flags2 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("gi"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue(*regexp), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue(*regexp), 8); ecma_runtime_call_info->SetFunction(regexp.GetTaggedValue()); ecma_runtime_call_info->SetThis(global_object.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, value.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, flags2.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); // invoke RegExpConstructor method JSTaggedValue result2 = reg_exp::RegExpConstructor(ecma_runtime_call_info.get()); // ASSERT IsRegExp() - JSHandle regexp_object(thread, result2); - ASSERT_TRUE(JSObject::IsRegExp(thread, regexp_object)); + JSHandle regexp_object(thread_, result2); + ASSERT_TRUE(JSObject::IsRegExp(thread_, regexp_object)); - JSHandle js_regexp(thread, JSRegExp::Cast(regexp_object->GetTaggedObject())); - JSHandle original_source(thread, js_regexp->GetOriginalSource()); + JSHandle js_regexp(thread_, JSRegExp::Cast(regexp_object->GetTaggedObject())); + JSHandle original_source(thread_, js_regexp->GetOriginalSource()); uint8_t flags_bits = static_cast(js_regexp->GetOriginalFlags().GetInt()); - JSHandle original_flags(thread, reg_exp::FlagsBitsToString(thread, flags_bits)); + JSHandle original_flags(thread_, reg_exp::FlagsBitsToString(thread_, flags_bits)); ASSERT_EQ(static_cast(original_source->GetTaggedObject())->Compare(*pattern1), 0); ASSERT_EQ(static_cast(original_flags->GetTaggedObject())->Compare(*flags2), 0); } @@ -174,104 +180,104 @@ TEST_F(BuiltinsRegExpTest, RegExpConstructor3) TEST_F(BuiltinsRegExpTest, GetSource1) { // invoke RegExpConstructor method - JSHandle pattern1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(""); - JSHandle flags1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("i"); - JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread, pattern1, flags1); - JSHandle result1_handle(thread, result1); + JSHandle pattern1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(""); + JSHandle flags1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("i"); + JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread_, pattern1, flags1); + JSHandle result1_handle(thread_, result1); // invoke GetSource method JSHandle source( - thread, thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("source").GetTaggedValue()); - JSHandle source_result(JSObject::GetProperty(thread, result1_handle, source).GetValue()); + thread_, thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("source").GetTaggedValue()); + JSHandle source_result(JSObject::GetProperty(thread_, result1_handle, source).GetValue()); - JSHandle expect = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("(?:)"); + JSHandle expect = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("(?:)"); ASSERT_EQ(static_cast(source_result->GetTaggedObject())->Compare(*expect), 0); } TEST_F(BuiltinsRegExpTest, GetSource2) { // invoke RegExpConstructor method - JSHandle pattern1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("/w+"); - JSHandle flags1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("i"); - JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread, pattern1, flags1); - JSHandle result1_handle(thread, result1); + JSHandle pattern1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("/w+"); + JSHandle flags1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("i"); + JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread_, pattern1, flags1); + JSHandle result1_handle(thread_, result1); // invoke GetSource method - JSHandle source(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("source")); - JSHandle source_result(JSObject::GetProperty(thread, result1_handle, source).GetValue()); + JSHandle source(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("source")); + JSHandle source_result(JSObject::GetProperty(thread_, result1_handle, source).GetValue()); - JSHandle expect = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("\\/w+"); + JSHandle expect = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("\\/w+"); ASSERT_EQ(static_cast(source_result->GetTaggedObject())->Compare(*expect), 0); } TEST_F(BuiltinsRegExpTest, Get) { // invoke RegExpConstructor method - JSHandle pattern1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("\\w+"); - JSHandle flags1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("gimuy"); - JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread, pattern1, flags1); - JSHandle result1_handle(thread, result1); + JSHandle pattern1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("\\w+"); + JSHandle flags1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("gimuy"); + JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread_, pattern1, flags1); + JSHandle result1_handle(thread_, result1); - JSHandle global(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("global")); + JSHandle global(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("global")); JSTaggedValue tagged_global_result = - JSTaggedValue(JSObject::GetProperty(thread, result1_handle, global).GetValue().GetTaggedValue()); + JSTaggedValue(JSObject::GetProperty(thread_, result1_handle, global).GetValue().GetTaggedValue()); ASSERT_EQ(tagged_global_result.GetRawData(), JSTaggedValue::True().GetRawData()); - JSHandle ignore_case(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("ignoreCase")); + JSHandle ignore_case(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("ignoreCase")); JSTaggedValue tagged_ignore_case_result = - JSTaggedValue(JSObject::GetProperty(thread, result1_handle, ignore_case).GetValue().GetTaggedValue()); + JSTaggedValue(JSObject::GetProperty(thread_, result1_handle, ignore_case).GetValue().GetTaggedValue()); ASSERT_EQ(tagged_ignore_case_result.GetRawData(), JSTaggedValue::True().GetRawData()); - JSHandle multiline(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("multiline")); + JSHandle multiline(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("multiline")); JSTaggedValue tagged_multiline_result = - JSTaggedValue(JSObject::GetProperty(thread, result1_handle, multiline).GetValue().GetTaggedValue()); + JSTaggedValue(JSObject::GetProperty(thread_, result1_handle, multiline).GetValue().GetTaggedValue()); ASSERT_EQ(tagged_multiline_result.GetRawData(), JSTaggedValue::True().GetRawData()); - JSHandle sticky(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("sticky")); + JSHandle sticky(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("sticky")); JSTaggedValue tagged_sticky_result = - JSTaggedValue(JSObject::GetProperty(thread, result1_handle, sticky).GetValue().GetTaggedValue()); + JSTaggedValue(JSObject::GetProperty(thread_, result1_handle, sticky).GetValue().GetTaggedValue()); ASSERT_EQ(tagged_sticky_result.GetRawData(), JSTaggedValue::True().GetRawData()); - JSHandle unicode(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("unicode")); + JSHandle unicode(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("unicode")); JSTaggedValue tagged_unicode_result = - JSTaggedValue(JSObject::GetProperty(thread, result1_handle, unicode).GetValue().GetTaggedValue()); + JSTaggedValue(JSObject::GetProperty(thread_, result1_handle, unicode).GetValue().GetTaggedValue()); ASSERT_EQ(tagged_unicode_result.GetRawData(), JSTaggedValue::True().GetRawData()); } TEST_F(BuiltinsRegExpTest, GetFlags) { // invoke RegExpConstructor method - JSHandle pattern1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("\\w+"); - JSHandle flags1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("imuyg"); - JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread, pattern1, flags1); - JSHandle result1_handle(thread, result1); + JSHandle pattern1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("\\w+"); + JSHandle flags1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("imuyg"); + JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread_, pattern1, flags1); + JSHandle result1_handle(thread_, result1); // invoke GetFlags method - JSHandle flags(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("flags")); - JSHandle flags_result(JSObject::GetProperty(thread, result1_handle, flags).GetValue()); + JSHandle flags(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("flags")); + JSHandle flags_result(JSObject::GetProperty(thread_, result1_handle, flags).GetValue()); - JSHandle expect_result = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("gimuy"); + JSHandle expect_result = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("gimuy"); ASSERT_EQ(static_cast(flags_result->GetTaggedObject())->Compare(*expect_result), 0); } TEST_F(BuiltinsRegExpTest, toString) { // invoke RegExpConstructor method - JSHandle pattern1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("\\w+"); - JSHandle flags1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("imuyg"); - JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread, pattern1, flags1); - JSHandle value(thread, reinterpret_cast(result1.GetRawData())); + JSHandle pattern1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("\\w+"); + JSHandle flags1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("imuyg"); + JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread_, pattern1, flags1); + JSHandle value(thread_, reinterpret_cast(result1.GetRawData())); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(value.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); // invoke ToString method JSTaggedValue to_string_result = reg_exp::proto::ToString(ecma_runtime_call_info.get()); ASSERT_TRUE(to_string_result.IsString()); - JSHandle to_string_result_handle(thread, to_string_result); - JSHandle expect_result = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("/\\w+/gimuy"); + JSHandle to_string_result_handle(thread_, to_string_result); + JSHandle expect_result = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("/\\w+/gimuy"); ASSERT_EQ(static_cast(to_string_result_handle->GetTaggedObject())->Compare(*expect_result), 0); } @@ -279,58 +285,58 @@ TEST_F(BuiltinsRegExpTest, Exec1) { // invoke RegExpConstructor method JSHandle pattern1 = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("quick\\s(brown).+?(jumps)"); - JSHandle flags1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("ig"); - JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread, pattern1, flags1); - JSHandle value(thread, reinterpret_cast(result1.GetRawData())); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("quick\\s(brown).+?(jumps)"); + JSHandle flags1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("ig"); + JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread_, pattern1, flags1); + JSHandle value(thread_, reinterpret_cast(result1.GetRawData())); JSHandle input_string = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("The Quick Brown Fox Jumps Over The Lazy Dog"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("The Quick Brown Fox Jumps Over The Lazy Dog"); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(value.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, input_string.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); // invoke Exec method JSTaggedValue results = reg_exp::proto::Exec(ecma_runtime_call_info.get()); - JSHandle exec_result(thread, results); + JSHandle exec_result(thread_, results); JSHandle result_zero = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Quick Brown Fox Jumps"); - JSHandle result_one = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Brown"); - JSHandle result_two = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Jumps"); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Quick Brown Fox Jumps"); + JSHandle result_one = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Brown"); + JSHandle result_two = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Jumps"); - JSHandle index(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("index")); - JSHandle index_handle(JSObject::GetProperty(thread, exec_result, index).GetValue()); - uint32_t result_index = JSTaggedValue::ToUint32(thread, index_handle); + JSHandle index(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("index")); + JSHandle index_handle(JSObject::GetProperty(thread_, exec_result, index).GetValue()); + uint32_t result_index = JSTaggedValue::ToUint32(thread_, index_handle); ASSERT_TRUE(result_index == 4U); - JSHandle input(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("input")); + JSHandle input(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("input")); - JSHandle input_handle(JSObject::GetProperty(thread, exec_result, input).GetValue()); - JSHandle output_input = JSTaggedValue::ToString(thread, input_handle); + JSHandle input_handle(JSObject::GetProperty(thread_, exec_result, input).GetValue()); + JSHandle output_input = JSTaggedValue::ToString(thread_, input_handle); ASSERT_EQ(output_input->Compare(*input_string), 0); - JSHandle zero(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0")); - JSHandle zero_handle(JSObject::GetProperty(thread, exec_result, zero).GetValue()); - JSHandle output_zero = JSTaggedValue::ToString(thread, zero_handle); + JSHandle zero(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0")); + JSHandle zero_handle(JSObject::GetProperty(thread_, exec_result, zero).GetValue()); + JSHandle output_zero = JSTaggedValue::ToString(thread_, zero_handle); ASSERT_EQ(output_zero->Compare(*result_zero), 0); - JSHandle first(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("1")); - JSHandle one_handle(JSObject::GetProperty(thread, exec_result, first).GetValue()); - JSHandle output_one = JSTaggedValue::ToString(thread, one_handle); + JSHandle first(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("1")); + JSHandle one_handle(JSObject::GetProperty(thread_, exec_result, first).GetValue()); + JSHandle output_one = JSTaggedValue::ToString(thread_, one_handle); ASSERT_EQ(output_one->Compare(*result_one), 0); - JSHandle second(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2")); - JSHandle two_handle(JSObject::GetProperty(thread, exec_result, second).GetValue()); - JSHandle output_two = JSTaggedValue::ToString(thread, two_handle); + JSHandle second(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2")); + JSHandle two_handle(JSObject::GetProperty(thread_, exec_result, second).GetValue()); + JSHandle output_two = JSTaggedValue::ToString(thread_, two_handle); ASSERT_EQ(output_two->Compare(*result_two), 0); JSHandle regexp = JSHandle::Cast(value); JSHandle last_index_handle( - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("lastIndex")); - JSHandle last_index_obj(JSObject::GetProperty(thread, regexp, last_index_handle).GetValue()); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("lastIndex")); + JSHandle last_index_obj(JSObject::GetProperty(thread_, regexp, last_index_handle).GetValue()); int last_index = last_index_obj->GetInt(); ASSERT_TRUE(last_index == 25); } @@ -339,76 +345,76 @@ TEST_F(BuiltinsRegExpTest, Exec2) { // invoke RegExpConstructor method JSHandle pattern1 = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("((1)|(12))((3)|(23))"); - JSHandle flags1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("ig"); - JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread, pattern1, flags1); - JSHandle value(thread, reinterpret_cast(result1.GetRawData())); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("((1)|(12))((3)|(23))"); + JSHandle flags1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("ig"); + JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread_, pattern1, flags1); + JSHandle value(thread_, reinterpret_cast(result1.GetRawData())); - JSHandle input_string = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("123"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle input_string = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("123"); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(value.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, input_string.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); // invoke Exec method JSTaggedValue results = reg_exp::proto::Exec(ecma_runtime_call_info.get()); - JSHandle exec_result(thread, results); - JSHandle result_zero = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("123"); - JSHandle result_one = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("1"); - JSHandle result_two = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("1"); - JSHandle result_four = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("23"); - JSHandle result_six = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("23"); + JSHandle exec_result(thread_, results); + JSHandle result_zero = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("123"); + JSHandle result_one = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("1"); + JSHandle result_two = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("1"); + JSHandle result_four = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("23"); + JSHandle result_six = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("23"); - JSHandle index(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("index")); - JSHandle index_handle(JSObject::GetProperty(thread, exec_result, index).GetValue()); - uint32_t result_index = JSTaggedValue::ToUint32(thread, index_handle); + JSHandle index(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("index")); + JSHandle index_handle(JSObject::GetProperty(thread_, exec_result, index).GetValue()); + uint32_t result_index = JSTaggedValue::ToUint32(thread_, index_handle); ASSERT_TRUE(result_index == 0U); - JSHandle input(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("input")); - JSHandle input_handle(JSObject::GetProperty(thread, exec_result, input).GetValue()); - JSHandle output_input = JSTaggedValue::ToString(thread, input_handle); + JSHandle input(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("input")); + JSHandle input_handle(JSObject::GetProperty(thread_, exec_result, input).GetValue()); + JSHandle output_input = JSTaggedValue::ToString(thread_, input_handle); ASSERT_EQ(output_input->Compare(*input_string), 0); - JSHandle zero(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0")); - JSHandle zero_handle(JSObject::GetProperty(thread, exec_result, zero).GetValue()); - JSHandle output_zero = JSTaggedValue::ToString(thread, zero_handle); + JSHandle zero(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0")); + JSHandle zero_handle(JSObject::GetProperty(thread_, exec_result, zero).GetValue()); + JSHandle output_zero = JSTaggedValue::ToString(thread_, zero_handle); ASSERT_EQ(output_zero->Compare(*result_zero), 0); - JSHandle first(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("1")); - JSHandle one_handle(JSObject::GetProperty(thread, exec_result, first).GetValue()); - JSHandle output_one = JSTaggedValue::ToString(thread, one_handle); + JSHandle first(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("1")); + JSHandle one_handle(JSObject::GetProperty(thread_, exec_result, first).GetValue()); + JSHandle output_one = JSTaggedValue::ToString(thread_, one_handle); ASSERT_EQ(output_one->Compare(*result_one), 0); - JSHandle second(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2")); - JSHandle two_handle(JSObject::GetProperty(thread, exec_result, second).GetValue()); - JSHandle output_two = JSTaggedValue::ToString(thread, two_handle); + JSHandle second(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2")); + JSHandle two_handle(JSObject::GetProperty(thread_, exec_result, second).GetValue()); + JSHandle output_two = JSTaggedValue::ToString(thread_, two_handle); ASSERT_EQ(output_two->Compare(*result_two), 0); JSHandle regexp = JSHandle::Cast(value); JSHandle last_index_handle( - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("lastIndex")); - JSHandle last_index_obj(JSObject::GetProperty(thread, regexp, last_index_handle).GetValue()); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("lastIndex")); + JSHandle last_index_obj(JSObject::GetProperty(thread_, regexp, last_index_handle).GetValue()); int last_index = last_index_obj->GetInt(); ASSERT_TRUE(last_index == 3); - JSHandle third(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("3")); - JSHandle third_handle(JSObject::GetProperty(thread, exec_result, third).GetValue()); + JSHandle third(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("3")); + JSHandle third_handle(JSObject::GetProperty(thread_, exec_result, third).GetValue()); ASSERT_TRUE(third_handle->IsUndefined()); - JSHandle four(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("4")); - JSHandle four_handle(JSObject::GetProperty(thread, exec_result, four).GetValue()); - JSHandle output_four = JSTaggedValue::ToString(thread, four_handle); + JSHandle four(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("4")); + JSHandle four_handle(JSObject::GetProperty(thread_, exec_result, four).GetValue()); + JSHandle output_four = JSTaggedValue::ToString(thread_, four_handle); ASSERT_EQ(output_four->Compare(*result_four), 0); - JSHandle five(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("5")); - JSHandle five_handle(JSObject::GetProperty(thread, exec_result, five).GetValue()); + JSHandle five(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("5")); + JSHandle five_handle(JSObject::GetProperty(thread_, exec_result, five).GetValue()); ASSERT_TRUE(five_handle->IsUndefined()); - JSHandle six(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("6")); - JSHandle six_handle(JSObject::GetProperty(thread, exec_result, six).GetValue()); - JSHandle output_six = JSTaggedValue::ToString(thread, six_handle); + JSHandle six(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("6")); + JSHandle six_handle(JSObject::GetProperty(thread_, exec_result, six).GetValue()); + JSHandle output_six = JSTaggedValue::ToString(thread_, six_handle); ASSERT_EQ(output_six->Compare(*result_six), 0); } @@ -416,28 +422,28 @@ TEST_F(BuiltinsRegExpTest, Match1) { // invoke RegExpConstructor method JSHandle pattern1 = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("quick\\s(brown).+?(jumps)"); - JSHandle flags1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("iug"); - JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread, pattern1, flags1); - JSHandle value(thread, reinterpret_cast(result1.GetRawData())); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("quick\\s(brown).+?(jumps)"); + JSHandle flags1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("iug"); + JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread_, pattern1, flags1); + JSHandle value(thread_, reinterpret_cast(result1.GetRawData())); JSHandle input_string = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("The Quick Brown Fox Jumps Over The Lazy Dog"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("The Quick Brown Fox Jumps Over The Lazy Dog"); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(value.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, input_string.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); // invoke Match method JSTaggedValue match_results = reg_exp::proto::Match(ecma_runtime_call_info.get()); - JSHandle match_result(thread, match_results); - JSHandle zero(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0")); + JSHandle match_result(thread_, match_results); + JSHandle zero(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0")); JSHandle result_zero = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Quick Brown Fox Jumps"); - JSHandle zero_handle(JSObject::GetProperty(thread, match_result, zero).GetValue()); - JSHandle output_zero = JSTaggedValue::ToString(thread, zero_handle); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("Quick Brown Fox Jumps"); + JSHandle zero_handle(JSObject::GetProperty(thread_, match_result, zero).GetValue()); + JSHandle output_zero = JSTaggedValue::ToString(thread_, zero_handle); ASSERT_EQ(output_zero->Compare(*result_zero), 0); } @@ -445,19 +451,19 @@ TEST_F(BuiltinsRegExpTest, Test1) { // invoke RegExpConstructor method JSHandle pattern1 = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("quick\\s(brown).+?(jumps)"); - JSHandle flags1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("iug"); - JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread, pattern1, flags1); - JSHandle value(thread, reinterpret_cast(result1.GetRawData())); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("quick\\s(brown).+?(jumps)"); + JSHandle flags1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("iug"); + JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread_, pattern1, flags1); + JSHandle value(thread_, reinterpret_cast(result1.GetRawData())); JSHandle input_string = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("The Quick Brown Fox Jumps Over The Lazy Dog"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("The Quick Brown Fox Jumps Over The Lazy Dog"); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(value.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, input_string.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); // invoke Test method JSTaggedValue test_result = reg_exp::proto::Test(ecma_runtime_call_info.get()); ASSERT_EQ(test_result.GetRawData(), JSTaggedValue::True().GetRawData()); @@ -467,19 +473,19 @@ TEST_F(BuiltinsRegExpTest, Search1) { // invoke RegExpConstructor method JSHandle pattern1 = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("quick\\s(brown).+?(jumps)"); - JSHandle flags1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("iug"); - JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread, pattern1, flags1); - JSHandle value(thread, reinterpret_cast(result1.GetRawData())); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("quick\\s(brown).+?(jumps)"); + JSHandle flags1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("iug"); + JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread_, pattern1, flags1); + JSHandle value(thread_, reinterpret_cast(result1.GetRawData())); JSHandle input_string = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("The Quick Brown Fox Jumps Over The Lazy Dog"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("The Quick Brown Fox Jumps Over The Lazy Dog"); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(value.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, input_string.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); // invoke Search method JSTaggedValue search_result = reg_exp::proto::Search(ecma_runtime_call_info.get()); ASSERT_EQ(search_result.GetRawData(), JSTaggedValue(4).GetRawData()); @@ -488,27 +494,27 @@ TEST_F(BuiltinsRegExpTest, Search1) TEST_F(BuiltinsRegExpTest, Split1) { // invoke RegExpConstructor method - JSHandle pattern1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("-"); - JSHandle flags1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("iug"); - JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread, pattern1, flags1); - JSHandle value(thread, reinterpret_cast(result1.GetRawData())); + JSHandle pattern1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("-"); + JSHandle flags1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("iug"); + JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread_, pattern1, flags1); + JSHandle value(thread_, reinterpret_cast(result1.GetRawData())); - JSHandle input_string = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(""); + JSHandle input_string = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(""); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(value.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, input_string.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue::Undefined()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); // invoke Split method JSTaggedValue split_results = reg_exp::proto::Split(ecma_runtime_call_info.get()); - JSHandle split_result(thread, split_results); + JSHandle split_result(thread_, split_results); - JSHandle zero(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0")); - JSHandle zero_handle(JSObject::GetProperty(thread, split_result, zero).GetValue()); - JSHandle output_zero = JSTaggedValue::ToString(thread, zero_handle); + JSHandle zero(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0")); + JSHandle zero_handle(JSObject::GetProperty(thread_, split_result, zero).GetValue()); + JSHandle output_zero = JSTaggedValue::ToString(thread_, zero_handle); ASSERT_EQ(output_zero->Compare(*input_string), 0); } @@ -516,54 +522,54 @@ TEST_F(BuiltinsRegExpTest, Split1) TEST_F(BuiltinsRegExpTest, Split2) { // invoke RegExpConstructor method - JSHandle pattern1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("-"); - JSHandle flags1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("iug"); - JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread, pattern1, flags1); - JSHandle value(thread, reinterpret_cast(result1.GetRawData())); + JSHandle pattern1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("-"); + JSHandle flags1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("iug"); + JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread_, pattern1, flags1); + JSHandle value(thread_, reinterpret_cast(result1.GetRawData())); - JSHandle input_string = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("a-b-c"); + JSHandle input_string = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("a-b-c"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(value.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, input_string.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue::Undefined()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); // invoke Split method JSTaggedValue split_results = reg_exp::proto::Split(ecma_runtime_call_info.get()); - JSHandle split_result(thread, split_results); - JSHandle result_zero = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("a"); - JSHandle result_one = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("b"); - JSHandle result_two = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("c"); - - JSHandle zero(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0")); - JSHandle zero_handle(JSObject::GetProperty(thread, split_result, zero).GetValue()); - JSHandle output_zero = JSTaggedValue::ToString(thread, zero_handle); + JSHandle split_result(thread_, split_results); + JSHandle result_zero = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("a"); + JSHandle result_one = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("b"); + JSHandle result_two = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("c"); + + JSHandle zero(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("0")); + JSHandle zero_handle(JSObject::GetProperty(thread_, split_result, zero).GetValue()); + JSHandle output_zero = JSTaggedValue::ToString(thread_, zero_handle); ASSERT_EQ(output_zero->Compare(*result_zero), 0); - JSHandle first(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("1")); - JSHandle one_handle(JSObject::GetProperty(thread, split_result, first).GetValue()); - JSHandle output_one = JSTaggedValue::ToString(thread, one_handle); + JSHandle first(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("1")); + JSHandle one_handle(JSObject::GetProperty(thread_, split_result, first).GetValue()); + JSHandle output_one = JSTaggedValue::ToString(thread_, one_handle); ASSERT_EQ(output_one->Compare(*result_one), 0); - JSHandle second(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2")); - JSHandle two_handle(JSObject::GetProperty(thread, split_result, second).GetValue()); - JSHandle output_two = JSTaggedValue::ToString(thread, two_handle); + JSHandle second(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("2")); + JSHandle two_handle(JSObject::GetProperty(thread_, split_result, second).GetValue()); + JSHandle output_two = JSTaggedValue::ToString(thread_, two_handle); ASSERT_EQ(output_two->Compare(*result_two), 0); } TEST_F(BuiltinsRegExpTest, GetSpecies) { // invoke RegExpConstructor method - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle species_symbol = env->GetSpeciesSymbol(); EXPECT_TRUE(!species_symbol.GetTaggedValue().IsUndefined()); JSHandle new_target(env->GetRegExpFunction()); JSTaggedValue value = - JSObject::GetProperty(thread, JSHandle(new_target), species_symbol).GetValue().GetTaggedValue(); + JSObject::GetProperty(thread_, JSHandle(new_target), species_symbol).GetValue().GetTaggedValue(); EXPECT_EQ(value, new_target.GetTaggedValue()); } @@ -571,26 +577,26 @@ TEST_F(BuiltinsRegExpTest, Replace1) { // invoke RegExpConstructor method JSHandle pattern1 = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("quick\\s(brown).+?(jumps)"); - JSHandle flags1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("iug"); - JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread, pattern1, flags1); - JSHandle value(thread, reinterpret_cast(result1.GetRawData())); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("quick\\s(brown).+?(jumps)"); + JSHandle flags1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("iug"); + JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread_, pattern1, flags1); + JSHandle value(thread_, reinterpret_cast(result1.GetRawData())); JSHandle input_string = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("The Quick Brown Fox Jumps Over The Lazy Dog"); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("The Quick Brown Fox Jumps Over The Lazy Dog"); JSHandle replace_string = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("$&a $` $\' $2 $01 $$1 $21 $32 a"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("$&a $` $\' $2 $01 $$1 $21 $32 a"); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(value.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, input_string.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, replace_string.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); // invoke replace method JSTaggedValue results = reg_exp::proto::Replace(ecma_runtime_call_info.get()); - JSHandle replace_result(thread, results); - JSHandle result_zero = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString( + JSHandle replace_result(thread_, results); + JSHandle result_zero = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString( "The Quick Brown Fox Jumpsa The Over The Lazy Dog Jumps Brown $1 Jumps1 $32 a Over The Lazy Dog"); ASSERT_EQ(static_cast(replace_result->GetTaggedObject())->Compare(*result_zero), 0); } @@ -598,24 +604,24 @@ TEST_F(BuiltinsRegExpTest, Replace1) TEST_F(BuiltinsRegExpTest, Replace2) { // invoke RegExpConstructor method - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle pattern1 = factory->NewFromCanBeCompressString("b(c)(z)?(.)"); JSHandle flags1 = factory->NewFromCanBeCompressString(""); - JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread, pattern1, flags1); - JSHandle value(thread, reinterpret_cast(result1.GetRawData())); + JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread_, pattern1, flags1); + JSHandle value(thread_, reinterpret_cast(result1.GetRawData())); JSHandle input_string = factory->NewFromCanBeCompressString("abcde"); JSHandle replace_string = factory->NewFromCanBeCompressString("[$01$02$03$04$00]"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(value.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, input_string.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, replace_string.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); // invoke replace method JSTaggedValue results = reg_exp::proto::Replace(ecma_runtime_call_info.get()); - JSHandle replace_result(thread, results); + JSHandle replace_result(thread_, results); JSHandle result_zero = factory->NewFromCanBeCompressString("a[cd$04$00]e"); ASSERT_EQ(static_cast(replace_result->GetTaggedObject())->Compare(*result_zero), 0); } @@ -623,32 +629,32 @@ TEST_F(BuiltinsRegExpTest, Replace2) TEST_F(BuiltinsRegExpTest, Replace3) { // invoke RegExpConstructor method - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle pattern1 = factory->NewFromCanBeCompressString("abc"); JSHandle flags1 = factory->NewFromCanBeCompressString("g"); - JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread, pattern1, flags1); - JSHandle value(thread, reinterpret_cast(result1.GetRawData())); + JSTaggedValue result1 = CreateBuiltinsRegExpObjByPatternAndFlags(thread_, pattern1, flags1); + JSHandle value(thread_, reinterpret_cast(result1.GetRawData())); JSHandle input_string = factory->NewFromCanBeCompressString("abcde"); JSHandle replace_string = factory->NewFromCanBeCompressString(""); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(value.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, input_string.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, replace_string.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); // invoke replace method JSTaggedValue results = reg_exp::proto::Replace(ecma_runtime_call_info.get()); - JSHandle replace_result(thread, results); + JSHandle replace_result(thread_, results); JSHandle result_zero = factory->NewFromCanBeCompressString("de"); ASSERT_EQ(static_cast(replace_result->GetTaggedObject())->Compare(*result_zero), 0); } TEST_F(BuiltinsRegExpTest, RegExpParseCache) { - RegExpParserCache *reg_exp_parser_cache = thread->GetEcmaVM()->GetRegExpParserCache(); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + RegExpParserCache *reg_exp_parser_cache = thread_->GetEcmaVM()->GetRegExpParserCache(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle string1 = factory->NewFromString("abc"); JSHandle string2 = factory->NewFromString("abcd"); PandaVector vec {}; diff --git a/tests/runtime/builtins/builtins_set_test.cpp b/tests/runtime/builtins/builtins_set_test.cpp index 843b9b17b8655f0f75296d31f37211b30a938a31..0439410da0966d8613f7a85550c432d9c10797e7 100644 --- a/tests/runtime/builtins/builtins_set_test.cpp +++ b/tests/runtime/builtins/builtins_set_test.cpp @@ -30,7 +30,9 @@ #include "plugins/ecmascript/tests/runtime/common/test_helper.h" #include "utils/bit_utils.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; namespace panda::test { @@ -50,18 +52,14 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; - class TestClass { public: static JSTaggedValue TestFunc(EcmaRuntimeCallInfo *argv) @@ -76,6 +74,14 @@ public: return JSTaggedValue::Undefined(); } }; + +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; JSSet *CreateBuiltinsSet(JSThread *thread) @@ -96,17 +102,17 @@ JSSet *CreateBuiltinsSet(JSThread *thread) // new Set("abrupt").toString() TEST_F(BuiltinsSetTest, CreateAndGetSize) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle new_target(env->GetSetFunction()); - JSHandle set(thread, CreateBuiltinsSet(thread)); + JSHandle set(thread_, CreateBuiltinsSet(thread_)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(set.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue::Undefined()); { - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = set::proto::GetSize(ecma_runtime_call_info.get()); EXPECT_EQ(result.GetRawData(), JSTaggedValue(0).GetRawData()); @@ -114,17 +120,17 @@ TEST_F(BuiltinsSetTest, CreateAndGetSize) JSHandle array(factory->NewTaggedArray(5)); for (int i = 0; i < 5; i++) { - array->Set(thread, i, JSTaggedValue(i)); + array->Set(thread_, i, JSTaggedValue(i)); } - JSHandle values = JSArray::CreateArrayFromList(thread, array); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle values = JSArray::CreateArrayFromList(thread_, array); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(new_target.GetTaggedValue()); ecma_runtime_call_info1->SetThis(set.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, values.GetTaggedValue()); ecma_runtime_call_info1->SetNewTarget(new_target.GetTaggedValue()); { - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result1 = set::SetConstructor(ecma_runtime_call_info1.get()); EXPECT_EQ(JSSet::Cast(reinterpret_cast(result1.GetRawData()))->GetSize(), 5); @@ -133,17 +139,17 @@ TEST_F(BuiltinsSetTest, CreateAndGetSize) TEST_F(BuiltinsSetTest, AddAndHas) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // create jsSet - JSHandle set(thread, CreateBuiltinsSet(thread)); - JSHandle key(thread, factory->NewFromCanBeCompressString("key").GetTaggedValue()); + JSHandle set(thread_, CreateBuiltinsSet(thread_)); + JSHandle key(thread_, factory->NewFromCanBeCompressString("key").GetTaggedValue()); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(set.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = set::proto::Has(ecma_runtime_call_info.get()); EXPECT_EQ(result1.GetRawData(), JSTaggedValue::False().GetRawData()); @@ -155,35 +161,35 @@ TEST_F(BuiltinsSetTest, AddAndHas) EXPECT_EQ(js_set->GetSize(), 1); // test Has() - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(JSTaggedValue(js_set)); ecma_runtime_call_info1->SetCallArg(0, key.GetTaggedValue()); { - [[maybe_unused]] auto prev_local = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev_local = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result3 = set::proto::Has(ecma_runtime_call_info1.get()); EXPECT_EQ(result3.GetRawData(), JSTaggedValue::True().GetRawData()); } // test -0.0 - JSHandle negative_zero(thread, JSTaggedValue(-0.0)); - JSHandle positive_zero(thread, JSTaggedValue(+0.0)); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle negative_zero(thread_, JSTaggedValue(-0.0)); + JSHandle positive_zero(thread_, JSTaggedValue(+0.0)); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(JSTaggedValue(js_set)); ecma_runtime_call_info2->SetCallArg(0, negative_zero.GetTaggedValue()); { - [[maybe_unused]] auto prev_local = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + [[maybe_unused]] auto prev_local = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); set::proto::Add(ecma_runtime_call_info.get()); } - auto ecma_runtime_call_info3 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info3 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info3->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info3->SetThis(JSTaggedValue(js_set)); ecma_runtime_call_info3->SetCallArg(0, positive_zero.GetTaggedValue()); { - [[maybe_unused]] auto prev_local = TestHelper::SetupFrame(thread, ecma_runtime_call_info3.get()); + [[maybe_unused]] auto prev_local = TestHelper::SetupFrame(thread_, ecma_runtime_call_info3.get()); JSTaggedValue result4 = set::proto::Has(ecma_runtime_call_info3.get()); EXPECT_EQ(result4.GetRawData(), JSTaggedValue::False().GetRawData()); @@ -193,18 +199,19 @@ TEST_F(BuiltinsSetTest, AddAndHas) TEST_F(BuiltinsSetTest, ForEach) { // generate a set has 5 entry{key1,key2,key3,key4,key5} - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle set(thread, CreateBuiltinsSet(thread)); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle set(thread_, CreateBuiltinsSet(thread_)); + // NOLINTNEXTLINE(modernize-avoid-c-arrays) char key_array[] = "key0"; for (int i = 0; i < 5; i++) { key_array[3] = '1' + i; JSHandle key(factory->NewFromCanBeCompressString(key_array)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(set.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = set::proto::Add(ecma_runtime_call_info.get()); EXPECT_TRUE(result1.IsECMAObject()); @@ -212,17 +219,17 @@ TEST_F(BuiltinsSetTest, ForEach) EXPECT_EQ(js_set->GetSize(), i + 1); } // test foreach; - JSHandle js_array(JSArray::ArrayCreate(thread, JSTaggedNumber(0))); + JSHandle js_array(JSArray::ArrayCreate(thread_, JSTaggedNumber(0))); JSHandle func = - factory->NewJSFunction(thread->GetEcmaVM()->GetGlobalEnv(), reinterpret_cast(TestClass::TestFunc)); + factory->NewJSFunction(thread_->GetEcmaVM()->GetGlobalEnv(), reinterpret_cast(TestClass::TestFunc)); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(set.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, func.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(1, js_array.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result2 = set::proto::ForEach(ecma_runtime_call_info1.get()); EXPECT_EQ(result2.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); @@ -231,22 +238,24 @@ TEST_F(BuiltinsSetTest, ForEach) TEST_F(BuiltinsSetTest, DeleteAndRemove) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // create jsSet - JSHandle set(thread, CreateBuiltinsSet(thread)); + JSHandle set(thread_, CreateBuiltinsSet(thread_)); // add 40 keys + // NOLINTNEXTLINE(modernize-avoid-c-arrays) char key_array[] = "key0"; + // NOLINTNEXTLINE(readability-magic-numbers) for (int i = 0; i < 40; i++) { key_array[3] = '1' + i; JSHandle key(factory->NewFromCanBeCompressString(key_array)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(set.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = set::proto::Add(ecma_runtime_call_info.get()); EXPECT_TRUE(result1.IsECMAObject()); @@ -257,12 +266,12 @@ TEST_F(BuiltinsSetTest, DeleteAndRemove) key_array[3] = '1' + 8; JSHandle delete_key(factory->NewFromCanBeCompressString(key_array)); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(set.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, delete_key.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result2 = set::proto::Has(ecma_runtime_call_info1.get()); EXPECT_EQ(result2.GetRawData(), JSTaggedValue::True().GetRawData()); @@ -289,73 +298,73 @@ TEST_F(BuiltinsSetTest, DeleteAndRemove) TEST_F(BuiltinsSetTest, Species) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); - JSHandle set(thread, CreateBuiltinsSet(thread)); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); + JSHandle set(thread_, CreateBuiltinsSet(thread_)); JSHandle species_symbol = env->GetSpeciesSymbol(); EXPECT_TRUE(!species_symbol->IsUndefined()); JSHandle new_target(env->GetSetFunction()); JSTaggedValue value = - JSObject::GetProperty(thread, JSHandle(new_target), species_symbol).GetValue().GetTaggedValue(); - JSHandle value_handle(thread, value); + JSObject::GetProperty(thread_, JSHandle(new_target), species_symbol).GetValue().GetTaggedValue(); + JSHandle value_handle(thread_, value); EXPECT_EQ(value, new_target.GetTaggedValue()); // to string tag JSHandle to_string_tag_symbol = env->GetToStringTagSymbol(); - JSHandle string_tag(JSObject::GetProperty(thread, set, to_string_tag_symbol).GetValue()); + JSHandle string_tag(JSObject::GetProperty(thread_, set, to_string_tag_symbol).GetValue()); JSHandle str = factory->NewFromCanBeCompressString("Set"); EXPECT_TRUE(!string_tag.GetTaggedValue().IsUndefined()); EXPECT_TRUE(EcmaString::StringsAreEqual(*str, *string_tag)); - JSHandle constructor = JSHandle::Cast(JSTaggedValue::ToObject(thread, value_handle)); - EXPECT_EQ(JSHandle(set)->GetPrototype(thread), constructor->GetFunctionPrototype()); + JSHandle constructor = JSHandle::Cast(JSTaggedValue::ToObject(thread_, value_handle)); + EXPECT_EQ(JSHandle(set)->GetPrototype(thread_), constructor->GetFunctionPrototype()); JSHandle key1(factory->NewFromCanBeCompressString("add")); - JSTaggedValue value1 = JSObject::GetProperty(thread, set, key1).GetValue().GetTaggedValue(); + JSTaggedValue value1 = JSObject::GetProperty(thread_, set, key1).GetValue().GetTaggedValue(); EXPECT_FALSE(value1.IsUndefined()); JSHandle key2(factory->NewFromCanBeCompressString("has")); - JSTaggedValue value2 = JSObject::GetProperty(thread, set, key1).GetValue().GetTaggedValue(); + JSTaggedValue value2 = JSObject::GetProperty(thread_, set, key1).GetValue().GetTaggedValue(); EXPECT_FALSE(value2.IsUndefined()); JSHandle key3(factory->NewFromCanBeCompressString("clear")); - JSTaggedValue value3 = JSObject::GetProperty(thread, set, key1).GetValue().GetTaggedValue(); + JSTaggedValue value3 = JSObject::GetProperty(thread_, set, key1).GetValue().GetTaggedValue(); EXPECT_FALSE(value3.IsUndefined()); JSHandle key4(factory->NewFromCanBeCompressString("size")); - JSTaggedValue value4 = JSObject::GetProperty(thread, set, key1).GetValue().GetTaggedValue(); + JSTaggedValue value4 = JSObject::GetProperty(thread_, set, key1).GetValue().GetTaggedValue(); EXPECT_FALSE(value4.IsUndefined()); JSHandle key5(factory->NewFromCanBeCompressString("delete")); - JSTaggedValue value5 = JSObject::GetProperty(thread, set, key1).GetValue().GetTaggedValue(); + JSTaggedValue value5 = JSObject::GetProperty(thread_, set, key1).GetValue().GetTaggedValue(); EXPECT_FALSE(value5.IsUndefined()); JSHandle key6(factory->NewFromCanBeCompressString("forEach")); - JSTaggedValue value6 = JSObject::GetProperty(thread, set, key1).GetValue().GetTaggedValue(); + JSTaggedValue value6 = JSObject::GetProperty(thread_, set, key1).GetValue().GetTaggedValue(); EXPECT_FALSE(value6.IsUndefined()); } TEST_F(BuiltinsSetTest, GetIterator) { - JSHandle set(thread, CreateBuiltinsSet(thread)); + JSHandle set(thread_, CreateBuiltinsSet(thread_)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(set.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); // test Values() JSTaggedValue result = set::proto::Values(ecma_runtime_call_info.get()); - JSHandle iter(thread, result); + JSHandle iter(thread_, result); EXPECT_TRUE(iter->IsJSSetIterator()); EXPECT_EQ(IterationKind::VALUE, IterationKind(iter->GetIterationKind().GetInt())); EXPECT_EQ(JSSet::Cast(set.GetTaggedValue().GetTaggedObject())->GetLinkedSet(), iter->GetIteratedSet()); // test entrys() JSTaggedValue result2 = set::proto::Entries(ecma_runtime_call_info.get()); - JSHandle iter2(thread, result2); + JSHandle iter2(thread_, result2); EXPECT_TRUE(iter2->IsJSSetIterator()); EXPECT_EQ(IterationKind::KEY_AND_VALUE, IterationKind(iter2->GetIterationKind().GetInt())); } diff --git a/tests/runtime/builtins/builtins_string_test.cpp b/tests/runtime/builtins/builtins_string_test.cpp index 3492a62b4e0d6b4f1cbf428159a82cb62ee39372..4c77592755156d52407ae75762d15cb7a641e967 100644 --- a/tests/runtime/builtins/builtins_string_test.cpp +++ b/tests/runtime/builtins/builtins_string_test.cpp @@ -27,9 +27,13 @@ #include "plugins/ecmascript/runtime/object_factory.h" #include "plugins/ecmascript/tests/runtime/common/test_helper.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; +// NOLINTBEGIN(readability-magic-numbers) + namespace panda::test { class BuiltinsStringTest : public testing::Test { public: @@ -45,17 +49,21 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; JSTaggedValue CreateRegExpObjByPatternAndFlags(JSThread *thread, const JSHandle &pattern, @@ -79,23 +87,23 @@ JSTaggedValue CreateRegExpObjByPatternAndFlags(JSThread *thread, const JSHandle< TEST_F(BuiltinsStringTest, StringConstructor1) { - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle string(env->GetStringFunction()); - JSHandle global_object(thread, env->GetGlobalObject()); + JSHandle global_object(thread_, env->GetGlobalObject()); JSHandle string2 = factory->NewFromCanBeCompressString("ABC"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, string.GetTaggedValue(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, string.GetTaggedValue(), 6); ecma_runtime_call_info->SetFunction(string.GetTaggedValue()); ecma_runtime_call_info->SetThis(global_object.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, string2.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::StringConstructor(ecma_runtime_call_info.get()); JSTaggedValue value(static_cast(result.GetRawData())); ASSERT_TRUE(value.IsECMAObject()); - JSHandle ref(thread, JSPrimitiveRef::Cast(value.GetTaggedObject())); + JSHandle ref(thread_, JSPrimitiveRef::Cast(value.GetTaggedObject())); JSTaggedValue test = factory->NewFromCanBeCompressString("ABC").GetTaggedValue(); ASSERT_EQ( EcmaString::Cast(ref->GetValue().GetTaggedObject())->Compare(reinterpret_cast(test.GetRawData())), @@ -105,23 +113,23 @@ TEST_F(BuiltinsStringTest, StringConstructor1) // String.fromCharCode(65, 66, 67) TEST_F(BuiltinsStringTest, fromCharCode1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); const double arg1 = 65; const double arg2 = 66; const double arg3 = 67; - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(arg1)); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(arg2)); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue(arg3)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::FromCharCode(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); JSTaggedValue value(static_cast(result.GetRawData())); - JSHandle value_handle(thread, JSTaggedValue(value.GetTaggedObject())); + JSHandle value_handle(thread_, JSTaggedValue(value.GetTaggedObject())); JSTaggedValue test = factory->NewFromCanBeCompressString("ABC").GetTaggedValue(); ASSERT_EQ( EcmaString::Cast(value_handle->GetTaggedObject())->Compare(reinterpret_cast(test.GetRawData())), @@ -131,22 +139,22 @@ TEST_F(BuiltinsStringTest, fromCharCode1) // String.fromCodePoint(65, 66, 67) TEST_F(BuiltinsStringTest, fromCodePoint1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); const double arg1 = 65; const double arg2 = 66; const double arg3 = 67; - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(arg1)); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(arg2)); ecma_runtime_call_info->SetCallArg(2, JSTaggedValue(arg3)); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::FromCodePoint(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromCanBeCompressString("ABC").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -154,18 +162,18 @@ TEST_F(BuiltinsStringTest, fromCodePoint1) // "abcabcabc".charAt(5) TEST_F(BuiltinsStringTest, charAt1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_val = factory->NewFromCanBeCompressString("abcabcabc"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_val.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(5))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::CharAt(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromCanBeCompressString("c").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -173,18 +181,18 @@ TEST_F(BuiltinsStringTest, charAt1) // "一二三四".charAt(2) TEST_F(BuiltinsStringTest, charAt2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_val = factory->NewFromString("一二三四"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_val.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(2))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::CharAt(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromString("三").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -192,18 +200,18 @@ TEST_F(BuiltinsStringTest, charAt2) // "abcabcabc".charAt(-1) TEST_F(BuiltinsStringTest, charAt3) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_val = factory->NewFromCanBeCompressString("abcabcabc"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_val.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(-1))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::CharAt(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->GetEmptyString().GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -211,15 +219,15 @@ TEST_F(BuiltinsStringTest, charAt3) // "ABC".charCodeAt(0) TEST_F(BuiltinsStringTest, charCodeAt1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_val = factory->NewFromCanBeCompressString("ABC"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_val.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(0))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::CharCodeAt(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(65).GetRawData()); @@ -228,15 +236,15 @@ TEST_F(BuiltinsStringTest, charCodeAt1) // "ABC".charCodeAt(-1) TEST_F(BuiltinsStringTest, charCodeAt2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_val = factory->NewFromCanBeCompressString("ABC"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_val.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(-1))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::CharCodeAt(ecma_runtime_call_info.get()); JSTaggedValue test = builtins_common::GetTaggedDouble(base::NAN_VALUE); @@ -246,15 +254,15 @@ TEST_F(BuiltinsStringTest, charCodeAt2) // "ABC".codePointAt(1) TEST_F(BuiltinsStringTest, codePointAt1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_val = factory->NewFromCanBeCompressString("ABC"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_val.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(1))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::CodePointAt(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(66).GetRawData()); @@ -263,23 +271,23 @@ TEST_F(BuiltinsStringTest, codePointAt1) // 'a'.concat('b', 'c', 'd') TEST_F(BuiltinsStringTest, concat1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("a"); JSHandle val1 = factory->NewFromCanBeCompressString("b"); JSHandle val2 = factory->NewFromCanBeCompressString("c"); JSHandle val3 = factory->NewFromCanBeCompressString("d"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val1.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, val2.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(2, val3.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::Concat(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromCanBeCompressString("abcd").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -287,16 +295,16 @@ TEST_F(BuiltinsStringTest, concat1) // "abcabcabc".indexof('b') TEST_F(BuiltinsStringTest, indexof1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("abcabcabc"); JSHandle val = factory->NewFromCanBeCompressString("b"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::IndexOf(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(1).GetRawData()); @@ -305,17 +313,17 @@ TEST_F(BuiltinsStringTest, indexof1) // "abcabcabc".indexof('b', 2) TEST_F(BuiltinsStringTest, indexof2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("abcabcabc"); JSHandle val = factory->NewFromCanBeCompressString("b"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(2))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::IndexOf(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(4).GetRawData()); @@ -324,16 +332,16 @@ TEST_F(BuiltinsStringTest, indexof2) // "abcabcabc".indexof('d') TEST_F(BuiltinsStringTest, indexof3) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("abcabcabc"); JSHandle val = factory->NewFromCanBeCompressString("d"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::IndexOf(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(-1).GetRawData()); @@ -342,16 +350,16 @@ TEST_F(BuiltinsStringTest, indexof3) // "abcabcabc".lastIndexOf('b') TEST_F(BuiltinsStringTest, lastIndexOf1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("abcabcabc"); JSHandle val = factory->NewFromCanBeCompressString("b"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::LastIndexOf(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(7).GetRawData()); @@ -359,17 +367,17 @@ TEST_F(BuiltinsStringTest, lastIndexOf1) // "abcabcabc".lastIndexOf('b', 2) TEST_F(BuiltinsStringTest, lastIndexOf2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("abcabcabc"); JSHandle val = factory->NewFromCanBeCompressString("b"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(2))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::LastIndexOf(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(1).GetRawData()); @@ -378,16 +386,16 @@ TEST_F(BuiltinsStringTest, lastIndexOf2) // "abcabcabc".lastIndexOf('d') TEST_F(BuiltinsStringTest, lastIndexOf3) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("abcabcabc"); JSHandle val = factory->NewFromCanBeCompressString("d"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::LastIndexOf(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(-1).GetRawData()); @@ -396,16 +404,16 @@ TEST_F(BuiltinsStringTest, lastIndexOf3) // "abcabcabc".includes('b') TEST_F(BuiltinsStringTest, Includes2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("abcabcabc"); JSHandle val = factory->NewFromCanBeCompressString("b"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::Includes(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); @@ -414,17 +422,17 @@ TEST_F(BuiltinsStringTest, Includes2) // "abccccccc".includes('b',2) TEST_F(BuiltinsStringTest, Includes3) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("abccccccc"); JSHandle val = factory->NewFromCanBeCompressString("b"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(2))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::Includes(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::False().GetRawData()); @@ -433,16 +441,16 @@ TEST_F(BuiltinsStringTest, Includes3) // "一二三四".includes('二') TEST_F(BuiltinsStringTest, Includes4) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromString("一二三四"); JSHandle val = factory->NewFromString("二"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::Includes(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); @@ -451,16 +459,16 @@ TEST_F(BuiltinsStringTest, Includes4) // "To be, or not to be, that is the question.".startsWith('To be') TEST_F(BuiltinsStringTest, startsWith1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("To be, or not to be, that is the question."); JSHandle val = factory->NewFromCanBeCompressString("To be"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::StartsWith(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); @@ -469,16 +477,16 @@ TEST_F(BuiltinsStringTest, startsWith1) // "To be, or not to be, that is the question.".startsWith('not to be') TEST_F(BuiltinsStringTest, startsWith2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("To be, or not to be, that is the question."); JSHandle val = factory->NewFromCanBeCompressString("not to be"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::StartsWith(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::False().GetRawData()); @@ -487,17 +495,17 @@ TEST_F(BuiltinsStringTest, startsWith2) // "To be, or not to be, that is the question.".startsWith('not to be', 10) TEST_F(BuiltinsStringTest, startsWith3) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("To be, or not to be, that is the question."); JSHandle val = factory->NewFromCanBeCompressString("not to be"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(10))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::StartsWith(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); @@ -506,16 +514,16 @@ TEST_F(BuiltinsStringTest, startsWith3) // "To be, or not to be, that is the question.".endsWith('question.') TEST_F(BuiltinsStringTest, endsWith1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("To be, or not to be, that is the question."); JSHandle val = factory->NewFromCanBeCompressString("question."); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::EndsWith(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); @@ -524,16 +532,16 @@ TEST_F(BuiltinsStringTest, endsWith1) // "To be, or not to be, that is the question.".endsWith('to be') TEST_F(BuiltinsStringTest, endsWith2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("To be, or not to be, that is the question."); JSHandle val = factory->NewFromCanBeCompressString("to be"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::EndsWith(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::False().GetRawData()); @@ -542,17 +550,17 @@ TEST_F(BuiltinsStringTest, endsWith2) // "To be, or not to be, that is the question.".endsWith('to be', 19) TEST_F(BuiltinsStringTest, endsWith3) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("To be, or not to be, that is the question."); JSHandle val = factory->NewFromCanBeCompressString("to be"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(19))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::EndsWith(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue::True().GetRawData()); @@ -561,18 +569,18 @@ TEST_F(BuiltinsStringTest, endsWith3) // "有ABC".toLocaleLowerCase() TEST_F(BuiltinsStringTest, toLocaleLowerCase2) { - ASSERT_NE(thread, nullptr); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ASSERT_NE(thread_, nullptr); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromString("有ABC"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::ToLocaleLowerCase(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromString("有abc").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -580,17 +588,17 @@ TEST_F(BuiltinsStringTest, toLocaleLowerCase2) // "ABC".toLowerCase() TEST_F(BuiltinsStringTest, toLowerCase1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("ABC"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::ToLowerCase(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSHandle test = factory->NewFromCanBeCompressString("abc"); ASSERT_TRUE(JSTaggedValue::SameValue(result_handle.GetTaggedValue(), test.GetTaggedValue())); } @@ -598,17 +606,17 @@ TEST_F(BuiltinsStringTest, toLowerCase1) // "abc".toUpperCase() TEST_F(BuiltinsStringTest, toUpperCase1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("abc"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::ToUpperCase(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromCanBeCompressString("ABC").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -616,16 +624,16 @@ TEST_F(BuiltinsStringTest, toUpperCase1) // "abc".localecompare('b') TEST_F(BuiltinsStringTest, localecompare1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("abc"); JSHandle val = factory->NewFromCanBeCompressString("b"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::LocaleCompare(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(-1).GetRawData()); @@ -634,16 +642,16 @@ TEST_F(BuiltinsStringTest, localecompare1) // "abc".localecompare('abc') TEST_F(BuiltinsStringTest, localecompare2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("abc"); JSHandle val = factory->NewFromCanBeCompressString("abc"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::LocaleCompare(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(0).GetRawData()); @@ -652,16 +660,16 @@ TEST_F(BuiltinsStringTest, localecompare2) // "abc".localecompare('aa') TEST_F(BuiltinsStringTest, localecompare3) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("abc"); JSHandle val = factory->NewFromCanBeCompressString("aa"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::LocaleCompare(ecma_runtime_call_info.get()); ASSERT_EQ(result.GetRawData(), JSTaggedValue(1).GetRawData()); @@ -670,20 +678,20 @@ TEST_F(BuiltinsStringTest, localecompare3) // "abc".normalize('NFC') TEST_F(BuiltinsStringTest, normalize1) { - ASSERT_NE(thread, nullptr); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ASSERT_NE(thread_, nullptr); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromString("abc"); JSHandle val = factory->NewFromString("NFC"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, val.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::Normalize(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromString("abc").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -691,20 +699,20 @@ TEST_F(BuiltinsStringTest, normalize1) // "hello".padEnd(10) TEST_F(BuiltinsStringTest, padEnd1) { - ASSERT_NE(thread, nullptr); + ASSERT_NE(thread_, nullptr); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromString("hello"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(10))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::PadEnd(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromString("hello ").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -712,22 +720,22 @@ TEST_F(BuiltinsStringTest, padEnd1) // "hello".padEnd(11, world) TEST_F(BuiltinsStringTest, padEnd2) { - ASSERT_NE(thread, nullptr); + ASSERT_NE(thread_, nullptr); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromString("hello"); JSHandle fill_string = factory->NewFromString("world"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(11))); ecma_runtime_call_info->SetCallArg(1, fill_string.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::PadEnd(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromString("helloworldw").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -735,20 +743,20 @@ TEST_F(BuiltinsStringTest, padEnd2) // "world".padStart(10) TEST_F(BuiltinsStringTest, padStart1) { - ASSERT_NE(thread, nullptr); + ASSERT_NE(thread_, nullptr); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromString("world"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(10))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::PadStart(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromString(" world").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -756,22 +764,22 @@ TEST_F(BuiltinsStringTest, padStart1) // "world".padStart(11, "hello") TEST_F(BuiltinsStringTest, padStart2) { - ASSERT_NE(thread, nullptr); + ASSERT_NE(thread_, nullptr); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromString("world"); JSHandle fill_string = factory->NewFromString("hello"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(11))); ecma_runtime_call_info->SetCallArg(1, fill_string.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::PadStart(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromString("hellohworld").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -779,18 +787,18 @@ TEST_F(BuiltinsStringTest, padStart2) // "abc".repeat(5) TEST_F(BuiltinsStringTest, repeat1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("abc"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(5))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::Repeat(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromCanBeCompressString("abcabcabcabcabc").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -798,19 +806,19 @@ TEST_F(BuiltinsStringTest, repeat1) // 'The morning is upon us.'.slice(4, -2) TEST_F(BuiltinsStringTest, slice1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("The morning is upon us."); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(4))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(-2))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::Slice(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromCanBeCompressString("morning is upon u").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -818,18 +826,18 @@ TEST_F(BuiltinsStringTest, slice1) // 'The morning is upon us.'.slice(12) TEST_F(BuiltinsStringTest, slice2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("The morning is upon us."); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(12))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::Slice(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromCanBeCompressString("is upon us.").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -837,19 +845,19 @@ TEST_F(BuiltinsStringTest, slice2) // 'Mozilla'.substring(3, -3) TEST_F(BuiltinsStringTest, substring1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("Mozilla"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(3))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(-3))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::Substring(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromCanBeCompressString("Moz").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -857,19 +865,19 @@ TEST_F(BuiltinsStringTest, substring1) // 'Mozilla'.substring(7, 4) TEST_F(BuiltinsStringTest, substring2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("Mozilla"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(static_cast(7))); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(4))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::Substring(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromCanBeCompressString("lla").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -877,40 +885,40 @@ TEST_F(BuiltinsStringTest, substring2) // " Hello world! ".trim() TEST_F(BuiltinsStringTest, trim1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString(" Hello world! "); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::Trim(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromCanBeCompressString("Hello world!").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } TEST_F(BuiltinsStringTest, trim2) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString(" Hello world! "); JSHandle string_object(env->GetStringFunction()); - JSHandle value(thread, JSTaggedValue(this_str.GetTaggedValue().GetTaggedObject())); + JSHandle value(thread_, JSTaggedValue(this_str.GetTaggedValue().GetTaggedObject())); JSHandle str = factory->NewJSPrimitiveRef(string_object, value); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::Trim(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromCanBeCompressString("Hello world!").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -918,19 +926,19 @@ TEST_F(BuiltinsStringTest, trim2) // " Hello world! ".trimEnd() TEST_F(BuiltinsStringTest, trimEnd1) { - ASSERT_NE(thread, nullptr); + ASSERT_NE(thread_, nullptr); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromString(" Hello world! "); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::TrimEnd(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromString(" Hello world!").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -938,24 +946,24 @@ TEST_F(BuiltinsStringTest, trimEnd1) // new String(" Hello world! ").trimEnd() TEST_F(BuiltinsStringTest, trimEnd2) { - ASSERT_NE(thread, nullptr); - auto ecma_vm = thread->GetEcmaVM(); + ASSERT_NE(thread_, nullptr); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromString(" Hello world! "); JSHandle string_object(env->GetStringFunction()); - JSHandle value(thread, JSTaggedValue(this_str.GetTaggedValue().GetHeapObject())); + JSHandle value(thread_, JSTaggedValue(this_str.GetTaggedValue().GetHeapObject())); JSHandle str = factory->NewJSPrimitiveRef(string_object, value); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::TrimEnd(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromString(" Hello world!").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -963,19 +971,19 @@ TEST_F(BuiltinsStringTest, trimEnd2) // " Hello world! ".trimStart() TEST_F(BuiltinsStringTest, trimStart1) { - ASSERT_NE(thread, nullptr); + ASSERT_NE(thread_, nullptr); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromString(" Hello world! "); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::TrimStart(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromString("Hello world! ").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -983,24 +991,24 @@ TEST_F(BuiltinsStringTest, trimStart1) // new String(" Hello world! ").trimStart() TEST_F(BuiltinsStringTest, trimStart2) { - ASSERT_NE(thread, nullptr); - auto ecma_vm = thread->GetEcmaVM(); + ASSERT_NE(thread_, nullptr); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromString(" Hello world! "); JSHandle string_object(env->GetStringFunction()); - JSHandle value(thread, JSTaggedValue(this_str.GetTaggedValue().GetHeapObject())); + JSHandle value(thread_, JSTaggedValue(this_str.GetTaggedValue().GetHeapObject())); JSHandle str = factory->NewJSPrimitiveRef(string_object, value); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::TrimStart(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); JSTaggedValue test = factory->NewFromString("Hello world! ").GetTaggedValue(); ASSERT_EQ(result_handle->Compare(reinterpret_cast(test.GetRawData())), 0); } @@ -1008,47 +1016,47 @@ TEST_F(BuiltinsStringTest, trimStart2) // new String("abcabcabc").toString(); TEST_F(BuiltinsStringTest, ToString) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("abcabcabc"); JSHandle string_object(env->GetStringFunction()); - JSHandle value(thread, JSTaggedValue(this_str.GetTaggedValue().GetTaggedObject())); + JSHandle value(thread_, JSTaggedValue(this_str.GetTaggedValue().GetTaggedObject())); JSHandle str = factory->NewJSPrimitiveRef(string_object, value); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::ToString(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); - JSTaggedValue test = JSTaggedValue(*this_str); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); + auto test = JSTaggedValue(*this_str); ASSERT_EQ(result.GetRawData(), test.GetRawData()); } TEST_F(BuiltinsStringTest, ValueOf) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("abcabcabc"); JSHandle string_object(env->GetStringFunction()); - JSHandle value(thread, JSTaggedValue(this_str.GetTaggedValue().GetTaggedObject())); + JSHandle value(thread_, JSTaggedValue(this_str.GetTaggedValue().GetTaggedObject())); JSHandle str = factory->NewJSPrimitiveRef(string_object, value); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::ValueOf(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); - JSTaggedValue test = JSTaggedValue(*this_str); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); + auto test = JSTaggedValue(*this_str); ASSERT_EQ(result.GetRawData(), test.GetRawData()); } @@ -1061,39 +1069,39 @@ static inline JSFunction *BuiltinsStringTestCreate(JSThread *thread) TEST_F(BuiltinsStringTest, Raw) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle foo(factory->NewFromCanBeCompressString("foo")); JSHandle bar(factory->NewFromCanBeCompressString("bar")); JSHandle baz(factory->NewFromCanBeCompressString("baz")); - JSHandle raw_array = JSHandle::Cast(JSArray::ArrayCreate(thread, JSTaggedNumber(0))); + JSHandle raw_array = JSHandle::Cast(JSArray::ArrayCreate(thread_, JSTaggedNumber(0))); JSHandle obj(raw_array); - JSHandle key0(thread, JSTaggedValue(0)); - PropertyDescriptor desc0(thread, foo); - JSArray::DefineOwnProperty(thread, obj, key0, desc0); - JSHandle key1(thread, JSTaggedValue(1)); - PropertyDescriptor desc1(thread, bar); - JSArray::DefineOwnProperty(thread, obj, key1, desc1); - JSHandle key2(thread, JSTaggedValue(2)); - PropertyDescriptor desc2(thread, baz); - JSArray::DefineOwnProperty(thread, obj, key2, desc2); - - JSHandle constructor(thread, BuiltinsStringTestCreate(thread)); + JSHandle key0(thread_, JSTaggedValue(0)); + PropertyDescriptor desc0(thread_, foo); + JSArray::DefineOwnProperty(thread_, obj, key0, desc0); + JSHandle key1(thread_, JSTaggedValue(1)); + PropertyDescriptor desc1(thread_, bar); + JSArray::DefineOwnProperty(thread_, obj, key1, desc1); + JSHandle key2(thread_, JSTaggedValue(2)); + PropertyDescriptor desc2(thread_, baz); + JSArray::DefineOwnProperty(thread_, obj, key2, desc2); + + JSHandle constructor(thread_, BuiltinsStringTestCreate(thread_)); JSHandle template_string( factory->NewJSObjectByConstructor(JSHandle(constructor), constructor)); JSHandle raw_key(factory->NewFromCanBeCompressString("raw")); - JSObject::SetProperty(thread, template_string, raw_key, raw_array); + JSObject::SetProperty(thread_, template_string, raw_key, raw_array); JSHandle test = factory->NewFromCanBeCompressString("foo5barJavaScriptbaz"); JSHandle javascript = factory->NewFromCanBeCompressString("JavaScript"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 10); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue(template_string.GetObject())); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(5))); ecma_runtime_call_info->SetCallArg(2, javascript.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::Raw(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); ASSERT_TRUE(EcmaString::StringsAreEqual(reinterpret_cast(result.GetRawData()), *test)); @@ -1101,21 +1109,21 @@ TEST_F(BuiltinsStringTest, Raw) TEST_F(BuiltinsStringTest, Replace) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("Twas the night before Xmas..."); JSHandle search_str = factory->NewFromCanBeCompressString("Xmas"); JSHandle replace_str = factory->NewFromCanBeCompressString("Christmas"); JSHandle expected = factory->NewFromCanBeCompressString("Twas the night before Christmas..."); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, search_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, replace_str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::Replace(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsString()); ASSERT_TRUE(EcmaString::StringsAreEqual(reinterpret_cast(result.GetRawData()), *expected)); @@ -1123,51 +1131,51 @@ TEST_F(BuiltinsStringTest, Replace) JSHandle replace_str1 = factory->NewFromCanBeCompressString("abc$$"); JSHandle expected1 = factory->NewFromCanBeCompressString("Twas the night before abc$..."); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, search_str.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(1, replace_str1.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result1 = string::proto::Replace(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - JSHandle result_string1(thread, result1); + JSHandle result_string1(thread_, result1); ASSERT_TRUE(result1.IsString()); ASSERT_TRUE(EcmaString::StringsAreEqual(*result_string1, *expected1)); JSHandle replace_str2 = factory->NewFromCanBeCompressString("abc$$dd"); JSHandle expected2 = factory->NewFromCanBeCompressString("Twas the night before abc$dd..."); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(0, search_str.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(1, replace_str2.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue result2 = string::proto::Replace(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - JSHandle result_string2(thread, result2); + JSHandle result_string2(thread_, result2); ASSERT_TRUE(result2.IsString()); ASSERT_TRUE(EcmaString::StringsAreEqual(*result_string2, *expected2)); JSHandle replace_str3 = factory->NewFromCanBeCompressString("abc$&dd"); JSHandle expected3 = factory->NewFromCanBeCompressString("Twas the night before abcXmasdd..."); - auto ecma_runtime_call_info3 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info3 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info3->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info3->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info3->SetCallArg(0, search_str.GetTaggedValue()); ecma_runtime_call_info3->SetCallArg(1, replace_str3.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info3.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info3.get()); JSTaggedValue result3 = string::proto::Replace(ecma_runtime_call_info3.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - JSHandle result_string3(thread, result3); + JSHandle result_string3(thread_, result3); ASSERT_TRUE(result3.IsString()); ASSERT_TRUE(EcmaString::StringsAreEqual(*result_string3, *expected3)); @@ -1175,38 +1183,38 @@ TEST_F(BuiltinsStringTest, Replace) JSHandle expected4 = factory->NewFromCanBeCompressString("Twas the night before abcTwas the night before dd..."); - auto ecma_runtime_call_info4 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info4 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info4->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info4->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info4->SetCallArg(0, search_str.GetTaggedValue()); ecma_runtime_call_info4->SetCallArg(1, replace_str4.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info4.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info4.get()); JSTaggedValue result4 = string::proto::Replace(ecma_runtime_call_info4.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - JSHandle result_string4(thread, result4); + JSHandle result_string4(thread_, result4); ASSERT_TRUE(result4.IsString()); ASSERT_TRUE(EcmaString::StringsAreEqual(*result_string4, *expected4)); } TEST_F(BuiltinsStringTest, Replace2) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("Twas the night before Xmas..."); JSHandle search_str = factory->NewFromCanBeCompressString("Xmas"); JSHandle replace_str = factory->NewFromCanBeCompressString("abc$\'dd"); JSHandle expected = factory->NewFromCanBeCompressString("Twas the night before abc...dd..."); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, search_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, replace_str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::Replace(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsString()); ASSERT_TRUE(EcmaString::StringsAreEqual(reinterpret_cast(result.GetRawData()), *expected)); @@ -1215,17 +1223,17 @@ TEST_F(BuiltinsStringTest, Replace2) JSHandle expected2 = factory->NewFromCanBeCompressString("Twas the night before abcTwas the night before dd...$ff..."); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(0, search_str.GetTaggedValue()); ecma_runtime_call_info2->SetCallArg(1, replace_str2.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue result2 = string::proto::Replace(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - JSHandle result_string2(thread, result2); + JSHandle result_string2(thread_, result2); ASSERT_TRUE(result2.IsString()); ASSERT_TRUE(EcmaString::StringsAreEqual(*result_string2, *expected2)); @@ -1233,17 +1241,17 @@ TEST_F(BuiltinsStringTest, Replace2) JSHandle expected3 = factory->NewFromCanBeCompressString("Twas the night before abcTwas the night before dd...$..."); - auto ecma_runtime_call_info3 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info3 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info3->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info3->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info3->SetCallArg(0, search_str.GetTaggedValue()); ecma_runtime_call_info3->SetCallArg(1, replace_str3.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info3.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info3.get()); JSTaggedValue result3 = string::proto::Replace(ecma_runtime_call_info3.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); - JSHandle result_string3(thread, result3); + JSHandle result_string3(thread_, result3); ASSERT_TRUE(result3.IsString()); ASSERT_TRUE(EcmaString::StringsAreEqual(*result_string3, *expected3)); @@ -1251,37 +1259,37 @@ TEST_F(BuiltinsStringTest, Replace2) JSHandle expected4 = factory->NewFromCanBeCompressString("Twas the night before abcTwas the night before dd$..."); - auto ecma_runtime_call_info4 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info4 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info4->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info4->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info4->SetCallArg(0, search_str.GetTaggedValue()); ecma_runtime_call_info4->SetCallArg(1, replace_str4.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info4.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info4.get()); JSTaggedValue result4 = string::proto::Replace(ecma_runtime_call_info4.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result4.IsString()); - JSHandle result_string4(thread, result4); + JSHandle result_string4(thread_, result4); ASSERT_TRUE(EcmaString::StringsAreEqual(*result_string4, *expected4)); } TEST_F(BuiltinsStringTest, Replace3) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("Twas the night before Xmas..."); JSHandle search_str = factory->NewFromCanBeCompressString("Xmas"); JSHandle replace_str = factory->NewFromCanBeCompressString("$&a $` $\' $2 $01 $$1 $21 $32 a"); JSHandle expected = factory->NewFromCanBeCompressString( "Twas the night before Xmasa Twas the night before ... $2 $01 $1 $21 $32 a..."); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, search_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, replace_str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::Replace(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); @@ -1292,26 +1300,26 @@ TEST_F(BuiltinsStringTest, Replace4) { // invoke RegExpConstructor method JSHandle pattern1 = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("quick\\s(brown).+?(jumps)"); - JSHandle flags1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("iug"); - JSTaggedValue result1 = CreateRegExpObjByPatternAndFlags(thread, pattern1, flags1); - JSHandle search_str(thread, reinterpret_cast(result1.GetRawData())); - JSHandle expected = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString( + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("quick\\s(brown).+?(jumps)"); + JSHandle flags1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("iug"); + JSTaggedValue result1 = CreateRegExpObjByPatternAndFlags(thread_, pattern1, flags1); + JSHandle search_str(thread_, reinterpret_cast(result1.GetRawData())); + JSHandle expected = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString( "The Quick Brown Fox Jumpsa The Over The Lazy Dog Jumps Brown $1 Jumps1 $32 a Over The Lazy Dog"); // make dyn_runtime_call_info2 JSHandle this_str = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("The Quick Brown Fox Jumps Over The Lazy Dog"); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("The Quick Brown Fox Jumps Over The Lazy Dog"); JSHandle replace_str = - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("$&a $` $\' $2 $01 $$1 $21 $32 a"); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("$&a $` $\' $2 $01 $$1 $21 $32 a"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, search_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, replace_str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::Replace(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); @@ -1320,20 +1328,20 @@ TEST_F(BuiltinsStringTest, Replace4) TEST_F(BuiltinsStringTest, ReplaceAll1) { - ASSERT_NE(thread, nullptr); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ASSERT_NE(thread_, nullptr); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromString("The Quick Brown Fox Jumps Over The Lazy Dog"); JSHandle search_str = factory->NewFromString("o"); JSHandle replace_str = factory->NewFromString("a"); JSHandle expected = factory->NewFromString("The Quick Brawn Fax Jumps Over The Lazy Dag"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, search_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, replace_str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::ReplaceAll(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); @@ -1342,20 +1350,20 @@ TEST_F(BuiltinsStringTest, ReplaceAll1) TEST_F(BuiltinsStringTest, ReplaceAll2) { - ASSERT_NE(thread, nullptr); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ASSERT_NE(thread_, nullptr); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromString("xxx"); JSHandle search_str = factory->NewFromString(""); JSHandle replace_str = factory->NewFromString("_"); JSHandle expected = factory->NewFromString("_x_x_x_"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, search_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, replace_str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::ReplaceAll(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); @@ -1364,20 +1372,20 @@ TEST_F(BuiltinsStringTest, ReplaceAll2) TEST_F(BuiltinsStringTest, ReplaceAll3) { - ASSERT_NE(thread, nullptr); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ASSERT_NE(thread_, nullptr); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromString("xxx"); JSHandle search_str = factory->NewFromString("x"); JSHandle replace_str = factory->NewFromString(""); JSHandle expected = factory->NewFromString(""); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, search_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, replace_str.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::ReplaceAll(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsString()); @@ -1387,33 +1395,33 @@ TEST_F(BuiltinsStringTest, ReplaceAll3) TEST_F(BuiltinsStringTest, Split) { // invoke RegExpConstructor method - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("Hello World. How are you doing?"); JSHandle separator_str = factory->NewFromCanBeCompressString(" "); - JSHandle limit(thread, JSTaggedValue(3)); + JSHandle limit(thread_, JSTaggedValue(3)); JSHandle expected1 = factory->NewFromCanBeCompressString("Hello"); JSHandle expected2 = factory->NewFromCanBeCompressString("World."); JSHandle expected3 = factory->NewFromCanBeCompressString("How"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, separator_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(3))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::Split(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsECMAObject()); - JSHandle result_array(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_array(thread_, reinterpret_cast(result.GetRawData())); ASSERT_TRUE(result_array->IsJSArray()); JSHandle result_obj(result_array); JSHandle string1( - JSObject::GetProperty(thread, result_obj, JSHandle(thread, JSTaggedValue(0))).GetValue()); + JSObject::GetProperty(thread_, result_obj, JSHandle(thread_, JSTaggedValue(0))).GetValue()); JSHandle string2( - JSObject::GetProperty(thread, result_obj, JSHandle(thread, JSTaggedValue(1))).GetValue()); + JSObject::GetProperty(thread_, result_obj, JSHandle(thread_, JSTaggedValue(1))).GetValue()); JSHandle string3( - JSObject::GetProperty(thread, result_obj, JSHandle(thread, JSTaggedValue(2))).GetValue()); + JSObject::GetProperty(thread_, result_obj, JSHandle(thread_, JSTaggedValue(2))).GetValue()); ASSERT_TRUE(EcmaString::StringsAreEqual(*string1, *expected1)); ASSERT_TRUE(EcmaString::StringsAreEqual(*string2, *expected2)); ASSERT_TRUE(EcmaString::StringsAreEqual(*string3, *expected3)); @@ -1422,39 +1430,41 @@ TEST_F(BuiltinsStringTest, Split) TEST_F(BuiltinsStringTest, Split2) { // invoke RegExpConstructor method - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle this_str = factory->NewFromCanBeCompressString("a-b-c"); JSHandle pattern1 = factory->NewFromCanBeCompressString("-"); JSHandle flags1 = factory->NewFromCanBeCompressString("iug"); - JSTaggedValue result1 = CreateRegExpObjByPatternAndFlags(thread, pattern1, flags1); - JSHandle separator_obj(thread, result1); + JSTaggedValue result1 = CreateRegExpObjByPatternAndFlags(thread_, pattern1, flags1); + JSHandle separator_obj(thread_, result1); - JSHandle limit(thread, JSTaggedValue(3)); + JSHandle limit(thread_, JSTaggedValue(3)); JSHandle expected1 = factory->NewFromCanBeCompressString("a"); JSHandle expected2 = factory->NewFromCanBeCompressString("b"); JSHandle expected3 = factory->NewFromCanBeCompressString("c"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(this_str.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, separator_obj.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(3))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = string::proto::Split(ecma_runtime_call_info.get()); ASSERT_TRUE(result.IsECMAObject()); - JSHandle result_array(thread, result); + JSHandle result_array(thread_, result); ASSERT_TRUE(result_array->IsJSArray()); JSHandle result_obj(result_array); JSHandle string1( - JSObject::GetProperty(thread, result_obj, JSHandle(thread, JSTaggedValue(0))).GetValue()); + JSObject::GetProperty(thread_, result_obj, JSHandle(thread_, JSTaggedValue(0))).GetValue()); JSHandle string2( - JSObject::GetProperty(thread, result_obj, JSHandle(thread, JSTaggedValue(1))).GetValue()); + JSObject::GetProperty(thread_, result_obj, JSHandle(thread_, JSTaggedValue(1))).GetValue()); JSHandle string3( - JSObject::GetProperty(thread, result_obj, JSHandle(thread, JSTaggedValue(2))).GetValue()); + JSObject::GetProperty(thread_, result_obj, JSHandle(thread_, JSTaggedValue(2))).GetValue()); ASSERT_TRUE(EcmaString::StringsAreEqual(*string1, *expected1)); ASSERT_TRUE(EcmaString::StringsAreEqual(*string2, *expected2)); ASSERT_TRUE(EcmaString::StringsAreEqual(*string3, *expected3)); } } // namespace panda::test + +// NOLINTEND(readability-magic-numbers) diff --git a/tests/runtime/builtins/builtins_symbol_test.cpp b/tests/runtime/builtins/builtins_symbol_test.cpp index 18b2c128dcc128c40fd315ca27642f14b081bf1d..298416746af0c2ecee47c6a8a8fbc2957da39ac4 100644 --- a/tests/runtime/builtins/builtins_symbol_test.cpp +++ b/tests/runtime/builtins/builtins_symbol_test.cpp @@ -30,7 +30,9 @@ #include "plugins/ecmascript/tests/runtime/common/test_helper.h" #include "utils/bit_utils.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; namespace panda::test { @@ -49,74 +51,78 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; // new Symbol.toString() TEST_F(BuiltinsSymbolTest, SymbolNoParameterToString) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle symbol = ecma_vm->GetFactory()->NewJSSymbol(); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(symbol.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = symbol::proto::ToString(ecma_runtime_call_info.get()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); ASSERT_TRUE(result.IsString()); - auto symbol_value = ecmascript::builtins_common::GetTaggedString(thread, "Symbol()"); + auto symbol_value = ecmascript::builtins_common::GetTaggedString(thread_, "Symbol()"); ASSERT_EQ(reinterpret_cast(symbol_value.GetRawData())->Compare(*result_handle), 0); } // new Symbol("aaa").toString() TEST_F(BuiltinsSymbolTest, SymbolWithParameterToString) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle symbol = ecma_vm->GetFactory()->NewPublicSymbolWithChar("aaa"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(symbol.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = symbol::proto::ToString(ecma_runtime_call_info.get()); - JSHandle result_handle(thread, reinterpret_cast(result.GetRawData())); + JSHandle result_handle(thread_, reinterpret_cast(result.GetRawData())); ASSERT_TRUE(result.IsString()); - auto symbol_value = ecmascript::builtins_common::GetTaggedString(thread, "Symbol(aaa)"); + auto symbol_value = ecmascript::builtins_common::GetTaggedString(thread_, "Symbol(aaa)"); ASSERT_EQ(reinterpret_cast(symbol_value.GetRawData())->Compare(*result_handle), 0); } // new Symbol().valueOf() TEST_F(BuiltinsSymbolTest, SymbolNoParameterValueOf) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle symbol = ecma_vm->GetFactory()->NewJSSymbol(); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(symbol.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = symbol::proto::ValueOf(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(result.IsSymbol()); ASSERT_EQ(result.GetRawData() == (JSTaggedValue(*symbol)).GetRawData(), true); @@ -124,13 +130,13 @@ TEST_F(BuiltinsSymbolTest, SymbolNoParameterValueOf) JSHandle symbol_value(symbol); JSHandle symbol_ref = ecma_vm->GetFactory()->NewJSPrimitiveRef(symbol_object, symbol_value); - auto other_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto other_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); other_ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); other_ecma_runtime_call_info->SetThis(symbol_ref.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, other_ecma_runtime_call_info.get()); + prev = TestHelper::SetupFrame(thread_, other_ecma_runtime_call_info.get()); JSTaggedValue other_result = symbol::proto::ValueOf(other_ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(other_result.IsSymbol()); ASSERT_EQ(other_result.GetRawData() == (JSTaggedValue(*symbol)).GetRawData(), true); } @@ -138,18 +144,18 @@ TEST_F(BuiltinsSymbolTest, SymbolNoParameterValueOf) // new Symbol("bbb").valueOf() TEST_F(BuiltinsSymbolTest, SymbolWithParameterValueOf) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle symbol = ecma_vm->GetFactory()->NewPublicSymbolWithChar("bbb"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(symbol.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = symbol::proto::ValueOf(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(result.IsSymbol()); ASSERT_EQ(result.GetRawData() == (JSTaggedValue(*symbol)).GetRawData(), true); @@ -157,13 +163,13 @@ TEST_F(BuiltinsSymbolTest, SymbolWithParameterValueOf) JSHandle symbol_value(symbol); JSHandle symbol_ref = ecma_vm->GetFactory()->NewJSPrimitiveRef(symbol_object, symbol_value); - auto other_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto other_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); other_ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); other_ecma_runtime_call_info->SetThis(symbol_ref.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, other_ecma_runtime_call_info.get()); + prev = TestHelper::SetupFrame(thread_, other_ecma_runtime_call_info.get()); JSTaggedValue other_result = symbol::proto::ValueOf(other_ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(other_result.IsSymbol()); ASSERT_EQ(other_result.GetRawData() == (JSTaggedValue(*symbol)).GetRawData(), true); } @@ -171,7 +177,7 @@ TEST_F(BuiltinsSymbolTest, SymbolWithParameterValueOf) // new Symbol().for TEST_F(BuiltinsSymbolTest, SymbolWithParameterFor) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle table_handle(env->GetRegisterSymbols()); @@ -179,19 +185,19 @@ TEST_F(BuiltinsSymbolTest, SymbolWithParameterFor) JSHandle string = ecma_vm->GetFactory()->NewFromCanBeCompressString("ccc"); ASSERT_EQ(string->GetLength(), 3); JSHandle string_handle(string); - ASSERT_EQ(table_handle->ContainsKey(thread, string_handle.GetTaggedValue()), false); + ASSERT_EQ(table_handle->ContainsKey(thread_, string_handle.GetTaggedValue()), false); JSHandle symbol = ecma_vm->GetFactory()->NewSymbolWithTableWithChar("ccc"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, string.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = symbol::For(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); - ASSERT_EQ(table_handle->ContainsKey(thread, string_handle.GetTaggedValue()), true); + TestHelper::TearDownFrame(thread_, prev); + ASSERT_EQ(table_handle->ContainsKey(thread_, string_handle.GetTaggedValue()), true); JSTaggedValue target(*symbol); ASSERT_EQ(result.GetRawData() == target.GetRawData(), true); @@ -200,63 +206,63 @@ TEST_F(BuiltinsSymbolTest, SymbolWithParameterFor) // Symbol.keyFor (sym) TEST_F(BuiltinsSymbolTest, SymbolKeyFor) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle symbol = ecma_vm->GetFactory()->NewPublicSymbolWithChar("bbb"); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, symbol.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = symbol::KeyFor(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_EQ(result.GetRawData(), JSTaggedValue::VALUE_UNDEFINED); JSHandle string = ecma_vm->GetFactory()->NewFromCanBeCompressString("ccc"); ASSERT_EQ(string->GetLength(), 3); - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetCallArg(0, string.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); symbol::For(ecma_runtime_call_info1.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); JSHandle other_symbol = ecma_vm->GetFactory()->NewPublicSymbolWithChar("ccc"); - auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info2 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info2->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info2->SetCallArg(0, other_symbol.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info2.get()); + prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info2.get()); JSTaggedValue other_result = symbol::KeyFor(ecma_runtime_call_info2.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(other_result.IsString()); JSHandle table_handle(env->GetRegisterSymbols()); JSTaggedValue string_value(*string); - ASSERT_EQ(table_handle->ContainsKey(thread, string_value), true); + ASSERT_EQ(table_handle->ContainsKey(thread_, string_value), true); } // Symbol.ToPrimitive() TEST_F(BuiltinsSymbolTest, SymbolToPrimitive) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle symbol = ecma_vm->GetFactory()->NewJSSymbol(); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(symbol.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = symbol::proto::ToPrimitive(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(result.IsSymbol()); ASSERT_EQ(result.GetRawData() == (JSTaggedValue(*symbol)).GetRawData(), true); @@ -264,13 +270,13 @@ TEST_F(BuiltinsSymbolTest, SymbolToPrimitive) JSHandle symbol_value(symbol); JSHandle symbol_ref = ecma_vm->GetFactory()->NewJSPrimitiveRef(symbol_object, symbol_value); - auto other_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto other_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); other_ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); other_ecma_runtime_call_info->SetThis(symbol_ref.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, other_ecma_runtime_call_info.get()); + prev = TestHelper::SetupFrame(thread_, other_ecma_runtime_call_info.get()); JSTaggedValue other_result = symbol::proto::ToPrimitive(other_ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(other_result.IsSymbol()); ASSERT_EQ(other_result.GetRawData() == (JSTaggedValue(*symbol)).GetRawData(), true); } @@ -278,51 +284,52 @@ TEST_F(BuiltinsSymbolTest, SymbolToPrimitive) // constructor TEST_F(BuiltinsSymbolTest, SymbolConstructor) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetCallArg(0, JSTaggedValue::Undefined()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = symbol::SymbolConstructor(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); EXPECT_TRUE(result.IsSymbol()); - JSSymbol *sym = reinterpret_cast(result.GetRawData()); + auto *sym = reinterpret_cast(result.GetRawData()); ASSERT_EQ(sym->GetDescription().IsUndefined(), true); JSHandle string = ecma_vm->GetFactory()->NewFromCanBeCompressString("ddd"); - auto other_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto other_ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); other_ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); other_ecma_runtime_call_info->SetThis(JSTaggedValue::Undefined()); other_ecma_runtime_call_info->SetCallArg(0, string.GetTaggedValue()); - prev = TestHelper::SetupFrame(thread, other_ecma_runtime_call_info.get()); + prev = TestHelper::SetupFrame(thread_, other_ecma_runtime_call_info.get()); JSTaggedValue result1 = symbol::SymbolConstructor(other_ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); JSHandle result_string = JSTaggedValue::ToString( - thread, JSHandle(thread, reinterpret_cast(result1.GetRawData())->GetDescription())); + thread_, + JSHandle(thread_, reinterpret_cast(result1.GetRawData())->GetDescription())); ASSERT_EQ(result_string->Compare(*string), 0); } TEST_F(BuiltinsSymbolTest, SymbolGetter) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle symbol = ecma_vm->GetFactory()->NewPublicSymbolWithChar(""); JSHandle string = ecma_vm->GetFactory()->NewFromCanBeCompressString(""); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 4); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(symbol.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result = symbol::proto::GetDescription(ecma_runtime_call_info.get()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); ASSERT_TRUE(result.IsString()); - EcmaString *res_string = reinterpret_cast(result.GetRawData()); + auto *res_string = reinterpret_cast(result.GetRawData()); ASSERT_EQ(res_string->GetLength(), 0); ASSERT_EQ(EcmaString::StringsAreEqual(res_string, *string), true); } diff --git a/tests/runtime/builtins/builtins_typedarray_test.cpp b/tests/runtime/builtins/builtins_typedarray_test.cpp index 1df3b91c1883ddd57f4814a7caf0995c2a6c5ebb..3e9ffdf926db5b648f159f43636a6f2681466938 100644 --- a/tests/runtime/builtins/builtins_typedarray_test.cpp +++ b/tests/runtime/builtins/builtins_typedarray_test.cpp @@ -36,9 +36,12 @@ #include "plugins/ecmascript/tests/runtime/common/test_helper.h" #include "utils/bit_utils.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; -using namespace panda::ecmascript::base; + +// NOLINTBEGIN(readability-magic-numbers) namespace panda::test { @@ -65,8 +68,7 @@ public: } protected: - PandaVM *instance_ {nullptr}; - EcmaHandleScope *scope_ {nullptr}; + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) JSThread *thread_ {nullptr}; class TestClass { @@ -166,9 +168,13 @@ protected: return builtins_common::GetTaggedBoolean(false); } }; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; -JSTaggedValue CreateBuiltinsJSObject(JSThread *thread, const PandaString key_c_str) +JSTaggedValue CreateBuiltinsJSObject(JSThread *thread, const PandaString &key_c_str) { auto ecma_vm = thread->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); @@ -358,3 +364,5 @@ TEST_F(BuiltinsTypedArrayTest, Includes5) ASSERT_EQ(result.GetRawData(), JSTaggedValue(false).GetRawData()); } } // namespace panda::test + +// NOLINTEND(readability-magic-numbers) diff --git a/tests/runtime/builtins/builtins_weak_map_test.cpp b/tests/runtime/builtins/builtins_weak_map_test.cpp index 203f1078f397f793173ffec8fcd33352edf91fc5..f3008cc3fbd5d6b3799e4f753a5ec52b598d5af8 100644 --- a/tests/runtime/builtins/builtins_weak_map_test.cpp +++ b/tests/runtime/builtins/builtins_weak_map_test.cpp @@ -31,7 +31,9 @@ #include "plugins/ecmascript/tests/runtime/common/test_helper.h" #include "utils/bit_utils.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; namespace panda::test { @@ -51,17 +53,21 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; static JSObject *JSObjectTestCreate(JSThread *thread) @@ -93,48 +99,48 @@ JSWeakMap *CreateBuiltinsWeakMap(JSThread *thread) // new Map("abrupt").toString() TEST_F(BuiltinsWeakMapTest, CreateAndGetSize) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle new_target(env->GetWeakMapFunction()); - JSHandle map(thread, CreateBuiltinsWeakMap(thread)); + JSHandle map(thread_, CreateBuiltinsWeakMap(thread_)); JSHandle array(factory->NewTaggedArray(1)); JSHandle internal_array(factory->NewTaggedArray(2)); - JSTaggedValue value(JSObjectTestCreate(thread)); - internal_array->Set(thread, 0, value); - internal_array->Set(thread, 1, JSTaggedValue(0)); - auto result = JSArray::CreateArrayFromList(thread, internal_array); - array->Set(thread, 0, result); + JSTaggedValue value(JSObjectTestCreate(thread_)); + internal_array->Set(thread_, 0, value); + internal_array->Set(thread_, 1, JSTaggedValue(0)); + auto result = JSArray::CreateArrayFromList(thread_, internal_array); + array->Set(thread_, 0, result); - JSHandle values = JSArray::CreateArrayFromList(thread, array); + JSHandle values = JSArray::CreateArrayFromList(thread_, array); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(new_target.GetTaggedValue()); ecma_runtime_call_info->SetThis(map.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, values.GetTaggedValue()); ecma_runtime_call_info->SetNewTarget(new_target.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = weak_map::WeakMapConstructor(ecma_runtime_call_info.get()); - JSHandle weak_map(thread, JSWeakMap::Cast(reinterpret_cast(result1.GetRawData()))); + JSHandle weak_map(thread_, JSWeakMap::Cast(reinterpret_cast(result1.GetRawData()))); EXPECT_EQ(weak_map->GetSize(), 1); } TEST_F(BuiltinsWeakMapTest, SetAndHas) { // create jsWeakMap - JSHandle weak_map(thread, CreateBuiltinsWeakMap(thread)); - JSHandle key(thread, JSObjectTestCreate(thread)); + JSHandle weak_map(thread_, CreateBuiltinsWeakMap(thread_)); + JSHandle key(thread_, JSObjectTestCreate(thread_)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(weak_map.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(1))); { - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = weak_map::proto::Has(ecma_runtime_call_info.get()); EXPECT_EQ(result1.GetRawData(), JSTaggedValue::False().GetRawData()); @@ -147,13 +153,13 @@ TEST_F(BuiltinsWeakMapTest, SetAndHas) EXPECT_EQ(js_weak_map->GetSize(), 1); // test Has() - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetCallArg(0, key.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(1, JSTaggedValue(static_cast(1))); ecma_runtime_call_info1->SetThis(JSTaggedValue(js_weak_map)); { - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result3 = weak_map::proto::Has(ecma_runtime_call_info1.get()); EXPECT_EQ(result3.GetRawData(), JSTaggedValue::True().GetRawData()); @@ -163,19 +169,20 @@ TEST_F(BuiltinsWeakMapTest, SetAndHas) TEST_F(BuiltinsWeakMapTest, DeleteAndRemove) { // create jsWeakMap - JSHandle weak_map(thread, CreateBuiltinsWeakMap(thread)); + JSHandle weak_map(thread_, CreateBuiltinsWeakMap(thread_)); // add 40 keys JSTaggedValue last_key(JSTaggedValue::Undefined()); + // NOLINTNEXTLINE(readability-magic-numbers) for (int i = 0; i < 40; i++) { - JSHandle key(thread, JSObjectTestCreate(thread)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); + JSHandle key(thread_, JSObjectTestCreate(thread_)); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 8); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(weak_map.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(1, JSTaggedValue(static_cast(i))); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = weak_map::proto::Set(ecma_runtime_call_info.get()); EXPECT_TRUE(result1.IsECMAObject()); @@ -186,12 +193,12 @@ TEST_F(BuiltinsWeakMapTest, DeleteAndRemove) // whether jsWeakMap has delete lastKey - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(weak_map.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, last_key); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result2 = weak_map::proto::Has(ecma_runtime_call_info1.get()); EXPECT_EQ(result2.GetRawData(), JSTaggedValue::True().GetRawData()); diff --git a/tests/runtime/builtins/builtins_weak_set_test.cpp b/tests/runtime/builtins/builtins_weak_set_test.cpp index 0f4d50e2a34602c73c3f570272c29298ec42a297..559cdf554b4a5b0912b786b5d1bae38f5deb049c 100644 --- a/tests/runtime/builtins/builtins_weak_set_test.cpp +++ b/tests/runtime/builtins/builtins_weak_set_test.cpp @@ -31,7 +31,9 @@ #include "plugins/ecmascript/tests/runtime/common/test_helper.h" #include "utils/bit_utils.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript::builtins; namespace panda::test { @@ -51,17 +53,21 @@ public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; - JSThread *thread {nullptr}; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {nullptr}; + +private: + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; static JSObject *JSObjectTestCreate(JSThread *thread) @@ -94,28 +100,28 @@ JSWeakSet *CreateBuiltinsWeakSet(JSThread *thread) TEST_F(BuiltinsWeakSetTest, CreateAndGetSize) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle new_target(env->GetWeakSetFunction()); - JSHandle weak_set(thread, CreateBuiltinsWeakSet(thread)); + JSHandle weak_set(thread_, CreateBuiltinsWeakSet(thread_)); JSHandle array(factory->NewTaggedArray(5)); for (int i = 0; i < 5; i++) { - JSHandle key(thread, JSObjectTestCreate(thread)); - array->Set(thread, i, key.GetTaggedValue()); + JSHandle key(thread_, JSObjectTestCreate(thread_)); + array->Set(thread_, i, key.GetTaggedValue()); } - JSHandle values = JSArray::CreateArrayFromList(thread, array); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle values = JSArray::CreateArrayFromList(thread_, array); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(new_target.GetTaggedValue()); ecma_runtime_call_info->SetThis(weak_set.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, values.GetTaggedValue()); ecma_runtime_call_info->SetNewTarget(new_target.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = weak_set::WeakSetConstructor(ecma_runtime_call_info.get()); - JSHandle weak_set_result(thread, + JSHandle weak_set_result(thread_, JSWeakSet::Cast(reinterpret_cast(result1.GetRawData()))); EXPECT_EQ(weak_set_result->GetSize(), 5); } @@ -123,16 +129,16 @@ TEST_F(BuiltinsWeakSetTest, CreateAndGetSize) TEST_F(BuiltinsWeakSetTest, AddAndHas) { // create jsWeakSet - JSHandle weak_set(thread, CreateBuiltinsWeakSet(thread)); - JSHandle key(thread, JSObjectTestCreate(thread)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + JSHandle weak_set(thread_, CreateBuiltinsWeakSet(thread_)); + JSHandle key(thread_, JSObjectTestCreate(thread_)); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(weak_set.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); JSWeakSet *js_weak_set; { - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = weak_set::proto::Has(ecma_runtime_call_info.get()); EXPECT_EQ(result1.GetRawData(), JSTaggedValue::False().GetRawData()); @@ -145,12 +151,12 @@ TEST_F(BuiltinsWeakSetTest, AddAndHas) } // test Has() - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(JSTaggedValue(js_weak_set)); ecma_runtime_call_info1->SetCallArg(0, key.GetTaggedValue()); { - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result3 = weak_set::proto::Has(ecma_runtime_call_info1.get()); EXPECT_EQ(result3.GetRawData(), JSTaggedValue::True().GetRawData()); @@ -160,19 +166,20 @@ TEST_F(BuiltinsWeakSetTest, AddAndHas) TEST_F(BuiltinsWeakSetTest, DeleteAndRemove) { // create jsSet - JSHandle weak_set(thread, CreateBuiltinsWeakSet(thread)); + JSHandle weak_set(thread_, CreateBuiltinsWeakSet(thread_)); // add 40 keys JSTaggedValue last_key(JSTaggedValue::Undefined()); + // NOLINTNEXTLINE(readability-magic-numbers) for (int i = 0; i < 40; i++) { - JSHandle key(thread, JSObjectTestCreate(thread)); + JSHandle key(thread_, JSObjectTestCreate(thread_)); - auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info->SetThis(weak_set.GetTaggedValue()); ecma_runtime_call_info->SetCallArg(0, key.GetTaggedValue()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); JSTaggedValue result1 = weak_set::proto::Add(ecma_runtime_call_info.get()); EXPECT_TRUE(result1.IsECMAObject()); @@ -182,12 +189,12 @@ TEST_F(BuiltinsWeakSetTest, DeleteAndRemove) } // whether jsWeakSet has delete lastKey - auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecma_runtime_call_info1 = TestHelper::CreateEcmaRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), 6); ecma_runtime_call_info1->SetFunction(JSTaggedValue::Undefined()); ecma_runtime_call_info1->SetThis(weak_set.GetTaggedValue()); ecma_runtime_call_info1->SetCallArg(0, last_key); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info1.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info1.get()); JSTaggedValue result2 = weak_set::proto::Has(ecma_runtime_call_info1.get()); EXPECT_EQ(result2.GetRawData(), JSTaggedValue::True().GetRawData()); diff --git a/tests/runtime/common/js_function_test.cpp b/tests/runtime/common/js_function_test.cpp index a4cffa27bdc8775e0ff3829b575ec3008542277c..e7add491e77975607510cf1740b39c53f1f79d87 100644 --- a/tests/runtime/common/js_function_test.cpp +++ b/tests/runtime/common/js_function_test.cpp @@ -29,26 +29,29 @@ #include "plugins/ecmascript/runtime/base/builtins_base.h" #include "plugins/ecmascript/runtime/internal_call_params.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; -using namespace panda::coretypes; -using namespace panda::ecmascript::base; namespace panda::test { class JSFunctionTest : public testing::Test { public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; - JSThread *thread; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {}; + +private: + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; JSFunction *JSObjectCreate(JSThread *thread) @@ -60,39 +63,39 @@ JSFunction *JSObjectCreate(JSThread *thread) TEST_F(JSFunctionTest, Create) { - EcmaVM *ecma_vm = thread->GetEcmaVM(); + EcmaVM *ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); - JSHandle fun_handle = thread->GetEcmaVM()->GetFactory()->NewJSFunction(env); + JSHandle fun_handle = thread_->GetEcmaVM()->GetFactory()->NewJSFunction(env); EXPECT_TRUE(*fun_handle != nullptr); EXPECT_EQ(fun_handle->GetProtoOrDynClass(), JSTaggedValue::Hole()); - JSHandle lexical_env = thread->GetEcmaVM()->GetFactory()->NewLexicalEnv(0); - fun_handle->SetLexicalEnv(thread, lexical_env.GetTaggedValue()); + JSHandle lexical_env = thread_->GetEcmaVM()->GetFactory()->NewLexicalEnv(0); + fun_handle->SetLexicalEnv(thread_, lexical_env.GetTaggedValue()); EXPECT_EQ(fun_handle->GetLexicalEnv(), lexical_env.GetTaggedValue()); EXPECT_TRUE(*lexical_env != nullptr); } TEST_F(JSFunctionTest, MakeConstructor) { - EcmaVM *ecma_vm = thread->GetEcmaVM(); + EcmaVM *ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); - JSHandle func = thread->GetEcmaVM()->GetFactory()->NewJSFunction(env, static_cast(nullptr), - FunctionKind::BASE_CONSTRUCTOR); + JSHandle func = thread_->GetEcmaVM()->GetFactory()->NewJSFunction(env, static_cast(nullptr), + FunctionKind::BASE_CONSTRUCTOR); EXPECT_TRUE(*func != nullptr); JSHandle func_handle(func); func->GetJSHClass()->SetExtensible(true); - JSHandle null_handle(thread, JSTaggedValue::Null()); - JSHandle obj = JSObject::ObjectCreate(thread, null_handle); + JSHandle null_handle(thread_, JSTaggedValue::Null()); + JSHandle obj = JSObject::ObjectCreate(thread_, null_handle); JSHandle obj_value(obj); - JSFunction::MakeConstructor(thread, func, obj_value); + JSFunction::MakeConstructor(thread_, func, obj_value); - JSHandle constructor_key(thread->GetEcmaVM()->GetFactory()->NewFromString("constructor")); + JSHandle constructor_key(thread_->GetEcmaVM()->GetFactory()->NewFromString("constructor")); - JSHandle proto_key(thread->GetEcmaVM()->GetFactory()->NewFromString("prototype")); - JSTaggedValue proto = JSObject::GetProperty(thread, func_handle, proto_key).GetValue().GetTaggedValue(); + JSHandle proto_key(thread_->GetEcmaVM()->GetFactory()->NewFromString("prototype")); + JSTaggedValue proto = JSObject::GetProperty(thread_, func_handle, proto_key).GetValue().GetTaggedValue(); JSTaggedValue constructor = - JSObject::GetProperty(thread, JSHandle(obj), constructor_key).GetValue().GetTaggedValue(); + JSObject::GetProperty(thread_, JSHandle(obj), constructor_key).GetValue().GetTaggedValue(); EXPECT_EQ(constructor, func_handle.GetTaggedValue()); EXPECT_EQ(proto, obj.GetTaggedValue()); EXPECT_EQ(func->GetFunctionKind(), FunctionKind::BASE_CONSTRUCTOR); @@ -100,17 +103,17 @@ TEST_F(JSFunctionTest, MakeConstructor) TEST_F(JSFunctionTest, OrdinaryHasInstance) { - JSHandle obj_fun(thread, JSObjectCreate(thread)); + JSHandle obj_fun(thread_, JSObjectCreate(thread_)); JSHandle jsobject = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_fun), obj_fun); - JSHandle obj(thread, jsobject.GetTaggedValue()); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_fun), obj_fun); + JSHandle obj(thread_, jsobject.GetTaggedValue()); EXPECT_TRUE(*jsobject != nullptr); - EcmaVM *ecma_vm = thread->GetEcmaVM(); + EcmaVM *ecma_vm = thread_->GetEcmaVM(); JSHandle global_env = ecma_vm->GetGlobalEnv(); JSHandle constructor = global_env->GetObjectFunction(); - EXPECT_TRUE(ecmascript::JSFunction::OrdinaryHasInstance(thread, constructor, obj)); + EXPECT_TRUE(ecmascript::JSFunction::OrdinaryHasInstance(thread_, constructor, obj)); } JSTaggedValue TestInvokeInternal(EcmaRuntimeCallInfo *argv) @@ -123,21 +126,22 @@ JSTaggedValue TestInvokeInternal(EcmaRuntimeCallInfo *argv) TEST_F(JSFunctionTest, Invoke) { - EcmaVM *ecma_vm = thread->GetEcmaVM(); + EcmaVM *ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); - JSHandle dynclass(thread, JSObjectCreate(thread)); + JSHandle dynclass(thread_, JSObjectCreate(thread_)); JSHandle callee( - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle::Cast(dynclass), dynclass)); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle::Cast(dynclass), dynclass)); EXPECT_TRUE(*callee != nullptr); + // NOLINTNEXTLINE(modernize-avoid-c-arrays) char key_array[] = "invoked"; - JSHandle callee_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(&key_array[0])); + JSHandle callee_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(&key_array[0])); JSHandle callee_func = - thread->GetEcmaVM()->GetFactory()->NewJSFunction(env, reinterpret_cast(TestInvokeInternal)); + thread_->GetEcmaVM()->GetFactory()->NewJSFunction(env, reinterpret_cast(TestInvokeInternal)); JSHandle callee_value(callee_func); - JSObject::SetProperty(thread, JSHandle(callee), callee_key, callee_value); + JSObject::SetProperty(thread_, JSHandle(callee), callee_key, callee_value); - auto info = NewRuntimeCallInfo(thread, JSTaggedValue::Undefined(), callee, JSTaggedValue::Undefined(), 1); + auto info = NewRuntimeCallInfo(thread_, JSTaggedValue::Undefined(), callee, JSTaggedValue::Undefined(), 1); info->SetCallArgs(JSTaggedValue(1)); JSTaggedValue res = JSFunction::Invoke(info.Get(), callee_key); @@ -147,15 +151,16 @@ TEST_F(JSFunctionTest, Invoke) TEST_F(JSFunctionTest, SetSymbolFunctionName) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle js_function = factory->NewJSFunction(env); JSHandle symbol = factory->NewPublicSymbolWithChar("name"); JSHandle name = factory->NewFromString("[name]"); - JSHandle prefix(thread, JSTaggedValue::Undefined()); - JSFunction::SetFunctionName(thread, JSHandle(js_function), JSHandle(symbol), prefix); + JSHandle prefix(thread_, JSTaggedValue::Undefined()); + JSFunction::SetFunctionName(thread_, JSHandle(js_function), JSHandle(symbol), + prefix); JSHandle function_name = - JSFunctionBase::GetFunctionName(thread, JSHandle(js_function)); + JSFunctionBase::GetFunctionName(thread_, JSHandle(js_function)); EXPECT_TRUE(function_name->IsString()); EXPECT_TRUE(EcmaString::StringsAreEqual(*(JSHandle(function_name)), *name)); } diff --git a/tests/runtime/common/js_object_test.cpp b/tests/runtime/common/js_object_test.cpp index 3d9e511d45db1a0652f10f12cf55b51e09c6786c..2ae5f0947f9755f5139ccc38d8c82392c412d21f 100644 --- a/tests/runtime/common/js_object_test.cpp +++ b/tests/runtime/common/js_object_test.cpp @@ -21,26 +21,31 @@ #include "plugins/ecmascript/runtime/weak_vector-inl.h" #include "plugins/ecmascript/runtime/ic/proto_change_details.h" +// NOLINTNEXTLINE(google-build-using-namespace) using namespace panda::ecmascript; -using namespace panda::ecmascript::base; -using namespace panda::coretypes; + +// NOLINTBEGIN(modernize-avoid-c-arrays,readability-magic-numbers) namespace panda::test { class JSObjectTest : public testing::Test { public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; - JSThread *thread; +protected: + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + JSThread *thread_ {}; + +private: + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; static JSFunction *JSObjectTestCreate(JSThread *thread) @@ -51,180 +56,181 @@ static JSFunction *JSObjectTestCreate(JSThread *thread) TEST_F(JSObjectTest, Create) { - JSHandle obj_func(thread, JSObjectTestCreate(thread)); + JSHandle obj_func(thread_, JSObjectTestCreate(thread_)); JSHandle jsobject = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); EXPECT_TRUE(*jsobject != nullptr); } TEST_F(JSObjectTest, SetProperty) { - JSHandle obj_func(thread, JSObjectTestCreate(thread)); + JSHandle obj_func(thread_, JSObjectTestCreate(thread_)); JSHandle jsobject = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); EXPECT_TRUE(*jsobject != nullptr); char array[] = "x"; - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromString(array)); - JSHandle value(thread, JSTaggedValue(1)); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromString(array)); + JSHandle value(thread_, JSTaggedValue(1)); - JSObject::SetProperty(thread, JSHandle(jsobject), key, value); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(jsobject), key).GetValue()->GetInt(), 1); + JSObject::SetProperty(thread_, JSHandle(jsobject), key, value); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(jsobject), key).GetValue()->GetInt(), 1); - JSHandle value2(thread, JSTaggedValue(2)); - JSObject::SetProperty(thread, JSHandle(jsobject), key, value2); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(jsobject), key).GetValue()->GetInt(), 2); + JSHandle value2(thread_, JSTaggedValue(2)); + JSObject::SetProperty(thread_, JSHandle(jsobject), key, value2); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(jsobject), key).GetValue()->GetInt(), 2); } TEST_F(JSObjectTest, GetProperty) { - JSHandle obj_func(thread, JSObjectTestCreate(thread)); + JSHandle obj_func(thread_, JSObjectTestCreate(thread_)); JSHandle obj = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); EXPECT_TRUE(*obj != nullptr); char array[] = "x"; - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromString(array)); - JSHandle value(thread, JSTaggedValue(1)); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromString(array)); + JSHandle value(thread_, JSTaggedValue(1)); - EXPECT_TRUE(JSObject::GetProperty(thread, JSHandle(obj), key).GetValue()->IsUndefined()); + EXPECT_TRUE(JSObject::GetProperty(thread_, JSHandle(obj), key).GetValue()->IsUndefined()); - JSObject::SetProperty(thread, JSHandle(obj), key, value); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj), key).GetValue()->GetInt(), 1); + JSObject::SetProperty(thread_, JSHandle(obj), key, value); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj), key).GetValue()->GetInt(), 1); } TEST_F(JSObjectTest, DeleteProperty) { - JSHandle obj_func(thread, JSObjectTestCreate(thread)); + JSHandle obj_func(thread_, JSObjectTestCreate(thread_)); JSHandle obj = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); EXPECT_TRUE(*obj != nullptr); char array[] = "print"; - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromString(array)); - JSHandle value(thread, JSTaggedValue(1)); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromString(array)); + JSHandle value(thread_, JSTaggedValue(1)); - JSObject::DeleteProperty(thread, (obj), key); - EXPECT_TRUE(JSObject::GetProperty(thread, JSHandle(obj), key).GetValue()->IsUndefined()); + JSObject::DeleteProperty(thread_, (obj), key); + EXPECT_TRUE(JSObject::GetProperty(thread_, JSHandle(obj), key).GetValue()->IsUndefined()); - JSObject::SetProperty(thread, JSHandle(obj), key, value); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj), key).GetValue()->GetInt(), 1); + JSObject::SetProperty(thread_, JSHandle(obj), key, value); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj), key).GetValue()->GetInt(), 1); - JSHandle key2(thread->GetEcmaVM()->GetFactory()->NewFromString("print_test")); - JSObject::SetProperty(thread, JSHandle(obj), key2, - JSHandle(thread, JSTaggedValue(10))); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj), key2).GetValue()->GetInt(), 10); + JSHandle key2(thread_->GetEcmaVM()->GetFactory()->NewFromString("print_test")); + JSObject::SetProperty(thread_, JSHandle(obj), key2, + JSHandle(thread_, JSTaggedValue(10))); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj), key2).GetValue()->GetInt(), 10); - JSObject::DeleteProperty(thread, (obj), key); - EXPECT_TRUE(JSObject::GetProperty(thread, JSHandle(obj), key).GetValue()->IsUndefined()); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj), key2).GetValue()->GetInt(), 10); + JSObject::DeleteProperty(thread_, (obj), key); + EXPECT_TRUE(JSObject::GetProperty(thread_, JSHandle(obj), key).GetValue()->IsUndefined()); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj), key2).GetValue()->GetInt(), 10); } TEST_F(JSObjectTest, DeletePropertyGlobal) { - JSHandle global_env = thread->GetEcmaVM()->GetGlobalEnv(); - JSHandle global(thread, global_env->GetGlobalObject()); - JSHandle print_key(thread->GetEcmaVM()->GetFactory()->NewFromString("print")); - JSHandle print_test_key(thread->GetEcmaVM()->GetFactory()->NewFromString("print_test")); + JSHandle global_env = thread_->GetEcmaVM()->GetGlobalEnv(); + JSHandle global(thread_, global_env->GetGlobalObject()); + JSHandle print_key(thread_->GetEcmaVM()->GetFactory()->NewFromString("print")); + JSHandle print_test_key(thread_->GetEcmaVM()->GetFactory()->NewFromString("print_test")); - JSHandle value = JSObject::GetProperty(thread, global, print_key).GetValue(); + JSHandle value = JSObject::GetProperty(thread_, global, print_key).GetValue(); - JSObject::SetProperty(thread, global, print_test_key, value); + JSObject::SetProperty(thread_, global, print_test_key, value); - JSTaggedValue val2 = JSObject::GetProperty(thread, global, print_test_key).GetValue().GetTaggedValue(); + JSTaggedValue val2 = JSObject::GetProperty(thread_, global, print_test_key).GetValue().GetTaggedValue(); EXPECT_EQ(val2, value.GetTaggedValue()); - JSTaggedValue::DeletePropertyOrThrow(thread, global, print_test_key); - JSTaggedValue val3 = JSObject::GetProperty(thread, global, print_key).GetValue().GetTaggedValue(); + JSTaggedValue::DeletePropertyOrThrow(thread_, global, print_test_key); + JSTaggedValue val3 = JSObject::GetProperty(thread_, global, print_key).GetValue().GetTaggedValue(); EXPECT_NE(val3, JSTaggedValue::Undefined()); } TEST_F(JSObjectTest, GetPropertyInPrototypeChain) { - JSHandle null_handle(thread, JSTaggedValue::Null()); - JSHandle grandfather = JSObject::ObjectCreate(thread, null_handle); - JSHandle father = JSObject::ObjectCreate(thread, grandfather); - JSHandle son = JSObject::ObjectCreate(thread, father); - - JSHandle son_key(thread->GetEcmaVM()->GetFactory()->NewFromString("key1")); - JSHandle father_key(thread->GetEcmaVM()->GetFactory()->NewFromString("key2")); - JSHandle grandfather_key(thread->GetEcmaVM()->GetFactory()->NewFromString("key3")); - JSHandle son_value(thread, JSTaggedValue(1)); - JSHandle father_value(thread, JSTaggedValue(2)); - JSHandle grandfather_value(thread, JSTaggedValue(3)); - - JSObject::SetProperty(thread, JSHandle(son), son_key, son_value); - JSObject::SetProperty(thread, JSHandle(father), father_key, father_value); - JSObject::SetProperty(thread, JSHandle(grandfather), grandfather_key, grandfather_value); + JSHandle null_handle(thread_, JSTaggedValue::Null()); + JSHandle grandfather = JSObject::ObjectCreate(thread_, null_handle); + JSHandle father = JSObject::ObjectCreate(thread_, grandfather); + JSHandle son = JSObject::ObjectCreate(thread_, father); + + JSHandle son_key(thread_->GetEcmaVM()->GetFactory()->NewFromString("key1")); + JSHandle father_key(thread_->GetEcmaVM()->GetFactory()->NewFromString("key2")); + JSHandle grandfather_key(thread_->GetEcmaVM()->GetFactory()->NewFromString("key3")); + JSHandle son_value(thread_, JSTaggedValue(1)); + JSHandle father_value(thread_, JSTaggedValue(2)); + JSHandle grandfather_value(thread_, JSTaggedValue(3)); + + JSObject::SetProperty(thread_, JSHandle(son), son_key, son_value); + JSObject::SetProperty(thread_, JSHandle(father), father_key, father_value); + JSObject::SetProperty(thread_, JSHandle(grandfather), grandfather_key, grandfather_value); EXPECT_EQ(son_value.GetTaggedValue(), - JSObject::GetProperty(thread, JSHandle(son), son_key).GetValue().GetTaggedValue()); + JSObject::GetProperty(thread_, JSHandle(son), son_key).GetValue().GetTaggedValue()); EXPECT_EQ(father_value.GetTaggedValue(), - JSObject::GetProperty(thread, JSHandle(son), father_key).GetValue().GetTaggedValue()); - EXPECT_EQ(grandfather_value.GetTaggedValue(), - JSObject::GetProperty(thread, JSHandle(son), grandfather_key).GetValue().GetTaggedValue()); + JSObject::GetProperty(thread_, JSHandle(son), father_key).GetValue().GetTaggedValue()); + EXPECT_EQ( + grandfather_value.GetTaggedValue(), + JSObject::GetProperty(thread_, JSHandle(son), grandfather_key).GetValue().GetTaggedValue()); } TEST_F(JSObjectTest, PropertyAttribute) { - JSHandle constructor(thread, JSObjectTestCreate(thread)); + JSHandle constructor(thread_, JSObjectTestCreate(thread_)); JSHandle obj1 = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(constructor), constructor); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(constructor), constructor); JSHandle obj2 = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(constructor), constructor); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(constructor), constructor); - JSHandle key1(thread->GetEcmaVM()->GetFactory()->NewFromString("key3")); - JSHandle key2(thread->GetEcmaVM()->GetFactory()->NewFromString("key3")); + JSHandle key1(thread_->GetEcmaVM()->GetFactory()->NewFromString("key3")); + JSHandle key2(thread_->GetEcmaVM()->GetFactory()->NewFromString("key3")); - JSHandle value1(thread, JSTaggedValue(1)); - JSHandle value2(thread, JSTaggedValue(2)); + JSHandle value1(thread_, JSTaggedValue(1)); + JSHandle value2(thread_, JSTaggedValue(2)); // test set property - PropertyDescriptor desc(thread); + PropertyDescriptor desc(thread_); desc.SetValue(value1); desc.SetWritable(false); - JSObject::DefineOwnProperty(thread, obj1, key1, desc); - JSObject::SetProperty(thread, JSHandle(obj1), key1, value2); - JSObject::SetProperty(thread, JSHandle(obj2), key1, value1); - JSObject::SetProperty(thread, JSHandle(obj2), key1, value2); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj1), key1).GetValue().GetTaggedValue(), + JSObject::DefineOwnProperty(thread_, obj1, key1, desc); + JSObject::SetProperty(thread_, JSHandle(obj1), key1, value2); + JSObject::SetProperty(thread_, JSHandle(obj2), key1, value1); + JSObject::SetProperty(thread_, JSHandle(obj2), key1, value2); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj1), key1).GetValue().GetTaggedValue(), value1.GetTaggedValue()); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj2), key1).GetValue().GetTaggedValue(), + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj2), key1).GetValue().GetTaggedValue(), value2.GetTaggedValue()); // test delete property - PropertyDescriptor desc1(thread); + PropertyDescriptor desc1(thread_); desc1.SetValue(value1); desc1.SetConfigurable(false); - JSObject::DefineOwnProperty(thread, obj1, key2, desc1); - JSObject::SetProperty(thread, JSHandle(obj1), key2, value1); - JSObject::SetProperty(thread, JSHandle(obj2), key2, value1); - JSObject::DeleteProperty(thread, (obj1), key2); - JSObject::DeleteProperty(thread, (obj2), key2); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj1), key2).GetValue().GetTaggedValue(), + JSObject::DefineOwnProperty(thread_, obj1, key2, desc1); + JSObject::SetProperty(thread_, JSHandle(obj1), key2, value1); + JSObject::SetProperty(thread_, JSHandle(obj2), key2, value1); + JSObject::DeleteProperty(thread_, (obj1), key2); + JSObject::DeleteProperty(thread_, (obj2), key2); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj1), key2).GetValue().GetTaggedValue(), value1.GetTaggedValue()); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj2), key2).GetValue().GetTaggedValue(), + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj2), key2).GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); } TEST_F(JSObjectTest, CreateDataProperty) { - JSHandle obj_func(thread, JSObjectTestCreate(thread)); + JSHandle obj_func(thread_, JSObjectTestCreate(thread_)); JSHandle obj = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); EXPECT_TRUE(*obj != nullptr); char array[] = "x"; - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromString(array)); - JSHandle value(thread, JSTaggedValue(1)); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromString(array)); + JSHandle value(thread_, JSTaggedValue(1)); - bool success = JSObject::CreateDataProperty(thread, obj, key, value); + bool success = JSObject::CreateDataProperty(thread_, obj, key, value); EXPECT_TRUE(success); - success = JSTaggedValue::HasOwnProperty(thread, JSHandle::Cast(obj), key); + success = JSTaggedValue::HasOwnProperty(thread_, JSHandle::Cast(obj), key); EXPECT_TRUE(success); - PropertyDescriptor desc(thread); - success = JSObject::GetOwnProperty(thread, obj, key, desc); + PropertyDescriptor desc(thread_); + success = JSObject::GetOwnProperty(thread_, obj, key, desc); EXPECT_TRUE(success); EXPECT_EQ(true, desc.IsWritable()); EXPECT_EQ(true, desc.IsEnumerable()); @@ -233,23 +239,23 @@ TEST_F(JSObjectTest, CreateDataProperty) TEST_F(JSObjectTest, CreateMethodProperty) { - JSHandle obj_func(thread, JSObjectTestCreate(thread)); + JSHandle obj_func(thread_, JSObjectTestCreate(thread_)); JSHandle obj = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); EXPECT_TRUE(*obj != nullptr); char array[] = "x"; - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromString(array)); - JSHandle value(thread, JSTaggedValue(1)); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromString(array)); + JSHandle value(thread_, JSTaggedValue(1)); - bool success = JSObject::CreateMethodProperty(thread, obj, key, value); + bool success = JSObject::CreateMethodProperty(thread_, obj, key, value); EXPECT_TRUE(success); - success = JSTaggedValue::HasOwnProperty(thread, JSHandle::Cast(obj), key); + success = JSTaggedValue::HasOwnProperty(thread_, JSHandle::Cast(obj), key); EXPECT_TRUE(success); - PropertyDescriptor desc(thread); - success = JSObject::GetOwnProperty(thread, obj, key, desc); + PropertyDescriptor desc(thread_); + success = JSObject::GetOwnProperty(thread_, obj, key, desc); EXPECT_TRUE(success); EXPECT_EQ(true, desc.IsWritable()); EXPECT_EQ(false, desc.IsEnumerable()); @@ -258,251 +264,251 @@ TEST_F(JSObjectTest, CreateMethodProperty) TEST_F(JSObjectTest, DefinePropertyOrThrow) { - JSHandle obj_func(thread, JSObjectTestCreate(thread)); + JSHandle obj_func(thread_, JSObjectTestCreate(thread_)); JSHandle obj = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); EXPECT_TRUE(*obj != nullptr); char array[] = "x"; - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromString(array)); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromString(array)); - PropertyDescriptor desc1(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - bool success = JSTaggedValue::DefinePropertyOrThrow(thread, JSHandle(obj), key, desc1); + PropertyDescriptor desc1(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + bool success = JSTaggedValue::DefinePropertyOrThrow(thread_, JSHandle(obj), key, desc1); EXPECT_TRUE(success); - PropertyDescriptor desc_res1(thread); - success = JSObject::GetOwnProperty(thread, obj, key, desc_res1); + PropertyDescriptor desc_res1(thread_); + success = JSObject::GetOwnProperty(thread_, obj, key, desc_res1); EXPECT_TRUE(success); EXPECT_EQ(1, desc_res1.GetValue()->GetInt()); EXPECT_EQ(true, desc_res1.IsWritable()); EXPECT_EQ(true, desc_res1.IsEnumerable()); EXPECT_EQ(true, desc_res1.IsConfigurable()); - PropertyDescriptor desc2(thread, false, true, true); - success = JSTaggedValue::DefinePropertyOrThrow(thread, JSHandle(obj), key, desc2); + PropertyDescriptor desc2(thread_, false, true, true); + success = JSTaggedValue::DefinePropertyOrThrow(thread_, JSHandle(obj), key, desc2); EXPECT_TRUE(success); - PropertyDescriptor desc_res2(thread); - success = JSObject::GetOwnProperty(thread, obj, key, desc_res2); + PropertyDescriptor desc_res2(thread_); + success = JSObject::GetOwnProperty(thread_, obj, key, desc_res2); EXPECT_TRUE(success); EXPECT_EQ(1, desc_res2.GetValue()->GetInt()); EXPECT_EQ(false, desc_res2.IsWritable()); EXPECT_EQ(true, desc_res2.IsEnumerable()); EXPECT_EQ(true, desc_res2.IsConfigurable()); - PropertyDescriptor desc3(thread); + PropertyDescriptor desc3(thread_); desc3.SetWritable(false); desc3.SetEnumerable(false); desc3.SetConfigurable(false); - success = JSTaggedValue::DefinePropertyOrThrow(thread, JSHandle(obj), key, desc3); + success = JSTaggedValue::DefinePropertyOrThrow(thread_, JSHandle(obj), key, desc3); EXPECT_TRUE(success); - PropertyDescriptor desc_res3(thread); - success = JSObject::GetOwnProperty(thread, obj, key, desc_res3); + PropertyDescriptor desc_res3(thread_); + success = JSObject::GetOwnProperty(thread_, obj, key, desc_res3); EXPECT_TRUE(success); EXPECT_EQ(1, desc_res3.GetValue()->GetInt()); EXPECT_EQ(false, desc_res3.IsWritable()); EXPECT_EQ(false, desc_res3.IsEnumerable()); EXPECT_EQ(false, desc_res3.IsConfigurable()); - PropertyDescriptor desc4(thread, JSHandle(thread, JSTaggedValue(2))); - success = JSTaggedValue::DefinePropertyOrThrow(thread, JSHandle(obj), key, desc4); + PropertyDescriptor desc4(thread_, JSHandle(thread_, JSTaggedValue(2))); + success = JSTaggedValue::DefinePropertyOrThrow(thread_, JSHandle(obj), key, desc4); EXPECT_FALSE(success); } TEST_F(JSObjectTest, HasProperty) { - JSHandle obj_func(thread, JSObjectTestCreate(thread)); + JSHandle obj_func(thread_, JSObjectTestCreate(thread_)); JSHandle obj = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); EXPECT_TRUE(*obj != nullptr); char array[] = "x"; - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromString(array)); - JSHandle value(thread, JSTaggedValue(1)); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromString(array)); + JSHandle value(thread_, JSTaggedValue(1)); - bool flag = JSObject::HasProperty(thread, obj, key); + bool flag = JSObject::HasProperty(thread_, obj, key); EXPECT_FALSE(flag); - JSObject::SetProperty(thread, JSHandle(obj), key, value); - flag = JSObject::HasProperty(thread, obj, key); + JSObject::SetProperty(thread_, JSHandle(obj), key, value); + flag = JSObject::HasProperty(thread_, obj, key); EXPECT_TRUE(flag); - JSObject::DeleteProperty(thread, (obj), key); - flag = JSObject::HasProperty(thread, obj, key); + JSObject::DeleteProperty(thread_, (obj), key); + flag = JSObject::HasProperty(thread_, obj, key); EXPECT_FALSE(flag); } TEST_F(JSObjectTest, HasPropertyWithProtoType) { - JSHandle null_handle(thread, JSTaggedValue::Null()); - JSHandle grandfather = JSObject::ObjectCreate(thread, null_handle); - JSHandle father = JSObject::ObjectCreate(thread, grandfather); - JSHandle son = JSObject::ObjectCreate(thread, father); - - auto test_grand = grandfather->GetPrototype(thread); - auto test_father = father->GetPrototype(thread); - auto test_son = son->GetPrototype(thread); + JSHandle null_handle(thread_, JSTaggedValue::Null()); + JSHandle grandfather = JSObject::ObjectCreate(thread_, null_handle); + JSHandle father = JSObject::ObjectCreate(thread_, grandfather); + JSHandle son = JSObject::ObjectCreate(thread_, father); + + auto test_grand = grandfather->GetPrototype(thread_); + auto test_father = father->GetPrototype(thread_); + auto test_son = son->GetPrototype(thread_); EXPECT_TRUE(test_son != test_father); EXPECT_TRUE(test_grand != test_father); - JSHandle son_key(thread->GetEcmaVM()->GetFactory()->NewFromString("key1")); - JSHandle father_key(thread->GetEcmaVM()->GetFactory()->NewFromString("key2")); - JSHandle grandfather_key(thread->GetEcmaVM()->GetFactory()->NewFromString("key3")); - JSHandle son_value(thread, JSTaggedValue(1)); - JSHandle father_value(thread, JSTaggedValue(2)); - JSHandle grandfather_value(thread, JSTaggedValue(3)); - - JSObject::SetProperty(thread, JSHandle(son), son_key, son_value); - JSObject::SetProperty(thread, JSHandle(father), father_key, father_value); - JSObject::SetProperty(thread, JSHandle(grandfather), grandfather_key, grandfather_value); - - bool flag = JSObject::HasProperty(thread, son, son_key); + JSHandle son_key(thread_->GetEcmaVM()->GetFactory()->NewFromString("key1")); + JSHandle father_key(thread_->GetEcmaVM()->GetFactory()->NewFromString("key2")); + JSHandle grandfather_key(thread_->GetEcmaVM()->GetFactory()->NewFromString("key3")); + JSHandle son_value(thread_, JSTaggedValue(1)); + JSHandle father_value(thread_, JSTaggedValue(2)); + JSHandle grandfather_value(thread_, JSTaggedValue(3)); + + JSObject::SetProperty(thread_, JSHandle(son), son_key, son_value); + JSObject::SetProperty(thread_, JSHandle(father), father_key, father_value); + JSObject::SetProperty(thread_, JSHandle(grandfather), grandfather_key, grandfather_value); + + bool flag = JSObject::HasProperty(thread_, son, son_key); EXPECT_TRUE(flag); - flag = JSObject::HasProperty(thread, son, father_key); + flag = JSObject::HasProperty(thread_, son, father_key); EXPECT_TRUE(flag); - flag = JSObject::HasProperty(thread, son, grandfather_key); + flag = JSObject::HasProperty(thread_, son, grandfather_key); EXPECT_TRUE(flag); } TEST_F(JSObjectTest, HasOwnProperty) { - JSHandle null_handle(thread, JSTaggedValue::Null()); - JSHandle grandfather = JSObject::ObjectCreate(thread, null_handle); - JSHandle father = JSObject::ObjectCreate(thread, grandfather); - JSHandle son = JSObject::ObjectCreate(thread, father); - - JSHandle son_key(thread->GetEcmaVM()->GetFactory()->NewFromString("key1")); - JSHandle father_key(thread->GetEcmaVM()->GetFactory()->NewFromString("key2")); - JSHandle grandfather_key(thread->GetEcmaVM()->GetFactory()->NewFromString("key3")); - JSHandle son_value(thread, JSTaggedValue(1)); - JSHandle father_value(thread, JSTaggedValue(2)); - JSHandle grandfather_value(thread, JSTaggedValue(3)); - - JSObject::SetProperty(thread, JSHandle(son), son_key, son_value); - JSObject::SetProperty(thread, JSHandle(father), father_key, father_value); - JSObject::SetProperty(thread, JSHandle(grandfather), grandfather_key, grandfather_value); - - bool flag = JSTaggedValue::HasOwnProperty(thread, JSHandle::Cast(son), son_key); + JSHandle null_handle(thread_, JSTaggedValue::Null()); + JSHandle grandfather = JSObject::ObjectCreate(thread_, null_handle); + JSHandle father = JSObject::ObjectCreate(thread_, grandfather); + JSHandle son = JSObject::ObjectCreate(thread_, father); + + JSHandle son_key(thread_->GetEcmaVM()->GetFactory()->NewFromString("key1")); + JSHandle father_key(thread_->GetEcmaVM()->GetFactory()->NewFromString("key2")); + JSHandle grandfather_key(thread_->GetEcmaVM()->GetFactory()->NewFromString("key3")); + JSHandle son_value(thread_, JSTaggedValue(1)); + JSHandle father_value(thread_, JSTaggedValue(2)); + JSHandle grandfather_value(thread_, JSTaggedValue(3)); + + JSObject::SetProperty(thread_, JSHandle(son), son_key, son_value); + JSObject::SetProperty(thread_, JSHandle(father), father_key, father_value); + JSObject::SetProperty(thread_, JSHandle(grandfather), grandfather_key, grandfather_value); + + bool flag = JSTaggedValue::HasOwnProperty(thread_, JSHandle::Cast(son), son_key); EXPECT_TRUE(flag); - flag = JSTaggedValue::HasOwnProperty(thread, JSHandle::Cast(son), father_key); + flag = JSTaggedValue::HasOwnProperty(thread_, JSHandle::Cast(son), father_key); EXPECT_FALSE(flag); - flag = JSTaggedValue::HasOwnProperty(thread, JSHandle::Cast(son), grandfather_key); + flag = JSTaggedValue::HasOwnProperty(thread_, JSHandle::Cast(son), grandfather_key); EXPECT_FALSE(flag); } TEST_F(JSObjectTest, GetOwnPropertyKeys) { - JSHandle constructor(thread, JSObjectTestCreate(thread)); + JSHandle constructor(thread_, JSObjectTestCreate(thread_)); JSHandle obj = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(constructor), constructor); - - JSHandle key1(thread->GetEcmaVM()->GetFactory()->NewFromString("x")); - JSHandle key2(thread->GetEcmaVM()->GetFactory()->NewFromString("y")); - JSHandle key3(thread->GetEcmaVM()->GetFactory()->NewFromString("3")); - JSHandle key4(thread->GetEcmaVM()->GetFactory()->NewFromString("4")); - JSHandle value1(thread, JSTaggedValue(1)); - JSHandle value2(thread, JSTaggedValue(2)); - JSHandle value3(thread, JSTaggedValue(3)); - JSHandle value4(thread, JSTaggedValue(4)); - - JSObject::SetProperty(thread, JSHandle(obj), key1, value1); - JSObject::SetProperty(thread, JSHandle(obj), key2, value2); - JSObject::SetProperty(thread, JSHandle(obj), key3, value3); - JSObject::SetProperty(thread, JSHandle(obj), key4, value4); - - JSHandle array = JSObject::GetOwnPropertyKeys(thread, obj); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(constructor), constructor); + + JSHandle key1(thread_->GetEcmaVM()->GetFactory()->NewFromString("x")); + JSHandle key2(thread_->GetEcmaVM()->GetFactory()->NewFromString("y")); + JSHandle key3(thread_->GetEcmaVM()->GetFactory()->NewFromString("3")); + JSHandle key4(thread_->GetEcmaVM()->GetFactory()->NewFromString("4")); + JSHandle value1(thread_, JSTaggedValue(1)); + JSHandle value2(thread_, JSTaggedValue(2)); + JSHandle value3(thread_, JSTaggedValue(3)); + JSHandle value4(thread_, JSTaggedValue(4)); + + JSObject::SetProperty(thread_, JSHandle(obj), key1, value1); + JSObject::SetProperty(thread_, JSHandle(obj), key2, value2); + JSObject::SetProperty(thread_, JSHandle(obj), key3, value3); + JSObject::SetProperty(thread_, JSHandle(obj), key4, value4); + + JSHandle array = JSObject::GetOwnPropertyKeys(thread_, obj); int length = array->GetLength(); EXPECT_EQ(length, 4); int sum = 0; for (int i = 0; i < length; i++) { - JSHandle key(thread, array->Get(i)); - sum += JSObject::GetProperty(thread, JSHandle(obj), key).GetValue()->GetInt(); + JSHandle key(thread_, array->Get(i)); + sum += JSObject::GetProperty(thread_, JSHandle(obj), key).GetValue()->GetInt(); } EXPECT_EQ(sum, 10); } TEST_F(JSObjectTest, ObjectCreateMethod) { - JSHandle null_handle(thread, JSTaggedValue::Null()); - JSHandle grandfather = JSObject::ObjectCreate(thread, null_handle); - JSHandle father = JSObject::ObjectCreate(thread, grandfather); - JSHandle son = JSObject::ObjectCreate(thread, father); - - EXPECT_EQ(son->GetPrototype(thread), father.GetTaggedValue()); - EXPECT_EQ(father->GetPrototype(thread), grandfather.GetTaggedValue()); - EXPECT_EQ(grandfather->GetPrototype(thread), JSTaggedValue::Null()); + JSHandle null_handle(thread_, JSTaggedValue::Null()); + JSHandle grandfather = JSObject::ObjectCreate(thread_, null_handle); + JSHandle father = JSObject::ObjectCreate(thread_, grandfather); + JSHandle son = JSObject::ObjectCreate(thread_, father); + + EXPECT_EQ(son->GetPrototype(thread_), father.GetTaggedValue()); + EXPECT_EQ(father->GetPrototype(thread_), grandfather.GetTaggedValue()); + EXPECT_EQ(grandfather->GetPrototype(thread_), JSTaggedValue::Null()); } TEST_F(JSObjectTest, GetMethod) { - JSHandle null_handle(thread, JSTaggedValue::Null()); - JSHandle obj = JSObject::ObjectCreate(thread, null_handle); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); - JSHandle func(thread->GetEcmaVM()->GetFactory()->NewJSFunction(env)); + JSHandle null_handle(thread_, JSTaggedValue::Null()); + JSHandle obj = JSObject::ObjectCreate(thread_, null_handle); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); + JSHandle func(thread_->GetEcmaVM()->GetFactory()->NewJSFunction(env)); EXPECT_TRUE(*func != nullptr); - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromString("1")); - JSObject::SetProperty(thread, JSHandle(obj), key, func); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj), key).GetValue().GetTaggedValue(), + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromString("1")); + JSObject::SetProperty(thread_, JSHandle(obj), key, func); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj), key).GetValue().GetTaggedValue(), func.GetTaggedValue()); } TEST_F(JSObjectTest, EnumerableOwnNames) { - JSHandle obj_func(thread, JSObjectTestCreate(thread)); + JSHandle obj_func(thread_, JSObjectTestCreate(thread_)); JSHandle obj = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); EXPECT_TRUE(*obj != nullptr); PandaString tag_c_str = "x"; - JSHandle tag_string = thread->GetEcmaVM()->GetFactory()->NewFromString(&tag_c_str[0]); + JSHandle tag_string = thread_->GetEcmaVM()->GetFactory()->NewFromString(&tag_c_str[0]); JSHandle key(tag_string); - JSHandle value(thread, JSTaggedValue(1)); + JSHandle value(thread_, JSTaggedValue(1)); - JSObject::SetProperty(thread, JSHandle(obj), key, value); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj), key).GetValue()->GetInt(), 1); + JSObject::SetProperty(thread_, JSHandle(obj), key, value); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj), key).GetValue()->GetInt(), 1); - JSHandle names = JSObject::EnumerableOwnNames(thread, obj); + JSHandle names = JSObject::EnumerableOwnNames(thread_, obj); - JSHandle key_from_names(thread, JSTaggedValue(names->Get(0))); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj), key_from_names).GetValue()->GetInt(), 1); + JSHandle key_from_names(thread_, JSTaggedValue(names->Get(0))); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj), key_from_names).GetValue()->GetInt(), 1); - PropertyDescriptor desc_no_enum(thread); + PropertyDescriptor desc_no_enum(thread_); desc_no_enum.SetEnumerable(false); - JSTaggedValue::DefinePropertyOrThrow(thread, JSHandle(obj), key, desc_no_enum); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj), key).GetValue()->GetInt(), 1); + JSTaggedValue::DefinePropertyOrThrow(thread_, JSHandle(obj), key, desc_no_enum); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj), key).GetValue()->GetInt(), 1); - JSHandle names_no_enum = JSObject::EnumerableOwnNames(thread, obj); + JSHandle names_no_enum = JSObject::EnumerableOwnNames(thread_, obj); EXPECT_TRUE(names_no_enum->GetLength() == 0); - PropertyDescriptor desc_enum(thread); + PropertyDescriptor desc_enum(thread_); desc_enum.SetConfigurable(false); desc_enum.SetEnumerable(true); - JSTaggedValue::DefinePropertyOrThrow(thread, JSHandle(obj), key, desc_enum); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj), key).GetValue()->GetInt(), 1); + JSTaggedValue::DefinePropertyOrThrow(thread_, JSHandle(obj), key, desc_enum); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj), key).GetValue()->GetInt(), 1); - JSHandle names_no_config = JSObject::EnumerableOwnNames(thread, obj); + JSHandle names_no_config = JSObject::EnumerableOwnNames(thread_, obj); - JSHandle key_no_config(thread, JSTaggedValue(names_no_config->Get(0))); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj), key_no_config).GetValue()->GetInt(), 1); + JSHandle key_no_config(thread_, JSTaggedValue(names_no_config->Get(0))); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj), key_no_config).GetValue()->GetInt(), 1); } TEST_F(JSObjectTest, SetIntegrityLevelSealed) { - JSHandle dynclass1(thread, JSObjectTestCreate(thread)); + JSHandle dynclass1(thread_, JSObjectTestCreate(thread_)); JSHandle obj1 = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(dynclass1), dynclass1); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(dynclass1), dynclass1); EXPECT_TRUE(*obj1 != nullptr); PandaString undefined_c_str = "x"; - JSHandle key1(thread->GetEcmaVM()->GetFactory()->NewFromString(&undefined_c_str[0])); - JSHandle value1(thread, JSTaggedValue(1)); - JSObject::SetProperty(thread, JSHandle(obj1), key1, value1); + JSHandle key1(thread_->GetEcmaVM()->GetFactory()->NewFromString(&undefined_c_str[0])); + JSHandle value1(thread_, JSTaggedValue(1)); + JSObject::SetProperty(thread_, JSHandle(obj1), key1, value1); // test SetIntegrityLevel::SEALED JSHandle jsobject(obj1); - bool status1 = JSObject::SetIntegrityLevel(thread, jsobject, IntegrityLevel::SEALED); + bool status1 = JSObject::SetIntegrityLevel(thread_, jsobject, IntegrityLevel::SEALED); EXPECT_TRUE(status1); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj1), key1).GetValue().GetTaggedValue(), + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj1), key1).GetValue().GetTaggedValue(), value1.GetTaggedValue()); - PropertyDescriptor desc1(thread); - bool success1 = JSObject::GetOwnProperty(thread, jsobject, key1, desc1); + PropertyDescriptor desc1(thread_); + bool success1 = JSObject::GetOwnProperty(thread_, jsobject, key1, desc1); EXPECT_TRUE(success1); EXPECT_EQ(true, desc1.IsWritable()); EXPECT_EQ(true, desc1.IsEnumerable()); @@ -511,23 +517,23 @@ TEST_F(JSObjectTest, SetIntegrityLevelSealed) TEST_F(JSObjectTest, SetIntegrityLevelFrozen) { - JSHandle dynclass1(thread, JSObjectTestCreate(thread)); + JSHandle dynclass1(thread_, JSObjectTestCreate(thread_)); JSHandle obj1 = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(dynclass1), dynclass1); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(dynclass1), dynclass1); EXPECT_TRUE(*obj1 != nullptr); PandaString undefined_c_str = "x"; - JSHandle key1(thread->GetEcmaVM()->GetFactory()->NewFromString(&undefined_c_str[0])); - JSHandle value1(thread, JSTaggedValue(1)); - JSObject::SetProperty(thread, JSHandle(obj1), key1, value1); + JSHandle key1(thread_->GetEcmaVM()->GetFactory()->NewFromString(&undefined_c_str[0])); + JSHandle value1(thread_, JSTaggedValue(1)); + JSObject::SetProperty(thread_, JSHandle(obj1), key1, value1); // test SetIntegrityLevel::FROZEN - bool status1 = JSObject::SetIntegrityLevel(thread, obj1, IntegrityLevel::FROZEN); + bool status1 = JSObject::SetIntegrityLevel(thread_, obj1, IntegrityLevel::FROZEN); EXPECT_TRUE(status1); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj1), key1).GetValue().GetTaggedValue(), + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj1), key1).GetValue().GetTaggedValue(), value1.GetTaggedValue()); - PropertyDescriptor desc1(thread); - bool success1 = JSObject::GetOwnProperty(thread, obj1, key1, desc1); + PropertyDescriptor desc1(thread_); + bool success1 = JSObject::GetOwnProperty(thread_, obj1, key1, desc1); EXPECT_TRUE(success1); EXPECT_EQ(false, desc1.IsWritable()); EXPECT_EQ(true, desc1.IsEnumerable()); @@ -536,71 +542,71 @@ TEST_F(JSObjectTest, SetIntegrityLevelFrozen) TEST_F(JSObjectTest, TestIntegrityLevelSealed) { - JSHandle dynclass1(thread, JSObjectTestCreate(thread)); + JSHandle dynclass1(thread_, JSObjectTestCreate(thread_)); JSHandle obj1 = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(dynclass1), dynclass1); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(dynclass1), dynclass1); PandaString undefined_c_str = "level"; - JSHandle key1(thread->GetEcmaVM()->GetFactory()->NewFromString(&undefined_c_str[0])); - JSHandle value1(thread, JSTaggedValue(1)); - JSObject::SetProperty(thread, JSHandle(obj1), key1, value1); + JSHandle key1(thread_->GetEcmaVM()->GetFactory()->NewFromString(&undefined_c_str[0])); + JSHandle value1(thread_, JSTaggedValue(1)); + JSObject::SetProperty(thread_, JSHandle(obj1), key1, value1); obj1->GetJSHClass()->SetExtensible(false); // test SetIntegrityLevel::SEALED - bool status1 = JSObject::SetIntegrityLevel(thread, obj1, IntegrityLevel::SEALED); + bool status1 = JSObject::SetIntegrityLevel(thread_, obj1, IntegrityLevel::SEALED); EXPECT_TRUE(status1); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj1), key1).GetValue().GetTaggedValue(), + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj1), key1).GetValue().GetTaggedValue(), value1.GetTaggedValue()); - PropertyDescriptor desc1(thread); - bool success1 = JSObject::GetOwnProperty(thread, obj1, key1, desc1); + PropertyDescriptor desc1(thread_); + bool success1 = JSObject::GetOwnProperty(thread_, obj1, key1, desc1); EXPECT_TRUE(success1); - EXPECT_EQ(true, JSObject::TestIntegrityLevel(thread, obj1, IntegrityLevel::SEALED)); - EXPECT_EQ(false, JSObject::TestIntegrityLevel(thread, obj1, IntegrityLevel::FROZEN)); + EXPECT_EQ(true, JSObject::TestIntegrityLevel(thread_, obj1, IntegrityLevel::SEALED)); + EXPECT_EQ(false, JSObject::TestIntegrityLevel(thread_, obj1, IntegrityLevel::FROZEN)); } TEST_F(JSObjectTest, TestIntegrityLevelFrozen) { - JSHandle dynclass1(thread, JSObjectTestCreate(thread)); + JSHandle dynclass1(thread_, JSObjectTestCreate(thread_)); JSHandle obj1 = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(dynclass1), dynclass1); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(dynclass1), dynclass1); PandaString undefined_c_str = "level"; - JSHandle key1(thread->GetEcmaVM()->GetFactory()->NewFromString(&undefined_c_str[0])); - JSHandle value1(thread, JSTaggedValue(1)); - JSObject::SetProperty(thread, JSHandle(obj1), key1, value1); + JSHandle key1(thread_->GetEcmaVM()->GetFactory()->NewFromString(&undefined_c_str[0])); + JSHandle value1(thread_, JSTaggedValue(1)); + JSObject::SetProperty(thread_, JSHandle(obj1), key1, value1); obj1->GetJSHClass()->SetExtensible(false); // test SetIntegrityLevel::FROZEN - bool status1 = JSObject::SetIntegrityLevel(thread, obj1, IntegrityLevel::FROZEN); + bool status1 = JSObject::SetIntegrityLevel(thread_, obj1, IntegrityLevel::FROZEN); EXPECT_TRUE(status1); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj1), key1).GetValue().GetTaggedValue(), + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj1), key1).GetValue().GetTaggedValue(), value1.GetTaggedValue()); - PropertyDescriptor desc1(thread); - bool success1 = JSObject::GetOwnProperty(thread, obj1, key1, desc1); + PropertyDescriptor desc1(thread_); + bool success1 = JSObject::GetOwnProperty(thread_, obj1, key1, desc1); EXPECT_TRUE(success1); - EXPECT_EQ(true, JSObject::TestIntegrityLevel(thread, obj1, IntegrityLevel::SEALED)); - EXPECT_EQ(true, JSObject::TestIntegrityLevel(thread, obj1, IntegrityLevel::FROZEN)); + EXPECT_EQ(true, JSObject::TestIntegrityLevel(thread_, obj1, IntegrityLevel::SEALED)); + EXPECT_EQ(true, JSObject::TestIntegrityLevel(thread_, obj1, IntegrityLevel::FROZEN)); } TEST_F(JSObjectTest, TestIntegrityLevelWithoutProperty) { - JSHandle dynclass1(thread, JSObjectTestCreate(thread)); + JSHandle dynclass1(thread_, JSObjectTestCreate(thread_)); JSHandle obj1( - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(dynclass1), dynclass1)); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(dynclass1), dynclass1)); JSHandle::Cast(obj1)->GetJSHClass()->SetExtensible(false); PandaString undefined_c_str = "level"; - JSHandle key1(thread->GetEcmaVM()->GetFactory()->NewFromString(&undefined_c_str[0])); + JSHandle key1(thread_->GetEcmaVM()->GetFactory()->NewFromString(&undefined_c_str[0])); // test SetIntegrityLevel::FROZEN JSHandle jsobject(obj1); - bool status1 = JSObject::SetIntegrityLevel(thread, jsobject, IntegrityLevel::SEALED); + bool status1 = JSObject::SetIntegrityLevel(thread_, jsobject, IntegrityLevel::SEALED); EXPECT_TRUE(status1); - PropertyDescriptor desc1(thread); - bool success1 = JSObject::GetOwnProperty(thread, jsobject, key1, desc1); + PropertyDescriptor desc1(thread_); + bool success1 = JSObject::GetOwnProperty(thread_, jsobject, key1, desc1); EXPECT_TRUE(!success1); - EXPECT_EQ(true, JSObject::TestIntegrityLevel(thread, jsobject, IntegrityLevel::SEALED)); - EXPECT_EQ(true, JSObject::TestIntegrityLevel(thread, jsobject, IntegrityLevel::FROZEN)); + EXPECT_EQ(true, JSObject::TestIntegrityLevel(thread_, jsobject, IntegrityLevel::SEALED)); + EXPECT_EQ(true, JSObject::TestIntegrityLevel(thread_, jsobject, IntegrityLevel::FROZEN)); } JSTaggedValue TestGetter(EcmaRuntimeCallInfo *argv) @@ -617,26 +623,26 @@ JSTaggedValue TestGetter(EcmaRuntimeCallInfo *argv) TEST_F(JSObjectTest, Getter) { - JSHandle dynclass1(thread, JSObjectTestCreate(thread)); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + JSHandle dynclass1(thread_, JSObjectTestCreate(thread_)); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle obj = factory->NewJSObjectByConstructor(JSHandle(dynclass1), dynclass1); JSHandle key1(factory->NewFromString("x")); JSHandle key2(factory->NewFromString("y")); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle getter = - thread->GetEcmaVM()->GetFactory()->NewJSFunction(env, reinterpret_cast(TestGetter)); + thread_->GetEcmaVM()->GetFactory()->NewJSFunction(env, reinterpret_cast(TestGetter)); - PropertyDescriptor desc1(thread); + PropertyDescriptor desc1(thread_); desc1.SetGetter(JSHandle::Cast(getter)); - bool success1 = JSObject::DefineOwnProperty(thread, obj, key1, desc1); + bool success1 = JSObject::DefineOwnProperty(thread_, obj, key1, desc1); EXPECT_TRUE(success1); - PropertyDescriptor desc2(thread); - desc2.SetValue(JSHandle(thread, JSTaggedValue(1))); - success1 = JSObject::DefineOwnProperty(thread, obj, key2, desc2); + PropertyDescriptor desc2(thread_); + desc2.SetValue(JSHandle(thread_, JSTaggedValue(1))); + success1 = JSObject::DefineOwnProperty(thread_, obj, key2, desc2); EXPECT_TRUE(success1); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj), key1).GetValue().GetTaggedValue(), + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj), key1).GetValue().GetTaggedValue(), JSTaggedValue(2)); } @@ -656,61 +662,61 @@ JSTaggedValue TestSetter(EcmaRuntimeCallInfo *argv) TEST_F(JSObjectTest, Setter) { - JSHandle dynclass1(thread, JSObjectTestCreate(thread)); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + JSHandle dynclass1(thread_, JSObjectTestCreate(thread_)); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle obj = factory->NewJSObjectByConstructor(JSHandle(dynclass1), dynclass1); JSHandle key1(factory->NewFromString("x")); JSHandle key2(factory->NewFromString("y")); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle setter = - thread->GetEcmaVM()->GetFactory()->NewJSFunction(env, reinterpret_cast(TestSetter)); + thread_->GetEcmaVM()->GetFactory()->NewJSFunction(env, reinterpret_cast(TestSetter)); - PropertyDescriptor desc1(thread); + PropertyDescriptor desc1(thread_); desc1.SetSetter(JSHandle::Cast(setter)); - bool success1 = JSObject::DefineOwnProperty(thread, obj, key1, desc1); + bool success1 = JSObject::DefineOwnProperty(thread_, obj, key1, desc1); EXPECT_TRUE(success1); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - success1 = JSObject::DefineOwnProperty(thread, obj, key2, desc2); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + success1 = JSObject::DefineOwnProperty(thread_, obj, key2, desc2); EXPECT_TRUE(success1); - JSHandle value_handle(thread, JSTaggedValue::Undefined()); - EXPECT_TRUE(JSObject::SetProperty(thread, JSHandle(obj), key1, value_handle)); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj), key2).GetValue().GetTaggedValue(), + JSHandle value_handle(thread_, JSTaggedValue::Undefined()); + EXPECT_TRUE(JSObject::SetProperty(thread_, JSHandle(obj), key1, value_handle)); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj), key2).GetValue().GetTaggedValue(), JSTaggedValue(2)); } TEST_F(JSObjectTest, SpeciesConstructor) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); - const GlobalEnvConstants *global_const = thread->GlobalConstants(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); + const GlobalEnvConstants *global_const = thread_->GlobalConstants(); JSHandle constructor_func = factory->NewJSFunction(env, static_cast(nullptr), FunctionKind::BASE_CONSTRUCTOR); JSHandle constructor_func_value(constructor_func); constructor_func->GetJSHClass()->SetExtensible(true); - JSFunction::NewJSFunctionPrototype(thread, factory, constructor_func); + JSFunction::NewJSFunctionPrototype(thread_, factory, constructor_func); - JSHandle null_handle(thread, JSTaggedValue::Null()); - JSHandle undefined_value(thread, JSTaggedValue::Undefined()); - JSHandle proto_obj = JSObject::ObjectCreate(thread, null_handle); + JSHandle null_handle(thread_, JSTaggedValue::Null()); + JSHandle undefined_value(thread_, JSTaggedValue::Undefined()); + JSHandle proto_obj = JSObject::ObjectCreate(thread_, null_handle); JSHandle proto_obj_value(proto_obj); JSHandle constructor_key = global_const->GetHandledConstructorString(); - JSObject::SetProperty(thread, proto_obj_value, constructor_key, constructor_func_value); + JSObject::SetProperty(thread_, proto_obj_value, constructor_key, constructor_func_value); factory->NewJSObjectByConstructor(constructor_func, JSHandle::Cast(constructor_func)); JSHandle species_construct = factory->NewJSFunction(env, static_cast(nullptr), FunctionKind::BASE_CONSTRUCTOR); JSHandle species_construct_value(species_construct); constructor_func->GetJSHClass()->SetExtensible(true); - JSFunction::MakeConstructor(thread, species_construct, undefined_value); + JSFunction::MakeConstructor(thread_, species_construct, undefined_value); JSHandle species_symbol = env->GetSpeciesSymbol(); - JSObject::SetProperty(thread, constructor_func_value, species_symbol, species_construct_value); + JSObject::SetProperty(thread_, constructor_func_value, species_symbol, species_construct_value); JSTaggedValue species_value = - JSObject::SpeciesConstructor(thread, proto_obj, constructor_func_value).GetTaggedValue(); + JSObject::SpeciesConstructor(thread_, proto_obj, constructor_func_value).GetTaggedValue(); EXPECT_EQ(species_value, species_construct_value.GetTaggedValue()); } @@ -726,32 +732,32 @@ JSTaggedValue TestUndefinedSetter([[maybe_unused]] EcmaRuntimeCallInfo *argv) TEST_F(JSObjectTest, GetterIsUndefined) { - JSHandle dynclass1(thread, JSObjectTestCreate(thread)); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + JSHandle dynclass1(thread_, JSObjectTestCreate(thread_)); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle obj = factory->NewJSObjectByConstructor(JSHandle(dynclass1), dynclass1); JSHandle key(factory->NewFromString("property")); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle getter = - thread->GetEcmaVM()->GetFactory()->NewJSFunction(env, reinterpret_cast(TestUndefinedGetter)); + thread_->GetEcmaVM()->GetFactory()->NewJSFunction(env, reinterpret_cast(TestUndefinedGetter)); JSHandle setter = - thread->GetEcmaVM()->GetFactory()->NewJSFunction(env, reinterpret_cast(TestUndefinedSetter)); - JSHandle un_getter(thread, JSTaggedValue::Undefined()); + thread_->GetEcmaVM()->GetFactory()->NewJSFunction(env, reinterpret_cast(TestUndefinedSetter)); + JSHandle un_getter(thread_, JSTaggedValue::Undefined()); - PropertyDescriptor desc1(thread); + PropertyDescriptor desc1(thread_); desc1.SetGetter(JSHandle::Cast(getter)); desc1.SetSetter(JSHandle::Cast(setter)); desc1.SetConfigurable(true); desc1.SetEnumerable(true); - bool success1 = JSObject::DefineOwnProperty(thread, obj, key, desc1); + bool success1 = JSObject::DefineOwnProperty(thread_, obj, key, desc1); EXPECT_TRUE(success1); - PropertyDescriptor desc2(thread); + PropertyDescriptor desc2(thread_); desc2.SetGetter(un_getter); - bool success2 = JSObject::DefineOwnProperty(thread, obj, key, desc2); + bool success2 = JSObject::DefineOwnProperty(thread_, obj, key, desc2); EXPECT_TRUE(success2); - PropertyDescriptor desc(thread); - bool success = JSObject::GetOwnProperty(thread, obj, key, desc); + PropertyDescriptor desc(thread_); + bool success = JSObject::GetOwnProperty(thread_, obj, key, desc); EXPECT_TRUE(success); EXPECT_TRUE(desc.GetSetter()->IsJSFunction()); EXPECT_TRUE(desc.GetGetter()->IsUndefined()); @@ -759,245 +765,245 @@ TEST_F(JSObjectTest, GetterIsUndefined) TEST_F(JSObjectTest, SetterIsUndefined) { - JSHandle dynclass1(thread, JSObjectTestCreate(thread)); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + JSHandle dynclass1(thread_, JSObjectTestCreate(thread_)); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle obj = factory->NewJSObjectByConstructor(JSHandle(dynclass1), dynclass1); JSHandle key(factory->NewFromString("property")); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle getter = - thread->GetEcmaVM()->GetFactory()->NewJSFunction(env, reinterpret_cast(TestUndefinedGetter)); + thread_->GetEcmaVM()->GetFactory()->NewJSFunction(env, reinterpret_cast(TestUndefinedGetter)); JSHandle setter = - thread->GetEcmaVM()->GetFactory()->NewJSFunction(env, reinterpret_cast(TestUndefinedSetter)); - JSHandle un_setter(thread, JSTaggedValue::Undefined()); + thread_->GetEcmaVM()->GetFactory()->NewJSFunction(env, reinterpret_cast(TestUndefinedSetter)); + JSHandle un_setter(thread_, JSTaggedValue::Undefined()); - PropertyDescriptor desc1(thread); + PropertyDescriptor desc1(thread_); desc1.SetGetter(JSHandle::Cast(getter)); desc1.SetSetter(JSHandle::Cast(setter)); desc1.SetConfigurable(true); desc1.SetEnumerable(true); - bool success1 = JSObject::DefineOwnProperty(thread, obj, key, desc1); + bool success1 = JSObject::DefineOwnProperty(thread_, obj, key, desc1); EXPECT_TRUE(success1); - PropertyDescriptor desc2(thread); + PropertyDescriptor desc2(thread_); desc2.SetSetter(un_setter); - bool success2 = JSObject::DefineOwnProperty(thread, obj, key, desc2); + bool success2 = JSObject::DefineOwnProperty(thread_, obj, key, desc2); EXPECT_TRUE(success2); - PropertyDescriptor desc(thread); - bool success = JSObject::GetOwnProperty(thread, obj, key, desc); + PropertyDescriptor desc(thread_); + bool success = JSObject::GetOwnProperty(thread_, obj, key, desc); EXPECT_TRUE(success); EXPECT_TRUE(desc.GetSetter()->IsUndefined()); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(obj), key).GetValue().GetTaggedValue(), + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(obj), key).GetValue().GetTaggedValue(), JSTaggedValue(10)); } TEST_F(JSObjectTest, HClass) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle obj_func(thread, JSObjectTestCreate(thread)); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle obj_func(thread_, JSObjectTestCreate(thread_)); JSHandle obj1 = factory->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); - JSHandle hc0(thread, obj1->GetJSHClass()); + JSHandle hc0(thread_, obj1->GetJSHClass()); JSHandle key1(factory->NewFromCanBeCompressString("x")); JSHandle key2(factory->NewFromCanBeCompressString("y")); JSHandle key3(factory->NewFromCanBeCompressString("z")); - JSHandle value(thread, JSTaggedValue(1)); + JSHandle value(thread_, JSTaggedValue(1)); - JSObject::SetProperty(thread, JSHandle(obj1), key1, value); - JSHandle hc1(thread, obj1->GetJSHClass()); + JSObject::SetProperty(thread_, JSHandle(obj1), key1, value); + JSHandle hc1(thread_, obj1->GetJSHClass()); EXPECT_NE(hc0.GetTaggedValue(), hc1.GetTaggedValue()); EXPECT_EQ(hc0.GetTaggedValue(), hc1->GetParent()); - JSObject::SetProperty(thread, JSHandle(obj1), key2, value); - JSHandle hc2(thread, obj1->GetJSHClass()); + JSObject::SetProperty(thread_, JSHandle(obj1), key2, value); + JSHandle hc2(thread_, obj1->GetJSHClass()); EXPECT_NE(hc1.GetTaggedValue(), hc2.GetTaggedValue()); EXPECT_EQ(hc1.GetTaggedValue(), hc2->GetParent()); JSHandle obj2 = factory->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); EXPECT_EQ(hc0.GetTaggedValue().GetTaggedObject(), obj2->GetJSHClass()); - JSObject::SetProperty(thread, JSHandle(obj2), key1, value); + JSObject::SetProperty(thread_, JSHandle(obj2), key1, value); EXPECT_EQ(hc1.GetTaggedValue().GetTaggedObject(), obj2->GetJSHClass()); - JSObject::SetProperty(thread, JSHandle(obj2), key3, value); - JSHandle hc3(thread, obj2->GetJSHClass()); + JSObject::SetProperty(thread_, JSHandle(obj2), key3, value); + JSHandle hc3(thread_, obj2->GetJSHClass()); EXPECT_NE(hc1.GetTaggedValue().GetTaggedObject(), obj2->GetJSHClass()); EXPECT_EQ(hc1.GetTaggedValue(), obj2->GetJSHClass()->GetParent()); JSHandle obj3 = factory->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); EXPECT_EQ(hc0.GetTaggedValue().GetTaggedObject(), obj3->GetJSHClass()); - JSObject::SetProperty(thread, JSHandle(obj3), key1, value); + JSObject::SetProperty(thread_, JSHandle(obj3), key1, value); EXPECT_EQ(hc1.GetTaggedValue().GetTaggedObject(), obj3->GetJSHClass()); - JSObject::SetProperty(thread, JSHandle(obj3), key2, value); + JSObject::SetProperty(thread_, JSHandle(obj3), key2, value); EXPECT_EQ(hc2.GetTaggedValue().GetTaggedObject(), obj3->GetJSHClass()); - JSObject::SetProperty(thread, JSHandle(obj3), key3, value); + JSObject::SetProperty(thread_, JSHandle(obj3), key3, value); EXPECT_NE(hc3.GetTaggedValue().GetTaggedObject(), obj3->GetJSHClass()); EXPECT_EQ(hc2.GetTaggedValue(), obj3->GetJSHClass()->GetParent()); } TEST_F(JSObjectTest, FastToSlow) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); ObjectFactory *factory = ecma_vm->GetFactory(); - JSHandle obj_func(thread, JSObjectTestCreate(thread)); + JSHandle obj_func(thread_, JSObjectTestCreate(thread_)); JSHandle obj1 = factory->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); JSMutableHandle key(factory->NewFromCanBeCompressString("x")); - JSMutableHandle number(thread, JSTaggedValue(0)); - JSMutableHandle newkey(thread, JSTaggedValue(0)); - JSHandle value(thread, JSTaggedValue(1)); + JSMutableHandle number(thread_, JSTaggedValue(0)); + JSMutableHandle newkey(thread_, JSTaggedValue(0)); + JSHandle value(thread_, JSTaggedValue(1)); for (uint32_t i = 0; i < PropertyAttributes::MAX_CAPACITY_OF_PROPERTIES; i++) { number.Update(JSTaggedValue(i)); - number.Update(JSTaggedValue::ToString(thread, number).GetTaggedValue()); - EcmaString *new_string = *factory->ConcatFromString(key, JSTaggedValue::ToString(thread, number)); + number.Update(JSTaggedValue::ToString(thread_, number).GetTaggedValue()); + EcmaString *new_string = *factory->ConcatFromString(key, JSTaggedValue::ToString(thread_, number)); newkey.Update(JSTaggedValue(new_string)); - JSObject::SetProperty(thread, JSHandle(obj1), newkey, value); + JSObject::SetProperty(thread_, JSHandle(obj1), newkey, value); } EXPECT_FALSE(TaggedArray::Cast(obj1->GetProperties().GetTaggedObject())->IsDictionaryMode()); number.Update(JSTaggedValue(PropertyAttributes::MAX_CAPACITY_OF_PROPERTIES)); - number.Update(JSTaggedValue::ToString(thread, number).GetTaggedValue()); - EcmaString *new_string = *factory->ConcatFromString(key, JSTaggedValue::ToString(thread, number)); + number.Update(JSTaggedValue::ToString(thread_, number).GetTaggedValue()); + EcmaString *new_string = *factory->ConcatFromString(key, JSTaggedValue::ToString(thread_, number)); newkey.Update(JSTaggedValue(new_string)); - JSObject::SetProperty(thread, JSHandle(obj1), newkey, value); + JSObject::SetProperty(thread_, JSHandle(obj1), newkey, value); EXPECT_TRUE(TaggedArray::Cast(obj1->GetProperties().GetTaggedObject())->IsDictionaryMode()); NameDictionary *dict = NameDictionary::Cast(obj1->GetProperties().GetTaggedObject()); EXPECT_EQ(dict->EntriesCount(), PropertyAttributes::MAX_CAPACITY_OF_PROPERTIES + 1); - EXPECT_EQ(dict->NextEnumerationIndex(thread), PropertyAttributes::MAX_CAPACITY_OF_PROPERTIES + 1); + EXPECT_EQ(dict->NextEnumerationIndex(thread_), PropertyAttributes::MAX_CAPACITY_OF_PROPERTIES + 1); } TEST_F(JSObjectTest, DeleteMiddle) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); ObjectFactory *factory = ecma_vm->GetFactory(); - JSHandle obj_func(thread, JSObjectTestCreate(thread)); + JSHandle obj_func(thread_, JSObjectTestCreate(thread_)); JSHandle obj1 = factory->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); JSMutableHandle key(factory->NewFromCanBeCompressString("x")); - JSMutableHandle number(thread, JSTaggedValue(0)); - JSMutableHandle newkey(thread, JSTaggedValue(0)); - JSHandle value(thread, JSTaggedValue(1)); + JSMutableHandle number(thread_, JSTaggedValue(0)); + JSMutableHandle newkey(thread_, JSTaggedValue(0)); + JSHandle value(thread_, JSTaggedValue(1)); for (uint32_t i = 0; i < 10; i++) { number.Update(JSTaggedValue(i)); - number.Update(JSTaggedValue::ToString(thread, number).GetTaggedValue()); - EcmaString *new_string = *factory->ConcatFromString(key, JSTaggedValue::ToString(thread, number)); + number.Update(JSTaggedValue::ToString(thread_, number).GetTaggedValue()); + EcmaString *new_string = *factory->ConcatFromString(key, JSTaggedValue::ToString(thread_, number)); newkey.Update(JSTaggedValue(new_string)); - JSObject::SetProperty(thread, JSHandle(obj1), newkey, value); + JSObject::SetProperty(thread_, JSHandle(obj1), newkey, value); } EXPECT_FALSE(TaggedArray::Cast(obj1->GetProperties().GetTaggedObject())->IsDictionaryMode()); JSMutableHandle key5(factory->NewFromCanBeCompressString("x5")); - JSObject::DeleteProperty(thread, (obj1), key5); + JSObject::DeleteProperty(thread_, (obj1), key5); EXPECT_TRUE(TaggedArray::Cast(obj1->GetProperties().GetTaggedObject())->IsDictionaryMode()); NameDictionary *dict = NameDictionary::Cast(obj1->GetProperties().GetTaggedObject()); EXPECT_EQ(dict->EntriesCount(), 9); - EXPECT_FALSE(JSObject::HasProperty(thread, obj1, key5)); + EXPECT_FALSE(JSObject::HasProperty(thread_, obj1, key5)); } TEST_F(JSObjectTest, ElementFastToSlow) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle obj_func(thread, JSObjectTestCreate(thread)); - JSHandle key0(thread, JSTaggedValue(0)); - JSHandle key1(thread, JSTaggedValue(1)); - JSHandle key2(thread, JSTaggedValue(2)); - JSHandle key2000(thread, JSTaggedValue(2000)); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle obj_func(thread_, JSObjectTestCreate(thread_)); + JSHandle key0(thread_, JSTaggedValue(0)); + JSHandle key1(thread_, JSTaggedValue(1)); + JSHandle key2(thread_, JSTaggedValue(2)); + JSHandle key2000(thread_, JSTaggedValue(2000)); JSHandle key_str(factory->NewFromCanBeCompressString("str")); // test dictionary [0,1,2,...,2000] JSHandle obj1 = factory->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); EXPECT_TRUE(!TaggedArray::Cast(obj1->GetElements().GetTaggedObject())->IsDictionaryMode()); - JSObject::SetProperty(thread, JSHandle(obj1), key_str, key2); - JSObject::SetProperty(thread, JSHandle(obj1), key0, key0); + JSObject::SetProperty(thread_, JSHandle(obj1), key_str, key2); + JSObject::SetProperty(thread_, JSHandle(obj1), key0, key0); EXPECT_TRUE(!TaggedArray::Cast(obj1->GetElements().GetTaggedObject())->IsDictionaryMode()); - JSHandle dyn_class(thread, obj1->GetJSHClass()); - JSObject::SetProperty(thread, JSHandle(obj1), key1, key1); + JSHandle dyn_class(thread_, obj1->GetJSHClass()); + JSObject::SetProperty(thread_, JSHandle(obj1), key1, key1); EXPECT_TRUE(!TaggedArray::Cast(obj1->GetElements().GetTaggedObject())->IsDictionaryMode()); EXPECT_EQ(obj1->GetJSHClass(), *dyn_class); - JSObject::SetProperty(thread, JSHandle(obj1), key2000, key2000); + JSObject::SetProperty(thread_, JSHandle(obj1), key2000, key2000); EXPECT_TRUE(TaggedArray::Cast(obj1->GetElements().GetTaggedObject())->IsDictionaryMode()); JSTaggedValue value = - JSObject::GetProperty(thread, JSHandle(obj1), key_str).GetValue().GetTaggedValue(); + JSObject::GetProperty(thread_, JSHandle(obj1), key_str).GetValue().GetTaggedValue(); EXPECT_EQ(value, key2.GetTaggedValue()); // test holey [0,,2] JSHandle obj2 = factory->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); - JSObject::SetProperty(thread, JSHandle(obj2), key0, key0); + JSObject::SetProperty(thread_, JSHandle(obj2), key0, key0); EXPECT_TRUE(!TaggedArray::Cast(obj2->GetElements().GetTaggedObject())->IsDictionaryMode()); - JSHandle dyn_class2(thread, obj2->GetJSHClass()); - JSObject::SetProperty(thread, JSHandle(obj2), key2, key2); + JSHandle dyn_class2(thread_, obj2->GetJSHClass()); + JSObject::SetProperty(thread_, JSHandle(obj2), key2, key2); EXPECT_TRUE(!TaggedArray::Cast(obj2->GetElements().GetTaggedObject())->IsDictionaryMode()); EXPECT_EQ(obj2->GetJSHClass(), *dyn_class2); // test change attr JSHandle obj3 = factory->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); - JSObject::SetProperty(thread, JSHandle(obj3), key0, key0); - JSObject::SetProperty(thread, JSHandle(obj3), key1, key1); - JSObject::SetProperty(thread, JSHandle(obj3), key2, key2); + JSObject::SetProperty(thread_, JSHandle(obj3), key0, key0); + JSObject::SetProperty(thread_, JSHandle(obj3), key1, key1); + JSObject::SetProperty(thread_, JSHandle(obj3), key2, key2); EXPECT_TRUE(!TaggedArray::Cast(obj3->GetElements().GetTaggedObject())->IsDictionaryMode()); - PropertyDescriptor desc(thread); + PropertyDescriptor desc(thread_); desc.SetValue(key1); desc.SetWritable(false); - JSObject::DefineOwnProperty(thread, obj3, key1, desc); + JSObject::DefineOwnProperty(thread_, obj3, key1, desc); EXPECT_TRUE(TaggedArray::Cast(obj3->GetElements().GetTaggedObject())->IsDictionaryMode()); // test delete element JSHandle obj4 = factory->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); - JSObject::SetProperty(thread, JSHandle(obj4), key0, key0); - JSObject::SetProperty(thread, JSHandle(obj4), key1, key1); - JSObject::SetProperty(thread, JSHandle(obj4), key2, key2); + JSObject::SetProperty(thread_, JSHandle(obj4), key0, key0); + JSObject::SetProperty(thread_, JSHandle(obj4), key1, key1); + JSObject::SetProperty(thread_, JSHandle(obj4), key2, key2); EXPECT_TRUE(!TaggedArray::Cast(obj4->GetElements().GetTaggedObject())->IsDictionaryMode()); - JSObject::DeleteProperty(thread, (obj4), key1); + JSObject::DeleteProperty(thread_, (obj4), key1); EXPECT_TRUE(TaggedArray::Cast(obj4->GetElements().GetTaggedObject())->IsDictionaryMode()); - JSHandle value1001(thread, JSTaggedValue(1001)); + JSHandle value1001(thread_, JSTaggedValue(1001)); JSHandle obj100 = factory->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); - PropertyDescriptor desc1(thread); + PropertyDescriptor desc1(thread_); desc1.SetValue(value1001); desc1.SetWritable(false); desc1.SetEnumerable(false); desc1.SetConfigurable(false); - JSObject::SetProperty(thread, JSHandle(obj100), key0, key1); - JSObject::DefineOwnProperty(thread, obj100, key0, desc1); + JSObject::SetProperty(thread_, JSHandle(obj100), key0, key1); + JSObject::DefineOwnProperty(thread_, obj100, key0, desc1); JSTaggedValue result1001 = - JSObject::GetProperty(thread, JSHandle(obj100), key0).GetValue().GetTaggedValue(); + JSObject::GetProperty(thread_, JSHandle(obj100), key0).GetValue().GetTaggedValue(); EXPECT_EQ(result1001, value1001.GetTaggedValue()); } TEST_F(JSObjectTest, EnableProtoChangeMarker) { - JSHandle null_handle(thread, JSTaggedValue::Null()); - JSHandle obj1 = JSObject::ObjectCreate(thread, null_handle); - JSHandle obj2 = JSObject::ObjectCreate(thread, obj1); - JSHandle obj3 = JSObject::ObjectCreate(thread, obj2); - - JSHandle obj1_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key1")); - JSHandle obj2_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key2")); - JSHandle obj3_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key3")); - JSHandle obj1_value(thread, JSTaggedValue(1)); - JSHandle obj2_value(thread, JSTaggedValue(2)); - JSHandle obj3_value(thread, JSTaggedValue(3)); - - JSObject::SetProperty(thread, JSHandle(obj1), obj1_key, obj1_value); - JSObject::SetProperty(thread, JSHandle(obj2), obj2_key, obj2_value); - JSObject::SetProperty(thread, JSHandle(obj3), obj3_key, obj3_value); - JSHandle obj3_dynclass(thread, obj3->GetJSHClass()); - JSHandle result_marker = JSHClass::EnableProtoChangeMarker(thread, obj3_dynclass); + JSHandle null_handle(thread_, JSTaggedValue::Null()); + JSHandle obj1 = JSObject::ObjectCreate(thread_, null_handle); + JSHandle obj2 = JSObject::ObjectCreate(thread_, obj1); + JSHandle obj3 = JSObject::ObjectCreate(thread_, obj2); + + JSHandle obj1_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key1")); + JSHandle obj2_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key2")); + JSHandle obj3_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key3")); + JSHandle obj1_value(thread_, JSTaggedValue(1)); + JSHandle obj2_value(thread_, JSTaggedValue(2)); + JSHandle obj3_value(thread_, JSTaggedValue(3)); + + JSObject::SetProperty(thread_, JSHandle(obj1), obj1_key, obj1_value); + JSObject::SetProperty(thread_, JSHandle(obj2), obj2_key, obj2_value); + JSObject::SetProperty(thread_, JSHandle(obj3), obj3_key, obj3_value); + JSHandle obj3_dynclass(thread_, obj3->GetJSHClass()); + JSHandle result_marker = JSHClass::EnableProtoChangeMarker(thread_, obj3_dynclass); EXPECT_TRUE(result_marker->IsProtoChangeMarker()); bool has_changed = ProtoChangeMarker::Cast(result_marker->GetTaggedObject())->GetHasChanged(); EXPECT_TRUE(!has_changed); - JSHandle obj1_dynclass(thread, obj1->GetJSHClass()); - JSHandle obj2_dynclass(thread, obj2->GetJSHClass()); + JSHandle obj1_dynclass(thread_, obj1->GetJSHClass()); + JSHandle obj2_dynclass(thread_, obj2->GetJSHClass()); JSTaggedValue obj2_marker = obj2_dynclass->GetProtoChangeMarker(); EXPECT_TRUE(obj2_marker.IsProtoChangeMarker()); bool has_changed2 = ProtoChangeMarker::Cast(obj2_marker.GetTaggedObject())->GetHasChanged(); @@ -1021,49 +1027,49 @@ TEST_F(JSObjectTest, EnableProtoChangeMarker) TEST_F(JSObjectTest, BuildRegisterTree) { - JSHandle null_handle(thread, JSTaggedValue::Null()); - JSHandle obj1 = JSObject::ObjectCreate(thread, null_handle); - JSHandle obj2 = JSObject::ObjectCreate(thread, obj1); - JSHandle obj3 = JSObject::ObjectCreate(thread, obj2); - JSHandle obj4 = JSObject::ObjectCreate(thread, obj2); - JSHandle obj5 = JSObject::ObjectCreate(thread, obj4); - JSHandle obj6 = JSObject::ObjectCreate(thread, obj2); - JSHandle obj7 = JSObject::ObjectCreate(thread, obj6); - - JSHandle obj1_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key1")); - JSHandle obj2_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key2")); - JSHandle obj3_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key3")); - JSHandle obj4_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key4")); - JSHandle obj5_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key5")); - JSHandle obj6_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key6")); - JSHandle obj7_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key7")); - - JSHandle obj1_value(thread, JSTaggedValue(1)); - JSHandle obj2_value(thread, JSTaggedValue(2)); - JSHandle obj3_value(thread, JSTaggedValue(3)); - JSHandle obj4_value(thread, JSTaggedValue(4)); - JSHandle obj5_value(thread, JSTaggedValue(5)); - JSHandle obj6_value(thread, JSTaggedValue(6)); - JSHandle obj7_value(thread, JSTaggedValue(7)); - - JSObject::SetProperty(thread, JSHandle(obj1), obj1_key, obj1_value); - JSObject::SetProperty(thread, JSHandle(obj2), obj2_key, obj2_value); - JSObject::SetProperty(thread, JSHandle(obj3), obj3_key, obj3_value); - JSObject::SetProperty(thread, JSHandle(obj4), obj4_key, obj4_value); - JSObject::SetProperty(thread, JSHandle(obj5), obj5_key, obj5_value); - JSObject::SetProperty(thread, JSHandle(obj6), obj6_key, obj6_value); - JSObject::SetProperty(thread, JSHandle(obj7), obj7_key, obj7_value); - - JSHandle obj1_dynclass(thread, obj1->GetJSHClass()); - JSHandle obj2_dynclass(thread, obj2->GetJSHClass()); - JSHandle obj3_dynclass(thread, obj3->GetJSHClass()); - JSHandle obj4_dynclass(thread, obj4->GetJSHClass()); - JSHandle obj5_dynclass(thread, obj5->GetJSHClass()); - JSHandle obj6_dynclass(thread, obj6->GetJSHClass()); - JSHandle obj7_dynclass(thread, obj7->GetJSHClass()); - - JSHandle result3_marker = JSHClass::EnableProtoChangeMarker(thread, obj3_dynclass); - JSHandle result5_marker = JSHClass::EnableProtoChangeMarker(thread, obj5_dynclass); + JSHandle null_handle(thread_, JSTaggedValue::Null()); + JSHandle obj1 = JSObject::ObjectCreate(thread_, null_handle); + JSHandle obj2 = JSObject::ObjectCreate(thread_, obj1); + JSHandle obj3 = JSObject::ObjectCreate(thread_, obj2); + JSHandle obj4 = JSObject::ObjectCreate(thread_, obj2); + JSHandle obj5 = JSObject::ObjectCreate(thread_, obj4); + JSHandle obj6 = JSObject::ObjectCreate(thread_, obj2); + JSHandle obj7 = JSObject::ObjectCreate(thread_, obj6); + + JSHandle obj1_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key1")); + JSHandle obj2_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key2")); + JSHandle obj3_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key3")); + JSHandle obj4_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key4")); + JSHandle obj5_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key5")); + JSHandle obj6_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key6")); + JSHandle obj7_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key7")); + + JSHandle obj1_value(thread_, JSTaggedValue(1)); + JSHandle obj2_value(thread_, JSTaggedValue(2)); + JSHandle obj3_value(thread_, JSTaggedValue(3)); + JSHandle obj4_value(thread_, JSTaggedValue(4)); + JSHandle obj5_value(thread_, JSTaggedValue(5)); + JSHandle obj6_value(thread_, JSTaggedValue(6)); + JSHandle obj7_value(thread_, JSTaggedValue(7)); + + JSObject::SetProperty(thread_, JSHandle(obj1), obj1_key, obj1_value); + JSObject::SetProperty(thread_, JSHandle(obj2), obj2_key, obj2_value); + JSObject::SetProperty(thread_, JSHandle(obj3), obj3_key, obj3_value); + JSObject::SetProperty(thread_, JSHandle(obj4), obj4_key, obj4_value); + JSObject::SetProperty(thread_, JSHandle(obj5), obj5_key, obj5_value); + JSObject::SetProperty(thread_, JSHandle(obj6), obj6_key, obj6_value); + JSObject::SetProperty(thread_, JSHandle(obj7), obj7_key, obj7_value); + + JSHandle obj1_dynclass(thread_, obj1->GetJSHClass()); + JSHandle obj2_dynclass(thread_, obj2->GetJSHClass()); + JSHandle obj3_dynclass(thread_, obj3->GetJSHClass()); + JSHandle obj4_dynclass(thread_, obj4->GetJSHClass()); + JSHandle obj5_dynclass(thread_, obj5->GetJSHClass()); + JSHandle obj6_dynclass(thread_, obj6->GetJSHClass()); + JSHandle obj7_dynclass(thread_, obj7->GetJSHClass()); + + JSHandle result3_marker = JSHClass::EnableProtoChangeMarker(thread_, obj3_dynclass); + JSHandle result5_marker = JSHClass::EnableProtoChangeMarker(thread_, obj5_dynclass); EXPECT_TRUE(result3_marker->IsProtoChangeMarker()); EXPECT_TRUE(!(ProtoChangeMarker::Cast(result3_marker->GetTaggedObject())->GetHasChanged())); EXPECT_TRUE(result5_marker->IsProtoChangeMarker()); @@ -1072,7 +1078,7 @@ TEST_F(JSObjectTest, BuildRegisterTree) EXPECT_TRUE(obj4_dynclass->GetProtoChangeMarker().IsProtoChangeMarker()); EXPECT_TRUE(!obj6_dynclass->GetProtoChangeMarker().IsProtoChangeMarker()); - JSHandle result7_marker = JSHClass::EnableProtoChangeMarker(thread, obj7_dynclass); + JSHandle result7_marker = JSHClass::EnableProtoChangeMarker(thread_, obj7_dynclass); EXPECT_TRUE(result7_marker->IsProtoChangeMarker()); EXPECT_TRUE(!(ProtoChangeMarker::Cast(result7_marker->GetTaggedObject())->GetHasChanged())); @@ -1080,7 +1086,7 @@ TEST_F(JSObjectTest, BuildRegisterTree) EXPECT_TRUE(proto_details1.IsProtoChangeDetails()); JSTaggedValue listeners1_value = ProtoChangeDetails::Cast(proto_details1.GetTaggedObject())->GetChangeListener(); EXPECT_TRUE(listeners1_value != JSTaggedValue(0)); - JSHandle listeners1(thread, listeners1_value.GetTaggedObject()); + JSHandle listeners1(thread_, listeners1_value.GetTaggedObject()); JSTaggedValue proto_details2 = obj2_dynclass->GetProtoChangeDetails(); EXPECT_TRUE(proto_details2.IsProtoChangeDetails()); JSTaggedValue index2 = ProtoChangeDetails::Cast(proto_details2.GetTaggedObject())->GetRegisterIndex(); @@ -1088,7 +1094,7 @@ TEST_F(JSObjectTest, BuildRegisterTree) JSTaggedValue listeners2_value = ProtoChangeDetails::Cast(proto_details2.GetTaggedObject())->GetChangeListener(); EXPECT_TRUE(listeners2_value != JSTaggedValue(0)); - JSHandle listeners2(thread, listeners2_value.GetTaggedObject()); + JSHandle listeners2(thread_, listeners2_value.GetTaggedObject()); JSTaggedValue proto_details4 = obj4_dynclass->GetProtoChangeDetails(); JSTaggedValue proto_details6 = obj6_dynclass->GetProtoChangeDetails(); EXPECT_TRUE(proto_details4.IsProtoChangeDetails()); @@ -1104,58 +1110,58 @@ TEST_F(JSObjectTest, BuildRegisterTree) TEST_F(JSObjectTest, NoticeThroughChain) { - JSHandle null_handle(thread, JSTaggedValue::Null()); - JSHandle obj1 = JSObject::ObjectCreate(thread, null_handle); - JSHandle obj2 = JSObject::ObjectCreate(thread, obj1); - JSHandle obj3 = JSObject::ObjectCreate(thread, obj2); - JSHandle obj4 = JSObject::ObjectCreate(thread, obj2); - JSHandle obj5 = JSObject::ObjectCreate(thread, obj4); - JSHandle obj6 = JSObject::ObjectCreate(thread, obj2); - JSHandle obj7 = JSObject::ObjectCreate(thread, obj6); - - JSHandle obj1_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key1")); - JSHandle obj2_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key2")); - JSHandle obj3_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key3")); - JSHandle obj4_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key4")); - JSHandle obj5_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key5")); - JSHandle obj6_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key6")); - JSHandle obj7_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key7")); - - JSHandle obj1_value(thread, JSTaggedValue(1)); - JSHandle obj2_value(thread, JSTaggedValue(2)); - JSHandle obj3_value(thread, JSTaggedValue(3)); - JSHandle obj4_value(thread, JSTaggedValue(4)); - JSHandle obj5_value(thread, JSTaggedValue(5)); - JSHandle obj6_value(thread, JSTaggedValue(6)); - JSHandle obj7_value(thread, JSTaggedValue(7)); - - JSObject::SetProperty(thread, JSHandle(obj1), obj1_key, obj1_value); - JSObject::SetProperty(thread, JSHandle(obj2), obj2_key, obj2_value); - JSObject::SetProperty(thread, JSHandle(obj3), obj3_key, obj3_value); - JSObject::SetProperty(thread, JSHandle(obj4), obj4_key, obj4_value); - JSObject::SetProperty(thread, JSHandle(obj5), obj5_key, obj5_value); - JSObject::SetProperty(thread, JSHandle(obj6), obj6_key, obj6_value); - JSObject::SetProperty(thread, JSHandle(obj7), obj7_key, obj7_value); - - JSHandle obj1_dynclass(thread, obj1->GetJSHClass()); - JSHandle obj2_dynclass(thread, obj2->GetJSHClass()); - JSHandle obj3_dynclass(thread, obj3->GetJSHClass()); - JSHandle obj4_dynclass(thread, obj4->GetJSHClass()); - JSHandle obj5_dynclass(thread, obj5->GetJSHClass()); - JSHandle obj6_dynclass(thread, obj6->GetJSHClass()); - JSHandle obj7_dynclass(thread, obj7->GetJSHClass()); - - JSHClass::EnableProtoChangeMarker(thread, obj3_dynclass); - JSHClass::EnableProtoChangeMarker(thread, obj7_dynclass); - JSHClass::EnableProtoChangeMarker(thread, obj5_dynclass); - - JSHClass::NoticeThroughChain(thread, obj2_dynclass); - JSHClass::UnregisterOnProtoChain(thread, obj2_dynclass); + JSHandle null_handle(thread_, JSTaggedValue::Null()); + JSHandle obj1 = JSObject::ObjectCreate(thread_, null_handle); + JSHandle obj2 = JSObject::ObjectCreate(thread_, obj1); + JSHandle obj3 = JSObject::ObjectCreate(thread_, obj2); + JSHandle obj4 = JSObject::ObjectCreate(thread_, obj2); + JSHandle obj5 = JSObject::ObjectCreate(thread_, obj4); + JSHandle obj6 = JSObject::ObjectCreate(thread_, obj2); + JSHandle obj7 = JSObject::ObjectCreate(thread_, obj6); + + JSHandle obj1_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key1")); + JSHandle obj2_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key2")); + JSHandle obj3_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key3")); + JSHandle obj4_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key4")); + JSHandle obj5_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key5")); + JSHandle obj6_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key6")); + JSHandle obj7_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key7")); + + JSHandle obj1_value(thread_, JSTaggedValue(1)); + JSHandle obj2_value(thread_, JSTaggedValue(2)); + JSHandle obj3_value(thread_, JSTaggedValue(3)); + JSHandle obj4_value(thread_, JSTaggedValue(4)); + JSHandle obj5_value(thread_, JSTaggedValue(5)); + JSHandle obj6_value(thread_, JSTaggedValue(6)); + JSHandle obj7_value(thread_, JSTaggedValue(7)); + + JSObject::SetProperty(thread_, JSHandle(obj1), obj1_key, obj1_value); + JSObject::SetProperty(thread_, JSHandle(obj2), obj2_key, obj2_value); + JSObject::SetProperty(thread_, JSHandle(obj3), obj3_key, obj3_value); + JSObject::SetProperty(thread_, JSHandle(obj4), obj4_key, obj4_value); + JSObject::SetProperty(thread_, JSHandle(obj5), obj5_key, obj5_value); + JSObject::SetProperty(thread_, JSHandle(obj6), obj6_key, obj6_value); + JSObject::SetProperty(thread_, JSHandle(obj7), obj7_key, obj7_value); + + JSHandle obj1_dynclass(thread_, obj1->GetJSHClass()); + JSHandle obj2_dynclass(thread_, obj2->GetJSHClass()); + JSHandle obj3_dynclass(thread_, obj3->GetJSHClass()); + JSHandle obj4_dynclass(thread_, obj4->GetJSHClass()); + JSHandle obj5_dynclass(thread_, obj5->GetJSHClass()); + JSHandle obj6_dynclass(thread_, obj6->GetJSHClass()); + JSHandle obj7_dynclass(thread_, obj7->GetJSHClass()); + + JSHClass::EnableProtoChangeMarker(thread_, obj3_dynclass); + JSHClass::EnableProtoChangeMarker(thread_, obj7_dynclass); + JSHClass::EnableProtoChangeMarker(thread_, obj5_dynclass); + + JSHClass::NoticeThroughChain(thread_, obj2_dynclass); + JSHClass::UnregisterOnProtoChain(thread_, obj2_dynclass); JSTaggedValue proto_details1 = obj1_dynclass->GetProtoChangeDetails(); EXPECT_TRUE(proto_details1.IsProtoChangeDetails()); JSTaggedValue listeners1_value = ProtoChangeDetails::Cast(proto_details1.GetTaggedObject())->GetChangeListener(); EXPECT_TRUE(listeners1_value != JSTaggedValue(0)); - JSHandle listeners1(thread, listeners1_value.GetTaggedObject()); + JSHandle listeners1(thread_, listeners1_value.GetTaggedObject()); uint32_t hole_index = ChangeListener::CheckHole(listeners1); EXPECT_TRUE(hole_index == 0); @@ -1179,52 +1185,52 @@ TEST_F(JSObjectTest, NoticeThroughChain) TEST_F(JSObjectTest, ChangeProtoAndNoticeTheChain) { - JSHandle null_handle(thread, JSTaggedValue::Null()); - JSHandle obj1 = JSObject::ObjectCreate(thread, null_handle); - JSHandle obj2 = JSObject::ObjectCreate(thread, obj1); - JSHandle obj3 = JSObject::ObjectCreate(thread, obj1); - JSHandle obj4 = JSObject::ObjectCreate(thread, obj2); - JSHandle obj5 = JSObject::ObjectCreate(thread, obj4); - JSHandle obj6 = JSObject::ObjectCreate(thread, obj2); - JSHandle obj7 = JSObject::ObjectCreate(thread, obj6); - - JSHandle obj1_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key1")); - JSHandle obj2_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key2")); - JSHandle obj3_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key3")); - JSHandle obj4_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key4")); - JSHandle obj5_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key5")); - JSHandle obj6_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key6")); - JSHandle obj7_key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key7")); - - JSHandle obj1_value(thread, JSTaggedValue(1)); - JSHandle obj2_value(thread, JSTaggedValue(2)); - JSHandle obj3_value(thread, JSTaggedValue(3)); - JSHandle obj4_value(thread, JSTaggedValue(4)); - JSHandle obj5_value(thread, JSTaggedValue(5)); - JSHandle obj6_value(thread, JSTaggedValue(6)); - JSHandle obj7_value(thread, JSTaggedValue(7)); - - JSObject::SetProperty(thread, JSHandle(obj1), obj1_key, obj1_value); - JSObject::SetProperty(thread, JSHandle(obj2), obj2_key, obj2_value); - JSObject::SetProperty(thread, JSHandle(obj3), obj3_key, obj3_value); - JSObject::SetProperty(thread, JSHandle(obj4), obj4_key, obj4_value); - JSObject::SetProperty(thread, JSHandle(obj5), obj5_key, obj5_value); - JSObject::SetProperty(thread, JSHandle(obj6), obj6_key, obj6_value); - JSObject::SetProperty(thread, JSHandle(obj7), obj7_key, obj7_value); - - JSHandle obj5_dynclass(thread, obj5->GetJSHClass()); - JSHandle obj7_dynclass(thread, obj7->GetJSHClass()); - - JSHClass::EnableProtoChangeMarker(thread, obj7_dynclass); - JSHClass::EnableProtoChangeMarker(thread, obj5_dynclass); - - JSObject::SetPrototype(thread, obj2, JSHandle(obj3)); - - JSHandle obj1_dynclass(thread, obj1->GetJSHClass()); - JSHandle obj2_dynclass(thread, obj2->GetJSHClass()); - JSHandle obj3_dynclass(thread, obj3->GetJSHClass()); - JSHandle obj4_dynclass(thread, obj4->GetJSHClass()); - JSHandle obj6_dynclass(thread, obj6->GetJSHClass()); + JSHandle null_handle(thread_, JSTaggedValue::Null()); + JSHandle obj1 = JSObject::ObjectCreate(thread_, null_handle); + JSHandle obj2 = JSObject::ObjectCreate(thread_, obj1); + JSHandle obj3 = JSObject::ObjectCreate(thread_, obj1); + JSHandle obj4 = JSObject::ObjectCreate(thread_, obj2); + JSHandle obj5 = JSObject::ObjectCreate(thread_, obj4); + JSHandle obj6 = JSObject::ObjectCreate(thread_, obj2); + JSHandle obj7 = JSObject::ObjectCreate(thread_, obj6); + + JSHandle obj1_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key1")); + JSHandle obj2_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key2")); + JSHandle obj3_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key3")); + JSHandle obj4_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key4")); + JSHandle obj5_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key5")); + JSHandle obj6_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key6")); + JSHandle obj7_key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("key7")); + + JSHandle obj1_value(thread_, JSTaggedValue(1)); + JSHandle obj2_value(thread_, JSTaggedValue(2)); + JSHandle obj3_value(thread_, JSTaggedValue(3)); + JSHandle obj4_value(thread_, JSTaggedValue(4)); + JSHandle obj5_value(thread_, JSTaggedValue(5)); + JSHandle obj6_value(thread_, JSTaggedValue(6)); + JSHandle obj7_value(thread_, JSTaggedValue(7)); + + JSObject::SetProperty(thread_, JSHandle(obj1), obj1_key, obj1_value); + JSObject::SetProperty(thread_, JSHandle(obj2), obj2_key, obj2_value); + JSObject::SetProperty(thread_, JSHandle(obj3), obj3_key, obj3_value); + JSObject::SetProperty(thread_, JSHandle(obj4), obj4_key, obj4_value); + JSObject::SetProperty(thread_, JSHandle(obj5), obj5_key, obj5_value); + JSObject::SetProperty(thread_, JSHandle(obj6), obj6_key, obj6_value); + JSObject::SetProperty(thread_, JSHandle(obj7), obj7_key, obj7_value); + + JSHandle obj5_dynclass(thread_, obj5->GetJSHClass()); + JSHandle obj7_dynclass(thread_, obj7->GetJSHClass()); + + JSHClass::EnableProtoChangeMarker(thread_, obj7_dynclass); + JSHClass::EnableProtoChangeMarker(thread_, obj5_dynclass); + + JSObject::SetPrototype(thread_, obj2, JSHandle(obj3)); + + JSHandle obj1_dynclass(thread_, obj1->GetJSHClass()); + JSHandle obj2_dynclass(thread_, obj2->GetJSHClass()); + JSHandle obj3_dynclass(thread_, obj3->GetJSHClass()); + JSHandle obj4_dynclass(thread_, obj4->GetJSHClass()); + JSHandle obj6_dynclass(thread_, obj6->GetJSHClass()); JSTaggedValue obj6_marker = obj6_dynclass->GetProtoChangeMarker(); EXPECT_TRUE(obj6_marker.IsProtoChangeMarker()); @@ -1272,8 +1278,8 @@ TEST_F(JSObjectTest, ChangeProtoAndNoticeTheChain) TEST_F(JSObjectTest, NativePointerField) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle obj_func(thread, JSObjectTestCreate(thread)); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle obj_func(thread_, JSObjectTestCreate(thread_)); JSHandle obj = factory->NewJSObjectByConstructor(JSHandle(obj_func), obj_func); obj->SetHash(87); EXPECT_TRUE(obj->GetHash() == 87); @@ -1286,4 +1292,7 @@ TEST_F(JSObjectTest, NativePointerField) void *pointer = obj->GetNativePointerField(0); EXPECT_TRUE(pointer == array); } + +// NOLINTEND(modernize-avoid-c-arrays,readability-magic-numbers) + } // namespace panda::test