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

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

Issue 1851673007: [modules] Treat top-level functions as lexical (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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
« src/parsing/parser.cc ('K') | « src/parsing/parser.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 e8c4a028656eecb5968aaeb2bf3d7672590a7cce..2805c686a6e7ef641d9b6ab8bb7c08d256951944 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -5750,6 +5750,43 @@ TEST(ImportExportParsingErrors) {
}
}
+TEST(ModuleTopLevelFunctionDecl) {
+ // clang-format off
+ const char* kErrorSources[] = {
+ "function f() {} function f() {}",
+ "var f; function f() {}",
+ "function f() {} var f;",
+ "function* f() {} function* f() {}",
+ "var f; function* f() {}",
+ "function* f() {} var f;",
+ "function f() {} function* f() {}",
+ "function* f() {} function f() {}",
+ };
+ // clang-format on
+
+ i::Isolate* isolate = CcTest::i_isolate();
+ i::Factory* factory = isolate->factory();
+
+ v8::HandleScope handles(CcTest::isolate());
+ v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
+ v8::Context::Scope context_scope(context);
+
+ isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
+ 128 * 1024);
+
+ for (unsigned i = 0; i < arraysize(kErrorSources); ++i) {
+ i::Handle<i::String> source =
+ factory->NewStringFromAsciiChecked(kErrorSources[i]);
+
+ i::Handle<i::Script> script = factory->NewScript(source);
+ i::Zone zone(CcTest::i_isolate()->allocator());
+ i::ParseInfo info(&zone, script);
+ i::Parser parser(&info);
+ info.set_module();
+ CHECK(!parser.Parse(&info));
+ }
+}
+
TEST(ModuleParsingInternals) {
i::Isolate* isolate = CcTest::i_isolate();
« src/parsing/parser.cc ('K') | « src/parsing/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698