OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "include/libplatform/libplatform.h" | 5 #include "include/libplatform/libplatform.h" |
6 #include "src/isolate-inl.h" | 6 #include "src/isolate-inl.h" |
7 #include "test/compiler-unittests/compiler-unittests.h" | 7 #include "test/runtime-unittests/runtime-unittests.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 | 9 |
10 using testing::IsNull; | 10 using testing::IsNull; |
11 using testing::NotNull; | 11 using testing::NotNull; |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 namespace compiler { | |
16 | 15 |
17 // static | 16 // static |
18 v8::Isolate* CompilerTest::isolate_ = NULL; | 17 v8::Isolate* RuntimeTest::isolate_ = NULL; |
19 | 18 |
20 | 19 |
21 CompilerTest::CompilerTest() | 20 RuntimeTest::RuntimeTest() |
22 : isolate_scope_(isolate_), | 21 : isolate_scope_(isolate_), handle_scope_(isolate_), zone_(isolate()) {} |
23 handle_scope_(isolate_), | |
24 context_scope_(v8::Context::New(isolate_)), | |
25 zone_(isolate()) {} | |
26 | 22 |
27 | 23 |
28 CompilerTest::~CompilerTest() {} | 24 RuntimeTest::~RuntimeTest() {} |
29 | 25 |
30 | 26 |
31 Factory* CompilerTest::factory() const { return isolate()->factory(); } | 27 Factory* RuntimeTest::factory() const { return isolate()->factory(); } |
| 28 |
| 29 |
| 30 Heap* RuntimeTest::heap() const { return isolate()->heap(); } |
32 | 31 |
33 | 32 |
34 // static | 33 // static |
35 void CompilerTest::SetUpTestCase() { | 34 void RuntimeTest::SetUpTestCase() { |
36 Test::SetUpTestCase(); | 35 Test::SetUpTestCase(); |
37 EXPECT_THAT(isolate_, IsNull()); | 36 EXPECT_THAT(isolate_, IsNull()); |
38 isolate_ = v8::Isolate::New(); | 37 isolate_ = v8::Isolate::New(); |
39 ASSERT_THAT(isolate_, NotNull()); | 38 ASSERT_THAT(isolate_, NotNull()); |
40 } | 39 } |
41 | 40 |
42 | 41 |
43 // static | 42 // static |
44 void CompilerTest::TearDownTestCase() { | 43 void RuntimeTest::TearDownTestCase() { |
45 ASSERT_THAT(isolate_, NotNull()); | 44 ASSERT_THAT(isolate_, NotNull()); |
46 isolate_->Dispose(); | 45 isolate_->Dispose(); |
47 isolate_ = NULL; | 46 isolate_ = NULL; |
48 Test::TearDownTestCase(); | 47 Test::TearDownTestCase(); |
49 } | 48 } |
50 | 49 |
51 } // namespace compiler | |
52 } // namespace internal | 50 } // namespace internal |
53 } // namespace v8 | 51 } // namespace v8 |
54 | 52 |
55 | 53 |
56 namespace { | 54 namespace { |
57 | 55 |
58 class CompilerTestEnvironment V8_FINAL : public ::testing::Environment { | 56 class RuntimeTestEnvironment V8_FINAL : public ::testing::Environment { |
59 public: | 57 public: |
60 CompilerTestEnvironment() : platform_(NULL) {} | 58 RuntimeTestEnvironment() : platform_(NULL) {} |
61 ~CompilerTestEnvironment() {} | 59 virtual ~RuntimeTestEnvironment() {} |
62 | 60 |
63 virtual void SetUp() V8_OVERRIDE { | 61 virtual void SetUp() V8_OVERRIDE { |
64 EXPECT_THAT(platform_, IsNull()); | 62 EXPECT_THAT(platform_, IsNull()); |
65 platform_ = v8::platform::CreateDefaultPlatform(); | 63 platform_ = v8::platform::CreateDefaultPlatform(); |
66 v8::V8::InitializePlatform(platform_); | 64 v8::V8::InitializePlatform(platform_); |
67 ASSERT_TRUE(v8::V8::Initialize()); | 65 ASSERT_TRUE(v8::V8::Initialize()); |
68 } | 66 } |
69 | 67 |
70 virtual void TearDown() V8_OVERRIDE { | 68 virtual void TearDown() V8_OVERRIDE { |
71 ASSERT_THAT(platform_, NotNull()); | 69 ASSERT_THAT(platform_, NotNull()); |
72 v8::V8::Dispose(); | 70 v8::V8::Dispose(); |
73 v8::V8::ShutdownPlatform(); | 71 v8::V8::ShutdownPlatform(); |
74 delete platform_; | 72 delete platform_; |
75 platform_ = NULL; | 73 platform_ = NULL; |
76 } | 74 } |
77 | 75 |
78 private: | 76 private: |
79 v8::Platform* platform_; | 77 v8::Platform* platform_; |
80 }; | 78 }; |
81 | 79 |
82 } | 80 } // namespace |
83 | 81 |
84 | 82 |
85 int main(int argc, char** argv) { | 83 int main(int argc, char** argv) { |
86 testing::InitGoogleMock(&argc, argv); | 84 testing::InitGoogleMock(&argc, argv); |
87 testing::AddGlobalTestEnvironment(new CompilerTestEnvironment); | 85 testing::AddGlobalTestEnvironment(new RuntimeTestEnvironment); |
88 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); | 86 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); |
89 return RUN_ALL_TESTS(); | 87 return RUN_ALL_TESTS(); |
90 } | 88 } |
OLD | NEW |