Chromium Code Reviews| 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" |
| 11 #include "vm/dart.h" | 11 #include "vm/dart.h" |
| 12 #include "vm/globals.h" | 12 #include "vm/globals.h" |
| 13 #include "vm/heap.h" | 13 #include "vm/heap.h" |
| 14 #include "vm/isolate.h" | 14 #include "vm/isolate.h" |
| 15 #include "vm/longjump.h" | 15 #include "vm/longjump.h" |
| 16 #include "vm/object.h" | 16 #include "vm/object.h" |
| 17 #include "vm/object_store.h" | 17 #include "vm/object_store.h" |
| 18 #include "vm/simulator.h" | |
| 18 #include "vm/zone.h" | 19 #include "vm/zone.h" |
| 19 | 20 |
| 20 // The UNIT_TEST_CASE macro is used for tests that do not need any | 21 // The UNIT_TEST_CASE macro is used for tests that do not need any |
| 21 // default isolate or zone functionality. | 22 // default isolate or zone functionality. |
| 22 #define UNIT_TEST_CASE(name) \ | 23 #define UNIT_TEST_CASE(name) \ |
| 23 void Dart_Test##name(); \ | 24 void Dart_Test##name(); \ |
| 24 static const dart::TestCase kRegister##name(Dart_Test##name, #name); \ | 25 static const dart::TestCase kRegister##name(Dart_Test##name, #name); \ |
| 25 void Dart_Test##name() | 26 void Dart_Test##name() |
| 26 | 27 |
| 27 // The TEST_CASE macro is used for tests that need an isolate and zone | 28 // The TEST_CASE macro is used for tests that need an isolate and zone |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 static void CodeGenTestRun##name1(const Function& function) { \ | 122 static void CodeGenTestRun##name1(const Function& function) { \ |
| 122 Object& result = Object::Handle(); \ | 123 Object& result = Object::Handle(); \ |
| 123 result = DartEntry::InvokeStatic(function, Object::empty_array()); \ | 124 result = DartEntry::InvokeStatic(function, Object::empty_array()); \ |
| 124 EXPECT(!result.IsError()); \ | 125 EXPECT(!result.IsError()); \ |
| 125 Instance& actual = Instance::Handle(); \ | 126 Instance& actual = Instance::Handle(); \ |
| 126 actual ^= result.raw(); \ | 127 actual ^= result.raw(); \ |
| 127 EXPECT(actual.Equals(Instance::Handle(expected))); \ | 128 EXPECT(actual.Equals(Instance::Handle(expected))); \ |
| 128 } | 129 } |
| 129 | 130 |
| 130 | 131 |
| 132 #if defined(HOST_ARCH_ARM) || defined(HOST_ARCH_MIPS) | |
|
Ivan Posva
2013/02/06 23:33:50
This whole section is only valid when TARGET_ARCH_
regis
2013/02/07 00:53:24
Done.
| |
| 133 // Running on actual ARM or MIPS hardware, execute code natively. | |
| 134 #define EXECUTE_TEST_CODE_INT32(name, entry) reinterpret_cast<name>(entry)() | |
| 135 #define EXECUTE_TEST_CODE_INT64_LL(name, entry, long_arg0, long_arg1) \ | |
| 136 reinterpret_cast<name>(entry)(long_arg0, long_arg1) | |
| 137 #define EXECUTE_TEST_CODE_FLOAT(name, entry) reinterpret_cast<name>(entry)() | |
| 138 #define EXECUTE_TEST_CODE_DOUBLE(name, entry) reinterpret_cast<name>(entry)() | |
| 139 #define EXECUTE_TEST_CODE_INT32_F(name, entry, float_arg) \ | |
| 140 reinterpret_cast<name>(entry)(float_arg) | |
| 141 #define EXECUTE_TEST_CODE_INT32_D(name, entry, double_arg) \ | |
| 142 reinterpret_cast<name>(entry)(double_arg) | |
| 143 #else | |
| 144 // Not running on ARM or MIPS hardware, call simulator to execute code. | |
| 145 #define EXECUTE_TEST_CODE_INT32(name, entry) \ | |
| 146 static_cast<int32_t>(Simulator::Current()->Call((int32_t)entry, \ | |
| 147 0, 0, 0, 0, 0)) | |
| 148 #define EXECUTE_TEST_CODE_INT64_LL(name, entry, long_arg0, long_arg1) \ | |
| 149 static_cast<int64_t>(Simulator::Current()->Call((int32_t)entry, \ | |
| 150 Utils::Low32Bits(long_arg0), \ | |
| 151 Utils::High32Bits(long_arg0), \ | |
| 152 Utils::Low32Bits(long_arg1), \ | |
| 153 Utils::High32Bits(long_arg1), \ | |
| 154 0)) | |
| 155 #define EXECUTE_TEST_CODE_FLOAT(name, entry) \ | |
| 156 bit_cast<float, int32_t>(Simulator::Current()->Call((int32_t)entry, \ | |
| 157 0, 0, 0, 0, 0)) | |
| 158 #define EXECUTE_TEST_CODE_DOUBLE(name, entry) \ | |
| 159 bit_cast<double, int64_t>(Simulator::Current()->Call((int32_t)entry, \ | |
| 160 0, 0, 0, 0, 0)) | |
| 161 #define EXECUTE_TEST_CODE_INT32_F(name, entry, float_arg) \ | |
| 162 static_cast<int32_t>(Simulator::Current()->Call((int32_t)entry, \ | |
| 163 bit_cast<int32_t, float>(float_arg), \ | |
| 164 0, 0, 0, 0)) | |
| 165 #define EXECUTE_TEST_CODE_INT32_D(name, entry, double_arg) \ | |
| 166 static_cast<int32_t>(Simulator::Current()->Call((int32_t)entry, \ | |
| 167 Utils::Low32Bits(bit_cast<int64_t, double>(double_arg)), \ | |
| 168 Utils::High32Bits(bit_cast<int64_t, double>(double_arg)), \ | |
| 169 0, 0, 0)) | |
| 170 #endif // defined(HOST_ARCH_ARM) || defined(HOST_ARCH_MIPS) | |
| 171 | |
| 172 | |
| 131 inline Dart_Handle NewString(const char* str) { | 173 inline Dart_Handle NewString(const char* str) { |
| 132 return Dart_NewStringFromCString(str); | 174 return Dart_NewStringFromCString(str); |
| 133 } | 175 } |
| 134 | 176 |
| 135 | 177 |
| 136 namespace dart { | 178 namespace dart { |
| 137 | 179 |
| 138 // Forward declarations. | 180 // Forward declarations. |
| 139 class Assembler; | 181 class Assembler; |
| 140 class CodeGenerator; | 182 class CodeGenerator; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 } else { \ | 347 } else { \ |
| 306 dart::Expect(__FILE__, __LINE__).Fail( \ | 348 dart::Expect(__FILE__, __LINE__).Fail( \ |
| 307 "expected '%s' to be an error handle but found a valid handle.\n", \ | 349 "expected '%s' to be an error handle but found a valid handle.\n", \ |
| 308 #handle); \ | 350 #handle); \ |
| 309 } \ | 351 } \ |
| 310 } while (0) | 352 } while (0) |
| 311 | 353 |
| 312 } // namespace dart | 354 } // namespace dart |
| 313 | 355 |
| 314 #endif // VM_UNIT_TEST_H_ | 356 #endif // VM_UNIT_TEST_H_ |
| OLD | NEW |