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

Side by Side Diff: test/cctest/test-parsing.cc

Issue 2252223002: Introduce ModuleScope subclass of DeclarationScope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « src/parsing/preparser.h ('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 5964 matching lines...) Expand 10 before | Expand all | Expand 10 after
5975 "export {foob};"; 5975 "export {foob};";
5976 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); 5976 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource);
5977 i::Handle<i::Script> script = factory->NewScript(source); 5977 i::Handle<i::Script> script = factory->NewScript(source);
5978 i::Zone zone(CcTest::i_isolate()->allocator()); 5978 i::Zone zone(CcTest::i_isolate()->allocator());
5979 i::ParseInfo info(&zone, script); 5979 i::ParseInfo info(&zone, script);
5980 i::Parser parser(&info); 5980 i::Parser parser(&info);
5981 info.set_module(); 5981 info.set_module();
5982 CHECK(parser.Parse(&info)); 5982 CHECK(parser.Parse(&info));
5983 CHECK(i::Compiler::Analyze(&info)); 5983 CHECK(i::Compiler::Analyze(&info));
5984 i::FunctionLiteral* func = info.literal(); 5984 i::FunctionLiteral* func = info.literal();
5985 i::DeclarationScope* module_scope = func->scope(); 5985 i::ModuleScope* module_scope = func->scope()->AsModuleScope();
5986 i::Scope* outer_scope = module_scope->outer_scope(); 5986 i::Scope* outer_scope = module_scope->outer_scope();
5987 CHECK(outer_scope->is_script_scope()); 5987 CHECK(outer_scope->is_script_scope());
5988 CHECK_NULL(outer_scope->outer_scope()); 5988 CHECK_NULL(outer_scope->outer_scope());
5989 CHECK(module_scope->is_module_scope()); 5989 CHECK(module_scope->is_module_scope());
5990 i::ZoneList<i::Declaration*>* declarations = module_scope->declarations(); 5990 i::ZoneList<i::Declaration*>* declarations = module_scope->declarations();
5991 CHECK_EQ(13, declarations->length()); 5991 CHECK_EQ(13, declarations->length());
5992 5992
5993 CHECK(declarations->at(0)->proxy()->raw_name()->IsOneByteEqualTo("x")); 5993 CHECK(declarations->at(0)->proxy()->raw_name()->IsOneByteEqualTo("x"));
5994 CHECK(declarations->at(0)->proxy()->var()->mode() == i::LET); 5994 CHECK(declarations->at(0)->proxy()->var()->mode() == i::LET);
5995 CHECK(declarations->at(0)->proxy()->var()->binding_needs_init()); 5995 CHECK(declarations->at(0)->proxy()->var()->binding_needs_init());
(...skipping 2145 matching lines...) Expand 10 before | Expand all | Expand 10 after
8141 "(a,);", 8141 "(a,);",
8142 "(a,b,c,);", 8142 "(a,b,c,);",
8143 NULL 8143 NULL
8144 }; 8144 };
8145 // clang-format on 8145 // clang-format on
8146 8146
8147 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; 8147 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas};
8148 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 8148 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
8149 arraysize(always_flags)); 8149 arraysize(always_flags));
8150 } 8150 }
OLDNEW
« no previous file with comments | « src/parsing/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698