v8/test/cctest/test-array-list.cc
jochen 3cf6e040c4 Mark cctests that don't use deprecated APIs as such
BUG=4134
R=epertoso@chromium.org
LOG=n

Review URL: https://codereview.chromium.org/1451733002

Cr-Commit-Position: refs/heads/master@{#32011}
2015-11-16 16:45:31 +00:00

46 lines
1.4 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.
// TODO(jochen): Remove this after the setting is turned on globally.
#define V8_IMMINENT_DEPRECATION_WARNINGS
#include <stdlib.h>
#include "src/v8.h"
#include "src/factory.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