Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: test/cctest/test-api.cc

Issue 6526016: Properly process try/finally blocks. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Some more asserts Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« src/top.cc ('K') | « src/top.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 9925 matching lines...) Expand 10 before | Expand all | Expand 10 after
12629 v8::Handle<v8::Function> define_property = 12664 v8::Handle<v8::Function> define_property =
12630 CompileRun("(function() {" 12665 CompileRun("(function() {"
12631 " Object.defineProperty(" 12666 " Object.defineProperty("
12632 " this," 12667 " this,"
12633 " 1," 12668 " 1,"
12634 " { configurable: true, enumerable: true, value: 3 });" 12669 " { configurable: true, enumerable: true, value: 3 });"
12635 "})").As<Function>(); 12670 "})").As<Function>();
12636 context->DetachGlobal(); 12671 context->DetachGlobal();
12637 define_property->Call(proxy, 0, NULL); 12672 define_property->Call(proxy, 0, NULL);
12638 } 12673 }
OLDNEW
« src/top.cc ('K') | « src/top.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698