1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#include "ecmascript/tests/test_helper.h" 17 18#include "ecmascript/ecma_vm.h" 19#include "ecmascript/global_env.h" 20#include "ecmascript/js_handle.h" 21 22using namespace panda::ecmascript; 23 24namespace panda::test { 25class ConcurrentSweepTest : public BaseTestWithScope<false> { 26}; 27 28TEST_F(ConcurrentSweepTest, ConcurrentSweep) 29{ 30 const uint8_t *utf8 = reinterpret_cast<const uint8_t *>("test"); 31 JSHandle<EcmaString> test1(thread, 32 EcmaStringAccessor::CreateFromUtf8(instance, utf8, 4, true)); // 4 : utf8 encoding length 33 if (instance->IsInitialized()) { 34 instance->CollectGarbage(ecmascript::TriggerGCType::OLD_GC); 35 } 36 JSHandle<EcmaString> test2(thread, 37 EcmaStringAccessor::CreateFromUtf8(instance, utf8, 4, true)); // 4 : utf8 encoding length 38 ASSERT_EQ(EcmaStringAccessor(test1).GetLength(), 4U); 39 ASSERT_NE(test1.GetTaggedValue().GetTaggedObject(), test2.GetTaggedValue().GetTaggedObject()); 40} 41} // namespace panda::test 42