public void testModuleWrapperBaseNameExpansion() throws Exception {
    useModules = ModulePattern.CHAIN;
    args.add("--module_wrapper=m0:%s // %basename%");
    testSame(new String[] {"var x = 3;", "var y = 4;"});

    StringBuilder builder = new StringBuilder();
    lastCommandLineRunner.writeModuleOutput(builder, lastCompiler.getModuleGraph().getRootModule());
    assertEquals("var x=3; // m0.js\n", builder.toString());
  }
 public void testSourceMapExpansion3() {
   useModules = ModulePattern.CHAIN;
   args.add("--create_source_map=%outname%.map");
   args.add("--module_output_path_prefix=foo_");
   testSame(new String[] {"var x = 3;", "var y = 5;"});
   assertEquals(
       "foo_m0.js.map",
       lastCommandLineRunner.expandSourceMapPath(
           lastCompiler.getOptions(), lastCompiler.getModuleGraph().getRootModule()));
 }
  public void testStarModuleManifest() throws Exception {
    useModules = ModulePattern.STAR;
    testSame(new String[] {"var x = 3;", "var y = 5;", "var z = 7;", "var a = 9;"});

    StringBuilder builder = new StringBuilder();
    lastCommandLineRunner.printModuleGraphManifestOrBundleTo(
        lastCompiler.getModuleGraph(), builder, true);
    assertEquals(
        "{m0}\n"
            + "i0\n"
            + "\n"
            + "{m1:m0}\n"
            + "i1\n"
            + "\n"
            + "{m2:m0}\n"
            + "i2\n"
            + "\n"
            + "{m3:m0}\n"
            + "i3\n",
        builder.toString());
  }
  private void assertSortedInputs(List<SourceFile> expected, List<SourceFile> shuffled)
      throws Exception {
    Compiler compiler = new Compiler(System.err);
    compiler.initCompilerOptionsIfTesting();
    compiler.getOptions().setProcessCommonJSModules(true);
    compiler
        .getOptions()
        .dependencyOptions
        .setEntryPoints(ImmutableList.of(ES6ModuleLoader.toModuleName(URI.create("a"))));
    compiler.compile(
        ImmutableList.of(SourceFile.fromCode("externs.js", "")), shuffled, compiler.getOptions());

    List<SourceFile> result = new ArrayList<>();
    for (JSModule m : compiler.getModuleGraph().getAllModules()) {
      for (CompilerInput i : m.getInputs()) {
        result.add(i.getSourceFile());
      }
    }

    assertEquals(expected, result);
  }