Chromium Code Reviews| Index: test/cctest/test-parsing.cc |
| diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
| index 4c324c56bea18ac7bd3b836054445a77b332d1a9..5ccfe012f1b35ee8a2962ecdcb1bd7955082123b 100644 |
| --- a/test/cctest/test-parsing.cc |
| +++ b/test/cctest/test-parsing.cc |
| @@ -8835,6 +8835,21 @@ class ScopeTestHelper { |
| return var->scope()->MustAllocateInContext(var); |
| } |
| + // True if the scope is hidden and all scopes in its subscope tree are hidden |
|
vogelheim
2017/02/02 18:28:56
super nitpick:
// True if this scope and its enti
marja
2017/02/03 06:48:58
Done.
|
| + // too. |
| + static bool IsHiddenLeafScope(Scope* scope) { |
|
vogelheim
2017/02/02 18:28:56
naming nitpick: I'm not super happy with the name,
marja
2017/02/03 06:48:58
Done.
|
| + if (!scope->is_hidden()) { |
| + return false; |
| + } |
| + for (Scope* inner = scope->inner_scope(); inner != nullptr; |
| + inner = inner->sibling()) { |
| + if (!IsHiddenLeafScope(inner)) { |
| + return false; |
| + } |
| + } |
| + return true; |
| + } |
| + |
| static void CompareScopeToData(Scope* scope, const PreParsedScopeData* data, |
| size_t& index) { |
| CHECK_EQ(data->backing_store_[index++], scope->scope_type()); |
| @@ -8844,7 +8859,9 @@ class ScopeTestHelper { |
| int inner_scope_count = 0; |
| for (Scope* inner = scope->inner_scope(); inner != nullptr; |
| inner = inner->sibling()) { |
| - if (!inner->is_hidden()) { |
| + // FIXME(marja): This is probably not the right condition for knowing what |
| + // scopes are present in the preparse data. |
| + if (!IsHiddenLeafScope(inner)) { |
| ++inner_scope_count; |
| } |
| } |
| @@ -8878,7 +8895,7 @@ class ScopeTestHelper { |
| for (Scope* inner = scope->inner_scope(); inner != nullptr; |
| inner = inner->sibling()) { |
| - if (!inner->is_hidden()) { |
| + if (!IsHiddenLeafScope(inner)) { |
| CompareScopeToData(inner, data, index); |
| } |
| } |
| @@ -9311,6 +9328,22 @@ TEST(PreParserScopeAnalysis) { |
| {"", "let var1; function f1() { eval(''); }"}, |
| {"", "const var1 = 10; eval('');"}, |
| {"", "const var1 = 10; function f1() { eval(''); }"}, |
| + |
| + {"", "for (var var1 = 0; var1 < 10; ++var1) { }"}, |
| + {"", "for (let var1 = 0; var1 < 10; ++var1) { }"}, |
| + {"", "for (const var1 = 0; var1 < 10; ++var1) { }"}, |
| + |
| + // FIXME(marja): make the corresponding cases work when foo is a sloppy |
| + // block function. |
| + {"", |
| + "'use strict'; for (var var1 = 0; var1 < 10; ++var1) { function foo() { " |
| + "var1; } }"}, |
| + {"", |
| + "'use strict'; for (let var1 = 0; var1 < 10; ++var1) { function foo() { " |
| + "var1; } }"}, |
| + {"", |
| + "'use strict'; for (const var1 = 0; var1 < 10; ++var1) { function foo() " |
| + "{ var1; } }"}, |
| }; |
| for (unsigned i = 0; i < arraysize(inners); ++i) { |