OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 16767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16778 // recursive call into Javascript is done in the finally block, e.g. to | 16778 // recursive call into Javascript is done in the finally block, e.g. to |
16779 // initialize an IC. (crbug.com/129171) | 16779 // initialize an IC. (crbug.com/129171) |
16780 TryCatch try_catch; | 16780 TryCatch try_catch; |
16781 const char* trigger_ic = | 16781 const char* trigger_ic = |
16782 "try { \n" | 16782 "try { \n" |
16783 " throw new Error('test'); \n" | 16783 " throw new Error('test'); \n" |
16784 "} finally { \n" | 16784 "} finally { \n" |
16785 " var x = 0; \n" | 16785 " var x = 0; \n" |
16786 " x++; \n" // Trigger an IC initialization here. | 16786 " x++; \n" // Trigger an IC initialization here. |
16787 "} \n"; | 16787 "} \n"; |
16788 Local<Value> result = CompileRun(trigger_ic); | 16788 CompileRun(trigger_ic); |
16789 CHECK(try_catch.HasCaught()); | 16789 CHECK(try_catch.HasCaught()); |
16790 Local<Message> message = try_catch.Message(); | 16790 Local<Message> message = try_catch.Message(); |
16791 CHECK(!message.IsEmpty()); | 16791 CHECK(!message.IsEmpty()); |
16792 CHECK_EQ(2, message->GetLineNumber()); | 16792 CHECK_EQ(2, message->GetLineNumber()); |
16793 } | 16793 } |
16794 | 16794 |
16795 { | 16795 { |
16796 // Test that the original exception message is indeed overwritten if | 16796 // Test that the original exception message is indeed overwritten if |
16797 // a new error is thrown in the finally block. | 16797 // a new error is thrown in the finally block. |
16798 TryCatch try_catch; | 16798 TryCatch try_catch; |
16799 const char* throw_again = | 16799 const char* throw_again = |
16800 "try { \n" | 16800 "try { \n" |
16801 " throw new Error('test'); \n" | 16801 " throw new Error('test'); \n" |
16802 "} finally { \n" | 16802 "} finally { \n" |
16803 " var x = 0; \n" | 16803 " var x = 0; \n" |
16804 " x++; \n" | 16804 " x++; \n" |
16805 " throw new Error('again'); \n" // This is the new uncaught error. | 16805 " throw new Error('again'); \n" // This is the new uncaught error. |
16806 "} \n"; | 16806 "} \n"; |
16807 Local<Value> result = CompileRun(throw_again); | 16807 CompileRun(throw_again); |
16808 CHECK(try_catch.HasCaught()); | 16808 CHECK(try_catch.HasCaught()); |
16809 Local<Message> message = try_catch.Message(); | 16809 Local<Message> message = try_catch.Message(); |
16810 CHECK(!message.IsEmpty()); | 16810 CHECK(!message.IsEmpty()); |
16811 CHECK_EQ(6, message->GetLineNumber()); | 16811 CHECK_EQ(6, message->GetLineNumber()); |
16812 } | 16812 } |
16813 } | 16813 } |
OLD | NEW |