Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Unified Diff: test/cctest/test-parsing.cc

Issue 2669163002: [parser] Skipping inner funcs: produce the same scopes / variables for (some) loops. (Closed)
Patch Set: code review (vogelheim@) Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parsing/preparser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index 4c324c56bea18ac7bd3b836054445a77b332d1a9..c13f22517ea82c2f17ece75d2c58265c63f55003 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -8835,6 +8835,20 @@ class ScopeTestHelper {
return var->scope()->MustAllocateInContext(var);
}
+ // True if the scope is and its entire subscope tree are hidden.
+ static bool ScopeTreeIsHidden(Scope* scope) {
+ if (!scope->is_hidden()) {
+ return false;
+ }
+ for (Scope* inner = scope->inner_scope(); inner != nullptr;
+ inner = inner->sibling()) {
+ if (!ScopeTreeIsHidden(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 +8858,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 (!ScopeTreeIsHidden(inner)) {
++inner_scope_count;
}
}
@@ -8878,7 +8894,7 @@ class ScopeTestHelper {
for (Scope* inner = scope->inner_scope(); inner != nullptr;
inner = inner->sibling()) {
- if (!inner->is_hidden()) {
+ if (!ScopeTreeIsHidden(inner)) {
CompareScopeToData(inner, data, index);
}
}
@@ -9311,6 +9327,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) {
« no previous file with comments | « src/parsing/preparser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698