| 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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 EXPECT_RESULT, Number::New(isolate, 1)); | 630 EXPECT_RESULT, Number::New(isolate, 1)); |
| 631 context.Check("this.x", | 631 context.Check("this.x", |
| 632 EXPECT_RESULT, Number::New(isolate, 1)); | 632 EXPECT_RESULT, Number::New(isolate, 1)); |
| 633 context.Check("function x() { return 7 }; x", | 633 context.Check("function x() { return 7 }; x", |
| 634 EXPECT_EXCEPTION); | 634 EXPECT_EXCEPTION); |
| 635 } | 635 } |
| 636 } | 636 } |
| 637 | 637 |
| 638 | 638 |
| 639 TEST(CrossScriptReferences_Simple) { | 639 TEST(CrossScriptReferences_Simple) { |
| 640 i::FLAG_harmony_scoping = true; | |
| 641 i::FLAG_use_strict = true; | 640 i::FLAG_use_strict = true; |
| 642 | 641 |
| 643 v8::Isolate* isolate = CcTest::isolate(); | 642 v8::Isolate* isolate = CcTest::isolate(); |
| 644 HandleScope scope(isolate); | 643 HandleScope scope(isolate); |
| 645 | 644 |
| 646 { | 645 { |
| 647 SimpleContext context; | 646 SimpleContext context; |
| 648 context.Check("let x = 1; x", EXPECT_RESULT, Number::New(isolate, 1)); | 647 context.Check("let x = 1; x", EXPECT_RESULT, Number::New(isolate, 1)); |
| 649 context.Check("let x = 5; x", EXPECT_EXCEPTION); | 648 context.Check("let x = 5; x", EXPECT_EXCEPTION); |
| 650 } | 649 } |
| 651 } | 650 } |
| 652 | 651 |
| 653 | 652 |
| 654 TEST(CrossScriptReferences_Simple2) { | 653 TEST(CrossScriptReferences_Simple2) { |
| 655 i::FLAG_harmony_scoping = true; | |
| 656 i::FLAG_use_strict = true; | 654 i::FLAG_use_strict = true; |
| 657 | 655 |
| 658 v8::Isolate* isolate = CcTest::isolate(); | 656 v8::Isolate* isolate = CcTest::isolate(); |
| 659 HandleScope scope(isolate); | 657 HandleScope scope(isolate); |
| 660 | 658 |
| 661 for (int k = 0; k < 100; k++) { | 659 for (int k = 0; k < 100; k++) { |
| 662 SimpleContext context; | 660 SimpleContext context; |
| 663 bool cond = (k % 2) == 0; | 661 bool cond = (k % 2) == 0; |
| 664 if (cond) { | 662 if (cond) { |
| 665 context.Check("let x = 1; x", EXPECT_RESULT, Number::New(isolate, 1)); | 663 context.Check("let x = 1; x", EXPECT_RESULT, Number::New(isolate, 1)); |
| 666 context.Check("let z = 4; z", EXPECT_RESULT, Number::New(isolate, 4)); | 664 context.Check("let z = 4; z", EXPECT_RESULT, Number::New(isolate, 4)); |
| 667 } else { | 665 } else { |
| 668 context.Check("let z = 1; z", EXPECT_RESULT, Number::New(isolate, 1)); | 666 context.Check("let z = 1; z", EXPECT_RESULT, Number::New(isolate, 1)); |
| 669 context.Check("let x = 4; x", EXPECT_RESULT, Number::New(isolate, 4)); | 667 context.Check("let x = 4; x", EXPECT_RESULT, Number::New(isolate, 4)); |
| 670 } | 668 } |
| 671 context.Check("let y = 2; x", EXPECT_RESULT, | 669 context.Check("let y = 2; x", EXPECT_RESULT, |
| 672 Number::New(isolate, cond ? 1 : 4)); | 670 Number::New(isolate, cond ? 1 : 4)); |
| 673 } | 671 } |
| 674 } | 672 } |
| 675 | 673 |
| 676 | 674 |
| 677 TEST(CrossScriptReferencesHarmony) { | 675 TEST(CrossScriptReferencesHarmony) { |
| 678 i::FLAG_harmony_scoping = true; | |
| 679 | |
| 680 v8::Isolate* isolate = CcTest::isolate(); | 676 v8::Isolate* isolate = CcTest::isolate(); |
| 681 HandleScope scope(isolate); | 677 HandleScope scope(isolate); |
| 682 | 678 |
| 683 // Check that simple cross-script global scope access works. | 679 // Check that simple cross-script global scope access works. |
| 684 const char* decs[] = { | 680 const char* decs[] = { |
| 685 "'use strict'; var x = 1; x", "x", | 681 "'use strict'; var x = 1; x", "x", |
| 686 "'use strict'; function x() { return 1 }; x()", "x()", | 682 "'use strict'; function x() { return 1 }; x()", "x()", |
| 687 "'use strict'; let x = 1; x", "x", | 683 "'use strict'; let x = 1; x", "x", |
| 688 "'use strict'; const x = 1; x", "x", | 684 "'use strict'; const x = 1; x", "x", |
| 689 NULL | 685 NULL |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 EXPECT_RESULT, Number::New(isolate, 0)); | 808 EXPECT_RESULT, Number::New(isolate, 0)); |
| 813 context.Check(script1, | 809 context.Check(script1, |
| 814 EXPECT_RESULT, Number::New(isolate, 4)); | 810 EXPECT_RESULT, Number::New(isolate, 4)); |
| 815 context.Check(script2, | 811 context.Check(script2, |
| 816 EXPECT_RESULT, Number::New(isolate, 5)); | 812 EXPECT_RESULT, Number::New(isolate, 5)); |
| 817 } | 813 } |
| 818 } | 814 } |
| 819 | 815 |
| 820 | 816 |
| 821 TEST(CrossScriptReferencesHarmonyRegress) { | 817 TEST(CrossScriptReferencesHarmonyRegress) { |
| 822 i::FLAG_harmony_scoping = true; | |
| 823 v8::Isolate* isolate = CcTest::isolate(); | 818 v8::Isolate* isolate = CcTest::isolate(); |
| 824 HandleScope scope(isolate); | 819 HandleScope scope(isolate); |
| 825 SimpleContext context; | 820 SimpleContext context; |
| 826 context.Check( | 821 context.Check( |
| 827 "'use strict';" | 822 "'use strict';" |
| 828 "function i1() { " | 823 "function i1() { " |
| 829 " let y = 10; return (typeof x2 === 'undefined' ? 0 : 2) + y" | 824 " let y = 10; return (typeof x2 === 'undefined' ? 0 : 2) + y" |
| 830 "}" | 825 "}" |
| 831 "i1();" | 826 "i1();" |
| 832 "i1();", | 827 "i1();", |
| 833 EXPECT_RESULT, Number::New(isolate, 10)); | 828 EXPECT_RESULT, Number::New(isolate, 10)); |
| 834 context.Check( | 829 context.Check( |
| 835 "'use strict';" | 830 "'use strict';" |
| 836 "let x2 = 2; i1();", | 831 "let x2 = 2; i1();", |
| 837 EXPECT_RESULT, Number::New(isolate, 12)); | 832 EXPECT_RESULT, Number::New(isolate, 12)); |
| 838 } | 833 } |
| 839 | 834 |
| 840 | 835 |
| 841 TEST(GlobalLexicalOSR) { | 836 TEST(GlobalLexicalOSR) { |
| 842 i::FLAG_use_strict = true; | 837 i::FLAG_use_strict = true; |
| 843 i::FLAG_harmony_scoping = true; | |
| 844 | 838 |
| 845 v8::Isolate* isolate = CcTest::isolate(); | 839 v8::Isolate* isolate = CcTest::isolate(); |
| 846 HandleScope scope(isolate); | 840 HandleScope scope(isolate); |
| 847 SimpleContext context; | 841 SimpleContext context; |
| 848 | 842 |
| 849 context.Check("'use strict';" | 843 context.Check("'use strict';" |
| 850 "let x = 1; x;", | 844 "let x = 1; x;", |
| 851 EXPECT_RESULT, Number::New(isolate, 1)); | 845 EXPECT_RESULT, Number::New(isolate, 1)); |
| 852 context.Check("'use strict';" | 846 context.Check("'use strict';" |
| 853 "let y = 2*x;" | 847 "let y = 2*x;" |
| 854 "++x;" | 848 "++x;" |
| 855 "let z = 0;" | 849 "let z = 0;" |
| 856 "const limit = 100000;" | 850 "const limit = 100000;" |
| 857 "for (var i = 0; i < limit; ++i) {" | 851 "for (var i = 0; i < limit; ++i) {" |
| 858 " z += x + y;" | 852 " z += x + y;" |
| 859 "}" | 853 "}" |
| 860 "z;", | 854 "z;", |
| 861 EXPECT_RESULT, Number::New(isolate, 400000)); | 855 EXPECT_RESULT, Number::New(isolate, 400000)); |
| 862 } | 856 } |
| 863 | 857 |
| 864 | 858 |
| 865 TEST(CrossScriptConflicts) { | 859 TEST(CrossScriptConflicts) { |
| 866 i::FLAG_use_strict = true; | 860 i::FLAG_use_strict = true; |
| 867 i::FLAG_harmony_scoping = true; | |
| 868 | 861 |
| 869 HandleScope scope(CcTest::isolate()); | 862 HandleScope scope(CcTest::isolate()); |
| 870 | 863 |
| 871 const char* firsts[] = { | 864 const char* firsts[] = { |
| 872 "var x = 1; x", | 865 "var x = 1; x", |
| 873 "function x() { return 1 }; x()", | 866 "function x() { return 1 }; x()", |
| 874 "let x = 1; x", | 867 "let x = 1; x", |
| 875 "const x = 1; x", | 868 "const x = 1; x", |
| 876 NULL | 869 NULL |
| 877 }; | 870 }; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 893 if (success_case) success_result = Number::New(CcTest::isolate(), 2); | 886 if (success_case) success_result = Number::New(CcTest::isolate(), 2); |
| 894 | 887 |
| 895 context.Check(seconds[j], success_case ? EXPECT_RESULT : EXPECT_EXCEPTION, | 888 context.Check(seconds[j], success_case ? EXPECT_RESULT : EXPECT_EXCEPTION, |
| 896 success_result); | 889 success_result); |
| 897 } | 890 } |
| 898 } | 891 } |
| 899 } | 892 } |
| 900 | 893 |
| 901 | 894 |
| 902 TEST(CrossScriptDynamicLookup) { | 895 TEST(CrossScriptDynamicLookup) { |
| 903 i::FLAG_harmony_scoping = true; | |
| 904 | |
| 905 HandleScope handle_scope(CcTest::isolate()); | 896 HandleScope handle_scope(CcTest::isolate()); |
| 906 | 897 |
| 907 { | 898 { |
| 908 SimpleContext context; | 899 SimpleContext context; |
| 909 Local<String> undefined_string = String::NewFromUtf8( | 900 Local<String> undefined_string = String::NewFromUtf8( |
| 910 CcTest::isolate(), "undefined", String::kInternalizedString); | 901 CcTest::isolate(), "undefined", String::kInternalizedString); |
| 911 Local<String> number_string = String::NewFromUtf8( | 902 Local<String> number_string = String::NewFromUtf8( |
| 912 CcTest::isolate(), "number", String::kInternalizedString); | 903 CcTest::isolate(), "number", String::kInternalizedString); |
| 913 | 904 |
| 914 context.Check( | 905 context.Check( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 926 "'use strict';" | 917 "'use strict';" |
| 927 "g({});0", | 918 "g({});0", |
| 928 EXPECT_RESULT, Number::New(CcTest::isolate(), 0)); | 919 EXPECT_RESULT, Number::New(CcTest::isolate(), 0)); |
| 929 context.Check("f({})", EXPECT_RESULT, Number::New(CcTest::isolate(), 15)); | 920 context.Check("f({})", EXPECT_RESULT, Number::New(CcTest::isolate(), 15)); |
| 930 context.Check("h({})", EXPECT_RESULT, number_string); | 921 context.Check("h({})", EXPECT_RESULT, number_string); |
| 931 } | 922 } |
| 932 } | 923 } |
| 933 | 924 |
| 934 | 925 |
| 935 TEST(CrossScriptGlobal) { | 926 TEST(CrossScriptGlobal) { |
| 936 i::FLAG_harmony_scoping = true; | |
| 937 | |
| 938 HandleScope handle_scope(CcTest::isolate()); | 927 HandleScope handle_scope(CcTest::isolate()); |
| 939 { | 928 { |
| 940 SimpleContext context; | 929 SimpleContext context; |
| 941 | 930 |
| 942 context.Check( | 931 context.Check( |
| 943 "var global = this;" | 932 "var global = this;" |
| 944 "global.x = 255;" | 933 "global.x = 255;" |
| 945 "x", | 934 "x", |
| 946 EXPECT_RESULT, Number::New(CcTest::isolate(), 255)); | 935 EXPECT_RESULT, Number::New(CcTest::isolate(), 255)); |
| 947 context.Check( | 936 context.Check( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 970 context.Check( | 959 context.Check( |
| 971 "'use strict';" | 960 "'use strict';" |
| 972 "const konst = 255;" | 961 "const konst = 255;" |
| 973 "f()", | 962 "f()", |
| 974 EXPECT_EXCEPTION); | 963 EXPECT_EXCEPTION); |
| 975 } | 964 } |
| 976 } | 965 } |
| 977 | 966 |
| 978 | 967 |
| 979 TEST(CrossScriptStaticLookupUndeclared) { | 968 TEST(CrossScriptStaticLookupUndeclared) { |
| 980 i::FLAG_harmony_scoping = true; | |
| 981 | |
| 982 HandleScope handle_scope(CcTest::isolate()); | 969 HandleScope handle_scope(CcTest::isolate()); |
| 983 | 970 |
| 984 { | 971 { |
| 985 SimpleContext context; | 972 SimpleContext context; |
| 986 Local<String> undefined_string = String::NewFromUtf8( | 973 Local<String> undefined_string = String::NewFromUtf8( |
| 987 CcTest::isolate(), "undefined", String::kInternalizedString); | 974 CcTest::isolate(), "undefined", String::kInternalizedString); |
| 988 Local<String> number_string = String::NewFromUtf8( | 975 Local<String> number_string = String::NewFromUtf8( |
| 989 CcTest::isolate(), "number", String::kInternalizedString); | 976 CcTest::isolate(), "number", String::kInternalizedString); |
| 990 | 977 |
| 991 context.Check( | 978 context.Check( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1004 "g(15);x", | 991 "g(15);x", |
| 1005 EXPECT_RESULT, Number::New(CcTest::isolate(), 15)); | 992 EXPECT_RESULT, Number::New(CcTest::isolate(), 15)); |
| 1006 context.Check("h({})", EXPECT_RESULT, number_string); | 993 context.Check("h({})", EXPECT_RESULT, number_string); |
| 1007 context.Check("f({})", EXPECT_RESULT, Number::New(CcTest::isolate(), 15)); | 994 context.Check("f({})", EXPECT_RESULT, Number::New(CcTest::isolate(), 15)); |
| 1008 context.Check("h({})", EXPECT_RESULT, number_string); | 995 context.Check("h({})", EXPECT_RESULT, number_string); |
| 1009 } | 996 } |
| 1010 } | 997 } |
| 1011 | 998 |
| 1012 | 999 |
| 1013 TEST(CrossScriptLoadICs) { | 1000 TEST(CrossScriptLoadICs) { |
| 1014 i::FLAG_harmony_scoping = true; | |
| 1015 i::FLAG_allow_natives_syntax = true; | 1001 i::FLAG_allow_natives_syntax = true; |
| 1016 | 1002 |
| 1017 HandleScope handle_scope(CcTest::isolate()); | 1003 HandleScope handle_scope(CcTest::isolate()); |
| 1018 | 1004 |
| 1019 { | 1005 { |
| 1020 SimpleContext context; | 1006 SimpleContext context; |
| 1021 context.Check( | 1007 context.Check( |
| 1022 "x = 15;" | 1008 "x = 15;" |
| 1023 "function f() { return x; }" | 1009 "function f() { return x; }" |
| 1024 "function g() { return x; }" | 1010 "function g() { return x; }" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 for (int k = 0; k < 3; k++) { | 1046 for (int k = 0; k < 3; k++) { |
| 1061 context.Check("f()", EXPECT_RESULT, Number::New(CcTest::isolate(), 5)); | 1047 context.Check("f()", EXPECT_RESULT, Number::New(CcTest::isolate(), 5)); |
| 1062 } | 1048 } |
| 1063 context.Check("%OptimizeFunctionOnNextCall(f); f()", EXPECT_RESULT, | 1049 context.Check("%OptimizeFunctionOnNextCall(f); f()", EXPECT_RESULT, |
| 1064 Number::New(CcTest::isolate(), 5)); | 1050 Number::New(CcTest::isolate(), 5)); |
| 1065 } | 1051 } |
| 1066 } | 1052 } |
| 1067 | 1053 |
| 1068 | 1054 |
| 1069 TEST(CrossScriptStoreICs) { | 1055 TEST(CrossScriptStoreICs) { |
| 1070 i::FLAG_harmony_scoping = true; | |
| 1071 i::FLAG_allow_natives_syntax = true; | 1056 i::FLAG_allow_natives_syntax = true; |
| 1072 | 1057 |
| 1073 HandleScope handle_scope(CcTest::isolate()); | 1058 HandleScope handle_scope(CcTest::isolate()); |
| 1074 | 1059 |
| 1075 { | 1060 { |
| 1076 SimpleContext context; | 1061 SimpleContext context; |
| 1077 context.Check( | 1062 context.Check( |
| 1078 "var global = this;" | 1063 "var global = this;" |
| 1079 "x = 15;" | 1064 "x = 15;" |
| 1080 "function f(v) { x = v; }" | 1065 "function f(v) { x = v; }" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 Number::New(CcTest::isolate(), 20)); | 1123 Number::New(CcTest::isolate(), 20)); |
| 1139 context.Check("%OptimizeFunctionOnNextCall(f); f(41); x", EXPECT_RESULT, | 1124 context.Check("%OptimizeFunctionOnNextCall(f); f(41); x", EXPECT_RESULT, |
| 1140 Number::New(CcTest::isolate(), 41)); | 1125 Number::New(CcTest::isolate(), 41)); |
| 1141 context.Check("global.x", EXPECT_RESULT, | 1126 context.Check("global.x", EXPECT_RESULT, |
| 1142 Number::New(CcTest::isolate(), 20)); | 1127 Number::New(CcTest::isolate(), 20)); |
| 1143 } | 1128 } |
| 1144 } | 1129 } |
| 1145 | 1130 |
| 1146 | 1131 |
| 1147 TEST(CrossScriptAssignmentToConst) { | 1132 TEST(CrossScriptAssignmentToConst) { |
| 1148 i::FLAG_harmony_scoping = true; | |
| 1149 i::FLAG_allow_natives_syntax = true; | 1133 i::FLAG_allow_natives_syntax = true; |
| 1150 | 1134 |
| 1151 HandleScope handle_scope(CcTest::isolate()); | 1135 HandleScope handle_scope(CcTest::isolate()); |
| 1152 | 1136 |
| 1153 { | 1137 { |
| 1154 SimpleContext context; | 1138 SimpleContext context; |
| 1155 | 1139 |
| 1156 context.Check("function f() { x = 27; }", EXPECT_RESULT, | 1140 context.Check("function f() { x = 27; }", EXPECT_RESULT, |
| 1157 Undefined(CcTest::isolate())); | 1141 Undefined(CcTest::isolate())); |
| 1158 context.Check("'use strict';const x = 1; x", EXPECT_RESULT, | 1142 context.Check("'use strict';const x = 1; x", EXPECT_RESULT, |
| 1159 Number::New(CcTest::isolate(), 1)); | 1143 Number::New(CcTest::isolate(), 1)); |
| 1160 context.Check("f();", EXPECT_EXCEPTION); | 1144 context.Check("f();", EXPECT_EXCEPTION); |
| 1161 context.Check("x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1)); | 1145 context.Check("x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1)); |
| 1162 context.Check("f();", EXPECT_EXCEPTION); | 1146 context.Check("f();", EXPECT_EXCEPTION); |
| 1163 context.Check("x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1)); | 1147 context.Check("x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1)); |
| 1164 context.Check("%OptimizeFunctionOnNextCall(f);f();", EXPECT_EXCEPTION); | 1148 context.Check("%OptimizeFunctionOnNextCall(f);f();", EXPECT_EXCEPTION); |
| 1165 context.Check("x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1)); | 1149 context.Check("x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1)); |
| 1166 } | 1150 } |
| 1167 } | 1151 } |
| 1168 | 1152 |
| 1169 | 1153 |
| 1170 TEST(Regress425510) { | 1154 TEST(Regress425510) { |
| 1171 i::FLAG_harmony_scoping = true; | |
| 1172 i::FLAG_allow_natives_syntax = true; | 1155 i::FLAG_allow_natives_syntax = true; |
| 1173 | 1156 |
| 1174 HandleScope handle_scope(CcTest::isolate()); | 1157 HandleScope handle_scope(CcTest::isolate()); |
| 1175 | 1158 |
| 1176 { | 1159 { |
| 1177 SimpleContext context; | 1160 SimpleContext context; |
| 1178 | 1161 |
| 1179 context.Check("'use strict'; o; const o = 10", EXPECT_EXCEPTION); | 1162 context.Check("'use strict'; o; const o = 10", EXPECT_EXCEPTION); |
| 1180 | 1163 |
| 1181 for (int i = 0; i < 100; i++) { | 1164 for (int i = 0; i < 100; i++) { |
| 1182 context.Check("o.prototype", EXPECT_EXCEPTION); | 1165 context.Check("o.prototype", EXPECT_EXCEPTION); |
| 1183 } | 1166 } |
| 1184 } | 1167 } |
| 1185 } | 1168 } |
| 1186 | 1169 |
| 1187 | 1170 |
| 1188 TEST(Regress3941) { | 1171 TEST(Regress3941) { |
| 1189 i::FLAG_harmony_scoping = true; | |
| 1190 i::FLAG_allow_natives_syntax = true; | 1172 i::FLAG_allow_natives_syntax = true; |
| 1191 | 1173 |
| 1192 HandleScope handle_scope(CcTest::isolate()); | 1174 HandleScope handle_scope(CcTest::isolate()); |
| 1193 | 1175 |
| 1194 { | 1176 { |
| 1195 SimpleContext context; | 1177 SimpleContext context; |
| 1196 context.Check("function f() { x = 1; }", EXPECT_RESULT, | 1178 context.Check("function f() { x = 1; }", EXPECT_RESULT, |
| 1197 Undefined(CcTest::isolate())); | 1179 Undefined(CcTest::isolate())); |
| 1198 context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION); | 1180 context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION); |
| 1199 } | 1181 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1221 } | 1203 } |
| 1222 context.Check("%OptimizeFunctionOnNextCall(f); f(); x", EXPECT_RESULT, | 1204 context.Check("%OptimizeFunctionOnNextCall(f); f(); x", EXPECT_RESULT, |
| 1223 Number::New(CcTest::isolate(), 1)); | 1205 Number::New(CcTest::isolate(), 1)); |
| 1224 | 1206 |
| 1225 context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION); | 1207 context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION); |
| 1226 } | 1208 } |
| 1227 } | 1209 } |
| 1228 | 1210 |
| 1229 | 1211 |
| 1230 TEST(Regress3941_Reads) { | 1212 TEST(Regress3941_Reads) { |
| 1231 i::FLAG_harmony_scoping = true; | |
| 1232 i::FLAG_allow_natives_syntax = true; | 1213 i::FLAG_allow_natives_syntax = true; |
| 1233 | 1214 |
| 1234 HandleScope handle_scope(CcTest::isolate()); | 1215 HandleScope handle_scope(CcTest::isolate()); |
| 1235 | 1216 |
| 1236 { | 1217 { |
| 1237 SimpleContext context; | 1218 SimpleContext context; |
| 1238 context.Check("function f() { return x; }", EXPECT_RESULT, | 1219 context.Check("function f() { return x; }", EXPECT_RESULT, |
| 1239 Undefined(CcTest::isolate())); | 1220 Undefined(CcTest::isolate())); |
| 1240 context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION); | 1221 context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION); |
| 1241 } | 1222 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1260 Undefined(CcTest::isolate())); | 1241 Undefined(CcTest::isolate())); |
| 1261 for (int i = 0; i < 4; i++) { | 1242 for (int i = 0; i < 4; i++) { |
| 1262 context.Check("f()", EXPECT_EXCEPTION); | 1243 context.Check("f()", EXPECT_EXCEPTION); |
| 1263 } | 1244 } |
| 1264 context.Check("%OptimizeFunctionOnNextCall(f);", EXPECT_RESULT, | 1245 context.Check("%OptimizeFunctionOnNextCall(f);", EXPECT_RESULT, |
| 1265 Undefined(CcTest::isolate())); | 1246 Undefined(CcTest::isolate())); |
| 1266 | 1247 |
| 1267 context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION); | 1248 context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION); |
| 1268 } | 1249 } |
| 1269 } | 1250 } |
| OLD | NEW |