Skip to content

Commit c054400

Browse files
blicklycopybara-github
authored andcommitted
Move a full-compiler (integration) test from VarCheckTest to CompilerTest
PiperOrigin-RevId: 322432900
1 parent 630f755 commit c054400

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

test/com/google/javascript/jscomp/CompilerTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,31 @@ public void testEs6ModuleEntryPoint() throws Exception {
14281428
assertThat(result.errors).isEmpty();
14291429
}
14301430

1431+
// ES6 Module Tests
1432+
@Test
1433+
public void testImportedNames() throws Exception {
1434+
List<SourceFile> inputs =
1435+
ImmutableList.of(
1436+
SourceFile.fromCode("/index[0].js", "import foo from './foo.js'; foo('hello');"),
1437+
SourceFile.fromCode("/foo.js", "export default (foo) => { alert(foo); }"));
1438+
1439+
List<ModuleIdentifier> entryPoints = ImmutableList.of(ModuleIdentifier.forFile("/index[0].js"));
1440+
1441+
CompilerOptions options = new CompilerOptions();
1442+
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
1443+
options.setLanguage(CompilerOptions.LanguageMode.ECMASCRIPT_2017);
1444+
options.setDependencyOptions(DependencyOptions.pruneLegacyForEntryPoints(entryPoints));
1445+
1446+
List<SourceFile> externs =
1447+
AbstractCommandLineRunner.getBuiltinExterns(options.getEnvironment());
1448+
1449+
Compiler compiler = new Compiler();
1450+
compiler.compile(externs, inputs, options);
1451+
1452+
Result result = compiler.getResult();
1453+
assertThat(result.errors).isEmpty();
1454+
}
1455+
14311456
// https://github.com/google/closure-compiler/issues/2692
14321457
@Test
14331458
public void testGoogNamespaceEntryPoint() throws Exception {
@@ -2686,6 +2711,7 @@ public void testTypesAreRemoved() {
26862711

26872712
System.gc();
26882713
System.runFinalization();
2714+
26892715
assertThat(registryWeakReference.get()).isNull();
26902716
}
26912717
}

test/com/google/javascript/jscomp/VarCheckTest.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@
2424
import static com.google.javascript.jscomp.VarCheck.VAR_MULTIPLY_DECLARED_ERROR;
2525
import static com.google.javascript.jscomp.testing.ScopeSubject.assertScope;
2626

27-
import com.google.common.collect.ImmutableList;
2827
import com.google.javascript.jscomp.CompilerOptions.LanguageMode;
2928
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback;
3029
import com.google.javascript.jscomp.testing.JSChunkGraphBuilder;
3130
import com.google.javascript.jscomp.testing.TestExternsBuilder;
3231
import com.google.javascript.rhino.Node;
3332
import com.google.javascript.rhino.StaticSourceFile.SourceKind;
34-
import java.util.List;
3533
import org.junit.Before;
3634
import org.junit.Test;
3735
import org.junit.runner.RunWith;
@@ -876,31 +874,6 @@ public void testNoUndeclaredVarWhenUsingClosurePass() {
876874
"goog.require('namespace.Class1');\n", ClosurePrimitiveErrors.MISSING_MODULE_OR_PROVIDE);
877875
}
878876

879-
// ES6 Module Tests
880-
@Test
881-
public void testImportedNames() throws Exception {
882-
List<SourceFile> inputs =
883-
ImmutableList.of(
884-
SourceFile.fromCode("/index[0].js", "import foo from './foo.js'; foo('hello');"),
885-
SourceFile.fromCode("/foo.js", "export default (foo) => { alert(foo); }"));
886-
887-
List<ModuleIdentifier> entryPoints = ImmutableList.of(ModuleIdentifier.forFile("/index[0].js"));
888-
889-
CompilerOptions options = new CompilerOptions();
890-
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
891-
options.setLanguage(CompilerOptions.LanguageMode.ECMASCRIPT_2017);
892-
options.setDependencyOptions(DependencyOptions.pruneLegacyForEntryPoints(entryPoints));
893-
894-
List<SourceFile> externs =
895-
AbstractCommandLineRunner.getBuiltinExterns(options.getEnvironment());
896-
897-
Compiler compiler = new Compiler();
898-
compiler.compile(externs, inputs, options);
899-
900-
Result result = compiler.getResult();
901-
assertThat(result.errors).isEmpty();
902-
}
903-
904877
@Test
905878
public void testImportedNameCollision() {
906879
// TODO(tbreisacher): This should throw a duplicate declaration error.

0 commit comments

Comments
 (0)