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

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

Issue 1995863002: Improve strictness of Annex B 3.3 for generators and async functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix mixed duplicates Created 4 years, 7 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/parser-base.h ('k') | test/mjsunit/harmony/sloppy-legacy-duplicate-generators.js » ('j') | 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 36f729344f94e2fc931bfe43fa42f2d46cfcbb12..5479fce8b79e6876e144a3de21f699d036a81c4f 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -1509,7 +1509,8 @@ enum ParserFlag {
kAllowHarmonyRestrictiveDeclarations,
kAllowHarmonyExponentiationOperator,
kAllowHarmonyForIn,
- kAllowHarmonyAsyncAwait
+ kAllowHarmonyAsyncAwait,
+ kAllowHarmonyRestrictiveGenerators,
};
enum ParserSyncTestResult {
@@ -1532,6 +1533,8 @@ void SetParserFlags(i::ParserBase<Traits>* parser,
parser->set_allow_harmony_for_in(flags.Contains(kAllowHarmonyForIn));
parser->set_allow_harmony_async_await(
flags.Contains(kAllowHarmonyAsyncAwait));
+ parser->set_allow_harmony_restrictive_generators(
+ flags.Contains(kAllowHarmonyRestrictiveGenerators));
}
@@ -7731,3 +7734,60 @@ TEST(RestrictiveForInErrors) {
RunParserSyncTest(context_data, error_data, kError, nullptr, 0, always_flags,
arraysize(always_flags));
}
+
+TEST(NoDuplicateGeneratorsInBlock) {
+ const char* block_context_data[][2] = {
+ {"'use strict'; {", "}"},
+ {"{", "}"},
+ {"(function() { {", "} })()"},
+ {"(function() {'use strict'; {", "} })()"},
+ {NULL, NULL}};
+ const char* top_level_context_data[][2] = {
+ {"'use strict';", ""},
+ {"", ""},
+ {"(function() {", "})()"},
+ {"(function() {'use strict';", "})()"},
+ {NULL, NULL}};
+ const char* error_data[] = {"function* x() {} function* x() {}",
+ "function x() {} function* x() {}",
+ "function* x() {} function x() {}", NULL};
+ static const ParserFlag always_flags[] = {kAllowHarmonyRestrictiveGenerators};
+ // The preparser doesn't enforce the restriction, so turn it off.
+ bool test_preparser = false;
+ RunParserSyncTest(block_context_data, error_data, kError, NULL, 0,
+ always_flags, arraysize(always_flags), NULL, 0, false,
+ test_preparser);
+ RunParserSyncTest(top_level_context_data, error_data, kSuccess, NULL, 0,
+ always_flags, arraysize(always_flags));
+}
+
+TEST(NoDuplicateAsyncFunctionInBlock) {
+ const char* block_context_data[][2] = {
+ {"'use strict'; {", "}"},
+ {"{", "}"},
+ {"(function() { {", "} })()"},
+ {"(function() {'use strict'; {", "} })()"},
+ {NULL, NULL}};
+ const char* top_level_context_data[][2] = {
+ {"'use strict';", ""},
+ {"", ""},
+ {"(function() {", "})()"},
+ {"(function() {'use strict';", "})()"},
+ {NULL, NULL}};
+ const char* error_data[] = {"async function x() {} async function x() {}",
+ "function x() {} async function x() {}",
+ "async function x() {} function x() {}",
+ "function* x() {} async function x() {}",
+ "function* x() {} async function x() {}",
+ "async function x() {} function* x() {}",
+ "function* x() {} async function x() {}",
+ NULL};
+ static const ParserFlag always_flags[] = {kAllowHarmonyAsyncAwait};
+ // The preparser doesn't enforce the restriction, so turn it off.
+ bool test_preparser = false;
+ RunParserSyncTest(block_context_data, error_data, kError, NULL, 0,
+ always_flags, arraysize(always_flags), NULL, 0, false,
+ test_preparser);
+ RunParserSyncTest(top_level_context_data, error_data, kSuccess, NULL, 0,
+ always_flags, arraysize(always_flags));
+}
« no previous file with comments | « src/parsing/parser-base.h ('k') | test/mjsunit/harmony/sloppy-legacy-duplicate-generators.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698