// 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 "test/unittests/test-utils.h" #include "include/libplatform/libplatform.h" #include "include/v8.h" #include "src/api-inl.h" #include "src/base/platform/time.h" #include "src/flags.h" #include "src/isolate.h" #include "src/objects-inl.h" #include "src/v8.h" namespace v8 { // static v8::ArrayBuffer::Allocator* TestWithIsolate::array_buffer_allocator_ = nullptr; // static Isolate* TestWithIsolate::isolate_ = nullptr; TestWithIsolate::TestWithIsolate() : isolate_scope_(isolate()), handle_scope_(isolate()) {} TestWithIsolate::~TestWithIsolate() {} // static void TestWithIsolate::SetUpTestCase() { Test::SetUpTestCase(); EXPECT_EQ(NULL, isolate_); // Make BigInt64Array / BigUint64Array available for testing. i::FLAG_harmony_bigint = true; v8::Isolate::CreateParams create_params; array_buffer_allocator_ = v8::ArrayBuffer::Allocator::NewDefaultAllocator(); create_params.array_buffer_allocator = array_buffer_allocator_; isolate_ = v8::Isolate::New(create_params); EXPECT_TRUE(isolate_ != NULL); } // static void TestWithIsolate::TearDownTestCase() { ASSERT_TRUE(isolate_ != NULL); v8::Platform* platform = internal::V8::GetCurrentPlatform(); ASSERT_TRUE(platform != NULL); while (platform::PumpMessageLoop(platform, isolate_)) continue; isolate_->Dispose(); isolate_ = NULL; delete array_buffer_allocator_; Test::TearDownTestCase(); } Local TestWithIsolate::RunJS(const char* source) { Local