From 82c5a742f956160475a38d32f433902ee940b7f9 Mon Sep 17 00:00:00 2001 From: Aleksandr Semenov Date: Wed, 31 May 2023 19:37:47 +0300 Subject: [PATCH] Clang-tidy: fix naming style for ecmasript Signed-off-by: Aleksandr Semenov --- .../code_generator/compiler_base_types.cpp | 20 +- .../ecmascript_inst_builder_gen.cpp.erb | 12 +- ecmastdlib/ecmastdlib_inline_gen.h.erb | 6 +- runtime/builtins/builtins_object.cpp | 6 + runtime/builtins/builtins_runtime_testing.cpp | 1 + .../templates/builtins_declaration_gen.h.erb | 4 + .../templates/builtins_initializers_gen.h.erb | 4 + tests/runtime/common/builtins_test.cpp | 44 +- tests/runtime/common/ecma_module_test.cpp | 248 +++--- tests/runtime/common/ecma_string_test.cpp | 432 +++++------ tests/runtime/common/glue_regs_test.cpp | 18 +- tests/runtime/common/huge_object_test.cpp | 20 +- tests/runtime/common/js_arguments_test.cpp | 120 +-- .../runtime/common/js_array_iterator_test.cpp | 8 +- tests/runtime/common/js_array_test.cpp | 158 ++-- tests/runtime/common/js_dataview_test.cpp | 56 +- tests/runtime/common/js_date_test.cpp | 14 +- .../runtime/common/js_forin_iterator_test.cpp | 52 +- tests/runtime/common/js_handle_test.cpp | 64 +- tests/runtime/common/js_iterator_test.cpp | 96 +-- tests/runtime/common/js_map_test.cpp | 94 +-- .../runtime/common/js_primitive_ref_test.cpp | 26 +- tests/runtime/common/js_promise_test.cpp | 56 +- tests/runtime/common/js_proxy_test.cpp | 350 ++++----- tests/runtime/common/js_set_iterator_test.cpp | 46 +- tests/runtime/common/js_set_test.cpp | 74 +- tests/runtime/common/js_symbol_test.cpp | 10 +- tests/runtime/common/js_tagged_queue_test.cpp | 38 +- tests/runtime/common/js_typed_array_test.cpp | 661 ++++++++-------- tests/runtime/common/large_object_test.cpp | 22 +- tests/runtime/common/lexical_env_test.cpp | 12 +- .../runtime/common/linked_hash_table_test.cpp | 76 +- tests/runtime/common/name_dictionary_test.cpp | 62 +- tests/runtime/common/native_pointer_test.cpp | 18 +- tests/runtime/common/object_factory_test.cpp | 62 +- tests/runtime/common/symbol_table_test.cpp | 72 +- tests/runtime/common/tagged_value_test.cpp | 710 +++++++++--------- tests/runtime/mem/g1gc_barrier_test.cpp | 16 +- tests/runtime/regexp/dyn_buffer_test.cpp | 10 +- 39 files changed, 1912 insertions(+), 1886 deletions(-) diff --git a/compiler/optimizer/code_generator/compiler_base_types.cpp b/compiler/optimizer/code_generator/compiler_base_types.cpp index 7e5f562ed..af1d20051 100644 --- a/compiler/optimizer/code_generator/compiler_base_types.cpp +++ b/compiler/optimizer/code_generator/compiler_base_types.cpp @@ -54,12 +54,12 @@ static void CompareAnyTypeGenDouble(Encoder *enc, Reg dst, Reg src, profiling::A auto jump = not_number_label != LabelHolder::INVALID_LABEL; ASSERT(allowed_input_type == profiling::AnyInputType::DEFAULT || jump); if (allowed_input_type == profiling::AnyInputType::SPECIAL_INT) { - constexpr auto min_object = coretypes::TaggedValue::VALUE_UNDEFINED + 1; - constexpr auto min_number = 1ULL << coretypes::TaggedValue::TAG_BITS_SHIFT; - static_assert(coretypes::TaggedValue::VALUE_TRUE < min_object); - static_assert(coretypes::TaggedValue::TAG_EXCEPTION >= min_object); - enc->EncodeSub(dst_ext, src, Imm(min_object)); - enc->EncodeJump(not_number_label, dst_ext, Imm(min_number - min_object), Condition::LO); + constexpr auto MIN_OBJECT = coretypes::TaggedValue::VALUE_UNDEFINED + 1; + constexpr auto MIN_NUMBER = 1ULL << coretypes::TaggedValue::TAG_BITS_SHIFT; + static_assert(coretypes::TaggedValue::VALUE_TRUE < MIN_OBJECT); + static_assert(coretypes::TaggedValue::TAG_EXCEPTION >= MIN_OBJECT); + enc->EncodeSub(dst_ext, src, Imm(MIN_OBJECT)); + enc->EncodeJump(not_number_label, dst_ext, Imm(MIN_NUMBER - MIN_OBJECT), Condition::LO); return; } if (allowed_input_type == profiling::AnyInputType::INTEGER) { @@ -102,16 +102,16 @@ static void CompareAnyTypeGenInt(Encoder *enc, Reg dst, Reg src, profiling::AnyI return; } ASSERT(allowed_input_type == profiling::AnyInputType::SPECIAL); - constexpr auto min_fail = coretypes::TaggedValue::VALUE_UNDEFINED; + constexpr auto MIN_FAIL = coretypes::TaggedValue::VALUE_UNDEFINED; // accept values < VALUE_UNDEFINED or >= TAG_INT auto dst_ext = dst.As(TypeInfo(TypeInfo::TypeId::INT64)); - enc->EncodeSub(dst_ext, src, Imm(min_fail)); + enc->EncodeSub(dst_ext, src, Imm(MIN_FAIL)); if (id == LabelHolder::INVALID_LABEL) { ScopedTmpReg reg_cmp(enc, TypeInfo(TypeInfo::TypeId::INT64)); - enc->EncodeMov(reg_cmp, Imm(coretypes::TaggedValue::TAG_INT - min_fail)); + enc->EncodeMov(reg_cmp, Imm(coretypes::TaggedValue::TAG_INT - MIN_FAIL)); enc->EncodeCompare(dst_ext, dst_ext, reg_cmp, Condition::HS); } else { - enc->EncodeJump(id, dst_ext, Imm(coretypes::TaggedValue::TAG_INT - min_fail), Condition::LO); + enc->EncodeJump(id, dst_ext, Imm(coretypes::TaggedValue::TAG_INT - MIN_FAIL), Condition::LO); } } diff --git a/compiler/templates/ecmascript_inst_builder_gen.cpp.erb b/compiler/templates/ecmascript_inst_builder_gen.cpp.erb index 8bb59f742..ad0498f06 100644 --- a/compiler/templates/ecmascript_inst_builder_gen.cpp.erb +++ b/compiler/templates/ecmascript_inst_builder_gen.cpp.erb @@ -76,7 +76,7 @@ void InstBuilder::BuildEcma([[maybe_unused]] const BytecodeInstruction* bc_inst) #endif } -template +template void InstBuilder::BuildEcmaAsIntrinsics(const BytecodeInstruction* bc_inst) // NOLINT(readability-function-size) { switch (bc_inst->GetOpcode()) { @@ -148,7 +148,7 @@ void InstBuilder::BuildEcmaAsIntrinsics(const BytecodeInstruction* bc_inst) // N inst->ReserveInputs(args_count); inst->AllocateInputTypes(GetGraph()->GetAllocator(), args_count); // NOLINTNEXTLINE(readability-braces-around-statements, bugprone-suspicious-semicolon) - if constexpr (with_speculative) { + if constexpr (WITH_SPECULATIVE) { inst->SetInlined(true); } @@ -168,7 +168,7 @@ void InstBuilder::BuildEcmaAsIntrinsics(const BytecodeInstruction* bc_inst) // N auto input = GetDefinition(bc_inst->GetVReg<<%= format %>, <%= vreg_index %>>()); % if has_profile && (inst.profile.properties.include?('operand_types_1') || inst.profile.properties.include?('operand_types_2')) // NOLINTNEXTLINE(readability-braces-around-statements, bugprone-suspicious-semicolon) - if constexpr (with_speculative) { + if constexpr (WITH_SPECULATIVE) { profiling::AnyInputType allowed_input_type {}; bool is_type_profiled = false; auto operand_type = GetRuntime()->GetProfilingAnyType(profile, bc_inst, <%= input_index %>, &allowed_input_type, &is_type_profiled); @@ -202,7 +202,7 @@ void InstBuilder::BuildEcmaAsIntrinsics(const BytecodeInstruction* bc_inst) // N if (!GetGraph()->IsBytecodeOptimizer()) { auto input = GetDefinition(GetGraph()->GetRuntime()->GetMethodRegistersCount(GetMethod()) + 1); // NOLINTNEXTLINE(readability-braces-around-statements, bugprone-suspicious-semicolon) - if constexpr (with_speculative) { + if constexpr (WITH_SPECULATIVE) { input = BuildAnyTypeCheckInst(GetPc(bc_inst->GetAddress()), input, inst_save_state); } inst->AppendInput(input); @@ -216,7 +216,7 @@ void InstBuilder::BuildEcmaAsIntrinsics(const BytecodeInstruction* bc_inst) // N for (uint32_t i = 1; i < <%= num_actual_vregs %>; ++i) { auto input = GetDefinition(start_reg + i); // NOLINTNEXTLINE(readability-braces-around-statements, bugprone-suspicious-semicolon) - if constexpr (with_speculative) { + if constexpr (WITH_SPECULATIVE) { input = BuildAnyTypeCheckInst(GetPc(bc_inst->GetAddress()), input, inst_save_state); } inst->AppendInput(input); @@ -229,7 +229,7 @@ void InstBuilder::BuildEcmaAsIntrinsics(const BytecodeInstruction* bc_inst) // N % if has_profile && (inst.profile.properties.include?('operand_types_1') || inst.profile.properties.include?('operand_types_2')) // NOLINTNEXTLINE(readability-braces-around-statements, bugprone-suspicious-semicolon) - if constexpr (with_speculative) { + if constexpr (WITH_SPECULATIVE) { profiling::AnyInputType allowed_input_type {}; bool is_type_profiled = false; % idx = inst.profile.properties.include?('operand_types_2') ? 1 : 0 diff --git a/ecmastdlib/ecmastdlib_inline_gen.h.erb b/ecmastdlib/ecmastdlib_inline_gen.h.erb index 3028c6e9a..00e9dfff5 100644 --- a/ecmastdlib/ecmastdlib_inline_gen.h.erb +++ b/ecmastdlib/ecmastdlib_inline_gen.h.erb @@ -18,7 +18,7 @@ namespace panda::ecmascript::ecmastdlib_inline { inline unsigned char const* GetEcmastdlibData(size_t &fsize) { // NOLINTNEXTLINE(modernize-avoid-c-arrays) - static unsigned char const data[] = + static unsigned char const DATA[] = { % if file_exist @@ -32,12 +32,12 @@ inline unsigned char const* GetEcmastdlibData(size_t &fsize) }; % if file_exist - fsize = sizeof(data); + fsize = sizeof(DATA); % else fsize = 0; % end - return data; + return DATA; } } // namespace panda::ecmascript::ecmastdlib_inline diff --git a/runtime/builtins/builtins_object.cpp b/runtime/builtins/builtins_object.cpp index 7ce19a230..d3c956855 100644 --- a/runtime/builtins/builtins_object.cpp +++ b/runtime/builtins/builtins_object.cpp @@ -952,6 +952,7 @@ JSTaggedValue object::proto::ValueOf(EcmaRuntimeCallInfo *argv) return object.GetTaggedValue(); } // B.2.2.1 Object.prototype.__proto__ +// NOLINTNEXLINE(readability-identifier-naming) JSTaggedValue object::proto::Get__proto__(EcmaRuntimeCallInfo *argv) { ASSERT(argv); @@ -969,6 +970,7 @@ JSTaggedValue object::proto::Get__proto__(EcmaRuntimeCallInfo *argv) return obj->GetPrototype(thread); } +// NOLINTNEXLINE(readability-identifier-naming) JSTaggedValue object::proto::Set__proto__(EcmaRuntimeCallInfo *argv) { ASSERT(argv); @@ -1009,6 +1011,7 @@ JSTaggedValue object::proto::Set__proto__(EcmaRuntimeCallInfo *argv) } // B.2.2.2 Object.prototype.__defineGetter__ ( P, getter ) +// NOLINTNEXLINE(readability-identifier-naming) JSTaggedValue object::proto::__defineGetter__(EcmaRuntimeCallInfo *argv) { ASSERT(argv); @@ -1045,6 +1048,7 @@ JSTaggedValue object::proto::__defineGetter__(EcmaRuntimeCallInfo *argv) } // B.2.2.3 Object.prototype.__defineSetter__ ( P, setter ) +// NOLINTNEXLINE(readability-identifier-naming) JSTaggedValue object::proto::__defineSetter__(EcmaRuntimeCallInfo *argv) { ASSERT(argv); @@ -1121,6 +1125,7 @@ static JSTaggedValue LookupDesc(EcmaRuntimeCallInfo *argv, } // B.2.2.4 Object.prototype.__lookupGetter__ ( P ) +// NOLINTNEXLINE(readability-identifier-naming) JSTaggedValue object::proto::__lookupGetter__(EcmaRuntimeCallInfo *argv) { return LookupDesc(argv, [](PropertyDescriptor desc) { @@ -1133,6 +1138,7 @@ JSTaggedValue object::proto::__lookupGetter__(EcmaRuntimeCallInfo *argv) } // B.2.2.5 Object.prototype.__lookupSetter__ ( P ) +// NOLINTNEXLINE(readability-identifier-naming) JSTaggedValue object::proto::__lookupSetter__(EcmaRuntimeCallInfo *argv) { return LookupDesc(argv, [](PropertyDescriptor desc) { diff --git a/runtime/builtins/builtins_runtime_testing.cpp b/runtime/builtins/builtins_runtime_testing.cpp index 98e7c4bc7..ede6f7175 100644 --- a/runtime/builtins/builtins_runtime_testing.cpp +++ b/runtime/builtins/builtins_runtime_testing.cpp @@ -211,6 +211,7 @@ JSTaggedValue runtime_testing::DeoptimizeNow([[maybe_unused]] EcmaRuntimeCallInf } // Not implemented +// NOLINTNEXLINE(readability-identifier-naming) JSTaggedValue runtime_testing::_DeoptimizeNow([[maybe_unused]] EcmaRuntimeCallInfo *argv) { JSThread *thread = argv->GetThread(); diff --git a/runtime/builtins/templates/builtins_declaration_gen.h.erb b/runtime/builtins/templates/builtins_declaration_gen.h.erb index 767bd8b51..b8f82d4eb 100644 --- a/runtime/builtins/templates/builtins_declaration_gen.h.erb +++ b/runtime/builtins/templates/builtins_declaration_gen.h.erb @@ -13,6 +13,8 @@ * limitations under the License. */ +// NOLINTBEGIN(readability-identifier-naming) + % Builtins.spaces.each do |space| namespace <%= space.name.snakecase %> { // <%= space.name %> NOLINT(modernize-concat-nested-namespaces) % space.properties.each do |property| @@ -50,3 +52,5 @@ namespace <%= ispace.name.snakecase %> { // <%= ispace.name %> } // namespace <%= ispace.name.snakecase %> % end + +// NOLINTEND(readability-identifier-naming) diff --git a/runtime/builtins/templates/builtins_initializers_gen.h.erb b/runtime/builtins/templates/builtins_initializers_gen.h.erb index 5730919a2..cce9c0c5a 100644 --- a/runtime/builtins/templates/builtins_initializers_gen.h.erb +++ b/runtime/builtins/templates/builtins_initializers_gen.h.erb @@ -13,6 +13,8 @@ * limitations under the License. */ +// NOLINTBEGIN(readability-identifier-naming) + % Builtins.spaces.each do |space| % if (space.methods.length + space.setters.length + space.getters.length) > 0 void SetFunctionsGen<%= space.name %>(const JSHandle &env, const JSHandle &<%= space.name.snakecase %>_func) const @@ -45,3 +47,5 @@ void SetFunctionsGen<%= space.name %>Proto(const JSHandle &env, cons % end % end + +// NOLINTEND(readability-identifier-naming) diff --git a/tests/runtime/common/builtins_test.cpp b/tests/runtime/common/builtins_test.cpp index 8ee26afb1..4aea2d3d7 100644 --- a/tests/runtime/common/builtins_test.cpp +++ b/tests/runtime/common/builtins_test.cpp @@ -36,27 +36,27 @@ class BuiltinsTest : 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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {}; + JSThread *thread_ {}; private: - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; TEST_F(BuiltinsTest, ObjectInit) { - ASSERT_NE(thread, nullptr); - auto ecma_vm = thread->GetEcmaVM(); + ASSERT_NE(thread_, nullptr); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle object_function(env->GetObjectFunction()); @@ -65,8 +65,8 @@ TEST_F(BuiltinsTest, ObjectInit) TEST_F(BuiltinsTest, FunctionInit) { - ASSERT_NE(thread, nullptr); - auto ecma_vm = thread->GetEcmaVM(); + ASSERT_NE(thread_, nullptr); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle function_function(env->GetFunctionFunction()); @@ -75,8 +75,8 @@ TEST_F(BuiltinsTest, FunctionInit) TEST_F(BuiltinsTest, NumberInit) { - ASSERT_NE(thread, nullptr); - auto ecma_vm = thread->GetEcmaVM(); + ASSERT_NE(thread_, nullptr); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle number_function(env->GetNumberFunction()); @@ -85,8 +85,8 @@ TEST_F(BuiltinsTest, NumberInit) TEST_F(BuiltinsTest, SetInit) { - ASSERT_NE(thread, nullptr); - auto ecma_vm = thread->GetEcmaVM(); + ASSERT_NE(thread_, nullptr); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle set_function(env->GetSetFunction()); @@ -95,8 +95,8 @@ TEST_F(BuiltinsTest, SetInit) TEST_F(BuiltinsTest, MapInit) { - ASSERT_NE(thread, nullptr); - auto ecma_vm = thread->GetEcmaVM(); + ASSERT_NE(thread_, nullptr); + auto ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle map_function(env->GetMapFunction()); @@ -105,21 +105,21 @@ TEST_F(BuiltinsTest, MapInit) TEST_F(BuiltinsTest, StrictModeForbiddenAccess) { - 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 function = factory->NewJSFunction(env, static_cast(nullptr)); JSHandle caller_key(factory->NewFromString("caller")); JSHandle arguments_key(factory->NewFromString("arguments")); - JSObject::GetProperty(thread, JSHandle(function), caller_key); - ASSERT_EQ(thread->HasPendingException(), true); + JSObject::GetProperty(thread_, JSHandle(function), caller_key); + ASSERT_EQ(thread_->HasPendingException(), true); - JSObject::GetProperty(thread, JSHandle(function), arguments_key); - ASSERT_EQ(thread->HasPendingException(), true); + JSObject::GetProperty(thread_, JSHandle(function), arguments_key); + ASSERT_EQ(thread_->HasPendingException(), true); } } // namespace panda::test diff --git a/tests/runtime/common/ecma_module_test.cpp b/tests/runtime/common/ecma_module_test.cpp index b1c802df6..d94d8ee74 100644 --- a/tests/runtime/common/ecma_module_test.cpp +++ b/tests/runtime/common/ecma_module_test.cpp @@ -44,21 +44,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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {nullptr}; + JSThread *thread_ {nullptr}; private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; EcmaModule *EcmaModuleCreate(JSThread *thread) @@ -81,15 +81,15 @@ TEST_F(EcmaModuleTest, AddItem_001) int num_of_elements_dict = 4; PandaString c_str_item_name = "key1"; int int_item_value = 1; - JSHandle handle_ecma_module(thread, EcmaModuleCreate(thread)); - JSHandle handle_name_dict(NameDictionary::Create(thread, num_of_elements_dict)); + JSHandle handle_ecma_module(thread_, EcmaModuleCreate(thread_)); + JSHandle handle_name_dict(NameDictionary::Create(thread_, num_of_elements_dict)); JSHandle handle_tag_val_item_name( - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(c_str_item_name)); - JSHandle handle_tag_val_item_value(thread, JSTaggedValue(int_item_value)); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(c_str_item_name)); + JSHandle handle_tag_val_item_value(thread_, JSTaggedValue(int_item_value)); - handle_ecma_module->SetNameDictionary(thread, handle_name_dict); // Call SetNameDictionary in TEST_F - EcmaModule::AddItem(thread, handle_ecma_module, handle_tag_val_item_name, handle_tag_val_item_value); - EXPECT_EQ(handle_ecma_module->GetItem(thread, handle_tag_val_item_name)->GetNumber(), int_item_value); + handle_ecma_module->SetNameDictionary(thread_, handle_name_dict); // Call SetNameDictionary in TEST_F + EcmaModule::AddItem(thread_, handle_ecma_module, handle_tag_val_item_name, handle_tag_val_item_value); + EXPECT_EQ(handle_ecma_module->GetItem(thread_, handle_tag_val_item_name)->GetNumber(), int_item_value); } /* @@ -104,14 +104,14 @@ TEST_F(EcmaModuleTest, AddItem_002) { PandaString c_str_item_name = "cStrItemName"; int int_item_value = 1; - JSHandle handle_ecma_module(thread, EcmaModuleCreate(thread)); + JSHandle handle_ecma_module(thread_, EcmaModuleCreate(thread_)); JSHandle handle_tag_val_item_name( - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(c_str_item_name)); - JSHandle handle_tag_val_item_value(thread, JSTaggedValue(int_item_value)); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(c_str_item_name)); + JSHandle handle_tag_val_item_value(thread_, JSTaggedValue(int_item_value)); // This EcmaModule calls 'SetNameDictionary' function through 'AddItem' function of "ecma_module.cpp". - EcmaModule::AddItem(thread, handle_ecma_module, handle_tag_val_item_name, handle_tag_val_item_value); - EXPECT_EQ(handle_ecma_module->GetItem(thread, handle_tag_val_item_name)->GetNumber(), int_item_value); + EcmaModule::AddItem(thread_, handle_ecma_module, handle_tag_val_item_name, handle_tag_val_item_value); + EXPECT_EQ(handle_ecma_module->GetItem(thread_, handle_tag_val_item_name)->GetNumber(), int_item_value); } /* @@ -125,17 +125,17 @@ TEST_F(EcmaModuleTest, AddItem_002) */ TEST_F(EcmaModuleTest, RemoveItem) { - ObjectFactory *obj_factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *obj_factory = thread_->GetEcmaVM()->GetFactory(); PandaString c_str_item_name = "cStrItemName"; int int_item_value = 1; - JSHandle handle_ecma_module(thread, EcmaModuleCreate(thread)); + JSHandle handle_ecma_module(thread_, EcmaModuleCreate(thread_)); JSHandle handle_tag_val_item_name(obj_factory->NewFromCanBeCompressString(c_str_item_name)); - JSHandle handle_tag_val_item_value(thread, JSTaggedValue(int_item_value)); + JSHandle handle_tag_val_item_value(thread_, JSTaggedValue(int_item_value)); - EcmaModule::AddItem(thread, handle_ecma_module, handle_tag_val_item_name, handle_tag_val_item_value); - EcmaModule::RemoveItem(thread, handle_ecma_module, handle_tag_val_item_name); - EXPECT_TRUE(handle_ecma_module->GetItem(thread, handle_tag_val_item_name)->IsUndefined()); + EcmaModule::AddItem(thread_, handle_ecma_module, handle_tag_val_item_name, handle_tag_val_item_value); + EcmaModule::RemoveItem(thread_, handle_ecma_module, handle_tag_val_item_name); + EXPECT_TRUE(handle_ecma_module->GetItem(thread_, handle_tag_val_item_name)->IsUndefined()); } /* @@ -151,23 +151,23 @@ TEST_F(EcmaModuleTest, RemoveItem) */ TEST_F(EcmaModuleTest, SetNameDictionary) { - ObjectFactory *obj_factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *obj_factory = thread_->GetEcmaVM()->GetFactory(); int num_of_elements_dict = 4; - JSHandle handle_name_dict(NameDictionary::Create(thread, num_of_elements_dict)); - JSHandle handle_obj_func = thread->GetEcmaVM()->GetGlobalEnv()->GetObjectFunction(); + JSHandle handle_name_dict(NameDictionary::Create(thread_, num_of_elements_dict)); + JSHandle handle_obj_func = thread_->GetEcmaVM()->GetGlobalEnv()->GetObjectFunction(); PandaString key_array1 = "hello1"; JSHandle string_key1 = obj_factory->NewFromCanBeCompressString(key_array1); JSHandle key1(string_key1); JSHandle value1( obj_factory->NewJSObjectByConstructor(JSHandle(handle_obj_func), handle_obj_func)); JSHandle handle_name_dictionary_from( - NameDictionary::Put(thread, handle_name_dict, key1, value1, PropertyAttributes::Default())); - JSHandle handle_ecma_module(thread, EcmaModuleCreate(thread)); + NameDictionary::Put(thread_, handle_name_dict, key1, value1, PropertyAttributes::Default())); + JSHandle handle_ecma_module(thread_, EcmaModuleCreate(thread_)); - handle_ecma_module->SetNameDictionary(thread, handle_name_dictionary_from); + handle_ecma_module->SetNameDictionary(thread_, handle_name_dictionary_from); JSHandle handle_name_dictionary_to( - thread, NameDictionary::Cast(handle_ecma_module->GetNameDictionary().GetTaggedObject())); + thread_, NameDictionary::Cast(handle_ecma_module->GetNameDictionary().GetTaggedObject())); EXPECT_EQ(handle_name_dictionary_to->EntriesCount(), 1); int entry1 = handle_name_dictionary_to->FindEntry(key1.GetTaggedValue()); EXPECT_TRUE(key1.GetTaggedValue() == handle_name_dictionary_to->GetKey(entry1)); @@ -185,8 +185,8 @@ TEST_F(EcmaModuleTest, SetNameDictionary) */ TEST_F(EcmaModuleTest, ModuleManager_AddModule) { - ObjectFactory *obj_factory = thread->GetEcmaVM()->GetFactory(); - ModuleManager *module_manager = thread->GetEcmaVM()->GetModuleManager(); + ObjectFactory *obj_factory = thread_->GetEcmaVM()->GetFactory(); + ModuleManager *module_manager = thread_->GetEcmaVM()->GetModuleManager(); int num_of_elements_dict1 = 4; int num_of_elements_dict2 = 4; @@ -194,26 +194,28 @@ TEST_F(EcmaModuleTest, ModuleManager_AddModule) PandaString c_str_item_name2 = "cStrItemName2"; int int_item_value1 = 1; int int_item_value2 = 2; - JSHandle handle_name_dict1(NameDictionary::Create(thread, num_of_elements_dict1)); - JSHandle handle_name_dict2(NameDictionary::Create(thread, num_of_elements_dict2)); + JSHandle handle_name_dict1(NameDictionary::Create(thread_, num_of_elements_dict1)); + JSHandle handle_name_dict2(NameDictionary::Create(thread_, num_of_elements_dict2)); JSHandle handle_item_name1( - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(c_str_item_name1)); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(c_str_item_name1)); JSHandle handle_item_name2( - thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(c_str_item_name2)); - JSHandle handle_item_value1(thread, JSTaggedValue(int_item_value1)); - JSHandle handle_item_value2(thread, JSTaggedValue(int_item_value2)); - JSHandle handle_ecma_module_add_from1(thread, EcmaModuleCreate(thread)); - JSHandle handle_ecma_module_add_from2(thread, EcmaModuleCreate(thread)); - handle_ecma_module_add_from1->SetNameDictionary(thread, handle_name_dict1); - handle_ecma_module_add_from2->SetNameDictionary(thread, handle_name_dict2); - - EcmaModule::AddItem(thread, handle_ecma_module_add_from1, handle_item_name1, handle_item_value1); - JSHandle handle_tag_val_ecma_module_add_from1(thread, handle_ecma_module_add_from1.GetTaggedValue()); + thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(c_str_item_name2)); + JSHandle handle_item_value1(thread_, JSTaggedValue(int_item_value1)); + JSHandle handle_item_value2(thread_, JSTaggedValue(int_item_value2)); + JSHandle handle_ecma_module_add_from1(thread_, EcmaModuleCreate(thread_)); + JSHandle handle_ecma_module_add_from2(thread_, EcmaModuleCreate(thread_)); + handle_ecma_module_add_from1->SetNameDictionary(thread_, handle_name_dict1); + handle_ecma_module_add_from2->SetNameDictionary(thread_, handle_name_dict2); + + EcmaModule::AddItem(thread_, handle_ecma_module_add_from1, handle_item_name1, handle_item_value1); + JSHandle handle_tag_val_ecma_module_add_from1(thread_, + handle_ecma_module_add_from1.GetTaggedValue()); std::string std_str_name_ecma_module_add1 = "NameEcmaModule1"; JSHandle handle_tag_val_name_ecma_module_add1( obj_factory->NewFromStdString(std_str_name_ecma_module_add1)); - EcmaModule::AddItem(thread, handle_ecma_module_add_from2, handle_item_name2, handle_item_value2); - JSHandle handle_tag_val_ecma_module_add_from2(thread, handle_ecma_module_add_from2.GetTaggedValue()); + EcmaModule::AddItem(thread_, handle_ecma_module_add_from2, handle_item_name2, handle_item_value2); + JSHandle handle_tag_val_ecma_module_add_from2(thread_, + handle_ecma_module_add_from2.GetTaggedValue()); std::string std_str_name_ecma_module_add2 = "NameEcmaModule2"; JSHandle handle_tag_val_name_ecma_module_add2( obj_factory->NewFromStdString(std_str_name_ecma_module_add2)); @@ -221,14 +223,14 @@ TEST_F(EcmaModuleTest, ModuleManager_AddModule) module_manager->AddModule(handle_tag_val_name_ecma_module_add1, handle_tag_val_ecma_module_add_from1); module_manager->AddModule(handle_tag_val_name_ecma_module_add2, handle_tag_val_ecma_module_add_from2); JSHandle handle_tag_val_ecma_module_get1 = - module_manager->GetModule(thread, handle_tag_val_name_ecma_module_add1); + module_manager->GetModule(thread_, handle_tag_val_name_ecma_module_add1); JSHandle handle_tag_val_ecma_module_get2 = - module_manager->GetModule(thread, handle_tag_val_name_ecma_module_add2); + module_manager->GetModule(thread_, handle_tag_val_name_ecma_module_add2); EXPECT_EQ( - JSHandle::Cast(handle_tag_val_ecma_module_get1)->GetItem(thread, handle_item_name1)->GetNumber(), + JSHandle::Cast(handle_tag_val_ecma_module_get1)->GetItem(thread_, handle_item_name1)->GetNumber(), int_item_value1); EXPECT_EQ( - JSHandle::Cast(handle_tag_val_ecma_module_get2)->GetItem(thread, handle_item_name2)->GetNumber(), + JSHandle::Cast(handle_tag_val_ecma_module_get2)->GetItem(thread_, handle_item_name2)->GetNumber(), int_item_value2); } @@ -244,8 +246,8 @@ TEST_F(EcmaModuleTest, ModuleManager_AddModule) */ TEST_F(EcmaModuleTest, ModuleManager_RemoveModule) { - ObjectFactory *obj_factory = thread->GetEcmaVM()->GetFactory(); - ModuleManager *module_manager = thread->GetEcmaVM()->GetModuleManager(); + ObjectFactory *obj_factory = thread_->GetEcmaVM()->GetFactory(); + ModuleManager *module_manager = thread_->GetEcmaVM()->GetModuleManager(); std::string std_str_name_ecma_module_add1 = "NameEcmaModule1"; std::string std_str_name_ecma_module_add2 = "NameEcmaModule2"; @@ -259,42 +261,42 @@ TEST_F(EcmaModuleTest, ModuleManager_RemoveModule) obj_factory->NewFromStdString(std_str_name_ecma_module_add2)); JSHandle handle_tag_val_item_name1(obj_factory->NewFromCanBeCompressString("name1")); JSHandle handle_tag_val_item_name2(obj_factory->NewFromCanBeCompressString("name2")); - JSHandle handle_tag_val_item_value1(thread, JSTaggedValue(int_item_value1)); - JSHandle handle_tag_val_item_value2(thread, JSTaggedValue(int_item_value2)); - JSHandle handle_ecma_module_add_from1(thread, EcmaModuleCreate(thread)); - JSHandle handle_ecma_module_add_from2(thread, EcmaModuleCreate(thread)); - JSHandle handle_name_dict1(NameDictionary::Create(thread, num_of_elements_dict1)); - JSHandle handle_name_dict2(NameDictionary::Create(thread, num_of_elements_dict2)); - handle_ecma_module_add_from1->SetNameDictionary(thread, handle_name_dict1); - handle_ecma_module_add_from2->SetNameDictionary(thread, handle_name_dict2); - EcmaModule::AddItem(thread, handle_ecma_module_add_from1, handle_tag_val_item_name1, handle_tag_val_item_value1); - EcmaModule::AddItem(thread, handle_ecma_module_add_from2, handle_tag_val_item_name2, handle_tag_val_item_value2); - JSHandle handle_tagged_value_ecma_module_add_from1(thread, + JSHandle handle_tag_val_item_value1(thread_, JSTaggedValue(int_item_value1)); + JSHandle handle_tag_val_item_value2(thread_, JSTaggedValue(int_item_value2)); + JSHandle handle_ecma_module_add_from1(thread_, EcmaModuleCreate(thread_)); + JSHandle handle_ecma_module_add_from2(thread_, EcmaModuleCreate(thread_)); + JSHandle handle_name_dict1(NameDictionary::Create(thread_, num_of_elements_dict1)); + JSHandle handle_name_dict2(NameDictionary::Create(thread_, num_of_elements_dict2)); + handle_ecma_module_add_from1->SetNameDictionary(thread_, handle_name_dict1); + handle_ecma_module_add_from2->SetNameDictionary(thread_, handle_name_dict2); + EcmaModule::AddItem(thread_, handle_ecma_module_add_from1, handle_tag_val_item_name1, handle_tag_val_item_value1); + EcmaModule::AddItem(thread_, handle_ecma_module_add_from2, handle_tag_val_item_name2, handle_tag_val_item_value2); + JSHandle handle_tagged_value_ecma_module_add_from1(thread_, handle_ecma_module_add_from1.GetTaggedValue()); - JSHandle handle_tagged_value_ecma_module_add_from2(thread, + JSHandle handle_tagged_value_ecma_module_add_from2(thread_, handle_ecma_module_add_from2.GetTaggedValue()); module_manager->AddModule(handle_tag_val_name_ecma_module_add1, handle_tagged_value_ecma_module_add_from1); module_manager->AddModule(handle_tag_val_name_ecma_module_add2, handle_tagged_value_ecma_module_add_from2); - EXPECT_EQ(JSHandle::Cast(module_manager->GetModule(thread, handle_tag_val_name_ecma_module_add1)) - ->GetItem(thread, handle_tag_val_item_name1) + EXPECT_EQ(JSHandle::Cast(module_manager->GetModule(thread_, handle_tag_val_name_ecma_module_add1)) + ->GetItem(thread_, handle_tag_val_item_name1) ->GetNumber(), int_item_value1); - EXPECT_EQ(JSHandle::Cast(module_manager->GetModule(thread, handle_tag_val_name_ecma_module_add2)) - ->GetItem(thread, handle_tag_val_item_name2) + EXPECT_EQ(JSHandle::Cast(module_manager->GetModule(thread_, handle_tag_val_name_ecma_module_add2)) + ->GetItem(thread_, handle_tag_val_item_name2) ->GetNumber(), int_item_value2); module_manager->RemoveModule(handle_tag_val_name_ecma_module_add1); - EXPECT_TRUE(module_manager->GetModule(thread, handle_tag_val_name_ecma_module_add1)->IsUndefined()); - EXPECT_EQ(JSHandle::Cast(module_manager->GetModule(thread, handle_tag_val_name_ecma_module_add2)) - ->GetItem(thread, handle_tag_val_item_name2) + EXPECT_TRUE(module_manager->GetModule(thread_, handle_tag_val_name_ecma_module_add1)->IsUndefined()); + EXPECT_EQ(JSHandle::Cast(module_manager->GetModule(thread_, handle_tag_val_name_ecma_module_add2)) + ->GetItem(thread_, handle_tag_val_item_name2) ->GetNumber(), int_item_value2); module_manager->RemoveModule(handle_tag_val_name_ecma_module_add2); - EXPECT_TRUE(module_manager->GetModule(thread, handle_tag_val_name_ecma_module_add1)->IsUndefined()); - EXPECT_TRUE(module_manager->GetModule(thread, handle_tag_val_name_ecma_module_add2)->IsUndefined()); + EXPECT_TRUE(module_manager->GetModule(thread_, handle_tag_val_name_ecma_module_add1)->IsUndefined()); + EXPECT_TRUE(module_manager->GetModule(thread_, handle_tag_val_name_ecma_module_add2)->IsUndefined()); } /* @@ -308,7 +310,7 @@ TEST_F(EcmaModuleTest, ModuleManager_RemoveModule) */ TEST_F(EcmaModuleTest, ModuleManager_SetCurrentExportModuleName) { - ModuleManager *module_manager = thread->GetEcmaVM()->GetModuleManager(); + ModuleManager *module_manager = thread_->GetEcmaVM()->GetModuleManager(); std::string_view str_view_name_ecma_module1 = "NameEcmaModule1"; std::string_view str_view_name_ecma_module2 = "NameEcmaModule2"; @@ -329,7 +331,7 @@ TEST_F(EcmaModuleTest, ModuleManager_SetCurrentExportModuleName) */ TEST_F(EcmaModuleTest, ModuleManager_GetPrevExportModuleName) { - ModuleManager *module_manager = thread->GetEcmaVM()->GetModuleManager(); + ModuleManager *module_manager = thread_->GetEcmaVM()->GetModuleManager(); std::string_view str_view_name_ecma_module1 = "NameEcmaModule1"; std::string_view str_view_name_ecma_module2 = "NameEcmaModule2"; @@ -353,7 +355,7 @@ TEST_F(EcmaModuleTest, ModuleManager_GetPrevExportModuleName) */ TEST_F(EcmaModuleTest, ModuleManager_RestoreCurrentExportModuleName) { - ModuleManager *module_manager = thread->GetEcmaVM()->GetModuleManager(); + ModuleManager *module_manager = thread_->GetEcmaVM()->GetModuleManager(); std::string_view str_view_name_ecma_module1 = "NameEcmaModule1"; std::string_view str_view_name_ecma_module2 = "NameEcmaModule2"; @@ -380,8 +382,8 @@ TEST_F(EcmaModuleTest, ModuleManager_RestoreCurrentExportModuleName) */ TEST_F(EcmaModuleTest, ModuleManager_AddModuleItem) { - ObjectFactory *obj_factory = thread->GetEcmaVM()->GetFactory(); - ModuleManager *module_manager = thread->GetEcmaVM()->GetModuleManager(); + ObjectFactory *obj_factory = thread_->GetEcmaVM()->GetFactory(); + ModuleManager *module_manager = thread_->GetEcmaVM()->GetModuleManager(); constexpr int INT_ITEM_VALUE_11 = 11; constexpr int INT_ITEM_VALUE_12 = 12; @@ -391,10 +393,10 @@ TEST_F(EcmaModuleTest, ModuleManager_AddModuleItem) JSHandle handle_tag_val_item_name12(obj_factory->NewFromCanBeCompressString("cStrItemName12")); JSHandle handle_tag_val_item_name21(obj_factory->NewFromCanBeCompressString("cStrItemName21")); JSHandle handle_tag_val_item_name22(obj_factory->NewFromCanBeCompressString("cStrItemName22")); - JSHandle handle_tag_val_item_value11(thread, JSTaggedValue(INT_ITEM_VALUE_11)); - JSHandle handle_tag_val_item_value12(thread, JSTaggedValue(INT_ITEM_VALUE_12)); - JSHandle handle_tag_val_item_value21(thread, JSTaggedValue(INT_ITEM_VALUE_21)); - JSHandle handle_tag_val_item_value22(thread, JSTaggedValue(INT_ITEM_VALUE_22)); + JSHandle handle_tag_val_item_value11(thread_, JSTaggedValue(INT_ITEM_VALUE_11)); + JSHandle handle_tag_val_item_value12(thread_, JSTaggedValue(INT_ITEM_VALUE_12)); + JSHandle handle_tag_val_item_value21(thread_, JSTaggedValue(INT_ITEM_VALUE_21)); + JSHandle handle_tag_val_item_value22(thread_, JSTaggedValue(INT_ITEM_VALUE_22)); JSHandle handle_ecma_str_name_ecma_module1 = obj_factory->NewFromString("cStrNameEcmaModule1"); JSHandle handle_ecma_str_name_ecma_module2 = obj_factory->NewFromString("cStrNameEcmaModule2"); std::string std_str_module_file_name1 = JSLocale::ConvertToStdString(handle_ecma_str_name_ecma_module1); @@ -403,38 +405,38 @@ TEST_F(EcmaModuleTest, ModuleManager_AddModuleItem) JSHandle handle_tag_val_ecma_module_name2(handle_ecma_str_name_ecma_module2); // Test when the module is created through 'NewEmptyEcmaModule' function called at TEST_F. - JSHandle handle_ecma_module1(thread, EcmaModuleCreate(thread)); - JSHandle handle_tag_val_ecma_module1(thread, handle_ecma_module1.GetTaggedValue()); + JSHandle handle_ecma_module1(thread_, EcmaModuleCreate(thread_)); + JSHandle handle_tag_val_ecma_module1(thread_, handle_ecma_module1.GetTaggedValue()); module_manager->AddModule(handle_tag_val_ecma_module_name1, handle_tag_val_ecma_module1); module_manager->SetCurrentExportModuleName(std_str_module_file_name1); - module_manager->AddModuleItem(thread, handle_tag_val_item_name11, handle_tag_val_item_value11); - module_manager->AddModuleItem(thread, handle_tag_val_item_name12, handle_tag_val_item_value12); + module_manager->AddModuleItem(thread_, handle_tag_val_item_name11, handle_tag_val_item_value11); + module_manager->AddModuleItem(thread_, handle_tag_val_item_name12, handle_tag_val_item_value12); EXPECT_EQ( - module_manager->GetModuleItem(thread, handle_tag_val_ecma_module1, handle_tag_val_item_name11)->GetNumber(), + module_manager->GetModuleItem(thread_, handle_tag_val_ecma_module1, handle_tag_val_item_name11)->GetNumber(), INT_ITEM_VALUE_11); EXPECT_EQ( - module_manager->GetModuleItem(thread, handle_tag_val_ecma_module1, handle_tag_val_item_name12)->GetNumber(), + module_manager->GetModuleItem(thread_, handle_tag_val_ecma_module1, handle_tag_val_item_name12)->GetNumber(), INT_ITEM_VALUE_12); // Test when the module is created through 'NewEmptyEcmaModule' function called at "ecma_module.cpp". module_manager->SetCurrentExportModuleName(std_str_module_file_name2); - module_manager->AddModuleItem(thread, handle_tag_val_item_name21, handle_tag_val_item_value21); - module_manager->AddModuleItem(thread, handle_tag_val_item_name22, handle_tag_val_item_value22); + module_manager->AddModuleItem(thread_, handle_tag_val_item_name21, handle_tag_val_item_value21); + module_manager->AddModuleItem(thread_, handle_tag_val_item_name22, handle_tag_val_item_value22); JSHandle handle_tag_val_ecma_module2 = - module_manager->GetModule(thread, handle_tag_val_ecma_module_name2); + module_manager->GetModule(thread_, handle_tag_val_ecma_module_name2); EXPECT_EQ( - module_manager->GetModuleItem(thread, handle_tag_val_ecma_module1, handle_tag_val_item_name11)->GetNumber(), + module_manager->GetModuleItem(thread_, handle_tag_val_ecma_module1, handle_tag_val_item_name11)->GetNumber(), INT_ITEM_VALUE_11); EXPECT_EQ( - module_manager->GetModuleItem(thread, handle_tag_val_ecma_module1, handle_tag_val_item_name12)->GetNumber(), + module_manager->GetModuleItem(thread_, handle_tag_val_ecma_module1, handle_tag_val_item_name12)->GetNumber(), INT_ITEM_VALUE_12); EXPECT_EQ( - module_manager->GetModuleItem(thread, handle_tag_val_ecma_module2, handle_tag_val_item_name21)->GetNumber(), + module_manager->GetModuleItem(thread_, handle_tag_val_ecma_module2, handle_tag_val_item_name21)->GetNumber(), INT_ITEM_VALUE_21); EXPECT_EQ( - module_manager->GetModuleItem(thread, handle_tag_val_ecma_module2, handle_tag_val_item_name22)->GetNumber(), + module_manager->GetModuleItem(thread_, handle_tag_val_ecma_module2, handle_tag_val_item_name22)->GetNumber(), INT_ITEM_VALUE_22); } @@ -450,8 +452,8 @@ TEST_F(EcmaModuleTest, ModuleManager_AddModuleItem) */ TEST_F(EcmaModuleTest, ModuleManager_CopyModule) { - ObjectFactory *obj_factory = thread->GetEcmaVM()->GetFactory(); - ModuleManager *module_manager = thread->GetEcmaVM()->GetModuleManager(); + ObjectFactory *obj_factory = thread_->GetEcmaVM()->GetFactory(); + ModuleManager *module_manager = thread_->GetEcmaVM()->GetModuleManager(); constexpr int INT_ITEM_VALUE_11 = 11; constexpr int INT_ITEM_VALUE_12 = 12; @@ -463,47 +465,53 @@ TEST_F(EcmaModuleTest, ModuleManager_CopyModule) JSHandle handle_tag_val_item_name12(obj_factory->NewFromCanBeCompressString("ItemName12")); JSHandle handle_tag_val_item_name21(obj_factory->NewFromCanBeCompressString("ItemName21")); JSHandle handle_tag_val_item_name22(obj_factory->NewFromCanBeCompressString("ItemName22")); - JSHandle handle_tag_val_item_value11(thread, JSTaggedValue(INT_ITEM_VALUE_11)); - JSHandle handle_tag_val_item_value12(thread, JSTaggedValue(INT_ITEM_VALUE_12)); - JSHandle handle_tag_val_item_value21(thread, JSTaggedValue(INT_ITEM_VALUE_21)); - JSHandle handle_tag_val_item_value22(thread, JSTaggedValue(INT_ITEM_VALUE_22)); - JSHandle handle_ecma_module_copy_from1(thread, EcmaModuleCreate(thread)); - JSHandle handle_ecma_module_copy_from2(thread, EcmaModuleCreate(thread)); - JSHandle handle_tag_val_ecma_module_copy_from1(thread, + JSHandle handle_tag_val_item_value11(thread_, JSTaggedValue(INT_ITEM_VALUE_11)); + JSHandle handle_tag_val_item_value12(thread_, JSTaggedValue(INT_ITEM_VALUE_12)); + JSHandle handle_tag_val_item_value21(thread_, JSTaggedValue(INT_ITEM_VALUE_21)); + JSHandle handle_tag_val_item_value22(thread_, JSTaggedValue(INT_ITEM_VALUE_22)); + JSHandle handle_ecma_module_copy_from1(thread_, EcmaModuleCreate(thread_)); + JSHandle handle_ecma_module_copy_from2(thread_, EcmaModuleCreate(thread_)); + JSHandle handle_tag_val_ecma_module_copy_from1(thread_, handle_ecma_module_copy_from1.GetTaggedValue()); - JSHandle handle_tag_val_ecma_module_copy_from2(thread, + JSHandle handle_tag_val_ecma_module_copy_from2(thread_, handle_ecma_module_copy_from2.GetTaggedValue()); - EcmaModule::AddItem(thread, handle_ecma_module_copy_from1, handle_tag_val_item_name11, handle_tag_val_item_value11); - EcmaModule::AddItem(thread, handle_ecma_module_copy_from1, handle_tag_val_item_name12, handle_tag_val_item_value12); - EcmaModule::AddItem(thread, handle_ecma_module_copy_from2, handle_tag_val_item_name21, handle_tag_val_item_value21); - EcmaModule::AddItem(thread, handle_ecma_module_copy_from2, handle_tag_val_item_name22, handle_tag_val_item_value22); + EcmaModule::AddItem(thread_, handle_ecma_module_copy_from1, handle_tag_val_item_name11, + handle_tag_val_item_value11); + EcmaModule::AddItem(thread_, handle_ecma_module_copy_from1, handle_tag_val_item_name12, + handle_tag_val_item_value12); + EcmaModule::AddItem(thread_, handle_ecma_module_copy_from2, handle_tag_val_item_name21, + handle_tag_val_item_value21); + EcmaModule::AddItem(thread_, handle_ecma_module_copy_from2, handle_tag_val_item_name22, + handle_tag_val_item_value22); module_manager->SetCurrentExportModuleName(file_name_ecma_module_copy_to1); - module_manager->CopyModule(thread, handle_tag_val_ecma_module_copy_from1); + module_manager->CopyModule(thread_, handle_tag_val_ecma_module_copy_from1); JSHandle handle_tag_val_ecma_module_copy_to1 = module_manager->GetModule( - thread, JSHandle::Cast(obj_factory->NewFromString(PandaString(file_name_ecma_module_copy_to1)))); + thread_, + JSHandle::Cast(obj_factory->NewFromString(PandaString(file_name_ecma_module_copy_to1)))); EXPECT_EQ(INT_ITEM_VALUE_11, - module_manager->GetModuleItem(thread, handle_tag_val_ecma_module_copy_to1, handle_tag_val_item_name11) + module_manager->GetModuleItem(thread_, handle_tag_val_ecma_module_copy_to1, handle_tag_val_item_name11) ->GetNumber()); EXPECT_EQ(INT_ITEM_VALUE_12, - module_manager->GetModuleItem(thread, handle_tag_val_ecma_module_copy_to1, handle_tag_val_item_name12) + module_manager->GetModuleItem(thread_, handle_tag_val_ecma_module_copy_to1, handle_tag_val_item_name12) ->GetNumber()); module_manager->SetCurrentExportModuleName(file_name_ecma_module_copy_to2); - module_manager->CopyModule(thread, handle_tag_val_ecma_module_copy_from2); + module_manager->CopyModule(thread_, handle_tag_val_ecma_module_copy_from2); JSHandle handle_tag_val_ecma_module_copy_to2 = module_manager->GetModule( - thread, JSHandle::Cast(obj_factory->NewFromString(PandaString(file_name_ecma_module_copy_to2)))); + thread_, + JSHandle::Cast(obj_factory->NewFromString(PandaString(file_name_ecma_module_copy_to2)))); EXPECT_EQ(INT_ITEM_VALUE_11, - module_manager->GetModuleItem(thread, handle_tag_val_ecma_module_copy_to1, handle_tag_val_item_name11) + module_manager->GetModuleItem(thread_, handle_tag_val_ecma_module_copy_to1, handle_tag_val_item_name11) ->GetNumber()); EXPECT_EQ(INT_ITEM_VALUE_12, - module_manager->GetModuleItem(thread, handle_tag_val_ecma_module_copy_to1, handle_tag_val_item_name12) + module_manager->GetModuleItem(thread_, handle_tag_val_ecma_module_copy_to1, handle_tag_val_item_name12) ->GetNumber()); EXPECT_EQ(INT_ITEM_VALUE_21, - module_manager->GetModuleItem(thread, handle_tag_val_ecma_module_copy_to2, handle_tag_val_item_name21) + module_manager->GetModuleItem(thread_, handle_tag_val_ecma_module_copy_to2, handle_tag_val_item_name21) ->GetNumber()); EXPECT_EQ(INT_ITEM_VALUE_22, - module_manager->GetModuleItem(thread, handle_tag_val_ecma_module_copy_to2, handle_tag_val_item_name22) + module_manager->GetModuleItem(thread_, handle_tag_val_ecma_module_copy_to2, handle_tag_val_item_name22) ->GetNumber()); } } // namespace panda::test diff --git a/tests/runtime/common/ecma_string_test.cpp b/tests/runtime/common/ecma_string_test.cpp index 2ebcd1ffb..f6bfa38ef 100644 --- a/tests/runtime/common/ecma_string_test.cpp +++ b/tests/runtime/common/ecma_string_test.cpp @@ -36,22 +36,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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {nullptr}; + JSThread *thread_ {nullptr}; // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - PandaVM *instance {nullptr}; + PandaVM *instance_ {nullptr}; private: - ecmascript::EcmaHandleScope *scope {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; /* @@ -103,15 +103,15 @@ TEST_F(EcmaStringTest, CanBeCompressed) */ TEST_F(EcmaStringTest, CreateEmptyString) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); - JSHandle handle_ecma_str_empty(thread, EcmaString::CreateEmptyString(ecma_vm_ptr)); + JSHandle handle_ecma_str_empty(thread_, EcmaString::CreateEmptyString(ecma_vm_ptr)); EXPECT_EQ(handle_ecma_str_empty->GetLength(), 0); EXPECT_TRUE(handle_ecma_str_empty->IsUtf8()); EXPECT_FALSE(handle_ecma_str_empty->IsUtf16()); EcmaString::SetCompressedStringsEnabled(false); // Set compressed_strings_enabled_ false. - JSHandle handle_ecma_str_empty_disable_comp(thread, EcmaString::CreateEmptyString(ecma_vm_ptr)); + JSHandle handle_ecma_str_empty_disable_comp(thread_, EcmaString::CreateEmptyString(ecma_vm_ptr)); EXPECT_EQ(handle_ecma_str_empty_disable_comp->GetLength(), 0); EXPECT_TRUE(handle_ecma_str_empty_disable_comp->IsUtf16()); EcmaString::SetCompressedStringsEnabled(true); // Set compressed_strings_enabled_ true(default). @@ -126,11 +126,11 @@ TEST_F(EcmaStringTest, CreateEmptyString) */ TEST_F(EcmaStringTest, AllocStringObject) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // AllocStringObject( , true, ). size_t size_alloc_comp = 5; - JSHandle handle_ecma_str_alloc_comp(thread, + JSHandle handle_ecma_str_alloc_comp(thread_, EcmaString::AllocStringObject(size_alloc_comp, true, ecma_vm_ptr)); for (size_t i = 0; i < size_alloc_comp; i++) { EXPECT_EQ(handle_ecma_str_alloc_comp->At(i), 0); @@ -142,7 +142,7 @@ TEST_F(EcmaStringTest, AllocStringObject) // AllocStringObject( , false, ). size_t size_alloc_not_comp = 5; JSHandle handle_ecma_str_alloc_not_comp( - thread, EcmaString::AllocStringObject(size_alloc_not_comp, false, ecma_vm_ptr)); + thread_, EcmaString::AllocStringObject(size_alloc_not_comp, false, ecma_vm_ptr)); for (size_t i = 0; i < size_alloc_not_comp; i++) { EXPECT_EQ(handle_ecma_str_alloc_not_comp->At(i), 0); } @@ -151,7 +151,7 @@ TEST_F(EcmaStringTest, AllocStringObject) EXPECT_TRUE(handle_ecma_str_alloc_not_comp->IsUtf16()); EcmaString::SetCompressedStringsEnabled(false); // Set compressed_strings_enabled_ false. JSHandle handle_ecma_str_alloc_not_comp_disable_comp( - thread, EcmaString::AllocStringObject(size_alloc_not_comp, false, ecma_vm_ptr)); + thread_, EcmaString::AllocStringObject(size_alloc_not_comp, false, ecma_vm_ptr)); EXPECT_TRUE(handle_ecma_str_alloc_not_comp_disable_comp->IsUtf16()); EcmaString::SetCompressedStringsEnabled(true); // Set compressed_strings_enabled_ true(default). } @@ -164,11 +164,11 @@ TEST_F(EcmaStringTest, AllocStringObject) */ TEST_F(EcmaStringTest, CreateFromUtf8) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); uint8_t array_u8[] = {"xyz123!@#"}; size_t length_ecma_str_u8 = sizeof(array_u8) - 1; JSHandle handle_ecma_str_u8( - thread, EcmaString::CreateFromUtf8(&array_u8[0], length_ecma_str_u8, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8[0], length_ecma_str_u8, ecma_vm_ptr, true)); for (size_t i = 0; i < length_ecma_str_u8; i++) { EXPECT_EQ(array_u8[i], handle_ecma_str_u8->At(i)); } @@ -186,13 +186,13 @@ TEST_F(EcmaStringTest, CreateFromUtf8) */ TEST_F(EcmaStringTest, CreateFromUtf16) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // CreateFromUtf16( , , , true). uint16_t array_u16_comp[] = {1, 23, 45, 67, 127}; size_t length_ecma_str_u16_comp = sizeof(array_u16_comp) / sizeof(array_u16_comp[0]); JSHandle handle_ecma_str_u16_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_comp[0], length_ecma_str_u16_comp, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp[0], length_ecma_str_u16_comp, ecma_vm_ptr, true)); EXPECT_EQ(handle_ecma_str_u16_comp->GetLength(), length_ecma_str_u16_comp); EXPECT_TRUE(handle_ecma_str_u16_comp->IsUtf8()); EXPECT_FALSE(handle_ecma_str_u16_comp->IsUtf16()); @@ -201,13 +201,13 @@ TEST_F(EcmaStringTest, CreateFromUtf16) uint16_t array_u16_not_comp[] = {127, 33, 128, 12, 256, 11100, 65535}; size_t length_ecma_str_u16_not_comp = sizeof(array_u16_not_comp) / sizeof(array_u16_not_comp[0]); JSHandle handle_ecma_str_u16_not_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); EXPECT_EQ(handle_ecma_str_u16_not_comp->GetLength(), length_ecma_str_u16_not_comp); EXPECT_FALSE(handle_ecma_str_u16_not_comp->IsUtf8()); EXPECT_TRUE(handle_ecma_str_u16_not_comp->IsUtf16()); EcmaString::SetCompressedStringsEnabled(false); // Set compressed_strings_enabled_ false. JSHandle handle_ecma_str_u16_not_comp_disable_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); EXPECT_TRUE(handle_ecma_str_u16_not_comp_disable_comp->IsUtf16()); EcmaString::SetCompressedStringsEnabled(true); // Set compressed_strings_enabled_ true(default). } @@ -265,41 +265,41 @@ TEST_F(EcmaStringTest, ComputeSizeUtf16) */ TEST_F(EcmaStringTest, ObjectSize) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); - JSHandle handle_ecma_str_empty(thread, EcmaString::CreateEmptyString(ecma_vm_ptr)); + JSHandle handle_ecma_str_empty(thread_, EcmaString::CreateEmptyString(ecma_vm_ptr)); EXPECT_EQ(handle_ecma_str_empty->ObjectSize(), EcmaString::SIZE + 0); size_t length_ecma_str_alloc_comp = 5; JSHandle handle_ecma_str_alloc_comp( - thread, EcmaString::AllocStringObject(length_ecma_str_alloc_comp, true, ecma_vm_ptr)); + thread_, EcmaString::AllocStringObject(length_ecma_str_alloc_comp, true, ecma_vm_ptr)); EXPECT_EQ(handle_ecma_str_alloc_comp->ObjectSize(), EcmaString::SIZE + sizeof(uint8_t) * length_ecma_str_alloc_comp); size_t length_ecma_str_alloc_not_comp = 5; JSHandle handle_ecma_str_alloc_not_comp( - thread, EcmaString::AllocStringObject(length_ecma_str_alloc_not_comp, false, ecma_vm_ptr)); + thread_, EcmaString::AllocStringObject(length_ecma_str_alloc_not_comp, false, ecma_vm_ptr)); EXPECT_EQ(handle_ecma_str_alloc_not_comp->ObjectSize(), EcmaString::SIZE + sizeof(uint16_t) * length_ecma_str_alloc_not_comp); uint8_t array_u8[] = {"abcde"}; size_t length_ecma_str_u8 = sizeof(array_u8) - 1; JSHandle handle_ecma_str_u8( - thread, EcmaString::CreateFromUtf8(&array_u8[0], length_ecma_str_u8, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8[0], length_ecma_str_u8, ecma_vm_ptr, true)); EXPECT_EQ(handle_ecma_str_u8->ObjectSize(), EcmaString::SIZE + sizeof(uint8_t) * length_ecma_str_u8); // ObjectSize(). EcmaString made by CreateFromUtf16( , , , true). uint16_t array_u16_comp[] = {1, 23, 45, 67, 127}; size_t length_ecma_str_u16_comp = sizeof(array_u16_comp) / sizeof(array_u16_comp[0]); JSHandle handle_ecma_str_u16_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_comp[0], length_ecma_str_u16_comp, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp[0], length_ecma_str_u16_comp, ecma_vm_ptr, true)); EXPECT_EQ(handle_ecma_str_u16_comp->ObjectSize(), EcmaString::SIZE + sizeof(uint8_t) * length_ecma_str_u16_comp); // ObjectSize(). EcmaString made by CreateFromUtf16( , , , false). uint16_t array_u16_not_comp[] = {127, 128, 256, 11100, 65535}; size_t length_ecma_str_u16_not_comp = sizeof(array_u16_not_comp) / sizeof(array_u16_not_comp[0]); JSHandle handle_ecma_str_u16_not_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); EXPECT_EQ(handle_ecma_str_u16_not_comp->ObjectSize(), EcmaString::SIZE + sizeof(uint16_t) * length_ecma_str_u16_not_comp); } @@ -313,7 +313,7 @@ TEST_F(EcmaStringTest, ObjectSize) */ TEST_F(EcmaStringTest, Compare_001) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // Compare(). Between EcmaStrings made by CreateFromUtf8(). uint8_t array_u8_no1[3] = {1, 23}; @@ -323,11 +323,11 @@ TEST_F(EcmaStringTest, Compare_001) uint32_t length_ecma_str_u8_no2 = sizeof(array_u8_no2) - 1; uint32_t length_ecma_str_u8_no3 = sizeof(array_u8_no3) - 1; JSHandle handle_ecma_str_u8_no1( - thread, EcmaString::CreateFromUtf8(&array_u8_no1[0], length_ecma_str_u8_no1, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_no1[0], length_ecma_str_u8_no1, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u8_no2( - thread, EcmaString::CreateFromUtf8(&array_u8_no2[0], length_ecma_str_u8_no2, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_no2[0], length_ecma_str_u8_no2, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u8_no3( - thread, EcmaString::CreateFromUtf8(&array_u8_no3[0], length_ecma_str_u8_no3, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_no3[0], length_ecma_str_u8_no3, ecma_vm_ptr, true)); EXPECT_EQ(handle_ecma_str_u8_no1->Compare(*handle_ecma_str_u8_no2), -1); EXPECT_EQ(handle_ecma_str_u8_no2->Compare(*handle_ecma_str_u8_no1), 1); EXPECT_EQ(handle_ecma_str_u8_no2->Compare(*handle_ecma_str_u8_no3), 49 - 45); @@ -343,7 +343,7 @@ TEST_F(EcmaStringTest, Compare_001) */ TEST_F(EcmaStringTest, Compare_002) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // Compare(). Between EcmaStrings made by CreateFromUtf16( , , , true). uint16_t array_u16_comp_no1[] = {1, 23}; @@ -353,11 +353,11 @@ TEST_F(EcmaStringTest, Compare_002) uint32_t length_ecma_str_u16_comp_no2 = sizeof(array_u16_comp_no2) / sizeof(array_u16_comp_no2[0]); uint32_t length_ecma_str_u16_comp_no3 = sizeof(array_u16_comp_no3) / sizeof(array_u16_comp_no3[0]); JSHandle handle_ecma_str_u16_comp_no1( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no1[0], length_ecma_str_u16_comp_no1, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no1[0], length_ecma_str_u16_comp_no1, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_comp_no2( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no2[0], length_ecma_str_u16_comp_no2, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no2[0], length_ecma_str_u16_comp_no2, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_comp_no3( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no3[0], length_ecma_str_u16_comp_no3, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no3[0], length_ecma_str_u16_comp_no3, ecma_vm_ptr, true)); EXPECT_EQ(handle_ecma_str_u16_comp_no1->Compare(*handle_ecma_str_u16_comp_no2), -1); EXPECT_EQ(handle_ecma_str_u16_comp_no2->Compare(*handle_ecma_str_u16_comp_no1), 1); EXPECT_EQ(handle_ecma_str_u16_comp_no2->Compare(*handle_ecma_str_u16_comp_no3), 49 - 45); @@ -374,7 +374,7 @@ TEST_F(EcmaStringTest, Compare_002) */ TEST_F(EcmaStringTest, Compare_003) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // Compare(). EcmaString made by CreateFromUtf8() and EcmaString made by CreateFromUtf16( , , , true). uint8_t array_u8_no1[3] = {1, 23}; @@ -388,15 +388,15 @@ TEST_F(EcmaStringTest, Compare_003) uint32_t length_ecma_str_u16_comp_no2 = sizeof(array_u16_comp_no2) / sizeof(array_u16_comp_no2[0]); uint32_t length_ecma_str_u16_comp_no3 = sizeof(array_u16_comp_no3) / sizeof(array_u16_comp_no3[0]); JSHandle handle_ecma_str_u8_no1( - thread, EcmaString::CreateFromUtf8(&array_u8_no1[0], length_ecma_str_u8_no1, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_no1[0], length_ecma_str_u8_no1, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u8_no2( - thread, EcmaString::CreateFromUtf8(&array_u8_no2[0], length_ecma_str_u8_no2, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_no2[0], length_ecma_str_u8_no2, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_comp_no1( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no1[0], length_ecma_str_u16_comp_no1, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no1[0], length_ecma_str_u16_comp_no1, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_comp_no2( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no2[0], length_ecma_str_u16_comp_no2, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no2[0], length_ecma_str_u16_comp_no2, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_comp_no3( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no3[0], length_ecma_str_u16_comp_no3, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no3[0], length_ecma_str_u16_comp_no3, ecma_vm_ptr, true)); EXPECT_EQ(handle_ecma_str_u8_no1->Compare(*handle_ecma_str_u16_comp_no1), 0); EXPECT_EQ(handle_ecma_str_u16_comp_no1->Compare(*handle_ecma_str_u8_no1), 0); EXPECT_EQ(handle_ecma_str_u8_no1->Compare(*handle_ecma_str_u16_comp_no2), -1); @@ -414,7 +414,7 @@ TEST_F(EcmaStringTest, Compare_003) */ TEST_F(EcmaStringTest, Compare_004) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // Compare(). Between EcmaStrings made by CreateFromUtf16( , , , false). uint16_t array_u16_not_comp_no1[] = {1, 23}; @@ -424,13 +424,13 @@ TEST_F(EcmaStringTest, Compare_004) uint32_t length_ecma_str_u16_not_comp_no2 = sizeof(array_u16_not_comp_no2) / sizeof(array_u16_not_comp_no2[0]); uint32_t length_ecma_str_u16_not_comp_no3 = sizeof(array_u16_not_comp_no3) / sizeof(array_u16_not_comp_no3[0]); JSHandle handle_ecma_str_u16_not_comp_no1( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no1[0], length_ecma_str_u16_not_comp_no1, ecma_vm_ptr, false)); JSHandle handle_ecma_str_u16_not_comp_no2( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no2[0], length_ecma_str_u16_not_comp_no2, ecma_vm_ptr, false)); JSHandle handle_ecma_str_u16_not_comp_no3( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no3[0], length_ecma_str_u16_not_comp_no3, ecma_vm_ptr, false)); EXPECT_EQ(handle_ecma_str_u16_not_comp_no1->Compare(*handle_ecma_str_u16_not_comp_no2), -1); EXPECT_EQ(handle_ecma_str_u16_not_comp_no2->Compare(*handle_ecma_str_u16_not_comp_no1), 1); @@ -447,7 +447,7 @@ TEST_F(EcmaStringTest, Compare_004) */ TEST_F(EcmaStringTest, Compare_005) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // Compare(). EcmaString made by CreateFromUtf8() and EcmaString made by CreateFromUtf16( , , , false). uint8_t array_u8_no1[3] = {1, 23}; @@ -461,17 +461,17 @@ TEST_F(EcmaStringTest, Compare_005) uint32_t length_ecma_str_u16_not_comp_no2 = sizeof(array_u16_not_comp_no2) / sizeof(array_u16_not_comp_no2[0]); uint32_t length_ecma_str_u16_not_comp_no3 = sizeof(array_u16_not_comp_no3) / sizeof(array_u16_not_comp_no3[0]); JSHandle handle_ecma_str_u8_no1( - thread, EcmaString::CreateFromUtf8(&array_u8_no1[0], length_ecma_str_u8_no1, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_no1[0], length_ecma_str_u8_no1, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u8_no2( - thread, EcmaString::CreateFromUtf8(&array_u8_no2[0], length_ecma_str_u8_no2, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_no2[0], length_ecma_str_u8_no2, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_not_comp_no1( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no1[0], length_ecma_str_u16_not_comp_no1, ecma_vm_ptr, false)); JSHandle handle_ecma_str_u16_not_comp_no2( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no2[0], length_ecma_str_u16_not_comp_no2, ecma_vm_ptr, false)); JSHandle handle_ecma_str_u16_not_comp_no3( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no3[0], length_ecma_str_u16_not_comp_no3, ecma_vm_ptr, false)); EXPECT_EQ(handle_ecma_str_u8_no1->Compare(*handle_ecma_str_u16_not_comp_no1), 0); EXPECT_EQ(handle_ecma_str_u16_not_comp_no1->Compare(*handle_ecma_str_u8_no1), 0); @@ -490,7 +490,7 @@ TEST_F(EcmaStringTest, Compare_005) */ TEST_F(EcmaStringTest, Compare_006) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // Compare(). EcmaString made by CreateFromUtf16( , , , true) and EcmaString made by CreateFromUtf16( , , , false). uint16_t array_u16_comp_no1[] = {1, 23}; @@ -504,17 +504,17 @@ TEST_F(EcmaStringTest, Compare_006) uint32_t length_ecma_str_u16_not_comp_no2 = sizeof(array_u16_not_comp_no2) / sizeof(array_u16_not_comp_no2[0]); uint32_t length_ecma_str_u16_not_comp_no3 = sizeof(array_u16_not_comp_no3) / sizeof(array_u16_not_comp_no3[0]); JSHandle handle_ecma_str_u16_comp_no1( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no1[0], length_ecma_str_u16_comp_no1, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no1[0], length_ecma_str_u16_comp_no1, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_comp_no2( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no2[0], length_ecma_str_u16_comp_no2, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no2[0], length_ecma_str_u16_comp_no2, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_not_comp_no1( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no1[0], length_ecma_str_u16_not_comp_no1, ecma_vm_ptr, false)); JSHandle handle_ecma_str_u16_not_comp_no2( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no2[0], length_ecma_str_u16_not_comp_no2, ecma_vm_ptr, false)); JSHandle handle_ecma_str_u16_not_comp_no3( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no3[0], length_ecma_str_u16_not_comp_no3, ecma_vm_ptr, false)); EXPECT_EQ(handle_ecma_str_u16_comp_no1->Compare(*handle_ecma_str_u16_not_comp_no1), 0); EXPECT_EQ(handle_ecma_str_u16_not_comp_no1->Compare(*handle_ecma_str_u16_comp_no1), 0); @@ -533,7 +533,7 @@ TEST_F(EcmaStringTest, Compare_006) */ TEST_F(EcmaStringTest, Concat_001) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // Concat(). EcmaString made by CreateFromUtf8() and EcmaString made by CreateFromUtf8(). uint8_t array_front_u8[] = {"abcdef"}; @@ -541,11 +541,11 @@ TEST_F(EcmaStringTest, Concat_001) uint32_t length_ecma_str_front_u8 = sizeof(array_front_u8) - 1; uint32_t length_ecma_str_back_u8 = sizeof(array_back_u8) - 1; JSHandle handle_ecma_str_front_u8( - thread, EcmaString::CreateFromUtf8(&array_front_u8[0], length_ecma_str_front_u8, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_front_u8[0], length_ecma_str_front_u8, ecma_vm_ptr, true)); JSHandle handle_ecma_str_back_u8( - thread, EcmaString::CreateFromUtf8(&array_back_u8[0], length_ecma_str_back_u8, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_back_u8[0], length_ecma_str_back_u8, ecma_vm_ptr, true)); JSHandle handle_ecma_str_concat_u8( - thread, EcmaString::Concat(handle_ecma_str_front_u8, handle_ecma_str_back_u8, ecma_vm_ptr)); + thread_, EcmaString::Concat(handle_ecma_str_front_u8, handle_ecma_str_back_u8, ecma_vm_ptr)); EXPECT_TRUE(handle_ecma_str_concat_u8->IsUtf8()); for (size_t i = 0; i < length_ecma_str_front_u8; i++) { EXPECT_EQ(handle_ecma_str_concat_u8->At(i), array_front_u8[i]); @@ -565,7 +565,7 @@ TEST_F(EcmaStringTest, Concat_001) */ TEST_F(EcmaStringTest, Concat_002) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // Concat(). EcmaString made by CreateFromUtf16( , , , false) and EcmaString made by CreateFromUtf16( , , , false). uint16_t array_front_u16_not_comp[] = {128, 129, 256, 11100, 65535, 100}; @@ -574,13 +574,14 @@ TEST_F(EcmaStringTest, Concat_002) sizeof(array_front_u16_not_comp) / sizeof(array_front_u16_not_comp[0]); uint32_t length_ecma_str_back_u16_not_comp = sizeof(array_back_u16_not_comp) / sizeof(array_back_u16_not_comp[0]); JSHandle handle_ecma_str_front_u16_not_comp( - thread, EcmaString::CreateFromUtf16(&array_front_u16_not_comp[0], length_ecma_str_front_u16_not_comp, - ecma_vm_ptr, false)); + thread_, EcmaString::CreateFromUtf16(&array_front_u16_not_comp[0], length_ecma_str_front_u16_not_comp, + ecma_vm_ptr, false)); JSHandle handle_ecma_str_back_u16_not_comp( - thread, EcmaString::CreateFromUtf16(&array_back_u16_not_comp[0], length_ecma_str_back_u16_not_comp, ecma_vm_ptr, - false)); + thread_, EcmaString::CreateFromUtf16(&array_back_u16_not_comp[0], length_ecma_str_back_u16_not_comp, + ecma_vm_ptr, false)); JSHandle handle_ecma_str_concat_u16_not_comp( - thread, EcmaString::Concat(handle_ecma_str_front_u16_not_comp, handle_ecma_str_back_u16_not_comp, ecma_vm_ptr)); + thread_, + EcmaString::Concat(handle_ecma_str_front_u16_not_comp, handle_ecma_str_back_u16_not_comp, ecma_vm_ptr)); EXPECT_TRUE(handle_ecma_str_concat_u16_not_comp->IsUtf16()); for (size_t i = 0; i < length_ecma_str_front_u16_not_comp; i++) { EXPECT_EQ(handle_ecma_str_concat_u16_not_comp->At(i), array_front_u16_not_comp[i]); @@ -602,7 +603,7 @@ TEST_F(EcmaStringTest, Concat_002) */ TEST_F(EcmaStringTest, Concat_003) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // Concat(). EcmaString made by CreateFromUtf8() and EcmaString made by CreateFromUtf16( , , , false). uint8_t array_front_u8[] = {"abcdef"}; @@ -610,12 +611,12 @@ TEST_F(EcmaStringTest, Concat_003) uint32_t length_ecma_str_front_u8 = sizeof(array_front_u8) - 1; uint32_t length_ecma_str_back_u16_not_comp = sizeof(array_back_u16_not_comp) / sizeof(array_back_u16_not_comp[0]); JSHandle handle_ecma_str_front_u8( - thread, EcmaString::CreateFromUtf8(&array_front_u8[0], length_ecma_str_front_u8, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_front_u8[0], length_ecma_str_front_u8, ecma_vm_ptr, true)); JSHandle handle_ecma_str_back_u16_not_comp( - thread, EcmaString::CreateFromUtf16(&array_back_u16_not_comp[0], length_ecma_str_back_u16_not_comp, ecma_vm_ptr, - false)); + thread_, EcmaString::CreateFromUtf16(&array_back_u16_not_comp[0], length_ecma_str_back_u16_not_comp, + ecma_vm_ptr, false)); JSHandle handle_ecma_str_concat_u8_u16_not_comp( - thread, EcmaString::Concat(handle_ecma_str_front_u8, handle_ecma_str_back_u16_not_comp, ecma_vm_ptr)); + thread_, EcmaString::Concat(handle_ecma_str_front_u8, handle_ecma_str_back_u16_not_comp, ecma_vm_ptr)); EXPECT_TRUE(handle_ecma_str_concat_u8_u16_not_comp->IsUtf16()); for (size_t i = 0; i < length_ecma_str_front_u8; i++) { EXPECT_EQ(handle_ecma_str_concat_u8_u16_not_comp->At(i), array_front_u8[i]); @@ -637,7 +638,7 @@ TEST_F(EcmaStringTest, Concat_003) */ TEST_F(EcmaStringTest, Concat_004) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); /* Concat() after SetCompressedStringsEnabled(false). EcmaString made by CreateFromUtf16( , , , false) and * EcmaString made by CreateFromUtf16( , , , false). @@ -649,13 +650,14 @@ TEST_F(EcmaStringTest, Concat_004) sizeof(array_front_u16_not_comp) / sizeof(array_front_u16_not_comp[0]); uint32_t length_ecma_str_back_u16_not_comp = sizeof(array_back_u16_not_comp) / sizeof(array_back_u16_not_comp[0]); JSHandle handle_ecma_str_front_u16_not_comp( - thread, EcmaString::CreateFromUtf16(&array_front_u16_not_comp[0], length_ecma_str_front_u16_not_comp, - ecma_vm_ptr, false)); + thread_, EcmaString::CreateFromUtf16(&array_front_u16_not_comp[0], length_ecma_str_front_u16_not_comp, + ecma_vm_ptr, false)); JSHandle handle_ecma_str_back_u16_not_comp( - thread, EcmaString::CreateFromUtf16(&array_back_u16_not_comp[0], length_ecma_str_back_u16_not_comp, ecma_vm_ptr, - false)); + thread_, EcmaString::CreateFromUtf16(&array_back_u16_not_comp[0], length_ecma_str_back_u16_not_comp, + ecma_vm_ptr, false)); JSHandle handle_ecma_str_concat_u16_not_comp_after_set_false( - thread, EcmaString::Concat(handle_ecma_str_front_u16_not_comp, handle_ecma_str_back_u16_not_comp, ecma_vm_ptr)); + thread_, + EcmaString::Concat(handle_ecma_str_front_u16_not_comp, handle_ecma_str_back_u16_not_comp, ecma_vm_ptr)); EXPECT_TRUE(handle_ecma_str_concat_u16_not_comp_after_set_false->IsUtf16()); for (size_t i = 0; i < length_ecma_str_front_u16_not_comp; i++) { EXPECT_EQ(handle_ecma_str_concat_u16_not_comp_after_set_false->At(i), array_front_u16_not_comp[i]); @@ -678,17 +680,17 @@ TEST_F(EcmaStringTest, Concat_004) */ TEST_F(EcmaStringTest, FastSubString_001) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // FastSubString(). From EcmaString made by CreateFromUtf8(). uint8_t array_u8[6] = {3, 7, 19, 54, 99}; uint32_t length_ecma_str_u8 = sizeof(array_u8) - 1; JSHandle handle_ecma_str_u8( - thread, EcmaString::CreateFromUtf8(&array_u8[0], length_ecma_str_u8, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8[0], length_ecma_str_u8, ecma_vm_ptr, true)); uint32_t index_start_sub_u8 = 2; uint32_t length_sub_u8 = 2; JSHandle handle_ecma_str_sub_u8( - thread, EcmaString::FastSubString(handle_ecma_str_u8, index_start_sub_u8, length_sub_u8, ecma_vm_ptr)); + thread_, EcmaString::FastSubString(handle_ecma_str_u8, index_start_sub_u8, length_sub_u8, ecma_vm_ptr)); for (size_t i = 0; i < length_sub_u8; i++) { EXPECT_EQ(handle_ecma_str_sub_u8->At(i), handle_ecma_str_u8->At(i + index_start_sub_u8)); } @@ -704,18 +706,18 @@ TEST_F(EcmaStringTest, FastSubString_001) */ TEST_F(EcmaStringTest, FastSubString_002) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // FastSubString(). From EcmaString made by CreateFromUtf16( , , , true). uint16_t array_u16_comp[] = {1, 12, 34, 56, 127}; uint32_t length_ecma_str_u16_comp = sizeof(array_u16_comp) / sizeof(array_u16_comp[0]); JSHandle handle_ecma_str_u16_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_comp[0], length_ecma_str_u16_comp, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp[0], length_ecma_str_u16_comp, ecma_vm_ptr, true)); uint32_t index_start_sub_u16_comp = 0; uint32_t length_sub_u16_comp = 2; JSHandle handle_ecma_str_sub_u16_comp( - thread, EcmaString::FastSubString(handle_ecma_str_u16_comp, index_start_sub_u16_comp, length_sub_u16_comp, - ecma_vm_ptr)); + thread_, EcmaString::FastSubString(handle_ecma_str_u16_comp, index_start_sub_u16_comp, length_sub_u16_comp, + ecma_vm_ptr)); for (size_t i = 0; i < length_sub_u16_comp; i++) { EXPECT_EQ(handle_ecma_str_sub_u16_comp->At(i), handle_ecma_str_u16_comp->At(i + index_start_sub_u16_comp)); } @@ -731,18 +733,18 @@ TEST_F(EcmaStringTest, FastSubString_002) */ TEST_F(EcmaStringTest, FastSubString_003) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // FastSubString(). From EcmaString made by CreateFromUtf16( , , , false). uint16_t array_u16_not_comp[] = {19, 54, 256, 11100, 65535}; uint32_t length_ecma_str_u16_not_comp = sizeof(array_u16_not_comp) / sizeof(array_u16_not_comp[0]); JSHandle handle_ecma_str_u16_not_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); uint32_t index_start_sub_u16_not_comp = 0; uint32_t length_sub_u16_not_comp = 2; JSHandle handle_ecma_str_sub_u16_not_comp( - thread, EcmaString::FastSubString(handle_ecma_str_u16_not_comp, index_start_sub_u16_not_comp, - length_sub_u16_not_comp, ecma_vm_ptr)); + thread_, EcmaString::FastSubString(handle_ecma_str_u16_not_comp, index_start_sub_u16_not_comp, + length_sub_u16_not_comp, ecma_vm_ptr)); for (size_t i = 0; i < length_sub_u16_not_comp; i++) { EXPECT_EQ(handle_ecma_str_sub_u16_not_comp->At(i), handle_ecma_str_u16_not_comp->At(i + index_start_sub_u16_not_comp)); @@ -759,16 +761,16 @@ TEST_F(EcmaStringTest, FastSubString_003) */ TEST_F(EcmaStringTest, WriteData_001) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // WriteData(). From EcmaString made by CreateFromUtf8() to EcmaString made by AllocStringObject( , true, ). uint8_t array_u8_write_from[6] = {1, 12, 34, 56, 127}; uint32_t length_ecma_str_u8_write_from = sizeof(array_u8_write_from) - 1; JSHandle handle_ecma_str_u8_write_from( - thread, EcmaString::CreateFromUtf8(&array_u8_write_from[0], length_ecma_str_u8_write_from, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_write_from[0], length_ecma_str_u8_write_from, ecma_vm_ptr, true)); size_t size_ecma_str_u8_write_to = 5; JSHandle handle_ecma_str_alloc_true_write_to( - thread, EcmaString::AllocStringObject(size_ecma_str_u8_write_to, true, ecma_vm_ptr)); + thread_, EcmaString::AllocStringObject(size_ecma_str_u8_write_to, true, ecma_vm_ptr)); uint32_t index_start_write_from_array_u8 = 2; uint32_t length_write_from_array_u8 = 2; handle_ecma_str_alloc_true_write_to->WriteData(*handle_ecma_str_u8_write_from, index_start_write_from_array_u8, @@ -788,13 +790,13 @@ TEST_F(EcmaStringTest, WriteData_001) */ TEST_F(EcmaStringTest, WriteData_002) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // WriteData(). From char to EcmaString made by AllocStringObject( , true, ). char u8_write = 'a'; size_t size_ecma_str_u8_write_to = 5; JSHandle handle_ecma_str_alloc_true_write_to( - thread, EcmaString::AllocStringObject(size_ecma_str_u8_write_to, true, ecma_vm_ptr)); + thread_, EcmaString::AllocStringObject(size_ecma_str_u8_write_to, true, ecma_vm_ptr)); uint32_t index_at_write_from_u8 = 4; handle_ecma_str_alloc_true_write_to->WriteData(u8_write, index_at_write_from_u8); EXPECT_EQ(handle_ecma_str_alloc_true_write_to->At(index_at_write_from_u8), u8_write); @@ -809,7 +811,7 @@ TEST_F(EcmaStringTest, WriteData_002) */ TEST_F(EcmaStringTest, WriteData_003) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); /* WriteData(). From EcmaString made by CreateFromUtf16( , , , false) to EcmaStringU16 made by * AllocStringObject( , false, ). @@ -817,11 +819,11 @@ TEST_F(EcmaStringTest, WriteData_003) uint16_t array_u16_write_from[10] = {67, 777, 1999, 1, 45, 66, 23456, 65535, 127, 333}; uint32_t length_ecma_str_u16_write_from = sizeof(array_u16_write_from) / sizeof(array_u16_write_from[0]); JSHandle handle_ecma_str_u16_write_from( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_write_from[0], length_ecma_str_u16_write_from, ecma_vm_ptr, false)); size_t size_ecma_str_u16_write_to = 10; JSHandle handle_ecma_str_u16_write_to( - thread, EcmaString::AllocStringObject(size_ecma_str_u16_write_to, false, ecma_vm_ptr)); + thread_, EcmaString::AllocStringObject(size_ecma_str_u16_write_to, false, ecma_vm_ptr)); uint32_t index_start_write_from_array_u16 = 3; uint32_t num_bytes_write_from_array_u16 = 2 * 3; handle_ecma_str_u16_write_to->WriteData(*handle_ecma_str_u16_write_from, index_start_write_from_array_u16, @@ -841,16 +843,16 @@ TEST_F(EcmaStringTest, WriteData_003) */ TEST_F(EcmaStringTest, WriteData_004) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // WriteData(). From EcmaString made by CreateFromUtf8() to EcmaString made by AllocStringObject( , false, ). uint8_t array_u8_write_from[6] = {1, 12, 34, 56, 127}; uint32_t length_ecma_str_u8_write_from = sizeof(array_u8_write_from) - 1; JSHandle handle_ecma_str_u8_write_from( - thread, EcmaString::CreateFromUtf8(&array_u8_write_from[0], length_ecma_str_u8_write_from, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_write_from[0], length_ecma_str_u8_write_from, ecma_vm_ptr, true)); size_t size_ecma_str_u16_write_to = 10; JSHandle handle_ecma_str_u16_write_to( - thread, EcmaString::AllocStringObject(size_ecma_str_u16_write_to, false, ecma_vm_ptr)); + thread_, EcmaString::AllocStringObject(size_ecma_str_u16_write_to, false, ecma_vm_ptr)); uint32_t index_start_write_from_u8_to_u16 = 1; uint32_t num_bytes_write_from_u8_to_u16 = 4; handle_ecma_str_u16_write_to->WriteData(*handle_ecma_str_u8_write_from, index_start_write_from_u8_to_u16, @@ -870,12 +872,12 @@ TEST_F(EcmaStringTest, WriteData_004) */ TEST_F(EcmaStringTest, WriteData_005) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // WriteData(). From char to EcmaString made by AllocStringObject( , false, ). size_t size_ecma_str_u16_write_to = 10; JSHandle handle_ecma_str_u16_write_to( - thread, EcmaString::AllocStringObject(size_ecma_str_u16_write_to, false, ecma_vm_ptr)); + thread_, EcmaString::AllocStringObject(size_ecma_str_u16_write_to, false, ecma_vm_ptr)); char u8_write = 'a'; uint32_t index_at = 4; handle_ecma_str_u16_write_to->WriteData(u8_write, index_at); @@ -890,7 +892,7 @@ TEST_F(EcmaStringTest, WriteData_005) */ TEST_F(EcmaStringTest, GetUtf8Length) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); uint8_t array_u8[6] = {3, 7, 19, 54, 99}; uint16_t array_u16_comp[] = {1, 12, 34, 56, 127}; uint16_t array_u16_not_comp[] = {19, 54, 256, 11100, 65535}; @@ -898,11 +900,11 @@ TEST_F(EcmaStringTest, GetUtf8Length) uint32_t length_ecma_str_u16_comp = sizeof(array_u16_comp) / sizeof(array_u16_comp[0]); uint32_t length_ecma_str_u16_not_comp = sizeof(array_u16_not_comp) / sizeof(array_u16_not_comp[0]); JSHandle handle_ecma_str_u8( - thread, EcmaString::CreateFromUtf8(&array_u8[0], length_ecma_str_u8, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8[0], length_ecma_str_u8, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_comp[0], length_ecma_str_u16_comp, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp[0], length_ecma_str_u16_comp, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_not_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); EXPECT_EQ(handle_ecma_str_u8->GetUtf8Length(), length_ecma_str_u8 + 1); EXPECT_EQ(handle_ecma_str_u16_comp->GetUtf8Length(), length_ecma_str_u16_comp + 1); EXPECT_EQ(handle_ecma_str_u16_not_comp->GetUtf8Length(), 2 * length_ecma_str_u16_not_comp + 1); @@ -916,7 +918,7 @@ TEST_F(EcmaStringTest, GetUtf8Length) */ TEST_F(EcmaStringTest, GetUtf16Length) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); uint8_t array_u8[6] = {3, 7, 19, 54, 99}; uint16_t array_u16_comp[] = {1, 12, 34, 56, 127}; @@ -925,11 +927,11 @@ TEST_F(EcmaStringTest, GetUtf16Length) uint32_t length_ecma_str_u16_comp = sizeof(array_u16_comp) / sizeof(array_u16_comp[0]); uint32_t length_ecma_str_u16_not_comp = sizeof(array_u16_not_comp) / sizeof(array_u16_not_comp[0]); JSHandle handle_ecma_str_u8( - thread, EcmaString::CreateFromUtf8(&array_u8[0], length_ecma_str_u8, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8[0], length_ecma_str_u8, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_comp[0], length_ecma_str_u16_comp, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp[0], length_ecma_str_u16_comp, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_not_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); EXPECT_EQ(handle_ecma_str_u8->GetUtf16Length(), length_ecma_str_u8); EXPECT_EQ(handle_ecma_str_u16_comp->GetUtf16Length(), length_ecma_str_u16_comp); EXPECT_EQ(handle_ecma_str_u16_not_comp->GetUtf16Length(), length_ecma_str_u16_not_comp); @@ -943,13 +945,13 @@ TEST_F(EcmaStringTest, GetUtf16Length) */ TEST_F(EcmaStringTest, GetDataUtf8) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // From EcmaString made by CreateFromUtf8(). uint8_t array_u8[] = {"abcde"}; uint32_t length_ecma_str_u8 = sizeof(array_u8) - 1; JSHandle handle_ecma_str_u8( - thread, EcmaString::CreateFromUtf8(&array_u8[0], length_ecma_str_u8, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8[0], length_ecma_str_u8, ecma_vm_ptr, true)); for (size_t i = 0; i < length_ecma_str_u8; i++) { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) EXPECT_EQ(*(handle_ecma_str_u8->GetDataUtf8() + i), array_u8[i]); @@ -959,7 +961,7 @@ TEST_F(EcmaStringTest, GetDataUtf8) uint16_t array_u16_comp[] = {3, 1, 34, 123, 127, 111, 42, 3, 20, 10}; uint32_t length_ecma_str_u16_comp = sizeof(array_u16_comp) / sizeof(array_u16_comp[0]); JSHandle handle_ecma_str_u16_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_comp[0], length_ecma_str_u16_comp, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp[0], length_ecma_str_u16_comp, ecma_vm_ptr, true)); for (size_t i = 0; i < sizeof(array_u16_comp) / array_u16_comp[0]; i++) { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) EXPECT_EQ(*(handle_ecma_str_u16_comp->GetDataUtf8() + i), array_u16_comp[i]); @@ -974,13 +976,13 @@ TEST_F(EcmaStringTest, GetDataUtf8) */ TEST_F(EcmaStringTest, GetDataUtf16) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // From EcmaString made by CreateFromUtf16( , , , false). uint16_t array_u16_not_comp[] = {67, 777, 1999, 1, 45, 66, 23456, 65535, 127, 333}; uint32_t length_ecma_str_u16_not_comp = sizeof(array_u16_not_comp) / sizeof(array_u16_not_comp[0]); JSHandle handle_ecma_str_u16_not_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); for (size_t i = 0; i < length_ecma_str_u16_not_comp; i++) { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) EXPECT_EQ(*(handle_ecma_str_u16_not_comp->GetDataUtf16() + i), array_u16_not_comp[i]); @@ -996,13 +998,13 @@ TEST_F(EcmaStringTest, GetDataUtf16) */ TEST_F(EcmaStringTest, CopyDataRegionUtf8) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // CopyDataRegionUtf8(). From EcmaString made by CreateFromUtf8(). uint8_t array_u8_copy_from[6] = {1, 12, 34, 56, 127}; uint32_t length_ecma_str_u8_copy_from = sizeof(array_u8_copy_from) - 1; JSHandle handle_ecma_str_u8_copy_from( - thread, EcmaString::CreateFromUtf8(&array_u8_copy_from[0], length_ecma_str_u8_copy_from, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_copy_from[0], length_ecma_str_u8_copy_from, ecma_vm_ptr, true)); const size_t length_array_u8_target = 7; uint8_t default_byte_for_u8_copy_to = 1; uint8_t array_u8_copy_to[length_array_u8_target]; @@ -1026,8 +1028,8 @@ TEST_F(EcmaStringTest, CopyDataRegionUtf8) uint32_t length_ecma_str_u16_comp_copy_from = sizeof(array_u16_comp_copy_from) / sizeof(array_u16_comp_copy_from[0]); JSHandle handle_ecma_str_u16_comp_copy_from( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_copy_from[0], length_ecma_str_u16_comp_copy_from, - ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_copy_from[0], length_ecma_str_u16_comp_copy_from, + ecma_vm_ptr, true)); const size_t length_array_u16_target = 8; uint8_t default_byte_for_u16_comp_copy_to = 1; uint8_t array_u16_comp_copy_to[length_array_u16_target]; @@ -1059,13 +1061,13 @@ TEST_F(EcmaStringTest, CopyDataRegionUtf8) */ TEST_F(EcmaStringTest, CopyDataUtf8) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // CopyDataUtf8(). From EcmaString made by CreateFromUtf8(). uint8_t array_u8_copy_from[6] = {1, 12, 34, 56, 127}; uint32_t length_ecma_str_u8_copy_from = sizeof(array_u8_copy_from) - 1; JSHandle handle_ecma_str_u8_copy_from( - thread, EcmaString::CreateFromUtf8(&array_u8_copy_from[0], length_ecma_str_u8_copy_from, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_copy_from[0], length_ecma_str_u8_copy_from, ecma_vm_ptr, true)); const size_t length_array_u8_target = 6; uint8_t array_u8_copy_to[length_array_u8_target]; @@ -1082,8 +1084,8 @@ TEST_F(EcmaStringTest, CopyDataUtf8) uint32_t length_ecma_str_u16_comp_copy_from = sizeof(array_u16_comp_copy_from) / sizeof(array_u16_comp_copy_from[0]); JSHandle handle_ecma_str_u16_comp_copy_from( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_copy_from[0], length_ecma_str_u16_comp_copy_from, - ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_copy_from[0], length_ecma_str_u16_comp_copy_from, + ecma_vm_ptr, true)); const size_t length_array_u16_target = 6; uint8_t array_u8_comp_copy_to[length_array_u16_target]; @@ -1106,15 +1108,15 @@ TEST_F(EcmaStringTest, CopyDataUtf8) */ TEST_F(EcmaStringTest, CopyDataRegionUtf16) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // CopyDataRegionUtf16(). From EcmaString made by CreateFromUtf16( , , , false). uint16_t array_u16_not_comp_copy_from[10] = {67, 777, 1999, 1, 45, 66, 23456, 65535, 127, 333}; uint32_t length_ecma_str_u16_not_comp_copy_from = sizeof(array_u16_not_comp_copy_from) / sizeof(array_u16_not_comp_copy_from[0]); JSHandle handle_ecma_str_u16_not_comp_copy_from( - thread, EcmaString::CreateFromUtf16(&array_u16_not_comp_copy_from[0], length_ecma_str_u16_not_comp_copy_from, - ecma_vm_ptr, false)); + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_copy_from[0], length_ecma_str_u16_not_comp_copy_from, + ecma_vm_ptr, false)); const size_t length_array_u16_target = 13; uint16_t array_u16_not_comp_copy_to[length_array_u16_target]; uint8_t default_one_byte_value_of_array_u16_not_comp_copy_to = 244; @@ -1147,15 +1149,15 @@ TEST_F(EcmaStringTest, CopyDataRegionUtf16) */ TEST_F(EcmaStringTest, CopyDataUtf16) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // CopyDataUtf16(). From EcmaString made by CreateFromUtf16( , , , false). uint16_t array_u16_not_comp_copy_from[10] = {67, 777, 1999, 1, 45, 66, 23456, 65535, 127, 333}; uint32_t length_ecma_str_u16_not_comp_copy_from = sizeof(array_u16_not_comp_copy_from) / sizeof(array_u16_not_comp_copy_from[0]); JSHandle handle_ecma_str_u16_not_comp_copy_from( - thread, EcmaString::CreateFromUtf16(&array_u16_not_comp_copy_from[0], length_ecma_str_u16_not_comp_copy_from, - ecma_vm_ptr, false)); + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_copy_from[0], length_ecma_str_u16_not_comp_copy_from, + ecma_vm_ptr, false)); const size_t length_array_u16_target = 13; uint16_t array_u16_not_comp_copy_to[length_array_u16_target]; uint8_t default_one_byte_value_of_array_u16_not_comp_copy_to = 244; @@ -1184,7 +1186,7 @@ TEST_F(EcmaStringTest, CopyDataUtf16) */ TEST_F(EcmaStringTest, IndexOf_001) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // IndexOf(). Find EcmaString made by CreateFromUtf8() From EcmaString made by CreateFromUtf8(). uint8_t array_u8_from[7] = {23, 25, 1, 3, 39, 80}; @@ -1192,9 +1194,9 @@ TEST_F(EcmaStringTest, IndexOf_001) uint32_t length_ecma_str_u8_from = sizeof(array_u8_from) - 1; uint32_t length_ecma_str_u8_target = sizeof(array_u8_target) - 1; JSHandle handle_ecma_str( - thread, EcmaString::CreateFromUtf8(&array_u8_from[0], length_ecma_str_u8_from, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_from[0], length_ecma_str_u8_from, ecma_vm_ptr, true)); JSHandle handle_ecma_str1( - thread, EcmaString::CreateFromUtf8(&array_u8_target[0], length_ecma_str_u8_target, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_target[0], length_ecma_str_u8_target, ecma_vm_ptr, true)); int32_t pos_start = 0; EXPECT_EQ(handle_ecma_str->IndexOf(*handle_ecma_str1, pos_start), 2); EXPECT_EQ(handle_ecma_str1->IndexOf(*handle_ecma_str, pos_start), -1); @@ -1217,7 +1219,7 @@ TEST_F(EcmaStringTest, IndexOf_001) */ TEST_F(EcmaStringTest, IndexOf_002) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // IndexOf(). Find EcmaString made by CreateFromUtf8() From EcmaString made by CreateFromUtf16( , , , false). uint8_t array_u8_target[4] = {1, 3, 39}; @@ -1226,10 +1228,10 @@ TEST_F(EcmaStringTest, IndexOf_002) uint32_t length_ecma_str_u16_not_comp_from_no1 = sizeof(array_u16_not_comp_from_no1) / sizeof(array_u16_not_comp_from_no1[0]); JSHandle handle_ecma_str( - thread, EcmaString::CreateFromUtf8(&array_u8_target[0], length_ecma_str_u8_target, ecma_vm_ptr, true)); - JSHandle handle_ecma_str1(thread, EcmaString::CreateFromUtf16(&array_u16_not_comp_from_no1[0], - length_ecma_str_u16_not_comp_from_no1, - ecma_vm_ptr, false)); + thread_, EcmaString::CreateFromUtf8(&array_u8_target[0], length_ecma_str_u8_target, ecma_vm_ptr, true)); + JSHandle handle_ecma_str1(thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_from_no1[0], + length_ecma_str_u16_not_comp_from_no1, + ecma_vm_ptr, false)); int32_t pos_start = 0; EXPECT_EQ(handle_ecma_str1->IndexOf(*handle_ecma_str, pos_start), 6); EXPECT_EQ(handle_ecma_str->IndexOf(*handle_ecma_str1, pos_start), -1); @@ -1252,7 +1254,7 @@ TEST_F(EcmaStringTest, IndexOf_002) */ TEST_F(EcmaStringTest, IndexOf_003) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); /* IndexOf(). Find EcmaString made by CreateFromUtf16( , , , false) From EcmaString made by * CreateFromUtf16( , , , false). @@ -1263,11 +1265,11 @@ TEST_F(EcmaStringTest, IndexOf_003) sizeof(array_u16_not_comp_target) / sizeof(array_u16_not_comp_target[0]); uint32_t length_ecma_str_u16_not_comp_from = sizeof(array_u16_not_comp_from) / sizeof(array_u16_not_comp_from[0]); JSHandle handle_ecma_str_u16_not_comp_target( - thread, EcmaString::CreateFromUtf16(&array_u16_not_comp_target[0], length_ecma_str_u16_not_comp_target, - ecma_vm_ptr, false)); + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_target[0], length_ecma_str_u16_not_comp_target, + ecma_vm_ptr, false)); JSHandle handle_ecma_str_u16_not_comp_from( - thread, EcmaString::CreateFromUtf16(&array_u16_not_comp_from[0], length_ecma_str_u16_not_comp_from, ecma_vm_ptr, - false)); + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_from[0], length_ecma_str_u16_not_comp_from, + ecma_vm_ptr, false)); int32_t pos_start = 0; EXPECT_EQ(handle_ecma_str_u16_not_comp_from->IndexOf(*handle_ecma_str_u16_not_comp_target, pos_start), 4); EXPECT_EQ(handle_ecma_str_u16_not_comp_target->IndexOf(*handle_ecma_str_u16_not_comp_from, pos_start), -1); @@ -1290,7 +1292,7 @@ TEST_F(EcmaStringTest, IndexOf_003) */ TEST_F(EcmaStringTest, IndexOf_004) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // IndexOf(). Find EcmaString made by CreateFromUtf16( , , , false) From EcmaString made by CreateFromUtf8(). uint16_t ecma_str_u16_not_comp_target[] = {3, 39, 80}; @@ -1299,10 +1301,10 @@ TEST_F(EcmaStringTest, IndexOf_004) sizeof(ecma_str_u16_not_comp_target) / sizeof(ecma_str_u16_not_comp_target[0]); uint32_t length_ecma_str_u8_from = sizeof(array_u8_from) - 1; JSHandle handle_ecma_str_u16_not_comp_target( - thread, EcmaString::CreateFromUtf16(&ecma_str_u16_not_comp_target[0], length_ecma_str_u16_not_comp_target, - ecma_vm_ptr, false)); + thread_, EcmaString::CreateFromUtf16(&ecma_str_u16_not_comp_target[0], length_ecma_str_u16_not_comp_target, + ecma_vm_ptr, false)); JSHandle handle_ecma_str_u8_from( - thread, EcmaString::CreateFromUtf8(&array_u8_from[0], length_ecma_str_u8_from, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_from[0], length_ecma_str_u8_from, ecma_vm_ptr, true)); int32_t pos_start = 0; EXPECT_EQ(handle_ecma_str_u8_from->IndexOf(*handle_ecma_str_u16_not_comp_target, pos_start), 3); EXPECT_EQ(handle_ecma_str_u16_not_comp_target->IndexOf(*handle_ecma_str_u8_from, pos_start), -1); @@ -1325,7 +1327,7 @@ TEST_F(EcmaStringTest, IndexOf_004) */ TEST_F(EcmaStringTest, StringsAreEqual_001) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // StringsAreEqual(). uint8_t array_u8_no1[4] = {45, 92, 78}; @@ -1335,11 +1337,11 @@ TEST_F(EcmaStringTest, StringsAreEqual_001) uint32_t length_ecma_str_u8_no2 = sizeof(array_u8_no2) - 1; uint32_t length_ecma_str_u8_no3 = sizeof(array_u8_no3) - 1; JSHandle handle_ecma_str_u8_no1( - thread, EcmaString::CreateFromUtf8(&array_u8_no1[0], length_ecma_str_u8_no1, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_no1[0], length_ecma_str_u8_no1, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u8_no2( - thread, EcmaString::CreateFromUtf8(&array_u8_no2[0], length_ecma_str_u8_no2, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_no2[0], length_ecma_str_u8_no2, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u8_no3( - thread, EcmaString::CreateFromUtf8(&array_u8_no3[0], length_ecma_str_u8_no3, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_no3[0], length_ecma_str_u8_no3, ecma_vm_ptr, true)); EXPECT_TRUE(EcmaString::StringsAreEqual(*handle_ecma_str_u8_no1, *handle_ecma_str_u8_no2)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handle_ecma_str_u8_no1, *handle_ecma_str_u8_no3)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handle_ecma_str_u8_no3, *handle_ecma_str_u8_no1)); @@ -1354,7 +1356,7 @@ TEST_F(EcmaStringTest, StringsAreEqual_001) */ TEST_F(EcmaStringTest, StringsAreEqual_002) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // StringsAreEqual(). uint8_t array_u8_no1[4] = {45, 92, 78}; @@ -1364,11 +1366,11 @@ TEST_F(EcmaStringTest, StringsAreEqual_002) uint32_t length_ecma_str_u16_comp_no2 = sizeof(array_u16_comp_no2) / sizeof(array_u16_comp_no2[0]); uint32_t length_ecma_str_u16_comp_no3 = sizeof(array_u16_comp_no3) / sizeof(array_u16_comp_no3[0]); JSHandle handle_ecma_str_u8_no1( - thread, EcmaString::CreateFromUtf8(&array_u8_no1[0], length_ecma_str_u8_no1, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_no1[0], length_ecma_str_u8_no1, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_comp_no2( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no2[0], length_ecma_str_u16_comp_no2, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no2[0], length_ecma_str_u16_comp_no2, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_comp_no3( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no3[0], length_ecma_str_u16_comp_no3, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no3[0], length_ecma_str_u16_comp_no3, ecma_vm_ptr, true)); EXPECT_TRUE(EcmaString::StringsAreEqual(*handle_ecma_str_u8_no1, *handle_ecma_str_u16_comp_no2)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handle_ecma_str_u8_no1, *handle_ecma_str_u16_comp_no3)); } @@ -1382,7 +1384,7 @@ TEST_F(EcmaStringTest, StringsAreEqual_002) */ TEST_F(EcmaStringTest, StringsAreEqual_003) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // StringsAreEqual(). uint16_t array_u16_comp_no1[] = {45, 92, 78}; @@ -1392,11 +1394,11 @@ TEST_F(EcmaStringTest, StringsAreEqual_003) uint32_t length_ecma_str_u16_comp_no2 = sizeof(array_u16_comp_no2) / sizeof(array_u16_comp_no2[0]); uint32_t length_ecma_str_u16_comp_no3 = sizeof(array_u16_comp_no3) / sizeof(array_u16_comp_no3[0]); JSHandle handle_ecma_str_u16_comp_no1( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no1[0], length_ecma_str_u16_comp_no1, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no1[0], length_ecma_str_u16_comp_no1, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_comp_no2( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no2[0], length_ecma_str_u16_comp_no2, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no2[0], length_ecma_str_u16_comp_no2, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_comp_no3( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no3[0], length_ecma_str_u16_comp_no3, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no3[0], length_ecma_str_u16_comp_no3, ecma_vm_ptr, true)); EXPECT_TRUE(EcmaString::StringsAreEqual(*handle_ecma_str_u16_comp_no1, *handle_ecma_str_u16_comp_no2)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handle_ecma_str_u16_comp_no1, *handle_ecma_str_u16_comp_no3)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handle_ecma_str_u16_comp_no3, *handle_ecma_str_u16_comp_no1)); @@ -1411,7 +1413,7 @@ TEST_F(EcmaStringTest, StringsAreEqual_003) */ TEST_F(EcmaStringTest, StringsAreEqual_004) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // StringsAreEqual(). uint8_t array_u8_no1[4] = {45, 92, 78}; @@ -1419,9 +1421,9 @@ TEST_F(EcmaStringTest, StringsAreEqual_004) uint32_t length_ecma_str_u8_no1 = sizeof(array_u8_no1) - 1; uint32_t length_ecma_str_u16_not_comp_no1 = sizeof(array_u16_not_comp_no1) / sizeof(array_u16_not_comp_no1[0]); JSHandle handle_ecma_str_u8_no1( - thread, EcmaString::CreateFromUtf8(&array_u8_no1[0], length_ecma_str_u8_no1, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_no1[0], length_ecma_str_u8_no1, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_not_comp_no1( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no1[0], length_ecma_str_u16_not_comp_no1, ecma_vm_ptr, false)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handle_ecma_str_u8_no1, *handle_ecma_str_u16_not_comp_no1)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handle_ecma_str_u16_not_comp_no1, *handle_ecma_str_u8_no1)); @@ -1436,7 +1438,7 @@ TEST_F(EcmaStringTest, StringsAreEqual_004) */ TEST_F(EcmaStringTest, StringsAreEqual_005) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // StringsAreEqual(). uint16_t array_u16_comp_no1[] = {45, 92, 78}; @@ -1444,9 +1446,9 @@ TEST_F(EcmaStringTest, StringsAreEqual_005) uint32_t length_ecma_str_u16_comp_no1 = sizeof(array_u16_comp_no1) / sizeof(array_u16_comp_no1[0]); uint32_t length_ecma_str_u16_not_comp_no1 = sizeof(array_u16_not_comp_no1) / sizeof(array_u16_not_comp_no1[0]); JSHandle handle_ecma_str_u16_comp_no1( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no1[0], length_ecma_str_u16_comp_no1, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no1[0], length_ecma_str_u16_comp_no1, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_not_comp_no1( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no1[0], length_ecma_str_u16_not_comp_no1, ecma_vm_ptr, false)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handle_ecma_str_u16_comp_no1, *handle_ecma_str_u16_not_comp_no1)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handle_ecma_str_u16_not_comp_no1, *handle_ecma_str_u16_comp_no1)); @@ -1461,7 +1463,7 @@ TEST_F(EcmaStringTest, StringsAreEqual_005) */ TEST_F(EcmaStringTest, StringsAreEqual_006) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // StringsAreEqual(). uint16_t array_u16_not_comp_no1[] = {234, 345, 127, 2345, 65535, 5}; @@ -1471,13 +1473,13 @@ TEST_F(EcmaStringTest, StringsAreEqual_006) uint32_t length_ecma_str_u16_not_comp_no2 = sizeof(array_u16_not_comp_no2) / sizeof(array_u16_not_comp_no2[0]); uint32_t length_ecma_str_u16_not_comp_no3 = sizeof(array_u16_not_comp_no3) / sizeof(array_u16_not_comp_no3[0]); JSHandle handle_ecma_str_u16_not_comp_no1( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no1[0], length_ecma_str_u16_not_comp_no1, ecma_vm_ptr, false)); JSHandle handle_ecma_str_u16_not_comp_no2( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no2[0], length_ecma_str_u16_not_comp_no2, ecma_vm_ptr, false)); JSHandle handle_ecma_str_u16_not_comp_no3( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no3[0], length_ecma_str_u16_not_comp_no3, ecma_vm_ptr, false)); EXPECT_TRUE(EcmaString::StringsAreEqual(*handle_ecma_str_u16_not_comp_no1, *handle_ecma_str_u16_not_comp_no2)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handle_ecma_str_u16_not_comp_no1, *handle_ecma_str_u16_not_comp_no3)); @@ -1493,7 +1495,7 @@ TEST_F(EcmaStringTest, StringsAreEqual_006) */ TEST_F(EcmaStringTest, StringsAreEqualUtf8_001) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // StringsAreEqualUtf8(). EcmaString made by CreateFromUtf8(), Array:U8. uint8_t array_u8_no1[4] = {45, 92, 78}; @@ -1503,11 +1505,11 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf8_001) uint32_t length_ecma_str_u8_no2 = sizeof(array_u8_no2) - 1; uint32_t length_ecma_str_u8_no3 = sizeof(array_u8_no3) - 1; JSHandle handle_ecma_str_u8_no1( - thread, EcmaString::CreateFromUtf8(&array_u8_no1[0], length_ecma_str_u8_no1, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_no1[0], length_ecma_str_u8_no1, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u8_no2( - thread, EcmaString::CreateFromUtf8(&array_u8_no2[0], length_ecma_str_u8_no2, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_no2[0], length_ecma_str_u8_no2, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u8_no3( - thread, EcmaString::CreateFromUtf8(&array_u8_no3[0], length_ecma_str_u8_no3, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_no3[0], length_ecma_str_u8_no3, ecma_vm_ptr, true)); EXPECT_TRUE( EcmaString::StringsAreEqualUtf8(*handle_ecma_str_u8_no1, &array_u8_no1[0], length_ecma_str_u8_no1, true)); EXPECT_FALSE( @@ -1527,7 +1529,7 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf8_001) */ TEST_F(EcmaStringTest, StringsAreEqualUtf8_002) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // StringsAreEqualUtf8(). EcmaString made by CreateFromUtf16( , , , true), Array:U8. uint8_t array_u8_no1[4] = {45, 92, 78}; @@ -1539,11 +1541,11 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf8_002) uint32_t length_ecma_str_u16_comp_no2 = sizeof(array_u16_comp_no2) / sizeof(array_u16_comp_no2[0]); uint32_t length_ecma_str_u16_comp_no3 = sizeof(array_u16_comp_no3) / sizeof(array_u16_comp_no3[0]); JSHandle handle_ecma_str_u16_comp_no1( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no1[0], length_ecma_str_u16_comp_no1, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no1[0], length_ecma_str_u16_comp_no1, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_comp_no2( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no2[0], length_ecma_str_u16_comp_no2, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no2[0], length_ecma_str_u16_comp_no2, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_comp_no3( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no3[0], length_ecma_str_u16_comp_no3, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no3[0], length_ecma_str_u16_comp_no3, ecma_vm_ptr, true)); EXPECT_TRUE( EcmaString::StringsAreEqualUtf8(*handle_ecma_str_u16_comp_no1, &array_u8_no1[0], length_ecma_str_u8_no1, true)); EXPECT_FALSE(EcmaString::StringsAreEqualUtf8(*handle_ecma_str_u16_comp_no1, &array_u8_no1[0], @@ -1563,7 +1565,7 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf8_002) */ TEST_F(EcmaStringTest, StringsAreEqualUtf8_003) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // StringsAreEqualUtf8(). EcmaString made by CreateFromUtf16( , , , false), Array:U8. uint8_t array_u8_no1[4] = {45, 92, 78}; @@ -1577,16 +1579,16 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf8_003) uint32_t length_ecma_str_u16_not_comp_no3 = sizeof(array_u16_not_comp_no3) / sizeof(array_u16_not_comp_no3[0]); uint32_t length_ecma_str_u16_not_comp_no4 = sizeof(array_u16_not_comp_no4) / sizeof(array_u16_not_comp_no4[0]); JSHandle handle_ecma_str_u16_not_comp_no1( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no1[0], length_ecma_str_u16_not_comp_no1, ecma_vm_ptr, false)); JSHandle handle_ecma_str_u16_not_comp_no2( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no2[0], length_ecma_str_u16_not_comp_no2, ecma_vm_ptr, false)); JSHandle handle_ecma_str_u16_not_comp_no3( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no3[0], length_ecma_str_u16_not_comp_no3, ecma_vm_ptr, false)); JSHandle handle_ecma_str_u16_not_comp_no4( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no4[0], length_ecma_str_u16_not_comp_no4, ecma_vm_ptr, false)); EXPECT_TRUE(EcmaString::StringsAreEqualUtf8(*handle_ecma_str_u16_not_comp_no1, &array_u8_no1[0], length_ecma_str_u8_no1, false)); @@ -1609,7 +1611,7 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf8_003) */ TEST_F(EcmaStringTest, StringsAreEqualUtf16_001) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // StringsAreEqualUtf16(). EcmaString made by CreateFromUtf8, Array:U16(1-127). uint8_t array_u8_no1[4] = {45, 92, 78}; @@ -1621,11 +1623,11 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf16_001) uint32_t length_ecma_str_u8_no3 = sizeof(array_u8_no3) - 1; uint32_t length_ecma_str_u16_not_comp_no1 = sizeof(array_u16_not_comp_no1) / sizeof(array_u16_not_comp_no1[0]); JSHandle handle_ecma_str_u8_no1( - thread, EcmaString::CreateFromUtf8(&array_u8_no1[0], length_ecma_str_u8_no1, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_no1[0], length_ecma_str_u8_no1, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u8_no2( - thread, EcmaString::CreateFromUtf8(&array_u8_no2[0], length_ecma_str_u8_no2, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_no2[0], length_ecma_str_u8_no2, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u8_no3( - thread, EcmaString::CreateFromUtf8(&array_u8_no3[0], length_ecma_str_u8_no3, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8_no3[0], length_ecma_str_u8_no3, ecma_vm_ptr, true)); EXPECT_TRUE(EcmaString::StringsAreEqualUtf16(*handle_ecma_str_u8_no1, &array_u16_not_comp_no1[0], length_ecma_str_u16_not_comp_no1)); EXPECT_FALSE(EcmaString::StringsAreEqualUtf16(*handle_ecma_str_u8_no2, &array_u16_not_comp_no1[0], @@ -1643,7 +1645,7 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf16_001) */ TEST_F(EcmaStringTest, StringsAreEqualUtf16_002) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // StringsAreEqualUtf16(). EcmaString made by CreateFromUtf16( , , , true), Array:U16(1-127). uint16_t array_u16_comp_no1[] = {45, 92, 78}; @@ -1655,13 +1657,13 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf16_002) uint32_t length_ecma_str_u16_comp_no3 = sizeof(array_u16_comp_no3) / sizeof(array_u16_comp_no3[0]); uint32_t length_ecma_str_u16_comp_no4 = sizeof(array_u16_comp_no4) / sizeof(array_u16_comp_no4[0]); JSHandle handle_ecma_str_u16_comp_no1( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no1[0], length_ecma_str_u16_comp_no1, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no1[0], length_ecma_str_u16_comp_no1, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_comp_no2( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no2[0], length_ecma_str_u16_comp_no2, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no2[0], length_ecma_str_u16_comp_no2, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_comp_no3( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no3[0], length_ecma_str_u16_comp_no3, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no3[0], length_ecma_str_u16_comp_no3, ecma_vm_ptr, true)); JSHandle handle_ecma_str_u16_comp_no4( - thread, EcmaString::CreateFromUtf16(&array_u16_comp_no4[0], length_ecma_str_u16_comp_no4, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp_no4[0], length_ecma_str_u16_comp_no4, ecma_vm_ptr, true)); EXPECT_TRUE(EcmaString::StringsAreEqualUtf16(*handle_ecma_str_u16_comp_no1, &array_u16_comp_no1[0], length_ecma_str_u16_comp_no1)); EXPECT_FALSE(EcmaString::StringsAreEqualUtf16(*handle_ecma_str_u16_comp_no2, &array_u16_comp_no1[0], @@ -1681,7 +1683,7 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf16_002) */ TEST_F(EcmaStringTest, StringsAreEqualUtf16_003) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // StringsAreEqualUtf16(). EcmaString made by CreateFromUtf16( , , , false), Array:U16(0-65535). uint16_t array_u16_not_comp_no1[] = {25645, 25692, 25678}; @@ -1693,16 +1695,16 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf16_003) uint32_t length_ecma_str_u16_not_comp_no3 = sizeof(array_u16_not_comp_no3) / sizeof(array_u16_not_comp_no3[0]); uint32_t length_ecma_str_u16_not_comp_no4 = sizeof(array_u16_not_comp_no4) / sizeof(array_u16_not_comp_no4[0]); JSHandle handle_ecma_str_u16_not_comp_no1( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no1[0], length_ecma_str_u16_not_comp_no1, ecma_vm_ptr, false)); JSHandle handle_ecma_str_u16_not_comp_no2( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no2[0], length_ecma_str_u16_not_comp_no2, ecma_vm_ptr, false)); JSHandle handle_ecma_str_u16_not_comp_no3( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no3[0], length_ecma_str_u16_not_comp_no3, ecma_vm_ptr, false)); JSHandle handle_ecma_str_u16_not_comp_no4( - thread, + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp_no4[0], length_ecma_str_u16_not_comp_no4, ecma_vm_ptr, false)); EXPECT_TRUE(EcmaString::StringsAreEqualUtf16(*handle_ecma_str_u16_not_comp_no1, &array_u16_not_comp_no1[0], length_ecma_str_u16_not_comp_no1)); @@ -1762,13 +1764,13 @@ TEST_F(EcmaStringTest, ComputeHashcodeUtf16) */ TEST_F(EcmaStringTest, GetHashcode_001) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // GetHashcode(). EcmaString made by CreateFromUtf8(). uint8_t array_u8[] = {"abc"}; uint32_t length_ecma_str_u8 = sizeof(array_u8) - 1; JSHandle handle_ecma_str_u8( - thread, EcmaString::CreateFromUtf8(&array_u8[0], length_ecma_str_u8, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8[0], length_ecma_str_u8, ecma_vm_ptr, true)); uint32_t hash_expect = 0; for (uint32_t i = 0; i < length_ecma_str_u8; i++) { hash_expect = hash_expect * 31 + array_u8[i]; @@ -1785,13 +1787,13 @@ TEST_F(EcmaStringTest, GetHashcode_001) */ TEST_F(EcmaStringTest, GetHashcode_002) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // GetHashcode(). EcmaString made by CreateFromUtf16( , , , true). uint16_t array_u16_comp[] = {45, 92, 78, 24}; uint32_t length_ecma_str_u16_comp = sizeof(array_u16_comp) / sizeof(array_u16_comp[0]); JSHandle handle_ecma_str_u16_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_comp[0], length_ecma_str_u16_comp, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp[0], length_ecma_str_u16_comp, ecma_vm_ptr, true)); uint32_t hash_expect = 0; for (uint32_t i = 0; i < length_ecma_str_u16_comp; i++) { hash_expect = hash_expect * 31 + array_u16_comp[i]; @@ -1809,13 +1811,13 @@ TEST_F(EcmaStringTest, GetHashcode_002) */ TEST_F(EcmaStringTest, GetHashcode_003) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // GetHashcode(). EcmaString made by CreateFromUtf16( , , , false). uint16_t array_u16_not_comp[] = {199, 1, 256, 65535, 777}; uint32_t length_ecma_str_u16_not_comp = sizeof(array_u16_not_comp) / sizeof(array_u16_not_comp[0]); JSHandle handle_ecma_str_u16_not_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); uint32_t hash_expect = 0; for (uint32_t i = 0; i < length_ecma_str_u16_not_comp; i++) { hash_expect = hash_expect * 31 + array_u16_not_comp[i]; @@ -1824,7 +1826,7 @@ TEST_F(EcmaStringTest, GetHashcode_003) EcmaString::SetCompressedStringsEnabled(false); // Set compressed_strings_enabled_ false. JSHandle handle_ecma_str_u16_not_comp_disable_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); EXPECT_EQ(handle_ecma_str_u16_not_comp_disable_comp->GetHashcode(), static_cast(hash_expect)); EcmaString::SetCompressedStringsEnabled(true); // Set compressed_strings_enabled_ true(default). } @@ -1838,14 +1840,14 @@ TEST_F(EcmaStringTest, GetHashcode_003) */ TEST_F(EcmaStringTest, GetHashcode_004) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // GetHashcode(). EcmaString made by CreateEmptyString(). - JSHandle handle_ecma_str_empty(thread, EcmaString::CreateEmptyString(ecma_vm_ptr)); + JSHandle handle_ecma_str_empty(thread_, EcmaString::CreateEmptyString(ecma_vm_ptr)); EXPECT_EQ(handle_ecma_str_empty->GetHashcode(), 0); EcmaString::SetCompressedStringsEnabled(false); // Set compressed_strings_enabled_ false. - JSHandle handle_ecma_str_empty_disable_comp(thread, EcmaString::CreateEmptyString(ecma_vm_ptr)); + JSHandle handle_ecma_str_empty_disable_comp(thread_, EcmaString::CreateEmptyString(ecma_vm_ptr)); EXPECT_EQ(handle_ecma_str_empty_disable_comp->GetHashcode(), 0); EcmaString::SetCompressedStringsEnabled(true); // Set compressed_strings_enabled_ true(default). } @@ -1860,20 +1862,20 @@ TEST_F(EcmaStringTest, GetHashcode_004) */ TEST_F(EcmaStringTest, GetHashcode_005) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); // GetHashcode(). EcmaString made by AllocStringObject(). size_t size_alloc = 5; - JSHandle handle_ecma_str_alloc_comp(thread, + JSHandle handle_ecma_str_alloc_comp(thread_, EcmaString::AllocStringObject(size_alloc, true, ecma_vm_ptr)); - JSHandle handle_ecma_str_alloc_not_comp(thread, + JSHandle handle_ecma_str_alloc_not_comp(thread_, EcmaString::AllocStringObject(size_alloc, false, ecma_vm_ptr)); EXPECT_EQ(handle_ecma_str_alloc_comp->GetHashcode(), 0); EXPECT_EQ(handle_ecma_str_alloc_not_comp->GetHashcode(), 0); EcmaString::SetCompressedStringsEnabled(false); // Set compressed_strings_enabled_ false. JSHandle handle_ecma_str_alloc_not_comp_disable_comp( - thread, EcmaString::AllocStringObject(size_alloc, false, ecma_vm_ptr)); + thread_, EcmaString::AllocStringObject(size_alloc, false, ecma_vm_ptr)); EXPECT_EQ(handle_ecma_str_alloc_not_comp_disable_comp->GetHashcode(), 0); EcmaString::SetCompressedStringsEnabled(true); // Set compressed_strings_enabled_ true(default). } @@ -1887,24 +1889,24 @@ TEST_F(EcmaStringTest, GetHashcode_005) */ TEST_F(EcmaStringTest, GetCString) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); uint8_t array_u8[] = {"abc"}; uint32_t length_ecma_str_u8 = sizeof(array_u8) - 1; JSHandle handle_ecma_str_u8( - thread, EcmaString::CreateFromUtf8(&array_u8[0], length_ecma_str_u8, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8[0], length_ecma_str_u8, ecma_vm_ptr, true)); EXPECT_STREQ(PandaString(handle_ecma_str_u8->GetCString().get()).c_str(), "abc"); uint16_t array_u16_comp[] = {97, 98, 99}; uint32_t length_ecma_str_u16_comp = sizeof(array_u16_comp) / sizeof(array_u16_comp[0]); JSHandle handle_ecma_str_u16_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_comp[0], length_ecma_str_u16_comp, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp[0], length_ecma_str_u16_comp, ecma_vm_ptr, true)); EXPECT_STREQ(PandaString(handle_ecma_str_u16_comp->GetCString().get()).c_str(), "abc"); uint16_t array_u16_not_comp[] = {97, 98, 99}; uint32_t length_ecma_str_u16_not_comp = sizeof(array_u16_not_comp) / sizeof(array_u16_not_comp[0]); JSHandle handle_ecma_str_u16_not_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); EXPECT_STREQ(PandaString(handle_ecma_str_u16_not_comp->GetCString().get()).c_str(), "abc"); } @@ -1917,12 +1919,12 @@ TEST_F(EcmaStringTest, GetCString) */ TEST_F(EcmaStringTest, SetIsInternString) { - EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance); + EcmaVM *ecma_vm_ptr = EcmaVM::Cast(instance_); uint8_t array_u8[] = {"abc"}; uint32_t length_ecma_str_u8 = sizeof(array_u8) - 1; JSHandle handle_ecma_str_u8( - thread, EcmaString::CreateFromUtf8(&array_u8[0], length_ecma_str_u8, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf8(&array_u8[0], length_ecma_str_u8, ecma_vm_ptr, true)); EXPECT_FALSE(handle_ecma_str_u8->IsInternString()); handle_ecma_str_u8->SetIsInternString(); EXPECT_TRUE(handle_ecma_str_u8->IsInternString()); @@ -1930,7 +1932,7 @@ TEST_F(EcmaStringTest, SetIsInternString) uint16_t array_u16_comp[] = {97, 98, 99}; uint32_t length_ecma_str_u16_comp = sizeof(array_u16_comp) / sizeof(array_u16_comp[0]); JSHandle handle_ecma_str_u16_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_comp[0], length_ecma_str_u16_comp, ecma_vm_ptr, true)); + thread_, EcmaString::CreateFromUtf16(&array_u16_comp[0], length_ecma_str_u16_comp, ecma_vm_ptr, true)); EXPECT_FALSE(handle_ecma_str_u16_comp->IsInternString()); handle_ecma_str_u16_comp->SetIsInternString(); EXPECT_TRUE(handle_ecma_str_u16_comp->IsInternString()); @@ -1938,7 +1940,7 @@ TEST_F(EcmaStringTest, SetIsInternString) uint16_t array_u16_not_comp[] = {97, 98, 99}; uint32_t length_ecma_str_u16_not_comp = sizeof(array_u16_not_comp) / sizeof(array_u16_not_comp[0]); JSHandle handle_ecma_str_u16_not_comp( - thread, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); + thread_, EcmaString::CreateFromUtf16(&array_u16_not_comp[0], length_ecma_str_u16_not_comp, ecma_vm_ptr, false)); EXPECT_FALSE(handle_ecma_str_u16_not_comp->IsInternString()); handle_ecma_str_u16_not_comp->SetIsInternString(); EXPECT_TRUE(handle_ecma_str_u16_not_comp->IsInternString()); diff --git a/tests/runtime/common/glue_regs_test.cpp b/tests/runtime/common/glue_regs_test.cpp index ce614efc0..494a6b240 100644 --- a/tests/runtime/common/glue_regs_test.cpp +++ b/tests/runtime/common/glue_regs_test.cpp @@ -31,26 +31,26 @@ class GlueRegsTest : 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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {}; + JSThread *thread_ {}; private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; TEST_F(GlueRegsTest, ConstantClassTest) { - const GlobalEnvConstants *global_const = thread->GlobalConstants(); + const GlobalEnvConstants *global_const = thread_->GlobalConstants(); ASSERT_NE(global_const, nullptr); const JSTaggedValue *address = global_const->BeginSlot(); @@ -63,7 +63,7 @@ TEST_F(GlueRegsTest, ConstantClassTest) TEST_F(GlueRegsTest, ConstantSpecialTest) { - auto global_const = const_cast(thread->GlobalConstants()); + auto global_const = const_cast(thread_->GlobalConstants()); ASSERT_NE(global_const, nullptr); EXPECT_TRUE(global_const->GetUndefined().IsUndefined()); @@ -76,7 +76,7 @@ TEST_F(GlueRegsTest, ConstantSpecialTest) TEST_F(GlueRegsTest, ConstantStringTest) { - auto global_const = const_cast(thread->GlobalConstants()); + auto global_const = const_cast(thread_->GlobalConstants()); ASSERT_NE(global_const, nullptr); // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) @@ -91,7 +91,7 @@ TEST_F(GlueRegsTest, ConstantStringTest) TEST_F(GlueRegsTest, ConstantAccessorTest) { - auto global_const = const_cast(thread->GlobalConstants()); + auto global_const = const_cast(thread_->GlobalConstants()); ASSERT_NE(global_const, nullptr); // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) diff --git a/tests/runtime/common/huge_object_test.cpp b/tests/runtime/common/huge_object_test.cpp index 3c4cae07c..611fe3517 100644 --- a/tests/runtime/common/huge_object_test.cpp +++ b/tests/runtime/common/huge_object_test.cpp @@ -35,21 +35,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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {nullptr}; + JSThread *thread_ {nullptr}; private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; #if !defined(NDEBUG) @@ -86,12 +86,12 @@ static TaggedArray *LargeArrayTestCreate(JSThread *thread) TEST_F(HugeObjectTest, LargeArrayKeep) { #if !defined(NDEBUG) - TaggedArray *array = LargeArrayTestCreate(thread); + TaggedArray *array = LargeArrayTestCreate(thread_); EXPECT_TRUE(array != nullptr); - JSHandle array_handle(thread, array); - JSHandle new_obj(thread, JSObjectTestCreate(thread)); - array_handle->Set(thread, 0, new_obj.GetTaggedValue()); - auto ecma_vm = thread->GetEcmaVM(); + JSHandle array_handle(thread_, array); + JSHandle new_obj(thread_, JSObjectTestCreate(thread_)); + array_handle->Set(thread_, 0, new_obj.GetTaggedValue()); + auto ecma_vm = thread_->GetEcmaVM(); EXPECT_EQ(*array_handle, reinterpret_cast(array)); ecma_vm->CollectGarbage(); // Trigger GC. ecma_vm->CollectGarbage(); // Trigger GC. diff --git a/tests/runtime/common/js_arguments_test.cpp b/tests/runtime/common/js_arguments_test.cpp index 758a77d4f..0998bc4b6 100644 --- a/tests/runtime/common/js_arguments_test.cpp +++ b/tests/runtime/common/js_arguments_test.cpp @@ -43,21 +43,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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {nullptr}; + JSThread *thread_ {nullptr}; private: - ecmascript::EcmaHandleScope *scope {nullptr}; - PandaVM *instance {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; + PandaVM *instance_ {nullptr}; }; static JSFunction *JSObjectTestCreate(JSThread *thread) @@ -69,111 +69,111 @@ static JSFunction *JSObjectTestCreate(JSThread *thread) TEST_F(JsArgumentsTest, SetProperty) { - JSHandle arg_func(thread, JSObjectTestCreate(thread)); + JSHandle arg_func(thread_, JSObjectTestCreate(thread_)); JSHandle jsarg = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(arg_func), arg_func); - JSHandle arg = thread->GetEcmaVM()->GetFactory()->NewJSArguments(); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(arg_func), arg_func); + JSHandle arg = thread_->GetEcmaVM()->GetFactory()->NewJSArguments(); // NOLINTNEXTLINE(modernize-avoid-c-arrays) char array[] = "x"; - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(array)); - JSHandle value(thread, JSTaggedValue(1)); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(array)); + JSHandle value(thread_, JSTaggedValue(1)); // receive must be jsarg's conversion JSHandle receiver = JSHandle::Cast(jsarg); - EXPECT_TRUE(JSArguments::SetProperty(thread, arg, key, value, receiver)); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(jsarg), key).GetValue()->GetInt(), 1); - EXPECT_EQ(JSArguments::GetProperty(thread, jsarg, key).GetValue()->GetInt(), 1); - - JSHandle value2(thread, JSTaggedValue(2)); - EXPECT_TRUE(JSArguments::SetProperty(thread, arg, key, value2, receiver)); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(jsarg), key).GetValue()->GetInt(), 2); - EXPECT_EQ(JSArguments::GetProperty(thread, jsarg, key).GetValue()->GetInt(), 2); + EXPECT_TRUE(JSArguments::SetProperty(thread_, arg, key, value, receiver)); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(jsarg), key).GetValue()->GetInt(), 1); + EXPECT_EQ(JSArguments::GetProperty(thread_, jsarg, key).GetValue()->GetInt(), 1); + + JSHandle value2(thread_, JSTaggedValue(2)); + EXPECT_TRUE(JSArguments::SetProperty(thread_, arg, key, value2, receiver)); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(jsarg), key).GetValue()->GetInt(), 2); + EXPECT_EQ(JSArguments::GetProperty(thread_, jsarg, key).GetValue()->GetInt(), 2); } TEST_F(JsArgumentsTest, GetProperty) { - JSHandle arg_func(thread, JSObjectTestCreate(thread)); + JSHandle arg_func(thread_, JSObjectTestCreate(thread_)); JSHandle jsarg = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(arg_func), arg_func); - JSHandle arg = thread->GetEcmaVM()->GetFactory()->NewJSArguments(); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(arg_func), arg_func); + JSHandle arg = thread_->GetEcmaVM()->GetFactory()->NewJSArguments(); // NOLINTNEXTLINE(modernize-avoid-c-arrays) char array[] = "x"; - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(array)); - JSHandle value(thread, JSTaggedValue(1)); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(array)); + JSHandle value(thread_, JSTaggedValue(1)); JSHandle receiver = JSHandle::Cast(jsarg); - JSArguments::SetProperty(thread, arg, key, value, receiver); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(jsarg), key).GetValue()->GetInt(), 1); - EXPECT_EQ(JSArguments::GetProperty(thread, JSHandle(jsarg), key, receiver).GetValue()->GetInt(), 1); - - JSHandle value2(thread, JSTaggedValue(2)); - JSArguments::SetProperty(thread, arg, key, value2, receiver); - EXPECT_EQ(JSArguments::GetProperty(thread, jsarg, key).GetValue()->GetInt(), 2); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(jsarg), key).GetValue()->GetInt(), 2); + JSArguments::SetProperty(thread_, arg, key, value, receiver); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(jsarg), key).GetValue()->GetInt(), 1); + EXPECT_EQ(JSArguments::GetProperty(thread_, JSHandle(jsarg), key, receiver).GetValue()->GetInt(), 1); + + JSHandle value2(thread_, JSTaggedValue(2)); + JSArguments::SetProperty(thread_, arg, key, value2, receiver); + EXPECT_EQ(JSArguments::GetProperty(thread_, jsarg, key).GetValue()->GetInt(), 2); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(jsarg), key).GetValue()->GetInt(), 2); } TEST_F(JsArgumentsTest, DeleteProperty) { - JSHandle arg_func(thread, JSObjectTestCreate(thread)); + JSHandle arg_func(thread_, JSObjectTestCreate(thread_)); JSHandle jsarg = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(arg_func), arg_func); - JSHandle arg = thread->GetEcmaVM()->GetFactory()->NewJSArguments(); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(arg_func), arg_func); + JSHandle arg = thread_->GetEcmaVM()->GetFactory()->NewJSArguments(); // NOLINTNEXTLINE(modernize-avoid-c-arrays) char array[] = "delete"; - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(array)); - JSHandle value(thread, JSTaggedValue(1)); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(array)); + JSHandle value(thread_, JSTaggedValue(1)); JSHandle receiver = JSHandle::Cast(jsarg); - JSArguments::SetProperty(thread, arg, key, value, receiver); - EXPECT_EQ(JSArguments::GetProperty(thread, jsarg, key).GetValue()->GetInt(), 1); + JSArguments::SetProperty(thread_, arg, key, value, receiver); + EXPECT_EQ(JSArguments::GetProperty(thread_, jsarg, key).GetValue()->GetInt(), 1); // test delete - bool result = JSArguments::DeleteProperty(thread, JSHandle(jsarg), key); + bool result = JSArguments::DeleteProperty(thread_, JSHandle(jsarg), key); EXPECT_TRUE(result); - EXPECT_TRUE(JSObject::GetProperty(thread, JSHandle(jsarg), key).GetValue()->IsUndefined()); + EXPECT_TRUE(JSObject::GetProperty(thread_, JSHandle(jsarg), key).GetValue()->IsUndefined()); } TEST_F(JsArgumentsTest, DefineOwnProperty) { - JSHandle arg_func(thread, JSObjectTestCreate(thread)); + JSHandle arg_func(thread_, JSObjectTestCreate(thread_)); JSHandle jsarg = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(arg_func), arg_func); - JSHandle arg = thread->GetEcmaVM()->GetFactory()->NewJSArguments(); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(arg_func), arg_func); + JSHandle arg = thread_->GetEcmaVM()->GetFactory()->NewJSArguments(); - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("x")); - JSHandle value1(thread, JSTaggedValue(1)); - JSHandle value2(thread, JSTaggedValue(2)); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("x")); + JSHandle value1(thread_, JSTaggedValue(1)); + JSHandle value2(thread_, JSTaggedValue(2)); JSHandle receiver = JSHandle::Cast(jsarg); - JSArguments::SetProperty(thread, arg, key, value2, receiver); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(jsarg), key).GetValue()->GetInt(), 2); + JSArguments::SetProperty(thread_, arg, key, value2, receiver); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(jsarg), key).GetValue()->GetInt(), 2); - PropertyDescriptor desc(thread); + PropertyDescriptor desc(thread_); // set value1 desc.SetValue(value1); desc.SetWritable(false); - EXPECT_TRUE(JSArguments::DefineOwnProperty(thread, JSHandle(jsarg), key, desc)); - EXPECT_EQ(JSObject::GetProperty(thread, JSHandle(jsarg), key).GetValue()->GetInt(), 1); + EXPECT_TRUE(JSArguments::DefineOwnProperty(thread_, JSHandle(jsarg), key, desc)); + EXPECT_EQ(JSObject::GetProperty(thread_, JSHandle(jsarg), key).GetValue()->GetInt(), 1); } TEST_F(JsArgumentsTest, GetOwnProperty) { - JSHandle arg_func(thread, JSObjectTestCreate(thread)); + JSHandle arg_func(thread_, JSObjectTestCreate(thread_)); JSHandle jsarg = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(arg_func), arg_func); - JSHandle arg = thread->GetEcmaVM()->GetFactory()->NewJSArguments(); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(arg_func), arg_func); + JSHandle arg = thread_->GetEcmaVM()->GetFactory()->NewJSArguments(); - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("x")); - JSHandle value(thread, JSTaggedValue(1)); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("x")); + JSHandle value(thread_, JSTaggedValue(1)); JSHandle receiver = JSHandle::Cast(jsarg); - JSArguments::SetProperty(thread, arg, key, value, receiver); + JSArguments::SetProperty(thread_, arg, key, value, receiver); - PropertyDescriptor desc(thread); - JSHandle caller = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("caller"); + PropertyDescriptor desc(thread_); + JSHandle caller = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("caller"); // key is not caller EXPECT_FALSE(JSTaggedValue::SameValue(key.GetTaggedValue(), caller.GetTaggedValue())); - EXPECT_TRUE(JSArguments::GetOwnProperty(thread, JSHandle(jsarg), key, desc)); + EXPECT_TRUE(JSArguments::GetOwnProperty(thread_, JSHandle(jsarg), key, desc)); EXPECT_EQ(desc.GetValue()->GetInt(), 1); } } // namespace panda::test diff --git a/tests/runtime/common/js_array_iterator_test.cpp b/tests/runtime/common/js_array_iterator_test.cpp index 38942b4a7..293e1f0d4 100644 --- a/tests/runtime/common/js_array_iterator_test.cpp +++ b/tests/runtime/common/js_array_iterator_test.cpp @@ -42,12 +42,12 @@ 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_); } public: @@ -55,8 +55,8 @@ public: JSThread *thread {nullptr}; private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; /* diff --git a/tests/runtime/common/js_array_test.cpp b/tests/runtime/common/js_array_test.cpp index 4d716985f..6e007f58f 100644 --- a/tests/runtime/common/js_array_test.cpp +++ b/tests/runtime/common/js_array_test.cpp @@ -50,12 +50,12 @@ class JSArrayTest : 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_); } bool SetProperty(ObjectOperator *op, const JSHandle &value) @@ -65,171 +65,171 @@ public: protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {nullptr}; + JSThread *thread_ {nullptr}; private: - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; TEST_F(JSArrayTest, ArrayCreate) { - JSHandle length_key_handle(thread->GlobalConstants()->GetHandledLengthString()); - auto *arr = JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetObject(); + JSHandle length_key_handle(thread_->GlobalConstants()->GetHandledLengthString()); + auto *arr = JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetObject(); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, obj, length_key_handle).GetValue()->GetInt(), 0); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, obj, length_key_handle).GetValue()->GetInt(), 0); // NOLINTNEXTLINE(readability-magic-numbers) - auto *arr2 = JSArray::ArrayCreate(thread, JSTaggedNumber(10)).GetObject(); + auto *arr2 = JSArray::ArrayCreate(thread_, JSTaggedNumber(10)).GetObject(); EXPECT_TRUE(arr2 != nullptr); - JSHandle obj2(thread, arr2); - EXPECT_EQ(JSArray::GetProperty(thread, obj2, length_key_handle).GetValue()->GetInt(), 10); + JSHandle obj2(thread_, arr2); + EXPECT_EQ(JSArray::GetProperty(thread_, obj2, length_key_handle).GetValue()->GetInt(), 10); } TEST_F(JSArrayTest, ArraySpeciesCreate) { - JSHandle length_key_handle(thread->GlobalConstants()->GetHandledLengthString()); - auto *arr = JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetObject(); + JSHandle length_key_handle(thread_->GlobalConstants()->GetHandledLengthString()); + auto *arr = JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetObject(); 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); // NOLINTNEXTLINE(readability-magic-numbers) - JSArray *arr2 = JSArray::Cast(JSArray::ArraySpeciesCreate(thread, obj, JSTaggedNumber(10)).GetHeapObject()); + JSArray *arr2 = JSArray::Cast(JSArray::ArraySpeciesCreate(thread_, obj, JSTaggedNumber(10)).GetHeapObject()); EXPECT_TRUE(arr2 != nullptr); - JSHandle obj2(thread, arr2); + JSHandle obj2(thread_, arr2); // NOLINTNEXTLINE(readability-magic-numbers) - EXPECT_EQ(JSArray::GetProperty(thread, obj2, length_key_handle).GetValue()->GetInt(), 10); + EXPECT_EQ(JSArray::GetProperty(thread_, obj2, length_key_handle).GetValue()->GetInt(), 10); } TEST_F(JSArrayTest, DefineOwnProperty) { - auto ecma_vm = thread->GetEcmaVM(); + auto ecma_vm = thread_->GetEcmaVM(); auto factory = ecma_vm->GetFactory(); - JSHandle length_key_handle(thread->GlobalConstants()->GetHandledLengthString()); - auto *arr = JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetObject(); + JSHandle length_key_handle(thread_->GlobalConstants()->GetHandledLengthString()); + auto *arr = JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetObject(); EXPECT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - EXPECT_EQ(JSArray::GetProperty(thread, obj, length_key_handle).GetValue()->GetInt(), 0); + JSHandle obj(thread_, arr); + EXPECT_EQ(JSArray::GetProperty(thread_, obj, length_key_handle).GetValue()->GetInt(), 0); // NOLINTNEXTLINE(readability-magic-numbers) - PropertyDescriptor desc(thread, JSHandle(thread, JSTaggedValue(100)), true, true, true); + PropertyDescriptor desc(thread_, JSHandle(thread_, JSTaggedValue(100)), true, true, true); EcmaLanguageContext ecma_language_context; LanguageContext ctx(&ecma_language_context); EcmaString *string1 = *factory->NewFromString("1"); - JSHandle key1(thread, static_cast(string1)); - JSHandle index1(thread, JSTaggedValue(1)); - EXPECT_TRUE(JSArray::DefineOwnProperty(thread, JSHandle(obj), key1, desc)); - EXPECT_EQ(JSArray::GetProperty(thread, obj, length_key_handle).GetValue()->GetInt(), 2); - TaggedValue v = JSArray::GetProperty(thread, obj, key1).GetValue().GetTaggedValue(); + JSHandle key1(thread_, static_cast(string1)); + JSHandle index1(thread_, JSTaggedValue(1)); + EXPECT_TRUE(JSArray::DefineOwnProperty(thread_, JSHandle(obj), key1, desc)); + EXPECT_EQ(JSArray::GetProperty(thread_, obj, length_key_handle).GetValue()->GetInt(), 2); + TaggedValue v = JSArray::GetProperty(thread_, obj, key1).GetValue().GetTaggedValue(); // NOLINTNEXTLINE(readability-magic-numbers) EXPECT_EQ(v.GetInt(), 100); - v = JSArray::GetProperty(thread, obj, index1).GetValue().GetTaggedValue(); + v = JSArray::GetProperty(thread_, obj, index1).GetValue().GetTaggedValue(); // NOLINTNEXTLINE(readability-magic-numbers) EXPECT_EQ(v.GetInt(), 100); - EXPECT_EQ(JSArray::GetProperty(thread, obj, length_key_handle).GetValue()->GetInt(), 2); + EXPECT_EQ(JSArray::GetProperty(thread_, obj, length_key_handle).GetValue()->GetInt(), 2); EcmaString *string100 = *factory->NewFromString("100"); - JSHandle key100(thread, static_cast(string100)); + JSHandle key100(thread_, static_cast(string100)); // NOLINTNEXTLINE(readability-magic-numbers) - JSHandle index100(thread, JSTaggedValue(100)); + JSHandle index100(thread_, JSTaggedValue(100)); - EXPECT_TRUE(JSArray::DefineOwnProperty(thread, JSHandle(obj), key100, desc)); + EXPECT_TRUE(JSArray::DefineOwnProperty(thread_, JSHandle(obj), key100, desc)); // NOLINTNEXTLINE(readability-magic-numbers) - EXPECT_EQ(JSArray::GetProperty(thread, obj, key100).GetValue()->GetInt(), 100); + EXPECT_EQ(JSArray::GetProperty(thread_, obj, key100).GetValue()->GetInt(), 100); // NOLINTNEXTLINE(readability-magic-numbers) - EXPECT_EQ(JSArray::GetProperty(thread, obj, index100).GetValue()->GetInt(), 100); + EXPECT_EQ(JSArray::GetProperty(thread_, obj, index100).GetValue()->GetInt(), 100); // NOLINTNEXTLINE(readability-magic-numbers) - EXPECT_EQ(JSArray::GetProperty(thread, obj, length_key_handle).GetValue()->GetInt(), 101); + EXPECT_EQ(JSArray::GetProperty(thread_, obj, length_key_handle).GetValue()->GetInt(), 101); EcmaString *stringx = *factory->NewFromString("2147483646"); - JSHandle keyx(thread, static_cast(stringx)); + JSHandle keyx(thread_, static_cast(stringx)); // NOLINTNEXTLINE(readability-magic-numbers) - JSHandle indexx(thread, JSTaggedValue(2147483646U)); // 2147483646U + JSHandle indexx(thread_, JSTaggedValue(2147483646U)); // 2147483646U - EXPECT_TRUE(JSArray::DefineOwnProperty(thread, JSHandle(obj), keyx, desc)); + EXPECT_TRUE(JSArray::DefineOwnProperty(thread_, JSHandle(obj), keyx, desc)); // NOLINTNEXTLINE(readability-magic-numbers) - EXPECT_EQ(JSArray::GetProperty(thread, obj, keyx).GetValue()->GetInt(), 100); + EXPECT_EQ(JSArray::GetProperty(thread_, obj, keyx).GetValue()->GetInt(), 100); // NOLINTNEXTLINE(readability-magic-numbers) - EXPECT_EQ(JSArray::GetProperty(thread, obj, indexx).GetValue()->GetInt(), 100); + EXPECT_EQ(JSArray::GetProperty(thread_, obj, indexx).GetValue()->GetInt(), 100); // NOLINTNEXTLINE(readability-magic-numbers) - EXPECT_EQ(JSArray::GetProperty(thread, obj, length_key_handle).GetValue()->GetInt(), 2147483647); + EXPECT_EQ(JSArray::GetProperty(thread_, obj, length_key_handle).GetValue()->GetInt(), 2147483647); - EXPECT_TRUE(JSArray::DeleteProperty(thread, JSHandle(obj), indexx)); - EXPECT_TRUE(JSArray::GetProperty(thread, obj, keyx).GetValue()->IsUndefined()); - EXPECT_TRUE(JSArray::GetProperty(thread, obj, indexx).GetValue()->IsUndefined()); + EXPECT_TRUE(JSArray::DeleteProperty(thread_, JSHandle(obj), indexx)); + EXPECT_TRUE(JSArray::GetProperty(thread_, obj, keyx).GetValue()->IsUndefined()); + EXPECT_TRUE(JSArray::GetProperty(thread_, obj, indexx).GetValue()->IsUndefined()); } TEST_F(JSArrayTest, Next) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle values(factory->NewTaggedArray(5)); for (int i = 0; i < 5; i++) { - values->Set(thread, i, JSTaggedValue(i)); + values->Set(thread_, i, JSTaggedValue(i)); } - JSHandle array(JSArray::CreateArrayFromList(thread, values)); + JSHandle array(JSArray::CreateArrayFromList(thread_, values)); JSHandle iter(factory->NewJSArrayIterator(array, IterationKind::KEY)); - 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()); - [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecma_runtime_call_info.get()); + [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread_, ecma_runtime_call_info.get()); for (int i = 0; i < 5; i++) { ecma_runtime_call_info->SetThis(iter.GetTaggedValue()); JSTaggedValue ret = JSArrayIterator::Next(ecma_runtime_call_info.get()); - JSHandle result(thread, ret); - EXPECT_EQ(JSIterator::IteratorValue(thread, result)->GetInt(), i); + JSHandle result(thread_, ret); + EXPECT_EQ(JSIterator::IteratorValue(thread_, result)->GetInt(), i); } - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); } TEST_F(JSArrayTest, Iterator) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle values(factory->NewTaggedArray(5)); for (int i = 0; i < 5; i++) { - values->Set(thread, i, JSTaggedValue(i)); + values->Set(thread_, i, JSTaggedValue(i)); } - JSHandle array(JSArray::CreateArrayFromList(thread, values)); + JSHandle array(JSArray::CreateArrayFromList(thread_, values)); JSHandle key_iter(factory->NewJSArrayIterator(array, IterationKind::KEY)); JSHandle value_iter(factory->NewJSArrayIterator(array, IterationKind::VALUE)); JSHandle iter(factory->NewJSArrayIterator(array, IterationKind::KEY_AND_VALUE)); for (int i = 0; i < 5; i++) { if (i == 2) { - JSHandle key(thread, JSTaggedValue(i)); - JSObject::DeleteProperty(thread, JSHandle(array), key); + JSHandle key(thread_, JSTaggedValue(i)); + JSObject::DeleteProperty(thread_, JSHandle(array), key); } - JSHandle key_result(JSIterator::IteratorStep(thread, key_iter)); - JSHandle value_result(JSIterator::IteratorStep(thread, value_iter)); - JSHandle iter_result(JSIterator::IteratorStep(thread, iter)); - JSHandle iter_value(JSIterator::IteratorValue(thread, iter_result)); - JSHandle index_key(thread, JSTaggedValue(0)); - JSHandle element_key(thread, JSTaggedValue(1)); + JSHandle key_result(JSIterator::IteratorStep(thread_, key_iter)); + JSHandle value_result(JSIterator::IteratorStep(thread_, value_iter)); + JSHandle iter_result(JSIterator::IteratorStep(thread_, iter)); + JSHandle iter_value(JSIterator::IteratorValue(thread_, iter_result)); + JSHandle index_key(thread_, JSTaggedValue(0)); + JSHandle element_key(thread_, JSTaggedValue(1)); if (i == 2) { - EXPECT_EQ(i, JSIterator::IteratorValue(thread, key_result)->GetInt()); - EXPECT_EQ(JSTaggedValue::Undefined(), JSIterator::IteratorValue(thread, value_result).GetTaggedValue()); - EXPECT_EQ(i, JSObject::GetProperty(thread, iter_value, index_key).GetValue()->GetInt()); + EXPECT_EQ(i, JSIterator::IteratorValue(thread_, key_result)->GetInt()); + EXPECT_EQ(JSTaggedValue::Undefined(), JSIterator::IteratorValue(thread_, value_result).GetTaggedValue()); + EXPECT_EQ(i, JSObject::GetProperty(thread_, iter_value, index_key).GetValue()->GetInt()); EXPECT_EQ(JSTaggedValue::Undefined(), - JSObject::GetProperty(thread, iter_value, element_key).GetValue().GetTaggedValue()); + JSObject::GetProperty(thread_, iter_value, element_key).GetValue().GetTaggedValue()); continue; } - EXPECT_EQ(i, JSIterator::IteratorValue(thread, key_result)->GetInt()); - EXPECT_EQ(i, JSIterator::IteratorValue(thread, value_result)->GetInt()); - EXPECT_EQ(i, JSObject::GetProperty(thread, iter_value, index_key).GetValue()->GetInt()); - EXPECT_EQ(i, JSObject::GetProperty(thread, iter_value, element_key).GetValue()->GetInt()); + EXPECT_EQ(i, JSIterator::IteratorValue(thread_, key_result)->GetInt()); + EXPECT_EQ(i, JSIterator::IteratorValue(thread_, value_result)->GetInt()); + EXPECT_EQ(i, JSObject::GetProperty(thread_, iter_value, index_key).GetValue()->GetInt()); + EXPECT_EQ(i, JSObject::GetProperty(thread_, iter_value, element_key).GetValue()->GetInt()); } } TEST_F(JSArrayTest, AddProperty) { - auto *arr = JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetObject(); + auto *arr = JSArray::ArrayCreate(thread_, JSTaggedNumber(0)).GetObject(); ASSERT_TRUE(arr != nullptr); - JSHandle obj(thread, arr); - JSHandle key(thread, JSTaggedValue(1)); - JSHandle value(thread, JSTaggedValue(true)); + JSHandle obj(thread_, arr); + JSHandle key(thread_, JSTaggedValue(1)); + JSHandle value(thread_, JSTaggedValue(true)); - ObjectOperator op(thread, obj, key); + ObjectOperator op(thread_, obj, key); ASSERT_TRUE(SetProperty(&op, value)); ASSERT_TRUE(op.IsFound()); ASSERT_TRUE(op.IsFastMode()); diff --git a/tests/runtime/common/js_dataview_test.cpp b/tests/runtime/common/js_dataview_test.cpp index cfbe2653c..fde919464 100644 --- a/tests/runtime/common/js_dataview_test.cpp +++ b/tests/runtime/common/js_dataview_test.cpp @@ -37,21 +37,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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {nullptr}; + JSThread *thread_ {nullptr}; private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; /* @@ -84,7 +84,7 @@ TEST_F(JSDataViewTest, GetElementSize) */ TEST_F(JSDataViewTest, SetDataView) { - EcmaVM *ecma_vm_ptr = thread->GetEcmaVM(); + EcmaVM *ecma_vm_ptr = thread_->GetEcmaVM(); ObjectFactory *factory = ecma_vm_ptr->GetFactory(); JSHandle handle_global_env = ecma_vm_ptr->GetGlobalEnv(); @@ -95,7 +95,7 @@ TEST_F(JSDataViewTest, SetDataView) JSHandle handle_tag_val_func_array_buf(handle_func_array_buf); JSHandle handle_array_buf( factory->NewJSObjectByConstructor(handle_func_array_buf, handle_tag_val_func_array_buf)); - handle_array_buf->SetArrayBufferByteLength(thread, JSTaggedValue(length_data_array_buf)); + handle_array_buf->SetArrayBufferByteLength(thread_, JSTaggedValue(length_data_array_buf)); // Call "SetDataView" function through "NewJSDataView" function of "object_factory.cpp" JSHandle handle_data_view = @@ -103,9 +103,9 @@ TEST_F(JSDataViewTest, SetDataView) EXPECT_TRUE(handle_data_view->GetDataView().IsTrue()); // Call "SetDataView" function in this TEST_F. - handle_data_view->SetDataView(thread, JSTaggedValue::False()); + handle_data_view->SetDataView(thread_, JSTaggedValue::False()); EXPECT_TRUE(handle_data_view->GetDataView().IsFalse()); - handle_data_view->SetDataView(thread, JSTaggedValue::True()); + handle_data_view->SetDataView(thread_, JSTaggedValue::True()); EXPECT_TRUE(handle_data_view->GetDataView().IsTrue()); } @@ -119,7 +119,7 @@ TEST_F(JSDataViewTest, SetDataView) */ TEST_F(JSDataViewTest, SetViewedArrayBuffer) { - EcmaVM *ecma_vm_ptr = thread->GetEcmaVM(); + EcmaVM *ecma_vm_ptr = thread_->GetEcmaVM(); ObjectFactory *factory = ecma_vm_ptr->GetFactory(); JSHandle handle_func_array_buf(ecma_vm_ptr->GetGlobalEnv()->GetArrayBufferFunction()); JSHandle handle_tag_val_func_array_buf(handle_func_array_buf); @@ -133,22 +133,22 @@ TEST_F(JSDataViewTest, SetViewedArrayBuffer) factory->NewJSObjectByConstructor(handle_func_array_buf, handle_tag_val_func_array_buf)); JSHandle handle_array_buf2( factory->NewJSObjectByConstructor(handle_func_array_buf, handle_tag_val_func_array_buf)); - handle_array_buf1->SetArrayBufferByteLength(thread, JSTaggedValue(length_data_array_buf1)); - handle_array_buf2->SetArrayBufferByteLength(thread, JSTaggedValue(length_data_array_buf2)); + handle_array_buf1->SetArrayBufferByteLength(thread_, JSTaggedValue(length_data_array_buf1)); + handle_array_buf2->SetArrayBufferByteLength(thread_, JSTaggedValue(length_data_array_buf2)); // Call "SetViewedArrayBuffer" function through "NewJSDataView" function of "object_factory.cpp" JSHandle handle_data_view = factory->NewJSDataView(handle_array_buf1, offset_data_view, length_data_view); - JSHandle handle_tag_val_data_view_from1(thread, handle_array_buf1.GetTaggedValue()); - JSHandle handle_tag_val_data_view_to1(thread, handle_data_view->GetViewedArrayBuffer()); - EXPECT_TRUE(JSTaggedValue::Equal(thread, handle_tag_val_data_view_from1, handle_tag_val_data_view_to1)); + JSHandle handle_tag_val_data_view_from1(thread_, handle_array_buf1.GetTaggedValue()); + JSHandle handle_tag_val_data_view_to1(thread_, handle_data_view->GetViewedArrayBuffer()); + EXPECT_TRUE(JSTaggedValue::Equal(thread_, handle_tag_val_data_view_from1, handle_tag_val_data_view_to1)); // Call "SetViewedArrayBuffer" function in this TEST_F. - handle_data_view->SetViewedArrayBuffer(thread, handle_array_buf2.GetTaggedValue()); - JSHandle handle_tag_val_data_view_from2(thread, handle_array_buf2.GetTaggedValue()); - JSHandle handle_tag_val_data_view_to2(thread, handle_data_view->GetViewedArrayBuffer()); - EXPECT_TRUE(JSTaggedValue::Equal(thread, handle_tag_val_data_view_from2, handle_tag_val_data_view_to2)); - EXPECT_FALSE(JSTaggedValue::Equal(thread, handle_tag_val_data_view_from1, handle_tag_val_data_view_from2)); + handle_data_view->SetViewedArrayBuffer(thread_, handle_array_buf2.GetTaggedValue()); + JSHandle handle_tag_val_data_view_from2(thread_, handle_array_buf2.GetTaggedValue()); + JSHandle handle_tag_val_data_view_to2(thread_, handle_data_view->GetViewedArrayBuffer()); + EXPECT_TRUE(JSTaggedValue::Equal(thread_, handle_tag_val_data_view_from2, handle_tag_val_data_view_to2)); + EXPECT_FALSE(JSTaggedValue::Equal(thread_, handle_tag_val_data_view_from1, handle_tag_val_data_view_from2)); } /* @@ -161,7 +161,7 @@ TEST_F(JSDataViewTest, SetViewedArrayBuffer) */ TEST_F(JSDataViewTest, SetByteLength) { - EcmaVM *ecma_vm_ptr = thread->GetEcmaVM(); + EcmaVM *ecma_vm_ptr = thread_->GetEcmaVM(); ObjectFactory *factory = ecma_vm_ptr->GetFactory(); JSHandle handle_func_array_buf(ecma_vm_ptr->GetGlobalEnv()->GetArrayBufferFunction()); JSHandle handle_tag_val_func_array_buf(handle_func_array_buf); @@ -170,10 +170,10 @@ TEST_F(JSDataViewTest, SetByteLength) int32_t offset_data_view = 4; int32_t length_data_view1 = 4; int32_t length_data_view2 = 2; - JSHandle handle_tag_val_length_data_view2(thread, JSTaggedValue(length_data_view2)); + JSHandle handle_tag_val_length_data_view2(thread_, JSTaggedValue(length_data_view2)); JSHandle handle_array_buf( factory->NewJSObjectByConstructor(handle_func_array_buf, handle_tag_val_func_array_buf)); - handle_array_buf->SetArrayBufferByteLength(thread, JSTaggedValue(length_data_array_buf)); + handle_array_buf->SetArrayBufferByteLength(thread_, JSTaggedValue(length_data_array_buf)); // Call "SetByteLength" function through "NewJSDataView" function of "object_factory.cpp" JSHandle handle_data_view = @@ -181,7 +181,7 @@ TEST_F(JSDataViewTest, SetByteLength) EXPECT_EQ(handle_data_view->GetByteLength().GetNumber(), length_data_view1); // Call "SetByteLength" function in this TEST_F. - handle_data_view->SetByteLength(thread, handle_tag_val_length_data_view2); + handle_data_view->SetByteLength(thread_, handle_tag_val_length_data_view2); EXPECT_EQ(handle_data_view->GetByteLength().GetNumber(), length_data_view2); } @@ -195,7 +195,7 @@ TEST_F(JSDataViewTest, SetByteLength) */ TEST_F(JSDataViewTest, SetByteOffset) { - EcmaVM *ecma_vm_ptr = thread->GetEcmaVM(); + EcmaVM *ecma_vm_ptr = thread_->GetEcmaVM(); ObjectFactory *factory = ecma_vm_ptr->GetFactory(); JSHandle handle_func_array_buf1(ecma_vm_ptr->GetGlobalEnv()->GetArrayBufferFunction()); JSHandle handle_tag_val_func_array_buf1(handle_func_array_buf1); @@ -204,10 +204,10 @@ TEST_F(JSDataViewTest, SetByteOffset) int32_t offset_data_view1 = 4; int32_t offset_data_view2 = 6; int32_t length_data_view = 2; - JSHandle handle_tag_val_offset_data_view2(thread, JSTaggedValue(offset_data_view2)); + JSHandle handle_tag_val_offset_data_view2(thread_, JSTaggedValue(offset_data_view2)); JSHandle handle_array_buf( factory->NewJSObjectByConstructor(handle_func_array_buf1, handle_tag_val_func_array_buf1)); - handle_array_buf->SetArrayBufferByteLength(thread, JSTaggedValue(length_data_array_buf)); + handle_array_buf->SetArrayBufferByteLength(thread_, JSTaggedValue(length_data_array_buf)); // Call "SetByteOffset" function through "NewJSDataView" function of "object_factory.cpp" JSHandle handle_data_view = @@ -215,7 +215,7 @@ TEST_F(JSDataViewTest, SetByteOffset) EXPECT_EQ(handle_data_view->GetByteOffset().GetNumber(), offset_data_view1); // Call "SetByteOffset" function in this TEST_F. - handle_data_view->SetByteOffset(thread, handle_tag_val_offset_data_view2); + handle_data_view->SetByteOffset(thread_, handle_tag_val_offset_data_view2); EXPECT_EQ(handle_data_view->GetByteOffset().GetNumber(), offset_data_view2); } } // namespace panda::test diff --git a/tests/runtime/common/js_date_test.cpp b/tests/runtime/common/js_date_test.cpp index 24db2da4a..b4374296d 100644 --- a/tests/runtime/common/js_date_test.cpp +++ b/tests/runtime/common/js_date_test.cpp @@ -32,21 +32,21 @@ class JSDateTest : 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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {}; + JSThread *thread_ {}; private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; JSDate *JSDateCreate(JSThread *thread) @@ -63,12 +63,12 @@ JSDate *JSDateCreate(JSThread *thread) TEST_F(JSDateTest, Create) { double tm = 0.0; - JSHandle js_date(thread, JSDateCreate(thread)); + JSHandle js_date(thread_, JSDateCreate(thread_)); EXPECT_EQ(js_date->GetTimeValue(), JSTaggedValue(tm)); EXPECT_EQ(js_date->GetLocalOffset(), JSTaggedValue(JSDate::MAX_DOUBLE)); // NOLINTNEXTLINE(readability-magic-numbers) tm = 28 * 60 * 60 * 1000; - js_date->SetTimeValue(thread, JSTaggedValue(tm)); + js_date->SetTimeValue(thread_, JSTaggedValue(tm)); [[maybe_unused]] double temp = js_date->GetTimeValue().GetDouble(); EXPECT_EQ(js_date->GetTimeValue(), JSTaggedValue(tm)); diff --git a/tests/runtime/common/js_forin_iterator_test.cpp b/tests/runtime/common/js_forin_iterator_test.cpp index d9fcd83de..15bf7bbaa 100644 --- a/tests/runtime/common/js_forin_iterator_test.cpp +++ b/tests/runtime/common/js_forin_iterator_test.cpp @@ -31,61 +31,61 @@ class JSForinIteratorTest : 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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {}; + JSThread *thread_ {}; private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; TEST_F(JSForinIteratorTest, Create) { - JSHandle null_handle(thread, JSTaggedValue::Null()); - JSHandle grandfather = JSObject::ObjectCreate(thread, null_handle); - EXPECT_TRUE(grandfather->GetPrototype(thread).IsNull()); + JSHandle null_handle(thread_, JSTaggedValue::Null()); + JSHandle grandfather = JSObject::ObjectCreate(thread_, null_handle); + EXPECT_TRUE(grandfather->GetPrototype(thread_).IsNull()); - JSHandle father = JSObject::ObjectCreate(thread, grandfather); + JSHandle father = JSObject::ObjectCreate(thread_, grandfather); - JSHandle son = JSObject::ObjectCreate(thread, father); + JSHandle son = JSObject::ObjectCreate(thread_, father); - JSHandle key1(thread->GetEcmaVM()->GetFactory()->NewFromString("key1")); - JSHandle key2(thread->GetEcmaVM()->GetFactory()->NewFromString("key2")); - JSHandle key3(thread->GetEcmaVM()->GetFactory()->NewFromString("key3")); - JSHandle key1_value(thread, JSTaggedValue(1)); - JSHandle key2_value(thread, JSTaggedValue(2)); - JSHandle key3_value(thread, JSTaggedValue(3)); + JSHandle key1(thread_->GetEcmaVM()->GetFactory()->NewFromString("key1")); + JSHandle key2(thread_->GetEcmaVM()->GetFactory()->NewFromString("key2")); + JSHandle key3(thread_->GetEcmaVM()->GetFactory()->NewFromString("key3")); + JSHandle key1_value(thread_, JSTaggedValue(1)); + JSHandle key2_value(thread_, JSTaggedValue(2)); + JSHandle key3_value(thread_, JSTaggedValue(3)); - JSObject::SetProperty(thread, JSHandle(grandfather), key3, key3_value); - JSObject::SetProperty(thread, JSHandle(father), key2, key2_value); + JSObject::SetProperty(thread_, JSHandle(grandfather), key3, key3_value); + JSObject::SetProperty(thread_, JSHandle(father), key2, key2_value); - JSObject::SetProperty(thread, JSHandle(son), key1, key1_value); - JSObject::SetProperty(thread, JSHandle(son), key2, key1_value); - JSObject::SetProperty(thread, JSHandle(son), key3, key1_value); + JSObject::SetProperty(thread_, JSHandle(son), key1, key1_value); + JSObject::SetProperty(thread_, JSHandle(son), key2, key1_value); + JSObject::SetProperty(thread_, JSHandle(son), key3, key1_value); - JSHandle it = thread->GetEcmaVM()->GetFactory()->NewJSForinIterator(JSHandle(son)); - std::pair n1 = JSForInIterator::NextInternal(thread, it); + JSHandle it = thread_->GetEcmaVM()->GetFactory()->NewJSForinIterator(JSHandle(son)); + std::pair n1 = JSForInIterator::NextInternal(thread_, it); EXPECT_EQ(n1.first, key1.GetTaggedValue()); EXPECT_FALSE(n1.second); - std::pair n2 = JSForInIterator::NextInternal(thread, it); + std::pair n2 = JSForInIterator::NextInternal(thread_, it); EXPECT_EQ(n2.first, key2.GetTaggedValue()); EXPECT_FALSE(n2.second); - std::pair n3 = JSForInIterator::NextInternal(thread, it); + std::pair n3 = JSForInIterator::NextInternal(thread_, it); EXPECT_EQ(n3.first, key3.GetTaggedValue()); EXPECT_FALSE(n3.second); - std::pair n4 = JSForInIterator::NextInternal(thread, it); + std::pair n4 = JSForInIterator::NextInternal(thread_, it); EXPECT_EQ(n4.first, JSTaggedValue::Undefined()); EXPECT_TRUE(n4.second); } diff --git a/tests/runtime/common/js_handle_test.cpp b/tests/runtime/common/js_handle_test.cpp index c6ee53f91..31d27b7b6 100644 --- a/tests/runtime/common/js_handle_test.cpp +++ b/tests/runtime/common/js_handle_test.cpp @@ -40,36 +40,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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {nullptr}; + JSThread *thread_ {nullptr}; private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; TEST_F(JSHandleTest, NewGlobalHandle) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - auto global = thread->GetEcmaGlobalStorage(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + auto global = thread_->GetEcmaGlobalStorage(); uintptr_t global_string = 0; { - [[maybe_unused]] EcmaHandleScope scope_nested(thread); + [[maybe_unused]] EcmaHandleScope scope_nested(thread_); auto string1 = factory->NewFromString("test1"); global_string = global->NewGlobalHandle(string1.GetTaggedType()); } // trigger GC - thread->GetEcmaVM()->CollectGarbage(); + thread_->GetEcmaVM()->CollectGarbage(); // check result EXPECT_TRUE(factory->NewFromString("test1")->Compare(*reinterpret_cast(global_string)) == 0); @@ -91,13 +91,13 @@ static void FillGlobalString(uintptr_t global_string[], int length, EcmaGlobalSt TEST_F(JSHandleTest, NewGlobalHandle1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - auto global = thread->GetEcmaGlobalStorage(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + auto global = thread_->GetEcmaGlobalStorage(); uintptr_t global_string[600] = {0}; - FillGlobalString(global_string, 600, global, factory, thread); + FillGlobalString(global_string, 600, global, factory, thread_); // trigger GC - thread->GetEcmaVM()->CollectGarbage(); + thread_->GetEcmaVM()->CollectGarbage(); for (int i = 300; i > 200; i--) { global->DisposeGlobalHandle(global_string[i]); } @@ -108,7 +108,7 @@ TEST_F(JSHandleTest, NewGlobalHandle1) 0); } // trigger GC - thread->GetEcmaVM()->CollectGarbage(); + thread_->GetEcmaVM()->CollectGarbage(); for (int i = 301; i < 600; i++) { std::string test = "test" + std::to_string(i); EXPECT_TRUE(factory->NewFromString(test.c_str())->Compare(*reinterpret_cast(global_string[i])) == @@ -118,11 +118,11 @@ TEST_F(JSHandleTest, NewGlobalHandle1) TEST_F(JSHandleTest, DisposeGlobalHandle) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - auto global = thread->GetEcmaGlobalStorage(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + auto global = thread_->GetEcmaGlobalStorage(); uintptr_t global_string[600] = {0}; - FillGlobalString(global_string, 600, global, factory, thread); + FillGlobalString(global_string, 600, global, factory, thread_); for (int i = 512; i > 200; i--) { global->DisposeGlobalHandle(global_string[i]); } @@ -137,18 +137,18 @@ TEST_F(JSHandleTest, DisposeGlobalHandle) TEST_F(JSHandleTest, DisposeAndNewGlobalHandle) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - auto global = thread->GetEcmaGlobalStorage(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + auto global = thread_->GetEcmaGlobalStorage(); uintptr_t global_string[768] = {0}; - FillGlobalString(global_string, 768, global, factory, thread); + FillGlobalString(global_string, 768, global, factory, thread_); for (int i = 767; i > 200; i--) { global->DisposeGlobalHandle(global_string[i]); } // trigger GC - thread->GetEcmaVM()->CollectGarbage(); + thread_->GetEcmaVM()->CollectGarbage(); { - [[maybe_unused]] EcmaHandleScope scope_nested(thread); + [[maybe_unused]] EcmaHandleScope scope_nested(thread_); for (int i = 200; i < 400; i++) { std::string test = "test" + std::to_string(i); auto string1 = factory->NewFromString(test.c_str()); @@ -165,25 +165,25 @@ TEST_F(JSHandleTest, DisposeAndNewGlobalHandle) TEST_F(JSHandleTest, DISABLED_NewWeakGlobalHandle) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - auto global = thread->GetEcmaGlobalStorage(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + auto global = thread_->GetEcmaGlobalStorage(); uintptr_t global_string = 0; { - [[maybe_unused]] EcmaHandleScope scope_nested(thread); + [[maybe_unused]] EcmaHandleScope scope_nested(thread_); auto string1 = factory->NewFromString("test1"); global_string = global->NewGlobalHandle(string1.GetTaggedType()); global_string = global->SetWeak(global_string); // trigger GC - thread->GetEcmaVM()->CollectGarbage(); + thread_->GetEcmaVM()->CollectGarbage(); // check result EXPECT_TRUE(factory->NewFromString("test1")->Compare(*reinterpret_cast(global_string)) == 0); EXPECT_TRUE(global->IsWeak(global_string)); } // trigger GC - thread->GetEcmaVM()->CollectGarbage(); + thread_->GetEcmaVM()->CollectGarbage(); // check weak reference JSTaggedType result = *reinterpret_cast(global_string); @@ -192,12 +192,12 @@ TEST_F(JSHandleTest, DISABLED_NewWeakGlobalHandle) TEST_F(JSHandleTest, DISABLED_NewWeakGlobalHandle1) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - auto global = thread->GetEcmaGlobalStorage(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + auto global = thread_->GetEcmaGlobalStorage(); uintptr_t global_string[800] = {0}; { - [[maybe_unused]] EcmaHandleScope scope_nested(thread); + [[maybe_unused]] EcmaHandleScope scope_nested(thread_); for (int i = 0; i < 800; i++) { std::string test = "test" + std::to_string(i); auto string1 = factory->NewFromString(test.c_str()); @@ -209,7 +209,7 @@ TEST_F(JSHandleTest, DISABLED_NewWeakGlobalHandle1) global->DisposeGlobalHandle(global_string[i]); } // trigger GC - thread->GetEcmaVM()->CollectGarbage(); + thread_->GetEcmaVM()->CollectGarbage(); // check result for (int i = 0; i <= 200; i++) { std::string test = "test" + std::to_string(i); @@ -218,7 +218,7 @@ TEST_F(JSHandleTest, DISABLED_NewWeakGlobalHandle1) } } // trigger GC - thread->GetEcmaVM()->CollectGarbage(); + thread_->GetEcmaVM()->CollectGarbage(); for (int i = 601; i < 800; i++) { EXPECT_TRUE(*reinterpret_cast(global_string[i]) == JSTaggedValue::Undefined().GetRawData()); } diff --git a/tests/runtime/common/js_iterator_test.cpp b/tests/runtime/common/js_iterator_test.cpp index 9b0f57dc9..ba7be9179 100644 --- a/tests/runtime/common/js_iterator_test.cpp +++ b/tests/runtime/common/js_iterator_test.cpp @@ -38,94 +38,94 @@ class JSIteratorTest : 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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {}; + JSThread *thread_ {}; private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; TEST_F(JSIteratorTest, GetIterator) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle data(factory->NewTaggedArray(2)); - data->Set(thread, 0, JSTaggedValue(1)); - data->Set(thread, 1, JSTaggedValue(1)); - JSHandle array(JSArray::CreateArrayFromList(thread, data)); - EXPECT_TRUE(array->IsArray(thread)); - JSHandle iter(JSIterator::GetIterator(thread, array)); + data->Set(thread_, 0, JSTaggedValue(1)); + data->Set(thread_, 1, JSTaggedValue(1)); + JSHandle array(JSArray::CreateArrayFromList(thread_, data)); + EXPECT_TRUE(array->IsArray(thread_)); + JSHandle iter(JSIterator::GetIterator(thread_, array)); EXPECT_TRUE(iter->IsJSArrayIterator()); - EXPECT_TRUE(iter->GetIteratedArray().IsArray(thread)); + EXPECT_TRUE(iter->GetIteratedArray().IsArray(thread_)); } TEST_F(JSIteratorTest, IteratorNext) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle value_str = thread->GlobalConstants()->GetHandledValueString(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle value_str = thread_->GlobalConstants()->GetHandledValueString(); JSHandle data(factory->NewTaggedArray(1)); - data->Set(thread, 0, JSTaggedValue(1)); - JSHandle array(JSArray::CreateArrayFromList(thread, data)); - JSHandle iter(JSIterator::GetIterator(thread, array)); - JSHandle result(JSIterator::IteratorNextOld(thread, iter)); - JSHandle result_value(JSObject::GetProperty(thread, result, value_str).GetValue()); + data->Set(thread_, 0, JSTaggedValue(1)); + JSHandle array(JSArray::CreateArrayFromList(thread_, data)); + JSHandle iter(JSIterator::GetIterator(thread_, array)); + JSHandle result(JSIterator::IteratorNextOld(thread_, iter)); + JSHandle result_value(JSObject::GetProperty(thread_, result, value_str).GetValue()); EXPECT_EQ(result_value->GetInt(), 1); } TEST_F(JSIteratorTest, IteratorComplete) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle data(factory->NewTaggedArray(2)); - data->Set(thread, 0, JSTaggedValue(1)); - data->Set(thread, 1, JSTaggedValue(1)); - JSHandle array(JSArray::CreateArrayFromList(thread, data)); - JSHandle iter(JSIterator::GetIterator(thread, array)); - JSHandle result1(JSIterator::IteratorNextOld(thread, iter)); - EXPECT_EQ(false, JSIterator::IteratorComplete(thread, result1)); - JSHandle result2(JSIterator::IteratorNextOld(thread, iter)); - EXPECT_EQ(false, JSIterator::IteratorComplete(thread, result2)); - JSHandle result3(JSIterator::IteratorNextOld(thread, iter)); - EXPECT_EQ(true, JSIterator::IteratorComplete(thread, result3)); + data->Set(thread_, 0, JSTaggedValue(1)); + data->Set(thread_, 1, JSTaggedValue(1)); + JSHandle array(JSArray::CreateArrayFromList(thread_, data)); + JSHandle iter(JSIterator::GetIterator(thread_, array)); + JSHandle result1(JSIterator::IteratorNextOld(thread_, iter)); + EXPECT_EQ(false, JSIterator::IteratorComplete(thread_, result1)); + JSHandle result2(JSIterator::IteratorNextOld(thread_, iter)); + EXPECT_EQ(false, JSIterator::IteratorComplete(thread_, result2)); + JSHandle result3(JSIterator::IteratorNextOld(thread_, iter)); + EXPECT_EQ(true, JSIterator::IteratorComplete(thread_, result3)); } TEST_F(JSIteratorTest, IteratorValue) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle data(factory->NewTaggedArray(3)); - data->Set(thread, 0, JSTaggedValue(1)); - data->Set(thread, 1, JSTaggedValue(1)); - data->Set(thread, 2, JSTaggedValue(1)); - JSHandle array(JSArray::CreateArrayFromList(thread, data)); - JSHandle iter(JSIterator::GetIterator(thread, array)); - JSHandle result(JSIterator::IteratorNextOld(thread, iter)); - JSHandle result_value(JSIterator::IteratorValue(thread, result)); + data->Set(thread_, 0, JSTaggedValue(1)); + data->Set(thread_, 1, JSTaggedValue(1)); + data->Set(thread_, 2, JSTaggedValue(1)); + JSHandle array(JSArray::CreateArrayFromList(thread_, data)); + JSHandle iter(JSIterator::GetIterator(thread_, array)); + JSHandle result(JSIterator::IteratorNextOld(thread_, iter)); + JSHandle result_value(JSIterator::IteratorValue(thread_, result)); EXPECT_EQ(result_value->GetInt(), 1); } TEST_F(JSIteratorTest, IteratorStep) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle data(factory->NewTaggedArray(2)); - data->Set(thread, 0, JSTaggedValue(1)); - data->Set(thread, 1, JSTaggedValue(2)); - JSHandle array(JSArray::CreateArrayFromList(thread, data)); - JSHandle iter(JSIterator::GetIterator(thread, array)); - JSHandle result1(JSIterator::IteratorStep(thread, iter)); - EXPECT_EQ(JSIterator::IteratorValue(thread, result1)->GetInt(), 1); - JSHandle result2(JSIterator::IteratorStep(thread, iter)); - EXPECT_EQ(JSIterator::IteratorValue(thread, result2)->GetInt(), 2); - JSHandle result3(JSIterator::IteratorStep(thread, iter)); + data->Set(thread_, 0, JSTaggedValue(1)); + data->Set(thread_, 1, JSTaggedValue(2)); + JSHandle array(JSArray::CreateArrayFromList(thread_, data)); + JSHandle iter(JSIterator::GetIterator(thread_, array)); + JSHandle result1(JSIterator::IteratorStep(thread_, iter)); + EXPECT_EQ(JSIterator::IteratorValue(thread_, result1)->GetInt(), 1); + JSHandle result2(JSIterator::IteratorStep(thread_, iter)); + EXPECT_EQ(JSIterator::IteratorValue(thread_, result2)->GetInt(), 2); + JSHandle result3(JSIterator::IteratorStep(thread_, iter)); EXPECT_EQ(result3.GetTaggedValue(), JSTaggedValue::False()); } diff --git a/tests/runtime/common/js_map_test.cpp b/tests/runtime/common/js_map_test.cpp index e51ee1783..8ed3d89b4 100644 --- a/tests/runtime/common/js_map_test.cpp +++ b/tests/runtime/common/js_map_test.cpp @@ -40,33 +40,33 @@ class JSMapTest : 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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {}; + JSThread *thread_ {}; JSMap *CreateMap() { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle constructor = env->GetMapFunction(); JSHandle map = JSHandle::Cast(factory->NewJSObjectByConstructor(JSHandle(constructor), constructor)); - JSHandle hash_map = LinkedHashMap::Create(thread); - map->SetLinkedMap(thread, hash_map); + JSHandle hash_map = LinkedHashMap::Create(thread_); + map->SetLinkedMap(thread_, hash_map); return *map; } private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; TEST_F(JSMapTest, MapCreate) @@ -77,22 +77,22 @@ TEST_F(JSMapTest, MapCreate) TEST_F(JSMapTest, AddAndHas) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // create js_map - JSHandle map(thread, CreateMap()); + JSHandle map(thread_, CreateMap()); JSHandle key(factory->NewFromString("key")); - JSHandle value(thread, JSTaggedValue(1)); - JSMap::Set(thread, map, key, value); + JSHandle value(thread_, JSTaggedValue(1)); + JSMap::Set(thread_, map, key, value); int hash = LinkedHash::Hash(key.GetTaggedValue()); EXPECT_TRUE(map->Has(key.GetTaggedValue(), hash)); } TEST_F(JSMapTest, DeleteAndGet) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // create js_map - JSHandle map(thread, CreateMap()); + JSHandle map(thread_, CreateMap()); // add 40 keys // NOLINTNEXTLINE(modernize-avoid-c-arrays) @@ -101,8 +101,8 @@ TEST_F(JSMapTest, DeleteAndGet) for (int i = 0; i < 40; i++) { key_array[3] = '1' + i; JSHandle key(factory->NewFromString(key_array)); - JSHandle value(thread, JSTaggedValue(i)); - JSMap::Set(thread, map, key, value); + JSHandle value(thread_, JSTaggedValue(i)); + JSMap::Set(thread_, map, key, value); int hash = LinkedHash::Hash(key.GetTaggedValue()); EXPECT_TRUE(map->Has(key.GetTaggedValue(), hash)); } @@ -111,7 +111,7 @@ TEST_F(JSMapTest, DeleteAndGet) key_array[3] = '1' + 8; JSHandle delete_key(factory->NewFromString(key_array)); EXPECT_EQ(map->GetValue(8), JSTaggedValue(8)); - JSMap::Delete(thread, map, delete_key); + JSMap::Delete(thread_, map, delete_key); int hash = LinkedHash::Hash(delete_key.GetTaggedValue()); EXPECT_FALSE(map->Has(delete_key.GetTaggedValue(), hash)); EXPECT_EQ(map->GetSize(), 39); @@ -119,49 +119,49 @@ TEST_F(JSMapTest, DeleteAndGet) TEST_F(JSMapTest, Iterator) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); - JSHandle map(thread, CreateMap()); + JSHandle map(thread_, CreateMap()); for (int i = 0; i < 5; i++) { - JSHandle key(thread, JSTaggedValue(i)); + JSHandle key(thread_, JSTaggedValue(i)); // NOLINTNEXTLINE(readability-magic-numbers) - JSHandle value(thread, JSTaggedValue(i + 10)); - JSMap::Set(thread, map, key, value); + JSHandle value(thread_, JSTaggedValue(i + 10)); + JSMap::Set(thread_, map, key, value); } JSHandle key_iter(factory->NewJSMapIterator(map, IterationKind::KEY)); JSHandle value_iter(factory->NewJSMapIterator(map, IterationKind::VALUE)); JSHandle iter(factory->NewJSMapIterator(map, IterationKind::KEY_AND_VALUE)); - JSHandle index_key(thread, JSTaggedValue(0)); - JSHandle element_key(thread, JSTaggedValue(1)); + JSHandle index_key(thread_, JSTaggedValue(0)); + JSHandle element_key(thread_, JSTaggedValue(1)); - JSHandle key_result0 = JSIterator::IteratorStep(thread, key_iter); - JSHandle value_result0 = JSIterator::IteratorStep(thread, value_iter); - JSHandle result0 = JSIterator::IteratorStep(thread, iter); + JSHandle key_result0 = JSIterator::IteratorStep(thread_, key_iter); + JSHandle value_result0 = JSIterator::IteratorStep(thread_, value_iter); + JSHandle result0 = JSIterator::IteratorStep(thread_, iter); - EXPECT_EQ(0, JSIterator::IteratorValue(thread, key_result0)->GetInt()); - EXPECT_EQ(10, JSIterator::IteratorValue(thread, value_result0)->GetInt()); - JSHandle result0_handle = JSIterator::IteratorValue(thread, result0); - EXPECT_EQ(0, JSObject::GetProperty(thread, result0_handle, index_key).GetValue()->GetInt()); - EXPECT_EQ(10, JSObject::GetProperty(thread, result0_handle, element_key).GetValue()->GetInt()); + EXPECT_EQ(0, JSIterator::IteratorValue(thread_, key_result0)->GetInt()); + EXPECT_EQ(10, JSIterator::IteratorValue(thread_, value_result0)->GetInt()); + JSHandle result0_handle = JSIterator::IteratorValue(thread_, result0); + EXPECT_EQ(0, JSObject::GetProperty(thread_, result0_handle, index_key).GetValue()->GetInt()); + EXPECT_EQ(10, JSObject::GetProperty(thread_, result0_handle, element_key).GetValue()->GetInt()); - JSHandle key_result1 = JSIterator::IteratorStep(thread, key_iter); - EXPECT_EQ(1, JSIterator::IteratorValue(thread, key_result1)->GetInt()); + JSHandle key_result1 = JSIterator::IteratorStep(thread_, key_iter); + EXPECT_EQ(1, JSIterator::IteratorValue(thread_, key_result1)->GetInt()); for (int i = 0; i < 3; i++) { - JSHandle key(thread, JSTaggedValue(i)); - JSMap::Delete(thread, map, key); + JSHandle key(thread_, JSTaggedValue(i)); + JSMap::Delete(thread_, map, key); } - JSHandle key_result2 = JSIterator::IteratorStep(thread, key_iter); - EXPECT_EQ(3, JSIterator::IteratorValue(thread, key_result2)->GetInt()); - JSHandle key_result3 = JSIterator::IteratorStep(thread, key_iter); - EXPECT_EQ(4, JSIterator::IteratorValue(thread, key_result3)->GetInt()); - JSHandle key(thread, JSTaggedValue(5)); - JSMap::Set(thread, map, key, key); - JSHandle key_result4 = JSIterator::IteratorStep(thread, key_iter); - - EXPECT_EQ(5, JSIterator::IteratorValue(thread, key_result4)->GetInt()); - JSHandle key_result5 = JSIterator::IteratorStep(thread, key_iter); + JSHandle key_result2 = JSIterator::IteratorStep(thread_, key_iter); + EXPECT_EQ(3, JSIterator::IteratorValue(thread_, key_result2)->GetInt()); + JSHandle key_result3 = JSIterator::IteratorStep(thread_, key_iter); + EXPECT_EQ(4, JSIterator::IteratorValue(thread_, key_result3)->GetInt()); + JSHandle key(thread_, JSTaggedValue(5)); + JSMap::Set(thread_, map, key, key); + JSHandle key_result4 = JSIterator::IteratorStep(thread_, key_iter); + + EXPECT_EQ(5, JSIterator::IteratorValue(thread_, key_result4)->GetInt()); + JSHandle key_result5 = JSIterator::IteratorStep(thread_, key_iter); EXPECT_EQ(JSTaggedValue::False(), key_result5.GetTaggedValue()); } diff --git a/tests/runtime/common/js_primitive_ref_test.cpp b/tests/runtime/common/js_primitive_ref_test.cpp index 76973a5ba..a3c927e98 100644 --- a/tests/runtime/common/js_primitive_ref_test.cpp +++ b/tests/runtime/common/js_primitive_ref_test.cpp @@ -36,37 +36,37 @@ class JSPrimitiveRefTest : 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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {}; + JSThread *thread_ {}; private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; TEST_F(JSPrimitiveRefTest, StringCreate) { - JSHandle hello(thread->GetEcmaVM()->GetFactory()->NewFromString("hello")); - JSHandle str(JSPrimitiveRef::StringCreate(thread, hello)); + JSHandle hello(thread_->GetEcmaVM()->GetFactory()->NewFromString("hello")); + JSHandle str(JSPrimitiveRef::StringCreate(thread_, hello)); - JSHandle idx(thread->GetEcmaVM()->GetFactory()->NewFromString("0")); - bool status = JSPrimitiveRef::HasProperty(thread, str, idx); + JSHandle idx(thread_->GetEcmaVM()->GetFactory()->NewFromString("0")); + bool status = JSPrimitiveRef::HasProperty(thread_, str, idx); ASSERT_TRUE(status); - PropertyDescriptor desc(thread); - status = JSPrimitiveRef::GetOwnProperty(thread, str, idx, desc); + PropertyDescriptor desc(thread_); + status = JSPrimitiveRef::GetOwnProperty(thread_, str, idx, desc); ASSERT_TRUE(status); - JSHandle h = thread->GetEcmaVM()->GetFactory()->NewFromString("h"); - JSHandle h2 = JSTaggedValue::ToString(thread, desc.GetValue()); + JSHandle h = thread_->GetEcmaVM()->GetFactory()->NewFromString("h"); + JSHandle h2 = JSTaggedValue::ToString(thread_, desc.GetValue()); ASSERT_TRUE(h->Compare(*h2) == 0); } diff --git a/tests/runtime/common/js_promise_test.cpp b/tests/runtime/common/js_promise_test.cpp index 88cdbb9e8..d452175a8 100644 --- a/tests/runtime/common/js_promise_test.cpp +++ b/tests/runtime/common/js_promise_test.cpp @@ -37,74 +37,74 @@ class JSPromiseTest : 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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {nullptr}; + JSThread *thread_ {nullptr}; private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; TEST_F(JSPromiseTest, CreateResolvingFunctions) { - EcmaVM *ecma_vm = thread->GetEcmaVM(); + EcmaVM *ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); ObjectFactory *factory = ecma_vm->GetFactory(); JSHandle promise_func = env->GetPromiseFunction(); JSHandle js_promise = JSHandle::Cast(factory->NewJSObjectByConstructor(JSHandle(promise_func), promise_func)); - JSHandle reactions = JSPromise::CreateResolvingFunctions(thread, js_promise); - JSHandle resolve(thread, reactions->GetResolveFunction()); - JSHandle reject(thread, reactions->GetRejectFunction()); + JSHandle reactions = JSPromise::CreateResolvingFunctions(thread_, js_promise); + JSHandle resolve(thread_, reactions->GetResolveFunction()); + JSHandle reject(thread_, reactions->GetRejectFunction()); EXPECT_EQ(resolve->IsCallable(), true); EXPECT_EQ(reject->IsCallable(), true); } TEST_F(JSPromiseTest, NewPromiseCapability) { - EcmaVM *ecma_vm = thread->GetEcmaVM(); + EcmaVM *ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle promise = env->GetPromiseFunction(); - JSHandle capbility = JSPromise::NewPromiseCapability(thread, promise); - JSHandle new_promise(thread, capbility->GetPromise()); + JSHandle capbility = JSPromise::NewPromiseCapability(thread_, promise); + JSHandle new_promise(thread_, capbility->GetPromise()); EXPECT_EQ(static_cast(new_promise->GetPromiseState().GetInt()), PromiseStatus::PENDING); - JSHandle resolve(thread, capbility->GetResolve()); - JSHandle reject(thread, capbility->GetReject()); + JSHandle resolve(thread_, capbility->GetResolve()); + JSHandle reject(thread_, capbility->GetReject()); EXPECT_EQ(resolve.GetTaggedValue().IsCallable(), true); EXPECT_EQ(resolve.GetTaggedValue().IsCallable(), true); - JSHandle resolve_promise(thread, resolve->GetPromise()); - JSHandle reject_promise(thread, reject->GetPromise()); + JSHandle resolve_promise(thread_, resolve->GetPromise()); + JSHandle reject_promise(thread_, reject->GetPromise()); EXPECT_EQ(JSTaggedValue::SameValue(new_promise.GetTaggedValue(), resolve_promise.GetTaggedValue()), true); EXPECT_EQ(JSTaggedValue::SameValue(new_promise.GetTaggedValue(), reject_promise.GetTaggedValue()), true); } TEST_F(JSPromiseTest, FullFillPromise) { - EcmaVM *ecma_vm = thread->GetEcmaVM(); + EcmaVM *ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle promise = env->GetPromiseFunction(); - JSHandle capbility = JSPromise::NewPromiseCapability(thread, promise); - JSHandle new_promise(thread, capbility->GetPromise()); + JSHandle capbility = JSPromise::NewPromiseCapability(thread_, promise); + JSHandle new_promise(thread_, capbility->GetPromise()); EXPECT_EQ(static_cast(new_promise->GetPromiseState().GetInt()), PromiseStatus::PENDING); EXPECT_EQ(new_promise->GetPromiseResult().IsUndefined(), true); - JSHandle resolve(thread, capbility->GetResolve()); - JSHandle undefined(thread, JSTaggedValue::Undefined()); + JSHandle resolve(thread_, capbility->GetResolve()); + JSHandle undefined(thread_, JSTaggedValue::Undefined()); - auto info = NewRuntimeCallInfo(thread, resolve, undefined, JSTaggedValue::Undefined(), 1); + auto info = NewRuntimeCallInfo(thread_, resolve, undefined, JSTaggedValue::Undefined(), 1); // NOLINTNEXTLINE(readability-magic-numbers) info->SetCallArgs(JSTaggedValue(33)); JSFunction::Call(info.Get()); @@ -114,18 +114,18 @@ TEST_F(JSPromiseTest, FullFillPromise) TEST_F(JSPromiseTest, RejectPromise) { - EcmaVM *ecma_vm = thread->GetEcmaVM(); + EcmaVM *ecma_vm = thread_->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle promise = env->GetPromiseFunction(); - JSHandle capbility = JSPromise::NewPromiseCapability(thread, promise); - JSHandle new_promise(thread, capbility->GetPromise()); + JSHandle capbility = JSPromise::NewPromiseCapability(thread_, promise); + JSHandle new_promise(thread_, capbility->GetPromise()); EXPECT_EQ(static_cast(new_promise->GetPromiseState().GetInt()), PromiseStatus::PENDING); EXPECT_EQ(new_promise->GetPromiseResult().IsUndefined(), true); - JSHandle reject(thread, capbility->GetReject()); - JSHandle undefined(thread, JSTaggedValue::Undefined()); + JSHandle reject(thread_, capbility->GetReject()); + JSHandle undefined(thread_, JSTaggedValue::Undefined()); - auto info = NewRuntimeCallInfo(thread, reject, undefined, JSTaggedValue::Undefined(), 1); + auto info = NewRuntimeCallInfo(thread_, reject, undefined, JSTaggedValue::Undefined(), 1); // NOLINTNEXTLINE(readability-magic-numbers) info->SetCallArgs(JSTaggedValue(44)); JSFunction::Call(info.Get()); diff --git a/tests/runtime/common/js_proxy_test.cpp b/tests/runtime/common/js_proxy_test.cpp index 715e54cd3..b1cbf8218 100644 --- a/tests/runtime/common/js_proxy_test.cpp +++ b/tests/runtime/common/js_proxy_test.cpp @@ -38,21 +38,21 @@ class JSProxyTest : 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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {}; + JSThread *thread_ {}; private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; static JSFunction *JSObjectTestCreate(JSThread *thread) @@ -64,25 +64,25 @@ static JSFunction *JSObjectTestCreate(JSThread *thread) TEST_F(JSProxyTest, ProxyCreate) { - JSHandle dynclass(thread, JSObjectTestCreate(thread)); + JSHandle dynclass(thread_, JSObjectTestCreate(thread_)); JSHandle target_handle( - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle::Cast(dynclass), dynclass)); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle::Cast(dynclass), dynclass)); - JSHandle key(thread->GetEcmaVM()->GetFactory()->NewFromString("x")); - JSHandle value(thread, JSTaggedValue(1)); - JSObject::SetProperty(thread, target_handle, key, value); - EXPECT_EQ(JSObject::GetProperty(thread, target_handle, key).GetValue()->GetInt(), 1); + JSHandle key(thread_->GetEcmaVM()->GetFactory()->NewFromString("x")); + JSHandle value(thread_, JSTaggedValue(1)); + JSObject::SetProperty(thread_, target_handle, key, value); + EXPECT_EQ(JSObject::GetProperty(thread_, target_handle, key).GetValue()->GetInt(), 1); JSHandle handler_handle( - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle::Cast(dynclass), dynclass)); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle::Cast(dynclass), dynclass)); EXPECT_TRUE(handler_handle->IsECMAObject()); - JSHandle proxy_handle = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle != nullptr); - EXPECT_EQ(JSProxy::GetProperty(thread, proxy_handle, key).GetValue()->GetInt(), 1); - PropertyDescriptor desc(thread); - JSProxy::GetOwnProperty(thread, proxy_handle, key, desc); + EXPECT_EQ(JSProxy::GetProperty(thread_, proxy_handle, key).GetValue()->GetInt(), 1); + PropertyDescriptor desc(thread_); + JSProxy::GetOwnProperty(thread_, proxy_handle, key, desc); EXPECT_EQ(desc.GetValue()->GetInt(), 1); } @@ -95,36 +95,36 @@ JSTaggedValue HandlerGetProperty([[maybe_unused]] EcmaRuntimeCallInfo *argv) TEST_F(JSProxyTest, GetProperty) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // 1. handler has no "get" - JSHandle dynclass(thread, JSObjectTestCreate(thread)); + JSHandle dynclass(thread_, JSObjectTestCreate(thread_)); JSHandle target_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(target_handle->IsECMAObject()); JSHandle key(factory->NewFromString("x")); - JSHandle value(thread, JSTaggedValue(1)); - JSObject::SetProperty(thread, target_handle, key, value); - EXPECT_EQ(JSObject::GetProperty(thread, target_handle, key).GetValue()->GetInt(), 1); + JSHandle value(thread_, JSTaggedValue(1)); + JSObject::SetProperty(thread_, target_handle, key, value); + EXPECT_EQ(JSObject::GetProperty(thread_, target_handle, key).GetValue()->GetInt(), 1); JSHandle handler_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(handler_handle->IsECMAObject()); - JSHandle proxy_handle = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle != nullptr); - EXPECT_EQ(JSProxy::GetProperty(thread, proxy_handle, key).GetValue()->GetInt(), 1); + EXPECT_EQ(JSProxy::GetProperty(thread_, proxy_handle, key).GetValue()->GetInt(), 1); // 2. handler has "get" - EcmaVM *vm = thread->GetEcmaVM(); + EcmaVM *vm = thread_->GetEcmaVM(); JSHandle env = vm->GetGlobalEnv(); - JSHandle get_key = thread->GlobalConstants()->GetHandledGetString(); + JSHandle get_key = thread_->GlobalConstants()->GetHandledGetString(); JSHandle get_handle(factory->NewJSFunction(env, reinterpret_cast(HandlerGetProperty))); - JSObject::SetProperty(thread, JSHandle(handler_handle), get_key, get_handle); + JSObject::SetProperty(thread_, JSHandle(handler_handle), get_key, get_handle); - JSHandle proxy_handle2(JSProxy::ProxyCreate(thread, target_handle, handler_handle)); + JSHandle proxy_handle2(JSProxy::ProxyCreate(thread_, target_handle, handler_handle)); EXPECT_TRUE(*proxy_handle2 != nullptr); JSHandle key2(factory->NewFromString("y")); - EXPECT_EQ(JSProxy::GetProperty(thread, proxy_handle2, key2).GetValue()->GetInt(), 10); + EXPECT_EQ(JSProxy::GetProperty(thread_, proxy_handle2, key2).GetValue()->GetInt(), 10); } // ES6 9.5.5 [[GetOwnProperty]] (P) @@ -135,39 +135,39 @@ JSTaggedValue HandlerGetOwnProperty([[maybe_unused]] EcmaRuntimeCallInfo *argv) TEST_F(JSProxyTest, GetOwnProperty) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // 1. handler has no "get" - JSHandle dynclass(thread, JSObjectTestCreate(thread)); + JSHandle dynclass(thread_, JSObjectTestCreate(thread_)); JSHandle target_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(target_handle->IsECMAObject()); JSHandle key(factory->NewFromString("x")); - JSHandle value(thread, JSTaggedValue(1)); - JSObject::SetProperty(thread, target_handle, key, value); - EXPECT_EQ(JSObject::GetProperty(thread, target_handle, key).GetValue()->GetInt(), 1); + JSHandle value(thread_, JSTaggedValue(1)); + JSObject::SetProperty(thread_, target_handle, key, value); + EXPECT_EQ(JSObject::GetProperty(thread_, target_handle, key).GetValue()->GetInt(), 1); JSHandle handler_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(handler_handle->IsECMAObject()); - JSHandle proxy_handle = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle != nullptr); - PropertyDescriptor desc(thread); - JSProxy::GetOwnProperty(thread, proxy_handle, key, desc); + PropertyDescriptor desc(thread_); + JSProxy::GetOwnProperty(thread_, proxy_handle, key, desc); EXPECT_EQ(desc.GetValue()->GetInt(), 1); // 2. handler has "get" - EcmaVM *vm = thread->GetEcmaVM(); + EcmaVM *vm = thread_->GetEcmaVM(); JSHandle env = vm->GetGlobalEnv(); - JSHandle define_key = thread->GlobalConstants()->GetHandledGetOwnPropertyDescriptorString(); + JSHandle define_key = thread_->GlobalConstants()->GetHandledGetOwnPropertyDescriptorString(); JSHandle define_handle(factory->NewJSFunction(env, reinterpret_cast(HandlerGetOwnProperty))); - JSObject::SetProperty(thread, JSHandle(handler_handle), define_key, define_handle); + JSObject::SetProperty(thread_, JSHandle(handler_handle), define_key, define_handle); - JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle2 != nullptr); JSHandle key2(factory->NewFromString("y")); - PropertyDescriptor desc2(thread); - EXPECT_FALSE(JSProxy::GetOwnProperty(thread, proxy_handle2, key2, desc2)); + PropertyDescriptor desc2(thread_); + EXPECT_FALSE(JSProxy::GetOwnProperty(thread_, proxy_handle2, key2, desc2)); } // ES6 9.5.9 [[Set]] ( P, V, Receiver) @@ -179,38 +179,38 @@ JSTaggedValue HandlerSetProperty([[maybe_unused]] EcmaRuntimeCallInfo *argv) TEST_F(JSProxyTest, SetProperty) { // 1. handler has no "get" - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // 1. handler has no "get" - JSHandle dynclass(thread, JSObjectTestCreate(thread)); + JSHandle dynclass(thread_, JSObjectTestCreate(thread_)); JSHandle target_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(target_handle->IsECMAObject()); JSHandle key(factory->NewFromString("x")); - JSHandle value(thread, JSTaggedValue(1)); + JSHandle value(thread_, JSTaggedValue(1)); JSHandle handler_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(handler_handle->IsECMAObject()); - JSHandle proxy_handle = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle != nullptr); - EXPECT_TRUE(JSProxy::SetProperty(thread, proxy_handle, key, value)); - EXPECT_EQ(JSProxy::GetProperty(thread, proxy_handle, key).GetValue()->GetInt(), 1); - EXPECT_EQ(JSObject::GetProperty(thread, target_handle, key).GetValue()->GetInt(), 1); + EXPECT_TRUE(JSProxy::SetProperty(thread_, proxy_handle, key, value)); + EXPECT_EQ(JSProxy::GetProperty(thread_, proxy_handle, key).GetValue()->GetInt(), 1); + EXPECT_EQ(JSObject::GetProperty(thread_, target_handle, key).GetValue()->GetInt(), 1); // 2. handler has "set" - EcmaVM *vm = thread->GetEcmaVM(); + EcmaVM *vm = thread_->GetEcmaVM(); JSHandle env = vm->GetGlobalEnv(); - JSHandle set_key = thread->GlobalConstants()->GetHandledSetString(); + JSHandle set_key = thread_->GlobalConstants()->GetHandledSetString(); JSHandle set_handle(factory->NewJSFunction(env, reinterpret_cast(HandlerSetProperty))); - JSObject::SetProperty(thread, JSHandle(handler_handle), set_key, set_handle); + JSObject::SetProperty(thread_, JSHandle(handler_handle), set_key, set_handle); - JSHandle proxy_handle2(JSProxy::ProxyCreate(thread, target_handle, handler_handle)); + JSHandle proxy_handle2(JSProxy::ProxyCreate(thread_, target_handle, handler_handle)); EXPECT_TRUE(*proxy_handle2 != nullptr); // NOLINTNEXTLINE(readability-magic-numbers) - JSHandle value2(thread, JSTaggedValue(10)); - EXPECT_FALSE(JSProxy::SetProperty(thread, proxy_handle2, key, value2)); - EXPECT_EQ(JSProxy::GetProperty(thread, proxy_handle2, key).GetValue()->GetInt(), 1); + JSHandle value2(thread_, JSTaggedValue(10)); + EXPECT_FALSE(JSProxy::SetProperty(thread_, proxy_handle2, key, value2)); + EXPECT_EQ(JSProxy::GetProperty(thread_, proxy_handle2, key).GetValue()->GetInt(), 1); } // ES6 9.5.6 [[DefineOwnProperty]] (P, Desc) @@ -221,39 +221,39 @@ JSTaggedValue HandlerDefineOwnProperty([[maybe_unused]] EcmaRuntimeCallInfo *arg TEST_F(JSProxyTest, DefineOwnProperty) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // 1. handler has no "defineProperty" - JSHandle dynclass(thread, JSObjectTestCreate(thread)); + JSHandle dynclass(thread_, JSObjectTestCreate(thread_)); JSHandle target_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(target_handle->IsECMAObject()); JSHandle key(factory->NewFromString("x")); - JSHandle value(thread, JSTaggedValue(1)); + JSHandle value(thread_, JSTaggedValue(1)); JSHandle handler_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(handler_handle->IsECMAObject()); - JSHandle proxy_handle = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle != nullptr); - PropertyDescriptor desc(thread, JSHandle(thread, JSTaggedValue(1))); - EXPECT_TRUE(JSProxy::DefineOwnProperty(thread, proxy_handle, key, desc)); - EXPECT_EQ(JSProxy::GetProperty(thread, proxy_handle, key).GetValue()->GetInt(), 1); - EXPECT_EQ(JSObject::GetProperty(thread, target_handle, key).GetValue()->GetInt(), 1); + PropertyDescriptor desc(thread_, JSHandle(thread_, JSTaggedValue(1))); + EXPECT_TRUE(JSProxy::DefineOwnProperty(thread_, proxy_handle, key, desc)); + EXPECT_EQ(JSProxy::GetProperty(thread_, proxy_handle, key).GetValue()->GetInt(), 1); + EXPECT_EQ(JSObject::GetProperty(thread_, target_handle, key).GetValue()->GetInt(), 1); // 2. handler has "defineProperty" - EcmaVM *vm = thread->GetEcmaVM(); + EcmaVM *vm = thread_->GetEcmaVM(); JSHandle env = vm->GetGlobalEnv(); - JSHandle set_key = thread->GlobalConstants()->GetHandledDefinePropertyString(); + JSHandle set_key = thread_->GlobalConstants()->GetHandledDefinePropertyString(); JSHandle set_handle(factory->NewJSFunction(env, reinterpret_cast(HandlerDefineOwnProperty))); - JSObject::SetProperty(thread, JSHandle(handler_handle), set_key, set_handle); + JSObject::SetProperty(thread_, JSHandle(handler_handle), set_key, set_handle); - JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle2 != nullptr); // NOLINTNEXTLINE(readability-magic-numbers) - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(10))); - EXPECT_FALSE(JSProxy::DefineOwnProperty(thread, proxy_handle, key, desc2)); - EXPECT_EQ(JSProxy::GetProperty(thread, proxy_handle2, key).GetValue()->GetInt(), 1); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(10))); + EXPECT_FALSE(JSProxy::DefineOwnProperty(thread_, proxy_handle, key, desc2)); + EXPECT_EQ(JSProxy::GetProperty(thread_, proxy_handle2, key).GetValue()->GetInt(), 1); } JSTaggedValue HandlerDeleteProperty([[maybe_unused]] EcmaRuntimeCallInfo *argv) @@ -264,43 +264,43 @@ JSTaggedValue HandlerDeleteProperty([[maybe_unused]] EcmaRuntimeCallInfo *argv) // ES6 9.5.10 [[Delete]] (P) TEST_F(JSProxyTest, DeleteProperty) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // 1. handler has no "deleteProperty" - JSHandle dynclass(thread, JSObjectTestCreate(thread)); + JSHandle dynclass(thread_, JSObjectTestCreate(thread_)); JSHandle target_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(target_handle->IsECMAObject()); JSHandle key(factory->NewFromString("x")); - JSHandle value(thread, JSTaggedValue(1)); + JSHandle value(thread_, JSTaggedValue(1)); JSHandle handler_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(handler_handle->IsECMAObject()); - JSHandle proxy_handle = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle != nullptr); - PropertyDescriptor desc(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - EXPECT_TRUE(JSProxy::DefineOwnProperty(thread, proxy_handle, key, desc)); - EXPECT_EQ(JSProxy::GetProperty(thread, proxy_handle, key).GetValue()->GetInt(), 1); - EXPECT_EQ(JSObject::GetProperty(thread, target_handle, key).GetValue()->GetInt(), 1); - EXPECT_TRUE(JSProxy::DeleteProperty(thread, proxy_handle, key)); - PropertyDescriptor res_desc(thread); - JSProxy::GetOwnProperty(thread, proxy_handle, key, res_desc); + PropertyDescriptor desc(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + EXPECT_TRUE(JSProxy::DefineOwnProperty(thread_, proxy_handle, key, desc)); + EXPECT_EQ(JSProxy::GetProperty(thread_, proxy_handle, key).GetValue()->GetInt(), 1); + EXPECT_EQ(JSObject::GetProperty(thread_, target_handle, key).GetValue()->GetInt(), 1); + EXPECT_TRUE(JSProxy::DeleteProperty(thread_, proxy_handle, key)); + PropertyDescriptor res_desc(thread_); + JSProxy::GetOwnProperty(thread_, proxy_handle, key, res_desc); EXPECT_TRUE(JSTaggedValue::SameValue(res_desc.GetValue().GetTaggedValue(), JSTaggedValue::Undefined())); // 2. handler has "deleteProperty" - EcmaVM *vm = thread->GetEcmaVM(); + EcmaVM *vm = thread_->GetEcmaVM(); JSHandle env = vm->GetGlobalEnv(); - JSHandle func_key = thread->GlobalConstants()->GetHandledDeletePropertyString(); + JSHandle func_key = thread_->GlobalConstants()->GetHandledDeletePropertyString(); JSHandle func_handle(factory->NewJSFunction(env, reinterpret_cast(HandlerDeleteProperty))); - JSObject::SetProperty(thread, JSHandle(handler_handle), func_key, func_handle); + JSObject::SetProperty(thread_, JSHandle(handler_handle), func_key, func_handle); - JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle2 != nullptr); - PropertyDescriptor desc2(thread, JSHandle(thread, JSTaggedValue(1)), true, true, true); - EXPECT_TRUE(JSProxy::DefineOwnProperty(thread, proxy_handle2, key, desc2)); - EXPECT_EQ(JSProxy::GetProperty(thread, proxy_handle2, key).GetValue()->GetInt(), 1); - EXPECT_FALSE(JSProxy::DeleteProperty(thread, proxy_handle2, key)); + PropertyDescriptor desc2(thread_, JSHandle(thread_, JSTaggedValue(1)), true, true, true); + EXPECT_TRUE(JSProxy::DefineOwnProperty(thread_, proxy_handle2, key, desc2)); + EXPECT_EQ(JSProxy::GetProperty(thread_, proxy_handle2, key).GetValue()->GetInt(), 1); + EXPECT_FALSE(JSProxy::DeleteProperty(thread_, proxy_handle2, key)); } JSTaggedValue HandlerGetPrototype([[maybe_unused]] EcmaRuntimeCallInfo *argv) @@ -311,34 +311,34 @@ JSTaggedValue HandlerGetPrototype([[maybe_unused]] EcmaRuntimeCallInfo *argv) // ES6 9.5.1 [[GetPrototypeOf]] ( ) TEST_F(JSProxyTest, GetPrototypeOf) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // 1. handler has no "GetPrototypeOf" - JSHandle dynclass(thread, JSObjectTestCreate(thread)); + JSHandle dynclass(thread_, JSObjectTestCreate(thread_)); JSHandle proto(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); JSHandle target_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(target_handle->IsECMAObject()); - JSObject::SetPrototype(thread, JSHandle(target_handle), proto); + JSObject::SetPrototype(thread_, JSHandle(target_handle), proto); EXPECT_TRUE( - JSTaggedValue::SameValue(JSHandle(target_handle)->GetPrototype(thread), proto.GetTaggedValue())); + JSTaggedValue::SameValue(JSHandle(target_handle)->GetPrototype(thread_), proto.GetTaggedValue())); JSHandle handler_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(handler_handle->IsECMAObject()); - JSHandle proxy_handle = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle != nullptr); - EXPECT_TRUE(JSTaggedValue::SameValue(JSProxy::GetPrototype(thread, proxy_handle), proto.GetTaggedValue())); + EXPECT_TRUE(JSTaggedValue::SameValue(JSProxy::GetPrototype(thread_, proxy_handle), proto.GetTaggedValue())); // 2. handler has "GetPrototypeOf" - EcmaVM *vm = thread->GetEcmaVM(); + EcmaVM *vm = thread_->GetEcmaVM(); JSHandle env = vm->GetGlobalEnv(); - JSHandle func_key = thread->GlobalConstants()->GetHandledGetPrototypeOfString(); + JSHandle func_key = thread_->GlobalConstants()->GetHandledGetPrototypeOfString(); JSHandle func_handle(factory->NewJSFunction(env, reinterpret_cast(HandlerGetPrototype))); - JSObject::SetProperty(thread, JSHandle(handler_handle), func_key, func_handle); + JSObject::SetProperty(thread_, JSHandle(handler_handle), func_key, func_handle); - JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle2 != nullptr); - EXPECT_TRUE(JSTaggedValue::SameValue(JSProxy::GetPrototype(thread, proxy_handle2), JSTaggedValue::Null())); + EXPECT_TRUE(JSTaggedValue::SameValue(JSProxy::GetPrototype(thread_, proxy_handle2), JSTaggedValue::Null())); } JSTaggedValue HandlerSetPrototype([[maybe_unused]] EcmaRuntimeCallInfo *argv) @@ -349,9 +349,9 @@ JSTaggedValue HandlerSetPrototype([[maybe_unused]] EcmaRuntimeCallInfo *argv) // ES6 9.5.2 [[SetPrototypeOf]] (V) TEST_F(JSProxyTest, SetPrototypeOf) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // 1. handler has no "SetPrototypeOf" - JSHandle dynclass(thread, JSObjectTestCreate(thread)); + JSHandle dynclass(thread_, JSObjectTestCreate(thread_)); JSHandle proto(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); JSHandle target_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(target_handle->IsECMAObject()); @@ -359,23 +359,23 @@ TEST_F(JSProxyTest, SetPrototypeOf) JSHandle handler_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(handler_handle->IsECMAObject()); - JSHandle proxy_handle = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle != nullptr); - JSProxy::SetPrototype(thread, proxy_handle, proto); + JSProxy::SetPrototype(thread_, proxy_handle, proto); EXPECT_TRUE( - JSTaggedValue::SameValue(JSHandle(target_handle)->GetPrototype(thread), proto.GetTaggedValue())); + JSTaggedValue::SameValue(JSHandle(target_handle)->GetPrototype(thread_), proto.GetTaggedValue())); // 2. handler has "SetPrototypeOf" - EcmaVM *vm = thread->GetEcmaVM(); + EcmaVM *vm = thread_->GetEcmaVM(); JSHandle env = vm->GetGlobalEnv(); - JSHandle func_key = thread->GlobalConstants()->GetHandledSetPrototypeOfString(); + JSHandle func_key = thread_->GlobalConstants()->GetHandledSetPrototypeOfString(); JSHandle func_handle(factory->NewJSFunction(env, reinterpret_cast(HandlerSetPrototype))); - JSObject::SetProperty(thread, JSHandle(handler_handle), func_key, func_handle); + JSObject::SetProperty(thread_, JSHandle(handler_handle), func_key, func_handle); - JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle2 != nullptr); - EXPECT_FALSE(JSProxy::SetPrototype(thread, proxy_handle2, proto)); + EXPECT_FALSE(JSProxy::SetPrototype(thread_, proxy_handle2, proto)); } JSTaggedValue HandlerIsExtensible([[maybe_unused]] EcmaRuntimeCallInfo *argv) @@ -386,32 +386,32 @@ JSTaggedValue HandlerIsExtensible([[maybe_unused]] EcmaRuntimeCallInfo *argv) // ES6 9.5.3 [[IsExtensible]] ( ) TEST_F(JSProxyTest, IsExtensible) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // 1. handler has no "IsExtensible" - JSHandle dynclass(thread, JSObjectTestCreate(thread)); + JSHandle dynclass(thread_, JSObjectTestCreate(thread_)); JSHandle target_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(target_handle->IsECMAObject()); JSHandle handler_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(handler_handle->IsECMAObject()); - JSHandle proxy_handle = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle != nullptr); - bool status1 = JSProxy::IsExtensible(thread, proxy_handle); + bool status1 = JSProxy::IsExtensible(thread_, proxy_handle); bool status2 = JSHandle::Cast(target_handle)->IsExtensible(); EXPECT_TRUE(status1 == status2); // 2. handler has "IsExtensible" - EcmaVM *vm = thread->GetEcmaVM(); + EcmaVM *vm = thread_->GetEcmaVM(); JSHandle env = vm->GetGlobalEnv(); - JSHandle func_key = thread->GlobalConstants()->GetHandledIsExtensibleString(); + JSHandle func_key = thread_->GlobalConstants()->GetHandledIsExtensibleString(); JSHandle func_handle(factory->NewJSFunction(env, reinterpret_cast(HandlerIsExtensible))); - JSObject::SetProperty(thread, JSHandle(handler_handle), func_key, func_handle); + JSObject::SetProperty(thread_, JSHandle(handler_handle), func_key, func_handle); - JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle2 != nullptr); - EXPECT_FALSE(JSProxy::IsExtensible(thread, proxy_handle2)); + EXPECT_FALSE(JSProxy::IsExtensible(thread_, proxy_handle2)); } JSTaggedValue HandlerPreventExtensions([[maybe_unused]] EcmaRuntimeCallInfo *argv) @@ -422,34 +422,34 @@ JSTaggedValue HandlerPreventExtensions([[maybe_unused]] EcmaRuntimeCallInfo *arg // ES6 9.5.4 [[PreventExtensions]] ( ) TEST_F(JSProxyTest, PreventExtensions) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // 1. handler has no "PreventExtensions" - JSHandle dynclass(thread, JSObjectTestCreate(thread)); + JSHandle dynclass(thread_, JSObjectTestCreate(thread_)); JSHandle target_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(target_handle->IsECMAObject()); JSHandle handler_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(handler_handle->IsECMAObject()); - JSHandle proxy_handle = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle != nullptr); - bool status1 = JSProxy::PreventExtensions(thread, proxy_handle); + bool status1 = JSProxy::PreventExtensions(thread_, proxy_handle); EXPECT_TRUE(status1); bool status2 = JSHandle::Cast(target_handle)->IsExtensible(); EXPECT_FALSE(status2); // 2. handler has "PreventExtensions" - EcmaVM *vm = thread->GetEcmaVM(); + EcmaVM *vm = thread_->GetEcmaVM(); JSHandle env = vm->GetGlobalEnv(); - JSHandle func_key = thread->GlobalConstants()->GetHandledPreventExtensionsString(); + JSHandle func_key = thread_->GlobalConstants()->GetHandledPreventExtensionsString(); JSHandle func_handle( factory->NewJSFunction(env, reinterpret_cast(HandlerPreventExtensions))); - JSObject::SetProperty(thread, JSHandle(handler_handle), func_key, func_handle); + JSObject::SetProperty(thread_, JSHandle(handler_handle), func_key, func_handle); - JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle2 != nullptr); - EXPECT_FALSE(JSProxy::PreventExtensions(thread, proxy_handle2)); + EXPECT_FALSE(JSProxy::PreventExtensions(thread_, proxy_handle2)); } JSTaggedValue HandlerHasProperty([[maybe_unused]] EcmaRuntimeCallInfo *argv) @@ -460,34 +460,34 @@ JSTaggedValue HandlerHasProperty([[maybe_unused]] EcmaRuntimeCallInfo *argv) // ES6 9.5.7 [[HasProperty]] (P) TEST_F(JSProxyTest, HasProperty) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // 1. handler has no "HasProperty" - JSHandle dynclass(thread, JSObjectTestCreate(thread)); + JSHandle dynclass(thread_, JSObjectTestCreate(thread_)); JSHandle target_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(target_handle->IsECMAObject()); JSHandle key(factory->NewFromString("x")); - PropertyDescriptor desc(thread, JSHandle(thread, JSTaggedValue(1))); - JSObject::DefineOwnProperty(thread, JSHandle::Cast(target_handle), key, desc); + PropertyDescriptor desc(thread_, JSHandle(thread_, JSTaggedValue(1))); + JSObject::DefineOwnProperty(thread_, JSHandle::Cast(target_handle), key, desc); JSHandle handler_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(handler_handle->IsECMAObject()); - JSHandle proxy_handle = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle != nullptr); - EXPECT_TRUE(JSProxy::HasProperty(thread, proxy_handle, key)); + EXPECT_TRUE(JSProxy::HasProperty(thread_, proxy_handle, key)); // 2. handler has "HasProperty" - EcmaVM *vm = thread->GetEcmaVM(); + EcmaVM *vm = thread_->GetEcmaVM(); JSHandle env = vm->GetGlobalEnv(); - JSHandle func_key = thread->GlobalConstants()->GetHandledHasString(); + JSHandle func_key = thread_->GlobalConstants()->GetHandledHasString(); JSHandle func_handle(factory->NewJSFunction(env, reinterpret_cast(HandlerHasProperty))); - JSObject::SetProperty(thread, JSHandle(handler_handle), func_key, func_handle); + JSObject::SetProperty(thread_, JSHandle(handler_handle), func_key, func_handle); - JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle2 != nullptr); - EXPECT_FALSE(JSProxy::HasProperty(thread, proxy_handle2, key)); + EXPECT_FALSE(JSProxy::HasProperty(thread_, proxy_handle2, key)); } JSTaggedValue HandlerOwnPropertyKeys([[maybe_unused]] EcmaRuntimeCallInfo *argv) @@ -502,22 +502,22 @@ JSTaggedValue HandlerOwnPropertyKeys([[maybe_unused]] EcmaRuntimeCallInfo *argv) // ES6 9.5.12 [[OwnPropertyKeys]] () TEST_F(JSProxyTest, OwnPropertyKeys) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // 1. handler has no "OwnPropertyKeys" - JSHandle dynclass(thread, JSObjectTestCreate(thread)); + JSHandle dynclass(thread_, JSObjectTestCreate(thread_)); JSHandle target_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(target_handle->IsECMAObject()); JSHandle key(factory->NewFromString("x")); - PropertyDescriptor desc(thread, JSHandle(thread, JSTaggedValue(1))); - JSObject::DefineOwnProperty(thread, JSHandle::Cast(target_handle), key, desc); + PropertyDescriptor desc(thread_, JSHandle(thread_, JSTaggedValue(1))); + JSObject::DefineOwnProperty(thread_, JSHandle::Cast(target_handle), key, desc); JSHandle handler_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(handler_handle->IsECMAObject()); - JSHandle proxy_handle = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle != nullptr); - JSHandle res = JSProxy::OwnPropertyKeys(thread, proxy_handle); + JSHandle res = JSProxy::OwnPropertyKeys(thread_, proxy_handle); EXPECT_TRUE(JSTaggedValue::SameValue(res->Get(0), key.GetTaggedValue())); @@ -525,15 +525,15 @@ TEST_F(JSProxyTest, OwnPropertyKeys) // create new empty target so we wont throw TypeError at (18. - 21.) JSHandle target_handle2(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(target_handle2->IsECMAObject()); - EcmaVM *vm = thread->GetEcmaVM(); + EcmaVM *vm = thread_->GetEcmaVM(); JSHandle env = vm->GetGlobalEnv(); - JSHandle func_key = thread->GlobalConstants()->GetHandledOwnKeysString(); + JSHandle func_key = thread_->GlobalConstants()->GetHandledOwnKeysString(); JSHandle func_handle(factory->NewJSFunction(env, reinterpret_cast(HandlerOwnPropertyKeys))); - JSObject::SetProperty(thread, JSHandle(handler_handle), func_key, func_handle); + JSObject::SetProperty(thread_, JSHandle(handler_handle), func_key, func_handle); - JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread, target_handle2, handler_handle); + JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread_, target_handle2, handler_handle); EXPECT_TRUE(*proxy_handle2 != nullptr); - JSHandle res2 = JSProxy::OwnPropertyKeys(thread, proxy_handle2); + JSHandle res2 = JSProxy::OwnPropertyKeys(thread_, proxy_handle2); EXPECT_TRUE(res2->GetLength() == 0 || !JSTaggedValue::SameValue(res2->Get(0), key.GetTaggedValue())); } @@ -549,42 +549,42 @@ JSTaggedValue HandlerFunction([[maybe_unused]] EcmaRuntimeCallInfo *argv) // ES6 9.5.13 [[Call]] (thisArgument, argumentsList) TEST_F(JSProxyTest, Call) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); // 1. handler has no "Call" - JSHandle dynclass(thread, JSObjectTestCreate(thread)); + JSHandle dynclass(thread_, JSObjectTestCreate(thread_)); JSHandle target_handle(factory->NewJSFunction(env, reinterpret_cast(HandlerFunction))); EXPECT_TRUE(target_handle->IsECMAObject()); JSHandle handler_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(handler_handle->IsECMAObject()); - JSHandle proxy_handle = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); JSTaggedValue res; EXPECT_TRUE(*proxy_handle != nullptr); { - auto info = NewRuntimeCallInfo(thread, proxy_handle, JSHandle::Cast(proxy_handle), + auto info = NewRuntimeCallInfo(thread_, proxy_handle, JSHandle::Cast(proxy_handle), JSTaggedValue::Undefined(), 0); res = JSProxy::CallInternal(info.Get()); } - JSHandle tagged_res(thread, res); + JSHandle tagged_res(thread_, res); EXPECT_TRUE(JSTaggedValue::SameValue(tagged_res.GetTaggedValue(), JSTaggedValue::True())); // 2. handler has "Call" - JSHandle func_key = thread->GlobalConstants()->GetHandledApplyString(); + JSHandle func_key = thread_->GlobalConstants()->GetHandledApplyString(); JSHandle func_handle(factory->NewJSFunction(env, reinterpret_cast(HandlerCall))); - JSObject::SetProperty(thread, JSHandle(handler_handle), func_key, func_handle); + JSObject::SetProperty(thread_, JSHandle(handler_handle), func_key, func_handle); - JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle2 != nullptr); JSTaggedValue res2; { - auto info = NewRuntimeCallInfo(thread, proxy_handle2, JSHandle::Cast(proxy_handle2), + auto info = NewRuntimeCallInfo(thread_, proxy_handle2, JSHandle::Cast(proxy_handle2), JSTaggedValue::Undefined(), 0); res2 = JSProxy::CallInternal(info.Get()); } - JSHandle tagged_res2(thread, res2); + JSHandle tagged_res2(thread_, res2); EXPECT_TRUE(JSTaggedValue::SameValue(tagged_res2.GetTaggedValue(), JSTaggedValue::False())); } @@ -619,10 +619,10 @@ JSTaggedValue HandlerConFunc([[maybe_unused]] EcmaRuntimeCallInfo *argv) // ES6 9.5.14 [[Construct]] ( argumentsList, new_target) TEST_F(JSProxyTest, Construct) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); // 1. handler has no "Construct" - JSHandle dynclass(thread, JSObjectTestCreate(thread)); + JSHandle dynclass(thread_, JSObjectTestCreate(thread_)); JSHandle target_handle(factory->NewJSFunction(env, reinterpret_cast(HandlerConFunc))); JSHandle::Cast(target_handle)->GetJSHClass()->SetConstructor(true); EXPECT_TRUE(target_handle->IsECMAObject()); @@ -630,30 +630,30 @@ TEST_F(JSProxyTest, Construct) JSHandle handler_handle(factory->NewJSObjectByConstructor(JSHandle(dynclass), dynclass)); EXPECT_TRUE(handler_handle->IsECMAObject()); - JSHandle proxy_handle = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle != nullptr); JSTaggedValue res; { - auto info = NewRuntimeCallInfo(thread, proxy_handle, JSTaggedValue::Undefined(), target_handle, 0); + auto info = NewRuntimeCallInfo(thread_, proxy_handle, JSTaggedValue::Undefined(), target_handle, 0); res = JSProxy::ConstructInternal(info.Get()); } - JSHandle tagged_res(thread, res); + JSHandle tagged_res(thread_, res); JSHandle key(factory->NewFromCanBeCompressString("x")); - EXPECT_EQ(JSObject::GetProperty(thread, tagged_res, key).GetValue()->GetInt(), 1); + EXPECT_EQ(JSObject::GetProperty(thread_, tagged_res, key).GetValue()->GetInt(), 1); // 2. handler has "Construct" - JSHandle func_key = thread->GlobalConstants()->GetHandledProxyConstructString(); + JSHandle func_key = thread_->GlobalConstants()->GetHandledProxyConstructString(); JSHandle func_handle(factory->NewJSFunction(env, reinterpret_cast(HandlerConstruct))); - JSObject::SetProperty(thread, JSHandle(handler_handle), func_key, func_handle); + JSObject::SetProperty(thread_, JSHandle(handler_handle), func_key, func_handle); - JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread, target_handle, handler_handle); + JSHandle proxy_handle2 = JSProxy::ProxyCreate(thread_, target_handle, handler_handle); EXPECT_TRUE(*proxy_handle2 != nullptr); JSTaggedValue res2; { - auto info = NewRuntimeCallInfo(thread, proxy_handle2, JSTaggedValue::Undefined(), target_handle, 0); + auto info = NewRuntimeCallInfo(thread_, proxy_handle2, JSTaggedValue::Undefined(), target_handle, 0); res2 = JSProxy::ConstructInternal(info.Get()); } - JSHandle tagged_res2(thread, res2); - EXPECT_EQ(JSObject::GetProperty(thread, tagged_res2, key).GetValue()->GetInt(), 2); + JSHandle tagged_res2(thread_, res2); + EXPECT_EQ(JSObject::GetProperty(thread_, tagged_res2, key).GetValue()->GetInt(), 2); } } // namespace panda::test diff --git a/tests/runtime/common/js_set_iterator_test.cpp b/tests/runtime/common/js_set_iterator_test.cpp index d26df6810..9fbddfddc 100644 --- a/tests/runtime/common/js_set_iterator_test.cpp +++ b/tests/runtime/common/js_set_iterator_test.cpp @@ -38,21 +38,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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {nullptr}; + JSThread *thread_ {nullptr}; private: - ecmascript::EcmaHandleScope *scope {nullptr}; - PandaVM *instance {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; + PandaVM *instance_ {nullptr}; }; JSSet *CreateSet(JSThread *thread) @@ -77,11 +77,11 @@ JSSet *CreateSet(JSThread *thread) */ TEST_F(JSSetIteratorTest, CreateSetIterator) { - JSHandle js_set(thread, CreateSet(thread)); + JSHandle js_set(thread_, CreateSet(thread_)); EXPECT_TRUE(*js_set != nullptr); JSHandle set_iterator_value1 = - JSSetIterator::CreateSetIterator(thread, JSHandle(js_set), IterationKind::KEY); + JSSetIterator::CreateSetIterator(thread_, JSHandle(js_set), IterationKind::KEY); EXPECT_EQ(set_iterator_value1->IsJSSetIterator(), true); JSHandle set_iterator1(set_iterator_value1); @@ -92,7 +92,7 @@ TEST_F(JSSetIteratorTest, CreateSetIterator) EXPECT_EQ(JSTaggedValue::SameValue(iteration_kind1, JSTaggedValue(static_cast(IterationKind::KEY))), true); JSHandle set_iterator_value2 = - JSSetIterator::CreateSetIterator(thread, JSHandle(js_set), IterationKind::VALUE); + JSSetIterator::CreateSetIterator(thread_, JSHandle(js_set), IterationKind::VALUE); EXPECT_EQ(set_iterator_value2->IsJSSetIterator(), true); JSHandle set_iterator2(set_iterator_value2); @@ -112,44 +112,44 @@ TEST_F(JSSetIteratorTest, CreateSetIterator) */ TEST_F(JSSetIteratorTest, Next) { - JSHandle js_set(thread, CreateSet(thread)); + JSHandle js_set(thread_, CreateSet(thread_)); EXPECT_TRUE(*js_set != nullptr); for (int i = 0; i < 3; i++) { - JSHandle key(thread, JSTaggedValue(i)); - JSSet::Add(thread, js_set, key); + JSHandle key(thread_, JSTaggedValue(i)); + JSSet::Add(thread_, js_set, key); } // set IterationKind(key or value) JSHandle set_iterator_value = - JSSetIterator::CreateSetIterator(thread, JSHandle(js_set), IterationKind::KEY); + JSSetIterator::CreateSetIterator(thread_, JSHandle(js_set), IterationKind::KEY); JSHandle set_iterator(set_iterator_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(set_iterator_value.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 result1 = JSSetIterator::Next(ecma_runtime_call_info.get()); EXPECT_EQ(set_iterator->GetNextIndex().GetInt(), 1); - JSHandle result_obj1(thread, result1); - EXPECT_EQ(0, JSIterator::IteratorValue(thread, result_obj1)->GetInt()); + JSHandle result_obj1(thread_, result1); + EXPECT_EQ(0, JSIterator::IteratorValue(thread_, result_obj1)->GetInt()); JSTaggedValue result2 = JSSetIterator::Next(ecma_runtime_call_info.get()); EXPECT_EQ(set_iterator->GetNextIndex().GetInt(), 2); - JSHandle result_obj2(thread, result2); - EXPECT_EQ(1, JSIterator::IteratorValue(thread, result_obj2)->GetInt()); + JSHandle result_obj2(thread_, result2); + EXPECT_EQ(1, JSIterator::IteratorValue(thread_, result_obj2)->GetInt()); JSTaggedValue result3 = JSSetIterator::Next(ecma_runtime_call_info.get()); EXPECT_EQ(set_iterator->GetNextIndex().GetInt(), 3); - JSHandle result_obj3(thread, result3); - EXPECT_EQ(2, JSIterator::IteratorValue(thread, result_obj3)->GetInt()); + JSHandle result_obj3(thread_, result3); + EXPECT_EQ(2, JSIterator::IteratorValue(thread_, result_obj3)->GetInt()); JSTaggedValue result4 = JSSetIterator::Next(ecma_runtime_call_info.get()); - JSHandle result_obj4(thread, result4); - EXPECT_EQ(JSIterator::IteratorValue(thread, result_obj4).GetTaggedValue(), JSTaggedValue::Undefined()); + JSHandle result_obj4(thread_, result4); + EXPECT_EQ(JSIterator::IteratorValue(thread_, result_obj4).GetTaggedValue(), JSTaggedValue::Undefined()); - TestHelper::TearDownFrame(thread, prev); + TestHelper::TearDownFrame(thread_, prev); } } // namespace panda::test diff --git a/tests/runtime/common/js_set_test.cpp b/tests/runtime/common/js_set_test.cpp index ddfa640b5..e678db012 100644 --- a/tests/runtime/common/js_set_test.cpp +++ b/tests/runtime/common/js_set_test.cpp @@ -40,34 +40,34 @@ class JSSetTest : 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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {}; + JSThread *thread_ {}; JSSet *CreateSet() { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle constructor = env->GetSetFunction(); JSHandle set = JSHandle::Cast(factory->NewJSObjectByConstructor(JSHandle(constructor), constructor)); - JSHandle hash_set = LinkedHashSet::Create(thread); - set->SetLinkedSet(thread, hash_set); + JSHandle hash_set = LinkedHashSet::Create(thread_); + set->SetLinkedSet(thread_, hash_set); return JSSet::Cast(set.GetTaggedValue().GetTaggedObject()); } private: - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; TEST_F(JSSetTest, SetCreate) @@ -78,22 +78,22 @@ TEST_F(JSSetTest, SetCreate) TEST_F(JSSetTest, AddAndHas) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // create js_set - JSHandle set(thread, CreateSet()); + JSHandle set(thread_, CreateSet()); // JSHandle key(factory->NewFromString("key")); - JSSet::Add(thread, set, key); + JSSet::Add(thread_, set, key); int hash = LinkedHash::Hash(key.GetTaggedValue()); EXPECT_TRUE(set->Has(key.GetTaggedValue(), hash)); } TEST_F(JSSetTest, DeleteAndGet) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // create js_set - JSHandle set(thread, CreateSet()); + JSHandle set(thread_, CreateSet()); // add 40 keys // NOLINTNEXTLINE(modernize-avoid-c-arrays) @@ -102,7 +102,7 @@ TEST_F(JSSetTest, DeleteAndGet) for (int i = 0; i < 40; i++) { key_array[3] = '1' + i; JSHandle key(factory->NewFromString(key_array)); - JSSet::Add(thread, set, key); + JSSet::Add(thread_, set, key); int hash = LinkedHash::Hash(key.GetTaggedValue()); EXPECT_TRUE(set->Has(key.GetTaggedValue(), hash)); } @@ -110,7 +110,7 @@ TEST_F(JSSetTest, DeleteAndGet) // whether js_set has delete key key_array[3] = '1' + 8; JSHandle delete_key(factory->NewFromString(key_array)); - JSSet::Delete(thread, set, delete_key); + JSSet::Delete(thread_, set, delete_key); int hash = LinkedHash::Hash(delete_key.GetTaggedValue()); EXPECT_FALSE(set->Has(delete_key.GetTaggedValue(), hash)); EXPECT_EQ(set->GetSize(), 39); @@ -118,39 +118,39 @@ TEST_F(JSSetTest, DeleteAndGet) TEST_F(JSSetTest, Iterator) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle set(thread, CreateSet()); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle set(thread_, CreateSet()); for (int i = 0; i < 5; i++) { - JSHandle key(thread, JSTaggedValue(i)); - JSSet::Add(thread, set, key); + JSHandle key(thread_, JSTaggedValue(i)); + JSSet::Add(thread_, set, key); } JSHandle key_iter(factory->NewJSSetIterator(set, IterationKind::KEY)); JSHandle value_iter(factory->NewJSSetIterator(set, IterationKind::VALUE)); - JSHandle key_result0 = JSIterator::IteratorStep(thread, key_iter); - JSHandle value_result0 = JSIterator::IteratorStep(thread, value_iter); + JSHandle key_result0 = JSIterator::IteratorStep(thread_, key_iter); + JSHandle value_result0 = JSIterator::IteratorStep(thread_, value_iter); - EXPECT_EQ(0, JSIterator::IteratorValue(thread, key_result0)->GetInt()); - EXPECT_EQ(0, JSIterator::IteratorValue(thread, value_result0)->GetInt()); + EXPECT_EQ(0, JSIterator::IteratorValue(thread_, key_result0)->GetInt()); + EXPECT_EQ(0, JSIterator::IteratorValue(thread_, value_result0)->GetInt()); - JSHandle key_result1 = JSIterator::IteratorStep(thread, key_iter); - EXPECT_EQ(1, JSIterator::IteratorValue(thread, key_result1)->GetInt()); + JSHandle key_result1 = JSIterator::IteratorStep(thread_, key_iter); + EXPECT_EQ(1, JSIterator::IteratorValue(thread_, key_result1)->GetInt()); for (int i = 0; i < 3; i++) { - JSHandle key(thread, JSTaggedValue(i)); - JSSet::Delete(thread, set, key); + JSHandle key(thread_, JSTaggedValue(i)); + JSSet::Delete(thread_, set, key); } - JSHandle key_result2 = JSIterator::IteratorStep(thread, key_iter); - EXPECT_EQ(3, JSIterator::IteratorValue(thread, key_result2)->GetInt()); - JSHandle key_result3 = JSIterator::IteratorStep(thread, key_iter); - EXPECT_EQ(4, JSIterator::IteratorValue(thread, key_result3)->GetInt()); - JSHandle key(thread, JSTaggedValue(5)); - JSSet::Add(thread, set, key); - JSHandle key_result4 = JSIterator::IteratorStep(thread, key_iter); - EXPECT_EQ(5, JSIterator::IteratorValue(thread, key_result4)->GetInt()); - JSHandle key_result5 = JSIterator::IteratorStep(thread, key_iter); + JSHandle key_result2 = JSIterator::IteratorStep(thread_, key_iter); + EXPECT_EQ(3, JSIterator::IteratorValue(thread_, key_result2)->GetInt()); + JSHandle key_result3 = JSIterator::IteratorStep(thread_, key_iter); + EXPECT_EQ(4, JSIterator::IteratorValue(thread_, key_result3)->GetInt()); + JSHandle key(thread_, JSTaggedValue(5)); + JSSet::Add(thread_, set, key); + JSHandle key_result4 = JSIterator::IteratorStep(thread_, key_iter); + EXPECT_EQ(5, JSIterator::IteratorValue(thread_, key_result4)->GetInt()); + JSHandle key_result5 = JSIterator::IteratorStep(thread_, key_iter); EXPECT_EQ(JSTaggedValue::False(), key_result5.GetTaggedValue()); } diff --git a/tests/runtime/common/js_symbol_test.cpp b/tests/runtime/common/js_symbol_test.cpp index 4d5f59151..e8e89a21f 100644 --- a/tests/runtime/common/js_symbol_test.cpp +++ b/tests/runtime/common/js_symbol_test.cpp @@ -38,18 +38,18 @@ class JSSymbolTest : 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_); } private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; - JSThread *thread {}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; + JSThread *thread_ {}; }; } // namespace panda::test diff --git a/tests/runtime/common/js_tagged_queue_test.cpp b/tests/runtime/common/js_tagged_queue_test.cpp index 3df1279bc..1c98e2ffc 100644 --- a/tests/runtime/common/js_tagged_queue_test.cpp +++ b/tests/runtime/common/js_tagged_queue_test.cpp @@ -32,26 +32,26 @@ class JSTaggedQueueTest : 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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {}; + JSThread *thread_ {}; private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; TEST_F(JSTaggedQueueTest, Create) { - JSHandle queue = thread->GetEcmaVM()->GetFactory()->NewTaggedQueue(0); + JSHandle queue = thread_->GetEcmaVM()->GetFactory()->NewTaggedQueue(0); EXPECT_TRUE(*queue != nullptr); EXPECT_TRUE(queue->Empty()); EXPECT_TRUE(queue->Size() == 0); @@ -61,50 +61,50 @@ TEST_F(JSTaggedQueueTest, Create) TEST_F(JSTaggedQueueTest, PopAndPush) { - JSHandle queue = thread->GetEcmaVM()->GetFactory()->NewTaggedQueue(0); + JSHandle queue = thread_->GetEcmaVM()->GetFactory()->NewTaggedQueue(0); EXPECT_TRUE(queue->Empty()); - JSHandle queue2(thread, - TaggedQueue::Push(thread, queue, JSHandle(thread, JSTaggedValue(0)))); + JSHandle queue2(thread_, + TaggedQueue::Push(thread_, queue, JSHandle(thread_, JSTaggedValue(0)))); EXPECT_FALSE(queue2->Empty()); EXPECT_EQ(queue2->Size(), 1); EXPECT_EQ(queue2->Front(), JSTaggedValue(0)); EXPECT_EQ(queue2->Back(), JSTaggedValue(0)); - JSHandle queue3(thread, - TaggedQueue::Push(thread, queue2, JSHandle(thread, JSTaggedValue(1)))); + JSHandle queue3( + thread_, TaggedQueue::Push(thread_, queue2, JSHandle(thread_, JSTaggedValue(1)))); EXPECT_EQ(queue3->Size(), 2); EXPECT_EQ(queue3->Front(), JSTaggedValue(0)); EXPECT_EQ(queue3->Back(), JSTaggedValue(1)); EXPECT_NE(queue3.GetTaggedValue(), queue2.GetTaggedValue()); - JSHandle queue4(thread, - TaggedQueue::Push(thread, queue3, JSHandle(thread, JSTaggedValue(2)))); + JSHandle queue4( + thread_, TaggedQueue::Push(thread_, queue3, JSHandle(thread_, JSTaggedValue(2)))); EXPECT_EQ(queue4->Size(), 3); EXPECT_EQ(queue4->Front(), JSTaggedValue(0)); EXPECT_EQ(queue4->Back(), JSTaggedValue(2)); EXPECT_NE(queue4.GetTaggedValue(), queue3.GetTaggedValue()); - JSHandle queue5(thread, - TaggedQueue::Push(thread, queue4, JSHandle(thread, JSTaggedValue(3)))); + JSHandle queue5( + thread_, TaggedQueue::Push(thread_, queue4, JSHandle(thread_, JSTaggedValue(3)))); EXPECT_EQ(queue5->Size(), 4); EXPECT_EQ(queue5->Front(), JSTaggedValue(0)); EXPECT_EQ(queue5->Back(), JSTaggedValue(3)); EXPECT_NE(queue5.GetTaggedValue(), queue4.GetTaggedValue()); - EXPECT_EQ(queue5->Pop(thread), JSTaggedValue(0)); + EXPECT_EQ(queue5->Pop(thread_), JSTaggedValue(0)); EXPECT_EQ(queue5->Size(), 3); EXPECT_EQ(queue5->Front(), JSTaggedValue(1)); - EXPECT_EQ(queue5->Pop(thread), JSTaggedValue(1)); + EXPECT_EQ(queue5->Pop(thread_), JSTaggedValue(1)); EXPECT_EQ(queue5->Size(), 2); EXPECT_EQ(queue5->Front(), JSTaggedValue(2)); - EXPECT_EQ(queue5->Pop(thread), JSTaggedValue(2)); + EXPECT_EQ(queue5->Pop(thread_), JSTaggedValue(2)); EXPECT_EQ(queue5->Size(), 1); EXPECT_EQ(queue5->Front(), JSTaggedValue(3)); - EXPECT_EQ(queue5->Pop(thread), JSTaggedValue(3)); + EXPECT_EQ(queue5->Pop(thread_), JSTaggedValue(3)); EXPECT_EQ(queue5->Size(), 0); EXPECT_EQ(queue5->Front(), JSTaggedValue::Hole()); EXPECT_TRUE(queue5->Empty()); diff --git a/tests/runtime/common/js_typed_array_test.cpp b/tests/runtime/common/js_typed_array_test.cpp index d3b622cb7..0eb75e6cb 100644 --- a/tests/runtime/common/js_typed_array_test.cpp +++ b/tests/runtime/common/js_typed_array_test.cpp @@ -36,17 +36,17 @@ 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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {nullptr}; + JSThread *thread_ {nullptr}; // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) const std::vector c_vec_js_type_ { @@ -65,8 +65,8 @@ protected: JSTaggedValue((double)(987654321.123456789))}; private: - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; JSHandle CreateNumberTypedArray(JSThread *thread, JSType js_type) @@ -121,10 +121,10 @@ JSHandle CreateNumberTypedArray(JSThread *thread, JSType js_type) */ TEST_F(JSTypedArrayTest, ToPropKey_001) { - JSHandle handle_undefined(thread, JSTaggedValue::Undefined()); - JSHandle handle_hole(thread, JSTaggedValue::Hole()); - JSHandle hnadle_tag_val_ecma_str_prop_key_to1 = JSTypedArray::ToPropKey(thread, handle_undefined); - JSHandle hnadle_tag_val_ecma_str_prop_key_to2 = JSTypedArray::ToPropKey(thread, handle_hole); + JSHandle handle_undefined(thread_, JSTaggedValue::Undefined()); + JSHandle handle_hole(thread_, JSTaggedValue::Hole()); + JSHandle hnadle_tag_val_ecma_str_prop_key_to1 = JSTypedArray::ToPropKey(thread_, handle_undefined); + JSHandle hnadle_tag_val_ecma_str_prop_key_to2 = JSTypedArray::ToPropKey(thread_, handle_hole); JSHandle handle_ecma_str_prop_key_to1 = JSHandle::Cast(hnadle_tag_val_ecma_str_prop_key_to1); JSHandle handle_ecma_str_prop_key_to2 = @@ -156,14 +156,14 @@ TEST_F(JSTypedArrayTest, ToPropKey_001) */ TEST_F(JSTypedArrayTest, ToPropKey_002) { - JSHandle handle_tag_val1(thread, JSTaggedValue(0)); - JSHandle handle_tag_val2(thread, JSTaggedValue(-1)); - JSHandle handle_tag_val3(thread, JSTaggedValue(1.789)); - JSHandle handle_tag_val4(thread, JSTaggedValue(-789.1)); - JSHandle hnadle_tag_val_ecma_str_prop_key_to1 = JSTypedArray::ToPropKey(thread, handle_tag_val1); - JSHandle hnadle_tag_val_ecma_str_prop_key_to2 = JSTypedArray::ToPropKey(thread, handle_tag_val2); - JSHandle hnadle_tag_val_ecma_str_prop_key_to3 = JSTypedArray::ToPropKey(thread, handle_tag_val3); - JSHandle hnadle_tag_val_ecma_str_prop_key_to4 = JSTypedArray::ToPropKey(thread, handle_tag_val4); + JSHandle handle_tag_val1(thread_, JSTaggedValue(0)); + JSHandle handle_tag_val2(thread_, JSTaggedValue(-1)); + JSHandle handle_tag_val3(thread_, JSTaggedValue(1.789)); + JSHandle handle_tag_val4(thread_, JSTaggedValue(-789.1)); + JSHandle hnadle_tag_val_ecma_str_prop_key_to1 = JSTypedArray::ToPropKey(thread_, handle_tag_val1); + JSHandle hnadle_tag_val_ecma_str_prop_key_to2 = JSTypedArray::ToPropKey(thread_, handle_tag_val2); + JSHandle hnadle_tag_val_ecma_str_prop_key_to3 = JSTypedArray::ToPropKey(thread_, handle_tag_val3); + JSHandle hnadle_tag_val_ecma_str_prop_key_to4 = JSTypedArray::ToPropKey(thread_, handle_tag_val4); JSHandle handle_ecma_str_prop_key_to1 = JSHandle::Cast(hnadle_tag_val_ecma_str_prop_key_to1); JSHandle handle_ecma_str_prop_key_to2 = @@ -206,41 +206,41 @@ TEST_F(JSTypedArrayTest, ToPropKey_002) */ TEST_F(JSTypedArrayTest, TypedArrayCreate) { - JSHandle handle_int8_array = CreateNumberTypedArray(thread, JSType::JS_INT8_ARRAY); + JSHandle handle_int8_array = CreateNumberTypedArray(thread_, JSType::JS_INT8_ARRAY); JSHandle handle_tag_val_int8_array = JSHandle::Cast(handle_int8_array); EXPECT_TRUE(handle_tag_val_int8_array->IsJSInt8Array() && handle_tag_val_int8_array->IsTypedArray()); - JSHandle handle_uint8_array = CreateNumberTypedArray(thread, JSType::JS_UINT8_ARRAY); + JSHandle handle_uint8_array = CreateNumberTypedArray(thread_, JSType::JS_UINT8_ARRAY); JSHandle handle_tag_val_uint8_array = JSHandle::Cast(handle_uint8_array); EXPECT_TRUE(handle_tag_val_uint8_array->IsJSUint8Array() && handle_tag_val_uint8_array->IsTypedArray()); - JSHandle handle_uint8_clamped_array = CreateNumberTypedArray(thread, JSType::JS_UINT8_CLAMPED_ARRAY); + JSHandle handle_uint8_clamped_array = CreateNumberTypedArray(thread_, JSType::JS_UINT8_CLAMPED_ARRAY); JSHandle handle_tag_val_uint8_clamped_array = JSHandle::Cast(handle_uint8_clamped_array); EXPECT_TRUE(handle_tag_val_uint8_clamped_array->IsJSUint8ClampedArray() && handle_tag_val_uint8_clamped_array->IsTypedArray()); - JSHandle handle_int16_array = CreateNumberTypedArray(thread, JSType::JS_INT16_ARRAY); + JSHandle handle_int16_array = CreateNumberTypedArray(thread_, JSType::JS_INT16_ARRAY); JSHandle handle_tag_val_int16_array = JSHandle::Cast(handle_int16_array); EXPECT_TRUE(handle_tag_val_int16_array->IsJSInt16Array() && handle_tag_val_int16_array->IsTypedArray()); - JSHandle handle_uint16_array = CreateNumberTypedArray(thread, JSType::JS_UINT16_ARRAY); + JSHandle handle_uint16_array = CreateNumberTypedArray(thread_, JSType::JS_UINT16_ARRAY); JSHandle handle_tag_val_uint16_array = JSHandle::Cast(handle_uint16_array); EXPECT_TRUE(handle_tag_val_uint16_array->IsJSUint16Array() && handle_tag_val_uint16_array->IsTypedArray()); - JSHandle handle_int32_array = CreateNumberTypedArray(thread, JSType::JS_INT32_ARRAY); + JSHandle handle_int32_array = CreateNumberTypedArray(thread_, JSType::JS_INT32_ARRAY); JSHandle handle_tag_val_int32_array = JSHandle::Cast(handle_int32_array); EXPECT_TRUE(handle_tag_val_int32_array->IsJSInt32Array() && handle_tag_val_int32_array->IsTypedArray()); - JSHandle handle_uint32_array = CreateNumberTypedArray(thread, JSType::JS_UINT32_ARRAY); + JSHandle handle_uint32_array = CreateNumberTypedArray(thread_, JSType::JS_UINT32_ARRAY); JSHandle handle_tag_val_uint32_array = JSHandle::Cast(handle_uint32_array); EXPECT_TRUE(handle_tag_val_uint32_array->IsJSUint32Array() && handle_tag_val_uint32_array->IsTypedArray()); - JSHandle handle_float32_array = CreateNumberTypedArray(thread, JSType::JS_FLOAT32_ARRAY); + JSHandle handle_float32_array = CreateNumberTypedArray(thread_, JSType::JS_FLOAT32_ARRAY); JSHandle handle_tag_val_float32_array = JSHandle::Cast(handle_float32_array); EXPECT_TRUE(handle_tag_val_float32_array->IsJSFloat32Array() && handle_tag_val_float32_array->IsTypedArray()); - JSHandle handle_float64_array = CreateNumberTypedArray(thread, JSType::JS_FLOAT64_ARRAY); + JSHandle handle_float64_array = CreateNumberTypedArray(thread_, JSType::JS_FLOAT64_ARRAY); JSHandle handle_tag_val_float64_array = JSHandle::Cast(handle_float64_array); EXPECT_TRUE(handle_tag_val_float64_array->IsJSFloat64Array() && handle_tag_val_float64_array->IsTypedArray()); } @@ -255,15 +255,15 @@ TEST_F(JSTypedArrayTest, TypedArrayCreate) */ TEST_F(JSTypedArrayTest, SetViewedArrayBuffer) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle handle_array_buffer_from = factory->NewJSArrayBuffer(10); JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(handle_array_buffer_from); for (size_t i = 0; i < c_vec_js_type_.size(); i++) { - JSHandle handle_typed_array = CreateNumberTypedArray(thread, c_vec_js_type_.at(i)); + JSHandle handle_typed_array = CreateNumberTypedArray(thread_, c_vec_js_type_.at(i)); EXPECT_EQ(handle_typed_array->GetViewedArrayBuffer(), JSTaggedValue::Undefined()); - handle_typed_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); + handle_typed_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); EXPECT_EQ(handle_typed_array->GetViewedArrayBuffer(), handle_tag_val_array_buffer_from.GetTaggedValue()); } } @@ -279,16 +279,16 @@ TEST_F(JSTypedArrayTest, SetViewedArrayBuffer) TEST_F(JSTypedArrayTest, SetTypedArrayName) { PandaString c_str_name = "cStrName"; - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle handle_ecma_str_name_from = factory->NewFromString(c_str_name); JSHandle handle_tag_val_ecma_str_name_from = JSHandle::Cast(handle_ecma_str_name_from); for (size_t i = 0; i < c_vec_js_type_.size(); i++) { - JSHandle handle_typed_array = CreateNumberTypedArray(thread, c_vec_js_type_.at(i)); + JSHandle handle_typed_array = CreateNumberTypedArray(thread_, c_vec_js_type_.at(i)); EXPECT_EQ(handle_typed_array->GetTypedArrayName(), JSTaggedValue::Undefined()); - handle_typed_array->SetTypedArrayName(thread, handle_tag_val_ecma_str_name_from); + handle_typed_array->SetTypedArrayName(thread_, handle_tag_val_ecma_str_name_from); EXPECT_EQ(handle_typed_array->GetTypedArrayName(), handle_tag_val_ecma_str_name_from.GetTaggedValue()); } } @@ -304,13 +304,13 @@ TEST_F(JSTypedArrayTest, SetTypedArrayName) TEST_F(JSTypedArrayTest, SetByteLength) { uint32_t u32_byte_length = 2; - JSHandle handle_tag_val_byte_length_from(thread, JSTaggedValue(u32_byte_length)); + JSHandle handle_tag_val_byte_length_from(thread_, JSTaggedValue(u32_byte_length)); for (size_t i = 0; i < c_vec_js_type_.size(); i++) { - JSHandle handle_typed_array = CreateNumberTypedArray(thread, c_vec_js_type_.at(i)); + JSHandle handle_typed_array = CreateNumberTypedArray(thread_, c_vec_js_type_.at(i)); EXPECT_EQ(handle_typed_array->GetByteLength(), JSTaggedValue(0)); - handle_typed_array->SetByteLength(thread, handle_tag_val_byte_length_from); + handle_typed_array->SetByteLength(thread_, handle_tag_val_byte_length_from); EXPECT_EQ(handle_typed_array->GetByteLength(), handle_tag_val_byte_length_from.GetTaggedValue()); } } @@ -326,13 +326,13 @@ TEST_F(JSTypedArrayTest, SetByteLength) TEST_F(JSTypedArrayTest, SetByteOffset) { uint32_t u32_byte_offset = 2; - JSHandle handle_tag_val_byte_offset_from(thread, JSTaggedValue(u32_byte_offset)); + JSHandle handle_tag_val_byte_offset_from(thread_, JSTaggedValue(u32_byte_offset)); for (size_t i = 0; i < c_vec_js_type_.size(); i++) { - JSHandle handle_typed_array = CreateNumberTypedArray(thread, c_vec_js_type_.at(i)); + JSHandle handle_typed_array = CreateNumberTypedArray(thread_, c_vec_js_type_.at(i)); EXPECT_EQ(handle_typed_array->GetByteOffset(), JSTaggedValue(0)); - handle_typed_array->SetByteOffset(thread, handle_tag_val_byte_offset_from); + handle_typed_array->SetByteOffset(thread_, handle_tag_val_byte_offset_from); EXPECT_EQ(handle_typed_array->GetByteOffset(), handle_tag_val_byte_offset_from.GetTaggedValue()); } } @@ -348,13 +348,13 @@ TEST_F(JSTypedArrayTest, SetByteOffset) TEST_F(JSTypedArrayTest, SetArrayLength) { uint32_t u32_array_length = 2; - JSHandle handle_tag_val_array_length_from(thread, JSTaggedValue(u32_array_length)); + JSHandle handle_tag_val_array_length_from(thread_, JSTaggedValue(u32_array_length)); for (size_t i = 0; i < c_vec_js_type_.size(); i++) { - JSHandle handle_typed_array = CreateNumberTypedArray(thread, c_vec_js_type_.at(i)); + JSHandle handle_typed_array = CreateNumberTypedArray(thread_, c_vec_js_type_.at(i)); EXPECT_EQ(handle_typed_array->GetArrayLength(), JSTaggedValue(0)); - handle_typed_array->SetArrayLength(thread, handle_tag_val_array_length_from); + handle_typed_array->SetArrayLength(thread_, handle_tag_val_array_length_from); EXPECT_EQ(handle_typed_array->GetArrayLength(), handle_tag_val_array_length_from.GetTaggedValue()); } } @@ -370,8 +370,8 @@ TEST_F(JSTypedArrayTest, SetArrayLength) TEST_F(JSTypedArrayTest, DISABLED_IntegerIndexedElementSet_Int8Array_001) { uint32_t num_elements_int8_array = 256; - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle handle_int8_array = CreateNumberTypedArray(thread, JSType::JS_INT8_ARRAY); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle handle_int8_array = CreateNumberTypedArray(thread_, JSType::JS_INT8_ARRAY); JSHandle handle_tag_val_int8_array = JSHandle::Cast(handle_int8_array); uint32_t size_element = @@ -379,16 +379,16 @@ TEST_F(JSTypedArrayTest, DISABLED_IntegerIndexedElementSet_Int8Array_001) uint32_t byte_length_viewd_array_buffer = size_element * num_elements_int8_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_int8_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_int8_array->SetArrayLength(thread, JSTaggedValue(num_elements_int8_array)); + handle_int8_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_int8_array->SetArrayLength(thread_, JSTaggedValue(num_elements_int8_array)); PandaVector c_vec_op_result = {}; for (size_t i = 0; i < num_elements_int8_array; i++) { EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet( - thread, handle_tag_val_int8_array, JSTaggedValue(i), - JSHandle(thread, JSTaggedValue(std::numeric_limits::min() + i)))); + thread_, handle_tag_val_int8_array, JSTaggedValue(i), + JSHandle(thread_, JSTaggedValue(std::numeric_limits::min() + i)))); OperationResult op_result = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int8_array, JSTaggedValue(i)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int8_array, JSTaggedValue(i)); c_vec_op_result.push_back(op_result); } for (size_t i = 0; i < num_elements_int8_array; i++) { @@ -398,31 +398,31 @@ TEST_F(JSTypedArrayTest, DISABLED_IntegerIndexedElementSet_Int8Array_001) c_vec_op_result.clear(); OperationResult op_result1 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int8_array, JSTaggedValue(-1)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int8_array, JSTaggedValue(-1)); OperationResult op_result2 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int8_array, JSTaggedValue(-0.0)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int8_array, JSTaggedValue(-0.0)); OperationResult op_result3 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int8_array, JSTaggedValue(1.1)); - OperationResult op_result4 = JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int8_array, + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int8_array, JSTaggedValue(1.1)); + OperationResult op_result4 = JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int8_array, JSTaggedValue(num_elements_int8_array)); EXPECT_EQ(op_result1.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result2.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result3.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result4.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); - EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_int8_array, JSTaggedValue(-1), - JSHandle(thread, JSTaggedValue(0)))); - EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_int8_array, + EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_int8_array, JSTaggedValue(-1), + JSHandle(thread_, JSTaggedValue(0)))); + EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_int8_array, JSTaggedValue(num_elements_int8_array), - JSHandle(thread, JSTaggedValue(0)))); + JSHandle(thread_, JSTaggedValue(0)))); } // Nonstandard input value for Int8Array TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Int8Array_002) { uint32_t num_elements_int8_array = 16; - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle handle_int8_array = CreateNumberTypedArray(thread, JSType::JS_INT8_ARRAY); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle handle_int8_array = CreateNumberTypedArray(thread_, JSType::JS_INT8_ARRAY); JSHandle handle_tag_val_int8_array = JSHandle::Cast(handle_int8_array); uint32_t size_element = @@ -430,34 +430,34 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Int8Array_002) uint32_t byte_length_viewd_array_buffer = size_element * num_elements_int8_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_int8_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_int8_array->SetArrayLength(thread, JSTaggedValue(num_elements_int8_array)); + handle_int8_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_int8_array->SetArrayLength(thread_, JSTaggedValue(num_elements_int8_array)); int64_t value1 = -129; // to int8 : 127 int64_t value2 = 128; // to int8 : -128 double value3 = 13.4; // to int8 : 13 double value4 = 13.6; // to int8 : 13 - JSHandle handle_tag_val_value_set1(thread, JSTaggedValue(value1)); - JSHandle handle_tag_val_value_set2(thread, JSTaggedValue(value2)); - JSHandle handle_tag_val_value_set3(thread, JSTaggedValue(value3)); - JSHandle handle_tag_val_value_set4(thread, JSTaggedValue(value4)); + JSHandle handle_tag_val_value_set1(thread_, JSTaggedValue(value1)); + JSHandle handle_tag_val_value_set2(thread_, JSTaggedValue(value2)); + JSHandle handle_tag_val_value_set3(thread_, JSTaggedValue(value3)); + JSHandle handle_tag_val_value_set4(thread_, JSTaggedValue(value4)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_int8_array, JSTaggedValue(0), + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_int8_array, JSTaggedValue(0), handle_tag_val_value_set1)); OperationResult op_result1 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int8_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_int8_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int8_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_int8_array, JSTaggedValue(0), handle_tag_val_value_set2)); OperationResult op_result2 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int8_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_int8_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int8_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_int8_array, JSTaggedValue(0), handle_tag_val_value_set3)); OperationResult op_result3 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int8_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_int8_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int8_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_int8_array, JSTaggedValue(0), handle_tag_val_value_set4)); OperationResult op_result4 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int8_array, JSTaggedValue(0)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int8_array, JSTaggedValue(0)); EXPECT_NE(value1, op_result1.GetValue().GetTaggedValue().GetNumber()); EXPECT_NE(value2, op_result2.GetValue().GetTaggedValue().GetNumber()); @@ -472,8 +472,8 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Int8Array_002) TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint8Array_001) { uint32_t num_elements_uint8_array = 256; - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle handle_uint8_array = CreateNumberTypedArray(thread, JSType::JS_UINT8_ARRAY); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle handle_uint8_array = CreateNumberTypedArray(thread_, JSType::JS_UINT8_ARRAY); JSHandle handle_tag_val_uint8_array = JSHandle::Cast(handle_uint8_array); uint32_t size_element = @@ -481,16 +481,16 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint8Array_001) uint32_t byte_length_viewd_array_buffer = size_element * num_elements_uint8_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_uint8_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_uint8_array->SetArrayLength(thread, JSTaggedValue(num_elements_uint8_array)); + handle_uint8_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_uint8_array->SetArrayLength(thread_, JSTaggedValue(num_elements_uint8_array)); PandaVector c_vec_op_result = {}; for (uint32_t i = 0; i < num_elements_uint8_array; i++) { EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet( - thread, handle_tag_val_uint8_array, JSTaggedValue(i), - JSHandle(thread, JSTaggedValue(std::numeric_limits::min() + i)))); + thread_, handle_tag_val_uint8_array, JSTaggedValue(i), + JSHandle(thread_, JSTaggedValue(std::numeric_limits::min() + i)))); OperationResult op_result = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint8_array, JSTaggedValue(i)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint8_array, JSTaggedValue(i)); c_vec_op_result.push_back(op_result); } for (uint32_t i = 0; i < num_elements_uint8_array; i++) { @@ -500,31 +500,31 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint8Array_001) c_vec_op_result.clear(); OperationResult op_result1 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint8_array, JSTaggedValue(-1)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint8_array, JSTaggedValue(-1)); OperationResult op_result2 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint8_array, JSTaggedValue(-0.0)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint8_array, JSTaggedValue(-0.0)); OperationResult op_result3 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint8_array, JSTaggedValue(1.1)); - OperationResult op_result4 = JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint8_array, + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint8_array, JSTaggedValue(1.1)); + OperationResult op_result4 = JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint8_array, JSTaggedValue(num_elements_uint8_array)); EXPECT_EQ(op_result1.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result2.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result3.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result4.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); - EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint8_array, JSTaggedValue(-1), - JSHandle(thread, JSTaggedValue(0)))); - EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint8_array, + EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint8_array, JSTaggedValue(-1), + JSHandle(thread_, JSTaggedValue(0)))); + EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint8_array, JSTaggedValue(num_elements_uint8_array), - JSHandle(thread, JSTaggedValue(0)))); + JSHandle(thread_, JSTaggedValue(0)))); } // Nonstandard input value for Uint8Array TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint8Array_002) { uint32_t num_elements_uint8_array = 16; - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle handle_uint8_array = CreateNumberTypedArray(thread, JSType::JS_UINT8_ARRAY); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle handle_uint8_array = CreateNumberTypedArray(thread_, JSType::JS_UINT8_ARRAY); JSHandle handle_tag_val_uint8_array = JSHandle::Cast(handle_uint8_array); uint32_t size_element = @@ -532,34 +532,34 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint8Array_002) uint32_t byte_length_viewd_array_buffer = size_element * num_elements_uint8_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_uint8_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_uint8_array->SetArrayLength(thread, JSTaggedValue(num_elements_uint8_array)); + handle_uint8_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_uint8_array->SetArrayLength(thread_, JSTaggedValue(num_elements_uint8_array)); int64_t value1 = -1; // to uint8 : 255 int64_t value2 = 256; // to uint8 : 0 double value3 = 13.4; // to uint8 : 13 double value4 = 13.6; // to uint8 : 13 - JSHandle handle_tag_val_value_set1(thread, JSTaggedValue(value1)); - JSHandle handle_tag_val_value_set2(thread, JSTaggedValue(value2)); - JSHandle handle_tag_val_value_set3(thread, JSTaggedValue(value3)); - JSHandle handle_tag_val_value_set4(thread, JSTaggedValue(value4)); + JSHandle handle_tag_val_value_set1(thread_, JSTaggedValue(value1)); + JSHandle handle_tag_val_value_set2(thread_, JSTaggedValue(value2)); + JSHandle handle_tag_val_value_set3(thread_, JSTaggedValue(value3)); + JSHandle handle_tag_val_value_set4(thread_, JSTaggedValue(value4)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint8_array, JSTaggedValue(0), + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint8_array, JSTaggedValue(0), handle_tag_val_value_set1)); OperationResult op_result1 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint8_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint8_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint8_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint8_array, JSTaggedValue(0), handle_tag_val_value_set2)); OperationResult op_result2 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint8_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint8_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint8_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint8_array, JSTaggedValue(0), handle_tag_val_value_set3)); OperationResult op_result3 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint8_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint8_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint8_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint8_array, JSTaggedValue(0), handle_tag_val_value_set4)); OperationResult op_result4 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint8_array, JSTaggedValue(0)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint8_array, JSTaggedValue(0)); EXPECT_NE(value1, op_result1.GetValue().GetTaggedValue().GetNumber()); EXPECT_NE(value2, op_result2.GetValue().GetTaggedValue().GetNumber()); @@ -574,8 +574,8 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint8Array_002) TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint8ClampedArray_001) { uint32_t num_elements_uint8_clamped_array = 256; - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle handle_uint8_clamped_array = CreateNumberTypedArray(thread, JSType::JS_UINT8_CLAMPED_ARRAY); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle handle_uint8_clamped_array = CreateNumberTypedArray(thread_, JSType::JS_UINT8_CLAMPED_ARRAY); JSHandle handle_tag_val_uint8_clamped_array = JSHandle::Cast(handle_uint8_clamped_array); @@ -584,16 +584,16 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint8ClampedArray_001) uint32_t byte_length_viewd_array_buffer = size_element * num_elements_uint8_clamped_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_uint8_clamped_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_uint8_clamped_array->SetArrayLength(thread, JSTaggedValue(num_elements_uint8_clamped_array)); + handle_uint8_clamped_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_uint8_clamped_array->SetArrayLength(thread_, JSTaggedValue(num_elements_uint8_clamped_array)); PandaVector c_vec_op_result = {}; for (uint32_t i = 0; i < num_elements_uint8_clamped_array; i++) { EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet( - thread, handle_tag_val_uint8_clamped_array, JSTaggedValue(i), - JSHandle(thread, JSTaggedValue(std::numeric_limits::min() + i)))); + thread_, handle_tag_val_uint8_clamped_array, JSTaggedValue(i), + JSHandle(thread_, JSTaggedValue(std::numeric_limits::min() + i)))); OperationResult op_result = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint8_clamped_array, JSTaggedValue(i)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint8_clamped_array, JSTaggedValue(i)); c_vec_op_result.push_back(op_result); } for (uint32_t i = 0; i < num_elements_uint8_clamped_array; i++) { @@ -603,31 +603,31 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint8ClampedArray_001) c_vec_op_result.clear(); OperationResult op_result1 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint8_clamped_array, JSTaggedValue(-1)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint8_clamped_array, JSTaggedValue(-1)); OperationResult op_result2 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint8_clamped_array, JSTaggedValue(-0.0)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint8_clamped_array, JSTaggedValue(-0.0)); OperationResult op_result3 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint8_clamped_array, JSTaggedValue(1.1)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint8_clamped_array, JSTaggedValue(1.1)); OperationResult op_result4 = JSTypedArray::IntegerIndexedElementGet( - thread, handle_tag_val_uint8_clamped_array, JSTaggedValue(num_elements_uint8_clamped_array)); + thread_, handle_tag_val_uint8_clamped_array, JSTaggedValue(num_elements_uint8_clamped_array)); EXPECT_EQ(op_result1.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result2.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result3.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result4.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); - EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint8_clamped_array, JSTaggedValue(-1), - JSHandle(thread, JSTaggedValue(0)))); - EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint8_clamped_array, + EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint8_clamped_array, JSTaggedValue(-1), + JSHandle(thread_, JSTaggedValue(0)))); + EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint8_clamped_array, JSTaggedValue(num_elements_uint8_clamped_array), - JSHandle(thread, JSTaggedValue(0)))); + JSHandle(thread_, JSTaggedValue(0)))); } // Nonstandard input value for Uint8ClampedArray TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint8ClampedArray_002) { uint32_t num_elements_uint8_clamped_array = 16; - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle handle_uint8_clamped_array = CreateNumberTypedArray(thread, JSType::JS_UINT8_CLAMPED_ARRAY); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle handle_uint8_clamped_array = CreateNumberTypedArray(thread_, JSType::JS_UINT8_CLAMPED_ARRAY); JSHandle handle_tag_val_uint8_clamped_array = JSHandle::Cast(handle_uint8_clamped_array); @@ -636,34 +636,34 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint8ClampedArray_002) uint32_t byte_length_viewd_array_buffer = size_element * num_elements_uint8_clamped_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_uint8_clamped_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_uint8_clamped_array->SetArrayLength(thread, JSTaggedValue(num_elements_uint8_clamped_array)); + handle_uint8_clamped_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_uint8_clamped_array->SetArrayLength(thread_, JSTaggedValue(num_elements_uint8_clamped_array)); int64_t value1 = -1; // to uint8_clamped : 0 int64_t value2 = 256; // to uint8_clamped : 255 double value3 = 13.4; // to uint8_clamped : 13 double value4 = 13.6; // to uint8_clamped : 14 - JSHandle handle_tag_val_value_set1(thread, JSTaggedValue(value1)); - JSHandle handle_tag_val_value_set2(thread, JSTaggedValue(value2)); - JSHandle handle_tag_val_value_set3(thread, JSTaggedValue(value3)); - JSHandle handle_tag_val_value_set4(thread, JSTaggedValue(value4)); + JSHandle handle_tag_val_value_set1(thread_, JSTaggedValue(value1)); + JSHandle handle_tag_val_value_set2(thread_, JSTaggedValue(value2)); + JSHandle handle_tag_val_value_set3(thread_, JSTaggedValue(value3)); + JSHandle handle_tag_val_value_set4(thread_, JSTaggedValue(value4)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint8_clamped_array, JSTaggedValue(0), + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint8_clamped_array, JSTaggedValue(0), handle_tag_val_value_set1)); OperationResult op_result1 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint8_clamped_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint8_clamped_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint8_clamped_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint8_clamped_array, JSTaggedValue(0), handle_tag_val_value_set2)); OperationResult op_result2 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint8_clamped_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint8_clamped_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint8_clamped_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint8_clamped_array, JSTaggedValue(0), handle_tag_val_value_set3)); OperationResult op_result3 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint8_clamped_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint8_clamped_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint8_clamped_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint8_clamped_array, JSTaggedValue(0), handle_tag_val_value_set4)); OperationResult op_result4 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint8_clamped_array, JSTaggedValue(0)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint8_clamped_array, JSTaggedValue(0)); EXPECT_NE(value1, op_result1.GetValue().GetTaggedValue().GetNumber()); EXPECT_NE(value2, op_result2.GetValue().GetTaggedValue().GetNumber()); @@ -679,8 +679,8 @@ TEST_F(JSTypedArrayTest, DISABLED_IntegerIndexedElementSet_Int16Array_001) { uint32_t num_elements_int16_array = 100; int16_t scale_for_int16_value_set = 100; - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle handle_int16_array = CreateNumberTypedArray(thread, JSType::JS_INT16_ARRAY); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle handle_int16_array = CreateNumberTypedArray(thread_, JSType::JS_INT16_ARRAY); JSHandle handle_tag_val_int16_array = JSHandle::Cast(handle_int16_array); uint32_t size_element = @@ -688,17 +688,17 @@ TEST_F(JSTypedArrayTest, DISABLED_IntegerIndexedElementSet_Int16Array_001) uint32_t byte_length_viewd_array_buffer = size_element * num_elements_int16_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_int16_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_int16_array->SetArrayLength(thread, JSTaggedValue(num_elements_int16_array)); + handle_int16_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_int16_array->SetArrayLength(thread_, JSTaggedValue(num_elements_int16_array)); PandaVector c_vec_op_result = {}; for (size_t i = 0; i < num_elements_int16_array; i++) { EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet( - thread, handle_tag_val_int16_array, JSTaggedValue(i), + thread_, handle_tag_val_int16_array, JSTaggedValue(i), JSHandle( - thread, JSTaggedValue(std::numeric_limits::min() + i * scale_for_int16_value_set)))); + thread_, JSTaggedValue(std::numeric_limits::min() + i * scale_for_int16_value_set)))); OperationResult op_result = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int16_array, JSTaggedValue(i)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int16_array, JSTaggedValue(i)); c_vec_op_result.push_back(op_result); } for (size_t i = 0; i < num_elements_int16_array; i++) { @@ -708,31 +708,31 @@ TEST_F(JSTypedArrayTest, DISABLED_IntegerIndexedElementSet_Int16Array_001) c_vec_op_result.clear(); OperationResult op_result1 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int16_array, JSTaggedValue(-1)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int16_array, JSTaggedValue(-1)); OperationResult op_result2 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int16_array, JSTaggedValue(-0.0)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int16_array, JSTaggedValue(-0.0)); OperationResult op_result3 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int16_array, JSTaggedValue(1.1)); - OperationResult op_result4 = JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int16_array, + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int16_array, JSTaggedValue(1.1)); + OperationResult op_result4 = JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int16_array, JSTaggedValue(num_elements_int16_array)); EXPECT_EQ(op_result1.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result2.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result3.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result4.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); - EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_int16_array, JSTaggedValue(-1), - JSHandle(thread, JSTaggedValue(0)))); - EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_int16_array, + EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_int16_array, JSTaggedValue(-1), + JSHandle(thread_, JSTaggedValue(0)))); + EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_int16_array, JSTaggedValue(num_elements_int16_array), - JSHandle(thread, JSTaggedValue(0)))); + JSHandle(thread_, JSTaggedValue(0)))); } // Nonstandard input value for Int16Array TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Int16Array_002) { uint32_t num_elements_int16_array = 16; - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle handle_int16_array = CreateNumberTypedArray(thread, JSType::JS_INT16_ARRAY); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle handle_int16_array = CreateNumberTypedArray(thread_, JSType::JS_INT16_ARRAY); JSHandle handle_tag_val_int16_array = JSHandle::Cast(handle_int16_array); uint32_t size_element = @@ -740,34 +740,34 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Int16Array_002) uint32_t byte_length_viewd_array_buffer = size_element * num_elements_int16_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_int16_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_int16_array->SetArrayLength(thread, JSTaggedValue(num_elements_int16_array)); + handle_int16_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_int16_array->SetArrayLength(thread_, JSTaggedValue(num_elements_int16_array)); int64_t value1 = -32769; // to int16 : 32767 int64_t value2 = 32768; // to int16 : -32768 double value3 = 13.4; // to int16 : 13 double value4 = 13.6; // to int16 : 13 - JSHandle handle_tag_val_value_set1(thread, JSTaggedValue(value1)); - JSHandle handle_tag_val_value_set2(thread, JSTaggedValue(value2)); - JSHandle handle_tag_val_value_set3(thread, JSTaggedValue(value3)); - JSHandle handle_tag_val_value_set4(thread, JSTaggedValue(value4)); + JSHandle handle_tag_val_value_set1(thread_, JSTaggedValue(value1)); + JSHandle handle_tag_val_value_set2(thread_, JSTaggedValue(value2)); + JSHandle handle_tag_val_value_set3(thread_, JSTaggedValue(value3)); + JSHandle handle_tag_val_value_set4(thread_, JSTaggedValue(value4)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_int16_array, JSTaggedValue(0), + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_int16_array, JSTaggedValue(0), handle_tag_val_value_set1)); OperationResult op_result1 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int16_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_int16_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int16_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_int16_array, JSTaggedValue(0), handle_tag_val_value_set2)); OperationResult op_result2 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int16_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_int16_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int16_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_int16_array, JSTaggedValue(0), handle_tag_val_value_set3)); OperationResult op_result3 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int16_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_int16_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int16_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_int16_array, JSTaggedValue(0), handle_tag_val_value_set4)); OperationResult op_result4 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int16_array, JSTaggedValue(0)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int16_array, JSTaggedValue(0)); EXPECT_NE(value1, op_result1.GetValue().GetTaggedValue().GetNumber()); EXPECT_NE(value2, op_result2.GetValue().GetTaggedValue().GetNumber()); @@ -783,8 +783,8 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint16Array_001) { uint32_t num_elements_uint16_array = 100; uint32_t scale_for_uint16_value_set = 100; - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle handle_uint16_array = CreateNumberTypedArray(thread, JSType::JS_UINT16_ARRAY); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle handle_uint16_array = CreateNumberTypedArray(thread_, JSType::JS_UINT16_ARRAY); JSHandle handle_tag_val_uint16_array = JSHandle::Cast(handle_uint16_array); uint32_t size_element = @@ -792,17 +792,17 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint16Array_001) uint32_t byte_length_viewd_array_buffer = size_element * num_elements_uint16_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_uint16_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_uint16_array->SetArrayLength(thread, JSTaggedValue(num_elements_uint16_array)); + handle_uint16_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_uint16_array->SetArrayLength(thread_, JSTaggedValue(num_elements_uint16_array)); PandaVector c_vec_op_result = {}; for (uint32_t i = 0; i < num_elements_uint16_array; i++) { EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet( - thread, handle_tag_val_uint16_array, JSTaggedValue(i), + thread_, handle_tag_val_uint16_array, JSTaggedValue(i), JSHandle( - thread, JSTaggedValue(std::numeric_limits::min() + i * scale_for_uint16_value_set)))); + thread_, JSTaggedValue(std::numeric_limits::min() + i * scale_for_uint16_value_set)))); OperationResult op_result = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint16_array, JSTaggedValue(i)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint16_array, JSTaggedValue(i)); c_vec_op_result.push_back(op_result); } for (uint32_t i = 0; i < num_elements_uint16_array; i++) { @@ -812,31 +812,31 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint16Array_001) c_vec_op_result.clear(); OperationResult op_result1 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint16_array, JSTaggedValue(-1)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint16_array, JSTaggedValue(-1)); OperationResult op_result2 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint16_array, JSTaggedValue(-0.0)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint16_array, JSTaggedValue(-0.0)); OperationResult op_result3 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint16_array, JSTaggedValue(1.1)); - OperationResult op_result4 = JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint16_array, + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint16_array, JSTaggedValue(1.1)); + OperationResult op_result4 = JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint16_array, JSTaggedValue(num_elements_uint16_array)); EXPECT_EQ(op_result1.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result2.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result3.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result4.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); - EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint16_array, JSTaggedValue(-1), - JSHandle(thread, JSTaggedValue(0)))); - EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint16_array, + EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint16_array, JSTaggedValue(-1), + JSHandle(thread_, JSTaggedValue(0)))); + EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint16_array, JSTaggedValue(num_elements_uint16_array), - JSHandle(thread, JSTaggedValue(0)))); + JSHandle(thread_, JSTaggedValue(0)))); } // Nonstandard input value for Uint16Array TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint16Array_002) { uint32_t num_elements_uint16_array = 16; - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle handle_uint16_array = CreateNumberTypedArray(thread, JSType::JS_UINT16_ARRAY); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle handle_uint16_array = CreateNumberTypedArray(thread_, JSType::JS_UINT16_ARRAY); JSHandle handle_tag_val_uint16_array = JSHandle::Cast(handle_uint16_array); uint32_t size_element = @@ -844,34 +844,34 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint16Array_002) uint32_t byte_length_viewd_array_buffer = size_element * num_elements_uint16_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_uint16_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_uint16_array->SetArrayLength(thread, JSTaggedValue(num_elements_uint16_array)); + handle_uint16_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_uint16_array->SetArrayLength(thread_, JSTaggedValue(num_elements_uint16_array)); int64_t value1 = -1; // to uint16 : 65535 int64_t value2 = 65536; // to uint16 : 0 double value3 = 13.4; // to uint16 : 13 double value4 = 13.6; // to uint16 : 13 - JSHandle handle_tag_val_value_set1(thread, JSTaggedValue(value1)); - JSHandle handle_tag_val_value_set2(thread, JSTaggedValue(value2)); - JSHandle handle_tag_val_value_set3(thread, JSTaggedValue(value3)); - JSHandle handle_tag_val_value_set4(thread, JSTaggedValue(value4)); + JSHandle handle_tag_val_value_set1(thread_, JSTaggedValue(value1)); + JSHandle handle_tag_val_value_set2(thread_, JSTaggedValue(value2)); + JSHandle handle_tag_val_value_set3(thread_, JSTaggedValue(value3)); + JSHandle handle_tag_val_value_set4(thread_, JSTaggedValue(value4)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint16_array, JSTaggedValue(0), + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint16_array, JSTaggedValue(0), handle_tag_val_value_set1)); OperationResult op_result1 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint16_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint16_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint16_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint16_array, JSTaggedValue(0), handle_tag_val_value_set2)); OperationResult op_result2 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint16_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint16_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint16_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint16_array, JSTaggedValue(0), handle_tag_val_value_set3)); OperationResult op_result3 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint16_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint16_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint16_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint16_array, JSTaggedValue(0), handle_tag_val_value_set4)); OperationResult op_result4 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint16_array, JSTaggedValue(0)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint16_array, JSTaggedValue(0)); EXPECT_NE(value1, op_result1.GetValue().GetTaggedValue().GetNumber()); EXPECT_NE(value2, op_result2.GetValue().GetTaggedValue().GetNumber()); @@ -887,8 +887,8 @@ TEST_F(JSTypedArrayTest, DISABLED_IntegerIndexedElementSet_Int32Array_001) { uint32_t num_elements_int32_array = 100; int32_t scale_for_int32_value_set = 100000; - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle handle_int32_array = CreateNumberTypedArray(thread, JSType::JS_INT32_ARRAY); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle handle_int32_array = CreateNumberTypedArray(thread_, JSType::JS_INT32_ARRAY); JSHandle handle_tag_val_int32_array = JSHandle::Cast(handle_int32_array); uint32_t size_element = @@ -896,17 +896,17 @@ TEST_F(JSTypedArrayTest, DISABLED_IntegerIndexedElementSet_Int32Array_001) uint32_t byte_length_viewd_array_buffer = size_element * num_elements_int32_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_int32_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_int32_array->SetArrayLength(thread, JSTaggedValue(num_elements_int32_array)); + handle_int32_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_int32_array->SetArrayLength(thread_, JSTaggedValue(num_elements_int32_array)); PandaVector c_vec_op_result = {}; for (size_t i = 0; i < num_elements_int32_array; i++) { EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet( - thread, handle_tag_val_int32_array, JSTaggedValue(i), + thread_, handle_tag_val_int32_array, JSTaggedValue(i), JSHandle( - thread, JSTaggedValue(std::numeric_limits::min() + i * scale_for_int32_value_set)))); + thread_, JSTaggedValue(std::numeric_limits::min() + i * scale_for_int32_value_set)))); OperationResult op_result = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int32_array, JSTaggedValue(i)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int32_array, JSTaggedValue(i)); c_vec_op_result.push_back(op_result); } for (size_t i = 0; i < num_elements_int32_array; i++) { @@ -916,31 +916,31 @@ TEST_F(JSTypedArrayTest, DISABLED_IntegerIndexedElementSet_Int32Array_001) c_vec_op_result.clear(); OperationResult op_result1 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int32_array, JSTaggedValue(-1)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int32_array, JSTaggedValue(-1)); OperationResult op_result2 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int32_array, JSTaggedValue(-0.0)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int32_array, JSTaggedValue(-0.0)); OperationResult op_result3 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int32_array, JSTaggedValue(1.1)); - OperationResult op_result4 = JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int32_array, + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int32_array, JSTaggedValue(1.1)); + OperationResult op_result4 = JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int32_array, JSTaggedValue(num_elements_int32_array)); EXPECT_EQ(op_result1.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result2.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result3.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result4.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); - EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_int32_array, JSTaggedValue(-1), - JSHandle(thread, JSTaggedValue(0)))); - EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_int32_array, + EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_int32_array, JSTaggedValue(-1), + JSHandle(thread_, JSTaggedValue(0)))); + EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_int32_array, JSTaggedValue(num_elements_int32_array), - JSHandle(thread, JSTaggedValue(0)))); + JSHandle(thread_, JSTaggedValue(0)))); } // Nonstandard input value for Int32Array TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Int32Array_002) { uint32_t num_elements_int32_array = 16; - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle handle_int32_array = CreateNumberTypedArray(thread, JSType::JS_INT32_ARRAY); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle handle_int32_array = CreateNumberTypedArray(thread_, JSType::JS_INT32_ARRAY); JSHandle handle_tag_val_int32_array = JSHandle::Cast(handle_int32_array); uint32_t size_element = @@ -948,34 +948,34 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Int32Array_002) uint32_t byte_length_viewd_array_buffer = size_element * num_elements_int32_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_int32_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_int32_array->SetArrayLength(thread, JSTaggedValue(num_elements_int32_array)); + handle_int32_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_int32_array->SetArrayLength(thread_, JSTaggedValue(num_elements_int32_array)); int64_t value1 = -2147483649; // to int32 : 2147483647 int64_t value2 = 2147483648; // to int32 : -2147483648 double value3 = 13.4; // to int32 : 13 double value4 = 13.6; // to int32 : 13 - JSHandle handle_tag_val_value_set1(thread, JSTaggedValue(value1)); - JSHandle handle_tag_val_value_set2(thread, JSTaggedValue(value2)); - JSHandle handle_tag_val_value_set3(thread, JSTaggedValue(value3)); - JSHandle handle_tag_val_value_set4(thread, JSTaggedValue(value4)); + JSHandle handle_tag_val_value_set1(thread_, JSTaggedValue(value1)); + JSHandle handle_tag_val_value_set2(thread_, JSTaggedValue(value2)); + JSHandle handle_tag_val_value_set3(thread_, JSTaggedValue(value3)); + JSHandle handle_tag_val_value_set4(thread_, JSTaggedValue(value4)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_int32_array, JSTaggedValue(0), + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_int32_array, JSTaggedValue(0), handle_tag_val_value_set1)); OperationResult op_result1 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int32_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_int32_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int32_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_int32_array, JSTaggedValue(0), handle_tag_val_value_set2)); OperationResult op_result2 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int32_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_int32_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int32_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_int32_array, JSTaggedValue(0), handle_tag_val_value_set3)); OperationResult op_result3 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int32_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_int32_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int32_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_int32_array, JSTaggedValue(0), handle_tag_val_value_set4)); OperationResult op_result4 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_int32_array, JSTaggedValue(0)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_int32_array, JSTaggedValue(0)); EXPECT_NE(value1, op_result1.GetValue().GetTaggedValue().GetNumber()); EXPECT_NE(value2, op_result2.GetValue().GetTaggedValue().GetNumber()); @@ -991,8 +991,8 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint32Array_001) { uint32_t num_elements_uint32_array = 100; uint32_t scale_for_uint32_value_set = 100000; - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle handle_uint32_array = CreateNumberTypedArray(thread, JSType::JS_UINT32_ARRAY); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle handle_uint32_array = CreateNumberTypedArray(thread_, JSType::JS_UINT32_ARRAY); JSHandle handle_tag_val_uint32_array = JSHandle::Cast(handle_uint32_array); uint32_t size_element = @@ -1000,17 +1000,17 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint32Array_001) uint32_t byte_length_viewd_array_buffer = size_element * num_elements_uint32_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_uint32_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_uint32_array->SetArrayLength(thread, JSTaggedValue(num_elements_uint32_array)); + handle_uint32_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_uint32_array->SetArrayLength(thread_, JSTaggedValue(num_elements_uint32_array)); PandaVector c_vec_op_result = {}; for (uint32_t i = 0; i < num_elements_uint32_array; i++) { EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet( - thread, handle_tag_val_uint32_array, JSTaggedValue(i), + thread_, handle_tag_val_uint32_array, JSTaggedValue(i), JSHandle( - thread, JSTaggedValue(std::numeric_limits::min() + i * scale_for_uint32_value_set)))); + thread_, JSTaggedValue(std::numeric_limits::min() + i * scale_for_uint32_value_set)))); OperationResult op_result = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint32_array, JSTaggedValue(i)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint32_array, JSTaggedValue(i)); c_vec_op_result.push_back(op_result); } for (uint32_t i = 0; i < num_elements_uint32_array; i++) { @@ -1020,31 +1020,31 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint32Array_001) c_vec_op_result.clear(); OperationResult op_result1 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint32_array, JSTaggedValue(-1)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint32_array, JSTaggedValue(-1)); OperationResult op_result2 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint32_array, JSTaggedValue(-0.0)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint32_array, JSTaggedValue(-0.0)); OperationResult op_result3 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint32_array, JSTaggedValue(1.1)); - OperationResult op_result4 = JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint32_array, + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint32_array, JSTaggedValue(1.1)); + OperationResult op_result4 = JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint32_array, JSTaggedValue(num_elements_uint32_array)); EXPECT_EQ(op_result1.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result2.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result3.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result4.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); - EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint32_array, JSTaggedValue(-1), - JSHandle(thread, JSTaggedValue(0)))); - EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint32_array, + EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint32_array, JSTaggedValue(-1), + JSHandle(thread_, JSTaggedValue(0)))); + EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint32_array, JSTaggedValue(num_elements_uint32_array), - JSHandle(thread, JSTaggedValue(0)))); + JSHandle(thread_, JSTaggedValue(0)))); } // Nonstandard input value for Uint32Array TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint32Array_002) { int32_t num_elements_uint32_array = 16; - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle handle_uint32_array = CreateNumberTypedArray(thread, JSType::JS_UINT32_ARRAY); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle handle_uint32_array = CreateNumberTypedArray(thread_, JSType::JS_UINT32_ARRAY); JSHandle handle_tag_val_uint32_array = JSHandle::Cast(handle_uint32_array); uint32_t size_element = @@ -1052,34 +1052,34 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint32Array_002) int32_t byte_length_viewd_array_buffer = size_element * num_elements_uint32_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_uint32_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_uint32_array->SetArrayLength(thread, JSTaggedValue(num_elements_uint32_array)); + handle_uint32_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_uint32_array->SetArrayLength(thread_, JSTaggedValue(num_elements_uint32_array)); int64_t value1 = -1; // to uint32 : 4294967295 int64_t value2 = 4294967296; // to uint32 : 0 double value3 = 13.4; // to uint32 : 13 double value4 = 13.6; // to uint32 : 13 - JSHandle handle_tag_val_value_set1(thread, JSTaggedValue(value1)); - JSHandle handle_tag_val_value_set2(thread, JSTaggedValue(value2)); - JSHandle handle_tag_val_value_set3(thread, JSTaggedValue(value3)); - JSHandle handle_tag_val_value_set4(thread, JSTaggedValue(value4)); + JSHandle handle_tag_val_value_set1(thread_, JSTaggedValue(value1)); + JSHandle handle_tag_val_value_set2(thread_, JSTaggedValue(value2)); + JSHandle handle_tag_val_value_set3(thread_, JSTaggedValue(value3)); + JSHandle handle_tag_val_value_set4(thread_, JSTaggedValue(value4)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint32_array, JSTaggedValue(0), + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint32_array, JSTaggedValue(0), handle_tag_val_value_set1)); OperationResult op_result1 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint32_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint32_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint32_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint32_array, JSTaggedValue(0), handle_tag_val_value_set2)); OperationResult op_result2 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint32_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint32_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint32_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint32_array, JSTaggedValue(0), handle_tag_val_value_set3)); OperationResult op_result3 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint32_array, JSTaggedValue(0)); - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_uint32_array, JSTaggedValue(0), + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint32_array, JSTaggedValue(0)); + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_uint32_array, JSTaggedValue(0), handle_tag_val_value_set4)); OperationResult op_result4 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_uint32_array, JSTaggedValue(0)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_uint32_array, JSTaggedValue(0)); EXPECT_NE(value1, op_result1.GetValue().GetTaggedValue().GetNumber()); EXPECT_NE(value2, op_result2.GetValue().GetTaggedValue().GetNumber()); @@ -1094,8 +1094,8 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Uint32Array_002) TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Float32Array) { uint32_t num_elements_float32_array = 100; - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle handle_float32_array = CreateNumberTypedArray(thread, JSType::JS_FLOAT32_ARRAY); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle handle_float32_array = CreateNumberTypedArray(thread_, JSType::JS_FLOAT32_ARRAY); JSHandle handle_tag_val_float32_array = JSHandle::Cast(handle_float32_array); uint32_t size_element = @@ -1103,18 +1103,18 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Float32Array) uint32_t byte_length_viewd_array_buffer = size_element * num_elements_float32_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_float32_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_float32_array->SetArrayLength(thread, JSTaggedValue(num_elements_float32_array)); + handle_float32_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_float32_array->SetArrayLength(thread_, JSTaggedValue(num_elements_float32_array)); PandaVector c_vec_op_result = {}; float float_max_value = std::numeric_limits::max(); for (uint32_t i = 0; i < num_elements_float32_array; i++) { EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet( - thread, handle_tag_val_float32_array, JSTaggedValue(i), + thread_, handle_tag_val_float32_array, JSTaggedValue(i), JSHandle( - thread, JSTaggedValue(float_max_value - (i * (float_max_value / num_elements_float32_array)))))); + thread_, JSTaggedValue(float_max_value - (i * (float_max_value / num_elements_float32_array)))))); OperationResult op_result = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_float32_array, JSTaggedValue(i)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_float32_array, JSTaggedValue(i)); c_vec_op_result.push_back(op_result); } for (uint32_t i = 0; i < num_elements_float32_array; i++) { @@ -1124,30 +1124,30 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Float32Array) c_vec_op_result.clear(); OperationResult op_result1 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_float32_array, JSTaggedValue(-1)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_float32_array, JSTaggedValue(-1)); OperationResult op_result2 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_float32_array, JSTaggedValue(-0.0)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_float32_array, JSTaggedValue(-0.0)); OperationResult op_result3 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_float32_array, JSTaggedValue(1.1)); - OperationResult op_result4 = JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_float32_array, + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_float32_array, JSTaggedValue(1.1)); + OperationResult op_result4 = JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_float32_array, JSTaggedValue(num_elements_float32_array)); EXPECT_EQ(op_result1.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result2.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result3.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result4.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); - EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_float32_array, JSTaggedValue(-1), - JSHandle(thread, JSTaggedValue(0)))); - EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_float32_array, + EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_float32_array, JSTaggedValue(-1), + JSHandle(thread_, JSTaggedValue(0)))); + EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_float32_array, JSTaggedValue(num_elements_float32_array), - JSHandle(thread, JSTaggedValue(0)))); + JSHandle(thread_, JSTaggedValue(0)))); } TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Float64Array) { uint32_t num_elements_float64_array = 100; - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle handle_float64_array = CreateNumberTypedArray(thread, JSType::JS_FLOAT64_ARRAY); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle handle_float64_array = CreateNumberTypedArray(thread_, JSType::JS_FLOAT64_ARRAY); JSHandle handle_tag_val_float64_array = JSHandle::Cast(handle_float64_array); uint32_t size_element = @@ -1155,18 +1155,18 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Float64Array) uint32_t byte_length_viewd_array_buffer = size_element * num_elements_float64_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_float64_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_float64_array->SetArrayLength(thread, JSTaggedValue(num_elements_float64_array)); + handle_float64_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_float64_array->SetArrayLength(thread_, JSTaggedValue(num_elements_float64_array)); PandaVector c_vec_op_result = {}; double double_max_value = std::numeric_limits::max(); for (uint32_t i = 0; i < num_elements_float64_array; i++) { EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet( - thread, handle_tag_val_float64_array, JSTaggedValue(i), + thread_, handle_tag_val_float64_array, JSTaggedValue(i), JSHandle( - thread, JSTaggedValue(double_max_value - (i * (double_max_value / num_elements_float64_array)))))); + thread_, JSTaggedValue(double_max_value - (i * (double_max_value / num_elements_float64_array)))))); OperationResult op_result = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_float64_array, JSTaggedValue(i)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_float64_array, JSTaggedValue(i)); c_vec_op_result.push_back(op_result); } for (uint32_t i = 0; i < num_elements_float64_array; i++) { @@ -1176,23 +1176,23 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Float64Array) c_vec_op_result.clear(); OperationResult op_result1 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_float64_array, JSTaggedValue(-1)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_float64_array, JSTaggedValue(-1)); OperationResult op_result2 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_float64_array, JSTaggedValue(-0.0)); + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_float64_array, JSTaggedValue(-0.0)); OperationResult op_result3 = - JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_float64_array, JSTaggedValue(1.1)); - OperationResult op_result4 = JSTypedArray::IntegerIndexedElementGet(thread, handle_tag_val_float64_array, + JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_float64_array, JSTaggedValue(1.1)); + OperationResult op_result4 = JSTypedArray::IntegerIndexedElementGet(thread_, handle_tag_val_float64_array, JSTaggedValue(num_elements_float64_array)); EXPECT_EQ(op_result1.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result2.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result3.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result4.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); - EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_float64_array, JSTaggedValue(-1), - JSHandle(thread, JSTaggedValue(0)))); - EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_float64_array, + EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_float64_array, JSTaggedValue(-1), + JSHandle(thread_, JSTaggedValue(0)))); + EXPECT_FALSE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_float64_array, JSTaggedValue(num_elements_float64_array), - JSHandle(thread, JSTaggedValue(0)))); + JSHandle(thread_, JSTaggedValue(0)))); } /* @@ -1205,11 +1205,11 @@ TEST_F(JSTypedArrayTest, IntegerIndexedElementSet_Float64Array) */ TEST_F(JSTypedArrayTest, FastElementGet_TypedArray) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); for (uint32_t j = 0; j < c_vec_js_type_.size(); j++) { uint32_t num_elements_typed_array = 10; - JSHandle handle_typed_array = CreateNumberTypedArray(thread, c_vec_js_type_.at(j)); + JSHandle handle_typed_array = CreateNumberTypedArray(thread_, c_vec_js_type_.at(j)); JSHandle handle_tag_val_typed_array = JSHandle::Cast(handle_typed_array); uint32_t size_element = @@ -1217,24 +1217,24 @@ TEST_F(JSTypedArrayTest, FastElementGet_TypedArray) uint32_t byte_length_viewd_array_buffer = size_element * num_elements_typed_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_typed_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_typed_array->SetArrayLength(thread, JSTaggedValue(num_elements_typed_array)); + handle_typed_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_typed_array->SetArrayLength(thread_, JSTaggedValue(num_elements_typed_array)); JSHandle handle_tag_val_value_set( - thread, JSTaggedValue(c_vec_handle_tag_val_value_for_typed_array_.at(j))); + thread_, JSTaggedValue(c_vec_handle_tag_val_value_for_typed_array_.at(j))); for (uint32_t i = 0; i < num_elements_typed_array; i++) { - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_typed_array, JSTaggedValue(i), + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_typed_array, JSTaggedValue(i), handle_tag_val_value_set)); } for (uint32_t i = 0; i < num_elements_typed_array; i++) { - OperationResult op_result = JSTypedArray::FastElementGet(thread, handle_tag_val_typed_array, i); + OperationResult op_result = JSTypedArray::FastElementGet(thread_, handle_tag_val_typed_array, i); EXPECT_EQ(op_result.GetValue().GetTaggedValue().GetNumber(), handle_tag_val_value_set.GetTaggedValue().GetNumber()); } - OperationResult op_result1 = JSTypedArray::FastElementGet(thread, handle_tag_val_typed_array, -1); + OperationResult op_result1 = JSTypedArray::FastElementGet(thread_, handle_tag_val_typed_array, -1); OperationResult op_result2 = - JSTypedArray::FastElementGet(thread, handle_tag_val_typed_array, num_elements_typed_array); + JSTypedArray::FastElementGet(thread_, handle_tag_val_typed_array, num_elements_typed_array); EXPECT_EQ(op_result1.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); EXPECT_EQ(op_result2.GetValue().GetTaggedValue(), JSTaggedValue::Undefined()); } @@ -1253,13 +1253,13 @@ TEST_F(JSTypedArrayTest, FastElementGet_TypedArray) */ TEST_F(JSTypedArrayTest, DefineOwnProperty_TypedArray) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); for (size_t j = 0; j < c_vec_js_type_.size(); j++) { int32_t num_elements_typed_array = 10; - JSHandle handle_tag_val_value_def(thread, c_vec_handle_tag_val_value_for_typed_array_.at(j)); - PropertyDescriptor desc_from1(thread, handle_tag_val_value_def, true, true, true); - JSHandle handle_typed_array = CreateNumberTypedArray(thread, c_vec_js_type_.at(j)); + JSHandle handle_tag_val_value_def(thread_, c_vec_handle_tag_val_value_for_typed_array_.at(j)); + PropertyDescriptor desc_from1(thread_, handle_tag_val_value_def, true, true, true); + JSHandle handle_typed_array = CreateNumberTypedArray(thread_, c_vec_js_type_.at(j)); JSHandle handle_tag_val_typed_array = JSHandle::Cast(handle_typed_array); uint32_t size_element = @@ -1267,25 +1267,26 @@ TEST_F(JSTypedArrayTest, DefineOwnProperty_TypedArray) int32_t byte_length_viewd_array_buffer = size_element * num_elements_typed_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_typed_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_typed_array->SetArrayLength(thread, JSTaggedValue(num_elements_typed_array)); + handle_typed_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_typed_array->SetArrayLength(thread_, JSTaggedValue(num_elements_typed_array)); for (int32_t i = 0; i < num_elements_typed_array; i++) { - JSHandle handle_tag_val_key(thread, JSTaggedValue(i)); - EXPECT_FALSE(JSTypedArray::HasProperty(thread, handle_tag_val_typed_array, handle_tag_val_key)); + JSHandle handle_tag_val_key(thread_, JSTaggedValue(i)); + EXPECT_FALSE(JSTypedArray::HasProperty(thread_, handle_tag_val_typed_array, handle_tag_val_key)); EXPECT_TRUE( - JSTypedArray::DefineOwnProperty(thread, handle_tag_val_typed_array, handle_tag_val_key, desc_from1)); - EXPECT_TRUE(JSTypedArray::HasProperty(thread, handle_tag_val_typed_array, handle_tag_val_key)); + JSTypedArray::DefineOwnProperty(thread_, handle_tag_val_typed_array, handle_tag_val_key, desc_from1)); + EXPECT_TRUE(JSTypedArray::HasProperty(thread_, handle_tag_val_typed_array, handle_tag_val_key)); EXPECT_TRUE(JSTaggedValue::StrictEqual( - thread, handle_tag_val_value_def, - JSTypedArray::GetProperty(thread, handle_tag_val_typed_array, handle_tag_val_key).GetValue())); + thread_, handle_tag_val_value_def, + JSTypedArray::GetProperty(thread_, handle_tag_val_typed_array, handle_tag_val_key).GetValue())); - PropertyDescriptor desc_to1(thread); + PropertyDescriptor desc_to1(thread_); EXPECT_FALSE(desc_to1.HasWritable() || desc_to1.HasEnumerable() || desc_to1.HasConfigurable()); - EXPECT_TRUE(JSTypedArray::GetOwnProperty(thread, handle_tag_val_typed_array, handle_tag_val_key, desc_to1)); + EXPECT_TRUE( + JSTypedArray::GetOwnProperty(thread_, handle_tag_val_typed_array, handle_tag_val_key, desc_to1)); EXPECT_TRUE(desc_to1.HasWritable() && desc_to1.HasEnumerable() && desc_to1.HasConfigurable()); EXPECT_TRUE(desc_to1.IsWritable() && desc_to1.IsEnumerable() && desc_to1.IsConfigurable()); - EXPECT_TRUE(JSTaggedValue::StrictEqual(thread, desc_to1.GetValue(), handle_tag_val_value_def)); + EXPECT_TRUE(JSTaggedValue::StrictEqual(thread_, desc_to1.GetValue(), handle_tag_val_value_def)); } } } @@ -1303,12 +1304,12 @@ TEST_F(JSTypedArrayTest, DefineOwnProperty_TypedArray) */ TEST_F(JSTypedArrayTest, SetProperty_TypedArray) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); for (size_t j = 0; j < c_vec_js_type_.size(); j++) { int32_t num_elements_typed_array = 10; - JSHandle handle_tag_val_value_set(thread, c_vec_handle_tag_val_value_for_typed_array_.at(j)); - JSHandle handle_typed_array = CreateNumberTypedArray(thread, c_vec_js_type_.at(j)); + JSHandle handle_tag_val_value_set(thread_, c_vec_handle_tag_val_value_for_typed_array_.at(j)); + JSHandle handle_typed_array = CreateNumberTypedArray(thread_, c_vec_js_type_.at(j)); JSHandle handle_tag_val_typed_array = JSHandle::Cast(handle_typed_array); uint32_t size_element = @@ -1316,18 +1317,18 @@ TEST_F(JSTypedArrayTest, SetProperty_TypedArray) int32_t byte_length_viewd_array_buffer = size_element * num_elements_typed_array; JSHandle handle_tag_val_array_buffer_from = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); - handle_typed_array->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer_from); - handle_typed_array->SetArrayLength(thread, JSTaggedValue(num_elements_typed_array)); + handle_typed_array->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer_from); + handle_typed_array->SetArrayLength(thread_, JSTaggedValue(num_elements_typed_array)); for (int32_t i = 0; i < num_elements_typed_array; i++) { - JSHandle handle_tag_val_key(thread, JSTaggedValue(i)); - EXPECT_FALSE(JSTypedArray::HasProperty(thread, handle_tag_val_typed_array, handle_tag_val_key)); - EXPECT_TRUE(JSTypedArray::SetProperty(thread, handle_tag_val_typed_array, handle_tag_val_key, + JSHandle handle_tag_val_key(thread_, JSTaggedValue(i)); + EXPECT_FALSE(JSTypedArray::HasProperty(thread_, handle_tag_val_typed_array, handle_tag_val_key)); + EXPECT_TRUE(JSTypedArray::SetProperty(thread_, handle_tag_val_typed_array, handle_tag_val_key, handle_tag_val_value_set)); - EXPECT_TRUE(JSTypedArray::HasProperty(thread, handle_tag_val_typed_array, handle_tag_val_key)); + EXPECT_TRUE(JSTypedArray::HasProperty(thread_, handle_tag_val_typed_array, handle_tag_val_key)); EXPECT_TRUE(JSTaggedValue::StrictEqual( - thread, handle_tag_val_value_set, - JSTypedArray::GetProperty(thread, handle_tag_val_typed_array, handle_tag_val_key).GetValue())); + thread_, handle_tag_val_value_set, + JSTypedArray::GetProperty(thread_, handle_tag_val_typed_array, handle_tag_val_key).GetValue())); } } } @@ -1345,12 +1346,12 @@ TEST_F(JSTypedArrayTest, SetProperty_TypedArray) */ TEST_F(JSTypedArrayTest, FastCopyElementToArray_TypedArray) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); for (size_t j = 0; j < c_vec_js_type_.size(); j++) { int32_t num_elements_typed_array = 10; - JSHandle handle_tag_val_value_set(thread, c_vec_handle_tag_val_value_for_typed_array_.at(j)); - JSHandle handle_typed_array_from = CreateNumberTypedArray(thread, c_vec_js_type_.at(j)); + JSHandle handle_tag_val_value_set(thread_, c_vec_handle_tag_val_value_for_typed_array_.at(j)); + JSHandle handle_typed_array_from = CreateNumberTypedArray(thread_, c_vec_js_type_.at(j)); JSHandle handle_tag_val_typed_array_from = JSHandle::Cast(handle_typed_array_from); @@ -1360,14 +1361,14 @@ TEST_F(JSTypedArrayTest, FastCopyElementToArray_TypedArray) JSHandle handle_tag_val_array_buffer = JSHandle::Cast(factory->NewJSArrayBuffer(byte_length_viewd_array_buffer)); JSHandle handle_tag_arr_to = factory->NewTaggedArray(byte_length_viewd_array_buffer); - handle_typed_array_from->SetViewedArrayBuffer(thread, handle_tag_val_array_buffer); - handle_typed_array_from->SetArrayLength(thread, JSTaggedValue(num_elements_typed_array)); + handle_typed_array_from->SetViewedArrayBuffer(thread_, handle_tag_val_array_buffer); + handle_typed_array_from->SetArrayLength(thread_, JSTaggedValue(num_elements_typed_array)); for (int32_t i = 0; i < num_elements_typed_array; i++) { - EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread, handle_tag_val_typed_array_from, + EXPECT_TRUE(JSTypedArray::IntegerIndexedElementSet(thread_, handle_tag_val_typed_array_from, JSTaggedValue(i), handle_tag_val_value_set)); } - EXPECT_TRUE(JSTypedArray::FastCopyElementToArray(thread, handle_tag_val_typed_array_from, handle_tag_arr_to)); + EXPECT_TRUE(JSTypedArray::FastCopyElementToArray(thread_, handle_tag_val_typed_array_from, handle_tag_arr_to)); for (int32_t i = 0; i < num_elements_typed_array; i++) { EXPECT_EQ(handle_tag_arr_to->Get(i), handle_tag_val_value_set.GetTaggedValue()); } diff --git a/tests/runtime/common/large_object_test.cpp b/tests/runtime/common/large_object_test.cpp index 9090634da..4cb56d1a2 100644 --- a/tests/runtime/common/large_object_test.cpp +++ b/tests/runtime/common/large_object_test.cpp @@ -33,22 +33,22 @@ class LargeObjectTest : public testing::Test { public: void SetUp() override { - TestHelper::CreateEcmaVMWithScope(instance, thread, scope); - thread->GetEcmaVM()->GetFactory()->SetTriggerGc(false); + TestHelper::CreateEcmaVMWithScope(instance_, thread_, scope_); + thread_->GetEcmaVM()->GetFactory()->SetTriggerGc(false); } void TearDown() override { - TestHelper::DestroyEcmaVMWithScope(instance, scope); + TestHelper::DestroyEcmaVMWithScope(instance_, scope_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {}; + JSThread *thread_ {}; private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; #if !defined(NDEBUG) @@ -77,12 +77,12 @@ static TaggedArray *LargeArrayTestCreate(JSThread *thread) TEST_F(LargeObjectTest, LargeArrayKeep) { #if !defined(NDEBUG) - TaggedArray *array = LargeArrayTestCreate(thread); + TaggedArray *array = LargeArrayTestCreate(thread_); EXPECT_TRUE(array != nullptr); - JSHandle array_handle(thread, array); - JSHandle new_obj(thread, JSObjectTestCreate(thread)); - array_handle->Set(thread, 0, new_obj.GetTaggedValue()); - auto ecma_vm = thread->GetEcmaVM(); + JSHandle array_handle(thread_, array); + JSHandle new_obj(thread_, JSObjectTestCreate(thread_)); + array_handle->Set(thread_, 0, new_obj.GetTaggedValue()); + auto ecma_vm = thread_->GetEcmaVM(); EXPECT_EQ(*array_handle, reinterpret_cast(array)); ecma_vm->GetGC()->WaitForGCInManaged(GCTask(GCTaskCause::EXPLICIT_CAUSE)); // Trigger GC. ecma_vm->GetGC()->WaitForGCInManaged(GCTask(GCTaskCause::EXPLICIT_CAUSE)); // Trigger GC. diff --git a/tests/runtime/common/lexical_env_test.cpp b/tests/runtime/common/lexical_env_test.cpp index 5168ab0c0..c1da36fc3 100644 --- a/tests/runtime/common/lexical_env_test.cpp +++ b/tests/runtime/common/lexical_env_test.cpp @@ -27,26 +27,26 @@ class LexicalEnvTest : 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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {}; + JSThread *thread_ {}; private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; TEST_F(LexicalEnvTest, LexicalEnv_Create) { - JSHandle lexical_env = thread->GetEcmaVM()->GetFactory()->NewLexicalEnv(0); + JSHandle lexical_env = thread_->GetEcmaVM()->GetFactory()->NewLexicalEnv(0); EXPECT_TRUE(lexical_env.GetTaggedValue().IsObject()); } } // namespace panda::test diff --git a/tests/runtime/common/linked_hash_table_test.cpp b/tests/runtime/common/linked_hash_table_test.cpp index fe97a400c..b086250b3 100644 --- a/tests/runtime/common/linked_hash_table_test.cpp +++ b/tests/runtime/common/linked_hash_table_test.cpp @@ -44,49 +44,49 @@ 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_); } JSHandle GetGlobalEnv() { - EcmaVM *ecma = thread->GetEcmaVM(); + EcmaVM *ecma = thread_->GetEcmaVM(); return ecma->GetGlobalEnv(); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {nullptr}; + JSThread *thread_ {nullptr}; private: - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; TEST_F(LinkedHashTableTest, MapCreate) { int num_of_element = 64; - JSHandle dict = LinkedHashMap::Create(thread, num_of_element); + JSHandle dict = LinkedHashMap::Create(thread_, num_of_element); EXPECT_TRUE(*dict != nullptr); } TEST_F(LinkedHashTableTest, SetCreate) { int num_of_element = 64; - JSHandle set = LinkedHashSet::Create(thread, num_of_element); + JSHandle set = LinkedHashSet::Create(thread_, num_of_element); EXPECT_TRUE(*set != nullptr); } TEST_F(LinkedHashTableTest, addKeyAndValue) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // mock object needed in test int num_of_element = 64; - JSHandle dict_handle = LinkedHashMap::Create(thread, num_of_element); + JSHandle dict_handle = LinkedHashMap::Create(thread_, num_of_element); EXPECT_TRUE(*dict_handle != nullptr); JSHandle obj_fun = GetGlobalEnv()->GetObjectFunction(); @@ -101,7 +101,7 @@ TEST_F(LinkedHashTableTest, addKeyAndValue) JSHandle value2(factory->NewJSObjectByConstructor(JSHandle(obj_fun), obj_fun)); // test set() - dict_handle = LinkedHashMap::Set(thread, dict_handle, key1, value1); + dict_handle = LinkedHashMap::Set(thread_, dict_handle, key1, value1); EXPECT_EQ(dict_handle->NumberOfElements(), 1); // test find() @@ -110,15 +110,15 @@ TEST_F(LinkedHashTableTest, addKeyAndValue) EXPECT_EQ(key1.GetTaggedValue(), dict_handle->GetKey(entry1)); EXPECT_EQ(value1.GetTaggedValue(), dict_handle->GetValue(entry1)); - dict_handle = LinkedHashMap::Set(thread, dict_handle, key2, value2); + dict_handle = LinkedHashMap::Set(thread_, dict_handle, key2, value2); EXPECT_EQ(dict_handle->NumberOfElements(), 2); // test remove() - dict_handle = LinkedHashMap::Delete(thread, dict_handle, key1); + dict_handle = LinkedHashMap::Delete(thread_, dict_handle, key1); EXPECT_EQ(-1, dict_handle->FindElement(key1.GetTaggedValue(), hash)); EXPECT_EQ(dict_handle->NumberOfElements(), 1); - JSHandle undefined_key(thread, JSTaggedValue::Undefined()); - dict_handle = LinkedHashMap::Set(thread, dict_handle, undefined_key, value1); + JSHandle undefined_key(thread_, JSTaggedValue::Undefined()); + dict_handle = LinkedHashMap::Set(thread_, dict_handle, undefined_key, value1); int undefined_hash = LinkedHash::Hash(undefined_key.GetTaggedValue()); int entry2 = dict_handle->FindElement(undefined_key.GetTaggedValue(), undefined_hash); EXPECT_EQ(value1.GetTaggedValue(), dict_handle->GetValue(entry2)); @@ -126,10 +126,10 @@ TEST_F(LinkedHashTableTest, addKeyAndValue) TEST_F(LinkedHashTableTest, SetaddKeyAndValue) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // mock object needed in test int num_of_element = 64; - JSHandle set_handle = LinkedHashSet::Create(thread, num_of_element); + JSHandle set_handle = LinkedHashSet::Create(thread_, num_of_element); EXPECT_TRUE(*set_handle != nullptr); JSHandle obj_fun = GetGlobalEnv()->GetObjectFunction(); @@ -144,31 +144,31 @@ TEST_F(LinkedHashTableTest, SetaddKeyAndValue) JSHandle value2(factory->NewJSObjectByConstructor(JSHandle(obj_fun), obj_fun)); // test set() - set_handle = LinkedHashSet::Add(thread, set_handle, key1); + set_handle = LinkedHashSet::Add(thread_, set_handle, key1); EXPECT_EQ(set_handle->NumberOfElements(), 1); // test has() int hash = LinkedHash::Hash(key1.GetTaggedValue()); EXPECT_TRUE(set_handle->Has(key1.GetTaggedValue(), hash)); - set_handle = LinkedHashSet::Add(thread, set_handle, key2); + set_handle = LinkedHashSet::Add(thread_, set_handle, key2); EXPECT_EQ(set_handle->NumberOfElements(), 2); // test remove() - set_handle = LinkedHashSet::Delete(thread, set_handle, key1); + set_handle = LinkedHashSet::Delete(thread_, set_handle, key1); EXPECT_EQ(-1, set_handle->FindElement(key1.GetTaggedValue(), hash)); EXPECT_EQ(set_handle->NumberOfElements(), 1); - JSHandle undefined_key(thread, JSTaggedValue::Undefined()); - set_handle = LinkedHashSet::Add(thread, set_handle, undefined_key); + JSHandle undefined_key(thread_, JSTaggedValue::Undefined()); + set_handle = LinkedHashSet::Add(thread_, set_handle, undefined_key); int undefined_hash = LinkedHash::Hash(undefined_key.GetTaggedValue()); EXPECT_TRUE(set_handle->Has(undefined_key.GetTaggedValue(), undefined_hash)); } TEST_F(LinkedHashTableTest, GrowCapacity) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); int num_of_element = 8; - JSHandle dict_handle = LinkedHashMap::Create(thread, num_of_element); + JSHandle dict_handle = LinkedHashMap::Create(thread_, num_of_element); EXPECT_TRUE(*dict_handle != nullptr); JSHandle obj_fun(GetGlobalEnv()->GetObjectFunction()); char key_array[7] = "hello"; @@ -176,10 +176,10 @@ TEST_F(LinkedHashTableTest, GrowCapacity) key_array[5] = '1' + i; key_array[6] = 0; JSHandle key(factory->NewFromCanBeCompressString(key_array)); - JSHandle value(thread, JSTaggedValue(i)); + JSHandle value(thread_, JSTaggedValue(i)); // test insert() - dict_handle = LinkedHashMap::Set(thread, dict_handle, key, value); + dict_handle = LinkedHashMap::Set(thread_, dict_handle, key, value); int hash = LinkedHash::Hash(key.GetTaggedValue()); EXPECT_EQ(i, dict_handle->FindElement(key.GetTaggedValue(), hash)); } @@ -199,9 +199,9 @@ TEST_F(LinkedHashTableTest, GrowCapacity) TEST_F(LinkedHashTableTest, SetGrowCapacity) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); int num_of_element = 8; - JSHandle set_handle = LinkedHashSet::Create(thread, num_of_element); + JSHandle set_handle = LinkedHashSet::Create(thread_, num_of_element); EXPECT_TRUE(*set_handle != nullptr); JSHandle obj_fun(GetGlobalEnv()->GetObjectFunction()); // create key and values @@ -213,7 +213,7 @@ TEST_F(LinkedHashTableTest, SetGrowCapacity) JSHandle key(string_key); // test insert() - set_handle = LinkedHashSet::Add(thread, set_handle, key); + set_handle = LinkedHashSet::Add(thread_, set_handle, key); int hash = LinkedHash::Hash(key.GetTaggedValue()); EXPECT_EQ(i, set_handle->FindElement(key.GetTaggedValue(), hash)); } @@ -233,9 +233,9 @@ TEST_F(LinkedHashTableTest, SetGrowCapacity) TEST_F(LinkedHashTableTest, ShrinkCapacity) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); int num_of_element = 64; - JSHandle dict_handle = LinkedHashMap::Create(thread, num_of_element); + JSHandle dict_handle = LinkedHashMap::Create(thread_, num_of_element); EXPECT_TRUE(*dict_handle != nullptr); JSHandle obj_fun(GetGlobalEnv()->GetObjectFunction()); char key_array[7] = "hello"; @@ -243,14 +243,14 @@ TEST_F(LinkedHashTableTest, ShrinkCapacity) key_array[5] = '1' + i; key_array[6] = 0; JSHandle key(factory->NewFromCanBeCompressString(key_array)); - JSHandle value(thread, JSTaggedValue(i)); + JSHandle value(thread_, JSTaggedValue(i)); // test insert() - dict_handle = LinkedHashMap::Set(thread, dict_handle, key, value); + dict_handle = LinkedHashMap::Set(thread_, dict_handle, key, value); } key_array[5] = '1' + 9; JSHandle key(factory->NewFromCanBeCompressString(key_array)); - dict_handle = LinkedHashMap::Delete(thread, dict_handle, key); + dict_handle = LinkedHashMap::Delete(thread_, dict_handle, key); // test order for (int i = 0; i < 9; i++) { key_array[5] = '1' + i; @@ -266,9 +266,9 @@ TEST_F(LinkedHashTableTest, ShrinkCapacity) TEST_F(LinkedHashTableTest, SetShrinkCapacity) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); int num_of_element = 64; - JSHandle set_handle = LinkedHashSet::Create(thread, num_of_element); + JSHandle set_handle = LinkedHashSet::Create(thread_, num_of_element); EXPECT_TRUE(*set_handle != nullptr); JSHandle obj_fun(GetGlobalEnv()->GetObjectFunction()); // create key and values @@ -279,11 +279,11 @@ TEST_F(LinkedHashTableTest, SetShrinkCapacity) JSHandle key(factory->NewFromCanBeCompressString(key_array)); // test insert() - set_handle = LinkedHashSet::Add(thread, set_handle, key); + set_handle = LinkedHashSet::Add(thread_, set_handle, key); } key_array[5] = '1' + 9; JSHandle key_handle(factory->NewFromCanBeCompressString(key_array)); - set_handle = LinkedHashSet::Delete(thread, set_handle, key_handle); + set_handle = LinkedHashSet::Delete(thread_, set_handle, key_handle); // test order for (int i = 0; i < 9; i++) { key_array[5] = '1' + i; diff --git a/tests/runtime/common/name_dictionary_test.cpp b/tests/runtime/common/name_dictionary_test.cpp index a2934db78..b96b96841 100644 --- a/tests/runtime/common/name_dictionary_test.cpp +++ b/tests/runtime/common/name_dictionary_test.cpp @@ -47,21 +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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {nullptr}; + JSThread *thread_ {nullptr}; private: - PandaVM *instance {nullptr}; - EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + EcmaHandleScope *scope_ {nullptr}; }; static JSHandle GetGlobalEnv(JSThread *thread) @@ -73,7 +73,7 @@ static JSHandle GetGlobalEnv(JSThread *thread) TEST_F(NameDictionaryTest, createDictionary) { int num_of_element = 64; - JSHandle dict = NameDictionary::Create(thread, num_of_element); + JSHandle dict = NameDictionary::Create(thread_, num_of_element); EXPECT_TRUE(*dict != nullptr); } @@ -81,34 +81,34 @@ TEST_F(NameDictionaryTest, addKeyAndValue) { // mock object needed in test int num_of_element = 64; - JSHandle dict_j_shandle(NameDictionary::Create(thread, num_of_element)); + JSHandle dict_j_shandle(NameDictionary::Create(thread_, num_of_element)); EXPECT_TRUE(*dict_j_shandle != nullptr); JSMutableHandle dict_handle(dict_j_shandle); - JSHandle obj_fun = GetGlobalEnv(thread)->GetObjectFunction(); + JSHandle obj_fun = GetGlobalEnv(thread_)->GetObjectFunction(); // create key and values JSHandle js_object = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_fun), obj_fun); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_fun), obj_fun); EXPECT_TRUE(*js_object != nullptr); char key_array[] = "hello"; - JSHandle string_key1 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(key_array); + JSHandle string_key1 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(key_array); JSHandle key1(string_key1); JSHandle taggedkey1(string_key1); JSHandle value1( - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_fun), obj_fun)); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_fun), obj_fun)); PropertyAttributes meta_data1; char key2_array[] = "hello2"; - JSHandle string_key2 = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(key2_array); + JSHandle string_key2 = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(key2_array); JSHandle key2(string_key2); JSHandle taggedkey2(string_key2); JSHandle value2( - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_fun), obj_fun)); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_fun), obj_fun)); PropertyAttributes meta_data2; // test insert() - JSHandle dict(NameDictionary::PutIfAbsent(thread, dict_handle, key1, value1, meta_data1)); + JSHandle dict(NameDictionary::PutIfAbsent(thread_, dict_handle, key1, value1, meta_data1)); dict_handle.Update(dict.GetTaggedValue()); EXPECT_EQ(dict->EntriesCount(), 1); @@ -117,10 +117,10 @@ TEST_F(NameDictionaryTest, addKeyAndValue) EXPECT_EQ(key1.GetTaggedValue(), JSTaggedValue(dict->GetKey(entry1).GetRawData())); EXPECT_EQ(value1.GetTaggedValue(), JSTaggedValue(dict->GetValue(entry1).GetRawData())); - JSHandle dict2(NameDictionary::PutIfAbsent(thread, dict_handle, key2, value2, meta_data2)); + JSHandle dict2(NameDictionary::PutIfAbsent(thread_, dict_handle, key2, value2, meta_data2)); EXPECT_EQ(dict2->EntriesCount(), 2); // test remove() - dict = NameDictionary::Remove(thread, dict_handle, entry1); + dict = NameDictionary::Remove(thread_, dict_handle, entry1); EXPECT_EQ(-1, dict->FindEntry(key1.GetTaggedValue())); EXPECT_EQ(dict->EntriesCount(), 1); } @@ -128,12 +128,12 @@ TEST_F(NameDictionaryTest, addKeyAndValue) TEST_F(NameDictionaryTest, GrowCapacity) { int num_of_element = 8; - JSHandle dict_handle(NameDictionary::Create(thread, num_of_element)); + JSHandle dict_handle(NameDictionary::Create(thread_, num_of_element)); EXPECT_TRUE(*dict_handle != nullptr); - JSHandle obj_fun = GetGlobalEnv(thread)->GetObjectFunction(); + JSHandle obj_fun = GetGlobalEnv(thread_)->GetObjectFunction(); // create key and values JSHandle js_object = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_fun), obj_fun); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_fun), obj_fun); EXPECT_TRUE(*js_object != nullptr); char key_array[7] = "hello"; for (int i = 0; i < 9; i++) { @@ -141,15 +141,15 @@ TEST_F(NameDictionaryTest, GrowCapacity) key_array[5] = '1' + i; key_array[6] = 0; - JSHandle string_key = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(key_array); + JSHandle string_key = thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(key_array); ecmascript::JSHandle key(string_key); JSHandle key_handle(key); - ecmascript::JSHandle value(thread, JSTaggedValue(i)); + ecmascript::JSHandle value(thread_, JSTaggedValue(i)); JSHandle value_handle(value); PropertyAttributes meta_data; // test insert() - dict_handle = NameDictionary::PutIfAbsent(thread, temp_handle, key_handle, value_handle, meta_data); + dict_handle = NameDictionary::PutIfAbsent(thread_, temp_handle, key_handle, value_handle, meta_data); } EXPECT_EQ(dict_handle->EntriesCount(), 9); EXPECT_EQ(dict_handle->Size(), 16); @@ -158,39 +158,39 @@ TEST_F(NameDictionaryTest, GrowCapacity) TEST_F(NameDictionaryTest, ShrinkCapacity) { int num_of_element = 64; - JSMutableHandle dict_handle(NameDictionary::Create(thread, num_of_element)); + JSMutableHandle dict_handle(NameDictionary::Create(thread_, num_of_element)); EXPECT_TRUE(*dict_handle != nullptr); - JSHandle obj_fun = GetGlobalEnv(thread)->GetObjectFunction(); + JSHandle obj_fun = GetGlobalEnv(thread_)->GetObjectFunction(); // create key and values JSHandle js_object = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_fun), obj_fun); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(obj_fun), obj_fun); EXPECT_TRUE(*js_object != nullptr); uint8_t key_array[7] = "hello"; - auto string_table = thread->GetEcmaVM()->GetEcmaStringTable(); + auto string_table = thread_->GetEcmaVM()->GetEcmaStringTable(); for (int i = 0; i < 10; i++) { key_array[5] = '0' + i; key_array[6] = 0; - JSHandle key(thread, + JSHandle key(thread_, string_table->GetOrInternString(key_array, utf::Mutf8Size(key_array), true)); - JSHandle value(thread, JSTaggedValue(i)); + JSHandle value(thread_, JSTaggedValue(i)); PropertyAttributes meta_data; // test insert() - JSHandle new_dict = NameDictionary::PutIfAbsent(thread, dict_handle, key, value, meta_data); + JSHandle new_dict = NameDictionary::PutIfAbsent(thread_, dict_handle, key, value, meta_data); dict_handle.Update(new_dict.GetTaggedValue()); } key_array[5] = '2'; key_array[6] = 0; - JSHandle array_handle(thread, + JSHandle array_handle(thread_, string_table->GetOrInternString(key_array, utf::Mutf8Size(key_array), true)); int entry = dict_handle->FindEntry(array_handle.GetTaggedValue()); EXPECT_NE(entry, -1); - JSHandle new_dict1 = NameDictionary::Remove(thread, dict_handle, entry); + JSHandle new_dict1 = NameDictionary::Remove(thread_, dict_handle, entry); dict_handle.Update(new_dict1.GetTaggedValue()); EXPECT_EQ(dict_handle->EntriesCount(), 9); EXPECT_EQ(dict_handle->Size(), 16); diff --git a/tests/runtime/common/native_pointer_test.cpp b/tests/runtime/common/native_pointer_test.cpp index 7c88cc13b..e009eaff9 100644 --- a/tests/runtime/common/native_pointer_test.cpp +++ b/tests/runtime/common/native_pointer_test.cpp @@ -42,21 +42,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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {nullptr}; + JSThread *thread_ {nullptr}; private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; TEST_F(NativePointerTest, Print) @@ -64,16 +64,16 @@ TEST_F(NativePointerTest, Print) // mock object needed in test // NOLINTNEXTLINE(modernize-avoid-c-arrays) char array[] = "Hello World!"; - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); JSHandle str = factory->NewFromCanBeCompressString(array); EXPECT_TRUE(*str != nullptr); JSHandle js_function = factory->NewJSFunction(env); EXPECT_TRUE(*js_function != nullptr); - JSMethod *target = thread->GetEcmaVM()->GetMethodForNativeFunction(nullptr); - js_function->SetCallTarget(thread, target); + JSMethod *target = thread_->GetEcmaVM()->GetMethodForNativeFunction(nullptr); + js_function->SetCallTarget(thread_, target); // run cpp methed 'Print' ASSERT_EQ(target, js_function->GetCallTarget()); diff --git a/tests/runtime/common/object_factory_test.cpp b/tests/runtime/common/object_factory_test.cpp index 0def03aa3..ad8342efa 100644 --- a/tests/runtime/common/object_factory_test.cpp +++ b/tests/runtime/common/object_factory_test.cpp @@ -45,21 +45,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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {nullptr}; + JSThread *thread_ {nullptr}; private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; JSHandle GetGlobal(JSThread *thread) @@ -69,48 +69,48 @@ JSHandle GetGlobal(JSThread *thread) TEST_F(ObjectFactoryTest, DISABLED_NewJSObjectByConstructor) // TODO(vpukhov) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle obj_fun = GetGlobal(thread)->GetObjectFunction(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle obj_fun = GetGlobal(thread_)->GetObjectFunction(); // check mem alloc JSHandle new_obj = factory->NewJSObjectByConstructor(JSHandle(obj_fun), obj_fun); - JSHandle new_obj_cls(thread, new_obj->GetJSHClass()); + JSHandle new_obj_cls(thread_, new_obj->GetJSHClass()); EXPECT_TRUE(*new_obj != nullptr); EXPECT_TRUE(*new_obj_cls != nullptr); // check feild - EXPECT_EQ(new_obj->GetProperties(), GetGlobal(thread)->GetEmptyArray().GetTaggedValue()); - EXPECT_EQ(new_obj->GetElements(), GetGlobal(thread)->GetEmptyArray().GetTaggedValue()); + EXPECT_EQ(new_obj->GetProperties(), GetGlobal(thread_)->GetEmptyArray().GetTaggedValue()); + EXPECT_EQ(new_obj->GetElements(), GetGlobal(thread_)->GetEmptyArray().GetTaggedValue()); EXPECT_TRUE(JSTaggedValue(*new_obj).IsECMAObject()); // check jshclass JSHClass *cls = *new_obj_cls; EXPECT_TRUE(cls->GetObjectSize() == JSObject::SIZE + JSHClass::DEFAULT_CAPACITY_OF_IN_OBJECTS * JSTaggedValue::TaggedTypeSize()); - EXPECT_TRUE(cls->GetPrototype() == GetGlobal(thread)->GetObjectFunctionPrototype().GetTaggedValue()); + EXPECT_TRUE(cls->GetPrototype() == GetGlobal(thread_)->GetObjectFunctionPrototype().GetTaggedValue()); EXPECT_TRUE(cls->GetObjectType() == JSType::JS_OBJECT); // check gc handle update auto *prototype = cls->GetPrototype().GetTaggedObject(); - thread->GetEcmaVM()->CollectGarbage(); + thread_->GetEcmaVM()->CollectGarbage(); // CompressGC not the same EXPECT_TRUE(prototype != new_obj_cls->GetPrototype().GetTaggedObject()); } TEST_F(ObjectFactoryTest, NewJSFunction) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); // check mem alloc JSHandle new_fun = factory->NewJSFunction(env); - JSHandle new_fun_cls(thread, new_fun->GetJSHClass()); + JSHandle new_fun_cls(thread_, new_fun->GetJSHClass()); EXPECT_TRUE(*new_fun != nullptr); EXPECT_TRUE(*new_fun_cls != nullptr); // check feild - EXPECT_EQ(new_fun->GetProperties(), GetGlobal(thread)->GetEmptyArray().GetTaggedValue()); - EXPECT_EQ(new_fun->GetElements(), GetGlobal(thread)->GetEmptyArray().GetTaggedValue()); + EXPECT_EQ(new_fun->GetProperties(), GetGlobal(thread_)->GetEmptyArray().GetTaggedValue()); + EXPECT_EQ(new_fun->GetElements(), GetGlobal(thread_)->GetEmptyArray().GetTaggedValue()); EXPECT_EQ(new_fun->GetProtoOrDynClass(), JSTaggedValue::Hole()); EXPECT_EQ(new_fun->GetHomeObject(), JSTaggedValue::Undefined()); EXPECT_TRUE(JSTaggedValue(*new_fun).IsJSFunction()); @@ -119,7 +119,7 @@ TEST_F(ObjectFactoryTest, NewJSFunction) JSHClass *cls = *new_fun_cls; EXPECT_TRUE(cls->GetObjectSize() == JSFunction::SIZE + JSHClass::DEFAULT_CAPACITY_OF_IN_OBJECTS * JSTaggedValue::TaggedTypeSize()); - EXPECT_TRUE(cls->GetPrototype() == GetGlobal(thread)->GetFunctionPrototype().GetTaggedValue()); + EXPECT_TRUE(cls->GetPrototype() == GetGlobal(thread_)->GetFunctionPrototype().GetTaggedValue()); EXPECT_TRUE(cls->GetObjectType() == JSType::JS_FUNCTION); EXPECT_TRUE(cls->IsCallable()); EXPECT_TRUE(cls->IsExtensible()); @@ -128,32 +128,32 @@ TEST_F(ObjectFactoryTest, NewJSFunction) TEST_F(ObjectFactoryTest, NewJSBoundFunction) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // test prepare - JSHandle fun_fun(GetGlobal(thread)->GetObjectFunction()); - JSHandle bound(thread, GetGlobal(thread)->GetObjectFunctionPrototype().GetTaggedValue()); - const JSHandle array(GetGlobal(thread)->GetEmptyArray()); + JSHandle fun_fun(GetGlobal(thread_)->GetObjectFunction()); + JSHandle bound(thread_, GetGlobal(thread_)->GetObjectFunctionPrototype().GetTaggedValue()); + const JSHandle array(GetGlobal(thread_)->GetEmptyArray()); // check mem alloc JSHandle target_func(fun_fun); JSHandle new_bound_fun = factory->NewJSBoundFunction(target_func, bound, array); - JSHandle new_bound_fun_cls(thread, new_bound_fun->GetJSHClass()); + JSHandle new_bound_fun_cls(thread_, new_bound_fun->GetJSHClass()); EXPECT_TRUE(*new_bound_fun != nullptr); EXPECT_TRUE(*new_bound_fun_cls != nullptr); } TEST_F(ObjectFactoryTest, NewJSPrimitiveRef) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // test prepare - JSHandle number_fun(GetGlobal(thread)->GetNumberFunction()); - JSHandle primitive(thread, JSTaggedValue(1)); + JSHandle number_fun(GetGlobal(thread_)->GetNumberFunction()); + JSHandle primitive(thread_, JSTaggedValue(1)); // check mem alloc JSHandle new_primitive = factory->NewJSPrimitiveRef(number_fun, primitive); - JSHandle new_primitive_cls(thread, new_primitive->GetJSHClass()); + JSHandle new_primitive_cls(thread_, new_primitive->GetJSHClass()); EXPECT_TRUE(*new_primitive != nullptr); EXPECT_TRUE(*new_primitive_cls != nullptr); @@ -162,22 +162,22 @@ TEST_F(ObjectFactoryTest, NewJSPrimitiveRef) TEST_F(ObjectFactoryTest, NewLexicalEnv) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // check mem alloc JSHandle new_lexical_env = factory->NewLexicalEnv(0); - JSHandle new_lexical_env_cls(thread, new_lexical_env->GetClass()); + JSHandle new_lexical_env_cls(thread_, new_lexical_env->GetClass()); EXPECT_TRUE(*new_lexical_env != nullptr); EXPECT_TRUE(*new_lexical_env_cls != nullptr); } TEST_F(ObjectFactoryTest, NewJSArray) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // check mem alloc JSHandle new_js_aarray = factory->NewJSArray(); - JSHandle new_js_array_cls(thread, new_js_aarray->GetJSHClass()); + JSHandle new_js_array_cls(thread_, new_js_aarray->GetJSHClass()); EXPECT_TRUE(*new_js_aarray != nullptr); EXPECT_TRUE(*new_js_array_cls != nullptr); } diff --git a/tests/runtime/common/symbol_table_test.cpp b/tests/runtime/common/symbol_table_test.cpp index d5b3a50cd..0855fbd70 100644 --- a/tests/runtime/common/symbol_table_test.cpp +++ b/tests/runtime/common/symbol_table_test.cpp @@ -39,21 +39,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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {nullptr}; + JSThread *thread_ {nullptr}; private: - ecmascript::EcmaHandleScope *scope {nullptr}; - PandaVM *instance {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; + PandaVM *instance_ {nullptr}; }; TEST_F(SymbolTableTest, GetKeyIndex) @@ -89,7 +89,7 @@ TEST_F(SymbolTableTest, GetEntrySize) */ TEST_F(SymbolTableTest, IsMatch) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle symbol_table_string = factory->NewFromCanBeCompressString("name"); JSTaggedValue symbol_table_other = symbol_table_string.GetTaggedValue(); @@ -114,7 +114,7 @@ TEST_F(SymbolTableTest, IsMatch) */ TEST_F(SymbolTableTest, Hash_Utf8) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // test obj is not string JSHandle js_ob_ject(factory->NewEmptyJSObject()); EXPECT_EQ(SymbolTable::Hash(js_ob_ject.GetTaggedValue()), JSSymbol::ComputeHash()); @@ -146,7 +146,7 @@ TEST_F(SymbolTableTest, Hash_Utf8) */ TEST_F(SymbolTableTest, Hash_Utf16) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // NOLINTNEXTLINE(modernize-avoid-c-arrays) uint16_t utf16_array_name1[] = {1, 2, 3}; @@ -178,7 +178,7 @@ TEST_F(SymbolTableTest, Create) bool flag = EcmaString::GetCompressedStringsEnabled(); EXPECT_EQ(flag, true); - JSHandle symbol_table = SymbolTable::Create(thread, number_of_elements); + JSHandle symbol_table = SymbolTable::Create(thread_, number_of_elements); EXPECT_TRUE(*symbol_table != nullptr); } @@ -192,30 +192,30 @@ TEST_F(SymbolTableTest, Create) */ TEST_F(SymbolTableTest, ContainsKey) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle symbol_table_string_key1 = factory->NewFromCanBeCompressString("key"); JSHandle symbol_table_string_key2 = factory->NewFromCanBeCompressString("key1"); JSHandle symbol_table_string_key3 = factory->NewFromCanBeCompressString("value"); int number_of_elements = 2; - JSHandle symbol_table = SymbolTable::Create(thread, number_of_elements); - EXPECT_EQ(symbol_table->ContainsKey(thread, symbol_table_string_key1.GetTaggedValue()), false); + JSHandle symbol_table = SymbolTable::Create(thread_, number_of_elements); + EXPECT_EQ(symbol_table->ContainsKey(thread_, symbol_table_string_key1.GetTaggedValue()), false); - symbol_table->SetKey(thread, 1, JSTaggedValue::Hole()); - EXPECT_EQ(symbol_table->ContainsKey(thread, symbol_table_string_key1.GetTaggedValue()), false); + symbol_table->SetKey(thread_, 1, JSTaggedValue::Hole()); + EXPECT_EQ(symbol_table->ContainsKey(thread_, symbol_table_string_key1.GetTaggedValue()), false); - symbol_table->SetKey(thread, 1, JSTaggedValue::Undefined()); - EXPECT_EQ(symbol_table->ContainsKey(thread, symbol_table_string_key1.GetTaggedValue()), false); + symbol_table->SetKey(thread_, 1, JSTaggedValue::Undefined()); + EXPECT_EQ(symbol_table->ContainsKey(thread_, symbol_table_string_key1.GetTaggedValue()), false); - symbol_table->SetKey(thread, 1, symbol_table_string_key1.GetTaggedValue()); - EXPECT_EQ(symbol_table->ContainsKey(thread, symbol_table_string_key1.GetTaggedValue()), true); + symbol_table->SetKey(thread_, 1, symbol_table_string_key1.GetTaggedValue()); + EXPECT_EQ(symbol_table->ContainsKey(thread_, symbol_table_string_key1.GetTaggedValue()), true); // the key value has numbers - symbol_table->SetKey(thread, 1, symbol_table_string_key2.GetTaggedValue()); - EXPECT_EQ(symbol_table->ContainsKey(thread, symbol_table_string_key2.GetTaggedValue()), false); + symbol_table->SetKey(thread_, 1, symbol_table_string_key2.GetTaggedValue()); + EXPECT_EQ(symbol_table->ContainsKey(thread_, symbol_table_string_key2.GetTaggedValue()), false); - symbol_table->SetKey(thread, 1, symbol_table_string_key3.GetTaggedValue()); - EXPECT_EQ(symbol_table->ContainsKey(thread, symbol_table_string_key3.GetTaggedValue()), true); + symbol_table->SetKey(thread_, 1, symbol_table_string_key3.GetTaggedValue()); + EXPECT_EQ(symbol_table->ContainsKey(thread_, symbol_table_string_key3.GetTaggedValue()), true); } /* @@ -228,19 +228,19 @@ TEST_F(SymbolTableTest, ContainsKey) */ TEST_F(SymbolTableTest, GetSymbol) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); int number_of_elements = 2; JSHandle symbol_table_string_key = factory->NewFromCanBeCompressString("key"); - JSHandle symbol_table = SymbolTable::Create(thread, number_of_elements); + JSHandle symbol_table = SymbolTable::Create(thread_, number_of_elements); - symbol_table->SetKey(thread, 1, symbol_table_string_key.GetTaggedValue()); + symbol_table->SetKey(thread_, 1, symbol_table_string_key.GetTaggedValue()); EXPECT_EQ(symbol_table->GetSymbol(symbol_table_string_key.GetTaggedValue()), JSTaggedValue::Undefined()); - symbol_table->SetValue(thread, 0, JSTaggedValue(1)); + symbol_table->SetValue(thread_, 0, JSTaggedValue(1)); EXPECT_EQ(symbol_table->GetSymbol(symbol_table_string_key.GetTaggedValue()), JSTaggedValue::Undefined()); - symbol_table->SetValue(thread, 1, JSTaggedValue(1)); + symbol_table->SetValue(thread_, 1, JSTaggedValue(1)); EXPECT_EQ(symbol_table->GetSymbol(symbol_table_string_key.GetTaggedValue()).GetInt(), 1); } @@ -256,27 +256,27 @@ TEST_F(SymbolTableTest, GetSymbol) */ TEST_F(SymbolTableTest, FindSymbol) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHandle symbol_table_string_key1(factory->NewFromCanBeCompressString("key")); JSHandle symbol_table_string_key2(factory->NewFromCanBeCompressString("key1")); int number_of_elements = 2; JSHandle handle_symbol = factory->NewJSSymbol(); - JSHandle symbol_table = SymbolTable::Create(thread, number_of_elements); + JSHandle symbol_table = SymbolTable::Create(thread_, number_of_elements); - JSTaggedValue result_value1 = symbol_table->FindSymbol(thread, handle_symbol.GetTaggedValue()); + JSTaggedValue result_value1 = symbol_table->FindSymbol(thread_, handle_symbol.GetTaggedValue()); EXPECT_EQ(JSTaggedValue::SameValue(result_value1, JSTaggedValue::Undefined()), true); - handle_symbol->SetDescription(thread, symbol_table_string_key1.GetTaggedValue()); - JSTaggedValue result_value2 = symbol_table->FindSymbol(thread, handle_symbol.GetTaggedValue()); + handle_symbol->SetDescription(thread_, symbol_table_string_key1.GetTaggedValue()); + JSTaggedValue result_value2 = symbol_table->FindSymbol(thread_, handle_symbol.GetTaggedValue()); EXPECT_EQ(JSTaggedValue::SameValue(result_value2, JSTaggedValue::Undefined()), true); - symbol_table->SetKey(thread, 1, symbol_table_string_key1.GetTaggedValue()); - JSTaggedValue result_value3 = symbol_table->FindSymbol(thread, handle_symbol.GetTaggedValue()); + symbol_table->SetKey(thread_, 1, symbol_table_string_key1.GetTaggedValue()); + JSTaggedValue result_value3 = symbol_table->FindSymbol(thread_, handle_symbol.GetTaggedValue()); EXPECT_EQ(result_value3.GetRawData() == symbol_table_string_key1.GetTaggedValue().GetRawData(), true); - symbol_table->SetKey(thread, 1, symbol_table_string_key2.GetTaggedValue()); - JSTaggedValue result_value4 = symbol_table->FindSymbol(thread, handle_symbol.GetTaggedValue()); + symbol_table->SetKey(thread_, 1, symbol_table_string_key2.GetTaggedValue()); + JSTaggedValue result_value4 = symbol_table->FindSymbol(thread_, handle_symbol.GetTaggedValue()); EXPECT_EQ(JSTaggedValue::SameValue(result_value4, JSTaggedValue::Undefined()), true); } } // namespace panda::test diff --git a/tests/runtime/common/tagged_value_test.cpp b/tests/runtime/common/tagged_value_test.cpp index 59d384abd..54c42d9dc 100644 --- a/tests/runtime/common/tagged_value_test.cpp +++ b/tests/runtime/common/tagged_value_test.cpp @@ -40,21 +40,21 @@ class JSTaggedValueTest : 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_); } protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {}; + JSThread *thread_ {}; private: - PandaVM *instance {nullptr}; - ecmascript::EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {nullptr}; + ecmascript::EcmaHandleScope *scope_ {nullptr}; }; TEST_F(JSTaggedValueTest, Double) @@ -131,31 +131,31 @@ TEST_F(JSTaggedValueTest, ToPrimitive) JSTaggedValue result; JSTaggedValue int_v(100); - result = JSTaggedValue::ToPrimitive(thread, JSHandle(thread, int_v)); + result = JSTaggedValue::ToPrimitive(thread_, JSHandle(thread_, int_v)); EXPECT_EQ(result.GetInt(), 100); JSTaggedValue double_v((double)100.0); - result = JSTaggedValue::ToPrimitive(thread, JSHandle(thread, double_v)); + result = JSTaggedValue::ToPrimitive(thread_, JSHandle(thread_, double_v)); EXPECT_EQ(result.GetDouble(), (double)100.0); JSTaggedValue undefined_v = JSTaggedValue::Undefined(); - result = JSTaggedValue::ToPrimitive(thread, JSHandle(thread, undefined_v)); + result = JSTaggedValue::ToPrimitive(thread_, JSHandle(thread_, undefined_v)); EXPECT_TRUE(result.IsUndefined()); JSTaggedValue hole_v = JSTaggedValue::Hole(); - result = JSTaggedValue::ToPrimitive(thread, JSHandle(thread, hole_v)); + result = JSTaggedValue::ToPrimitive(thread_, JSHandle(thread_, hole_v)); EXPECT_TRUE(result.IsHole()); JSTaggedValue null_v = JSTaggedValue::Null(); - result = JSTaggedValue::ToPrimitive(thread, JSHandle(thread, null_v)); + result = JSTaggedValue::ToPrimitive(thread_, JSHandle(thread_, null_v)); EXPECT_TRUE(result.IsNull()); JSTaggedValue false_v = JSTaggedValue::False(); - result = JSTaggedValue::ToPrimitive(thread, JSHandle(thread, false_v)); + result = JSTaggedValue::ToPrimitive(thread_, JSHandle(thread_, false_v)); EXPECT_TRUE(result.IsFalse()); JSTaggedValue true_v = JSTaggedValue::True(); - result = JSTaggedValue::ToPrimitive(thread, JSHandle(thread, true_v)); + result = JSTaggedValue::ToPrimitive(thread_, JSHandle(thread_, true_v)); EXPECT_TRUE(result.IsTrue()); } @@ -176,8 +176,8 @@ TEST_F(JSTaggedValueTest, ToBoolean) EXPECT_FALSE(JSTaggedValue::False().ToBoolean()); EXPECT_TRUE(JSTaggedValue::True().ToBoolean()); - EXPECT_FALSE(thread->GetEcmaVM()->GetFactory()->GetEmptyString().GetTaggedValue().ToBoolean()); - EXPECT_TRUE(thread->GetEcmaVM()->GetFactory()->NewFromString("test").GetTaggedValue().ToBoolean()); + EXPECT_FALSE(thread_->GetEcmaVM()->GetFactory()->GetEmptyString().GetTaggedValue().ToBoolean()); + EXPECT_TRUE(thread_->GetEcmaVM()->GetFactory()->NewFromString("test").GetTaggedValue().ToBoolean()); } TEST_F(JSTaggedValueTest, ToNumber) @@ -185,162 +185,162 @@ TEST_F(JSTaggedValueTest, ToNumber) JSTaggedNumber result; JSTaggedValue int_v(100); - result = JSTaggedValue::ToNumber(thread, JSHandle(thread, int_v)); + result = JSTaggedValue::ToNumber(thread_, JSHandle(thread_, int_v)); EXPECT_EQ(result.GetNumber(), 100); JSTaggedValue double_v((double)100.0); - result = JSTaggedValue::ToNumber(thread, JSHandle(thread, double_v)); + result = JSTaggedValue::ToNumber(thread_, JSHandle(thread_, double_v)); EXPECT_EQ(result.GetNumber(), (double)100.0); JSTaggedValue undefined_v = JSTaggedValue::Undefined(); - result = JSTaggedValue::ToNumber(thread, JSHandle(thread, undefined_v)); + result = JSTaggedValue::ToNumber(thread_, JSHandle(thread_, undefined_v)); EXPECT_TRUE(std::isnan(result.GetNumber())); JSTaggedValue hole_v = JSTaggedValue::Hole(); - result = JSTaggedValue::ToNumber(thread, JSHandle(thread, hole_v)); + result = JSTaggedValue::ToNumber(thread_, JSHandle(thread_, hole_v)); EXPECT_TRUE(std::isnan(result.GetNumber())); JSTaggedValue null_v = JSTaggedValue::Null(); - result = JSTaggedValue::ToNumber(thread, JSHandle(thread, null_v)); + result = JSTaggedValue::ToNumber(thread_, JSHandle(thread_, null_v)); EXPECT_EQ(result.GetNumber(), 0); JSTaggedValue false_v = JSTaggedValue::False(); - result = JSTaggedValue::ToNumber(thread, JSHandle(thread, false_v)); + result = JSTaggedValue::ToNumber(thread_, JSHandle(thread_, false_v)); EXPECT_EQ(result.GetNumber(), 0); JSTaggedValue true_v = JSTaggedValue::True(); - result = JSTaggedValue::ToNumber(thread, JSHandle(thread, true_v)); + result = JSTaggedValue::ToNumber(thread_, JSHandle(thread_, true_v)); EXPECT_EQ(result.GetNumber(), 1); - JSHandle string_v0(thread->GetEcmaVM()->GetFactory()->NewFromString(" 1234 ")); - result = JSTaggedValue::ToNumber(thread, string_v0); + JSHandle string_v0(thread_->GetEcmaVM()->GetFactory()->NewFromString(" 1234 ")); + result = JSTaggedValue::ToNumber(thread_, string_v0); EXPECT_EQ(result.GetNumber(), 1234); - JSHandle string_v1(thread->GetEcmaVM()->GetFactory()->NewFromString(" 0b1010 ")); - result = JSTaggedValue::ToNumber(thread, string_v1); + JSHandle string_v1(thread_->GetEcmaVM()->GetFactory()->NewFromString(" 0b1010 ")); + result = JSTaggedValue::ToNumber(thread_, string_v1); EXPECT_EQ(result.GetNumber(), 10); - JSHandle string_v2(thread->GetEcmaVM()->GetFactory()->NewFromString(" 0O11 ")); - result = JSTaggedValue::ToNumber(thread, string_v2); + JSHandle string_v2(thread_->GetEcmaVM()->GetFactory()->NewFromString(" 0O11 ")); + result = JSTaggedValue::ToNumber(thread_, string_v2); EXPECT_EQ(result.GetNumber(), 9); - JSHandle string_v3(thread->GetEcmaVM()->GetFactory()->NewFromString(" 0x2d ")); - result = JSTaggedValue::ToNumber(thread, string_v3); + JSHandle string_v3(thread_->GetEcmaVM()->GetFactory()->NewFromString(" 0x2d ")); + result = JSTaggedValue::ToNumber(thread_, string_v3); EXPECT_EQ(result.GetNumber(), 45); - JSHandle string_v4(thread->GetEcmaVM()->GetFactory()->NewFromString(" 0.000001 ")); - result = JSTaggedValue::ToNumber(thread, string_v4); + JSHandle string_v4(thread_->GetEcmaVM()->GetFactory()->NewFromString(" 0.000001 ")); + result = JSTaggedValue::ToNumber(thread_, string_v4); EXPECT_EQ(result.GetNumber(), 0.000001); - JSHandle string_v5(thread->GetEcmaVM()->GetFactory()->NewFromString(" 1.23 ")); - result = JSTaggedValue::ToNumber(thread, string_v5); + JSHandle string_v5(thread_->GetEcmaVM()->GetFactory()->NewFromString(" 1.23 ")); + result = JSTaggedValue::ToNumber(thread_, string_v5); EXPECT_EQ(result.GetNumber(), 1.23); - JSHandle string_v6(thread->GetEcmaVM()->GetFactory()->NewFromString(" -1.23e2 ")); - result = JSTaggedValue::ToNumber(thread, string_v6); + JSHandle string_v6(thread_->GetEcmaVM()->GetFactory()->NewFromString(" -1.23e2 ")); + result = JSTaggedValue::ToNumber(thread_, string_v6); EXPECT_EQ(result.GetNumber(), -123); - JSHandle string_v7(thread->GetEcmaVM()->GetFactory()->NewFromString(" -123e-2")); - result = JSTaggedValue::ToNumber(thread, string_v7); + JSHandle string_v7(thread_->GetEcmaVM()->GetFactory()->NewFromString(" -123e-2")); + result = JSTaggedValue::ToNumber(thread_, string_v7); EXPECT_EQ(result.GetNumber(), -1.23); - JSHandle string_v8(thread->GetEcmaVM()->GetFactory()->NewFromString(" Infinity ")); - result = JSTaggedValue::ToNumber(thread, string_v8); + JSHandle string_v8(thread_->GetEcmaVM()->GetFactory()->NewFromString(" Infinity ")); + result = JSTaggedValue::ToNumber(thread_, string_v8); EXPECT_TRUE(std::isinf(result.GetNumber())); - JSHandle string_v9(thread->GetEcmaVM()->GetFactory()->NewFromString("100e307")); - result = JSTaggedValue::ToNumber(thread, string_v9); + JSHandle string_v9(thread_->GetEcmaVM()->GetFactory()->NewFromString("100e307")); + result = JSTaggedValue::ToNumber(thread_, string_v9); EXPECT_TRUE(std::isinf(result.GetNumber())); - JSHandle string_v10(thread->GetEcmaVM()->GetFactory()->NewFromString(" .")); - result = JSTaggedValue::ToNumber(thread, string_v10); + JSHandle string_v10(thread_->GetEcmaVM()->GetFactory()->NewFromString(" .")); + result = JSTaggedValue::ToNumber(thread_, string_v10); EXPECT_TRUE(std::isnan(result.GetNumber())); - JSHandle string_v11(thread->GetEcmaVM()->GetFactory()->NewFromString("12e+")); - result = JSTaggedValue::ToNumber(thread, string_v11); + JSHandle string_v11(thread_->GetEcmaVM()->GetFactory()->NewFromString("12e+")); + result = JSTaggedValue::ToNumber(thread_, string_v11); EXPECT_TRUE(std::isnan(result.GetNumber())); - JSHandle string_v12(thread->GetEcmaVM()->GetFactory()->NewFromString(".e3")); - result = JSTaggedValue::ToNumber(thread, string_v12); + JSHandle string_v12(thread_->GetEcmaVM()->GetFactory()->NewFromString(".e3")); + result = JSTaggedValue::ToNumber(thread_, string_v12); EXPECT_TRUE(std::isnan(result.GetNumber())); - JSHandle string_v13(thread->GetEcmaVM()->GetFactory()->NewFromString("23eE")); - result = JSTaggedValue::ToNumber(thread, string_v13); + JSHandle string_v13(thread_->GetEcmaVM()->GetFactory()->NewFromString("23eE")); + result = JSTaggedValue::ToNumber(thread_, string_v13); EXPECT_TRUE(std::isnan(result.GetNumber())); - JSHandle string_v14(thread->GetEcmaVM()->GetFactory()->NewFromString("a")); - result = JSTaggedValue::ToNumber(thread, string_v14); + JSHandle string_v14(thread_->GetEcmaVM()->GetFactory()->NewFromString("a")); + result = JSTaggedValue::ToNumber(thread_, string_v14); EXPECT_TRUE(std::isnan(result.GetNumber())); - JSHandle string_v15(thread->GetEcmaVM()->GetFactory()->NewFromString("0o12e3")); - result = JSTaggedValue::ToNumber(thread, string_v15); + JSHandle string_v15(thread_->GetEcmaVM()->GetFactory()->NewFromString("0o12e3")); + result = JSTaggedValue::ToNumber(thread_, string_v15); EXPECT_TRUE(std::isnan(result.GetNumber())); - JSHandle string_v16(thread->GetEcmaVM()->GetFactory()->NewFromString("0x12.3")); - result = JSTaggedValue::ToNumber(thread, string_v16); + JSHandle string_v16(thread_->GetEcmaVM()->GetFactory()->NewFromString("0x12.3")); + result = JSTaggedValue::ToNumber(thread_, string_v16); EXPECT_TRUE(std::isnan(result.GetNumber())); - JSHandle string_v17(thread->GetEcmaVM()->GetFactory()->NewFromString(" 12.4.")); - result = JSTaggedValue::ToNumber(thread, string_v17); + JSHandle string_v17(thread_->GetEcmaVM()->GetFactory()->NewFromString(" 12.4.")); + result = JSTaggedValue::ToNumber(thread_, string_v17); EXPECT_TRUE(std::isnan(result.GetNumber())); - JSHandle string_v18(thread->GetEcmaVM()->GetFactory()->NewFromString("123test")); - result = JSTaggedValue::ToNumber(thread, string_v18); + JSHandle string_v18(thread_->GetEcmaVM()->GetFactory()->NewFromString("123test")); + result = JSTaggedValue::ToNumber(thread_, string_v18); EXPECT_TRUE(std::isnan(result.GetNumber())); - JSHandle string_v19(thread->GetEcmaVM()->GetFactory()->NewFromString("123test")); - result = JSTaggedValue::ToNumber(thread, string_v19); + JSHandle string_v19(thread_->GetEcmaVM()->GetFactory()->NewFromString("123test")); + result = JSTaggedValue::ToNumber(thread_, string_v19); EXPECT_TRUE(std::isnan(result.GetNumber())); - JSHandle string_v20(thread->GetEcmaVM()->GetFactory()->NewFromString(" 0b ")); - result = JSTaggedValue::ToNumber(thread, string_v20); + JSHandle string_v20(thread_->GetEcmaVM()->GetFactory()->NewFromString(" 0b ")); + result = JSTaggedValue::ToNumber(thread_, string_v20); EXPECT_TRUE(std::isnan(result.GetNumber())); - JSHandle string_v21(thread->GetEcmaVM()->GetFactory()->NewFromString(" 0b0000 ")); - result = JSTaggedValue::ToNumber(thread, string_v21); + JSHandle string_v21(thread_->GetEcmaVM()->GetFactory()->NewFromString(" 0b0000 ")); + result = JSTaggedValue::ToNumber(thread_, string_v21); EXPECT_EQ(result.GetNumber(), 0); - JSHandle string_v22(thread->GetEcmaVM()->GetFactory()->NewFromString(" 0o0000 ")); - result = JSTaggedValue::ToNumber(thread, string_v22); + JSHandle string_v22(thread_->GetEcmaVM()->GetFactory()->NewFromString(" 0o0000 ")); + result = JSTaggedValue::ToNumber(thread_, string_v22); EXPECT_EQ(result.GetNumber(), 0); - JSHandle string_v23(thread->GetEcmaVM()->GetFactory()->NewFromString(" 0X0000 ")); - result = JSTaggedValue::ToNumber(thread, string_v23); + JSHandle string_v23(thread_->GetEcmaVM()->GetFactory()->NewFromString(" 0X0000 ")); + result = JSTaggedValue::ToNumber(thread_, string_v23); EXPECT_EQ(result.GetNumber(), 0); - JSHandle string_v24(thread->GetEcmaVM()->GetFactory()->NewFromString(" 000.00000 ")); - result = JSTaggedValue::ToNumber(thread, string_v24); + JSHandle string_v24(thread_->GetEcmaVM()->GetFactory()->NewFromString(" 000.00000 ")); + result = JSTaggedValue::ToNumber(thread_, string_v24); EXPECT_EQ(result.GetNumber(), 0); - JSHandle string_v25(thread->GetEcmaVM()->GetFactory()->NewFromString("")); - result = JSTaggedValue::ToNumber(thread, string_v25); + JSHandle string_v25(thread_->GetEcmaVM()->GetFactory()->NewFromString("")); + result = JSTaggedValue::ToNumber(thread_, string_v25); EXPECT_EQ(result.GetNumber(), 0); - JSHandle string_v26(thread->GetEcmaVM()->GetFactory()->NewFromString(" ")); - result = JSTaggedValue::ToNumber(thread, string_v26); + JSHandle string_v26(thread_->GetEcmaVM()->GetFactory()->NewFromString(" ")); + result = JSTaggedValue::ToNumber(thread_, string_v26); EXPECT_EQ(result.GetNumber(), 0); - JSHandle string_v27(thread->GetEcmaVM()->GetFactory()->NewFromString("0")); - result = JSTaggedValue::ToNumber(thread, string_v27); + JSHandle string_v27(thread_->GetEcmaVM()->GetFactory()->NewFromString("0")); + result = JSTaggedValue::ToNumber(thread_, string_v27); EXPECT_EQ(result.GetNumber(), 0); - JSHandle string_v28(thread->GetEcmaVM()->GetFactory()->NewFromString(" 0 ")); - result = JSTaggedValue::ToNumber(thread, string_v28); + JSHandle string_v28(thread_->GetEcmaVM()->GetFactory()->NewFromString(" 0 ")); + result = JSTaggedValue::ToNumber(thread_, string_v28); EXPECT_EQ(result.GetNumber(), 0); - JSHandle string_v29(thread->GetEcmaVM()->GetFactory()->NewFromString("00000000")); - result = JSTaggedValue::ToNumber(thread, string_v29); + JSHandle string_v29(thread_->GetEcmaVM()->GetFactory()->NewFromString("00000000")); + result = JSTaggedValue::ToNumber(thread_, string_v29); EXPECT_EQ(result.GetNumber(), 0); - JSHandle string_v30(thread->GetEcmaVM()->GetFactory()->NewFromString(" 00000000 ")); - result = JSTaggedValue::ToNumber(thread, string_v30); + JSHandle string_v30(thread_->GetEcmaVM()->GetFactory()->NewFromString(" 00000000 ")); + result = JSTaggedValue::ToNumber(thread_, string_v30); EXPECT_EQ(result.GetNumber(), 0); - thread->ClearException(); - JSHandle symbol_v1(thread->GetEcmaVM()->GetFactory()->NewJSSymbol()); - JSTaggedValue::ToNumber(thread, symbol_v1); - EXPECT_TRUE(thread->HasPendingException()); - EXPECT_TRUE(thread->GetException().IsJSError()); + thread_->ClearException(); + JSHandle symbol_v1(thread_->GetEcmaVM()->GetFactory()->NewJSSymbol()); + JSTaggedValue::ToNumber(thread_, symbol_v1); + EXPECT_TRUE(thread_->HasPendingException()); + EXPECT_TRUE(thread_->GetException().IsJSError()); } TEST_F(JSTaggedValueTest, ToInteger) @@ -348,35 +348,35 @@ TEST_F(JSTaggedValueTest, ToInteger) JSTaggedNumber result; JSTaggedValue int_v(100); - result = JSTaggedValue::ToInteger(thread, JSHandle(thread, int_v)); + result = JSTaggedValue::ToInteger(thread_, JSHandle(thread_, int_v)); EXPECT_EQ(result.GetNumber(), 100); JSTaggedValue double_v1((double)100.0); - result = JSTaggedValue::ToInteger(thread, JSHandle(thread, double_v1)); + result = JSTaggedValue::ToInteger(thread_, JSHandle(thread_, double_v1)); EXPECT_EQ(result.GetNumber(), (double)100.0); JSTaggedValue double_v2((double)100.123); - result = JSTaggedValue::ToInteger(thread, JSHandle(thread, double_v2)); + result = JSTaggedValue::ToInteger(thread_, JSHandle(thread_, double_v2)); EXPECT_EQ(result.GetNumber(), (double)100); JSTaggedValue undefined_v = JSTaggedValue::Undefined(); - result = JSTaggedValue::ToInteger(thread, JSHandle(thread, undefined_v)); + result = JSTaggedValue::ToInteger(thread_, JSHandle(thread_, undefined_v)); EXPECT_EQ(result.GetNumber(), 0); JSTaggedValue hole_v = JSTaggedValue::Hole(); - result = JSTaggedValue::ToInteger(thread, JSHandle(thread, hole_v)); + result = JSTaggedValue::ToInteger(thread_, JSHandle(thread_, hole_v)); EXPECT_EQ(result.GetNumber(), 0); JSTaggedValue null_v = JSTaggedValue::Null(); - result = JSTaggedValue::ToInteger(thread, JSHandle(thread, null_v)); + result = JSTaggedValue::ToInteger(thread_, JSHandle(thread_, null_v)); EXPECT_EQ(result.GetNumber(), 0); JSTaggedValue false_v = JSTaggedValue::False(); - result = JSTaggedValue::ToInteger(thread, JSHandle(thread, false_v)); + result = JSTaggedValue::ToInteger(thread_, JSHandle(thread_, false_v)); EXPECT_EQ(result.GetNumber(), 0); JSTaggedValue true_v = JSTaggedValue::True(); - result = JSTaggedValue::ToInteger(thread, JSHandle(thread, true_v)); + result = JSTaggedValue::ToInteger(thread_, JSHandle(thread_, true_v)); EXPECT_EQ(result.GetNumber(), 1); } @@ -385,50 +385,50 @@ TEST_F(JSTaggedValueTest, ToInt32) int32_t result; JSTaggedValue int_v(100); - result = JSTaggedValue::ToInt32(thread, JSHandle(thread, int_v)); + result = JSTaggedValue::ToInt32(thread_, JSHandle(thread_, int_v)); EXPECT_EQ(result, 100); JSTaggedValue double_v1((double)100.0); - result = JSTaggedValue::ToInt32(thread, JSHandle(thread, double_v1)); + result = JSTaggedValue::ToInt32(thread_, JSHandle(thread_, double_v1)); EXPECT_EQ(result, 100); JSTaggedValue double_v2((double)100.123); - result = JSTaggedValue::ToInt32(thread, JSHandle(thread, double_v2)); + result = JSTaggedValue::ToInt32(thread_, JSHandle(thread_, double_v2)); EXPECT_EQ(result, 100); double input_1 = (static_cast(UINT32_MAX) + 1) + 12345; JSTaggedValue double_v3(input_1); - result = JSTaggedValue::ToInt32(thread, JSHandle(thread, double_v3)); + result = JSTaggedValue::ToInt32(thread_, JSHandle(thread_, double_v3)); EXPECT_EQ(result, 12345); double input_2 = 100 * (static_cast(UINT32_MAX) + 1) + 23456; JSTaggedValue double_v4(input_2); - result = JSTaggedValue::ToInt32(thread, JSHandle(thread, double_v4)); + result = JSTaggedValue::ToInt32(thread_, JSHandle(thread_, double_v4)); EXPECT_EQ(result, 23456); double input_3 = 100 * (static_cast(UINT32_MAX) + 1) + INT32_MAX + 1 + 23456; JSTaggedValue double_v5(input_3); - result = JSTaggedValue::ToInt32(thread, JSHandle(thread, double_v5)); + result = JSTaggedValue::ToInt32(thread_, JSHandle(thread_, double_v5)); EXPECT_EQ(result, 23456 - static_cast(INT32_MAX) - 1); JSTaggedValue undefined_v = JSTaggedValue::Undefined(); - result = JSTaggedValue::ToInt32(thread, JSHandle(thread, undefined_v)); + result = JSTaggedValue::ToInt32(thread_, JSHandle(thread_, undefined_v)); EXPECT_EQ(result, 0); JSTaggedValue hole_v = JSTaggedValue::Hole(); - result = JSTaggedValue::ToInt32(thread, JSHandle(thread, hole_v)); + result = JSTaggedValue::ToInt32(thread_, JSHandle(thread_, hole_v)); EXPECT_EQ(result, 0); JSTaggedValue null_v = JSTaggedValue::Null(); - result = JSTaggedValue::ToInt32(thread, JSHandle(thread, null_v)); + result = JSTaggedValue::ToInt32(thread_, JSHandle(thread_, null_v)); EXPECT_EQ(result, 0); JSTaggedValue false_v = JSTaggedValue::False(); - result = JSTaggedValue::ToInt32(thread, JSHandle(thread, false_v)); + result = JSTaggedValue::ToInt32(thread_, JSHandle(thread_, false_v)); EXPECT_EQ(result, 0); JSTaggedValue true_v = JSTaggedValue::True(); - result = JSTaggedValue::ToInt32(thread, JSHandle(thread, true_v)); + result = JSTaggedValue::ToInt32(thread_, JSHandle(thread_, true_v)); EXPECT_EQ(result, 1); } @@ -437,50 +437,50 @@ TEST_F(JSTaggedValueTest, ToUint32) uint32_t result; JSTaggedValue int_v(100); - result = JSTaggedValue::ToUint32(thread, JSHandle(thread, int_v)); + result = JSTaggedValue::ToUint32(thread_, JSHandle(thread_, int_v)); EXPECT_EQ(result, 100); JSTaggedValue double_v1((double)100.0); - result = JSTaggedValue::ToUint32(thread, JSHandle(thread, double_v1)); + result = JSTaggedValue::ToUint32(thread_, JSHandle(thread_, double_v1)); EXPECT_EQ(result, 100); JSTaggedValue double_v2((double)100.123); - result = JSTaggedValue::ToUint32(thread, JSHandle(thread, double_v2)); + result = JSTaggedValue::ToUint32(thread_, JSHandle(thread_, double_v2)); EXPECT_EQ(result, 100); double input_1 = (static_cast(UINT32_MAX) + 1) + 12345; JSTaggedValue double_v3(input_1); - result = JSTaggedValue::ToUint32(thread, JSHandle(thread, double_v3)); + result = JSTaggedValue::ToUint32(thread_, JSHandle(thread_, double_v3)); EXPECT_EQ(result, 12345); double input_2 = 100 * (static_cast(UINT32_MAX) + 1) + 23456; JSTaggedValue double_v4(input_2); - result = JSTaggedValue::ToUint32(thread, JSHandle(thread, double_v4)); + result = JSTaggedValue::ToUint32(thread_, JSHandle(thread_, double_v4)); EXPECT_EQ(result, 23456); double input_3 = 100 * (static_cast(UINT32_MAX) + 1) + INT32_MAX + 1 + 23456; JSTaggedValue double_v5(input_3); - result = JSTaggedValue::ToUint32(thread, JSHandle(thread, double_v5)); + result = JSTaggedValue::ToUint32(thread_, JSHandle(thread_, double_v5)); EXPECT_EQ(result, static_cast(INT32_MAX) + 1 + 23456); JSTaggedValue undefined_v = JSTaggedValue::Undefined(); - result = JSTaggedValue::ToUint32(thread, JSHandle(thread, undefined_v)); + result = JSTaggedValue::ToUint32(thread_, JSHandle(thread_, undefined_v)); EXPECT_EQ(result, 0); JSTaggedValue hole_v = JSTaggedValue::Hole(); - result = JSTaggedValue::ToUint32(thread, JSHandle(thread, hole_v)); + result = JSTaggedValue::ToUint32(thread_, JSHandle(thread_, hole_v)); EXPECT_EQ(result, 0); JSTaggedValue null_v = JSTaggedValue::Null(); - result = JSTaggedValue::ToUint32(thread, JSHandle(thread, null_v)); + result = JSTaggedValue::ToUint32(thread_, JSHandle(thread_, null_v)); EXPECT_EQ(result, 0); JSTaggedValue false_v = JSTaggedValue::False(); - result = JSTaggedValue::ToUint32(thread, JSHandle(thread, false_v)); + result = JSTaggedValue::ToUint32(thread_, JSHandle(thread_, false_v)); EXPECT_EQ(result, 0); JSTaggedValue true_v = JSTaggedValue::True(); - result = JSTaggedValue::ToUint32(thread, JSHandle(thread, true_v)); + result = JSTaggedValue::ToUint32(thread_, JSHandle(thread_, true_v)); EXPECT_EQ(result, 1); } @@ -489,50 +489,50 @@ TEST_F(JSTaggedValueTest, ToInt16) int32_t result; JSTaggedValue int_v(100); - result = JSTaggedValue::ToInt16(thread, JSHandle(thread, int_v)); + result = JSTaggedValue::ToInt16(thread_, JSHandle(thread_, int_v)); EXPECT_EQ(result, 100); JSTaggedValue double_v1((double)100.0); - result = JSTaggedValue::ToInt16(thread, JSHandle(thread, double_v1)); + result = JSTaggedValue::ToInt16(thread_, JSHandle(thread_, double_v1)); EXPECT_EQ(result, 100); JSTaggedValue double_v2((double)100.123); - result = JSTaggedValue::ToInt16(thread, JSHandle(thread, double_v2)); + result = JSTaggedValue::ToInt16(thread_, JSHandle(thread_, double_v2)); EXPECT_EQ(result, 100); double input_1 = (static_cast(UINT16_MAX) + 1) + 12345; JSTaggedValue double_v3(input_1); - result = JSTaggedValue::ToInt16(thread, JSHandle(thread, double_v3)); + result = JSTaggedValue::ToInt16(thread_, JSHandle(thread_, double_v3)); EXPECT_EQ(result, 12345); double input_2 = 100 * (static_cast(UINT16_MAX) + 1) + 23456; JSTaggedValue double_v4(input_2); - result = JSTaggedValue::ToInt16(thread, JSHandle(thread, double_v4)); + result = JSTaggedValue::ToInt16(thread_, JSHandle(thread_, double_v4)); EXPECT_EQ(result, 23456); double input_3 = 100 * (static_cast(UINT16_MAX) + 1) + INT16_MAX + 1 + 23456; JSTaggedValue double_v5(input_3); - result = JSTaggedValue::ToInt16(thread, JSHandle(thread, double_v5)); + result = JSTaggedValue::ToInt16(thread_, JSHandle(thread_, double_v5)); EXPECT_EQ(result, 23456 - static_cast(INT16_MAX) - 1); JSTaggedValue undefined_v = JSTaggedValue::Undefined(); - result = JSTaggedValue::ToInt16(thread, JSHandle(thread, undefined_v)); + result = JSTaggedValue::ToInt16(thread_, JSHandle(thread_, undefined_v)); EXPECT_EQ(result, 0); JSTaggedValue hole_v = JSTaggedValue::Hole(); - result = JSTaggedValue::ToInt16(thread, JSHandle(thread, hole_v)); + result = JSTaggedValue::ToInt16(thread_, JSHandle(thread_, hole_v)); EXPECT_EQ(result, 0); JSTaggedValue null_v = JSTaggedValue::Null(); - result = JSTaggedValue::ToInt16(thread, JSHandle(thread, null_v)); + result = JSTaggedValue::ToInt16(thread_, JSHandle(thread_, null_v)); EXPECT_EQ(result, 0); JSTaggedValue false_v = JSTaggedValue::False(); - result = JSTaggedValue::ToInt16(thread, JSHandle(thread, false_v)); + result = JSTaggedValue::ToInt16(thread_, JSHandle(thread_, false_v)); EXPECT_EQ(result, 0); JSTaggedValue true_v = JSTaggedValue::True(); - result = JSTaggedValue::ToInt16(thread, JSHandle(thread, true_v)); + result = JSTaggedValue::ToInt16(thread_, JSHandle(thread_, true_v)); EXPECT_EQ(result, 1); } @@ -541,50 +541,50 @@ TEST_F(JSTaggedValueTest, ToUint16) uint32_t result; JSTaggedValue int_v(100); - result = JSTaggedValue::ToUint16(thread, JSHandle(thread, int_v)); + result = JSTaggedValue::ToUint16(thread_, JSHandle(thread_, int_v)); EXPECT_EQ(result, 100); JSTaggedValue double_v1((double)100.0); - result = JSTaggedValue::ToUint16(thread, JSHandle(thread, double_v1)); + result = JSTaggedValue::ToUint16(thread_, JSHandle(thread_, double_v1)); EXPECT_EQ(result, 100); JSTaggedValue double_v2((double)100.123); - result = JSTaggedValue::ToUint16(thread, JSHandle(thread, double_v2)); + result = JSTaggedValue::ToUint16(thread_, JSHandle(thread_, double_v2)); EXPECT_EQ(result, 100); double input_1 = (static_cast(UINT16_MAX) + 1) + 12345; JSTaggedValue double_v3(input_1); - result = JSTaggedValue::ToUint16(thread, JSHandle(thread, double_v3)); + result = JSTaggedValue::ToUint16(thread_, JSHandle(thread_, double_v3)); EXPECT_EQ(result, 12345); double input_2 = 100 * (static_cast(UINT16_MAX) + 1) + 23456; JSTaggedValue double_v4(input_2); - result = JSTaggedValue::ToUint16(thread, JSHandle(thread, double_v4)); + result = JSTaggedValue::ToUint16(thread_, JSHandle(thread_, double_v4)); EXPECT_EQ(result, 23456); double input_3 = 100 * (static_cast(UINT16_MAX) + 1) + INT16_MAX + 1 + 23456; JSTaggedValue double_v5(input_3); - result = JSTaggedValue::ToUint16(thread, JSHandle(thread, double_v5)); + result = JSTaggedValue::ToUint16(thread_, JSHandle(thread_, double_v5)); EXPECT_EQ(result, static_cast(INT16_MAX) + 1 + 23456); JSTaggedValue undefined_v = JSTaggedValue::Undefined(); - result = JSTaggedValue::ToUint16(thread, JSHandle(thread, undefined_v)); + result = JSTaggedValue::ToUint16(thread_, JSHandle(thread_, undefined_v)); EXPECT_EQ(result, 0); JSTaggedValue hole_v = JSTaggedValue::Hole(); - result = JSTaggedValue::ToUint16(thread, JSHandle(thread, hole_v)); + result = JSTaggedValue::ToUint16(thread_, JSHandle(thread_, hole_v)); EXPECT_EQ(result, 0); JSTaggedValue null_v = JSTaggedValue::Null(); - result = JSTaggedValue::ToUint16(thread, JSHandle(thread, null_v)); + result = JSTaggedValue::ToUint16(thread_, JSHandle(thread_, null_v)); EXPECT_EQ(result, 0); JSTaggedValue false_v = JSTaggedValue::False(); - result = JSTaggedValue::ToUint16(thread, JSHandle(thread, false_v)); + result = JSTaggedValue::ToUint16(thread_, JSHandle(thread_, false_v)); EXPECT_EQ(result, 0); JSTaggedValue true_v = JSTaggedValue::True(); - result = JSTaggedValue::ToUint16(thread, JSHandle(thread, true_v)); + result = JSTaggedValue::ToUint16(thread_, JSHandle(thread_, true_v)); EXPECT_EQ(result, 1); } @@ -593,50 +593,50 @@ TEST_F(JSTaggedValueTest, ToInt8) int32_t result; JSTaggedValue int_v(100); - result = JSTaggedValue::ToInt8(thread, JSHandle(thread, int_v)); + result = JSTaggedValue::ToInt8(thread_, JSHandle(thread_, int_v)); EXPECT_EQ(result, 100); JSTaggedValue double_v1((double)100.0); - result = JSTaggedValue::ToInt8(thread, JSHandle(thread, double_v1)); + result = JSTaggedValue::ToInt8(thread_, JSHandle(thread_, double_v1)); EXPECT_EQ(result, 100); JSTaggedValue double_v2((double)100.123); - result = JSTaggedValue::ToInt8(thread, JSHandle(thread, double_v2)); + result = JSTaggedValue::ToInt8(thread_, JSHandle(thread_, double_v2)); EXPECT_EQ(result, 100); double input_1 = (static_cast(UINT8_MAX) + 1) + 45; JSTaggedValue double_v3(input_1); - result = JSTaggedValue::ToInt8(thread, JSHandle(thread, double_v3)); + result = JSTaggedValue::ToInt8(thread_, JSHandle(thread_, double_v3)); EXPECT_EQ(result, 45); double input_2 = 100 * (static_cast(UINT8_MAX) + 1) + 56; JSTaggedValue double_v4(input_2); - result = JSTaggedValue::ToInt8(thread, JSHandle(thread, double_v4)); + result = JSTaggedValue::ToInt8(thread_, JSHandle(thread_, double_v4)); EXPECT_EQ(result, 56); double input_3 = 100 * (static_cast(UINT8_MAX) + 1) + INT8_MAX + 1 + 23; JSTaggedValue double_v5(input_3); - result = JSTaggedValue::ToInt8(thread, JSHandle(thread, double_v5)); + result = JSTaggedValue::ToInt8(thread_, JSHandle(thread_, double_v5)); EXPECT_EQ(result, 23 - static_cast(INT8_MAX) - 1); JSTaggedValue undefined_v = JSTaggedValue::Undefined(); - result = JSTaggedValue::ToInt8(thread, JSHandle(thread, undefined_v)); + result = JSTaggedValue::ToInt8(thread_, JSHandle(thread_, undefined_v)); EXPECT_EQ(result, 0); JSTaggedValue hole_v = JSTaggedValue::Hole(); - result = JSTaggedValue::ToInt8(thread, JSHandle(thread, hole_v)); + result = JSTaggedValue::ToInt8(thread_, JSHandle(thread_, hole_v)); EXPECT_EQ(result, 0); JSTaggedValue null_v = JSTaggedValue::Null(); - result = JSTaggedValue::ToInt8(thread, JSHandle(thread, null_v)); + result = JSTaggedValue::ToInt8(thread_, JSHandle(thread_, null_v)); EXPECT_EQ(result, 0); JSTaggedValue false_v = JSTaggedValue::False(); - result = JSTaggedValue::ToInt8(thread, JSHandle(thread, false_v)); + result = JSTaggedValue::ToInt8(thread_, JSHandle(thread_, false_v)); EXPECT_EQ(result, 0); JSTaggedValue true_v = JSTaggedValue::True(); - result = JSTaggedValue::ToInt8(thread, JSHandle(thread, true_v)); + result = JSTaggedValue::ToInt8(thread_, JSHandle(thread_, true_v)); EXPECT_EQ(result, 1); } @@ -645,50 +645,50 @@ TEST_F(JSTaggedValueTest, ToUint8) uint32_t result; JSTaggedValue int_v(100); - result = JSTaggedValue::ToUint8(thread, JSHandle(thread, int_v)); + result = JSTaggedValue::ToUint8(thread_, JSHandle(thread_, int_v)); EXPECT_EQ(result, 100); JSTaggedValue double_v1((double)100.0); - result = JSTaggedValue::ToUint8(thread, JSHandle(thread, double_v1)); + result = JSTaggedValue::ToUint8(thread_, JSHandle(thread_, double_v1)); EXPECT_EQ(result, 100); JSTaggedValue double_v2((double)100.123); - result = JSTaggedValue::ToUint8(thread, JSHandle(thread, double_v2)); + result = JSTaggedValue::ToUint8(thread_, JSHandle(thread_, double_v2)); EXPECT_EQ(result, 100); double input_1 = (static_cast(UINT8_MAX) + 1) + 34; JSTaggedValue double_v3(input_1); - result = JSTaggedValue::ToUint8(thread, JSHandle(thread, double_v3)); + result = JSTaggedValue::ToUint8(thread_, JSHandle(thread_, double_v3)); EXPECT_EQ(result, 34); double input_2 = 100 * (static_cast(UINT8_MAX) + 1) + 45; JSTaggedValue double_v4(input_2); - result = JSTaggedValue::ToUint8(thread, JSHandle(thread, double_v4)); + result = JSTaggedValue::ToUint8(thread_, JSHandle(thread_, double_v4)); EXPECT_EQ(result, 45); double input_3 = 100 * (static_cast(UINT8_MAX) + 1) + INT8_MAX + 1 + 56; JSTaggedValue double_v5(input_3); - result = JSTaggedValue::ToUint8(thread, JSHandle(thread, double_v5)); + result = JSTaggedValue::ToUint8(thread_, JSHandle(thread_, double_v5)); EXPECT_EQ(result, static_cast(INT8_MAX) + 1 + 56); JSTaggedValue undefined_v = JSTaggedValue::Undefined(); - result = JSTaggedValue::ToUint8(thread, JSHandle(thread, undefined_v)); + result = JSTaggedValue::ToUint8(thread_, JSHandle(thread_, undefined_v)); EXPECT_EQ(result, 0); JSTaggedValue hole_v = JSTaggedValue::Hole(); - result = JSTaggedValue::ToUint8(thread, JSHandle(thread, hole_v)); + result = JSTaggedValue::ToUint8(thread_, JSHandle(thread_, hole_v)); EXPECT_EQ(result, 0); JSTaggedValue null_v = JSTaggedValue::Null(); - result = JSTaggedValue::ToUint8(thread, JSHandle(thread, null_v)); + result = JSTaggedValue::ToUint8(thread_, JSHandle(thread_, null_v)); EXPECT_EQ(result, 0); JSTaggedValue false_v = JSTaggedValue::False(); - result = JSTaggedValue::ToUint8(thread, JSHandle(thread, false_v)); + result = JSTaggedValue::ToUint8(thread_, JSHandle(thread_, false_v)); EXPECT_EQ(result, 0); JSTaggedValue true_v = JSTaggedValue::True(); - result = JSTaggedValue::ToUint8(thread, JSHandle(thread, true_v)); + result = JSTaggedValue::ToUint8(thread_, JSHandle(thread_, true_v)); EXPECT_EQ(result, 1); } @@ -697,64 +697,64 @@ TEST_F(JSTaggedValueTest, ToUint8Clamp) uint32_t result; JSTaggedValue int_v1(-100); - result = JSTaggedValue::ToUint8Clamp(thread, JSHandle(thread, int_v1)); + result = JSTaggedValue::ToUint8Clamp(thread_, JSHandle(thread_, int_v1)); EXPECT_EQ(result, 0); JSTaggedValue int_v2(100); - result = JSTaggedValue::ToUint8Clamp(thread, JSHandle(thread, int_v2)); + result = JSTaggedValue::ToUint8Clamp(thread_, JSHandle(thread_, int_v2)); EXPECT_EQ(result, 100); JSTaggedValue int_v3(300); - result = JSTaggedValue::ToUint8Clamp(thread, JSHandle(thread, int_v3)); + result = JSTaggedValue::ToUint8Clamp(thread_, JSHandle(thread_, int_v3)); EXPECT_EQ(result, 255); JSTaggedValue double_v1((double)-100.123); - result = JSTaggedValue::ToUint8Clamp(thread, JSHandle(thread, double_v1)); + result = JSTaggedValue::ToUint8Clamp(thread_, JSHandle(thread_, double_v1)); EXPECT_EQ(result, 0); JSTaggedValue double_v2((double)100.123); - result = JSTaggedValue::ToUint8Clamp(thread, JSHandle(thread, double_v2)); + result = JSTaggedValue::ToUint8Clamp(thread_, JSHandle(thread_, double_v2)); EXPECT_EQ(result, 100); JSTaggedValue double_v3((double)100.55); - result = JSTaggedValue::ToUint8Clamp(thread, JSHandle(thread, double_v3)); + result = JSTaggedValue::ToUint8Clamp(thread_, JSHandle(thread_, double_v3)); EXPECT_EQ(result, 101); JSTaggedValue double_v4((double)99.9); - result = JSTaggedValue::ToUint8Clamp(thread, JSHandle(thread, double_v4)); + result = JSTaggedValue::ToUint8Clamp(thread_, JSHandle(thread_, double_v4)); EXPECT_EQ(result, 100); JSTaggedValue double_v5((double)300.5); - result = JSTaggedValue::ToUint8Clamp(thread, JSHandle(thread, double_v5)); + result = JSTaggedValue::ToUint8Clamp(thread_, JSHandle(thread_, double_v5)); EXPECT_EQ(result, 255); JSTaggedValue undefined_v = JSTaggedValue::Undefined(); - result = JSTaggedValue::ToUint8Clamp(thread, JSHandle(thread, undefined_v)); + result = JSTaggedValue::ToUint8Clamp(thread_, JSHandle(thread_, undefined_v)); EXPECT_EQ(result, 0); JSTaggedValue hole_v = JSTaggedValue::Hole(); - result = JSTaggedValue::ToUint8Clamp(thread, JSHandle(thread, hole_v)); + result = JSTaggedValue::ToUint8Clamp(thread_, JSHandle(thread_, hole_v)); EXPECT_EQ(result, 0); JSTaggedValue null_v = JSTaggedValue::Null(); - result = JSTaggedValue::ToUint8Clamp(thread, JSHandle(thread, null_v)); + result = JSTaggedValue::ToUint8Clamp(thread_, JSHandle(thread_, null_v)); EXPECT_EQ(result, 0); JSTaggedValue false_v = JSTaggedValue::False(); - result = JSTaggedValue::ToUint8Clamp(thread, JSHandle(thread, false_v)); + result = JSTaggedValue::ToUint8Clamp(thread_, JSHandle(thread_, false_v)); EXPECT_EQ(result, 0); JSTaggedValue true_v = JSTaggedValue::True(); - result = JSTaggedValue::ToUint8Clamp(thread, JSHandle(thread, true_v)); + result = JSTaggedValue::ToUint8Clamp(thread_, JSHandle(thread_, true_v)); EXPECT_EQ(result, 1); } TEST_F(JSTaggedValueTest, ToPropertyKey) { JSTaggedValue result; - JSHandle str = thread->GetEcmaVM()->GetFactory()->NewFromString("null"); + JSHandle str = thread_->GetEcmaVM()->GetFactory()->NewFromString("null"); JSTaggedValue key = str.GetTaggedValue(); - result = JSTaggedValue::ToPropertyKey(thread, JSHandle(thread, key)).GetTaggedValue(); + result = JSTaggedValue::ToPropertyKey(thread_, JSHandle(thread_, key)).GetTaggedValue(); EXPECT_TRUE(key == result); } @@ -769,95 +769,95 @@ void CheckOkString(JSThread *thread, const JSHandle &tagged, Pand TEST_F(JSTaggedValueTest, ToString) { PandaString right_c_str; - CheckOkString(thread, JSHandle(thread, JSTaggedValue()), right_c_str); + CheckOkString(thread_, JSHandle(thread_, JSTaggedValue()), right_c_str); right_c_str = "undefined"; - CheckOkString(thread, JSHandle(thread, JSTaggedValue::Undefined()), right_c_str); + CheckOkString(thread_, JSHandle(thread_, JSTaggedValue::Undefined()), right_c_str); right_c_str = "null"; - CheckOkString(thread, JSHandle(thread, JSTaggedValue::Null()), right_c_str); + CheckOkString(thread_, JSHandle(thread_, JSTaggedValue::Null()), right_c_str); right_c_str = "true"; - CheckOkString(thread, JSHandle(thread, JSTaggedValue::True()), right_c_str); + CheckOkString(thread_, JSHandle(thread_, JSTaggedValue::True()), right_c_str); right_c_str = "false"; - CheckOkString(thread, JSHandle(thread, JSTaggedValue::False()), right_c_str); + CheckOkString(thread_, JSHandle(thread_, JSTaggedValue::False()), right_c_str); right_c_str = "hello world"; - CheckOkString(thread, - JSHandle(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(right_c_str)), + CheckOkString(thread_, + JSHandle(thread_->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(right_c_str)), right_c_str); double num = 1; auto number_num = JSTaggedNumber(num); right_c_str = "1"; - CheckOkString(thread, JSHandle(thread, number_num), right_c_str); + CheckOkString(thread_, JSHandle(thread_, number_num), right_c_str); num = 1.23; number_num = JSTaggedNumber(num); right_c_str = "1.23"; - CheckOkString(thread, JSHandle(thread, number_num), right_c_str); + CheckOkString(thread_, JSHandle(thread_, number_num), right_c_str); int num_int = 2; - JSHandle value1(thread, JSTaggedValue(num_int)); + JSHandle value1(thread_, JSTaggedValue(num_int)); right_c_str = "2"; - CheckOkString(thread, JSHandle::Cast(JSTaggedValue::ToObject(thread, value1)), right_c_str); + CheckOkString(thread_, JSHandle::Cast(JSTaggedValue::ToObject(thread_, value1)), right_c_str); num = 1.23; - JSHandle value2(thread, JSTaggedValue(num)); + JSHandle value2(thread_, JSTaggedValue(num)); right_c_str = "1.23"; - CheckOkString(thread, JSHandle::Cast(JSTaggedValue::ToObject(thread, value2)), right_c_str); + CheckOkString(thread_, JSHandle::Cast(JSTaggedValue::ToObject(thread_, value2)), right_c_str); bool value_bool = true; - JSHandle value3(thread, JSTaggedValue(value_bool)); + JSHandle value3(thread_, JSTaggedValue(value_bool)); right_c_str = "true"; - CheckOkString(thread, JSHandle::Cast(JSTaggedValue::ToObject(thread, value3)), right_c_str); + CheckOkString(thread_, JSHandle::Cast(JSTaggedValue::ToObject(thread_, value3)), right_c_str); } TEST_F(JSTaggedValueTest, CanonicalNumericIndexString) { JSTaggedValue result; - JSHandle str = thread->GetEcmaVM()->GetFactory()->NewFromString("-0"); + JSHandle str = thread_->GetEcmaVM()->GetFactory()->NewFromString("-0"); JSTaggedValue tmp_str = str.GetTaggedValue(); - result = JSTaggedValue::CanonicalNumericIndexString(thread, JSHandle(thread, tmp_str)); + result = JSTaggedValue::CanonicalNumericIndexString(thread_, JSHandle(thread_, tmp_str)); EXPECT_EQ(result.GetDouble(), -0.0); JSTaggedValue tmp_int(1); - result = JSTaggedValue::CanonicalNumericIndexString(thread, JSHandle(thread, tmp_int)); + result = JSTaggedValue::CanonicalNumericIndexString(thread_, JSHandle(thread_, tmp_int)); EXPECT_TRUE(result.IsUndefined()); JSTaggedValue tmp_double((double)100.0); - result = JSTaggedValue::CanonicalNumericIndexString(thread, JSHandle(thread, tmp_double)); + result = JSTaggedValue::CanonicalNumericIndexString(thread_, JSHandle(thread_, tmp_double)); EXPECT_TRUE(result.IsUndefined()); } TEST_F(JSTaggedValueTest, ToObject) { - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); // int -> JSObject - JSHandle value1(thread, JSTaggedValue(2)); + JSHandle value1(thread_, JSTaggedValue(2)); JSTaggedValue tagged1 = - JSTaggedValue(JSHandle::Cast(JSTaggedValue::ToObject(thread, value1))->GetValue()); + JSTaggedValue(JSHandle::Cast(JSTaggedValue::ToObject(thread_, value1))->GetValue()); EXPECT_EQ(tagged1.GetRawData(), JSTaggedValue(2).GetRawData()); // double -> JSObject - JSHandle value2(thread, JSTaggedValue(2.2)); + JSHandle value2(thread_, JSTaggedValue(2.2)); JSTaggedValue tagged2 = - JSTaggedValue(JSHandle::Cast(JSTaggedValue::ToObject(thread, value2))->GetValue()); + JSTaggedValue(JSHandle::Cast(JSTaggedValue::ToObject(thread_, value2))->GetValue()); EXPECT_EQ(tagged2.GetRawData(), JSTaggedValue(static_cast(2.2)).GetRawData()); // bool -> JSObject - JSHandle value3(thread, JSTaggedValue::True()); + JSHandle value3(thread_, JSTaggedValue::True()); JSTaggedValue tagged3 = - JSTaggedValue(JSHandle::Cast(JSTaggedValue::ToObject(thread, value3))->GetValue()); + JSTaggedValue(JSHandle::Cast(JSTaggedValue::ToObject(thread_, value3))->GetValue()); EXPECT_EQ(tagged3.GetRawData(), JSTaggedValue::True().GetRawData()); // String -> JSObject JSHandle value4(factory->NewFromString("aaa")); JSTaggedValue tagged4 = - JSTaggedValue(JSHandle::Cast(JSTaggedValue::ToObject(thread, value4))->GetValue()); + JSTaggedValue(JSHandle::Cast(JSTaggedValue::ToObject(thread_, value4))->GetValue()); EXPECT_TRUE(tagged4.IsString()); EXPECT_EQ(reinterpret_cast(tagged4.GetRawData())->Compare(value4.GetObject()), 0); @@ -866,18 +866,18 @@ TEST_F(JSTaggedValueTest, ToObject) JSHandle str = factory->NewFromString("bbb"); JSHandle value5(symbol); JSTaggedValue tagged5 = - JSTaggedValue(JSHandle::Cast(JSTaggedValue::ToObject(thread, value5))->GetValue()); + JSTaggedValue(JSHandle::Cast(JSTaggedValue::ToObject(thread_, value5))->GetValue()); EXPECT_EQ(EcmaString::Cast(reinterpret_cast(tagged5.GetRawData())->GetDescription().GetHeapObject()) ->Compare(*str), 0); EXPECT_TRUE(tagged5.IsSymbol()); // JSObject(include all types of objects inherited from JSObject) -> JSObject - EcmaVM *ecma = thread->GetEcmaVM(); + EcmaVM *ecma = thread_->GetEcmaVM(); JSHandle object_fun = ecma->GetGlobalEnv()->GetObjectFunction(); JSHandle js_obj = factory->NewJSObjectByConstructor(JSHandle(object_fun), object_fun); JSHandle value(js_obj); - EXPECT_EQ(*JSTaggedValue::ToObject(thread, value), *js_obj); + EXPECT_EQ(*JSTaggedValue::ToObject(thread_, value), *js_obj); } TEST_F(JSTaggedValueTest, ToLength) @@ -885,68 +885,68 @@ TEST_F(JSTaggedValueTest, ToLength) JSTaggedNumber result; JSTaggedValue int_v(100); - result = JSTaggedValue::ToLength(thread, JSHandle(thread, int_v)); + result = JSTaggedValue::ToLength(thread_, JSHandle(thread_, int_v)); EXPECT_EQ(result.GetNumber(), 100); JSTaggedValue int_v2(-1); - result = JSTaggedValue::ToLength(thread, JSHandle(thread, int_v2)); + result = JSTaggedValue::ToLength(thread_, JSHandle(thread_, int_v2)); EXPECT_EQ(result.GetNumber(), 0); JSTaggedValue double_v1((double)100.0); - result = JSTaggedValue::ToLength(thread, JSHandle(thread, double_v1)); + result = JSTaggedValue::ToLength(thread_, JSHandle(thread_, double_v1)); EXPECT_EQ(result.GetNumber(), (double)100.0); JSTaggedValue double_v2((double)100.123); - result = JSTaggedValue::ToLength(thread, JSHandle(thread, double_v2)); + result = JSTaggedValue::ToLength(thread_, JSHandle(thread_, double_v2)); EXPECT_EQ(result.GetNumber(), (double)100); JSTaggedValue double_v3((double)-1.0); - result = JSTaggedValue::ToLength(thread, JSHandle(thread, double_v3)); + result = JSTaggedValue::ToLength(thread_, JSHandle(thread_, double_v3)); EXPECT_EQ(result.GetNumber(), (double)0); JSTaggedValue double_v4((double)9007199254740992); - result = JSTaggedValue::ToLength(thread, JSHandle(thread, double_v4)); + result = JSTaggedValue::ToLength(thread_, JSHandle(thread_, double_v4)); EXPECT_EQ(result.GetNumber(), (double)9007199254740991); JSTaggedValue undefined_v = JSTaggedValue::Undefined(); - result = JSTaggedValue::ToLength(thread, JSHandle(thread, undefined_v)); + result = JSTaggedValue::ToLength(thread_, JSHandle(thread_, undefined_v)); EXPECT_EQ(result.GetNumber(), 0); JSTaggedValue hole_v = JSTaggedValue::Hole(); - result = JSTaggedValue::ToLength(thread, JSHandle(thread, hole_v)); + result = JSTaggedValue::ToLength(thread_, JSHandle(thread_, hole_v)); EXPECT_EQ(result.GetNumber(), 0); JSTaggedValue null_v = JSTaggedValue::Null(); - result = JSTaggedValue::ToLength(thread, JSHandle(thread, null_v)); + result = JSTaggedValue::ToLength(thread_, JSHandle(thread_, null_v)); EXPECT_EQ(result.GetNumber(), 0); JSTaggedValue false_v = JSTaggedValue::False(); - result = JSTaggedValue::ToLength(thread, JSHandle(thread, false_v)); + result = JSTaggedValue::ToLength(thread_, JSHandle(thread_, false_v)); EXPECT_EQ(result.GetNumber(), 0); JSTaggedValue true_v = JSTaggedValue::True(); - result = JSTaggedValue::ToLength(thread, JSHandle(thread, true_v)); + result = JSTaggedValue::ToLength(thread_, JSHandle(thread_, true_v)); EXPECT_EQ(result.GetNumber(), 1); } TEST_F(JSTaggedValueTest, IsArray) { - EcmaVM *ecma = thread->GetEcmaVM(); + EcmaVM *ecma = thread_->GetEcmaVM(); JSHandle object_fun = ecma->GetGlobalEnv()->GetArrayFunction(); JSHandle js_obj = - thread->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(object_fun), object_fun); + thread_->GetEcmaVM()->GetFactory()->NewJSObjectByConstructor(JSHandle(object_fun), object_fun); ASSERT_TRUE(js_obj->IsJSArray()); - ASSERT_FALSE(JSTaggedValue(1).IsArray(thread)); + ASSERT_FALSE(JSTaggedValue(1).IsArray(thread_)); - ASSERT_FALSE(thread->GetEcmaVM()->GetFactory()->NewFromString("test").GetTaggedValue().IsArray(thread)); + ASSERT_FALSE(thread_->GetEcmaVM()->GetFactory()->NewFromString("test").GetTaggedValue().IsArray(thread_)); } TEST_F(JSTaggedValueTest, IsCallable_IsConstructor_IsExtensible) { - JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); - JSHandle js_function = thread->GetEcmaVM()->GetFactory()->NewJSFunction(env); + JSHandle env = thread_->GetEcmaVM()->GetGlobalEnv(); + JSHandle js_function = thread_->GetEcmaVM()->GetFactory()->NewJSFunction(env); JSHClass *js_hclass = js_function->GetJSHClass(); ASSERT_TRUE(js_function->IsCallable()); js_hclass->SetConstructor(true); @@ -957,7 +957,7 @@ TEST_F(JSTaggedValueTest, IsCallable_IsConstructor_IsExtensible) ASSERT_TRUE(js_function->IsExtensible()); js_hclass->SetExtensible(false); ASSERT_FALSE(js_function->IsExtensible()); - ASSERT_FALSE(JSTaggedValue(1).IsExtensible(thread)); + ASSERT_FALSE(JSTaggedValue(1).IsExtensible(thread_)); ASSERT_FALSE(JSTaggedValue(1).IsConstructor()); ASSERT_FALSE(JSTaggedValue(1).IsCallable()); } @@ -978,25 +978,25 @@ TEST_F(JSTaggedValueTest, IsInteger) ASSERT_FALSE(JSTaggedValue::Null().IsInteger()); ASSERT_FALSE(JSTaggedValue::False().IsInteger()); ASSERT_FALSE(JSTaggedValue::Hole().IsInteger()); - ASSERT_FALSE(thread->GetEcmaVM()->GetFactory()->NewFromString("test").GetTaggedValue().IsInteger()); + ASSERT_FALSE(thread_->GetEcmaVM()->GetFactory()->NewFromString("test").GetTaggedValue().IsInteger()); } TEST_F(JSTaggedValueTest, IsPropertyKey) { ASSERT_TRUE(JSTaggedValue::IsPropertyKey( - JSHandle(thread->GetEcmaVM()->GetFactory()->NewFromString("test")))); + JSHandle(thread_->GetEcmaVM()->GetFactory()->NewFromString("test")))); } TEST_F(JSTaggedValueTest, IsRegExp) { - JSHandle string = thread->GetEcmaVM()->GetFactory()->NewFromString("test"); + JSHandle string = thread_->GetEcmaVM()->GetFactory()->NewFromString("test"); JSHandle obj = JSHandle::Cast(string); - ASSERT_FALSE(JSObject::IsRegExp(thread, obj)); + ASSERT_FALSE(JSObject::IsRegExp(thread_, obj)); } TEST_F(JSTaggedValueTest, SameValue) { - EcmaVM *ecma = thread->GetEcmaVM(); + EcmaVM *ecma = thread_->GetEcmaVM(); JSHandle object_fun = ecma->GetGlobalEnv()->GetObjectFunction(); JSHandle js_obj = @@ -1053,155 +1053,155 @@ TEST_F(JSTaggedValueTest, SameValueZero) TEST_F(JSTaggedValueTest, Less) { - JSHandle test(thread->GetEcmaVM()->GetFactory()->NewFromString("test")); - JSHandle test1(thread->GetEcmaVM()->GetFactory()->NewFromString("test1")); - JSHandle test2(thread->GetEcmaVM()->GetFactory()->NewFromString("test2")); - - ASSERT_TRUE(JSTaggedValue::Less(thread, JSHandle(thread, JSTaggedValue(1.0)), - JSHandle(thread, JSTaggedValue(2.0)))); - ASSERT_FALSE(JSTaggedValue::Less(thread, JSHandle(thread, JSTaggedValue(0.0)), - JSHandle(thread, JSTaggedValue(-0.0)))); - ASSERT_TRUE(JSTaggedValue::Less(thread, JSHandle(thread, JSTaggedValue(1)), - JSHandle(thread, JSTaggedValue(2)))); - - ASSERT_TRUE(JSTaggedValue::Less(thread, test, test1)); - ASSERT_FALSE(JSTaggedValue::Less(thread, test2, test1)); - ASSERT_FALSE(JSTaggedValue::Less(thread, JSHandle(thread, JSTaggedValue(1)), test1)); - ASSERT_FALSE(JSTaggedValue::Less(thread, test2, JSHandle(thread, JSTaggedValue(2)))); - - ASSERT_TRUE(JSTaggedValue::Less(thread, - JSHandle(thread->GetEcmaVM()->GetFactory()->NewFromString("1")), - JSHandle(thread, JSTaggedValue(2)))); - ASSERT_TRUE(JSTaggedValue::Less(thread, JSHandle(thread, JSTaggedValue(1)), - JSHandle(thread->GetEcmaVM()->GetFactory()->NewFromString("2")))); - - ASSERT_TRUE(JSTaggedValue::Less(thread, JSHandle(thread, JSTaggedValue::False()), - JSHandle(thread, JSTaggedValue::True()))); - ASSERT_FALSE(JSTaggedValue::Less(thread, JSHandle(thread, JSTaggedValue::True()), - JSHandle(thread, JSTaggedValue::False()))); - ASSERT_FALSE(JSTaggedValue::Less(thread, JSHandle(thread, JSTaggedValue::Undefined()), - JSHandle(thread, JSTaggedValue::Null()))); - ASSERT_FALSE(JSTaggedValue::Less(thread, JSHandle(thread, JSTaggedValue::Null()), - JSHandle(thread, JSTaggedValue::Undefined()))); + JSHandle test(thread_->GetEcmaVM()->GetFactory()->NewFromString("test")); + JSHandle test1(thread_->GetEcmaVM()->GetFactory()->NewFromString("test1")); + JSHandle test2(thread_->GetEcmaVM()->GetFactory()->NewFromString("test2")); + + ASSERT_TRUE(JSTaggedValue::Less(thread_, JSHandle(thread_, JSTaggedValue(1.0)), + JSHandle(thread_, JSTaggedValue(2.0)))); + ASSERT_FALSE(JSTaggedValue::Less(thread_, JSHandle(thread_, JSTaggedValue(0.0)), + JSHandle(thread_, JSTaggedValue(-0.0)))); + ASSERT_TRUE(JSTaggedValue::Less(thread_, JSHandle(thread_, JSTaggedValue(1)), + JSHandle(thread_, JSTaggedValue(2)))); + + ASSERT_TRUE(JSTaggedValue::Less(thread_, test, test1)); + ASSERT_FALSE(JSTaggedValue::Less(thread_, test2, test1)); + ASSERT_FALSE(JSTaggedValue::Less(thread_, JSHandle(thread_, JSTaggedValue(1)), test1)); + ASSERT_FALSE(JSTaggedValue::Less(thread_, test2, JSHandle(thread_, JSTaggedValue(2)))); + + ASSERT_TRUE(JSTaggedValue::Less(thread_, + JSHandle(thread_->GetEcmaVM()->GetFactory()->NewFromString("1")), + JSHandle(thread_, JSTaggedValue(2)))); + ASSERT_TRUE(JSTaggedValue::Less(thread_, JSHandle(thread_, JSTaggedValue(1)), + JSHandle(thread_->GetEcmaVM()->GetFactory()->NewFromString("2")))); + + ASSERT_TRUE(JSTaggedValue::Less(thread_, JSHandle(thread_, JSTaggedValue::False()), + JSHandle(thread_, JSTaggedValue::True()))); + ASSERT_FALSE(JSTaggedValue::Less(thread_, JSHandle(thread_, JSTaggedValue::True()), + JSHandle(thread_, JSTaggedValue::False()))); + ASSERT_FALSE(JSTaggedValue::Less(thread_, JSHandle(thread_, JSTaggedValue::Undefined()), + JSHandle(thread_, JSTaggedValue::Null()))); + ASSERT_FALSE(JSTaggedValue::Less(thread_, JSHandle(thread_, JSTaggedValue::Null()), + JSHandle(thread_, JSTaggedValue::Undefined()))); } TEST_F(JSTaggedValueTest, Equal) { - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::Undefined()), - JSHandle(thread, JSTaggedValue::Undefined()))); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::Null()), - JSHandle(thread, JSTaggedValue::Undefined()))); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::Null()), - JSHandle(thread, JSTaggedValue::Null()))); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::Null()), - JSHandle(thread, JSTaggedValue::Undefined()))); - ASSERT_FALSE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::Null()), - JSHandle(thread, JSTaggedValue(1)))); - ASSERT_FALSE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::Null()), - JSHandle(thread, JSTaggedValue::True()))); - ASSERT_FALSE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::Null()), - JSHandle(thread, JSTaggedValue::False()))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::Undefined()), + JSHandle(thread_, JSTaggedValue::Undefined()))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::Null()), + JSHandle(thread_, JSTaggedValue::Undefined()))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::Null()), + JSHandle(thread_, JSTaggedValue::Null()))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::Null()), + JSHandle(thread_, JSTaggedValue::Undefined()))); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::Null()), + JSHandle(thread_, JSTaggedValue(1)))); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::Null()), + JSHandle(thread_, JSTaggedValue::True()))); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::Null()), + JSHandle(thread_, JSTaggedValue::False()))); // number compare - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue(1)), - JSHandle(thread, JSTaggedValue(1)))); - ASSERT_FALSE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue(1)), - JSHandle(thread, JSTaggedValue(2)))); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue(1.0)), - JSHandle(thread, JSTaggedValue(1.0)))); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue(0.0)), - JSHandle(thread, JSTaggedValue(0.0)))); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue(0.0)), - JSHandle(thread, JSTaggedValue(-0.0)))); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue(0)), - JSHandle(thread, JSTaggedValue(-0)))); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue(1)), - JSHandle(thread, JSTaggedValue::True()))); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue(0)), - JSHandle(thread, JSTaggedValue::False()))); - ASSERT_FALSE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue(0)), - JSHandle(thread, JSTaggedValue::Undefined()))); - ASSERT_FALSE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue(0)), - JSHandle(thread, JSTaggedValue::Null()))); - - JSHandle test(thread->GetEcmaVM()->GetFactory()->NewFromString("test")); - JSHandle test1(thread->GetEcmaVM()->GetFactory()->NewFromString("test1")); - JSHandle empty(thread->GetEcmaVM()->GetFactory()->NewFromString("")); - JSHandle char0(thread->GetEcmaVM()->GetFactory()->NewFromString("0")); - JSHandle char0_point_0(thread->GetEcmaVM()->GetFactory()->NewFromString("0.0")); - JSHandle char1(thread->GetEcmaVM()->GetFactory()->NewFromString("1")); - JSHandle char1_point_0(thread->GetEcmaVM()->GetFactory()->NewFromString("1.0")); - JSHandle char_1(thread->GetEcmaVM()->GetFactory()->NewFromString("-1")); - JSHandle char_0_point_0(thread->GetEcmaVM()->GetFactory()->NewFromString("-0.0")); - JSHandle char_0_point_1(thread->GetEcmaVM()->GetFactory()->NewFromString("-0.1")); - - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue(0)), char0)); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue(0.0)), char0)); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue(1.0)), char1)); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue(-1.0)), char_1)); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue(0.0)), char_0_point_0)); - ASSERT_FALSE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue(0.0)), char_0_point_1)); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue(1)), + JSHandle(thread_, JSTaggedValue(1)))); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue(1)), + JSHandle(thread_, JSTaggedValue(2)))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue(1.0)), + JSHandle(thread_, JSTaggedValue(1.0)))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue(0.0)), + JSHandle(thread_, JSTaggedValue(0.0)))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue(0.0)), + JSHandle(thread_, JSTaggedValue(-0.0)))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue(0)), + JSHandle(thread_, JSTaggedValue(-0)))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue(1)), + JSHandle(thread_, JSTaggedValue::True()))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue(0)), + JSHandle(thread_, JSTaggedValue::False()))); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue(0)), + JSHandle(thread_, JSTaggedValue::Undefined()))); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue(0)), + JSHandle(thread_, JSTaggedValue::Null()))); + + JSHandle test(thread_->GetEcmaVM()->GetFactory()->NewFromString("test")); + JSHandle test1(thread_->GetEcmaVM()->GetFactory()->NewFromString("test1")); + JSHandle empty(thread_->GetEcmaVM()->GetFactory()->NewFromString("")); + JSHandle char0(thread_->GetEcmaVM()->GetFactory()->NewFromString("0")); + JSHandle char0_point_0(thread_->GetEcmaVM()->GetFactory()->NewFromString("0.0")); + JSHandle char1(thread_->GetEcmaVM()->GetFactory()->NewFromString("1")); + JSHandle char1_point_0(thread_->GetEcmaVM()->GetFactory()->NewFromString("1.0")); + JSHandle char_1(thread_->GetEcmaVM()->GetFactory()->NewFromString("-1")); + JSHandle char_0_point_0(thread_->GetEcmaVM()->GetFactory()->NewFromString("-0.0")); + JSHandle char_0_point_1(thread_->GetEcmaVM()->GetFactory()->NewFromString("-0.1")); + + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue(0)), char0)); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue(0.0)), char0)); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue(1.0)), char1)); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue(-1.0)), char_1)); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue(0.0)), char_0_point_0)); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue(0.0)), char_0_point_1)); // string compare - ASSERT_TRUE(JSTaggedValue::Equal(thread, test, test)); - ASSERT_FALSE(JSTaggedValue::Equal(thread, test, test1)); - ASSERT_FALSE(JSTaggedValue::Equal(thread, test, empty)); - ASSERT_TRUE(JSTaggedValue::Equal(thread, empty, empty)); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, test, test)); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, test, test1)); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, test, empty)); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, empty, empty)); // ASSERT_FALSE(JSTaggedValue::Equal(JSTaggedValue(thread->GetEcmaVM()->GetFactory()->NewFromString(""))), // JSTaggedValue(1))); - ASSERT_TRUE(JSTaggedValue::Equal(thread, char1, JSHandle(thread, JSTaggedValue(1)))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, char1, JSHandle(thread_, JSTaggedValue(1)))); // ASSERT_FALSE(JSTaggedValue::Equal( // JSTaggedValue(thread->GetEcmaVM()->GetFactory()->NewFromString("aaa"))), // JSTaggedValue(0))); // ASSERT_FALSE(JSTaggedValue::Equal( // JSTaggedValue(thread->GetEcmaVM()->GetFactory()->NewFromString("true"))), // JSTaggedValue::True())); - ASSERT_TRUE(JSTaggedValue::Equal(thread, char1, JSHandle(thread, JSTaggedValue::True()))); - ASSERT_TRUE(JSTaggedValue::Equal(thread, char0, JSHandle(thread, JSTaggedValue::False()))); - ASSERT_FALSE(JSTaggedValue::Equal(thread, char0, JSHandle(thread, JSTaggedValue::Undefined()))); - ASSERT_FALSE(JSTaggedValue::Equal(thread, char0, JSHandle(thread, JSTaggedValue::Null()))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, char1, JSHandle(thread_, JSTaggedValue::True()))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, char0, JSHandle(thread_, JSTaggedValue::False()))); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, char0, JSHandle(thread_, JSTaggedValue::Undefined()))); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, char0, JSHandle(thread_, JSTaggedValue::Null()))); // boolean compare - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::True()), - JSHandle(thread, JSTaggedValue::True()))); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::False()), - JSHandle(thread, JSTaggedValue::False()))); - ASSERT_FALSE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::True()), - JSHandle(thread, JSTaggedValue::False()))); - ASSERT_FALSE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::False()), - JSHandle(thread, JSTaggedValue::True()))); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::True()), - JSHandle(thread, JSTaggedValue(1)))); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::True()), - JSHandle(thread, JSTaggedValue(1.0)))); - ASSERT_FALSE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::True()), - JSHandle(thread, JSTaggedValue(0)))); - ASSERT_FALSE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::True()), - JSHandle(thread, JSTaggedValue(0.0)))); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::False()), - JSHandle(thread, JSTaggedValue(0)))); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::False()), - JSHandle(thread, JSTaggedValue(0.0)))); - ASSERT_FALSE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::False()), - JSHandle(thread, JSTaggedValue(1)))); - ASSERT_FALSE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::False()), - JSHandle(thread, JSTaggedValue(1.0)))); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::False()), char0)); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::False()), char0_point_0)); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::True()), char1)); - ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::True()), char1_point_0)); - ASSERT_FALSE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::True()), char0)); - ASSERT_FALSE(JSTaggedValue::Equal(thread, JSHandle(thread, JSTaggedValue::False()), char1)); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::True()), + JSHandle(thread_, JSTaggedValue::True()))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::False()), + JSHandle(thread_, JSTaggedValue::False()))); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::True()), + JSHandle(thread_, JSTaggedValue::False()))); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::False()), + JSHandle(thread_, JSTaggedValue::True()))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::True()), + JSHandle(thread_, JSTaggedValue(1)))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::True()), + JSHandle(thread_, JSTaggedValue(1.0)))); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::True()), + JSHandle(thread_, JSTaggedValue(0)))); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::True()), + JSHandle(thread_, JSTaggedValue(0.0)))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::False()), + JSHandle(thread_, JSTaggedValue(0)))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::False()), + JSHandle(thread_, JSTaggedValue(0.0)))); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::False()), + JSHandle(thread_, JSTaggedValue(1)))); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::False()), + JSHandle(thread_, JSTaggedValue(1.0)))); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::False()), char0)); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::False()), char0_point_0)); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::True()), char1)); + ASSERT_TRUE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::True()), char1_point_0)); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::True()), char0)); + ASSERT_FALSE(JSTaggedValue::Equal(thread_, JSHandle(thread_, JSTaggedValue::False()), char1)); } TEST_F(JSTaggedValueTest, StrictEqual) { // This algorithm differs from the SameValue Algorithm in its treatment of signed zeroes and NaNs. - ASSERT_TRUE(JSTaggedValue::StrictEqual(thread, JSHandle(thread, JSTaggedValue(0.0)), - JSHandle(thread, JSTaggedValue(-0.0)))); + ASSERT_TRUE(JSTaggedValue::StrictEqual(thread_, JSHandle(thread_, JSTaggedValue(0.0)), + JSHandle(thread_, JSTaggedValue(-0.0)))); ASSERT_FALSE(JSTaggedValue::StrictEqual( - thread, JSHandle(thread, JSTaggedValue(std::numeric_limits::quiet_NaN())), - JSHandle(thread, JSTaggedValue(std::numeric_limits::quiet_NaN())))); + thread_, JSHandle(thread_, JSTaggedValue(std::numeric_limits::quiet_NaN())), + JSHandle(thread_, JSTaggedValue(std::numeric_limits::quiet_NaN())))); } } // namespace panda::test diff --git a/tests/runtime/mem/g1gc_barrier_test.cpp b/tests/runtime/mem/g1gc_barrier_test.cpp index 894b325c7..446aee0c2 100644 --- a/tests/runtime/mem/g1gc_barrier_test.cpp +++ b/tests/runtime/mem/g1gc_barrier_test.cpp @@ -156,7 +156,7 @@ public: Runtime::Create(options); - thread = JSThread::GetCurrent(); + thread_ = JSThread::GetCurrent(); } ~G1GCClassCollectionTest() override @@ -166,8 +166,8 @@ public: JSHandle AllocClass() { - const GlobalEnvConstants *global_const = thread->GlobalConstants(); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); + const GlobalEnvConstants *global_const = thread_->GlobalConstants(); + ObjectFactory *factory = thread_->GetEcmaVM()->GetFactory(); JSHClass *root_hclass = JSHClass::Cast(global_const->GetHClassClass().GetTaggedObject()); return factory->NewEcmaDynClass(root_hclass, 0, JSType::JS_OBJECT); } @@ -181,15 +181,15 @@ public: protected: // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) - JSThread *thread {}; + JSThread *thread_ {}; }; TEST_P(G1GCClassCollectionTest, TestCollectClasses) { - ScopedManagedCodeThread s(thread); + ScopedManagedCodeThread s(thread_); JSHClass *hclass = nullptr; { - [[maybe_unused]] EcmaHandleScope scope(thread); + [[maybe_unused]] EcmaHandleScope scope(thread_); JSHandle hclass_handle = AllocClass(); // JSHClass is allocated in the non-movable space so we can use raw pointer safe hclass = hclass_handle.GetObject(); @@ -197,10 +197,10 @@ TEST_P(G1GCClassCollectionTest, TestCollectClasses) ASSERT_NE(nullptr, hclass); mem::Region *region = mem::ObjectToRegion(hclass); ASSERT_TRUE(region->HasFlag(mem::IS_NONMOVABLE)); - mem::GC *gc = thread->GetVM()->GetGC(); + mem::GC *gc = thread_->GetVM()->GetGC(); { - ScopedNativeCodeThread sn(thread); + ScopedNativeCodeThread sn(thread_); GCTask task(GCTaskCause::HEAP_USAGE_THRESHOLD_CAUSE); // trigger concurrent marking task.Run(*gc); } diff --git a/tests/runtime/regexp/dyn_buffer_test.cpp b/tests/runtime/regexp/dyn_buffer_test.cpp index 3fea8c015..7bc98541d 100644 --- a/tests/runtime/regexp/dyn_buffer_test.cpp +++ b/tests/runtime/regexp/dyn_buffer_test.cpp @@ -31,18 +31,18 @@ class DynBufferTest : 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_); } private: - PandaVM *instance {}; - JSThread *thread {}; - EcmaHandleScope *scope {nullptr}; + PandaVM *instance_ {}; + JSThread *thread_ {}; + EcmaHandleScope *scope_ {nullptr}; }; TEST_F(DynBufferTest, EmitAndGet) -- Gitee