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

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: GetBoundFunction returns v8::Undefined if this function is not bound + REBASE 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
« src/api.cc ('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 91f37367dae9d0ec815cbd4738bc62484e1df80f..0864cac81cfdd16abb9eb859c5e9fd42560fa3bb 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -17836,6 +17836,33 @@ THREADED_TEST(FunctionGetScriptId) {
}
+THREADED_TEST(FunctionGetBoundFunction) {
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+ v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::NewFromUtf8(
+ env->GetIsolate(), "test"));
+ 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(!g->GetBoundFunction()->IsUndefined());
yurys 2013/12/12 20:20:50 CHECK(g->GetBoundFunction()->IsFunction())
Alexandra Mikhaylova 2013/12/18 10:00:28 Done.
+ CHECK_EQ(*v8::String::Utf8Value(f->GetName()),
yurys 2013/12/12 20:20:50 CHECK_EQ should work well for Handles, you don't n
Alexandra Mikhaylova 2013/12/18 10:00:28 Done.
+ *v8::String::Utf8Value(
+ Local<v8::Function>::Cast(g->GetBoundFunction())->GetName()));
yurys 2013/12/12 20:20:50 It may make sense to extract Local<v8::Function>::
Alexandra Mikhaylova 2013/12/18 10:00:28 Done.
+ CHECK_EQ(f->GetScriptLineNumber(),
+ Local<v8::Function>::Cast(
+ g->GetBoundFunction())->GetScriptLineNumber());
+ CHECK_EQ(f->GetScriptColumnNumber(),
+ Local<v8::Function>::Cast(
+ g->GetBoundFunction())->GetScriptColumnNumber());
+}
+
+
static void GetterWhichReturns42(
Local<String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
« src/api.cc ('K') | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698