Commit 056f7e52 authored by jameslahm's avatar jameslahm Committed by V8 LUCI CQ

[test] Move cctest/test-array-list to unittests

... /objects/array-list-unittest.

Bug: v8:12781
Change-Id: I8bf50cd6680b6a875fb7029a6767eebc39ed8b13
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3596444Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: 王澳 <wangao.james@bytedance.com>
Cr-Commit-Position: refs/heads/main@{#80074}
parent 63b3d332
......@@ -192,7 +192,6 @@ v8_source_set("cctest_sources") {
"test-api-typed-array.cc",
"test-api.cc",
"test-api.h",
"test-array-list.cc",
"test-atomicops.cc",
"test-bignum-dtoa.cc",
"test-bignum.cc",
......
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <stdlib.h>
#include "src/heap/factory.h"
#include "src/objects/objects-inl.h"
#include "test/cctest/cctest.h"
namespace v8 {
namespace internal {
TEST(ArrayList) {
LocalContext context;
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
Handle<ArrayList> array = ReadOnlyRoots(isolate).empty_array_list_handle();
CHECK_EQ(0, array->Length());
array = ArrayList::Add(isolate, array, handle(Smi::FromInt(100), isolate));
CHECK_EQ(1, array->Length());
CHECK_EQ(100, Smi::ToInt(array->Get(0)));
array = ArrayList::Add(isolate, array, handle(Smi::FromInt(200), isolate),
handle(Smi::FromInt(300), isolate));
CHECK_EQ(3, array->Length());
CHECK_EQ(100, Smi::ToInt(array->Get(0)));
CHECK_EQ(200, Smi::ToInt(array->Get(1)));
CHECK_EQ(300, Smi::ToInt(array->Get(2)));
array->Set(2, Smi::FromInt(400));
CHECK_EQ(400, Smi::ToInt(array->Get(2)));
array->Clear(2, ReadOnlyRoots(isolate).undefined_value());
array->SetLength(2);
CHECK_EQ(2, array->Length());
CHECK_EQ(100, Smi::ToInt(array->Get(0)));
CHECK_EQ(200, Smi::ToInt(array->Get(1)));
}
} // namespace internal
} // namespace v8
......@@ -367,6 +367,7 @@ v8_source_set("unittests_sources") {
"logging/counters-unittest.cc",
"numbers/bigint-unittest.cc",
"numbers/conversions-unittest.cc",
"objects/array-list-unittest.cc",
"objects/object-unittest.cc",
"objects/osr-optimized-code-cache-unittest.cc",
"objects/swiss-hash-table-helpers-unittest.cc",
......
// Copyright 2022 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <stdlib.h>
#include "src/heap/factory.h"
#include "src/objects/objects-inl.h"
#include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace v8 {
namespace internal {
using ArrayListTest = TestWithContext;
TEST_F(ArrayListTest, ArrayList) {
HandleScope scope(i_isolate());
Handle<ArrayList> array =
ReadOnlyRoots(i_isolate()).empty_array_list_handle();
EXPECT_EQ(0, array->Length());
array = ArrayList::Add(i_isolate(), array,
handle(Smi::FromInt(100), i_isolate()));
EXPECT_EQ(1, array->Length());
EXPECT_EQ(100, Smi::ToInt(array->Get(0)));
array =
ArrayList::Add(i_isolate(), array, handle(Smi::FromInt(200), i_isolate()),
handle(Smi::FromInt(300), i_isolate()));
EXPECT_EQ(3, array->Length());
EXPECT_EQ(100, Smi::ToInt(array->Get(0)));
EXPECT_EQ(200, Smi::ToInt(array->Get(1)));
EXPECT_EQ(300, Smi::ToInt(array->Get(2)));
array->Set(2, Smi::FromInt(400));
EXPECT_EQ(400, Smi::ToInt(array->Get(2)));
array->Clear(2, ReadOnlyRoots(i_isolate()).undefined_value());
array->SetLength(2);
EXPECT_EQ(2, array->Length());
EXPECT_EQ(100, Smi::ToInt(array->Get(0)));
EXPECT_EQ(200, Smi::ToInt(array->Get(1)));
}
} // namespace internal
} // namespace v8
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment