Skip to content

Commit

Permalink
Update tests to set CompilerOptions as needed explicitly, so that whe…
Browse files Browse the repository at this point in the history
…n the default changes they will not break.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=174044824
  • Loading branch information
tbreisacher authored and brad4d committed Oct 31, 2017
1 parent cb4a8ad commit d7fd438
Show file tree
Hide file tree
Showing 17 changed files with 104 additions and 32 deletions.
2 changes: 2 additions & 0 deletions test/com/google/debugging/sourcemap/SourceMapTestCase.java
Expand Up @@ -22,6 +22,7 @@
import com.google.debugging.sourcemap.proto.Mapping.OriginalMapping; import com.google.debugging.sourcemap.proto.Mapping.OriginalMapping;
import com.google.javascript.jscomp.Compiler; import com.google.javascript.jscomp.Compiler;
import com.google.javascript.jscomp.CompilerOptions; import com.google.javascript.jscomp.CompilerOptions;
import com.google.javascript.jscomp.CompilerOptions.LanguageMode;
import com.google.javascript.jscomp.Result; import com.google.javascript.jscomp.Result;
import com.google.javascript.jscomp.SourceFile; import com.google.javascript.jscomp.SourceFile;
import com.google.javascript.jscomp.SourceMap; import com.google.javascript.jscomp.SourceMap;
Expand Down Expand Up @@ -262,6 +263,7 @@ protected RunResult compile(String js, String fileName) {


protected CompilerOptions getCompilerOptions() { protected CompilerOptions getCompilerOptions() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setSourceMapOutputPath("testcode_source_map.out"); options.setSourceMapOutputPath("testcode_source_map.out");
options.setSourceMapFormat(getSourceMapFormat()); options.setSourceMapFormat(getSourceMapFormat());
options.setSourceMapDetailLevel(detailLevel); options.setSourceMapDetailLevel(detailLevel);
Expand Down
Expand Up @@ -22,6 +22,7 @@


import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.javascript.jscomp.CompilerOptions.LanguageMode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
Expand Down Expand Up @@ -67,6 +68,7 @@ protected void setUp() throws Exception {
*/ */
protected CompilerOptions getOptions(DiagnosticGroup... typesOfGuard) { protected CompilerOptions getOptions(DiagnosticGroup... typesOfGuard) {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.declaredGlobalExternsOnWindow = false; options.declaredGlobalExternsOnWindow = false;
options.setClosurePass(true); options.setClosurePass(true);
// These are the options that are always on in JsDev which is the only // These are the options that are always on in JsDev which is the only
Expand Down
Expand Up @@ -15,6 +15,7 @@
*/ */
package com.google.javascript.jscomp; package com.google.javascript.jscomp;


import com.google.javascript.jscomp.CompilerOptions.LanguageMode;


/** /**
* Tests that the property renaming primitive goog.reflect.objectProperty * Tests that the property renaming primitive goog.reflect.objectProperty
Expand Down Expand Up @@ -145,6 +146,8 @@ public void testStaticPropRenameSimple() {
@Override @Override
protected CompilerOptions createCompilerOptions() { protected CompilerOptions createCompilerOptions() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT_2017);
options.setLanguageOut(LanguageMode.ECMASCRIPT3);
if (useSimpleMode) { if (useSimpleMode) {
CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options); CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
} else { } else {
Expand Down
Expand Up @@ -16,6 +16,7 @@


package com.google.javascript.jscomp; package com.google.javascript.jscomp;


import com.google.javascript.jscomp.CompilerOptions.LanguageMode;
import com.google.javascript.jscomp.deps.ModuleLoader; import com.google.javascript.jscomp.deps.ModuleLoader;


/** /**
Expand Down Expand Up @@ -314,6 +315,7 @@ public void testCrossModuleSubclass6() {
@Override @Override
protected CompilerOptions createCompilerOptions() { protected CompilerOptions createCompilerOptions() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setCodingConvention(new GoogleCodingConvention()); options.setCodingConvention(new GoogleCodingConvention());
WarningLevel.VERBOSE.setOptionsForWarningLevel(options); WarningLevel.VERBOSE.setOptionsForWarningLevel(options);
options.setProcessCommonJSModules(true); options.setProcessCommonJSModules(true);
Expand Down
24 changes: 16 additions & 8 deletions test/com/google/javascript/jscomp/CompilerTest.java
Expand Up @@ -114,6 +114,7 @@ public void testPrintExterns() {
List<SourceFile> externs = List<SourceFile> externs =
ImmutableList.of(SourceFile.fromCode("extern", "function alert(x) {}")); ImmutableList.of(SourceFile.fromCode("extern", "function alert(x) {}"));
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setPrintExterns(true); options.setPrintExterns(true);
Compiler compiler = new Compiler(); Compiler compiler = new Compiler();
compiler.init(externs, ImmutableList.<SourceFile>of(), options); compiler.init(externs, ImmutableList.<SourceFile>of(), options);
Expand All @@ -131,8 +132,7 @@ public void testLocalUndefined() throws Exception {
// //
// This test is just to make sure that the compiler doesn't crash. // This test is just to make sure that the compiler doesn't crash.
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel( CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
options);
Compiler compiler = new Compiler(); Compiler compiler = new Compiler();
SourceFile externs = SourceFile.fromCode("externs.js", ""); SourceFile externs = SourceFile.fromCode("externs.js", "");
SourceFile input = SourceFile.fromCode("input.js", SourceFile input = SourceFile.fromCode("input.js",
Expand Down Expand Up @@ -318,6 +318,7 @@ public void testApplyInputSourceMaps() throws Exception {
originalSourcePosition)); originalSourcePosition));


CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.sourceMapOutputPath = "fake/source_map_path.js.map"; options.sourceMapOutputPath = "fake/source_map_path.js.map";
options.inputSourceMaps = inputSourceMaps; options.inputSourceMaps = inputSourceMaps;
options.applyInputSourceMaps = true; options.applyInputSourceMaps = true;
Expand Down Expand Up @@ -874,6 +875,9 @@ static Result test(String js, String expected, DiagnosticType error) {


public void testConsecutiveSemicolons() { public void testConsecutiveSemicolons() {
Compiler compiler = new Compiler(); Compiler compiler = new Compiler();
CompilerOptions options = new CompilerOptions();
options.setEmitUseStrict(false);
compiler.initOptions(options);
String js = "if(a);"; String js = "if(a);";
Node n = compiler.parseTestCode(js); Node n = compiler.parseTestCode(js);
Compiler.CodeBuilder cb = new Compiler.CodeBuilder(); Compiler.CodeBuilder cb = new Compiler.CodeBuilder();
Expand Down Expand Up @@ -914,6 +918,7 @@ public void testWarningsFiltering() {
public void testExportSymbolReservesNamesForRenameVars() { public void testExportSymbolReservesNamesForRenameVars() {
Compiler compiler = new Compiler(); Compiler compiler = new Compiler();
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setEmitUseStrict(false);
options.setClosurePass(true); options.setClosurePass(true);
options.setVariableRenaming(VariableRenamingPolicy.ALL); options.setVariableRenaming(VariableRenamingPolicy.ALL);


Expand All @@ -923,12 +928,13 @@ public void testExportSymbolReservesNamesForRenameVars() {
Result result = compiler.compile(EMPTY_EXTERNS, inputs, options); Result result = compiler.compile(EMPTY_EXTERNS, inputs, options);


assertTrue(result.success); assertTrue(result.success);
assertEquals("var b;var c;b.exportSymbol(\"a\",c);", compiler.toSource()); assertThat(compiler.toSource()).isEqualTo("var b;var c;b.exportSymbol(\"a\",c);");
} }


public void testGenerateExportsReservesNames() { public void testGenerateExportsReservesNames() {
Compiler compiler = new Compiler(); Compiler compiler = new Compiler();
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setEmitUseStrict(false);
options.setClosurePass(true); options.setClosurePass(true);
options.setVariableRenaming(VariableRenamingPolicy.ALL); options.setVariableRenaming(VariableRenamingPolicy.ALL);
options.setGenerateExports(true); options.setGenerateExports(true);
Expand All @@ -939,8 +945,7 @@ public void testGenerateExportsReservesNames() {
Result result = compiler.compile(EMPTY_EXTERNS, inputs, options); Result result = compiler.compile(EMPTY_EXTERNS, inputs, options);


assertTrue(result.success); assertTrue(result.success);
assertEquals("var b;var c={};b.exportSymbol(\"a\",c);", assertThat(compiler.toSource()).isEqualTo("var b;var c={};b.exportSymbol(\"a\",c);");
compiler.toSource());
} }


private static final DiagnosticType TEST_ERROR = private static final DiagnosticType TEST_ERROR =
Expand Down Expand Up @@ -1432,9 +1437,12 @@ public Class<String> getType() {
} }


private static CompilerOptions createNewFlagBasedOptions() { private static CompilerOptions createNewFlagBasedOptions() {
CompilerOptions opt = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(opt); CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
return opt; options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setLanguageOut(LanguageMode.ECMASCRIPT3);
options.setEmitUseStrict(false);
return options;
} }


private static byte[] serialize(Object obj) throws IOException { private static byte[] serialize(Object obj) throws IOException {
Expand Down
Expand Up @@ -160,6 +160,9 @@ private Node getSideEffectsHookNode() {
private void checkKeepSimplifiedShortCircuitExpr(Node root, private void checkKeepSimplifiedShortCircuitExpr(Node root,
List<String> expected) { List<String> expected) {
Compiler compiler = new Compiler(); Compiler compiler = new Compiler();
CompilerOptions options = new CompilerOptions();
options.setEmitUseStrict(false);
compiler.initOptions(options);
List<Node> replacements = new ArrayList<>(); List<Node> replacements = new ArrayList<>();
GetReplacementSideEffectSubexpressions accumulator = GetReplacementSideEffectSubexpressions accumulator =
new GetReplacementSideEffectSubexpressions(compiler, replacements); new GetReplacementSideEffectSubexpressions(compiler, replacements);
Expand All @@ -177,6 +180,9 @@ private void checkKeepSimplifiedHookExpr(Node root,
boolean elseHasSideEffects, boolean elseHasSideEffects,
List<String> expected) { List<String> expected) {
Compiler compiler = new Compiler(); Compiler compiler = new Compiler();
CompilerOptions options = new CompilerOptions();
options.setEmitUseStrict(false);
compiler.initOptions(options);
List<Node> replacements = new ArrayList<>(); List<Node> replacements = new ArrayList<>();
GetReplacementSideEffectSubexpressions accumulator = GetReplacementSideEffectSubexpressions accumulator =
new GetReplacementSideEffectSubexpressions(compiler, replacements); new GetReplacementSideEffectSubexpressions(compiler, replacements);
Expand Down
2 changes: 2 additions & 0 deletions test/com/google/javascript/jscomp/GoldenFileComparer.java
Expand Up @@ -20,6 +20,7 @@


import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.google.javascript.jscomp.CompilerOptions.LanguageMode;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
Expand Down Expand Up @@ -107,6 +108,7 @@ private static void compileAndCompare(
*/ */
public static CompilerOptions options() { public static CompilerOptions options() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
// Instrumentation done // Instrumentation done
options.setPrettyPrint(true); options.setPrettyPrint(true);
return options; return options;
Expand Down
28 changes: 25 additions & 3 deletions test/com/google/javascript/jscomp/IntegrationTest.java
Expand Up @@ -279,6 +279,7 @@ public void testBug1949424_v2() {
@GwtIncompatible // b/63595345 @GwtIncompatible // b/63595345
public void testUnresolvedDefine() { public void testUnresolvedDefine() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setClosurePass(true); options.setClosurePass(true);
options.setCheckTypes(true); options.setCheckTypes(true);
DiagnosticType[] warnings = { DiagnosticType[] warnings = {
Expand Down Expand Up @@ -378,6 +379,7 @@ public void testBug31301233() {


public void testAdvancedModeIncludesExtraSmartNameRemoval() { public void testAdvancedModeIncludesExtraSmartNameRemoval() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options); CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
test( test(
options, options,
Expand Down Expand Up @@ -957,6 +959,7 @@ public void testCheckTypes() {


public void testRenamingOfTypedefPropertiesWithNTI() { public void testRenamingOfTypedefPropertiesWithNTI() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setNewTypeInference(true); options.setNewTypeInference(true);
options.setPropertyRenaming(PropertyRenamingPolicy.ALL_UNQUOTED); options.setPropertyRenaming(PropertyRenamingPolicy.ALL_UNQUOTED);


Expand Down Expand Up @@ -1028,6 +1031,7 @@ public void testBothTypeCheckersRunNoDupWarning() {


public void testSilenceUnknownTypeWarningFromOTI() { public void testSilenceUnknownTypeWarningFromOTI() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setCheckTypes(true); options.setCheckTypes(true);
options.setNewTypeInference(true); options.setNewTypeInference(true);


Expand Down Expand Up @@ -1081,6 +1085,7 @@ public void testNTInoMaskTypeParseError() {


public void testLegacyCompileOverridesStrict() { public void testLegacyCompileOverridesStrict() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setCheckTypes(true); options.setCheckTypes(true);
options.addWarningsGuard(new StrictWarningsGuard()); options.addWarningsGuard(new StrictWarningsGuard());
options.setLegacyCodeCompile(true); options.setLegacyCodeCompile(true);
Expand All @@ -1091,6 +1096,7 @@ public void testLegacyCompileOverridesStrict() {


public void testLegacyCompileOverridesExplicitPromotionToError() { public void testLegacyCompileOverridesExplicitPromotionToError() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setCheckTypes(true); options.setCheckTypes(true);
options.addWarningsGuard(new DiagnosticGroupWarningsGuard( options.addWarningsGuard(new DiagnosticGroupWarningsGuard(
DiagnosticGroups.CHECK_TYPES, CheckLevel.ERROR)); DiagnosticGroups.CHECK_TYPES, CheckLevel.ERROR));
Expand Down Expand Up @@ -1176,6 +1182,7 @@ public void testRemoveClosureAsserts() {


public void testRemoveClosureAsserts2() { public void testRemoveClosureAsserts2() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setClosurePass(true); options.setClosurePass(true);
options.setNewTypeInference(true); options.setNewTypeInference(true);
options.setRunOTIafterNTI(false); options.setRunOTIafterNTI(false);
Expand Down Expand Up @@ -1471,6 +1478,7 @@ public void testDisambiguatePropertiesWithNtiNoCrash() {


public void testDisambiguatePropertiesWithNtiNoCrash2() { public void testDisambiguatePropertiesWithNtiNoCrash2() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setClosurePass(true); options.setClosurePass(true);
options.setNewTypeInference(true); options.setNewTypeInference(true);
options.setRunOTIafterNTI(false); options.setRunOTIafterNTI(false);
Expand Down Expand Up @@ -1498,6 +1506,7 @@ public void testDisambiguatePropertiesWithNtiNoCrash2() {
// disambiguation. // disambiguation.
public void testNtiTypeVariableErrorsDontBlockDisambiguation() { public void testNtiTypeVariableErrorsDontBlockDisambiguation() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setClosurePass(true); options.setClosurePass(true);
options.setNewTypeInference(true); options.setNewTypeInference(true);
options.setRunOTIafterNTI(false); options.setRunOTIafterNTI(false);
Expand Down Expand Up @@ -1546,6 +1555,7 @@ public void testNtiTypeVariableErrorsDontBlockDisambiguation() {


public void testNtiTypeVariableErrorsDontBlockDisambiguation2() { public void testNtiTypeVariableErrorsDontBlockDisambiguation2() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setClosurePass(true); options.setClosurePass(true);
options.setNewTypeInference(true); options.setNewTypeInference(true);
options.setRunOTIafterNTI(false); options.setRunOTIafterNTI(false);
Expand Down Expand Up @@ -1600,6 +1610,7 @@ public void testNtiTypeVariableErrorsDontBlockDisambiguation2() {


public void testTurnOffConstChecksOfCheckAccessControlsWithNtiOn() { public void testTurnOffConstChecksOfCheckAccessControlsWithNtiOn() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setClosurePass(true); options.setClosurePass(true);
options.setNewTypeInference(true); options.setNewTypeInference(true);
options.setRunOTIafterNTI(false); options.setRunOTIafterNTI(false);
Expand Down Expand Up @@ -2301,7 +2312,6 @@ public void testPreservesCastInformation() {
// looks for that exact suffix, and IntegrationTestCase adds an input // looks for that exact suffix, and IntegrationTestCase adds an input
// id number between prefix and suffix. // id number between prefix and suffix.
inputFileNameSuffix = "vmbootstrap/Arrays.impl.java.js"; inputFileNameSuffix = "vmbootstrap/Arrays.impl.java.js";
CompilerOptions options = new CompilerOptions();
String code = LINE_JOINER.join( String code = LINE_JOINER.join(
"/** @constructor */", "/** @constructor */",
"var Arrays = function() {};", "var Arrays = function() {};",
Expand All @@ -2312,6 +2322,8 @@ public void testPreservesCastInformation() {
"function Bar() { this.myprop = 2; }", "function Bar() { this.myprop = 2; }",
"var x = /** @type {!Foo} */ (Arrays.$create()).myprop;"); "var x = /** @type {!Foo} */ (Arrays.$create()).myprop;");


CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setCheckTypes(true); options.setCheckTypes(true);
options.setDisambiguateProperties(true); options.setDisambiguateProperties(true);


Expand Down Expand Up @@ -2345,6 +2357,7 @@ public void testInliningLocalVarsPreservesCasts() {
"})()"); "})()");


CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setCheckTypes(true); options.setCheckTypes(true);
options.setSmartNameRemoval(true); options.setSmartNameRemoval(true);
options.setFoldConstants(true); options.setFoldConstants(true);
Expand Down Expand Up @@ -2394,6 +2407,7 @@ public void testInliningLocalVarsPreservesCastsNullable() {
"})()"); "})()");


CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setCheckTypes(true); options.setCheckTypes(true);
options.setSmartNameRemoval(true); options.setSmartNameRemoval(true);
options.setFoldConstants(true); options.setFoldConstants(true);
Expand Down Expand Up @@ -3138,8 +3152,8 @@ public void testIssue598() {


public void testCheckStrictMode() { public void testCheckStrictMode() {
CompilerOptions options = createCompilerOptions(); CompilerOptions options = createCompilerOptions();
CompilationLevel.ADVANCED_OPTIMIZATIONS options.setLanguageIn(LanguageMode.ECMASCRIPT3);
.setOptionsForCompilationLevel(options); CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
WarningLevel.VERBOSE.setOptionsForWarningLevel(options); WarningLevel.VERBOSE.setOptionsForWarningLevel(options);


externs = ImmutableList.of( externs = ImmutableList.of(
Expand Down Expand Up @@ -3665,6 +3679,7 @@ public void testSuppressEs5StrictWarning() {


public void testCheckProvidesWarning() { public void testCheckProvidesWarning() {
CompilerOptions options = createCompilerOptions(); CompilerOptions options = createCompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setWarningLevel(DiagnosticGroups.MISSING_PROVIDE, CheckLevel.WARNING); options.setWarningLevel(DiagnosticGroups.MISSING_PROVIDE, CheckLevel.WARNING);
options.setWarningLevel(DiagnosticGroups.ES5_STRICT, CheckLevel.OFF); options.setWarningLevel(DiagnosticGroups.ES5_STRICT, CheckLevel.OFF);
test(options, test(options,
Expand Down Expand Up @@ -3915,6 +3930,7 @@ public void testGoogModuleDuplicateExport() {


public void testGoogModuleOuterLegacyInner() { public void testGoogModuleOuterLegacyInner() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setClosurePass(true); options.setClosurePass(true);
options.setCodingConvention(new ClosureCodingConvention()); options.setCodingConvention(new ClosureCodingConvention());


Expand Down Expand Up @@ -3960,6 +3976,7 @@ public void testGoogModuleOuterLegacyInner() {


public void testLegacyGoogModuleExport() { public void testLegacyGoogModuleExport() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setClosurePass(true); options.setClosurePass(true);
options.setCodingConvention(new ClosureCodingConvention()); options.setCodingConvention(new ClosureCodingConvention());
options.setGenerateExports(true); options.setGenerateExports(true);
Expand Down Expand Up @@ -4465,6 +4482,7 @@ public void testExports() {


public void testGatherExternPropsWithNTI() { public void testGatherExternPropsWithNTI() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setNewTypeInference(true); options.setNewTypeInference(true);
options.setGenerateExports(true); options.setGenerateExports(true);
options.setExportLocalPropertyDefinitions(true); options.setExportLocalPropertyDefinitions(true);
Expand Down Expand Up @@ -4782,6 +4800,7 @@ public void testInlineRestParam() {
public void testInlineRestParamNonTranspiling() { public void testInlineRestParamNonTranspiling() {
CompilerOptions options = createCompilerOptions(); CompilerOptions options = createCompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT_2017); options.setLanguageIn(LanguageMode.ECMASCRIPT_2017);
options.setLanguageOut(LanguageMode.ECMASCRIPT_2017);
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options); CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
test( test(
options, options,
Expand Down Expand Up @@ -4814,6 +4833,7 @@ public void testDefaultParametersNonTranspiling() {
CompilerOptions options = createCompilerOptions(); CompilerOptions options = createCompilerOptions();
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options); CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
options.setLanguageIn(LanguageMode.ECMASCRIPT_2017); options.setLanguageIn(LanguageMode.ECMASCRIPT_2017);
options.setLanguageOut(LanguageMode.ECMASCRIPT_2017);


test( test(
options, options,
Expand Down Expand Up @@ -4851,6 +4871,7 @@ public void testRestObjectPatternParametersNonTranspiling() {
CompilerOptions options = createCompilerOptions(); CompilerOptions options = createCompilerOptions();
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options); CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
options.setLanguageIn(LanguageMode.ECMASCRIPT_2017); options.setLanguageIn(LanguageMode.ECMASCRIPT_2017);
options.setLanguageOut(LanguageMode.ECMASCRIPT_2017);
externs = DEFAULT_EXTERNS; externs = DEFAULT_EXTERNS;


test( test(
Expand All @@ -4867,6 +4888,7 @@ public void testRestObjectPatternParametersNonTranspiling() {
@Override @Override
protected CompilerOptions createCompilerOptions() { protected CompilerOptions createCompilerOptions() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageOut(LanguageMode.ECMASCRIPT3);
options.setDevMode(DevMode.EVERY_PASS); options.setDevMode(DevMode.EVERY_PASS);
options.setCodingConvention(new GoogleCodingConvention()); options.setCodingConvention(new GoogleCodingConvention());
options.setRenamePrefixNamespaceAssumeCrossModuleNames(true); options.setRenamePrefixNamespaceAssumeCrossModuleNames(true);
Expand Down
2 changes: 1 addition & 1 deletion test/com/google/javascript/jscomp/NodeUtilTest.java
Expand Up @@ -1820,7 +1820,7 @@ public void testGetNumberValue() {
assertNull(NodeUtil.getNumberValue(getNode("+1"))); assertNull(NodeUtil.getNumberValue(getNode("+1")));
} }


public void testIsNumbericResult() { public void testIsNumericResult() {
assertTrue(NodeUtil.isNumericResult(getNode("1"))); assertTrue(NodeUtil.isNumericResult(getNode("1")));
assertFalse(NodeUtil.isNumericResult(getNode("true"))); assertFalse(NodeUtil.isNumericResult(getNode("true")));
assertTrue(NodeUtil.isNumericResult(getNode("+true"))); assertTrue(NodeUtil.isNumericResult(getNode("+true")));
Expand Down

0 comments on commit d7fd438

Please sign in to comment.