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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 220 |
221 | 221 |
222 v8::Local<Integer> DeclarationContext::Query(Local<Name> key) { | 222 v8::Local<Integer> DeclarationContext::Query(Local<Name> key) { |
223 return v8::Local<Integer>(); | 223 return v8::Local<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 i::FLAG_legacy_const = true; |
230 HandleScope scope(CcTest::isolate()); | 231 HandleScope scope(CcTest::isolate()); |
231 v8::V8::Initialize(); | 232 v8::V8::Initialize(); |
232 | 233 |
233 { DeclarationContext context; | 234 { DeclarationContext context; |
234 context.Check("var x; x", | 235 context.Check("var x; x", |
235 1, // access | 236 1, // access |
236 0, 0, EXPECT_RESULT, Undefined(CcTest::isolate())); | 237 0, 0, EXPECT_RESULT, Undefined(CcTest::isolate())); |
237 } | 238 } |
238 | 239 |
239 { DeclarationContext context; | 240 { DeclarationContext context; |
(...skipping 29 matching lines...) Expand all Loading... |
269 | 270 |
270 class AbsentPropertyContext: public DeclarationContext { | 271 class AbsentPropertyContext: public DeclarationContext { |
271 protected: | 272 protected: |
272 virtual v8::Local<Integer> Query(Local<Name> key) { | 273 virtual v8::Local<Integer> Query(Local<Name> key) { |
273 return v8::Local<Integer>(); | 274 return v8::Local<Integer>(); |
274 } | 275 } |
275 }; | 276 }; |
276 | 277 |
277 | 278 |
278 TEST(Absent) { | 279 TEST(Absent) { |
| 280 i::FLAG_legacy_const = true; |
279 v8::Isolate* isolate = CcTest::isolate(); | 281 v8::Isolate* isolate = CcTest::isolate(); |
280 v8::V8::Initialize(); | 282 v8::V8::Initialize(); |
281 HandleScope scope(isolate); | 283 HandleScope scope(isolate); |
282 | 284 |
283 { AbsentPropertyContext context; | 285 { AbsentPropertyContext context; |
284 context.Check("var x; x", | 286 context.Check("var x; x", |
285 1, // access | 287 1, // access |
286 0, 0, EXPECT_RESULT, Undefined(isolate)); | 288 0, 0, EXPECT_RESULT, Undefined(isolate)); |
287 } | 289 } |
288 | 290 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 // Do the lookup in the object. | 354 // Do the lookup in the object. |
353 return v8::Local<Integer>(); | 355 return v8::Local<Integer>(); |
354 } | 356 } |
355 | 357 |
356 private: | 358 private: |
357 State state_; | 359 State state_; |
358 }; | 360 }; |
359 | 361 |
360 | 362 |
361 TEST(Appearing) { | 363 TEST(Appearing) { |
| 364 i::FLAG_legacy_const = true; |
362 v8::V8::Initialize(); | 365 v8::V8::Initialize(); |
363 HandleScope scope(CcTest::isolate()); | 366 HandleScope scope(CcTest::isolate()); |
364 | 367 |
365 { AppearingPropertyContext context; | 368 { AppearingPropertyContext context; |
366 context.Check("var x; x", | 369 context.Check("var x; x", |
367 1, // access | 370 1, // access |
368 0, 0, EXPECT_RESULT, Undefined(CcTest::isolate())); | 371 0, 0, EXPECT_RESULT, Undefined(CcTest::isolate())); |
369 } | 372 } |
370 | 373 |
371 { AppearingPropertyContext context; | 374 { AppearingPropertyContext context; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 } | 411 } |
409 | 412 |
410 // Use the prototype as the holder for the interceptors. | 413 // Use the prototype as the holder for the interceptors. |
411 virtual Local<ObjectTemplate> GetHolder(Local<FunctionTemplate> function) { | 414 virtual Local<ObjectTemplate> GetHolder(Local<FunctionTemplate> function) { |
412 return function->PrototypeTemplate(); | 415 return function->PrototypeTemplate(); |
413 } | 416 } |
414 }; | 417 }; |
415 | 418 |
416 | 419 |
417 TEST(ExistsInPrototype) { | 420 TEST(ExistsInPrototype) { |
| 421 i::FLAG_legacy_const = true; |
418 HandleScope scope(CcTest::isolate()); | 422 HandleScope scope(CcTest::isolate()); |
419 | 423 |
420 // Sanity check to make sure that the holder of the interceptor | 424 // Sanity check to make sure that the holder of the interceptor |
421 // really is the prototype object. | 425 // really is the prototype object. |
422 { ExistsInPrototypeContext context; | 426 { ExistsInPrototypeContext context; |
423 context.Check("this.x = 87; this.x", 0, 0, 1, EXPECT_RESULT, | 427 context.Check("this.x = 87; this.x", 0, 0, 1, EXPECT_RESULT, |
424 Number::New(CcTest::isolate(), 87)); | 428 Number::New(CcTest::isolate(), 87)); |
425 } | 429 } |
426 | 430 |
427 { ExistsInPrototypeContext context; | 431 { ExistsInPrototypeContext context; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 virtual Local<ObjectTemplate> GetHolder(Local<FunctionTemplate> function) { | 521 virtual Local<ObjectTemplate> GetHolder(Local<FunctionTemplate> function) { |
518 return hidden_proto_->InstanceTemplate(); | 522 return hidden_proto_->InstanceTemplate(); |
519 } | 523 } |
520 | 524 |
521 private: | 525 private: |
522 Local<FunctionTemplate> hidden_proto_; | 526 Local<FunctionTemplate> hidden_proto_; |
523 }; | 527 }; |
524 | 528 |
525 | 529 |
526 TEST(ExistsInHiddenPrototype) { | 530 TEST(ExistsInHiddenPrototype) { |
| 531 i::FLAG_legacy_const = true; |
527 HandleScope scope(CcTest::isolate()); | 532 HandleScope scope(CcTest::isolate()); |
528 | 533 |
529 { ExistsInHiddenPrototypeContext context; | 534 { ExistsInHiddenPrototypeContext context; |
530 context.Check("var x; x", 0, 0, 0, EXPECT_RESULT, | 535 context.Check("var x; x", 0, 0, 0, EXPECT_RESULT, |
531 Undefined(CcTest::isolate())); | 536 Undefined(CcTest::isolate())); |
532 } | 537 } |
533 | 538 |
534 { ExistsInHiddenPrototypeContext context; | 539 { ExistsInHiddenPrototypeContext context; |
535 context.Check("var x = 0; x", 0, 0, 0, EXPECT_RESULT, | 540 context.Check("var x = 0; x", 0, 0, 0, EXPECT_RESULT, |
536 Number::New(CcTest::isolate(), 0)); | 541 Number::New(CcTest::isolate(), 0)); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 } | 605 } |
601 } | 606 } |
602 | 607 |
603 private: | 608 private: |
604 HandleScope handle_scope_; | 609 HandleScope handle_scope_; |
605 Local<Context> context_; | 610 Local<Context> context_; |
606 }; | 611 }; |
607 | 612 |
608 | 613 |
609 TEST(CrossScriptReferences) { | 614 TEST(CrossScriptReferences) { |
| 615 i::FLAG_legacy_const = true; |
610 v8::Isolate* isolate = CcTest::isolate(); | 616 v8::Isolate* isolate = CcTest::isolate(); |
611 HandleScope scope(isolate); | 617 HandleScope scope(isolate); |
612 | 618 |
613 { SimpleContext context; | 619 { SimpleContext context; |
614 context.Check("var x = 1; x", | 620 context.Check("var x = 1; x", |
615 EXPECT_RESULT, Number::New(isolate, 1)); | 621 EXPECT_RESULT, Number::New(isolate, 1)); |
616 context.Check("var x = 2; x", | 622 context.Check("var x = 2; x", |
617 EXPECT_RESULT, Number::New(isolate, 2)); | 623 EXPECT_RESULT, Number::New(isolate, 2)); |
618 context.Check("const x = 3; x", EXPECT_EXCEPTION); | 624 context.Check("const x = 3; x", EXPECT_EXCEPTION); |
619 context.Check("const x = 4; x", EXPECT_EXCEPTION); | 625 context.Check("const x = 4; x", EXPECT_EXCEPTION); |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1258 Undefined(CcTest::isolate())); | 1264 Undefined(CcTest::isolate())); |
1259 for (int i = 0; i < 4; i++) { | 1265 for (int i = 0; i < 4; i++) { |
1260 context.Check("f()", EXPECT_EXCEPTION); | 1266 context.Check("f()", EXPECT_EXCEPTION); |
1261 } | 1267 } |
1262 context.Check("%OptimizeFunctionOnNextCall(f);", EXPECT_RESULT, | 1268 context.Check("%OptimizeFunctionOnNextCall(f);", EXPECT_RESULT, |
1263 Undefined(CcTest::isolate())); | 1269 Undefined(CcTest::isolate())); |
1264 | 1270 |
1265 context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION); | 1271 context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION); |
1266 } | 1272 } |
1267 } | 1273 } |
OLD | NEW |