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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects-inl.h ('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 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 846
847 Local<Value> result = v8_compile("(new obj()).toString()")->Run(); 847 Local<Value> result = v8_compile("(new obj()).toString()")->Run();
848 CHECK_EQ(v8_str("[object funky]"), result); 848 CHECK_EQ(v8_str("[object funky]"), result);
849 849
850 result = v8_compile("(new obj()).m")->Run(); 850 result = v8_compile("(new obj()).m")->Run();
851 CHECK_EQ(239, result->Int32Value()); 851 CHECK_EQ(239, result->Int32Value());
852 } 852 }
853 } 853 }
854 854
855 855
856 THREADED_TEST(FunctionTemplateSetLength) {
857 v8::HandleScope scope;
858 LocalContext env;
859 {
860 Local<v8::FunctionTemplate> fun_templ =
861 v8::FunctionTemplate::New(handle_call);
862 fun_templ->SetLength(22);
863 Local<Function> fun = fun_templ->GetFunction();
864 env->Global()->Set(v8_str("obj"), fun);
865 Local<Script> script = v8_compile("obj.length");
866 CHECK_EQ(22, script->Run()->Int32Value());
867 }
868 {
869 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(
870 handle_call, Handle<v8::Value>(), Handle<v8::Signature>(), 23);
871 Local<Function> fun = fun_templ->GetFunction();
872 env->Global()->Set(v8_str("obj"), fun);
873 Local<Script> script = v8_compile("obj.length");
874 CHECK_EQ(23, script->Run()->Int32Value());
875 }
876 {
877 // Without setting length it defaults to 0.
878 Local<v8::FunctionTemplate> fun_templ =
879 v8::FunctionTemplate::New(handle_call);
880 Local<Function> fun = fun_templ->GetFunction();
881 env->Global()->Set(v8_str("obj"), fun);
882 Local<Script> script = v8_compile("obj.length");
883 CHECK_EQ(0, script->Run()->Int32Value());
884 }
885 }
886
887
856 static void* expected_ptr; 888 static void* expected_ptr;
857 static v8::Handle<v8::Value> callback(const v8::Arguments& args) { 889 static v8::Handle<v8::Value> callback(const v8::Arguments& args) {
858 void* ptr = v8::External::Unwrap(args.Data()); 890 void* ptr = v8::External::Unwrap(args.Data());
859 CHECK_EQ(expected_ptr, ptr); 891 CHECK_EQ(expected_ptr, ptr);
860 return v8::True(); 892 return v8::True();
861 } 893 }
862 894
863 895
864 static void TestExternalPointerWrapping() { 896 static void TestExternalPointerWrapping() {
865 v8::HandleScope scope; 897 v8::HandleScope scope;
(...skipping 17231 matching lines...) Expand 10 before | Expand all | Expand 10 after
18097 18129
18098 i::Semaphore* sem_; 18130 i::Semaphore* sem_;
18099 volatile int sem_value_; 18131 volatile int sem_value_;
18100 }; 18132 };
18101 18133
18102 18134
18103 THREADED_TEST(SemaphoreInterruption) { 18135 THREADED_TEST(SemaphoreInterruption) {
18104 ThreadInterruptTest().RunTest(); 18136 ThreadInterruptTest().RunTest();
18105 } 18137 }
18106 #endif // WIN32 18138 #endif // WIN32
OLDNEW
« 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