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

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

Issue 1094963002: [modules] Parsing: add ModuleRequests where missing (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 5428 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 "export { a as b } from 'm.js';"
5450 "export * from 'p.js';"
5451 "import 'q.js'";
5450 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); 5452 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource);
5451 i::Handle<i::Script> script = factory->NewScript(source); 5453 i::Handle<i::Script> script = factory->NewScript(source);
5452 i::Zone zone; 5454 i::Zone zone;
5453 i::ParseInfo info(&zone, script); 5455 i::ParseInfo info(&zone, script);
5454 i::Parser parser(&info); 5456 i::Parser parser(&info);
5455 parser.set_allow_harmony_modules(true); 5457 parser.set_allow_harmony_modules(true);
5456 info.set_module(); 5458 info.set_module();
5457 CHECK(parser.Parse(&info)); 5459 CHECK(parser.Parse(&info));
5458 CHECK(i::Compiler::Analyze(&info)); 5460 CHECK(i::Compiler::Analyze(&info));
5459 i::FunctionLiteral* func = info.function(); 5461 i::FunctionLiteral* func = info.function();
(...skipping 20 matching lines...) Expand all
5480 i::ImportDeclaration* import_decl = 5482 i::ImportDeclaration* import_decl =
5481 declarations->at(1)->AsImportDeclaration(); 5483 declarations->at(1)->AsImportDeclaration();
5482 CHECK(import_decl->import_name()->IsOneByteEqualTo("q")); 5484 CHECK(import_decl->import_name()->IsOneByteEqualTo("q"));
5483 CHECK(import_decl->proxy()->raw_name()->IsOneByteEqualTo("z")); 5485 CHECK(import_decl->proxy()->raw_name()->IsOneByteEqualTo("z"));
5484 CHECK(import_decl->module_specifier()->IsOneByteEqualTo("m.js")); 5486 CHECK(import_decl->module_specifier()->IsOneByteEqualTo("m.js"));
5485 import_decl = declarations->at(2)->AsImportDeclaration(); 5487 import_decl = declarations->at(2)->AsImportDeclaration();
5486 CHECK(import_decl->import_name()->IsOneByteEqualTo("default")); 5488 CHECK(import_decl->import_name()->IsOneByteEqualTo("default"));
5487 CHECK(import_decl->proxy()->raw_name()->IsOneByteEqualTo("n")); 5489 CHECK(import_decl->proxy()->raw_name()->IsOneByteEqualTo("n"));
5488 CHECK(import_decl->module_specifier()->IsOneByteEqualTo("n.js")); 5490 CHECK(import_decl->module_specifier()->IsOneByteEqualTo("n.js"));
5489 // TODO(adamk): Add test for indirect exports once they're fully implemented. 5491 // TODO(adamk): Add test for indirect exports once they're fully implemented.
5492 // TODO(adamk): Add test for star exports once they're fully implemented.
5490 const i::ZoneList<const i::AstRawString*>& requested_modules = 5493 const i::ZoneList<const i::AstRawString*>& requested_modules =
5491 descriptor->requested_modules(); 5494 descriptor->requested_modules();
5492 CHECK_EQ(2, requested_modules.length()); 5495 CHECK_EQ(4, requested_modules.length());
5493 CHECK(requested_modules[0]->IsOneByteEqualTo("m.js")); 5496 CHECK(requested_modules[0]->IsOneByteEqualTo("m.js"));
5494 CHECK(requested_modules[1]->IsOneByteEqualTo("n.js")); 5497 CHECK(requested_modules[1]->IsOneByteEqualTo("n.js"));
5498 CHECK(requested_modules[2]->IsOneByteEqualTo("p.js"));
5499 CHECK(requested_modules[3]->IsOneByteEqualTo("q.js"));
5495 } 5500 }
5496 5501
5497 5502
5498 TEST(DuplicateProtoError) { 5503 TEST(DuplicateProtoError) {
5499 const char* context_data[][2] = { 5504 const char* context_data[][2] = {
5500 {"({", "});"}, 5505 {"({", "});"},
5501 {"'use strict'; ({", "});"}, 5506 {"'use strict'; ({", "});"},
5502 {NULL, NULL} 5507 {NULL, NULL}
5503 }; 5508 };
5504 const char* error_data[] = { 5509 const char* error_data[] = {
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
6171 v8::Script::Compile(v8_str(script3)); 6176 v8::Script::Compile(v8_str(script3));
6172 CHECK(try_catch2.HasCaught()); 6177 CHECK(try_catch2.HasCaught());
6173 v8::String::Utf8Value exception(try_catch2.Exception()); 6178 v8::String::Utf8Value exception(try_catch2.Exception());
6174 CHECK_EQ(0, 6179 CHECK_EQ(0,
6175 strcmp( 6180 strcmp(
6176 "ReferenceError: In strong mode, using an undeclared global " 6181 "ReferenceError: In strong mode, using an undeclared global "
6177 "variable 'not_there3' is not allowed", 6182 "variable 'not_there3' is not allowed",
6178 *exception)); 6183 *exception));
6179 } 6184 }
6180 } 6185 }
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