| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 221 |
| 222 v8::Handle<Integer> DeclarationContext::Query(Local<String> key) { | 222 v8::Handle<Integer> DeclarationContext::Query(Local<String> key) { |
| 223 return v8::Handle<Integer>(); | 223 return v8::Handle<Integer>(); |
| 224 } | 224 } |
| 225 | 225 |
| 226 | 226 |
| 227 // Test global declaration of a property the interceptor doesn't know | 227 // Test global declaration of a property the interceptor doesn't know |
| 228 // about and doesn't handle. | 228 // about and doesn't handle. |
| 229 TEST(Unknown) { | 229 TEST(Unknown) { |
| 230 HandleScope scope(CcTest::isolate()); | 230 HandleScope scope(CcTest::isolate()); |
| 231 v8::V8::Initialize(); |
| 231 | 232 |
| 232 { DeclarationContext context; | 233 { DeclarationContext context; |
| 233 context.Check("var x; x", | 234 context.Check("var x; x", |
| 234 1, // access | 235 1, // access |
| 235 1, // declaration | 236 1, // declaration |
| 236 2, // declaration + initialization | 237 2, // declaration + initialization |
| 237 EXPECT_RESULT, Undefined(CcTest::isolate())); | 238 EXPECT_RESULT, Undefined(CcTest::isolate())); |
| 238 } | 239 } |
| 239 | 240 |
| 240 { DeclarationContext context; | 241 { DeclarationContext context; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 class AbsentPropertyContext: public DeclarationContext { | 332 class AbsentPropertyContext: public DeclarationContext { |
| 332 protected: | 333 protected: |
| 333 virtual v8::Handle<Integer> Query(Local<String> key) { | 334 virtual v8::Handle<Integer> Query(Local<String> key) { |
| 334 return v8::Handle<Integer>(); | 335 return v8::Handle<Integer>(); |
| 335 } | 336 } |
| 336 }; | 337 }; |
| 337 | 338 |
| 338 | 339 |
| 339 TEST(Absent) { | 340 TEST(Absent) { |
| 340 v8::Isolate* isolate = CcTest::isolate(); | 341 v8::Isolate* isolate = CcTest::isolate(); |
| 342 v8::V8::Initialize(); |
| 341 HandleScope scope(isolate); | 343 HandleScope scope(isolate); |
| 342 | 344 |
| 343 { AbsentPropertyContext context; | 345 { AbsentPropertyContext context; |
| 344 context.Check("var x; x", | 346 context.Check("var x; x", |
| 345 1, // access | 347 1, // access |
| 346 1, // declaration | 348 1, // declaration |
| 347 2, // declaration + initialization | 349 2, // declaration + initialization |
| 348 EXPECT_RESULT, Undefined(isolate)); | 350 EXPECT_RESULT, Undefined(isolate)); |
| 349 } | 351 } |
| 350 | 352 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 // Do the lookup in the object. | 423 // Do the lookup in the object. |
| 422 return v8::Handle<Integer>(); | 424 return v8::Handle<Integer>(); |
| 423 } | 425 } |
| 424 | 426 |
| 425 private: | 427 private: |
| 426 State state_; | 428 State state_; |
| 427 }; | 429 }; |
| 428 | 430 |
| 429 | 431 |
| 430 TEST(Appearing) { | 432 TEST(Appearing) { |
| 433 v8::V8::Initialize(); |
| 431 HandleScope scope(CcTest::isolate()); | 434 HandleScope scope(CcTest::isolate()); |
| 432 | 435 |
| 433 { AppearingPropertyContext context; | 436 { AppearingPropertyContext context; |
| 434 context.Check("var x; x", | 437 context.Check("var x; x", |
| 435 1, // access | 438 1, // access |
| 436 1, // declaration | 439 1, // declaration |
| 437 2, // declaration + initialization | 440 2, // declaration + initialization |
| 438 EXPECT_RESULT, Undefined(CcTest::isolate())); | 441 EXPECT_RESULT, Undefined(CcTest::isolate())); |
| 439 } | 442 } |
| 440 | 443 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 // Do the lookup in the object. | 516 // Do the lookup in the object. |
| 514 return Handle<Integer>(); | 517 return Handle<Integer>(); |
| 515 } | 518 } |
| 516 | 519 |
| 517 private: | 520 private: |
| 518 State state_; | 521 State state_; |
| 519 }; | 522 }; |
| 520 | 523 |
| 521 | 524 |
| 522 TEST(Reappearing) { | 525 TEST(Reappearing) { |
| 526 v8::V8::Initialize(); |
| 523 HandleScope scope(CcTest::isolate()); | 527 HandleScope scope(CcTest::isolate()); |
| 524 | 528 |
| 525 { ReappearingPropertyContext context; | 529 { ReappearingPropertyContext context; |
| 526 context.Check("const x; var x = 0", | 530 context.Check("const x; var x = 0", |
| 527 0, | 531 0, |
| 528 3, // const declaration+initialization, var initialization | 532 3, // const declaration+initialization, var initialization |
| 529 3, // 2 x declaration + var initialization | 533 3, // 2 x declaration + var initialization |
| 530 EXPECT_RESULT, Undefined(CcTest::isolate())); | 534 EXPECT_RESULT, Undefined(CcTest::isolate())); |
| 531 } | 535 } |
| 532 } | 536 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 | 609 |
| 606 // Use the prototype as the holder for the interceptors. | 610 // Use the prototype as the holder for the interceptors. |
| 607 virtual Local<ObjectTemplate> GetHolder(Local<FunctionTemplate> function) { | 611 virtual Local<ObjectTemplate> GetHolder(Local<FunctionTemplate> function) { |
| 608 return function->PrototypeTemplate(); | 612 return function->PrototypeTemplate(); |
| 609 } | 613 } |
| 610 }; | 614 }; |
| 611 | 615 |
| 612 | 616 |
| 613 TEST(AbsentInPrototype) { | 617 TEST(AbsentInPrototype) { |
| 614 i::FLAG_es52_globals = true; | 618 i::FLAG_es52_globals = true; |
| 619 v8::V8::Initialize(); |
| 615 HandleScope scope(CcTest::isolate()); | 620 HandleScope scope(CcTest::isolate()); |
| 616 | 621 |
| 617 { AbsentInPrototypeContext context; | 622 { AbsentInPrototypeContext context; |
| 618 context.Check("if (false) { var x = 0; }; x", | 623 context.Check("if (false) { var x = 0; }; x", |
| 619 0, | 624 0, |
| 620 0, | 625 0, |
| 621 0, | 626 0, |
| 622 EXPECT_RESULT, Undefined(CcTest::isolate())); | 627 EXPECT_RESULT, Undefined(CcTest::isolate())); |
| 623 } | 628 } |
| 624 } | 629 } |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 SimpleContext context; | 854 SimpleContext context; |
| 850 context.Check(firsts[i], EXPECT_RESULT, Number::New(1)); | 855 context.Check(firsts[i], EXPECT_RESULT, Number::New(1)); |
| 851 // TODO(rossberg): All tests should actually be errors in Harmony, | 856 // TODO(rossberg): All tests should actually be errors in Harmony, |
| 852 // but we currently do not detect the cases where the first declaration | 857 // but we currently do not detect the cases where the first declaration |
| 853 // is not lexical. | 858 // is not lexical. |
| 854 context.Check(seconds[j], | 859 context.Check(seconds[j], |
| 855 i < 2 ? EXPECT_RESULT : EXPECT_ERROR, Number::New(2)); | 860 i < 2 ? EXPECT_RESULT : EXPECT_ERROR, Number::New(2)); |
| 856 } | 861 } |
| 857 } | 862 } |
| 858 } | 863 } |
| OLD | NEW |