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

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

Issue 9415010: Make built-ins strict mode conforming, and support a --use-strict flag. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Yang's comments. Created 8 years, 10 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 | « src/v8natives.js ('k') | test/mjsunit/builtins.js » ('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 4204 matching lines...) Expand 10 before | Expand all | Expand 10 after
4215 indexed->NewInstance()); 4215 indexed->NewInstance());
4216 4216
4217 // Create object with both named and indexed interceptor. 4217 // Create object with both named and indexed interceptor.
4218 v8::Handle<v8::ObjectTemplate> both = v8::ObjectTemplate::New(); 4218 v8::Handle<v8::ObjectTemplate> both = v8::ObjectTemplate::New();
4219 both->SetNamedPropertyHandler(NamedGetter, NULL, NULL, NULL, NamedEnum); 4219 both->SetNamedPropertyHandler(NamedGetter, NULL, NULL, NULL, NamedEnum);
4220 both->SetIndexedPropertyHandler(IndexedGetter, NULL, NULL, NULL, IndexedEnum); 4220 both->SetIndexedPropertyHandler(IndexedGetter, NULL, NULL, NULL, IndexedEnum);
4221 env->Global()->Set(v8::String::New("intercepted_both"), both->NewInstance()); 4221 env->Global()->Set(v8::String::New("intercepted_both"), both->NewInstance());
4222 4222
4223 // Get mirrors for the three objects with interceptor. 4223 // Get mirrors for the three objects with interceptor.
4224 CompileRun( 4224 CompileRun(
4225 "named_mirror = debug.MakeMirror(intercepted_named);" 4225 "var named_mirror = debug.MakeMirror(intercepted_named);"
4226 "indexed_mirror = debug.MakeMirror(intercepted_indexed);" 4226 "var indexed_mirror = debug.MakeMirror(intercepted_indexed);"
4227 "both_mirror = debug.MakeMirror(intercepted_both)"); 4227 "var both_mirror = debug.MakeMirror(intercepted_both)");
4228 CHECK(CompileRun( 4228 CHECK(CompileRun(
4229 "named_mirror instanceof debug.ObjectMirror")->BooleanValue()); 4229 "named_mirror instanceof debug.ObjectMirror")->BooleanValue());
4230 CHECK(CompileRun( 4230 CHECK(CompileRun(
4231 "indexed_mirror instanceof debug.ObjectMirror")->BooleanValue()); 4231 "indexed_mirror instanceof debug.ObjectMirror")->BooleanValue());
4232 CHECK(CompileRun( 4232 CHECK(CompileRun(
4233 "both_mirror instanceof debug.ObjectMirror")->BooleanValue()); 4233 "both_mirror instanceof debug.ObjectMirror")->BooleanValue());
4234 4234
4235 // Get the property names from the interceptors 4235 // Get the property names from the interceptors
4236 CompileRun( 4236 CompileRun(
4237 "named_names = named_mirror.propertyNames();" 4237 "named_names = named_mirror.propertyNames();"
(...skipping 20 matching lines...) Expand all
4258 4258
4259 // 2 is PropertyKind.Indexed; 4259 // 2 is PropertyKind.Indexed;
4260 source = "both_mirror.properties(2).length"; 4260 source = "both_mirror.properties(2).length";
4261 CHECK_EQ(2, CompileRun(source)->Int32Value()); 4261 CHECK_EQ(2, CompileRun(source)->Int32Value());
4262 4262
4263 // 3 is PropertyKind.Named | PropertyKind.Indexed; 4263 // 3 is PropertyKind.Named | PropertyKind.Indexed;
4264 source = "both_mirror.properties(3).length"; 4264 source = "both_mirror.properties(3).length";
4265 CHECK_EQ(5, CompileRun(source)->Int32Value()); 4265 CHECK_EQ(5, CompileRun(source)->Int32Value());
4266 4266
4267 // Get the interceptor properties for the object with only named interceptor. 4267 // Get the interceptor properties for the object with only named interceptor.
4268 CompileRun("named_values = named_mirror.properties()"); 4268 CompileRun("var named_values = named_mirror.properties()");
4269 4269
4270 // Check that the properties are interceptor properties. 4270 // Check that the properties are interceptor properties.
4271 for (int i = 0; i < 3; i++) { 4271 for (int i = 0; i < 3; i++) {
4272 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; 4272 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
4273 OS::SNPrintF(buffer, 4273 OS::SNPrintF(buffer,
4274 "named_values[%d] instanceof debug.PropertyMirror", i); 4274 "named_values[%d] instanceof debug.PropertyMirror", i);
4275 CHECK(CompileRun(buffer.start())->BooleanValue()); 4275 CHECK(CompileRun(buffer.start())->BooleanValue());
4276 4276
4277 // 5 is PropertyType.Interceptor 4277 // 5 is PropertyType.Interceptor
4278 OS::SNPrintF(buffer, "named_values[%d].propertyType()", i); 4278 OS::SNPrintF(buffer, "named_values[%d].propertyType()", i);
4279 CHECK_EQ(5, CompileRun(buffer.start())->Int32Value()); 4279 CHECK_EQ(5, CompileRun(buffer.start())->Int32Value());
4280 4280
4281 OS::SNPrintF(buffer, "named_values[%d].isNative()", i); 4281 OS::SNPrintF(buffer, "named_values[%d].isNative()", i);
4282 CHECK(CompileRun(buffer.start())->BooleanValue()); 4282 CHECK(CompileRun(buffer.start())->BooleanValue());
4283 } 4283 }
4284 4284
4285 // Get the interceptor properties for the object with only indexed 4285 // Get the interceptor properties for the object with only indexed
4286 // interceptor. 4286 // interceptor.
4287 CompileRun("indexed_values = indexed_mirror.properties()"); 4287 CompileRun("var indexed_values = indexed_mirror.properties()");
4288 4288
4289 // Check that the properties are interceptor properties. 4289 // Check that the properties are interceptor properties.
4290 for (int i = 0; i < 2; i++) { 4290 for (int i = 0; i < 2; i++) {
4291 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; 4291 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
4292 OS::SNPrintF(buffer, 4292 OS::SNPrintF(buffer,
4293 "indexed_values[%d] instanceof debug.PropertyMirror", i); 4293 "indexed_values[%d] instanceof debug.PropertyMirror", i);
4294 CHECK(CompileRun(buffer.start())->BooleanValue()); 4294 CHECK(CompileRun(buffer.start())->BooleanValue());
4295 } 4295 }
4296 4296
4297 // Get the interceptor properties for the object with both types of 4297 // Get the interceptor properties for the object with both types of
4298 // interceptors. 4298 // interceptors.
4299 CompileRun("both_values = both_mirror.properties()"); 4299 CompileRun("var both_values = both_mirror.properties()");
4300 4300
4301 // Check that the properties are interceptor properties. 4301 // Check that the properties are interceptor properties.
4302 for (int i = 0; i < 5; i++) { 4302 for (int i = 0; i < 5; i++) {
4303 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; 4303 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer;
4304 OS::SNPrintF(buffer, "both_values[%d] instanceof debug.PropertyMirror", i); 4304 OS::SNPrintF(buffer, "both_values[%d] instanceof debug.PropertyMirror", i);
4305 CHECK(CompileRun(buffer.start())->BooleanValue()); 4305 CHECK(CompileRun(buffer.start())->BooleanValue());
4306 } 4306 }
4307 4307
4308 // Check the property names. 4308 // Check the property names.
4309 source = "both_values[0].name() == 'a'"; 4309 source = "both_values[0].name() == 'a'";
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
4345 env->Global()->Set(v8::String::New("o0"), o0); 4345 env->Global()->Set(v8::String::New("o0"), o0);
4346 v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance(); 4346 v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance();
4347 env->Global()->Set(v8::String::New("o1"), o1); 4347 env->Global()->Set(v8::String::New("o1"), o1);
4348 v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance(); 4348 v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance();
4349 env->Global()->Set(v8::String::New("o2"), o2); 4349 env->Global()->Set(v8::String::New("o2"), o2);
4350 v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance(); 4350 v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance();
4351 env->Global()->Set(v8::String::New("o3"), o3); 4351 env->Global()->Set(v8::String::New("o3"), o3);
4352 4352
4353 // Get mirrors for the four objects. 4353 // Get mirrors for the four objects.
4354 CompileRun( 4354 CompileRun(
4355 "o0_mirror = debug.MakeMirror(o0);" 4355 "var o0_mirror = debug.MakeMirror(o0);"
4356 "o1_mirror = debug.MakeMirror(o1);" 4356 "var o1_mirror = debug.MakeMirror(o1);"
4357 "o2_mirror = debug.MakeMirror(o2);" 4357 "var o2_mirror = debug.MakeMirror(o2);"
4358 "o3_mirror = debug.MakeMirror(o3)"); 4358 "var o3_mirror = debug.MakeMirror(o3)");
4359 CHECK(CompileRun("o0_mirror instanceof debug.ObjectMirror")->BooleanValue()); 4359 CHECK(CompileRun("o0_mirror instanceof debug.ObjectMirror")->BooleanValue());
4360 CHECK(CompileRun("o1_mirror instanceof debug.ObjectMirror")->BooleanValue()); 4360 CHECK(CompileRun("o1_mirror instanceof debug.ObjectMirror")->BooleanValue());
4361 CHECK(CompileRun("o2_mirror instanceof debug.ObjectMirror")->BooleanValue()); 4361 CHECK(CompileRun("o2_mirror instanceof debug.ObjectMirror")->BooleanValue());
4362 CHECK(CompileRun("o3_mirror instanceof debug.ObjectMirror")->BooleanValue()); 4362 CHECK(CompileRun("o3_mirror instanceof debug.ObjectMirror")->BooleanValue());
4363 4363
4364 // Check that each object has one property. 4364 // Check that each object has one property.
4365 CHECK_EQ(1, CompileRun( 4365 CHECK_EQ(1, CompileRun(
4366 "o0_mirror.propertyNames().length")->Int32Value()); 4366 "o0_mirror.propertyNames().length")->Int32Value());
4367 CHECK_EQ(1, CompileRun( 4367 CHECK_EQ(1, CompileRun(
4368 "o1_mirror.propertyNames().length")->Int32Value()); 4368 "o1_mirror.propertyNames().length")->Int32Value());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
4434 // Create object with named accessor. 4434 // Create object with named accessor.
4435 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); 4435 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New();
4436 named->SetAccessor(name, &ProtperyXNativeGetter, NULL, 4436 named->SetAccessor(name, &ProtperyXNativeGetter, NULL,
4437 v8::Handle<v8::Value>(), v8::DEFAULT, v8::None); 4437 v8::Handle<v8::Value>(), v8::DEFAULT, v8::None);
4438 4438
4439 // Create object with named property getter. 4439 // Create object with named property getter.
4440 env->Global()->Set(v8::String::New("instance"), named->NewInstance()); 4440 env->Global()->Set(v8::String::New("instance"), named->NewInstance());
4441 CHECK_EQ(10, CompileRun("instance.x")->Int32Value()); 4441 CHECK_EQ(10, CompileRun("instance.x")->Int32Value());
4442 4442
4443 // Get mirror for the object with property getter. 4443 // Get mirror for the object with property getter.
4444 CompileRun("instance_mirror = debug.MakeMirror(instance);"); 4444 CompileRun("var instance_mirror = debug.MakeMirror(instance);");
4445 CHECK(CompileRun( 4445 CHECK(CompileRun(
4446 "instance_mirror instanceof debug.ObjectMirror")->BooleanValue()); 4446 "instance_mirror instanceof debug.ObjectMirror")->BooleanValue());
4447 4447
4448 CompileRun("named_names = instance_mirror.propertyNames();"); 4448 CompileRun("var named_names = instance_mirror.propertyNames();");
4449 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); 4449 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value());
4450 CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue()); 4450 CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue());
4451 CHECK(CompileRun( 4451 CHECK(CompileRun(
4452 "instance_mirror.property('x').value().isNumber()")->BooleanValue()); 4452 "instance_mirror.property('x').value().isNumber()")->BooleanValue());
4453 CHECK(CompileRun( 4453 CHECK(CompileRun(
4454 "instance_mirror.property('x').value().value() == 10")->BooleanValue()); 4454 "instance_mirror.property('x').value().value() == 10")->BooleanValue());
4455 } 4455 }
4456 4456
4457 4457
4458 static v8::Handle<v8::Value> ProtperyXNativeGetterThrowingError( 4458 static v8::Handle<v8::Value> ProtperyXNativeGetterThrowingError(
(...skipping 11 matching lines...) Expand all
4470 v8::Handle<v8::String> name = v8::String::New("x"); 4470 v8::Handle<v8::String> name = v8::String::New("x");
4471 // Create object with named accessor. 4471 // Create object with named accessor.
4472 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); 4472 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New();
4473 named->SetAccessor(name, &ProtperyXNativeGetterThrowingError, NULL, 4473 named->SetAccessor(name, &ProtperyXNativeGetterThrowingError, NULL,
4474 v8::Handle<v8::Value>(), v8::DEFAULT, v8::None); 4474 v8::Handle<v8::Value>(), v8::DEFAULT, v8::None);
4475 4475
4476 // Create object with named property getter. 4476 // Create object with named property getter.
4477 env->Global()->Set(v8::String::New("instance"), named->NewInstance()); 4477 env->Global()->Set(v8::String::New("instance"), named->NewInstance());
4478 4478
4479 // Get mirror for the object with property getter. 4479 // Get mirror for the object with property getter.
4480 CompileRun("instance_mirror = debug.MakeMirror(instance);"); 4480 CompileRun("var instance_mirror = debug.MakeMirror(instance);");
4481 CHECK(CompileRun( 4481 CHECK(CompileRun(
4482 "instance_mirror instanceof debug.ObjectMirror")->BooleanValue()); 4482 "instance_mirror instanceof debug.ObjectMirror")->BooleanValue());
4483 CompileRun("named_names = instance_mirror.propertyNames();"); 4483 CompileRun("named_names = instance_mirror.propertyNames();");
4484 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); 4484 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value());
4485 CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue()); 4485 CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue());
4486 CHECK(CompileRun( 4486 CHECK(CompileRun(
4487 "instance_mirror.property('x').value().isError()")->BooleanValue()); 4487 "instance_mirror.property('x').value().isError()")->BooleanValue());
4488 4488
4489 // Check that the message is that passed to the Error constructor. 4489 // Check that the message is that passed to the Error constructor.
4490 CHECK(CompileRun( 4490 CHECK(CompileRun(
(...skipping 2850 matching lines...) Expand 10 before | Expand all | Expand 10 after
7341 "g(false); \n" 7341 "g(false); \n"
7342 "%OptimizeFunctionOnNextCall(g); \n" 7342 "%OptimizeFunctionOnNextCall(g); \n"
7343 "g(true);"; 7343 "g(true);";
7344 v8::Debug::SetDebugEventListener(DebugBreakInlineListener); 7344 v8::Debug::SetDebugEventListener(DebugBreakInlineListener);
7345 inline_script = v8::Script::Compile(v8::String::New(source)); 7345 inline_script = v8::Script::Compile(v8::String::New(source));
7346 inline_script->Run(); 7346 inline_script->Run();
7347 } 7347 }
7348 7348
7349 7349
7350 #endif // ENABLE_DEBUGGER_SUPPORT 7350 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « src/v8natives.js ('k') | test/mjsunit/builtins.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698