v8/test/cctest/test-array-list.cc
ishell@chromium.org 32971301ea Rename TypeFeedbackVector to FeedbackVector.
... and TypeFeedbackMetadata to FeedbackMetadata.

BUG=

Change-Id: I2556d1c2a8f37b8cf3d532cc98d973b6dc7e9e6c
Reviewed-on: https://chromium-review.googlesource.com/439244
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Michael Stanton <mvstanton@chromium.org>
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#42999}
2017-02-07 14:46:36 +00:00

50 lines
1.7 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/v8.h"
#include "src/factory.h"
// FIXME(mstarzinger, marja): This is weird, but required because of the missing
// (disallowed) include: src/factory.h -> src/objects-inl.h
#include "src/objects-inl.h"
// FIXME(mstarzinger, marja): This is weird, but required because of the missing
// (disallowed) include: src/feedback-vector.h ->
// src/feedback-vector-inl.h
#include "src/feedback-vector-inl.h"
#include "test/cctest/cctest.h"
namespace {
using namespace v8::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::cast(array->Get(0))->value());
array = ArrayList::Add(array, handle(Smi::FromInt(200), isolate),
handle(Smi::FromInt(300), isolate));
CHECK_EQ(3, array->Length());
CHECK_EQ(100, Smi::cast(array->Get(0))->value());
CHECK_EQ(200, Smi::cast(array->Get(1))->value());
CHECK_EQ(300, Smi::cast(array->Get(2))->value());
array->Set(2, Smi::FromInt(400));
CHECK_EQ(400, Smi::cast(array->Get(2))->value());
array->Clear(2, isolate->heap()->undefined_value());
array->SetLength(2);
CHECK_EQ(2, array->Length());
CHECK_EQ(100, Smi::cast(array->Get(0))->value());
CHECK_EQ(200, Smi::cast(array->Get(1))->value());
}
} // namespace