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

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

Issue 11631002: Extend API to allow setting length property for function templates. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Support length as argument to FunctionTempalte::New Created 8 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
« no previous file with comments | « src/objects-inl.h ('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 0a5583bb94ade75c2cf4748436c19efb72e80d37..91d46a3249aaf40733c690fc57256ae25c9586a0 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -853,6 +853,38 @@ THREADED_TEST(FunctionTemplate) {
}
+THREADED_TEST(FunctionTemplateSetLength) {
+ v8::HandleScope scope;
+ LocalContext env;
+ {
+ Local<v8::FunctionTemplate> fun_templ =
+ v8::FunctionTemplate::New(handle_call);
+ fun_templ->SetLength(22);
+ Local<Function> fun = fun_templ->GetFunction();
+ env->Global()->Set(v8_str("obj"), fun);
+ Local<Script> script = v8_compile("obj.length");
+ CHECK_EQ(22, script->Run()->Int32Value());
+ }
+ {
+ Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(
+ handle_call, Handle<v8::Value>(), Handle<v8::Signature>(), 23);
+ Local<Function> fun = fun_templ->GetFunction();
+ env->Global()->Set(v8_str("obj"), fun);
+ Local<Script> script = v8_compile("obj.length");
+ CHECK_EQ(23, script->Run()->Int32Value());
+ }
+ {
+ // Without setting length it defaults to 0.
+ Local<v8::FunctionTemplate> fun_templ =
+ v8::FunctionTemplate::New(handle_call);
+ Local<Function> fun = fun_templ->GetFunction();
+ env->Global()->Set(v8_str("obj"), fun);
+ Local<Script> script = v8_compile("obj.length");
+ CHECK_EQ(0, script->Run()->Int32Value());
+ }
+}
+
+
static void* expected_ptr;
static v8::Handle<v8::Value> callback(const v8::Arguments& args) {
void* ptr = v8::External::Unwrap(args.Data());
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698