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

Side by Side 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: Code review response 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 unified diff | Download patch | Annotate | Revision Log
« src/api.cc ('K') | « src/api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 17818 matching lines...) Expand 10 before | Expand all | Expand 10 after
17829 script->Run(); 17829 script->Run();
17830 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( 17830 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
17831 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); 17831 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
17832 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( 17832 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast(
17833 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "bar"))); 17833 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "bar")));
17834 CHECK_EQ(script->GetId(), foo->ScriptId()); 17834 CHECK_EQ(script->GetId(), foo->ScriptId());
17835 CHECK_EQ(script->GetId(), bar->ScriptId()); 17835 CHECK_EQ(script->GetId(), bar->ScriptId());
17836 } 17836 }
17837 17837
17838 17838
17839 THREADED_TEST(FunctionGetBoundFunction) {
17840 LocalContext env;
17841 v8::HandleScope scope(env->GetIsolate());
17842 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::NewFromUtf8(
17843 env->GetIsolate(), "test"));
17844 v8::Handle<v8::String> script = v8::String::NewFromUtf8(
17845 env->GetIsolate(),
17846 "function f () {}\n"
17847 "var g = f.bind();\n");
yurys 2013/12/18 10:10:14 Maybe add some arguments to make sure this is not
Alexandra Mikhaylova 2013/12/18 14:16:07 Done.
17848 v8::Script::Compile(script, &origin)->Run();
17849 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
17850 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
17851 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
17852 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g")));
17853 CHECK(g->GetBoundFunction()->IsFunction());
17854 Local<v8::Function> g_original = Local<v8::Function>::Cast(
yurys 2013/12/18 10:10:14 g_original -> original_function?
Alexandra Mikhaylova 2013/12/18 14:16:07 Done.
17855 g->GetBoundFunction());
17856 CHECK_EQ(f->GetName(), g_original->GetName());
17857 CHECK_EQ(f->GetScriptLineNumber(), g_original->GetScriptLineNumber());
17858 CHECK_EQ(f->GetScriptColumnNumber(), g_original->GetScriptColumnNumber());
17859 }
17860
17861
17839 static void GetterWhichReturns42( 17862 static void GetterWhichReturns42(
17840 Local<String> name, 17863 Local<String> name,
17841 const v8::PropertyCallbackInfo<v8::Value>& info) { 17864 const v8::PropertyCallbackInfo<v8::Value>& info) {
17842 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); 17865 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject());
17843 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); 17866 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject());
17844 info.GetReturnValue().Set(v8_num(42)); 17867 info.GetReturnValue().Set(v8_num(42));
17845 } 17868 }
17846 17869
17847 17870
17848 static void SetterWhichSetsYOnThisTo23( 17871 static void SetterWhichSetsYOnThisTo23(
(...skipping 3101 matching lines...) Expand 10 before | Expand all | Expand 10 after
20950 } 20973 }
20951 for (int i = 0; i < runs; i++) { 20974 for (int i = 0; i < runs; i++) {
20952 Local<String> expected; 20975 Local<String> expected;
20953 if (i != 0) { 20976 if (i != 0) {
20954 CHECK_EQ(v8_str("escape value"), values[i]); 20977 CHECK_EQ(v8_str("escape value"), values[i]);
20955 } else { 20978 } else {
20956 CHECK(values[i].IsEmpty()); 20979 CHECK(values[i].IsEmpty());
20957 } 20980 }
20958 } 20981 }
20959 } 20982 }
OLDNEW
« 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