c55875b493
All auto-generated with some fix-ups including marking the following classes as NeverReadOnlySpaceObject so their GetIsolate/GetHeap methods are safe to use: Code, CodeDataContainer, AbstractCode, DeoptimizationData, CompilationCacheTable, NormalizedMapCache, Script, SharedFunctionInfo TBR=yangguo@chromium.org Bug: v8:7786 Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng Change-Id: I6cb5dcca88a0bc99b5afe80f553e06a661b5da3c Reviewed-on: https://chromium-review.googlesource.com/1135306 Commit-Queue: Dan Elphick <delphick@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/master@{#54439}
41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
// 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-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(
|
|
ArrayList::cast(ReadOnlyRoots(isolate).empty_fixed_array()), isolate);
|
|
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
|