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

Side by Side Diff: vm/unit_test.h

Issue 11648006: Create read only handles for empty_array and sentinel objects (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years 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 | « vm/symbols.cc ('k') | no next file » | 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // Pass the name of test and the expected results as RawObject. 74 // Pass the name of test and the expected results as RawObject.
75 #define CODEGEN_TEST_RUN(name, expected) \ 75 #define CODEGEN_TEST_RUN(name, expected) \
76 static void CodeGenTestRun##name(const Function& function); \ 76 static void CodeGenTestRun##name(const Function& function); \
77 TEST_CASE(name) { \ 77 TEST_CASE(name) { \
78 CodeGenTest __test__(""#name); \ 78 CodeGenTest __test__(""#name); \
79 CodeGenTestGenerate##name(&__test__); \ 79 CodeGenTestGenerate##name(&__test__); \
80 __test__.Compile(); \ 80 __test__.Compile(); \
81 CodeGenTestRun##name(__test__.function()); \ 81 CodeGenTestRun##name(__test__.function()); \
82 } \ 82 } \
83 static void CodeGenTestRun##name(const Function& function) { \ 83 static void CodeGenTestRun##name(const Function& function) { \
84 const Array& args = Array::Handle(Object::empty_array()); \
85 Object& result = Object::Handle(); \ 84 Object& result = Object::Handle(); \
86 result = DartEntry::InvokeStatic(function, args); \ 85 result = DartEntry::InvokeStatic(function, Object::empty_array()); \
87 EXPECT(!result.IsError()); \ 86 EXPECT(!result.IsError()); \
88 Instance& actual = Instance::Handle(); \ 87 Instance& actual = Instance::Handle(); \
89 actual ^= result.raw(); \ 88 actual ^= result.raw(); \
90 EXPECT(actual.Equals(Instance::Handle(expected))); \ 89 EXPECT(actual.Equals(Instance::Handle(expected))); \
91 } 90 }
92 91
93 92
94 // Pass the name of test, and use the generated function to call it 93 // Pass the name of test, and use the generated function to call it
95 // and evaluate its result. 94 // and evaluate its result.
96 #define CODEGEN_TEST_RAW_RUN(name, function) \ 95 #define CODEGEN_TEST_RAW_RUN(name, function) \
(...skipping 16 matching lines...) Expand all
113 CodeGenTest __test2__(""#name2); \ 112 CodeGenTest __test2__(""#name2); \
114 CodeGenTestGenerate##name2(&__test2__); \ 113 CodeGenTestGenerate##name2(&__test2__); \
115 __test2__.Compile(); \ 114 __test2__.Compile(); \
116 /* Generate code for name1, providing function2 */ \ 115 /* Generate code for name1, providing function2 */ \
117 CodeGenTest __test1__(""#name1); \ 116 CodeGenTest __test1__(""#name1); \
118 CodeGenTestGenerate##name1(__test2__.function(), &__test1__); \ 117 CodeGenTestGenerate##name1(__test2__.function(), &__test1__); \
119 __test1__.Compile(); \ 118 __test1__.Compile(); \
120 CodeGenTestRun##name1(__test1__.function()); \ 119 CodeGenTestRun##name1(__test1__.function()); \
121 } \ 120 } \
122 static void CodeGenTestRun##name1(const Function& function) { \ 121 static void CodeGenTestRun##name1(const Function& function) { \
123 const Array& args = Array::Handle(Object::empty_array()); \
124 Object& result = Object::Handle(); \ 122 Object& result = Object::Handle(); \
125 result = DartEntry::InvokeStatic(function, args); \ 123 result = DartEntry::InvokeStatic(function, Object::empty_array()); \
126 EXPECT(!result.IsError()); \ 124 EXPECT(!result.IsError()); \
127 Instance& actual = Instance::Handle(); \ 125 Instance& actual = Instance::Handle(); \
128 actual ^= result.raw(); \ 126 actual ^= result.raw(); \
129 EXPECT(actual.Equals(Instance::Handle(expected))); \ 127 EXPECT(actual.Equals(Instance::Handle(expected))); \
130 } 128 }
131 129
132 130
133 inline Dart_Handle NewString(const char* str) { 131 inline Dart_Handle NewString(const char* str) {
134 return Dart_NewStringFromCString(str); 132 return Dart_NewStringFromCString(str);
135 } 133 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 } else { \ 305 } else { \
308 dart::Expect(__FILE__, __LINE__).Fail( \ 306 dart::Expect(__FILE__, __LINE__).Fail( \
309 "expected '%s' to be an error handle but found a valid handle.\n", \ 307 "expected '%s' to be an error handle but found a valid handle.\n", \
310 #handle); \ 308 #handle); \
311 } \ 309 } \
312 } while (0) 310 } while (0)
313 311
314 } // namespace dart 312 } // namespace dart
315 313
316 #endif // VM_UNIT_TEST_H_ 314 #endif // VM_UNIT_TEST_H_
OLDNEW
« no previous file with comments | « vm/symbols.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698