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

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

Issue 1233563005: Take the ScriptOrigin into account for CompileFunctionInContext (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-compiler.cc
diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc
index 3b25480a4aa784687daacb44cdc7ea90bbd74d0e..038d4d76e7c9352df33a994980213d9e9a527111 100644
--- a/test/cctest/test-compiler.cc
+++ b/test/cctest/test-compiler.cc
@@ -566,6 +566,32 @@ TEST(CompileFunctionInContextNonIdentifierArgs) {
}
+TEST(CompileFunctionInContextScriptOrigin) {
+ CcTest::InitializeVM();
+ v8::HandleScope scope(CcTest::isolate());
+ LocalContext env;
+ v8::ScriptOrigin origin(v8_str("test"),
+ v8::Integer::New(CcTest::isolate(), 22),
+ v8::Integer::New(CcTest::isolate(), 41));
+ v8::ScriptCompiler::Source script_source(v8_str("throw new Error()"), origin);
+ v8::Local<v8::Function> fun = v8::ScriptCompiler::CompileFunctionInContext(
+ CcTest::isolate(), &script_source, env.local(), 0, NULL, 0, NULL);
+ CHECK(!fun.IsEmpty());
+ v8::TryCatch try_catch;
+ CcTest::isolate()->SetCaptureStackTraceForUncaughtExceptions(true);
+ fun->Call(env->Global(), 0, NULL);
+ CHECK(try_catch.HasCaught());
+ CHECK(!try_catch.Exception().IsEmpty());
+ v8::Local<v8::StackTrace> stack =
+ v8::Exception::GetStackTrace(try_catch.Exception());
+ CHECK(!stack.IsEmpty());
+ CHECK(stack->GetFrameCount() > 0);
+ v8::Local<v8::StackFrame> frame = stack->GetFrame(0);
+ CHECK_EQ(23, frame->GetLineNumber());
+ CHECK_EQ(42 + strlen("throw "), static_cast<unsigned>(frame->GetColumn()));
+}
+
+
#ifdef ENABLE_DISASSEMBLER
static Handle<JSFunction> GetJSFunction(v8::Handle<v8::Object> obj,
const char* property_name) {
« no previous file with comments | « src/messages.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698