diff options
Diffstat (limited to 'deps/v8/test/mjsunit/es6/block-let-semantics.js')
-rw-r--r-- | deps/v8/test/mjsunit/es6/block-let-semantics.js | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/deps/v8/test/mjsunit/es6/block-let-semantics.js b/deps/v8/test/mjsunit/es6/block-let-semantics.js index b0a826a007..59eec1ceea 100644 --- a/deps/v8/test/mjsunit/es6/block-let-semantics.js +++ b/deps/v8/test/mjsunit/es6/block-let-semantics.js @@ -70,6 +70,7 @@ TestAll('x += 1; let x;'); TestAll('++x; let x;'); TestAll('x++; let x;'); TestAll('let y = x; const x = 1;'); +TestAll('let y = x; class x {}'); TestAll('f(); let x; function f() { return x + 1; }'); TestAll('f(); let x; function f() { x = 1; }'); @@ -77,6 +78,7 @@ TestAll('f(); let x; function f() { x += 1; }'); TestAll('f(); let x; function f() { ++x; }'); TestAll('f(); let x; function f() { x++; }'); TestAll('f(); const x = 1; function f() { return x; }'); +TestAll('f(); class x { }; function f() { return x; }'); TestAll('f()(); let x; function f() { return function() { return x + 1; } }'); TestAll('f()(); let x; function f() { return function() { x = 1; } }'); @@ -84,21 +86,24 @@ TestAll('f()(); let x; function f() { return function() { x += 1; } }'); TestAll('f()(); let x; function f() { return function() { ++x; } }'); TestAll('f()(); let x; function f() { return function() { x++; } }'); TestAll('f()(); const x = 1; function f() { return function() { return x; } }'); - -// Use before initialization with a dynamic lookup. -TestAll('eval("x + 1;"); let x;'); -TestAll('eval("x = 1;"); let x;'); -TestAll('eval("x += 1;"); let x;'); -TestAll('eval("++x;"); let x;'); -TestAll('eval("x++;"); let x;'); -TestAll('eval("x"); const x = 1;'); - -// Use before initialization with check for eval-shadowed bindings. -TestAll('function f() { eval("var y = 2;"); x + 1; }; f(); let x;'); -TestAll('function f() { eval("var y = 2;"); x = 1; }; f(); let x;'); -TestAll('function f() { eval("var y = 2;"); x += 1; }; f(); let x;'); -TestAll('function f() { eval("var y = 2;"); ++x; }; f(); let x;'); -TestAll('function f() { eval("var y = 2;"); x++; }; f(); let x;'); +TestAll('f()(); class x { }; function f() { return function() { return x; } }'); + +for (var kw of ['let x = 2', 'const x = 2', 'class x { }']) { + // Use before initialization with a dynamic lookup. + TestAll(`eval("x"); ${kw};`); + TestAll(`eval("x + 1;"); ${kw};`); + TestAll(`eval("x = 1;"); ${kw};`); + TestAll(`eval("x += 1;"); ${kw};`); + TestAll(`eval("++x;"); ${kw};`); + TestAll(`eval("x++;"); ${kw};`); + + // Use before initialization with check for eval-shadowed bindings. + TestAll(`function f() { eval("var y = 2;"); x + 1; }; f(); ${kw};`); + TestAll(`function f() { eval("var y = 2;"); x = 1; }; f(); ${kw};`); + TestAll(`function f() { eval("var y = 2;"); x += 1; }; f(); ${kw};`); + TestAll(`function f() { eval("var y = 2;"); ++x; }; f(); ${kw};`); + TestAll(`function f() { eval("var y = 2;"); x++; }; f(); ${kw};`); +} // Test that variables introduced by function declarations are created and // initialized upon entering a function / block scope. |