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

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

Issue 118523003: More API cleanup. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Feedback 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
« no previous file with comments | « test/cctest/profiler-extension.cc ('k') | test/cctest/test-api.cc » ('j') | 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 LocalContext context; 194 LocalContext context;
195 v8::Isolate* isolate = context->GetIsolate(); 195 v8::Isolate* isolate = context->GetIsolate();
196 v8::HandleScope scope(isolate); 196 v8::HandleScope scope(isolate);
197 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); 197 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
198 obj->SetAccessor(v8_str("x0"), XGetter, XSetter); 198 obj->SetAccessor(v8_str("x0"), XGetter, XSetter);
199 obj->SetAccessorProperty(v8_str("x1"), 199 obj->SetAccessorProperty(v8_str("x1"),
200 v8::FunctionTemplate::New(isolate, XGetter), 200 v8::FunctionTemplate::New(isolate, XGetter),
201 v8::FunctionTemplate::New(isolate, XSetter)); 201 v8::FunctionTemplate::New(isolate, XSetter));
202 x_holder = obj->NewInstance(); 202 x_holder = obj->NewInstance();
203 context->Global()->Set(v8_str("holder"), x_holder); 203 context->Global()->Set(v8_str("holder"), x_holder);
204 x_receiver = v8::Object::New(); 204 x_receiver = v8::Object::New(isolate);
205 context->Global()->Set(v8_str("obj"), x_receiver); 205 context->Global()->Set(v8_str("obj"), x_receiver);
206 v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(CompileRun( 206 v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(CompileRun(
207 "obj.__proto__ = holder;" 207 "obj.__proto__ = holder;"
208 "var result = [];" 208 "var result = [];"
209 "var key_0 = 'x0';" 209 "var key_0 = 'x0';"
210 "var key_1 = 'x1';" 210 "var key_1 = 'x1';"
211 "for (var j = 0; j < 10; j++) {" 211 "for (var j = 0; j < 10; j++) {"
212 " var i = 4*j;" 212 " var i = 4*j;"
213 " holder.x0 = i;" 213 " holder.x0 = i;"
214 " result.push(obj.x0);" 214 " result.push(obj.x0);"
215 " holder.x1 = i + 1;" 215 " holder.x1 = i + 1;"
216 " result.push(obj.x1);" 216 " result.push(obj.x1);"
217 " holder[key_0] = i + 2;" 217 " holder[key_0] = i + 2;"
218 " result.push(obj[key_0]);" 218 " result.push(obj[key_0]);"
219 " holder[key_1] = i + 3;" 219 " holder[key_1] = i + 3;"
220 " result.push(obj[key_1]);" 220 " result.push(obj[key_1]);"
221 "}" 221 "}"
222 "result")); 222 "result"));
223 CHECK_EQ(40, array->Length()); 223 CHECK_EQ(40, array->Length());
224 for (int i = 0; i < 40; i++) { 224 for (int i = 0; i < 40; i++) {
225 v8::Handle<Value> entry = array->Get(v8::Integer::New(i)); 225 v8::Handle<Value> entry = array->Get(v8::Integer::New(isolate, i));
226 CHECK_EQ(v8::Integer::New(i), entry); 226 CHECK_EQ(v8::Integer::New(isolate, i), entry);
227 } 227 }
228 } 228 }
229 229
230 230
231 static void AccessorProhibitsOverwritingGetter( 231 static void AccessorProhibitsOverwritingGetter(
232 Local<String> name, 232 Local<String> name,
233 const v8::PropertyCallbackInfo<v8::Value>& info) { 233 const v8::PropertyCallbackInfo<v8::Value>& info) {
234 ApiTestFuzzer::Fuzz(); 234 ApiTestFuzzer::Fuzz();
235 info.GetReturnValue().Set(true); 235 info.GetReturnValue().Set(true);
236 } 236 }
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 " foo();" 517 " foo();"
518 "}"))->Run(); 518 "}"))->Run();
519 } 519 }
520 520
521 521
522 static void AllocateHandles(Local<String> name, 522 static void AllocateHandles(Local<String> name,
523 const v8::PropertyCallbackInfo<v8::Value>& info) { 523 const v8::PropertyCallbackInfo<v8::Value>& info) {
524 for (int i = 0; i < i::kHandleBlockSize + 1; i++) { 524 for (int i = 0; i < i::kHandleBlockSize + 1; i++) {
525 v8::Local<v8::Value>::New(info.GetIsolate(), name); 525 v8::Local<v8::Value>::New(info.GetIsolate(), name);
526 } 526 }
527 info.GetReturnValue().Set(v8::Integer::New(100)); 527 info.GetReturnValue().Set(v8::Integer::New(info.GetIsolate(), 100));
528 } 528 }
529 529
530 530
531 THREADED_TEST(HandleScopeSegment) { 531 THREADED_TEST(HandleScopeSegment) {
532 // Check that we can return values past popping of handle scope 532 // Check that we can return values past popping of handle scope
533 // segments. 533 // segments.
534 LocalContext env; 534 LocalContext env;
535 v8::HandleScope scope(env->GetIsolate()); 535 v8::HandleScope scope(env->GetIsolate());
536 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); 536 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
537 obj->SetAccessor(v8_str("xxx"), AllocateHandles); 537 obj->SetAccessor(v8_str("xxx"), AllocateHandles);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 v8::HandleScope scope(isolate); 578 v8::HandleScope scope(isolate);
579 v8::Handle<v8::Function> fun = v8::Function::New(isolate, handle_property); 579 v8::Handle<v8::Function> fun = v8::Function::New(isolate, handle_property);
580 LocalContext switch_context; 580 LocalContext switch_context;
581 switch_context->Global()->Set(v8_str("fun"), fun); 581 switch_context->Global()->Set(v8_str("fun"), fun);
582 v8::TryCatch try_catch; 582 v8::TryCatch try_catch;
583 CompileRun( 583 CompileRun(
584 "var o = Object.create(null, { n: { get:fun } });" 584 "var o = Object.create(null, { n: { get:fun } });"
585 "for (var i = 0; i < 10; i++) o.n;"); 585 "for (var i = 0; i < 10; i++) o.n;");
586 CHECK(!try_catch.HasCaught()); 586 CHECK(!try_catch.HasCaught());
587 } 587 }
OLDNEW
« no previous file with comments | « test/cctest/profiler-extension.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698