v8/test/cctest/test-array-list.cc
Michael Starzinger f7da4d7110 [iwyu] Remove stale TODOs about objects-inl.h inclusion.
R=marja@chromium.org

Change-Id: I93a366caded175256abd7966c3c157191a2b7de2
Reviewed-on: https://chromium-review.googlesource.com/690455
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48370}
2017-10-09 11:14:59 +00:00

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/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(isolate->heap()->empty_fixed_array()));
CHECK_EQ(0, array->Length());
array = ArrayList::Add(array, handle(Smi::FromInt(100), isolate));
CHECK_EQ(1, array->Length());
CHECK_EQ(100, Smi::ToInt(array->Get(0)));
array = ArrayList::Add(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, isolate->heap()->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