Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/compiler/compiler-unittests.cc

Issue 540823002: Refactor common unit test code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixes Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler/compiler-unittests.h ('k') | src/compiler/graph-unittest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "include/libplatform/libplatform.h"
6 #include "src/compiler/compiler-unittests.h"
7 #include "src/isolate-inl.h"
8 #include "testing/gmock/include/gmock/gmock.h"
9
10 using testing::IsNull;
11 using testing::NotNull;
12
13 namespace v8 {
14 namespace internal {
15 namespace compiler {
16
17 // static
18 v8::Isolate* CompilerTest::isolate_ = NULL;
19
20
21 CompilerTest::CompilerTest()
22 : isolate_scope_(isolate_),
23 handle_scope_(isolate_),
24 context_scope_(v8::Context::New(isolate_)),
25 zone_(isolate()) {}
26
27
28 CompilerTest::~CompilerTest() {}
29
30
31 Factory* CompilerTest::factory() const { return isolate()->factory(); }
32
33
34 // static
35 void CompilerTest::SetUpTestCase() {
36 Test::SetUpTestCase();
37 EXPECT_THAT(isolate_, IsNull());
38 isolate_ = v8::Isolate::New();
39 ASSERT_THAT(isolate_, NotNull());
40 }
41
42
43 // static
44 void CompilerTest::TearDownTestCase() {
45 ASSERT_THAT(isolate_, NotNull());
46 isolate_->Dispose();
47 isolate_ = NULL;
48 Test::TearDownTestCase();
49 }
50
51 } // namespace compiler
52 } // namespace internal
53 } // namespace v8
54
55
56 namespace {
57
58 class CompilerTestEnvironment FINAL : public ::testing::Environment {
59 public:
60 CompilerTestEnvironment() : platform_(NULL) {}
61 ~CompilerTestEnvironment() {}
62
63 virtual void SetUp() OVERRIDE {
64 EXPECT_THAT(platform_, IsNull());
65 platform_ = v8::platform::CreateDefaultPlatform();
66 v8::V8::InitializePlatform(platform_);
67 ASSERT_TRUE(v8::V8::Initialize());
68 }
69
70 virtual void TearDown() OVERRIDE {
71 ASSERT_THAT(platform_, NotNull());
72 v8::V8::Dispose();
73 v8::V8::ShutdownPlatform();
74 delete platform_;
75 platform_ = NULL;
76 }
77
78 private:
79 v8::Platform* platform_;
80 };
81
82 } // namespace
83
84
85 int main(int argc, char** argv) {
86 testing::InitGoogleMock(&argc, argv);
87 testing::AddGlobalTestEnvironment(new CompilerTestEnvironment);
88 v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
89 return RUN_ALL_TESTS();
90 }
OLDNEW
« no previous file with comments | « src/compiler/compiler-unittests.h ('k') | src/compiler/graph-unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698