| OLD | NEW |
| 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 1, // access | 225 1, // access |
| 226 0, | 226 0, |
| 227 0, | 227 0, |
| 228 EXPECT_RESULT); | 228 EXPECT_RESULT); |
| 229 } | 229 } |
| 230 | 230 |
| 231 { DeclarationContext context; | 231 { DeclarationContext context; |
| 232 context.Check("const x; x", | 232 context.Check("const x; x", |
| 233 1, // access | 233 1, // access |
| 234 2, // declaration + initialization | 234 2, // declaration + initialization |
| 235 2, // declaration + initialization | 235 1, // declaration |
| 236 EXPECT_RESULT, Undefined()); | 236 EXPECT_RESULT, Undefined()); |
| 237 } | 237 } |
| 238 | 238 |
| 239 { DeclarationContext context; | 239 { DeclarationContext context; |
| 240 context.Check("const x = 0; x", | 240 context.Check("const x = 0; x", |
| 241 1, // access | 241 1, // access |
| 242 2, // declaration + initialization | 242 2, // declaration + initialization |
| 243 2, // declaration + initialization | 243 1, // declaration |
| 244 EXPECT_RESULT, Undefined()); // SB 0 - BUG 1213579 | 244 EXPECT_RESULT, Undefined()); // SB 0 - BUG 1213579 |
| 245 } | 245 } |
| 246 } | 246 } |
| 247 | 247 |
| 248 | 248 |
| 249 | 249 |
| 250 class PresentPropertyContext: public DeclarationContext { | 250 class PresentPropertyContext: public DeclarationContext { |
| 251 protected: | 251 protected: |
| 252 virtual v8::Handle<Integer> Query(Local<String> key) { | 252 virtual v8::Handle<Integer> Query(Local<String> key) { |
| 253 return Integer::New(v8::None); | 253 return Integer::New(v8::None); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 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 0, | 288 1, // access |
| 289 0, | 289 1, // initialization |
| 290 1, // (re-)declaration | 290 1, // (re-)declaration |
| 291 EXPECT_EXCEPTION); // x has already been declared! | 291 EXPECT_RESULT, Undefined()); |
| 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 0, | 296 1, // access |
| 297 0, | 297 1, // initialization |
| 298 1, // (re-)declaration | 298 1, // (re-)declaration |
| 299 EXPECT_EXCEPTION); // x has already been declared! | 299 EXPECT_RESULT, Number::New(0)); |
| 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 24 matching lines...) Expand all Loading... |
| 334 1, // access | 334 1, // access |
| 335 0, | 335 0, |
| 336 0, | 336 0, |
| 337 EXPECT_RESULT); | 337 EXPECT_RESULT); |
| 338 } | 338 } |
| 339 | 339 |
| 340 { AbsentPropertyContext context; | 340 { AbsentPropertyContext context; |
| 341 context.Check("const x; x", | 341 context.Check("const x; x", |
| 342 1, // access | 342 1, // access |
| 343 2, // declaration + initialization | 343 2, // declaration + initialization |
| 344 2, // declaration + initializetion | 344 1, // declaration |
| 345 EXPECT_RESULT, Undefined()); | 345 EXPECT_RESULT, Undefined()); |
| 346 } | 346 } |
| 347 | 347 |
| 348 { AbsentPropertyContext context; | 348 { AbsentPropertyContext context; |
| 349 context.Check("const x = 0; x", | 349 context.Check("const x = 0; x", |
| 350 1, // access | 350 1, // access |
| 351 2, // declaration + initialization | 351 2, // declaration + initialization |
| 352 2, // declaration + initialization | 352 1, // declaration |
| 353 EXPECT_RESULT, Undefined()); // SB 0 - BUG 1213579 | 353 EXPECT_RESULT, Undefined()); // SB 0 - BUG 1213579 |
| 354 } | 354 } |
| 355 | 355 |
| 356 { AbsentPropertyContext context; | 356 { AbsentPropertyContext context; |
| 357 context.Check("if (false) { var x = 0 }; x", | 357 context.Check("if (false) { var x = 0 }; x", |
| 358 1, // access | 358 1, // access |
| 359 1, // declaration | 359 1, // declaration |
| 360 1, // declaration + initialization | 360 1, // declaration + initialization |
| 361 EXPECT_RESULT, Undefined()); | 361 EXPECT_RESULT, Undefined()); |
| 362 } | 362 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 2, // declaration + initialization |
| 433 1, // declaration | 434 1, // declaration |
| 434 2, // declaration + initialization | 435 EXPECT_RESULT, Undefined()); |
| 435 EXPECT_EXCEPTION); // x has already been declared! | |
| 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 2, // declaration + initialization |
| 441 1, // declaration | 442 1, // declaration |
| 442 2, // declaration + initialization | 443 EXPECT_RESULT, Undefined()); |
| 443 EXPECT_EXCEPTION); // x has already been declared! | 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 State state_; | 491 State state_; |
| 490 }; | 492 }; |
| 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 3, // const declaration+initialization, var initialization |
| 500 4, // 2 x declaration + 2 x initialization | 502 3, // 2 x declaration + var 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 Loading... |
| 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 } |
| OLD | NEW |