Skip to content

Commit

Permalink
Rewrite IntegrationTest.testArrayValuesIsPolyfilledForEs2015Out to use
Browse files Browse the repository at this point in the history
NoninjectingCompiler.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172782031
  • Loading branch information
lauraharker committed Oct 19, 2017
1 parent 2baef98 commit 3924144
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 8 additions & 4 deletions test/com/google/javascript/jscomp/IntegrationTest.java
Expand Up @@ -28,6 +28,7 @@
import com.google.javascript.jscomp.CompilerOptions.DevMode;
import com.google.javascript.jscomp.CompilerOptions.LanguageMode;
import com.google.javascript.jscomp.CompilerOptions.Reach;
import com.google.javascript.jscomp.CompilerTestCase.NoninjectingCompiler;
import com.google.javascript.jscomp.testing.NodeSubject;
import com.google.javascript.rhino.Node;
import com.google.javascript.rhino.Token;
Expand Down Expand Up @@ -475,13 +476,16 @@ public void testArrayValuesIsPolyfilledForEs2015Out() {
options.setRewritePolyfills(true);
options.setLanguageIn(LanguageMode.ECMASCRIPT_2015);
options.setLanguageOut(LanguageMode.ECMASCRIPT_2015);
Compiler compiler = compile(

NoninjectingCompiler compiler = new NoninjectingCompiler();
compile(
options,
"for (const x of [1, 2, 3].values()) { alert(x); }");
new String[] {"for (const x of [1, 2, 3].values()) { alert(x); }"},
compiler);

assertThat(compiler.getResult().errors).isEmpty();
assertThat(compiler.getResult().warnings).isEmpty();
assertThat(compiler.getResult().warnings).isEmpty();
assertThat(compiler.toSource()).contains("Array.prototype.values");
assertThat(compiler.injected).containsExactly("es6/array/values");
}

public void testWindowIsTypedEs6() {
Expand Down
6 changes: 5 additions & 1 deletion test/com/google/javascript/jscomp/IntegrationTestCase.java
Expand Up @@ -406,7 +406,11 @@ protected Compiler compile(CompilerOptions options, String original) {
}

protected Compiler compile(CompilerOptions options, String[] original) {
Compiler compiler = lastCompiler = new Compiler();
return compile(options, original, new Compiler());
}

protected Compiler compile(CompilerOptions options, String[] original, Compiler compiler) {
lastCompiler = compiler;
BlackHoleErrorManager.silence(compiler);
compiler.compileModules(
externs,
Expand Down

0 comments on commit 3924144

Please sign in to comment.