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

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

Issue 1078903002: Collect list of requested modules in ModuleDescriptor while parsing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/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 5427 matching lines...) Expand 10 before | Expand all | Expand 10 after
5438 v8::HandleScope handles(CcTest::isolate()); 5438 v8::HandleScope handles(CcTest::isolate());
5439 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); 5439 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate());
5440 v8::Context::Scope context_scope(context); 5440 v8::Context::Scope context_scope(context);
5441 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - 5441 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
5442 128 * 1024); 5442 128 * 1024);
5443 5443
5444 static const char kSource[] = 5444 static const char kSource[] =
5445 "let x = 5;" 5445 "let x = 5;"
5446 "export { x as y };" 5446 "export { x as y };"
5447 "import { q as z } from 'm.js';" 5447 "import { q as z } from 'm.js';"
5448 "import n from 'n.js'"; 5448 "import n from 'n.js';"
5449 "export { a as b } from 'm.js';";
5449 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); 5450 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource);
5450 i::Handle<i::Script> script = factory->NewScript(source); 5451 i::Handle<i::Script> script = factory->NewScript(source);
5451 i::Zone zone; 5452 i::Zone zone;
5452 i::ParseInfo info(&zone, script); 5453 i::ParseInfo info(&zone, script);
5453 i::Parser parser(&info); 5454 i::Parser parser(&info);
5454 parser.set_allow_harmony_modules(true); 5455 parser.set_allow_harmony_modules(true);
5455 info.set_module(); 5456 info.set_module();
5456 CHECK(parser.Parse(&info)); 5457 CHECK(parser.Parse(&info));
5457 CHECK(i::Compiler::Analyze(&info)); 5458 CHECK(i::Compiler::Analyze(&info));
5458 i::FunctionLiteral* func = info.function(); 5459 i::FunctionLiteral* func = info.function();
(...skipping 19 matching lines...) Expand all
5478 CHECK(declarations->at(0)->proxy()->raw_name()->IsOneByteEqualTo("x")); 5479 CHECK(declarations->at(0)->proxy()->raw_name()->IsOneByteEqualTo("x"));
5479 i::ImportDeclaration* import_decl = 5480 i::ImportDeclaration* import_decl =
5480 declarations->at(1)->AsImportDeclaration(); 5481 declarations->at(1)->AsImportDeclaration();
5481 CHECK(import_decl->import_name()->IsOneByteEqualTo("q")); 5482 CHECK(import_decl->import_name()->IsOneByteEqualTo("q"));
5482 CHECK(import_decl->proxy()->raw_name()->IsOneByteEqualTo("z")); 5483 CHECK(import_decl->proxy()->raw_name()->IsOneByteEqualTo("z"));
5483 CHECK(import_decl->module_specifier()->IsOneByteEqualTo("m.js")); 5484 CHECK(import_decl->module_specifier()->IsOneByteEqualTo("m.js"));
5484 import_decl = declarations->at(2)->AsImportDeclaration(); 5485 import_decl = declarations->at(2)->AsImportDeclaration();
5485 CHECK(import_decl->import_name()->IsOneByteEqualTo("default")); 5486 CHECK(import_decl->import_name()->IsOneByteEqualTo("default"));
5486 CHECK(import_decl->proxy()->raw_name()->IsOneByteEqualTo("n")); 5487 CHECK(import_decl->proxy()->raw_name()->IsOneByteEqualTo("n"));
5487 CHECK(import_decl->module_specifier()->IsOneByteEqualTo("n.js")); 5488 CHECK(import_decl->module_specifier()->IsOneByteEqualTo("n.js"));
5489 // TODO(adamk): Add test for indirect exports once they're fully implemented.
5490 const i::ZoneList<const i::AstRawString*>& requested_modules =
5491 descriptor->requested_modules();
5492 CHECK_EQ(2, requested_modules.length());
5493 CHECK(requested_modules[0]->IsOneByteEqualTo("m.js"));
5494 CHECK(requested_modules[1]->IsOneByteEqualTo("n.js"));
5488 } 5495 }
5489 5496
5490 5497
5491 TEST(DuplicateProtoError) { 5498 TEST(DuplicateProtoError) {
5492 const char* context_data[][2] = { 5499 const char* context_data[][2] = {
5493 {"({", "});"}, 5500 {"({", "});"},
5494 {"'use strict'; ({", "});"}, 5501 {"'use strict'; ({", "});"},
5495 {NULL, NULL} 5502 {NULL, NULL}
5496 }; 5503 };
5497 const char* error_data[] = { 5504 const char* error_data[] = {
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
5997 v8::Script::Compile(v8_str(script3)); 6004 v8::Script::Compile(v8_str(script3));
5998 CHECK(try_catch2.HasCaught()); 6005 CHECK(try_catch2.HasCaught());
5999 v8::String::Utf8Value exception(try_catch2.Exception()); 6006 v8::String::Utf8Value exception(try_catch2.Exception());
6000 CHECK_EQ(0, 6007 CHECK_EQ(0,
6001 strcmp( 6008 strcmp(
6002 "ReferenceError: In strong mode, using an undeclared global " 6009 "ReferenceError: In strong mode, using an undeclared global "
6003 "variable 'not_there3' is not allowed", 6010 "variable 'not_there3' is not allowed",
6004 *exception)); 6011 *exception));
6005 } 6012 }
6006 } 6013 }
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698