| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 5 #ifndef V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ |
| 6 #define V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 6 #define V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 #include "test/cctest/cctest.h" | 9 #include "test/cctest/cctest.h" |
| 10 | 10 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 Handle<Object> args[] = {a, b}; | 91 Handle<Object> args[] = {a, b}; |
| 92 return Execution::Call(isolate, function, undefined(), 2, args, false); | 92 return Execution::Call(isolate, function, undefined(), 2, args, false); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void CheckThrows(Handle<Object> a, Handle<Object> b) { | 95 void CheckThrows(Handle<Object> a, Handle<Object> b) { |
| 96 TryCatch try_catch; | 96 TryCatch try_catch; |
| 97 MaybeHandle<Object> no_result = Call(a, b); | 97 MaybeHandle<Object> no_result = Call(a, b); |
| 98 CHECK(isolate->has_pending_exception()); | 98 CHECK(isolate->has_pending_exception()); |
| 99 CHECK(try_catch.HasCaught()); | 99 CHECK(try_catch.HasCaught()); |
| 100 CHECK(no_result.is_null()); | 100 CHECK(no_result.is_null()); |
| 101 // TODO(mstarzinger): Temporary workaround for issue chromium:362388. | |
| 102 isolate->OptionalRescheduleException(true); | |
| 103 } | 101 } |
| 104 | 102 |
| 105 v8::Handle<v8::Message> CheckThrowsReturnMessage(Handle<Object> a, | 103 v8::Handle<v8::Message> CheckThrowsReturnMessage(Handle<Object> a, |
| 106 Handle<Object> b) { | 104 Handle<Object> b) { |
| 107 TryCatch try_catch; | 105 TryCatch try_catch; |
| 108 MaybeHandle<Object> no_result = Call(a, b); | 106 MaybeHandle<Object> no_result = Call(a, b); |
| 109 CHECK(isolate->has_pending_exception()); | 107 CHECK(isolate->has_pending_exception()); |
| 110 CHECK(try_catch.HasCaught()); | 108 CHECK(try_catch.HasCaught()); |
| 111 CHECK(no_result.is_null()); | 109 CHECK(no_result.is_null()); |
| 112 // TODO(mstarzinger): Calling OptionalRescheduleException is a dirty hack, | |
| 113 // it's the only way to make Message() not to assert because an external | |
| 114 // exception has been caught by the try_catch. | |
| 115 isolate->OptionalRescheduleException(true); | |
| 116 return try_catch.Message(); | 110 return try_catch.Message(); |
| 117 } | 111 } |
| 118 | 112 |
| 119 void CheckCall(Handle<Object> expected, Handle<Object> a, Handle<Object> b) { | 113 void CheckCall(Handle<Object> expected, Handle<Object> a, Handle<Object> b) { |
| 120 Handle<Object> result = Call(a, b).ToHandleChecked(); | 114 Handle<Object> result = Call(a, b).ToHandleChecked(); |
| 121 CHECK(expected->SameValue(*result)); | 115 CHECK(expected->SameValue(*result)); |
| 122 } | 116 } |
| 123 | 117 |
| 124 void CheckCall(Handle<Object> expected, Handle<Object> a) { | 118 void CheckCall(Handle<Object> expected, Handle<Object> a) { |
| 125 CheckCall(expected, a, undefined()); | 119 CheckCall(expected, a, undefined()); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 179 |
| 186 Handle<Object> true_value() { return isolate->factory()->true_value(); } | 180 Handle<Object> true_value() { return isolate->factory()->true_value(); } |
| 187 | 181 |
| 188 Handle<Object> false_value() { return isolate->factory()->false_value(); } | 182 Handle<Object> false_value() { return isolate->factory()->false_value(); } |
| 189 }; | 183 }; |
| 190 } | 184 } |
| 191 } | 185 } |
| 192 } // namespace v8::internal::compiler | 186 } // namespace v8::internal::compiler |
| 193 | 187 |
| 194 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 188 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ |
| OLD | NEW |