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

Unified Diff: test/cctest/test-api.cc

Issue 39342: Refactor some source position info (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/messages.js ('k') | test/mjsunit/debug-sourceinfo.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
===================================================================
--- test/cctest/test-api.cc (revision 1456)
+++ test/cctest/test-api.cc (working copy)
@@ -5320,6 +5320,28 @@
}
+static void CheckTryCatchSourceInfo(v8::Handle<v8::Script> script,
+ char* resource_name,
+ int line_offset) {
+ v8::HandleScope scope;
+ v8::TryCatch try_catch;
+ v8::Handle<v8::Value> result = script->Run();
+ CHECK(result.IsEmpty());
+ CHECK(try_catch.HasCaught());
+ v8::Handle<v8::Message> message = try_catch.Message();
+ CHECK(!message.IsEmpty());
+ CHECK_EQ(10 + line_offset, message->GetLineNumber());
+ CHECK_EQ(91, message->GetStartPosition());
+ CHECK_EQ(92, message->GetEndPosition());
+ CHECK_EQ(2, message->GetStartColumn());
+ CHECK_EQ(3, message->GetEndColumn());
+ v8::String::AsciiValue line(message->GetSourceLine());
+ CHECK_EQ(" throw 'nirk';", *line);
+ v8::String::AsciiValue name(message->GetScriptResourceName());
+ CHECK_EQ(resource_name, *name);
+}
+
+
THREADED_TEST(TryCatchSourceInfo) {
v8::HandleScope scope;
LocalContext context;
@@ -5337,23 +5359,22 @@
"}\n"
"\n"
"Foo();\n");
- v8::Handle<v8::Script> script =
- v8::Script::Compile(source, v8::String::New("test.js"));
- v8::TryCatch try_catch;
- v8::Handle<v8::Value> result = script->Run();
- CHECK(result.IsEmpty());
- CHECK(try_catch.HasCaught());
- v8::Handle<v8::Message> message = try_catch.Message();
- CHECK(!message.IsEmpty());
- CHECK_EQ(10, message->GetLineNumber());
- CHECK_EQ(91, message->GetStartPosition());
- CHECK_EQ(92, message->GetEndPosition());
- CHECK_EQ(2, message->GetStartColumn());
- CHECK_EQ(3, message->GetEndColumn());
- v8::String::AsciiValue line(message->GetSourceLine());
- CHECK_EQ(" throw 'nirk';", *line);
- v8::String::AsciiValue name(message->GetScriptResourceName());
- CHECK_EQ("test.js", *name);
+
+ char* resource_name;
+ v8::Handle<v8::Script> script;
+ resource_name = "test.js";
+ script = v8::Script::Compile(source, v8::String::New(resource_name));
+ CheckTryCatchSourceInfo(script, resource_name, 0);
+
+ resource_name = "test1.js";
+ v8::ScriptOrigin origin1(v8::String::New(resource_name));
+ script = v8::Script::Compile(source, &origin1);
+ CheckTryCatchSourceInfo(script, resource_name, 0);
+
+ resource_name = "test2.js";
+ v8::ScriptOrigin origin2(v8::String::New(resource_name), v8::Integer::New(7));
+ script = v8::Script::Compile(source, &origin2);
+ CheckTryCatchSourceInfo(script, resource_name, 7);
}
« no previous file with comments | « src/messages.js ('k') | test/mjsunit/debug-sourceinfo.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698