OLD | NEW |
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 static void CodeGenTestRun##name(const Function& function); \ | 71 static void CodeGenTestRun##name(const Function& function); \ |
72 TEST_CASE(name) { \ | 72 TEST_CASE(name) { \ |
73 CodeGenTest __test__(""#name); \ | 73 CodeGenTest __test__(""#name); \ |
74 CodeGenTestGenerate##name(&__test__); \ | 74 CodeGenTestGenerate##name(&__test__); \ |
75 __test__.Compile(); \ | 75 __test__.Compile(); \ |
76 CodeGenTestRun##name(__test__.function()); \ | 76 CodeGenTestRun##name(__test__.function()); \ |
77 } \ | 77 } \ |
78 static void CodeGenTestRun##name(const Function& function) { \ | 78 static void CodeGenTestRun##name(const Function& function) { \ |
79 GrowableArray<const Object*> arguments; \ | 79 GrowableArray<const Object*> arguments; \ |
80 const Array& kNoArgumentNames = Array::Handle(); \ | 80 const Array& kNoArgumentNames = Array::Handle(); \ |
81 Instance& result = Instance::Handle(); \ | 81 Object& result = Object::Handle(); \ |
82 result = DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); \ | 82 result = DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); \ |
83 EXPECT(result.Equals(Instance::Handle(expected))); \ | 83 EXPECT(!result.IsError()); \ |
| 84 Instance& actual = Instance::Handle(); \ |
| 85 actual ^= result.raw(); \ |
| 86 EXPECT(actual.Equals(Instance::Handle(expected))); \ |
84 } | 87 } |
85 | 88 |
86 | 89 |
87 // Pass the name of test, and use the generated function to call it | 90 // Pass the name of test, and use the generated function to call it |
88 // and evaluate its result. | 91 // and evaluate its result. |
89 #define CODEGEN_TEST_RAW_RUN(name, function) \ | 92 #define CODEGEN_TEST_RAW_RUN(name, function) \ |
90 static void CodeGenTestRun##name(const Function& function); \ | 93 static void CodeGenTestRun##name(const Function& function); \ |
91 TEST_CASE(name) { \ | 94 TEST_CASE(name) { \ |
92 CodeGenTest __test__(""#name); \ | 95 CodeGenTest __test__(""#name); \ |
93 CodeGenTestGenerate##name(&__test__); \ | 96 CodeGenTestGenerate##name(&__test__); \ |
(...skipping 14 matching lines...) Expand all Loading... |
108 __test2__.Compile(); \ | 111 __test2__.Compile(); \ |
109 /* Generate code for name1, providing function2 */ \ | 112 /* Generate code for name1, providing function2 */ \ |
110 CodeGenTest __test1__(""#name1); \ | 113 CodeGenTest __test1__(""#name1); \ |
111 CodeGenTestGenerate##name1(__test2__.function(), &__test1__); \ | 114 CodeGenTestGenerate##name1(__test2__.function(), &__test1__); \ |
112 __test1__.Compile(); \ | 115 __test1__.Compile(); \ |
113 CodeGenTestRun##name1(__test1__.function()); \ | 116 CodeGenTestRun##name1(__test1__.function()); \ |
114 } \ | 117 } \ |
115 static void CodeGenTestRun##name1(const Function& function) { \ | 118 static void CodeGenTestRun##name1(const Function& function) { \ |
116 GrowableArray<const Object*> arguments; \ | 119 GrowableArray<const Object*> arguments; \ |
117 const Array& kNoArgumentNames = Array::Handle(); \ | 120 const Array& kNoArgumentNames = Array::Handle(); \ |
118 Instance& result = Instance::Handle(); \ | 121 Object& result = Object::Handle(); \ |
119 result = DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); \ | 122 result = DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); \ |
120 EXPECT(result.Equals(Instance::Handle(expected))); \ | 123 EXPECT(!result.IsError()); \ |
| 124 Instance& actual = Instance::Handle(); \ |
| 125 actual ^= result.raw(); \ |
| 126 EXPECT(actual.Equals(Instance::Handle(expected))); \ |
121 } | 127 } |
122 | 128 |
123 | 129 |
124 namespace dart { | 130 namespace dart { |
125 | 131 |
126 // Forward declarations. | 132 // Forward declarations. |
127 class Assembler; | 133 class Assembler; |
128 class CodeGenerator; | 134 class CodeGenerator; |
129 class VirtualMemory; | 135 class VirtualMemory; |
130 | 136 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 279 |
274 #define EXPECT_VALID(handle) \ | 280 #define EXPECT_VALID(handle) \ |
275 if (Dart_IsError((handle))) { \ | 281 if (Dart_IsError((handle))) { \ |
276 dart::Expect(__FILE__, __LINE__).Fail("invalid handle '%s':\n '%s'\n", \ | 282 dart::Expect(__FILE__, __LINE__).Fail("invalid handle '%s':\n '%s'\n", \ |
277 #handle, Dart_GetError(handle)); \ | 283 #handle, Dart_GetError(handle)); \ |
278 } | 284 } |
279 | 285 |
280 } // namespace dart | 286 } // namespace dart |
281 | 287 |
282 #endif // VM_UNIT_TEST_H_ | 288 #endif // VM_UNIT_TEST_H_ |
OLD | NEW |