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

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

Issue 106763002: Get information about original function from bound function (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Correct API + add a test Created 7 years 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
« include/v8.h ('K') | « src/api.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 819f42d4bac469b8ab461c0ee19b8701425f0e5b..a7c8dba168841012637315a34ee484ba97ef8d8e 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -17757,6 +17757,29 @@ THREADED_TEST(FunctionGetScriptId) {
}
+THREADED_TEST(FunctionGetBoundFunction) {
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+ v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::NewFromUtf8(
+ env->GetIsolate(), "test"));
yurys 2013/12/12 12:49:27 style: wrong indentation
Alexandra Mikhaylova 2013/12/12 15:53:02 Done.
+ v8::Handle<v8::String> script = v8::String::NewFromUtf8(
+ env->GetIsolate(),
+ "function f () {}\n"
+ "var g = f.bind();\n");
+ v8::Script::Compile(script, &origin)->Run();
+ v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
+ v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g")));
+ CHECK_EQ(*v8::String::Utf8Value(f->GetName()),
+ *v8::String::Utf8Value(g->GetBoundFunction()->GetName()));
+ CHECK_EQ(f->GetScriptLineNumber(),
+ g->GetBoundFunction()->GetScriptLineNumber());
+ CHECK_EQ(f->GetScriptColumnNumber(),
+ g->GetBoundFunction()->GetScriptColumnNumber());
+}
+
+
static void GetterWhichReturns42(
Local<String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
« include/v8.h ('K') | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698