@@ -106,40 +106,40 @@ private void testModules(String input, DiagnosticType error) {
106106
107107 public void testImport () {
108108 testModules (
109- "import name from 'other'; use(name);" ,
109+ "import name from './ other'; use(name);" ,
110110 "goog.require('module$other'); use(module$other.default);" );
111111
112- testModules ("import {n as name} from 'other';" , "goog.require('module$other');" );
112+ testModules ("import {n as name} from './ other';" , "goog.require('module$other');" );
113113
114114 testModules (
115- "import x, {f as foo, b as bar} from 'other'; use(x);" ,
115+ "import x, {f as foo, b as bar} from './ other'; use(x);" ,
116116 "goog.require('module$other'); use(module$other.default);" );
117117
118118 testModules (
119- "import {default as name} from 'other'; use(name);" ,
119+ "import {default as name} from './ other'; use(name);" ,
120120 "goog.require('module$other'); use(module$other.default);" );
121121
122122 testModules (
123- "import {class as name} from 'other'; use(name);" ,
123+ "import {class as name} from './ other'; use(name);" ,
124124 "goog.require('module$other'); use(module$other.class);" );
125125 }
126126
127127 public void testImport_missing () {
128128 setExpectParseWarningsThisTest (); // JSC_ES6_MODULE_LOAD_WARNING
129129 testModules (
130- "import name from 'does_not_exist'; use(name);" ,
130+ "import name from './ does_not_exist'; use(name);" ,
131131 "goog.require('module$does_not_exist'); use(module$does_not_exist.default);" );
132132 }
133133
134134 public void testImportStar () {
135135 testModules (
136- "import * as name from 'other'; use(name.foo);" ,
136+ "import * as name from './ other'; use(name.foo);" ,
137137 "goog.require('module$other'); use(module$other.foo)" );
138138 }
139139
140140 public void testTypeNodeRewriting () {
141141 testModules (
142- "import * as name from 'other'; /** @type {name.foo} */ var x;" ,
142+ "import * as name from './ other'; /** @type {name.foo} */ var x;" ,
143143 "goog.require('module$other');"
144144 + "/** @type {module$other.foo} */ var x$$module$testcode;" );
145145 }
@@ -244,7 +244,7 @@ public void testExportWithJsDoc() {
244244
245245 public void testImportAndExport () {
246246 testModules (
247- LINE_JOINER .join ("import {name as n} from 'other';" , "use(n);" , "export {n as name};" ),
247+ LINE_JOINER .join ("import {name as n} from './ other';" , "use(n);" , "export {n as name};" ),
248248 LINE_JOINER .join (
249249 "goog.provide('module$testcode');" ,
250250 "goog.require('module$other');" ,
@@ -255,9 +255,9 @@ public void testImportAndExport() {
255255 public void testExportFrom () {
256256 testModules (
257257 LINE_JOINER .join (
258- "export {name} from 'other';" ,
259- "export {default} from 'other';" ,
260- "export {class} from 'other';" ),
258+ "export {name} from './ other';" ,
259+ "export {default} from './ other';" ,
260+ "export {class} from './ other';" ),
261261 LINE_JOINER .join (
262262 "goog.provide('module$testcode');" ,
263263 "goog.require('module$other');" ,
@@ -266,7 +266,7 @@ public void testExportFrom() {
266266 "module$testcode.class = module$other.class;" ));
267267
268268 testModules (
269- "export {a, b as c, d} from 'other';" ,
269+ "export {a, b as c, d} from './ other';" ,
270270 LINE_JOINER .join (
271271 "goog.provide('module$testcode');" ,
272272 "goog.require('module$other');" ,
@@ -275,7 +275,7 @@ public void testExportFrom() {
275275 "module$testcode.d = module$other.d;" ));
276276
277277 testModules (
278- "export {a as b, b as a} from 'other';" ,
278+ "export {a as b, b as a} from './ other';" ,
279279 LINE_JOINER .join (
280280 "goog.provide('module$testcode');" ,
281281 "goog.require('module$other');" ,
@@ -284,9 +284,9 @@ public void testExportFrom() {
284284
285285 testModules (
286286 LINE_JOINER .join (
287- "export {default as a} from 'other';" ,
288- "export {a as a2, default as b} from 'other';" ,
289- "export {class as switch} from 'other';" ),
287+ "export {default as a} from './ other';" ,
288+ "export {a as a2, default as b} from './ other';" ,
289+ "export {class as switch} from './ other';" ),
290290 LINE_JOINER .join (
291291 "goog.provide('module$testcode');" ,
292292 "goog.require('module$other');" ,
@@ -348,7 +348,7 @@ public void testExportDefault_anonymous() {
348348 public void testExtendImportedClass () {
349349 testModules (
350350 LINE_JOINER .join (
351- "import {Parent} from 'other';" ,
351+ "import {Parent} from './ other';" ,
352352 "class Child extends Parent {" ,
353353 " /** @param {Parent} parent */" ,
354354 " useParent(parent) {}" ,
@@ -362,7 +362,7 @@ public void testExtendImportedClass() {
362362
363363 testModules (
364364 LINE_JOINER .join (
365- "import {Parent} from 'other';" ,
365+ "import {Parent} from './ other';" ,
366366 "class Child extends Parent {" ,
367367 " /** @param {./other.Parent} parent */" ,
368368 " useParent(parent) {}" ,
@@ -376,7 +376,7 @@ public void testExtendImportedClass() {
376376
377377 testModules (
378378 LINE_JOINER .join (
379- "import {Parent} from 'other';" ,
379+ "import {Parent} from './ other';" ,
380380 "export class Child extends Parent {" ,
381381 " /** @param {Parent} parent */" ,
382382 " useParent(parent) {}" ,
@@ -448,7 +448,7 @@ public void testReferenceToTypeFromOtherModule() {
448448 public void testRenameTypedef () {
449449 testModules (
450450 LINE_JOINER .join (
451- "import 'other';" , "/** @typedef {string|!Object} */" , "export var UnionType;" ),
451+ "import './ other';" , "/** @typedef {string|!Object} */" , "export var UnionType;" ),
452452 LINE_JOINER .join (
453453 "goog.provide('module$testcode');" ,
454454 "goog.require('module$other');" ,
@@ -461,8 +461,8 @@ public void testRenameTypedef() {
461461 public void testRenameImportedReference () {
462462 testModules (
463463 LINE_JOINER .join (
464- "import {f} from 'other';" ,
465- "import {b as bar} from 'other';" ,
464+ "import {f} from './ other';" ,
465+ "import {b as bar} from './ other';" ,
466466 "f();" ,
467467 "function g() {" ,
468468 " f();" ,
@@ -506,11 +506,11 @@ public void testGoogRequires_noChange() {
506506 "module$testcode.x = x$$module$testcode" ));
507507
508508 testModules (
509- "import * as s from 'other'; goog.require('foo.bar');" ,
509+ "import * as s from './ other'; goog.require('foo.bar');" ,
510510 "goog.require('module$other'); goog.require('foo.bar');" );
511511
512512 testModules (
513- "goog.require('foo.bar'); import * as s from 'other';" ,
513+ "goog.require('foo.bar'); import * as s from './ other';" ,
514514 "goog.require('module$other'); goog.require('foo.bar'); " );
515515 }
516516
@@ -534,14 +534,14 @@ public void testGoogRequires_rewrite() {
534534 "module$testcode.x = x$$module$testcode" ));
535535
536536 testModules (
537- "import * as s from 'other'; const bar = goog.require('foo.bar');" ,
537+ "import * as s from './ other'; const bar = goog.require('foo.bar');" ,
538538 LINE_JOINER .join (
539539 "goog.require('module$other');" ,
540540 "goog.require('foo.bar');" ,
541541 "const bar$$module$testcode = foo.bar;" ));
542542
543543 testModules (
544- "const bar = goog.require('foo.bar'); import * as s from 'other';" ,
544+ "const bar = goog.require('foo.bar'); import * as s from './ other';" ,
545545 LINE_JOINER .join (
546546 "goog.require('module$other');" ,
547547 "goog.require('foo.bar');" ,
@@ -558,18 +558,18 @@ public void testGoogRequires_nonConst() {
558558 LHS_OF_GOOG_REQUIRE_MUST_BE_CONST );
559559
560560 testModules (
561- "import * as s from 'other'; var bar = goog.require('foo.bar');" ,
561+ "import * as s from './ other'; var bar = goog.require('foo.bar');" ,
562562 LHS_OF_GOOG_REQUIRE_MUST_BE_CONST );
563563
564564 testModules (
565- "var bar = goog.require('foo.bar'); import * as s from 'other';" ,
565+ "var bar = goog.require('foo.bar'); import * as s from './ other';" ,
566566 LHS_OF_GOOG_REQUIRE_MUST_BE_CONST );
567567 }
568568
569569 public void testGoogRequiresDestructuring_rewrite () {
570570 testModules (
571571 LINE_JOINER .join (
572- "import * as s from 'other';" ,
572+ "import * as s from './ other';" ,
573573 "const {foo, bar} = goog.require('some.name.space');" ,
574574 "use(foo, bar);" ),
575575 LINE_JOINER .join (
@@ -583,14 +583,14 @@ public void testGoogRequiresDestructuring_rewrite() {
583583
584584 testModules (
585585 LINE_JOINER .join (
586- "import * as s from 'other';" ,
586+ "import * as s from './ other';" ,
587587 "var {foo, bar} = goog.require('some.name.space');" ,
588588 "use(foo, bar);" ),
589589 LHS_OF_GOOG_REQUIRE_MUST_BE_CONST );
590590
591591 testModules (
592592 LINE_JOINER .join (
593- "import * as s from 'other';" ,
593+ "import * as s from './ other';" ,
594594 "let {foo, bar} = goog.require('some.name.space');" ,
595595 "use(foo, bar);" ),
596596 LHS_OF_GOOG_REQUIRE_MUST_BE_CONST );
@@ -628,7 +628,7 @@ public void testNamespaceImports() {
628628 public void testObjectDestructuringAndObjLitShorthand () {
629629 testModules (
630630 LINE_JOINER .join (
631- "import {f} from 'other';" ,
631+ "import {f} from './ other';" ,
632632 "const foo = 1;" ,
633633 "const {a, b} = f({foo});" ,
634634 "use(a, b);" ),
@@ -643,11 +643,11 @@ public void testObjectDestructuringAndObjLitShorthand() {
643643 }
644644
645645 public void testImportWithoutReferences () {
646- testModules ("import 'other';" , "goog.require('module$other');" );
646+ testModules ("import './ other';" , "goog.require('module$other');" );
647647 // GitHub issue #1819: https://github.com/google/closure-compiler/issues/1819
648648 // Need to make sure the order of the goog.requires matches the order of the imports.
649649 testModules (
650- "import 'other'; import 'yet_another';" ,
650+ "import './ other'; import './ yet_another';" ,
651651 "goog.require('module$other'); goog.require('module$yet_another');" );
652652 }
653653
0 commit comments