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

Side by Side 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, 8 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 unified diff | Download patch
« src/parsing/parser.cc ('K') | « src/parsing/parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 5732 matching lines...) Expand 10 before | Expand all | Expand 10 after
5743 5743
5744 i::Handle<i::Script> script = factory->NewScript(source); 5744 i::Handle<i::Script> script = factory->NewScript(source);
5745 i::Zone zone(CcTest::i_isolate()->allocator()); 5745 i::Zone zone(CcTest::i_isolate()->allocator());
5746 i::ParseInfo info(&zone, script); 5746 i::ParseInfo info(&zone, script);
5747 i::Parser parser(&info); 5747 i::Parser parser(&info);
5748 info.set_module(); 5748 info.set_module();
5749 CHECK(!parser.Parse(&info)); 5749 CHECK(!parser.Parse(&info));
5750 } 5750 }
5751 } 5751 }
5752 5752
5753 TEST(ModuleTopLevelFunctionDecl) {
5754 // clang-format off
5755 const char* kErrorSources[] = {
5756 "function f() {} function f() {}",
5757 "var f; function f() {}",
5758 "function f() {} var f;",
5759 "function* f() {} function* f() {}",
5760 "var f; function* f() {}",
5761 "function* f() {} var f;",
5762 "function f() {} function* f() {}",
5763 "function* f() {} function f() {}",
5764 };
5765 // clang-format on
5766
5767 i::Isolate* isolate = CcTest::i_isolate();
5768 i::Factory* factory = isolate->factory();
5769
5770 v8::HandleScope handles(CcTest::isolate());
5771 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
5772 v8::Context::Scope context_scope(context);
5773
5774 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
5775 128 * 1024);
5776
5777 for (unsigned i = 0; i < arraysize(kErrorSources); ++i) {
5778 i::Handle<i::String> source =
5779 factory->NewStringFromAsciiChecked(kErrorSources[i]);
5780
5781 i::Handle<i::Script> script = factory->NewScript(source);
5782 i::Zone zone(CcTest::i_isolate()->allocator());
5783 i::ParseInfo info(&zone, script);
5784 i::Parser parser(&info);
5785 info.set_module();
5786 CHECK(!parser.Parse(&info));
5787 }
5788 }
5789
5753 5790
5754 TEST(ModuleParsingInternals) { 5791 TEST(ModuleParsingInternals) {
5755 i::Isolate* isolate = CcTest::i_isolate(); 5792 i::Isolate* isolate = CcTest::i_isolate();
5756 i::Factory* factory = isolate->factory(); 5793 i::Factory* factory = isolate->factory();
5757 v8::HandleScope handles(CcTest::isolate()); 5794 v8::HandleScope handles(CcTest::isolate());
5758 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); 5795 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
5759 v8::Context::Scope context_scope(context); 5796 v8::Context::Scope context_scope(context);
5760 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - 5797 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
5761 128 * 1024); 5798 128 * 1024);
5762 5799
(...skipping 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after
7380 // "Array() **= 10", 7417 // "Array() **= 10",
7381 NULL 7418 NULL
7382 }; 7419 };
7383 // clang-format on 7420 // clang-format on
7384 7421
7385 static const ParserFlag always_flags[] = { 7422 static const ParserFlag always_flags[] = {
7386 kAllowHarmonyExponentiationOperator}; 7423 kAllowHarmonyExponentiationOperator};
7387 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, 7424 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags,
7388 arraysize(always_flags)); 7425 arraysize(always_flags));
7389 } 7426 }
OLDNEW
« 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