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

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

Issue 17694002: Restore message when rethrowing in TryCatch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 4482 matching lines...) Expand 10 before | Expand all | Expand 10 after
4493 v8::V8::Initialize(); 4493 v8::V8::Initialize();
4494 LocalContext context; 4494 LocalContext context;
4495 v8::HandleScope scope(context->GetIsolate()); 4495 v8::HandleScope scope(context->GetIsolate());
4496 v8::TryCatch try_catch; 4496 v8::TryCatch try_catch;
4497 TryCatchNestedHelper(5); 4497 TryCatchNestedHelper(5);
4498 CHECK(try_catch.HasCaught()); 4498 CHECK(try_catch.HasCaught());
4499 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(try_catch.Exception()), "back")); 4499 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(try_catch.Exception()), "back"));
4500 } 4500 }
4501 4501
4502 4502
4503 void TryCatchNestedSyntaxHelper(
4504 const v8::FunctionCallbackInfo<v8::Value>& args) {
4505 ApiTestFuzzer::Fuzz();
4506 v8::TryCatch try_catch;
4507 v8::ScriptOrigin origin(v8::String::New("inner"),
4508 v8::Integer::New(1), v8::Integer::New(1));
4509 v8::Script::Compile(v8::String::New("invalid ?= 1;\n"), &origin);
4510 CHECK(try_catch.HasCaught());
4511 Handle<Value> resource = try_catch.Message()->GetScriptResourceName();
4512 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(resource), "inner"));
4513 try_catch.ReThrow();
4514 }
4515
4516
4517 // This test ensures that an outer TryCatch in the following situation:
4518 // C++/TryCatch -> JS -> C++/TryCatch -> JS w/ SyntaxError
4519 // does clobber the Message object generated for the inner TryCatch.
apaprocki 2013/06/26 03:22:52 I meant to say "doesn't clobber" here.
4520 // This exercises the ability of TryCatch.ReThrow() to restore the
4521 // inner pending Message before throwing the exception again.
4522 TEST(TryCatchNestedSyntax) {
4523 v8::HandleScope scope(v8::Isolate::GetCurrent());
4524 v8::V8::Initialize();
4525 v8::TryCatch try_catch;
4526 Local<ObjectTemplate> templ = ObjectTemplate::New();
4527 templ->Set(v8_str("TryCatchNestedSyntaxHelper"),
4528 v8::FunctionTemplate::New(TryCatchNestedSyntaxHelper));
4529 LocalContext context(0, templ);
4530 CompileRunWithOrigin("TryCatchNestedSyntaxHelper();\n", "outer", 1, 1);
4531 CHECK(try_catch.HasCaught());
4532 Handle<Value> resource = try_catch.Message()->GetScriptResourceName();
4533 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(resource), "inner"));
4534 }
4535
4536
4503 THREADED_TEST(Equality) { 4537 THREADED_TEST(Equality) {
4504 LocalContext context; 4538 LocalContext context;
4505 v8::Isolate* isolate = context->GetIsolate(); 4539 v8::Isolate* isolate = context->GetIsolate();
4506 v8::HandleScope scope(context->GetIsolate()); 4540 v8::HandleScope scope(context->GetIsolate());
4507 // Check that equality works at all before relying on CHECK_EQ 4541 // Check that equality works at all before relying on CHECK_EQ
4508 CHECK(v8_str("a")->Equals(v8_str("a"))); 4542 CHECK(v8_str("a")->Equals(v8_str("a")));
4509 CHECK(!v8_str("a")->Equals(v8_str("b"))); 4543 CHECK(!v8_str("a")->Equals(v8_str("b")));
4510 4544
4511 CHECK_EQ(v8_str("a"), v8_str("a")); 4545 CHECK_EQ(v8_str("a"), v8_str("a"));
4512 CHECK_NE(v8_str("a"), v8_str("b")); 4546 CHECK_NE(v8_str("a"), v8_str("b"));
(...skipping 14823 matching lines...) Expand 10 before | Expand all | Expand 10 after
19336 i::Semaphore* sem_; 19370 i::Semaphore* sem_;
19337 volatile int sem_value_; 19371 volatile int sem_value_;
19338 }; 19372 };
19339 19373
19340 19374
19341 THREADED_TEST(SemaphoreInterruption) { 19375 THREADED_TEST(SemaphoreInterruption) {
19342 ThreadInterruptTest().RunTest(); 19376 ThreadInterruptTest().RunTest();
19343 } 19377 }
19344 19378
19345 #endif // WIN32 19379 #endif // WIN32
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