| 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);
|
| + }
|
| +}
|
|
|