Commit d50b1962 authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[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/608972Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47325}
parent c527fc77
......@@ -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();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment