OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 2673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2684 THREADED_TEST(CatchExceptionFromWith) { | 2684 THREADED_TEST(CatchExceptionFromWith) { |
2685 v8::HandleScope scope; | 2685 v8::HandleScope scope; |
2686 LocalContext context; | 2686 LocalContext context; |
2687 v8::TryCatch try_catch; | 2687 v8::TryCatch try_catch; |
2688 CHECK(!try_catch.HasCaught()); | 2688 CHECK(!try_catch.HasCaught()); |
2689 Script::Compile(v8_str("var o = {}; with (o) { throw 42; }"))->Run(); | 2689 Script::Compile(v8_str("var o = {}; with (o) { throw 42; }"))->Run(); |
2690 CHECK(try_catch.HasCaught()); | 2690 CHECK(try_catch.HasCaught()); |
2691 } | 2691 } |
2692 | 2692 |
2693 | 2693 |
| 2694 THREADED_TEST(TryCatchAndFinallyHidingException) { |
| 2695 v8::HandleScope scope; |
| 2696 LocalContext context; |
| 2697 v8::TryCatch try_catch; |
| 2698 CHECK(!try_catch.HasCaught()); |
| 2699 CompileRun("function f(k) { try { this[k]; } finally { return 0; } };"); |
| 2700 CompileRun("f({toString: function() { throw 42; }});"); |
| 2701 CHECK(!try_catch.HasCaught()); |
| 2702 } |
| 2703 |
| 2704 |
| 2705 v8::Handle<v8::Value> WithTryCatch(const v8::Arguments& args) { |
| 2706 v8::TryCatch try_catch; |
| 2707 return v8::Undefined(); |
| 2708 } |
| 2709 |
| 2710 |
| 2711 THREADED_TEST(TryCatchAndFinally) { |
| 2712 v8::HandleScope scope; |
| 2713 LocalContext context; |
| 2714 context->Global()->Set( |
| 2715 v8_str("native_with_try_catch"), |
| 2716 v8::FunctionTemplate::New(WithTryCatch)->GetFunction()); |
| 2717 v8::TryCatch try_catch; |
| 2718 CHECK(!try_catch.HasCaught()); |
| 2719 CompileRun( |
| 2720 "try {\n" |
| 2721 " throw new Error('a');\n" |
| 2722 "} finally {\n" |
| 2723 " native_with_try_catch();\n" |
| 2724 "}\n"); |
| 2725 CHECK(try_catch.HasCaught()); |
| 2726 } |
| 2727 |
| 2728 |
2694 THREADED_TEST(Equality) { | 2729 THREADED_TEST(Equality) { |
2695 v8::HandleScope scope; | 2730 v8::HandleScope scope; |
2696 LocalContext context; | 2731 LocalContext context; |
2697 // Check that equality works at all before relying on CHECK_EQ | 2732 // Check that equality works at all before relying on CHECK_EQ |
2698 CHECK(v8_str("a")->Equals(v8_str("a"))); | 2733 CHECK(v8_str("a")->Equals(v8_str("a"))); |
2699 CHECK(!v8_str("a")->Equals(v8_str("b"))); | 2734 CHECK(!v8_str("a")->Equals(v8_str("b"))); |
2700 | 2735 |
2701 CHECK_EQ(v8_str("a"), v8_str("a")); | 2736 CHECK_EQ(v8_str("a"), v8_str("a")); |
2702 CHECK_NE(v8_str("a"), v8_str("b")); | 2737 CHECK_NE(v8_str("a"), v8_str("b")); |
2703 CHECK_EQ(v8_num(1), v8_num(1)); | 2738 CHECK_EQ(v8_num(1), v8_num(1)); |
(...skipping 10009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12713 v8::Handle<v8::Function> define_property = | 12748 v8::Handle<v8::Function> define_property = |
12714 CompileRun("(function() {" | 12749 CompileRun("(function() {" |
12715 " Object.defineProperty(" | 12750 " Object.defineProperty(" |
12716 " this," | 12751 " this," |
12717 " 1," | 12752 " 1," |
12718 " { configurable: true, enumerable: true, value: 3 });" | 12753 " { configurable: true, enumerable: true, value: 3 });" |
12719 "})").As<Function>(); | 12754 "})").As<Function>(); |
12720 context->DetachGlobal(); | 12755 context->DetachGlobal(); |
12721 define_property->Call(proxy, 0, NULL); | 12756 define_property->Call(proxy, 0, NULL); |
12722 } | 12757 } |
OLD | NEW |