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

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

Issue 2199283002: [modules] Introduce new VariableLocation for module imports/exports. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parsing/parser.cc ('k') | test/mjsunit/harmony/modules.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 090a9d00e7318f05e80393dc37a72c046089a8aa..c489c69c969978d9f168982e0871d0dc931f3ef8 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -5932,7 +5932,14 @@ TEST(ModuleParsingInternals) {
"export let hoo;"
"export const joo = 42;"
"export default (function koo() {});"
- "import 'q.js'";
+ "import 'q.js';"
+ "let nonexport = 42;"
+ "import {m as mm} from 'm.js';"
+ "import {aa} from 'm.js';"
+ "export {aa as bb, x};"
+ "import * as loo from 'bar.js';"
+ "import * as foob from 'bar.js';"
+ "export {foob};";
i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource);
i::Handle<i::Script> script = factory->NewScript(source);
i::Zone zone(CcTest::i_isolate()->allocator());
@@ -5947,19 +5954,78 @@ TEST(ModuleParsingInternals) {
CHECK(outer_scope->is_script_scope());
CHECK_NULL(outer_scope->outer_scope());
CHECK(module_scope->is_module_scope());
- i::ModuleDescriptor* descriptor = module_scope->module();
- CHECK_NOT_NULL(descriptor);
i::ZoneList<i::Declaration*>* declarations = module_scope->declarations();
- CHECK_EQ(8, declarations->length());
+
CHECK(declarations->at(0)->proxy()->raw_name()->IsOneByteEqualTo("x"));
+ CHECK(declarations->at(0)->proxy()->var()->mode() == i::LET);
+ CHECK(declarations->at(0)->proxy()->var()->location() ==
+ i::VariableLocation::MODULE);
+
CHECK(declarations->at(1)->proxy()->raw_name()->IsOneByteEqualTo("z"));
+ CHECK(declarations->at(1)->proxy()->var()->mode() == i::CONST);
+ CHECK(declarations->at(1)->proxy()->var()->location() ==
+ i::VariableLocation::MODULE);
+
CHECK(declarations->at(2)->proxy()->raw_name()->IsOneByteEqualTo("n"));
+ CHECK(declarations->at(2)->proxy()->var()->mode() == i::CONST);
+ CHECK(declarations->at(2)->proxy()->var()->location() ==
+ i::VariableLocation::MODULE);
+
CHECK(declarations->at(3)->proxy()->raw_name()->IsOneByteEqualTo("foo"));
+ CHECK(declarations->at(3)->proxy()->var()->mode() == i::VAR);
+ CHECK(declarations->at(3)->proxy()->var()->location() ==
+ i::VariableLocation::MODULE);
+
CHECK(declarations->at(4)->proxy()->raw_name()->IsOneByteEqualTo("goo"));
+ CHECK(declarations->at(4)->proxy()->var()->mode() == i::LET);
+ CHECK(declarations->at(4)->proxy()->var()->location() ==
+ i::VariableLocation::MODULE);
+
CHECK(declarations->at(5)->proxy()->raw_name()->IsOneByteEqualTo("hoo"));
+ CHECK(declarations->at(5)->proxy()->var()->mode() == i::LET);
+ CHECK(declarations->at(5)->proxy()->var()->location() ==
+ i::VariableLocation::MODULE);
+
CHECK(declarations->at(6)->proxy()->raw_name()->IsOneByteEqualTo("joo"));
+ CHECK(declarations->at(6)->proxy()->var()->mode() == i::CONST);
+ CHECK(declarations->at(6)->proxy()->var()->location() ==
+ i::VariableLocation::MODULE);
+
CHECK(
declarations->at(7)->proxy()->raw_name()->IsOneByteEqualTo("*default*"));
+ CHECK(declarations->at(7)->proxy()->var()->mode() == i::CONST);
+ CHECK(declarations->at(7)->proxy()->var()->location() ==
+ i::VariableLocation::MODULE);
+
+ CHECK(
+ declarations->at(8)->proxy()->raw_name()->IsOneByteEqualTo("nonexport"));
+ CHECK(declarations->at(8)->proxy()->var()->location() !=
+ i::VariableLocation::MODULE);
+
+ CHECK(declarations->at(9)->proxy()->raw_name()->IsOneByteEqualTo("mm"));
+ CHECK(declarations->at(9)->proxy()->var()->mode() == i::CONST);
+ CHECK(declarations->at(9)->proxy()->var()->location() ==
+ i::VariableLocation::MODULE);
+
+ CHECK(declarations->at(10)->proxy()->raw_name()->IsOneByteEqualTo("aa"));
+ CHECK(declarations->at(10)->proxy()->var()->mode() == i::CONST);
+ CHECK(declarations->at(10)->proxy()->var()->location() ==
+ i::VariableLocation::MODULE);
+
+ CHECK(declarations->at(11)->proxy()->raw_name()->IsOneByteEqualTo("loo"));
+ CHECK(declarations->at(11)->proxy()->var()->mode() == i::CONST);
+ CHECK(declarations->at(11)->proxy()->var()->location() !=
+ i::VariableLocation::MODULE);
+
+ CHECK(declarations->at(12)->proxy()->raw_name()->IsOneByteEqualTo("foob"));
+ CHECK(declarations->at(12)->proxy()->var()->mode() == i::CONST);
+ CHECK(declarations->at(12)->proxy()->var()->location() ==
+ i::VariableLocation::MODULE);
+
+ CHECK_EQ(13, declarations->length());
+
+ i::ModuleDescriptor* descriptor = module_scope->module();
+ CHECK_NOT_NULL(descriptor);
// TODO(neis): Test more once we can inspect the imports/exports.
}
« no previous file with comments | « src/parsing/parser.cc ('k') | test/mjsunit/harmony/modules.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698