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

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

Issue 745963002: harmony-scoping: Disallow cross-script assignment to const (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
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
« no previous file with comments | « src/hydrogen.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 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 Number::New(CcTest::isolate(), 13)); 1129 Number::New(CcTest::isolate(), 13));
1130 } 1130 }
1131 context.Check("global.x", EXPECT_RESULT, 1131 context.Check("global.x", EXPECT_RESULT,
1132 Number::New(CcTest::isolate(), 20)); 1132 Number::New(CcTest::isolate(), 20));
1133 context.Check("%OptimizeFunctionOnNextCall(f); f(41); x", EXPECT_RESULT, 1133 context.Check("%OptimizeFunctionOnNextCall(f); f(41); x", EXPECT_RESULT,
1134 Number::New(CcTest::isolate(), 41)); 1134 Number::New(CcTest::isolate(), 41));
1135 context.Check("global.x", EXPECT_RESULT, 1135 context.Check("global.x", EXPECT_RESULT,
1136 Number::New(CcTest::isolate(), 20)); 1136 Number::New(CcTest::isolate(), 20));
1137 } 1137 }
1138 } 1138 }
1139
1140
1141 TEST(CrossScriptAssignmentToConst) {
1142 i::FLAG_harmony_scoping = true;
1143 i::FLAG_allow_natives_syntax = true;
1144
1145 HandleScope handle_scope(CcTest::isolate());
1146
1147 {
1148 SimpleContext context;
1149
1150 context.Check("function f() { x = 27; }", EXPECT_RESULT,
1151 Undefined(CcTest::isolate()));
1152 context.Check("'use strict';const x = 1; x", EXPECT_RESULT,
1153 Number::New(CcTest::isolate(), 1));
1154 context.Check("f();", EXPECT_EXCEPTION);
1155 context.Check("x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1));
1156 context.Check("f();", EXPECT_EXCEPTION);
1157 context.Check("x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1));
1158 context.Check("%OptimizeFunctionOnNextCall(f);f();", EXPECT_EXCEPTION);
1159 context.Check("x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1));
1160 }
1161 }
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698