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

Side by Side Diff: runtime/vm/unit_test.h

Issue 8528010: Changes to pass the current isolate to all runtime and native calls. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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 | « runtime/vm/thread.h ('k') | runtime/vm/zone.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_UNIT_TEST_H_ 5 #ifndef VM_UNIT_TEST_H_
6 #define VM_UNIT_TEST_H_ 6 #define VM_UNIT_TEST_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 9
10 #include "vm/ast.h" 10 #include "vm/ast.h"
(...skipping 13 matching lines...) Expand all
24 static const dart::TestCase kRegister##name(Dart_Test##name, #name); \ 24 static const dart::TestCase kRegister##name(Dart_Test##name, #name); \
25 void Dart_Test##name() 25 void Dart_Test##name()
26 26
27 // The TEST_CASE macro is used for tests that need an isolate and zone 27 // The TEST_CASE macro is used for tests that need an isolate and zone
28 // in order to test its functionality. 28 // in order to test its functionality.
29 #define TEST_CASE(name) \ 29 #define TEST_CASE(name) \
30 static void Dart_TestHelper##name(); \ 30 static void Dart_TestHelper##name(); \
31 UNIT_TEST_CASE(name) \ 31 UNIT_TEST_CASE(name) \
32 { \ 32 { \
33 TestIsolateScope __test_isolate__; \ 33 TestIsolateScope __test_isolate__; \
34 Zone __zone__; \ 34 Zone __zone__(__test_isolate__.isolate()); \
35 HandleScope __hs__; \ 35 HandleScope __hs__(__test_isolate__.isolate()); \
36 Dart_TestHelper##name(); \ 36 Dart_TestHelper##name(); \
37 } \ 37 } \
38 static void Dart_TestHelper##name() 38 static void Dart_TestHelper##name()
39 39
40 // The ASSEMBLER_TEST_GENERATE macro is used to generate a unit test 40 // The ASSEMBLER_TEST_GENERATE macro is used to generate a unit test
41 // for the assembler. 41 // for the assembler.
42 #define ASSEMBLER_TEST_GENERATE(name, assembler) \ 42 #define ASSEMBLER_TEST_GENERATE(name, assembler) \
43 static void AssemblerTestGenerate##name(Assembler* assembler) 43 static void AssemblerTestGenerate##name(Assembler* assembler)
44 44
45 // The ASSEMBLER_TEST_RUN macro is used to execute the assembler unit 45 // The ASSEMBLER_TEST_RUN macro is used to execute the assembler unit
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 isolate_ = reinterpret_cast<Isolate*>(Dart_CreateIsolate(NULL, NULL)); 176 isolate_ = reinterpret_cast<Isolate*>(Dart_CreateIsolate(NULL, NULL));
177 EXPECT(isolate_ != NULL); 177 EXPECT(isolate_ != NULL);
178 Dart_EnterScope(); // Create a Dart API scope for unit tests. 178 Dart_EnterScope(); // Create a Dart API scope for unit tests.
179 } 179 }
180 ~TestIsolateScope() { 180 ~TestIsolateScope() {
181 Dart_ExitScope(); // Exit the Dart API scope created for unit tests. 181 Dart_ExitScope(); // Exit the Dart API scope created for unit tests.
182 ASSERT(isolate_ == Isolate::Current()); 182 ASSERT(isolate_ == Isolate::Current());
183 Dart_ShutdownIsolate(); 183 Dart_ShutdownIsolate();
184 isolate_ = NULL; 184 isolate_ = NULL;
185 } 185 }
186 Isolate* isolate() const { return isolate_; }
186 187
187 private: 188 private:
188 Isolate* isolate_; 189 Isolate* isolate_;
189 190
190 DISALLOW_COPY_AND_ASSIGN(TestIsolateScope); 191 DISALLOW_COPY_AND_ASSIGN(TestIsolateScope);
191 }; 192 };
192 193
193 194
194 class AssemblerTest { 195 class AssemblerTest {
195 public: 196 public:
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 254
254 #define EXPECT_VALID(handle) \ 255 #define EXPECT_VALID(handle) \
255 if (Dart_IsError((handle))) { \ 256 if (Dart_IsError((handle))) { \
256 dart::Expect(__FILE__, __LINE__).Fail("invalid handle '%s':\n '%s'\n", \ 257 dart::Expect(__FILE__, __LINE__).Fail("invalid handle '%s':\n '%s'\n", \
257 #handle, Dart_GetError(handle)); \ 258 #handle, Dart_GetError(handle)); \
258 } 259 }
259 260
260 } // namespace dart 261 } // namespace dart
261 262
262 #endif // VM_UNIT_TEST_H_ 263 #endif // VM_UNIT_TEST_H_
OLDNEW
« no previous file with comments | « runtime/vm/thread.h ('k') | runtime/vm/zone.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698