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

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

Issue 881623002: Begin modernization of --harmony-modules (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
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 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 context.Check("let x = 4; x", EXPECT_RESULT, Number::New(isolate, 4)); 669 context.Check("let x = 4; x", EXPECT_RESULT, Number::New(isolate, 4));
670 } 670 }
671 context.Check("let y = 2; x", EXPECT_RESULT, 671 context.Check("let y = 2; x", EXPECT_RESULT,
672 Number::New(isolate, cond ? 1 : 4)); 672 Number::New(isolate, cond ? 1 : 4));
673 } 673 }
674 } 674 }
675 675
676 676
677 TEST(CrossScriptReferencesHarmony) { 677 TEST(CrossScriptReferencesHarmony) {
678 i::FLAG_harmony_scoping = true; 678 i::FLAG_harmony_scoping = true;
679 i::FLAG_harmony_modules = true;
680 679
681 v8::Isolate* isolate = CcTest::isolate(); 680 v8::Isolate* isolate = CcTest::isolate();
682 HandleScope scope(isolate); 681 HandleScope scope(isolate);
683 682
684 // Check that simple cross-script global scope access works. 683 // Check that simple cross-script global scope access works.
685 const char* decs[] = { 684 const char* decs[] = {
686 "'use strict'; var x = 1; x", "x", 685 "'use strict'; var x = 1; x", "x",
687 "'use strict'; function x() { return 1 }; x()", "x()", 686 "'use strict'; function x() { return 1 }; x()", "x()",
688 "'use strict'; let x = 1; x", "x", 687 "'use strict'; let x = 1; x", "x",
689 "'use strict'; const x = 1; x", "x", 688 "'use strict'; const x = 1; x", "x",
690 "'use strict'; module x { export let a = 1 }; x.a", "x.a",
691 NULL 689 NULL
692 }; 690 };
693 691
694 for (int i = 0; decs[i] != NULL; i += 2) { 692 for (int i = 0; decs[i] != NULL; i += 2) {
695 SimpleContext context; 693 SimpleContext context;
696 context.Check(decs[i], EXPECT_RESULT, Number::New(isolate, 1)); 694 context.Check(decs[i], EXPECT_RESULT, Number::New(isolate, 1));
697 context.Check(decs[i+1], EXPECT_RESULT, Number::New(isolate, 1)); 695 context.Check(decs[i+1], EXPECT_RESULT, Number::New(isolate, 1));
698 } 696 }
699 697
700 // Check that cross-script global scope access works with late declarations. 698 // Check that cross-script global scope access works with late declarations.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 EXPECT_RESULT, Number::New(isolate, 4)); 814 EXPECT_RESULT, Number::New(isolate, 4));
817 context.Check(script2, 815 context.Check(script2,
818 EXPECT_RESULT, Number::New(isolate, 5)); 816 EXPECT_RESULT, Number::New(isolate, 5));
819 } 817 }
820 } 818 }
821 819
822 820
823 TEST(GlobalLexicalOSR) { 821 TEST(GlobalLexicalOSR) {
824 i::FLAG_use_strict = true; 822 i::FLAG_use_strict = true;
825 i::FLAG_harmony_scoping = true; 823 i::FLAG_harmony_scoping = true;
826 i::FLAG_harmony_modules = true;
827 824
828 v8::Isolate* isolate = CcTest::isolate(); 825 v8::Isolate* isolate = CcTest::isolate();
829 HandleScope scope(isolate); 826 HandleScope scope(isolate);
830 SimpleContext context; 827 SimpleContext context;
831 828
832 context.Check("'use strict';" 829 context.Check("'use strict';"
833 "let x = 1; x;", 830 "let x = 1; x;",
834 EXPECT_RESULT, Number::New(isolate, 1)); 831 EXPECT_RESULT, Number::New(isolate, 1));
835 context.Check("'use strict';" 832 context.Check("'use strict';"
836 "let y = 2*x;" 833 "let y = 2*x;"
837 "++x;" 834 "++x;"
838 "let z = 0;" 835 "let z = 0;"
839 "const limit = 100000;" 836 "const limit = 100000;"
840 "for (var i = 0; i < limit; ++i) {" 837 "for (var i = 0; i < limit; ++i) {"
841 " z += x + y;" 838 " z += x + y;"
842 "}" 839 "}"
843 "z;", 840 "z;",
844 EXPECT_RESULT, Number::New(isolate, 400000)); 841 EXPECT_RESULT, Number::New(isolate, 400000));
845 } 842 }
846 843
847 844
848 TEST(CrossScriptConflicts) { 845 TEST(CrossScriptConflicts) {
849 i::FLAG_use_strict = true; 846 i::FLAG_use_strict = true;
850 i::FLAG_harmony_scoping = true; 847 i::FLAG_harmony_scoping = true;
851 i::FLAG_harmony_modules = true;
852 848
853 HandleScope scope(CcTest::isolate()); 849 HandleScope scope(CcTest::isolate());
854 850
855 const char* firsts[] = { 851 const char* firsts[] = {
856 "var x = 1; x", 852 "var x = 1; x",
857 "function x() { return 1 }; x()", 853 "function x() { return 1 }; x()",
858 "let x = 1; x", 854 "let x = 1; x",
859 "const x = 1; x", 855 "const x = 1; x",
860 "module x { export let a = 1 }; x.a",
861 NULL 856 NULL
862 }; 857 };
863 const char* seconds[] = { 858 const char* seconds[] = {
864 "var x = 2; x", 859 "var x = 2; x",
865 "function x() { return 2 }; x()", 860 "function x() { return 2 }; x()",
866 "let x = 2; x", 861 "let x = 2; x",
867 "const x = 2; x", 862 "const x = 2; x",
868 "module x { export let a = 2 }; x.a",
869 NULL 863 NULL
870 }; 864 };
871 865
872 for (int i = 0; firsts[i] != NULL; ++i) { 866 for (int i = 0; firsts[i] != NULL; ++i) {
873 for (int j = 0; seconds[j] != NULL; ++j) { 867 for (int j = 0; seconds[j] != NULL; ++j) {
874 SimpleContext context; 868 SimpleContext context;
875 context.Check(firsts[i], EXPECT_RESULT, 869 context.Check(firsts[i], EXPECT_RESULT,
876 Number::New(CcTest::isolate(), 1)); 870 Number::New(CcTest::isolate(), 1));
877 bool success_case = i < 2 && j < 2; 871 bool success_case = i < 2 && j < 2;
878 Local<Value> success_result; 872 Local<Value> success_result;
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 context.Check("'use strict';const x = 1; x", EXPECT_RESULT, 1138 context.Check("'use strict';const x = 1; x", EXPECT_RESULT,
1145 Number::New(CcTest::isolate(), 1)); 1139 Number::New(CcTest::isolate(), 1));
1146 context.Check("f();", EXPECT_EXCEPTION); 1140 context.Check("f();", EXPECT_EXCEPTION);
1147 context.Check("x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1)); 1141 context.Check("x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1));
1148 context.Check("f();", EXPECT_EXCEPTION); 1142 context.Check("f();", EXPECT_EXCEPTION);
1149 context.Check("x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1)); 1143 context.Check("x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1));
1150 context.Check("%OptimizeFunctionOnNextCall(f);f();", EXPECT_EXCEPTION); 1144 context.Check("%OptimizeFunctionOnNextCall(f);f();", EXPECT_EXCEPTION);
1151 context.Check("x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1)); 1145 context.Check("x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1));
1152 } 1146 }
1153 } 1147 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698