| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 Handle<Object> args[] = {a, b}; | 54 Handle<Object> args[] = {a, b}; |
| 55 return Execution::Call(isolate, function, undefined(), 2, args, false); | 55 return Execution::Call(isolate, function, undefined(), 2, args, false); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void CheckThrows(Handle<Object> a, Handle<Object> b) { | 58 void CheckThrows(Handle<Object> a, Handle<Object> b) { |
| 59 TryCatch try_catch; | 59 TryCatch try_catch; |
| 60 MaybeHandle<Object> no_result = Call(a, b); | 60 MaybeHandle<Object> no_result = Call(a, b); |
| 61 CHECK(isolate->has_pending_exception()); | 61 CHECK(isolate->has_pending_exception()); |
| 62 CHECK(try_catch.HasCaught()); | 62 CHECK(try_catch.HasCaught()); |
| 63 CHECK(no_result.is_null()); | 63 CHECK(no_result.is_null()); |
| 64 // TODO(mstarzinger): Temporary workaround for issue chromium:362388. | |
| 65 isolate->OptionalRescheduleException(true); | 64 isolate->OptionalRescheduleException(true); |
| 66 } | 65 } |
| 67 | 66 |
| 68 v8::Handle<v8::Message> CheckThrowsReturnMessage(Handle<Object> a, | 67 v8::Handle<v8::Message> CheckThrowsReturnMessage(Handle<Object> a, |
| 69 Handle<Object> b) { | 68 Handle<Object> b) { |
| 70 TryCatch try_catch; | 69 TryCatch try_catch; |
| 71 MaybeHandle<Object> no_result = Call(a, b); | 70 MaybeHandle<Object> no_result = Call(a, b); |
| 72 CHECK(isolate->has_pending_exception()); | 71 CHECK(isolate->has_pending_exception()); |
| 73 CHECK(try_catch.HasCaught()); | 72 CHECK(try_catch.HasCaught()); |
| 74 CHECK(no_result.is_null()); | 73 CHECK(no_result.is_null()); |
| 75 // TODO(mstarzinger): Calling OptionalRescheduleException is a dirty hack, | |
| 76 // it's the only way to make Message() not to assert because an external | |
| 77 // exception has been caught by the try_catch. | |
| 78 isolate->OptionalRescheduleException(true); | 74 isolate->OptionalRescheduleException(true); |
| 75 CHECK(!try_catch.Message().IsEmpty()); |
| 79 return try_catch.Message(); | 76 return try_catch.Message(); |
| 80 } | 77 } |
| 81 | 78 |
| 82 void CheckCall(Handle<Object> expected, Handle<Object> a, Handle<Object> b) { | 79 void CheckCall(Handle<Object> expected, Handle<Object> a, Handle<Object> b) { |
| 83 Handle<Object> result = Call(a, b).ToHandleChecked(); | 80 Handle<Object> result = Call(a, b).ToHandleChecked(); |
| 84 CHECK(expected->SameValue(*result)); | 81 CHECK(expected->SameValue(*result)); |
| 85 } | 82 } |
| 86 | 83 |
| 87 void CheckCall(Handle<Object> expected, Handle<Object> a) { | 84 void CheckCall(Handle<Object> expected, Handle<Object> a) { |
| 88 CheckCall(expected, a, undefined()); | 85 CheckCall(expected, a, undefined()); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 CHECK(!code.is_null()); | 218 CHECK(!code.is_null()); |
| 222 function->ReplaceCode(*code); | 219 function->ReplaceCode(*code); |
| 223 return function; | 220 return function; |
| 224 } | 221 } |
| 225 }; | 222 }; |
| 226 } | 223 } |
| 227 } | 224 } |
| 228 } // namespace v8::internal::compiler | 225 } // namespace v8::internal::compiler |
| 229 | 226 |
| 230 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 227 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ |
| OLD | NEW |