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

Unified Diff: test/cctest/test-decls.cc

Issue 1001323002: Implement TDZ in StoreIC for top-level lexicals. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Hydrogen fixes Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ic/ic.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-decls.cc
diff --git a/test/cctest/test-decls.cc b/test/cctest/test-decls.cc
index f4fa8289e45d0f7aa4d7960ae663c503b2bb24d1..861b3a225e07f0180a4f341d132ab6def9ab9299 100644
--- a/test/cctest/test-decls.cc
+++ b/test/cctest/test-decls.cc
@@ -1183,3 +1183,87 @@ TEST(Regress425510) {
}
}
}
+
+
+TEST(Regress3941) {
+ i::FLAG_harmony_scoping = true;
+ i::FLAG_allow_natives_syntax = true;
+
+ HandleScope handle_scope(CcTest::isolate());
+
+ {
+ SimpleContext context;
+ context.Check("function f() { x = 1; }", EXPECT_RESULT,
+ Undefined(CcTest::isolate()));
+ context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION);
+ }
+
+
+ {
+ // Train ICs.
+ SimpleContext context;
+ context.Check("function f() { x = 1; }", EXPECT_RESULT,
+ Undefined(CcTest::isolate()));
+ for (int i = 0; i < 4; i++) {
+ context.Check("f(); x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1));
+ }
+ context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION);
+ }
+
+
+ {
+ // Optimize.
+ SimpleContext context;
+ context.Check("function f() { x = 1; }", EXPECT_RESULT,
+ Undefined(CcTest::isolate()));
+ for (int i = 0; i < 4; i++) {
+ context.Check("f(); x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1));
+ }
+ context.Check("%OptimizeFunctionOnNextCall(f); f(); x", EXPECT_RESULT,
+ Number::New(CcTest::isolate(), 1));
+
+ context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION);
+ }
+}
+
+
+TEST(Regress3941_Reads) {
+ i::FLAG_harmony_scoping = true;
+ i::FLAG_allow_natives_syntax = true;
+
+ HandleScope handle_scope(CcTest::isolate());
+
+ {
+ SimpleContext context;
+ context.Check("function f() { return x; }", EXPECT_RESULT,
+ Undefined(CcTest::isolate()));
+ context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION);
+ }
+
+
+ {
+ // Train ICs.
+ SimpleContext context;
+ context.Check("function f() { return x; }", EXPECT_RESULT,
+ Undefined(CcTest::isolate()));
+ for (int i = 0; i < 4; i++) {
+ context.Check("f()", EXPECT_EXCEPTION);
+ }
+ context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION);
+ }
+
+
+ {
+ // Optimize.
+ SimpleContext context;
+ context.Check("function f() { return x; }", EXPECT_RESULT,
+ Undefined(CcTest::isolate()));
+ for (int i = 0; i < 4; i++) {
+ context.Check("f()", EXPECT_EXCEPTION);
+ }
+ context.Check("%OptimizeFunctionOnNextCall(f);", EXPECT_RESULT,
+ Undefined(CcTest::isolate()));
+
+ context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION);
+ }
+}
« no previous file with comments | « src/ic/ic.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698