OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 1648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1659 "try {" | 1659 "try {" |
1660 " ThrowFromC();" | 1660 " ThrowFromC();" |
1661 "} catch (e) {" | 1661 "} catch (e) {" |
1662 " thrown = true;" | 1662 " thrown = true;" |
1663 "}"); | 1663 "}"); |
1664 Local<Value> thrown = context->Global()->Get(v8_str("thrown")); | 1664 Local<Value> thrown = context->Global()->Get(v8_str("thrown")); |
1665 CHECK(thrown->BooleanValue()); | 1665 CHECK(thrown->BooleanValue()); |
1666 } | 1666 } |
1667 | 1667 |
1668 | 1668 |
| 1669 THREADED_TEST(APIThrowTryCatch) { |
| 1670 v8::HandleScope scope; |
| 1671 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 1672 templ->Set(v8_str("ThrowFromC"), |
| 1673 v8::FunctionTemplate::New(ThrowFromC)); |
| 1674 LocalContext context(0, templ); |
| 1675 v8::TryCatch try_catch; |
| 1676 CompileRun("ThrowFromC();"); |
| 1677 CHECK(try_catch.HasCaught()); |
| 1678 } |
| 1679 |
| 1680 |
| 1681 static void receive_message(v8::Handle<v8::Message> message, |
| 1682 v8::Handle<v8::Value> data) { |
| 1683 message_received = true; |
| 1684 } |
| 1685 |
| 1686 |
| 1687 TEST(APIThrowMessage) { |
| 1688 message_received = false; |
| 1689 v8::HandleScope scope; |
| 1690 v8::V8::AddMessageListener(receive_message); |
| 1691 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 1692 templ->Set(v8_str("ThrowFromC"), |
| 1693 v8::FunctionTemplate::New(ThrowFromC)); |
| 1694 LocalContext context(0, templ); |
| 1695 CompileRun("ThrowFromC();"); |
| 1696 CHECK(message_received); |
| 1697 v8::V8::RemoveMessageListeners(check_message); |
| 1698 } |
| 1699 |
| 1700 |
| 1701 TEST(APIThrowMessageAndVerboseTryCatch) { |
| 1702 message_received = false; |
| 1703 v8::HandleScope scope; |
| 1704 v8::V8::AddMessageListener(receive_message); |
| 1705 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 1706 templ->Set(v8_str("ThrowFromC"), |
| 1707 v8::FunctionTemplate::New(ThrowFromC)); |
| 1708 LocalContext context(0, templ); |
| 1709 v8::TryCatch try_catch; |
| 1710 try_catch.SetVerbose(true); |
| 1711 CompileRun("ThrowFromC();"); |
| 1712 CHECK(try_catch.HasCaught()); |
| 1713 CHECK(message_received); |
| 1714 v8::V8::RemoveMessageListeners(check_message); |
| 1715 } |
| 1716 |
| 1717 |
1669 THREADED_TEST(ExternalScriptException) { | 1718 THREADED_TEST(ExternalScriptException) { |
1670 v8::HandleScope scope; | 1719 v8::HandleScope scope; |
1671 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 1720 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
1672 templ->Set(v8_str("ThrowFromC"), | 1721 templ->Set(v8_str("ThrowFromC"), |
1673 v8::FunctionTemplate::New(ThrowFromC)); | 1722 v8::FunctionTemplate::New(ThrowFromC)); |
1674 LocalContext context(0, templ); | 1723 LocalContext context(0, templ); |
1675 | 1724 |
1676 v8::TryCatch try_catch; | 1725 v8::TryCatch try_catch; |
1677 Local<Script> script | 1726 Local<Script> script |
1678 = Script::Compile(v8_str("ThrowFromC(); throw 'panama';")); | 1727 = Script::Compile(v8_str("ThrowFromC(); throw 'panama';")); |
(...skipping 3705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5384 CompileRun("for (var j = 0; j < 10; j++) new RegExp('');"); | 5433 CompileRun("for (var j = 0; j < 10; j++) new RegExp('');"); |
5385 } | 5434 } |
5386 // Test CallIC. | 5435 // Test CallIC. |
5387 for (int i = 0; i < 2; i++) { | 5436 for (int i = 0; i < 2; i++) { |
5388 LocalContext context; | 5437 LocalContext context; |
5389 context->Global()->Set(v8_str("tmp"), v8::True()); | 5438 context->Global()->Set(v8_str("tmp"), v8::True()); |
5390 context->Global()->Delete(v8_str("tmp")); | 5439 context->Global()->Delete(v8_str("tmp")); |
5391 CompileRun("for (var j = 0; j < 10; j++) RegExp('')"); | 5440 CompileRun("for (var j = 0; j < 10; j++) RegExp('')"); |
5392 } | 5441 } |
5393 } | 5442 } |
OLD | NEW |