Index: test/cctest/test-compiler.cc |
=================================================================== |
--- test/cctest/test-compiler.cc (revision 3862) |
+++ test/cctest/test-compiler.cc (working copy) |
@@ -317,3 +317,27 @@ |
CHECK_EQ(-1, GetScriptLineNumber(script, 100)); |
CHECK_EQ(-1, GetScriptLineNumber(script, -1)); |
} |
+ |
+ |
+TEST(GetScriptLineNumber) { |
+ LocalContext env; |
+ v8::HandleScope scope; |
+ v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); |
+ const char function_f[] = "function f() {}"; |
+ const int max_rows = 1000; |
+ const int buffer_size = max_rows + sizeof(function_f); |
+ ScopedVector<char> buffer(buffer_size); |
+ memset(buffer.start(), '\n', buffer_size - 1); |
+ buffer[buffer_size - 1] = '\0'; |
+ |
+ for (int i = 0; i < max_rows; ++i) { |
+ if (i > 0) |
+ buffer[i - 1] = '\n'; |
+ memcpy(&buffer[i], function_f, sizeof(function_f) - 1); |
+ v8::Handle<v8::String> script_body = v8::String::New(buffer.start()); |
+ v8::Script::Compile(script_body, &origin)->Run(); |
+ v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
+ env->Global()->Get(v8::String::New("f"))); |
+ CHECK_EQ(i, f->GetScriptLineNumber()); |
+ } |
+} |