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

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

Issue 705663004: harmony_scoping: Implement lexical bindings at top level (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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
« src/runtime/runtime-scopes.cc ('K') | « src/runtime/runtime-scopes.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 context.Check("var x = 5; x", // assignment ignored 637 context.Check("var x = 5; x", // assignment ignored
638 EXPECT_RESULT, Number::New(isolate, 1)); 638 EXPECT_RESULT, Number::New(isolate, 1));
639 context.Check("this.x", 639 context.Check("this.x",
640 EXPECT_RESULT, Number::New(isolate, 1)); 640 EXPECT_RESULT, Number::New(isolate, 1));
641 context.Check("function x() { return 7 }; x", 641 context.Check("function x() { return 7 }; x",
642 EXPECT_EXCEPTION); 642 EXPECT_EXCEPTION);
643 } 643 }
644 } 644 }
645 645
646 646
647 TEST(CrossScriptReferences_Simple) {
648 i::FLAG_harmony_scoping = true;
649 i::FLAG_use_strict = true;
650
651 v8::Isolate* isolate = CcTest::isolate();
652 HandleScope scope(isolate);
653
654 {
655 SimpleContext context;
656 context.Check("let x = 1; x", EXPECT_RESULT, Number::New(isolate, 1));
657 context.Check("let x = 5; x", EXPECT_EXCEPTION);
658 }
659 }
660
661
662 TEST(CrossScriptReferences_Simple2) {
663 i::FLAG_harmony_scoping = true;
664 i::FLAG_use_strict = true;
665
666 v8::Isolate* isolate = CcTest::isolate();
667 HandleScope scope(isolate);
668
669 for (int k = 0; k < 100; k++) {
670 SimpleContext context;
671 bool cond = (k % 2) == 0;
672 if (cond) {
673 printf("First!\n");
674 context.Check("let x = 1; x", EXPECT_RESULT, Number::New(isolate, 1));
675 context.Check("let z = 4; z", EXPECT_RESULT, Number::New(isolate, 4));
676 } else {
677 printf("Second!\n");
678 context.Check("let z = 1; z", EXPECT_RESULT, Number::New(isolate, 1));
679 context.Check("let x = 4; x", EXPECT_RESULT, Number::New(isolate, 4));
680 }
681 context.Check("let y = 2; x", EXPECT_RESULT,
682 Number::New(isolate, cond ? 1 : 4));
683 }
684 }
685
686
647 TEST(CrossScriptReferencesHarmony) { 687 TEST(CrossScriptReferencesHarmony) {
648 i::FLAG_use_strict = true; 688 i::FLAG_use_strict = true;
649 i::FLAG_harmony_scoping = true; 689 i::FLAG_harmony_scoping = true;
650 i::FLAG_harmony_modules = true; 690 i::FLAG_harmony_modules = true;
651 691
652 v8::Isolate* isolate = CcTest::isolate(); 692 v8::Isolate* isolate = CcTest::isolate();
653 HandleScope scope(isolate); 693 HandleScope scope(isolate);
654 694
655 const char* decs[] = { 695 const char* decs[] = {
656 "var x = 1; x", "x", "this.x", 696 "var x = 1; x", "x", "this.x",
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 "function h(o) { with(o) { return typeof x; } }", 773 "function h(o) { with(o) { return typeof x; } }",
734 EXPECT_RESULT, Undefined(CcTest::isolate())); 774 EXPECT_RESULT, Undefined(CcTest::isolate()));
735 context.Check("h({})", EXPECT_RESULT, undefined_string); 775 context.Check("h({})", EXPECT_RESULT, undefined_string);
736 context.Check( 776 context.Check(
737 "'use strict';" 777 "'use strict';"
738 "let x = 1;" 778 "let x = 1;"
739 "f({})", 779 "f({})",
740 EXPECT_RESULT, Number::New(CcTest::isolate(), 1)); 780 EXPECT_RESULT, Number::New(CcTest::isolate(), 1));
741 context.Check( 781 context.Check(
742 "'use strict';" 782 "'use strict';"
743 "g({});" 783 "g({});0",
744 "x", 784 EXPECT_RESULT, Number::New(CcTest::isolate(), 0));
745 EXPECT_RESULT, Number::New(CcTest::isolate(), 15));
746 context.Check("f({})", EXPECT_RESULT, Number::New(CcTest::isolate(), 15)); 785 context.Check("f({})", EXPECT_RESULT, Number::New(CcTest::isolate(), 15));
747 context.Check("h({})", EXPECT_RESULT, number_string); 786 context.Check("h({})", EXPECT_RESULT, number_string);
748 } 787 }
749 } 788 }
OLDNEW
« src/runtime/runtime-scopes.cc ('K') | « src/runtime/runtime-scopes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698