[parser] Skipping inner funcs: add more tests.
These now pass because of https://chromium-review.googlesource.com/603787. BUG=v8:5516 Change-Id: Ifcb576056c3cba523e56c5c9c563724efe096012 Reviewed-on: https://chromium-review.googlesource.com/608972 Reviewed-by: Adam Klein <adamk@chromium.org> Commit-Queue: Marja Hölttä <marja@chromium.org> Cr-Commit-Position: refs/heads/master@{#47325}
This commit is contained in:
parent
c527fc77e6
commit
d50b196246
@ -374,6 +374,41 @@ TEST(PreParserScopeAnalysis) {
|
||||
{"for (let [var1, var2] of [[1, 1], [2, 2]]) { () => { var2 = 3; } }"},
|
||||
{"for (const [var1, var2] of [[1, 1], [2, 2]]) { () => { var2 = 3; } }"},
|
||||
|
||||
// Skippable function in loop header
|
||||
{"for (let [var1, var2 = function() { }] of [[1]]) { }"},
|
||||
{"for (let [var1, var2 = function() { var1; }] of [[1]]) { }"},
|
||||
{"for (let [var1, var2 = function() { var2; }] of [[1]]) { }"},
|
||||
{"for (let [var1, var2 = function() { var1; var2; }] of [[1]]) { }"},
|
||||
{"for (let [var1, var2 = function() { var1 = 0; }] of [[1]]) { }"},
|
||||
{"for (let [var1, var2 = function() { var2 = 0; }] of [[1]]) { }"},
|
||||
{"for (let [var1, var2 = function() { var1 = 0; var2 = 0; }] of [[1]]) { "
|
||||
"}"},
|
||||
|
||||
{"for (let [var1, var2 = function() { }] of [[1]]) { function f() { "
|
||||
"var1; } }"},
|
||||
{"for (let [var1, var2 = function() { }] of [[1]]) { function f() { "
|
||||
"var2; } }"},
|
||||
{"for (let [var1, var2 = function() { }] of [[1]]) { function f() { "
|
||||
"var1; var2; } }"},
|
||||
{"for (let [var1, var2 = function() { }] of [[1]]) { function f() { "
|
||||
"var1 = 0; } }"},
|
||||
{"for (let [var1, var2 = function() { }] of [[1]]) { function f() { "
|
||||
"var2 = 0; } }"},
|
||||
{"for (let [var1, var2 = function() { }] of [[1]]) { function f() { "
|
||||
"var1 = 0; var2 = 0; } }"},
|
||||
{"for (let [var1, var2 = function() { var1; }] of [[1]]) { "
|
||||
"function f() { var1; } }"},
|
||||
{"for (let [var1, var2 = function() { var1; }] of [[1]]) { "
|
||||
"function f() { var2; } }"},
|
||||
{"for (let [var1, var2 = function() { var1; }] of [[1]]) { "
|
||||
"function f() { var1; var2; } }"},
|
||||
{"for (let [var1, var2 = function() { var2; }] of [[1]]) { "
|
||||
"function f() { var1; } }"},
|
||||
{"for (let [var1, var2 = function() { var2; }] of [[1]]) { "
|
||||
"function f() { var2; } }"},
|
||||
{"for (let [var1, var2 = function() { var2; }] of [[1]]) { "
|
||||
"function f() { var1; var2; } }"},
|
||||
|
||||
// Loops without declarations
|
||||
{"var var1 = 0; for ( ; var1 < 2; ++var1) { }"},
|
||||
{"var var1 = 0; for ( ; var1 < 2; ++var1) { function foo() { var1; } }"},
|
||||
|
@ -248,3 +248,50 @@ function TestSloppyEvalInFunctionWithComplexParams() {
|
||||
}
|
||||
|
||||
TestSloppyEvalInFunctionWithComplexParams();
|
||||
|
||||
function TestSkippableFunctionInForOfHeader() {
|
||||
var c;
|
||||
function inner() {
|
||||
for (let [a, b = c = function() { return a; }] of [[10]]) {
|
||||
}
|
||||
}
|
||||
inner();
|
||||
var result = c();
|
||||
assertEquals(10, result);
|
||||
}
|
||||
|
||||
TestSkippableFunctionInForOfHeader();
|
||||
|
||||
function TestSkippableFunctionInForOfBody() {
|
||||
var c;
|
||||
function inner() {
|
||||
for (let [a, b] of [[10, 11]]) {
|
||||
c = function f() {
|
||||
return a + b;
|
||||
}
|
||||
}
|
||||
}
|
||||
inner();
|
||||
var result = c();
|
||||
assertEquals(21, result);
|
||||
}
|
||||
|
||||
TestSkippableFunctionInForOfBody();
|
||||
|
||||
|
||||
function TestSkippableFunctionInForOfHeaderAndBody() {
|
||||
var c1;
|
||||
var c2;
|
||||
function inner() {
|
||||
for (let [a, b = c1 = function() { return a; }] of [[10]]) {
|
||||
c2 = function f() {
|
||||
return a + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
inner();
|
||||
var result = c1() + c2();
|
||||
assertEquals(21, result);
|
||||
}
|
||||
|
||||
TestSkippableFunctionInForOfHeaderAndBody();
|
||||
|
Loading…
Reference in New Issue
Block a user