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

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

Issue 10555004: Fix external exceptions in external try-catch handlers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 6 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
« no previous file with comments | « src/isolate.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 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 3345 matching lines...) Expand 10 before | Expand all | Expand 10 after
3356 CompileRun( 3356 CompileRun(
3357 "try {\n" 3357 "try {\n"
3358 " throw new Error('a');\n" 3358 " throw new Error('a');\n"
3359 "} finally {\n" 3359 "} finally {\n"
3360 " native_with_try_catch();\n" 3360 " native_with_try_catch();\n"
3361 "}\n"); 3361 "}\n");
3362 CHECK(try_catch.HasCaught()); 3362 CHECK(try_catch.HasCaught());
3363 } 3363 }
3364 3364
3365 3365
3366 static void TryCatchNestedHelper(int depth) {
3367 if (depth > 0) {
3368 v8::TryCatch try_catch;
3369 try_catch.SetVerbose(true);
3370 TryCatchNestedHelper(depth - 1);
3371 CHECK(try_catch.HasCaught());
3372 try_catch.ReThrow();
3373 } else {
3374 v8::ThrowException(v8_str("back"));
3375 }
3376 }
3377
3378
3379 TEST(TryCatchNested) {
3380 v8::V8::Initialize();
3381 v8::HandleScope scope;
3382 LocalContext context;
3383 v8::TryCatch try_catch;
3384 TryCatchNestedHelper(5);
3385 CHECK(try_catch.HasCaught());
3386 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(try_catch.Exception()), "back"));
3387 }
3388
3389
3366 THREADED_TEST(Equality) { 3390 THREADED_TEST(Equality) {
3367 v8::HandleScope scope; 3391 v8::HandleScope scope;
3368 LocalContext context; 3392 LocalContext context;
3369 // Check that equality works at all before relying on CHECK_EQ 3393 // Check that equality works at all before relying on CHECK_EQ
3370 CHECK(v8_str("a")->Equals(v8_str("a"))); 3394 CHECK(v8_str("a")->Equals(v8_str("a")));
3371 CHECK(!v8_str("a")->Equals(v8_str("b"))); 3395 CHECK(!v8_str("a")->Equals(v8_str("b")));
3372 3396
3373 CHECK_EQ(v8_str("a"), v8_str("a")); 3397 CHECK_EQ(v8_str("a"), v8_str("a"));
3374 CHECK_NE(v8_str("a"), v8_str("b")); 3398 CHECK_NE(v8_str("a"), v8_str("b"));
3375 CHECK_EQ(v8_num(1), v8_num(1)); 3399 CHECK_EQ(v8_num(1), v8_num(1));
(...skipping 13428 matching lines...) Expand 10 before | Expand all | Expand 10 after
16804 " x++; \n" 16828 " x++; \n"
16805 " throw new Error('again'); \n" // This is the new uncaught error. 16829 " throw new Error('again'); \n" // This is the new uncaught error.
16806 "} \n"; 16830 "} \n";
16807 CompileRun(throw_again); 16831 CompileRun(throw_again);
16808 CHECK(try_catch.HasCaught()); 16832 CHECK(try_catch.HasCaught());
16809 Local<Message> message = try_catch.Message(); 16833 Local<Message> message = try_catch.Message();
16810 CHECK(!message.IsEmpty()); 16834 CHECK(!message.IsEmpty());
16811 CHECK_EQ(6, message->GetLineNumber()); 16835 CHECK_EQ(6, message->GetLineNumber());
16812 } 16836 }
16813 } 16837 }
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698