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 "platform/globals.h" | 10 #include "platform/globals.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 CodeGenTestGenerate##name(&__test__); \ | 83 CodeGenTestGenerate##name(&__test__); \ |
84 __test__.Compile(); \ | 84 __test__.Compile(); \ |
85 CodeGenTestRun##name(__test__.function()); \ | 85 CodeGenTestRun##name(__test__.function()); \ |
86 } \ | 86 } \ |
87 static void CodeGenTestRun##name(const Function& function) { \ | 87 static void CodeGenTestRun##name(const Function& function) { \ |
88 Object& result = Object::Handle(); \ | 88 Object& result = Object::Handle(); \ |
89 result = DartEntry::InvokeFunction(function, Object::empty_array()); \ | 89 result = DartEntry::InvokeFunction(function, Object::empty_array()); \ |
90 EXPECT(!result.IsError()); \ | 90 EXPECT(!result.IsError()); \ |
91 Instance& actual = Instance::Handle(); \ | 91 Instance& actual = Instance::Handle(); \ |
92 actual ^= result.raw(); \ | 92 actual ^= result.raw(); \ |
93 EXPECT(actual.Equals(Instance::Handle(expected))); \ | 93 EXPECT(actual.CanonicalizeEquals(Instance::Handle(expected))); \ |
94 } | 94 } |
95 | 95 |
96 | 96 |
97 // Pass the name of test, and use the generated function to call it | 97 // Pass the name of test, and use the generated function to call it |
98 // and evaluate its result. | 98 // and evaluate its result. |
99 #define CODEGEN_TEST_RAW_RUN(name, function) \ | 99 #define CODEGEN_TEST_RAW_RUN(name, function) \ |
100 static void CodeGenTestRun##name(const Function& function); \ | 100 static void CodeGenTestRun##name(const Function& function); \ |
101 TEST_CASE(name) { \ | 101 TEST_CASE(name) { \ |
102 CodeGenTest __test__(""#name); \ | 102 CodeGenTest __test__(""#name); \ |
103 CodeGenTestGenerate##name(&__test__); \ | 103 CodeGenTestGenerate##name(&__test__); \ |
(...skipping 17 matching lines...) Expand all Loading... |
121 CodeGenTestGenerate##name1(__test2__.function(), &__test1__); \ | 121 CodeGenTestGenerate##name1(__test2__.function(), &__test1__); \ |
122 __test1__.Compile(); \ | 122 __test1__.Compile(); \ |
123 CodeGenTestRun##name1(__test1__.function()); \ | 123 CodeGenTestRun##name1(__test1__.function()); \ |
124 } \ | 124 } \ |
125 static void CodeGenTestRun##name1(const Function& function) { \ | 125 static void CodeGenTestRun##name1(const Function& function) { \ |
126 Object& result = Object::Handle(); \ | 126 Object& result = Object::Handle(); \ |
127 result = DartEntry::InvokeFunction(function, Object::empty_array()); \ | 127 result = DartEntry::InvokeFunction(function, Object::empty_array()); \ |
128 EXPECT(!result.IsError()); \ | 128 EXPECT(!result.IsError()); \ |
129 Instance& actual = Instance::Handle(); \ | 129 Instance& actual = Instance::Handle(); \ |
130 actual ^= result.raw(); \ | 130 actual ^= result.raw(); \ |
131 EXPECT(actual.Equals(Instance::Handle(expected))); \ | 131 EXPECT(actual.CanonicalizeEquals(Instance::Handle(expected))); \ |
132 } | 132 } |
133 | 133 |
134 | 134 |
135 #if defined(TARGET_ARCH_ARM) || \ | 135 #if defined(TARGET_ARCH_ARM) || \ |
136 defined(TARGET_ARCH_MIPS) || \ | 136 defined(TARGET_ARCH_MIPS) || \ |
137 defined(TARGET_ARCH_ARM64) | 137 defined(TARGET_ARCH_ARM64) |
138 #if defined(HOST_ARCH_ARM) || \ | 138 #if defined(HOST_ARCH_ARM) || \ |
139 defined(HOST_ARCH_MIPS) || \ | 139 defined(HOST_ARCH_MIPS) || \ |
140 defined(HOST_ARCH_ARM64) | 140 defined(HOST_ARCH_ARM64) |
141 // Running on actual ARM or MIPS hardware, execute code natively. | 141 // Running on actual ARM or MIPS hardware, execute code natively. |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 } \ | 398 } \ |
399 } else { \ | 399 } else { \ |
400 dart::Expect(__FILE__, __LINE__).Fail("expected True, but was '%s'\n", \ | 400 dart::Expect(__FILE__, __LINE__).Fail("expected True, but was '%s'\n", \ |
401 #handle); \ | 401 #handle); \ |
402 } \ | 402 } \ |
403 } while (0) | 403 } while (0) |
404 | 404 |
405 } // namespace dart | 405 } // namespace dart |
406 | 406 |
407 #endif // VM_UNIT_TEST_H_ | 407 #endif // VM_UNIT_TEST_H_ |
OLD | NEW |