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

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

Issue 887843002: Implement new syntax for ImportDeclarations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add more negative tests Created 5 years, 11 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/parser.cc ('k') | no next file » | 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 594e3773f0bd4ab965411358dcc4cacafe5daf67..1022aae1ec5f42c89881f158055ab07f997a0364 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -4681,13 +4681,32 @@ TEST(BasicImportExportParsing) {
"function f() {}; f(); export { f };",
"var a, b, c; export { a, b as baz, c };",
"var d, e; export { d as dreary, e, };",
- "import y from 'http://module.com/foo.js';",
"export default function f() {}",
"export default class C {}",
"export default 42",
"var x; export default x = 7",
"export { Q } from 'somemodule.js';",
- "export * from 'somemodule.js';"
+ "export * from 'somemodule.js';",
+ "var foo; export { foo as for };",
+ "export { arguments } from 'm.js';",
+ "export { for } from 'm.js';",
+ "export { yield } from 'm.js'",
+ "export { static } from 'm.js'",
+ "export { let } from 'm.js'",
+
+ "import 'somemodule.js';",
+ "import { } from 'm.js';",
+ "import { a } from 'm.js';",
+ "import { a, b as d, c, } from 'm.js';",
+ "import * as thing from 'm.js';",
+ "import thing from 'm.js';",
+ "import thing, * as rest from 'm.js';",
+ "import thing, { a, b, c } from 'm.js';",
+ "import { arguments as a } from 'm.js';",
+ "import { for as f } from 'm.js';",
+ "import { yield as y } from 'm.js';",
+ "import { static as s } from 'm.js';",
+ "import { let as l } from 'm.js';",
};
i::Isolate* isolate = CcTest::i_isolate();
@@ -4720,7 +4739,22 @@ TEST(BasicImportExportParsing) {
parser.set_allow_harmony_modules(true);
parser.set_allow_harmony_scoping(true);
info.MarkAsModule();
- CHECK(parser.Parse());
+ if (!parser.Parse()) {
+ i::Handle<i::JSObject> exception_handle(
+ i::JSObject::cast(isolate->pending_exception()));
+ i::Handle<i::String> message_string =
+ i::Handle<i::String>::cast(i::Object::GetProperty(
+ isolate, exception_handle, "message").ToHandleChecked());
+
+ v8::base::OS::Print(
+ "Parser failed on:\n"
+ "\t%s\n"
+ "with error:\n"
+ "\t%s\n"
+ "However, we expected no error.",
+ source->ToCString().get(), message_string->ToCString().get());
+ CHECK(false);
+ }
}
// And that parsing a script does not.
@@ -4761,6 +4795,38 @@ TEST(ImportExportParsingErrors) {
"export * from;",
"export { Q } from;",
"export default from 'module.js';",
+ "export { for }",
+ "export { for as foo }",
+ "export { arguments }",
+ "export { arguments as foo }",
+
+ "import from;",
+ "import from 'm.js';",
+ "import { };",
+ "import {;",
+ "import };",
+ "import { , };",
+ "import { , } from 'm.js';",
+ "import { a } from;",
+ "import { a } 'm.js';",
+ "import , from 'm.js';",
+ "import a , from 'm.js';",
+ "import a { b, c } from 'm.js';",
+ "import arguments from 'm.js';",
+ "import eval from 'm.js';",
+ "import { arguments } from 'm.js';",
+ "import { eval } from 'm.js';",
+ "import { a as arguments } from 'm.js';",
+ "import { for } from 'm.js';",
+ "import { y as yield } from 'm.js'",
+ "import { s as static } from 'm.js'",
+ "import { l as let } from 'm.js'",
+ "import { x }, def from 'm.js';",
+ "import def, def2 from 'm.js';",
+ "import * as x, def from 'm.js';",
+ "import * as x, * as y from 'm.js';",
+ "import {x}, {y} from 'm.js';",
+ "import * as x, {y} from 'm.js';",
// TODO(ES6): These two forms should be supported
"export default function() {};",
« 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