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

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

Issue 7811015: Change global const handling to silently ignore redeclarations (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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
OLDNEW
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 { PresentPropertyContext context; 278 { PresentPropertyContext context;
279 context.Check("function x() { }; x", 279 context.Check("function x() { }; x",
280 1, // access 280 1, // access
281 0, 281 0,
282 0, 282 0,
283 EXPECT_RESULT); 283 EXPECT_RESULT);
284 } 284 }
285 285
286 { PresentPropertyContext context; 286 { PresentPropertyContext context;
287 context.Check("const x; x", 287 context.Check("const x; x",
288 1, // access
288 0, 289 0,
289 0, 290 2, // (re-)declaration + initialization
290 1, // (re-)declaration 291 EXPECT_EXCEPTION); // x is not defined!
291 EXPECT_EXCEPTION); // x has already been declared!
292 } 292 }
293 293
294 { PresentPropertyContext context; 294 { PresentPropertyContext context;
295 context.Check("const x = 0; x", 295 context.Check("const x = 0; x",
296 1, // access
296 0, 297 0,
297 0, 298 2, // (re-)declaration + initialization
298 1, // (re-)declaration 299 EXPECT_EXCEPTION); // x is not defined!
299 EXPECT_EXCEPTION); // x has already been declared!
300 } 300 }
301 } 301 }
302 302
303 303
304 304
305 class AbsentPropertyContext: public DeclarationContext { 305 class AbsentPropertyContext: public DeclarationContext {
306 protected: 306 protected:
307 virtual v8::Handle<Integer> Query(Local<String> key) { 307 virtual v8::Handle<Integer> Query(Local<String> key) {
308 return v8::Handle<Integer>(); 308 return v8::Handle<Integer>();
309 } 309 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 { AppearingPropertyContext context; 422 { AppearingPropertyContext context;
423 context.Check("function x() { }; x", 423 context.Check("function x() { }; x",
424 1, // access 424 1, // access
425 0, 425 0,
426 0, 426 0,
427 EXPECT_RESULT); 427 EXPECT_RESULT);
428 } 428 }
429 429
430 { AppearingPropertyContext context; 430 { AppearingPropertyContext context;
431 context.Check("const x; x", 431 context.Check("const x; x",
432 0, 432 1, // access
433 1, // declaration 433 1, // declaration
434 2, // declaration + initialization 434 2, // declaration + initialization
435 EXPECT_EXCEPTION); // x has already been declared! 435 EXPECT_RESULT, Undefined());
436 } 436 }
437 437
438 { AppearingPropertyContext context; 438 { AppearingPropertyContext context;
439 context.Check("const x = 0; x", 439 context.Check("const x = 0; x",
440 0, 440 1, // access
441 1, // declaration 441 1, // declaration
442 2, // declaration + initialization 442 2, // declaration + initialization
443 EXPECT_EXCEPTION); // x has already been declared! 443 EXPECT_RESULT, Undefined());
444 // Result is undefined because declaration succeeded but
445 // initialization to 0 failed (due to context behavior).
444 } 446 }
445 } 447 }
446 448
447 449
448 450
449 class ReappearingPropertyContext: public DeclarationContext { 451 class ReappearingPropertyContext: public DeclarationContext {
450 public: 452 public:
451 enum State { 453 enum State {
452 DECLARE, 454 DECLARE,
453 DONT_DECLARE, 455 DONT_DECLARE,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 493
492 494
493 TEST(Reappearing) { 495 TEST(Reappearing) {
494 HandleScope scope; 496 HandleScope scope;
495 497
496 { ReappearingPropertyContext context; 498 { ReappearingPropertyContext context;
497 context.Check("const x; var x = 0", 499 context.Check("const x; var x = 0",
498 0, 500 0,
499 2, // var declaration + const initialization 501 2, // var declaration + const initialization
500 4, // 2 x declaration + 2 x initialization 502 4, // 2 x declaration + 2 x initialization
501 EXPECT_EXCEPTION); // x has already been declared! 503 EXPECT_RESULT, Undefined());
502 } 504 }
503 } 505 }
504 506
505 507
506 508
507 class ExistsInPrototypeContext: public DeclarationContext { 509 class ExistsInPrototypeContext: public DeclarationContext {
508 protected: 510 protected:
509 virtual v8::Handle<Integer> Query(Local<String> key) { 511 virtual v8::Handle<Integer> Query(Local<String> key) {
510 // Let it seem that the property exists in the prototype object. 512 // Let it seem that the property exists in the prototype object.
511 return Integer::New(v8::None); 513 return Integer::New(v8::None);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 HandleScope scope; 586 HandleScope scope;
585 587
586 { AbsentInPrototypeContext context; 588 { AbsentInPrototypeContext context;
587 context.Check("if (false) { var x = 0; }; x", 589 context.Check("if (false) { var x = 0; }; x",
588 0, 590 0,
589 0, 591 0,
590 1, // declaration 592 1, // declaration
591 EXPECT_RESULT, Undefined()); 593 EXPECT_RESULT, Undefined());
592 } 594 }
593 } 595 }
OLDNEW
« src/runtime.cc ('K') | « src/v8natives.js ('k') | test/es5conform/es5conform.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698