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

Side by Side Diff: test/cctest/test-api.cc

Issue 23819021: revert 16543 for breaking windows build (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 months 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 | « test/cctest/test-accessors.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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 134 }
135 135
136 136
137 static void ExpectUndefined(const char* code) { 137 static void ExpectUndefined(const char* code) {
138 Local<Value> result = CompileRun(code); 138 Local<Value> result = CompileRun(code);
139 CHECK(result->IsUndefined()); 139 CHECK(result->IsUndefined());
140 } 140 }
141 141
142 142
143 static int signature_callback_count; 143 static int signature_callback_count;
144 static Local<Value> signature_expected_receiver;
145 static void IncrementingSignatureCallback( 144 static void IncrementingSignatureCallback(
146 const v8::FunctionCallbackInfo<v8::Value>& args) { 145 const v8::FunctionCallbackInfo<v8::Value>& args) {
147 ApiTestFuzzer::Fuzz(); 146 ApiTestFuzzer::Fuzz();
148 signature_callback_count++; 147 signature_callback_count++;
149 CHECK_EQ(signature_expected_receiver, args.Holder());
150 CHECK_EQ(signature_expected_receiver, args.This());
151 v8::Handle<v8::Array> result = v8::Array::New(args.Length()); 148 v8::Handle<v8::Array> result = v8::Array::New(args.Length());
152 for (int i = 0; i < args.Length(); i++) 149 for (int i = 0; i < args.Length(); i++)
153 result->Set(v8::Integer::New(i), args[i]); 150 result->Set(v8::Integer::New(i), args[i]);
154 args.GetReturnValue().Set(result); 151 args.GetReturnValue().Set(result);
155 } 152 }
156 153
157 154
158 static void SignatureCallback( 155 static void SignatureCallback(
159 const v8::FunctionCallbackInfo<v8::Value>& args) { 156 const v8::FunctionCallbackInfo<v8::Value>& args) {
160 ApiTestFuzzer::Fuzz(); 157 ApiTestFuzzer::Fuzz();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 THREADED_TEST(ReceiverSignature) { 206 THREADED_TEST(ReceiverSignature) {
210 LocalContext env; 207 LocalContext env;
211 v8::HandleScope scope(env->GetIsolate()); 208 v8::HandleScope scope(env->GetIsolate());
212 v8::Handle<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(); 209 v8::Handle<v8::FunctionTemplate> fun = v8::FunctionTemplate::New();
213 v8::Handle<v8::Signature> sig = v8::Signature::New(fun); 210 v8::Handle<v8::Signature> sig = v8::Signature::New(fun);
214 fun->PrototypeTemplate()->Set( 211 fun->PrototypeTemplate()->Set(
215 v8_str("m"), 212 v8_str("m"),
216 v8::FunctionTemplate::New(IncrementingSignatureCallback, 213 v8::FunctionTemplate::New(IncrementingSignatureCallback,
217 v8::Handle<Value>(), 214 v8::Handle<Value>(),
218 sig)); 215 sig));
219 fun->PrototypeTemplate()->SetAccessorProperty(
220 v8_str("n"),
221 v8::FunctionTemplate::New(IncrementingSignatureCallback,
222 v8::Handle<Value>(),
223 sig));
224 env->Global()->Set(v8_str("Fun"), fun->GetFunction()); 216 env->Global()->Set(v8_str("Fun"), fun->GetFunction());
225 Local<Value> fun_instance = fun->InstanceTemplate()->NewInstance();
226 env->Global()->Set(v8_str("fun_instance"), fun_instance);
227 signature_callback_count = 0; 217 signature_callback_count = 0;
228 int expected_count = 0;
229 signature_expected_receiver = fun_instance;
230 CompileRun( 218 CompileRun(
231 "var o = fun_instance;" 219 "var o = new Fun();"
232 "var key_n = 'n';" 220 "o.m();");
233 "for (var i = 0; i < 10; i++) o.m();" 221 CHECK_EQ(1, signature_callback_count);
234 "for (var i = 0; i < 10; i++) o.n;"
235 "for (var i = 0; i < 10; i++) o[key_n];");
236 expected_count += 30;
237 CHECK_EQ(expected_count, signature_callback_count);
238 v8::Handle<v8::FunctionTemplate> sub_fun = v8::FunctionTemplate::New(); 222 v8::Handle<v8::FunctionTemplate> sub_fun = v8::FunctionTemplate::New();
239 sub_fun->Inherit(fun); 223 sub_fun->Inherit(fun);
240 fun_instance = sub_fun->InstanceTemplate()->NewInstance(); 224 env->Global()->Set(v8_str("SubFun"), sub_fun->GetFunction());
241 env->Global()->Set(v8_str("fun_instance"), fun_instance);
242 signature_expected_receiver = fun_instance;
243 CompileRun( 225 CompileRun(
244 "var o = fun_instance;" 226 "var o = new SubFun();"
245 "var key_n = 'n';" 227 "o.m();");
246 "for (var i = 0; i < 10; i++) o.m();" 228 CHECK_EQ(2, signature_callback_count);
247 "for (var i = 0; i < 10; i++) o.n;" 229
248 "for (var i = 0; i < 10; i++) o[key_n];");
249 expected_count += 30;
250 CHECK_EQ(expected_count, signature_callback_count);
251 v8::TryCatch try_catch; 230 v8::TryCatch try_catch;
252 CompileRun( 231 CompileRun(
253 "var o = { };" 232 "var o = { };"
254 "o.m = Fun.prototype.m;" 233 "o.m = Fun.prototype.m;"
255 "o.m();"); 234 "o.m();");
256 CHECK_EQ(expected_count, signature_callback_count); 235 CHECK_EQ(2, signature_callback_count);
257 CHECK(try_catch.HasCaught());
258 CompileRun(
259 "var o = { };"
260 "o.n = Fun.prototype.n;"
261 "o.n;");
262 CHECK_EQ(expected_count, signature_callback_count);
263 CHECK(try_catch.HasCaught()); 236 CHECK(try_catch.HasCaught());
264 try_catch.Reset(); 237 try_catch.Reset();
265 v8::Handle<v8::FunctionTemplate> unrel_fun = v8::FunctionTemplate::New(); 238 v8::Handle<v8::FunctionTemplate> unrel_fun = v8::FunctionTemplate::New();
266 sub_fun->Inherit(fun); 239 sub_fun->Inherit(fun);
267 env->Global()->Set(v8_str("UnrelFun"), unrel_fun->GetFunction()); 240 env->Global()->Set(v8_str("UnrelFun"), unrel_fun->GetFunction());
268 CompileRun( 241 CompileRun(
269 "var o = new UnrelFun();" 242 "var o = new UnrelFun();"
270 "o.m = Fun.prototype.m;" 243 "o.m = Fun.prototype.m;"
271 "o.m();"); 244 "o.m();");
272 CHECK_EQ(expected_count, signature_callback_count); 245 CHECK_EQ(2, signature_callback_count);
273 CHECK(try_catch.HasCaught());
274 try_catch.Reset();
275 CompileRun(
276 "var o = new UnrelFun();"
277 "o.n = Fun.prototype.n;"
278 "o.n;");
279 CHECK_EQ(expected_count, signature_callback_count);
280 CHECK(try_catch.HasCaught()); 246 CHECK(try_catch.HasCaught());
281 } 247 }
282 248
283 249
284 THREADED_TEST(ArgumentSignature) { 250 THREADED_TEST(ArgumentSignature) {
285 LocalContext env; 251 LocalContext env;
286 v8::HandleScope scope(env->GetIsolate()); 252 v8::HandleScope scope(env->GetIsolate());
287 v8::Handle<v8::FunctionTemplate> cons = v8::FunctionTemplate::New(); 253 v8::Handle<v8::FunctionTemplate> cons = v8::FunctionTemplate::New();
288 cons->SetClassName(v8_str("Cons")); 254 cons->SetClassName(v8_str("Cons"));
289 v8::Handle<v8::Signature> sig = 255 v8::Handle<v8::Signature> sig =
(...skipping 20157 matching lines...) Expand 10 before | Expand all | Expand 10 after
20447 "setAge(100);" 20413 "setAge(100);"
20448 "setAge(101);" 20414 "setAge(101);"
20449 "setAge(102);" 20415 "setAge(102);"
20450 "%OptimizeFunctionOnNextCall(setAge);" 20416 "%OptimizeFunctionOnNextCall(setAge);"
20451 "setAge(103);"); 20417 "setAge(103);");
20452 ExpectInt32("obj.age", 100000); 20418 ExpectInt32("obj.age", 100000);
20453 ExpectInt32("obj.interceptor_age", 103); 20419 ExpectInt32("obj.interceptor_age", 103);
20454 } 20420 }
20455 20421
20456 #endif // V8_OS_POSIX 20422 #endif // V8_OS_POSIX
OLDNEW
« no previous file with comments | « test/cctest/test-accessors.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698