From 6ee9f3994624a7341813615149e0807f07d0438b Mon Sep 17 00:00:00 2001 From: tbreisacher Date: Mon, 30 Oct 2017 14:17:03 -0700 Subject: [PATCH] Change the default input language to ES 2017 to match the command-line default. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=173947967 --- .../javascript/jscomp/CompilerOptions.java | 2 +- .../jscomp/ComposeWarningsGuard.java | 6 ++-- .../sourcemap/SourceMapTestCase.java | 2 ++ .../jscomp/BaseReplaceScriptTestCase.java | 2 ++ .../ClosurePrimitivesIntegrationTest.java | 3 ++ .../jscomp/CommonJSIntegrationTest.java | 2 ++ .../javascript/jscomp/CompilerTest.java | 24 ++++++++----- ...rSideEffectSubexpressionsCallbackTest.java | 6 ++++ .../javascript/jscomp/GoldenFileComparer.java | 2 ++ .../javascript/jscomp/IntegrationTest.java | 28 +++++++++++++-- .../javascript/jscomp/NodeUtilTest.java | 2 +- .../javascript/jscomp/NormalizeTest.java | 5 ++- .../javascript/jscomp/PhaseOptimizerTest.java | 6 ++++ .../jscomp/RecordFunctionInformationTest.java | 11 +++--- .../jscomp/RenamePropertiesTest.java | 34 +++++++++++-------- .../jscomp/ReplaceCssNamesTest.java | 3 ++ .../jscomp/RhinoErrorReporterTest.java | 2 ++ .../jscomp/TemplateAstMatcherTest.java | 2 ++ .../jscomp/TypeMatchingStrategyTest.java | 2 ++ 19 files changed, 107 insertions(+), 37 deletions(-) diff --git a/src/com/google/javascript/jscomp/CompilerOptions.java b/src/com/google/javascript/jscomp/CompilerOptions.java index 467bc81d066..21008181781 100644 --- a/src/com/google/javascript/jscomp/CompilerOptions.java +++ b/src/com/google/javascript/jscomp/CompilerOptions.java @@ -1207,7 +1207,7 @@ public void setPrintConfig(boolean printConfig) { */ public CompilerOptions() { // Accepted language - languageIn = LanguageMode.ECMASCRIPT3; + languageIn = LanguageMode.ECMASCRIPT_2017; languageOut = LanguageMode.NO_TRANSPILE; // Which environment to use diff --git a/src/com/google/javascript/jscomp/ComposeWarningsGuard.java b/src/com/google/javascript/jscomp/ComposeWarningsGuard.java index 0e453757243..f3e51b1ae4c 100644 --- a/src/com/google/javascript/jscomp/ComposeWarningsGuard.java +++ b/src/com/google/javascript/jscomp/ComposeWarningsGuard.java @@ -46,8 +46,7 @@ public class ComposeWarningsGuard extends WarningsGuard { private final Map orderOfAddition = new HashMap<>(); private int numberOfAdds = 0; - private final Comparator guardComparator = - new GuardComparator(orderOfAddition); + private final Comparator guardComparator = new GuardComparator(orderOfAddition); private boolean demoteErrors = false; private static class GuardComparator @@ -73,8 +72,7 @@ public int compare(WarningsGuard a, WarningsGuard b) { } // The order that the guards are applied in. - private final TreeSet guards = - new TreeSet<>(guardComparator); + private final TreeSet guards = new TreeSet<>(guardComparator); public ComposeWarningsGuard(List guards) { addGuards(guards); diff --git a/test/com/google/debugging/sourcemap/SourceMapTestCase.java b/test/com/google/debugging/sourcemap/SourceMapTestCase.java index 0810aecde5d..27ef454cf5e 100644 --- a/test/com/google/debugging/sourcemap/SourceMapTestCase.java +++ b/test/com/google/debugging/sourcemap/SourceMapTestCase.java @@ -22,6 +22,7 @@ import com.google.debugging.sourcemap.proto.Mapping.OriginalMapping; import com.google.javascript.jscomp.Compiler; import com.google.javascript.jscomp.CompilerOptions; +import com.google.javascript.jscomp.CompilerOptions.LanguageMode; import com.google.javascript.jscomp.Result; import com.google.javascript.jscomp.SourceFile; import com.google.javascript.jscomp.SourceMap; @@ -262,6 +263,7 @@ protected RunResult compile(String js, String fileName) { protected CompilerOptions getCompilerOptions() { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setSourceMapOutputPath("testcode_source_map.out"); options.setSourceMapFormat(getSourceMapFormat()); options.setSourceMapDetailLevel(detailLevel); diff --git a/test/com/google/javascript/jscomp/BaseReplaceScriptTestCase.java b/test/com/google/javascript/jscomp/BaseReplaceScriptTestCase.java index 38a0f3a45cc..f642d52c7ee 100644 --- a/test/com/google/javascript/jscomp/BaseReplaceScriptTestCase.java +++ b/test/com/google/javascript/jscomp/BaseReplaceScriptTestCase.java @@ -22,6 +22,7 @@ import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; +import com.google.javascript.jscomp.CompilerOptions.LanguageMode; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -67,6 +68,7 @@ protected void setUp() throws Exception { */ protected CompilerOptions getOptions(DiagnosticGroup... typesOfGuard) { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.declaredGlobalExternsOnWindow = false; options.setClosurePass(true); // These are the options that are always on in JsDev which is the only diff --git a/test/com/google/javascript/jscomp/ClosurePrimitivesIntegrationTest.java b/test/com/google/javascript/jscomp/ClosurePrimitivesIntegrationTest.java index b8a56b41257..2b12f27ea3a 100644 --- a/test/com/google/javascript/jscomp/ClosurePrimitivesIntegrationTest.java +++ b/test/com/google/javascript/jscomp/ClosurePrimitivesIntegrationTest.java @@ -15,6 +15,7 @@ */ package com.google.javascript.jscomp; +import com.google.javascript.jscomp.CompilerOptions.LanguageMode; /** * Tests that the property renaming primitive goog.reflect.objectProperty @@ -145,6 +146,8 @@ public void testStaticPropRenameSimple() { @Override protected CompilerOptions createCompilerOptions() { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT_2017); + options.setLanguageOut(LanguageMode.ECMASCRIPT3); if (useSimpleMode) { CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options); } else { diff --git a/test/com/google/javascript/jscomp/CommonJSIntegrationTest.java b/test/com/google/javascript/jscomp/CommonJSIntegrationTest.java index 9c1e5ee138c..0c7db60e453 100644 --- a/test/com/google/javascript/jscomp/CommonJSIntegrationTest.java +++ b/test/com/google/javascript/jscomp/CommonJSIntegrationTest.java @@ -16,6 +16,7 @@ package com.google.javascript.jscomp; +import com.google.javascript.jscomp.CompilerOptions.LanguageMode; import com.google.javascript.jscomp.deps.ModuleLoader; /** @@ -314,6 +315,7 @@ public void testCrossModuleSubclass6() { @Override protected CompilerOptions createCompilerOptions() { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setCodingConvention(new GoogleCodingConvention()); WarningLevel.VERBOSE.setOptionsForWarningLevel(options); options.setProcessCommonJSModules(true); diff --git a/test/com/google/javascript/jscomp/CompilerTest.java b/test/com/google/javascript/jscomp/CompilerTest.java index c22a0af2f94..0d1fa2b9c9e 100644 --- a/test/com/google/javascript/jscomp/CompilerTest.java +++ b/test/com/google/javascript/jscomp/CompilerTest.java @@ -114,6 +114,7 @@ public void testPrintExterns() { List externs = ImmutableList.of(SourceFile.fromCode("extern", "function alert(x) {}")); CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setPrintExterns(true); Compiler compiler = new Compiler(); compiler.init(externs, ImmutableList.of(), options); @@ -131,8 +132,7 @@ public void testLocalUndefined() throws Exception { // // This test is just to make sure that the compiler doesn't crash. CompilerOptions options = new CompilerOptions(); - CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel( - options); + CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options); Compiler compiler = new Compiler(); SourceFile externs = SourceFile.fromCode("externs.js", ""); SourceFile input = SourceFile.fromCode("input.js", @@ -318,6 +318,7 @@ public void testApplyInputSourceMaps() throws Exception { originalSourcePosition)); CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.sourceMapOutputPath = "fake/source_map_path.js.map"; options.inputSourceMaps = inputSourceMaps; options.applyInputSourceMaps = true; @@ -874,6 +875,9 @@ static Result test(String js, String expected, DiagnosticType error) { public void testConsecutiveSemicolons() { Compiler compiler = new Compiler(); + CompilerOptions options = new CompilerOptions(); + options.setEmitUseStrict(false); + compiler.initOptions(options); String js = "if(a);"; Node n = compiler.parseTestCode(js); Compiler.CodeBuilder cb = new Compiler.CodeBuilder(); @@ -914,6 +918,7 @@ public void testWarningsFiltering() { public void testExportSymbolReservesNamesForRenameVars() { Compiler compiler = new Compiler(); CompilerOptions options = new CompilerOptions(); + options.setEmitUseStrict(false); options.setClosurePass(true); options.setVariableRenaming(VariableRenamingPolicy.ALL); @@ -923,12 +928,13 @@ public void testExportSymbolReservesNamesForRenameVars() { Result result = compiler.compile(EMPTY_EXTERNS, inputs, options); 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() { Compiler compiler = new Compiler(); CompilerOptions options = new CompilerOptions(); + options.setEmitUseStrict(false); options.setClosurePass(true); options.setVariableRenaming(VariableRenamingPolicy.ALL); options.setGenerateExports(true); @@ -939,8 +945,7 @@ public void testGenerateExportsReservesNames() { Result result = compiler.compile(EMPTY_EXTERNS, inputs, options); 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);"); } private static final DiagnosticType TEST_ERROR = @@ -1432,9 +1437,12 @@ public Class getType() { } private static CompilerOptions createNewFlagBasedOptions() { - CompilerOptions opt = new CompilerOptions(); - CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(opt); - return opt; + CompilerOptions options = new CompilerOptions(); + CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); + options.setLanguageOut(LanguageMode.ECMASCRIPT3); + options.setEmitUseStrict(false); + return options; } private static byte[] serialize(Object obj) throws IOException { diff --git a/test/com/google/javascript/jscomp/GatherSideEffectSubexpressionsCallbackTest.java b/test/com/google/javascript/jscomp/GatherSideEffectSubexpressionsCallbackTest.java index 1551ae8daab..ee1c0267837 100644 --- a/test/com/google/javascript/jscomp/GatherSideEffectSubexpressionsCallbackTest.java +++ b/test/com/google/javascript/jscomp/GatherSideEffectSubexpressionsCallbackTest.java @@ -160,6 +160,9 @@ private Node getSideEffectsHookNode() { private void checkKeepSimplifiedShortCircuitExpr(Node root, List expected) { Compiler compiler = new Compiler(); + CompilerOptions options = new CompilerOptions(); + options.setEmitUseStrict(false); + compiler.initOptions(options); List replacements = new ArrayList<>(); GetReplacementSideEffectSubexpressions accumulator = new GetReplacementSideEffectSubexpressions(compiler, replacements); @@ -177,6 +180,9 @@ private void checkKeepSimplifiedHookExpr(Node root, boolean elseHasSideEffects, List expected) { Compiler compiler = new Compiler(); + CompilerOptions options = new CompilerOptions(); + options.setEmitUseStrict(false); + compiler.initOptions(options); List replacements = new ArrayList<>(); GetReplacementSideEffectSubexpressions accumulator = new GetReplacementSideEffectSubexpressions(compiler, replacements); diff --git a/test/com/google/javascript/jscomp/GoldenFileComparer.java b/test/com/google/javascript/jscomp/GoldenFileComparer.java index 8519adfa777..e71992127dc 100644 --- a/test/com/google/javascript/jscomp/GoldenFileComparer.java +++ b/test/com/google/javascript/jscomp/GoldenFileComparer.java @@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.io.Files; +import com.google.javascript.jscomp.CompilerOptions.LanguageMode; import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -107,6 +108,7 @@ private static void compileAndCompare( */ public static CompilerOptions options() { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); // Instrumentation done options.setPrettyPrint(true); return options; diff --git a/test/com/google/javascript/jscomp/IntegrationTest.java b/test/com/google/javascript/jscomp/IntegrationTest.java index d75f6e12d85..dcd604e1bea 100644 --- a/test/com/google/javascript/jscomp/IntegrationTest.java +++ b/test/com/google/javascript/jscomp/IntegrationTest.java @@ -279,6 +279,7 @@ public void testBug1949424_v2() { @GwtIncompatible // b/63595345 public void testUnresolvedDefine() { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setClosurePass(true); options.setCheckTypes(true); DiagnosticType[] warnings = { @@ -378,6 +379,7 @@ public void testBug31301233() { public void testAdvancedModeIncludesExtraSmartNameRemoval() { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options); test( options, @@ -957,6 +959,7 @@ public void testCheckTypes() { public void testRenamingOfTypedefPropertiesWithNTI() { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setNewTypeInference(true); options.setPropertyRenaming(PropertyRenamingPolicy.ALL_UNQUOTED); @@ -1028,6 +1031,7 @@ public void testBothTypeCheckersRunNoDupWarning() { public void testSilenceUnknownTypeWarningFromOTI() { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setCheckTypes(true); options.setNewTypeInference(true); @@ -1081,6 +1085,7 @@ public void testNTInoMaskTypeParseError() { public void testLegacyCompileOverridesStrict() { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setCheckTypes(true); options.addWarningsGuard(new StrictWarningsGuard()); options.setLegacyCodeCompile(true); @@ -1091,6 +1096,7 @@ public void testLegacyCompileOverridesStrict() { public void testLegacyCompileOverridesExplicitPromotionToError() { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setCheckTypes(true); options.addWarningsGuard(new DiagnosticGroupWarningsGuard( DiagnosticGroups.CHECK_TYPES, CheckLevel.ERROR)); @@ -1176,6 +1182,7 @@ public void testRemoveClosureAsserts() { public void testRemoveClosureAsserts2() { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setClosurePass(true); options.setNewTypeInference(true); options.setRunOTIafterNTI(false); @@ -1471,6 +1478,7 @@ public void testDisambiguatePropertiesWithNtiNoCrash() { public void testDisambiguatePropertiesWithNtiNoCrash2() { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setClosurePass(true); options.setNewTypeInference(true); options.setRunOTIafterNTI(false); @@ -1498,6 +1506,7 @@ public void testDisambiguatePropertiesWithNtiNoCrash2() { // disambiguation. public void testNtiTypeVariableErrorsDontBlockDisambiguation() { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setClosurePass(true); options.setNewTypeInference(true); options.setRunOTIafterNTI(false); @@ -1546,6 +1555,7 @@ public void testNtiTypeVariableErrorsDontBlockDisambiguation() { public void testNtiTypeVariableErrorsDontBlockDisambiguation2() { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setClosurePass(true); options.setNewTypeInference(true); options.setRunOTIafterNTI(false); @@ -1600,6 +1610,7 @@ public void testNtiTypeVariableErrorsDontBlockDisambiguation2() { public void testTurnOffConstChecksOfCheckAccessControlsWithNtiOn() { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setClosurePass(true); options.setNewTypeInference(true); options.setRunOTIafterNTI(false); @@ -2301,7 +2312,6 @@ public void testPreservesCastInformation() { // looks for that exact suffix, and IntegrationTestCase adds an input // id number between prefix and suffix. inputFileNameSuffix = "vmbootstrap/Arrays.impl.java.js"; - CompilerOptions options = new CompilerOptions(); String code = LINE_JOINER.join( "/** @constructor */", "var Arrays = function() {};", @@ -2312,6 +2322,8 @@ public void testPreservesCastInformation() { "function Bar() { this.myprop = 2; }", "var x = /** @type {!Foo} */ (Arrays.$create()).myprop;"); + CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setCheckTypes(true); options.setDisambiguateProperties(true); @@ -2345,6 +2357,7 @@ public void testInliningLocalVarsPreservesCasts() { "})()"); CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setCheckTypes(true); options.setSmartNameRemoval(true); options.setFoldConstants(true); @@ -2394,6 +2407,7 @@ public void testInliningLocalVarsPreservesCastsNullable() { "})()"); CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setCheckTypes(true); options.setSmartNameRemoval(true); options.setFoldConstants(true); @@ -3138,8 +3152,8 @@ public void testIssue598() { public void testCheckStrictMode() { CompilerOptions options = createCompilerOptions(); - CompilationLevel.ADVANCED_OPTIMIZATIONS - .setOptionsForCompilationLevel(options); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); + CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options); WarningLevel.VERBOSE.setOptionsForWarningLevel(options); externs = ImmutableList.of( @@ -3665,6 +3679,7 @@ public void testSuppressEs5StrictWarning() { public void testCheckProvidesWarning() { CompilerOptions options = createCompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setWarningLevel(DiagnosticGroups.MISSING_PROVIDE, CheckLevel.WARNING); options.setWarningLevel(DiagnosticGroups.ES5_STRICT, CheckLevel.OFF); test(options, @@ -3915,6 +3930,7 @@ public void testGoogModuleDuplicateExport() { public void testGoogModuleOuterLegacyInner() { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setClosurePass(true); options.setCodingConvention(new ClosureCodingConvention()); @@ -3960,6 +3976,7 @@ public void testGoogModuleOuterLegacyInner() { public void testLegacyGoogModuleExport() { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setClosurePass(true); options.setCodingConvention(new ClosureCodingConvention()); options.setGenerateExports(true); @@ -4465,6 +4482,7 @@ public void testExports() { public void testGatherExternPropsWithNTI() { CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setNewTypeInference(true); options.setGenerateExports(true); options.setExportLocalPropertyDefinitions(true); @@ -4782,6 +4800,7 @@ public void testInlineRestParam() { public void testInlineRestParamNonTranspiling() { CompilerOptions options = createCompilerOptions(); options.setLanguageIn(LanguageMode.ECMASCRIPT_2017); + options.setLanguageOut(LanguageMode.ECMASCRIPT_2017); CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options); test( options, @@ -4814,6 +4833,7 @@ public void testDefaultParametersNonTranspiling() { CompilerOptions options = createCompilerOptions(); CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options); options.setLanguageIn(LanguageMode.ECMASCRIPT_2017); + options.setLanguageOut(LanguageMode.ECMASCRIPT_2017); test( options, @@ -4851,6 +4871,7 @@ public void testRestObjectPatternParametersNonTranspiling() { CompilerOptions options = createCompilerOptions(); CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options); options.setLanguageIn(LanguageMode.ECMASCRIPT_2017); + options.setLanguageOut(LanguageMode.ECMASCRIPT_2017); externs = DEFAULT_EXTERNS; test( @@ -4867,6 +4888,7 @@ public void testRestObjectPatternParametersNonTranspiling() { @Override protected CompilerOptions createCompilerOptions() { CompilerOptions options = new CompilerOptions(); + options.setLanguageOut(LanguageMode.ECMASCRIPT3); options.setDevMode(DevMode.EVERY_PASS); options.setCodingConvention(new GoogleCodingConvention()); options.setRenamePrefixNamespaceAssumeCrossModuleNames(true); diff --git a/test/com/google/javascript/jscomp/NodeUtilTest.java b/test/com/google/javascript/jscomp/NodeUtilTest.java index d808a79e44f..ad2ca4f59e3 100644 --- a/test/com/google/javascript/jscomp/NodeUtilTest.java +++ b/test/com/google/javascript/jscomp/NodeUtilTest.java @@ -1820,7 +1820,7 @@ public void testGetNumberValue() { assertNull(NodeUtil.getNumberValue(getNode("+1"))); } - public void testIsNumbericResult() { + public void testIsNumericResult() { assertTrue(NodeUtil.isNumericResult(getNode("1"))); assertFalse(NodeUtil.isNumericResult(getNode("true"))); assertTrue(NodeUtil.isNumericResult(getNode("+true"))); diff --git a/test/com/google/javascript/jscomp/NormalizeTest.java b/test/com/google/javascript/jscomp/NormalizeTest.java index b72cfb7c43c..9592a609da9 100644 --- a/test/com/google/javascript/jscomp/NormalizeTest.java +++ b/test/com/google/javascript/jscomp/NormalizeTest.java @@ -735,9 +735,12 @@ public void testIssue() { public void testNormalizeSyntheticCode() { Compiler compiler = new Compiler(); + CompilerOptions options = new CompilerOptions(); + options.setEmitUseStrict(false); compiler.init( new ArrayList(), - new ArrayList(), new CompilerOptions()); + new ArrayList(), + options); String code = "function f(x) {} function g(x) {}"; Node ast = compiler.parseSyntheticCode(code); Normalize.normalizeSyntheticCode(compiler, ast, "prefix_"); diff --git a/test/com/google/javascript/jscomp/PhaseOptimizerTest.java b/test/com/google/javascript/jscomp/PhaseOptimizerTest.java index 3e306163fa1..e88440f2a5e 100644 --- a/test/com/google/javascript/jscomp/PhaseOptimizerTest.java +++ b/test/com/google/javascript/jscomp/PhaseOptimizerTest.java @@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableList; import com.google.javascript.jscomp.CompilerOptions.TracerMode; import com.google.javascript.jscomp.PhaseOptimizer.Loop; +import com.google.javascript.jscomp.parsing.parser.FeatureSet; import com.google.javascript.rhino.IR; import com.google.javascript.rhino.Node; import com.google.javascript.rhino.Token; @@ -222,6 +223,11 @@ private PassFactory createPassFactory( protected CompilerPass create(AbstractCompiler compiler) { return pass; } + + @Override + public FeatureSet featureSet() { + return FeatureSet.latest(); + } }; } diff --git a/test/com/google/javascript/jscomp/RecordFunctionInformationTest.java b/test/com/google/javascript/jscomp/RecordFunctionInformationTest.java index 68b5b3085c4..21c4c8b9334 100644 --- a/test/com/google/javascript/jscomp/RecordFunctionInformationTest.java +++ b/test/com/google/javascript/jscomp/RecordFunctionInformationTest.java @@ -74,8 +74,7 @@ public void testMotionPreservesOriginalSourceName() { mainRoot.getFirstChild().removeChild(nodeG); mainRoot.getLastChild().addChildToBack(nodeG.cloneTree()); - FunctionInformationMap.Builder expected = - FunctionInformationMap.newBuilder(); + FunctionInformationMap.Builder expected = FunctionInformationMap.newBuilder(); expected.addEntry( FunctionInformationMap.Entry.newBuilder() .setId(0) @@ -101,9 +100,11 @@ public void testMotionPreservesOriginalSourceName() { private void test(String js, FunctionInformationMap expected) { Compiler compiler = new Compiler(); + CompilerOptions options = new CompilerOptions(); + options.setEmitUseStrict(false); compiler.init(ImmutableList.of(SourceFile.fromCode("externs", "")), ImmutableList.of(SourceFile.fromCode("testcode", js)), - new CompilerOptions()); + options); test(compiler, expected); } @@ -126,10 +127,12 @@ private void test(Compiler compiler, Node externsRoot, Node mainRoot, private Compiler compilerFor(JSModule[] modules) { Compiler compiler = new Compiler(); + CompilerOptions options = new CompilerOptions(); + options.setEmitUseStrict(false); compiler.initModules( ImmutableList.of(SourceFile.fromCode("externs", "")), ImmutableList.copyOf(modules), - new CompilerOptions()); + options); return compiler; } diff --git a/test/com/google/javascript/jscomp/RenamePropertiesTest.java b/test/com/google/javascript/jscomp/RenamePropertiesTest.java index 6e63445b7f1..3466786d14c 100644 --- a/test/com/google/javascript/jscomp/RenamePropertiesTest.java +++ b/test/com/google/javascript/jscomp/RenamePropertiesTest.java @@ -233,14 +233,17 @@ public void testGeneratePseudoNames() { } public void testModules() { - String module1Js = "function Bar(){} Bar.prototype.getA=function(x){};" + - "var foo;foo.getA(foo);foo.doo=foo;foo.bloo=foo;"; + String module1Js = + "function Bar(){} Bar.prototype.getA=function(x){};" + + "var foo;foo.getA(foo);foo.doo=foo;foo.bloo=foo;"; - String module2Js = "function Far(){} Far.prototype.getB=function(x){};" + - "var too;too.getB(too);too.woo=too;too.bloo=too;"; + String module2Js = + "function Far(){} Far.prototype.getB=function(y){};" + + "var too;too.getB(too);too.woo=too;too.bloo=too;"; - String module3Js = "function Car(){} Car.prototype.getC=function(x){};" + - "var noo;noo.getC(noo);noo.zoo=noo;noo.cloo=noo;"; + String module3Js = + "function Car(){} Car.prototype.getC=function(z){};" + + "var noo;noo.getC(noo);noo.zoo=noo;noo.cloo=noo;"; JSModule module1 = new JSModule("m1"); module1.add(SourceFile.fromCode("input1", module1Js)); @@ -257,13 +260,13 @@ public void testModules() { Result result = compiler.getResult(); assertTrue(result.success); - assertEquals("function Bar(){}Bar.prototype.b=function(x){};" + - "var foo;foo.b(foo);foo.f=foo;foo.a=foo;", - compiler.toSource(module1)); + assertEquals( + "function Bar(){}Bar.prototype.b=function(x){};var foo;foo.b(foo);foo.f=foo;foo.a=foo;", + compiler.toSource(module1)); - assertEquals("function Far(){}Far.prototype.c=function(x){};" + - "var too;too.c(too);too.g=too;too.a=too;", - compiler.toSource(module2)); + assertEquals( + "function Far(){}Far.prototype.c=function(y){};var too;too.c(too);too.g=too;too.a=too;", + compiler.toSource(module2)); // Note that properties that occur most often globally get the earliest // names. The "getC" property, which doesn't occur until module 3, is @@ -271,9 +274,9 @@ public void testModules() { // in module 2, because "getC" occurs more total times across all modules. // Might be better to give early modules the shortest names, but this is // how the pass currently works. - assertEquals("function Car(){}Car.prototype.d=function(x){};" + - "var noo;noo.d(noo);noo.h=noo;noo.e=noo;", - compiler.toSource(module3)); + assertEquals( + "function Car(){}Car.prototype.d=function(z){};var noo;noo.d(noo);noo.h=noo;noo.e=noo;", + compiler.toSource(module3)); } public void testPropertyAffinityOff() { @@ -666,6 +669,7 @@ private Compiler compileModules(String externs, JSModule[] modules) { SourceFile externsInput = SourceFile.fromCode("externs", externs); CompilerOptions options = new CompilerOptions(); + options.setEmitUseStrict(false); options.setPropertyRenaming(PropertyRenamingPolicy.ALL_UNQUOTED); Compiler compiler = new Compiler(); diff --git a/test/com/google/javascript/jscomp/ReplaceCssNamesTest.java b/test/com/google/javascript/jscomp/ReplaceCssNamesTest.java index 886224efc98..0fe3b628912 100644 --- a/test/com/google/javascript/jscomp/ReplaceCssNamesTest.java +++ b/test/com/google/javascript/jscomp/ReplaceCssNamesTest.java @@ -302,6 +302,9 @@ public void testNonStringArgument() { public void testNoSymbolMapStripsCallAndDoesntIssueWarnings() { String input = "[goog.getCssName('test'), goog.getCssName(base, 'active')]"; Compiler compiler = new Compiler(); + CompilerOptions options = new CompilerOptions(); + options.setEmitUseStrict(false); + compiler.initOptions(options); ErrorManager errorMan = new BasicErrorManager() { @Override protected void printSummary() {} @Override public void println(CheckLevel level, JSError error) {} diff --git a/test/com/google/javascript/jscomp/RhinoErrorReporterTest.java b/test/com/google/javascript/jscomp/RhinoErrorReporterTest.java index 728dde62453..0634d623f15 100644 --- a/test/com/google/javascript/jscomp/RhinoErrorReporterTest.java +++ b/test/com/google/javascript/jscomp/RhinoErrorReporterTest.java @@ -18,6 +18,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; +import com.google.javascript.jscomp.CompilerOptions.LanguageMode; import java.util.Arrays; import java.util.List; import junit.framework.TestCase; @@ -154,6 +155,7 @@ private JSError assertWarning( private Compiler parseCode(String code) { Compiler compiler = new Compiler(); CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); if (!reportEs3Props) { options.setWarningLevel( diff --git a/test/com/google/javascript/jscomp/TemplateAstMatcherTest.java b/test/com/google/javascript/jscomp/TemplateAstMatcherTest.java index 502df3dc8bc..d01eae22965 100644 --- a/test/com/google/javascript/jscomp/TemplateAstMatcherTest.java +++ b/test/com/google/javascript/jscomp/TemplateAstMatcherTest.java @@ -17,6 +17,7 @@ package com.google.javascript.jscomp; import com.google.common.collect.ImmutableList; +import com.google.javascript.jscomp.CompilerOptions.LanguageMode; import com.google.javascript.rhino.Node; import junit.framework.TestCase; @@ -552,6 +553,7 @@ private TestNodePair compile(String externs, String template, String code) { Compiler compiler = lastCompiler = new Compiler(); compiler.disableThreads(); CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setCheckTypes(true); Node templateNode = compiler.parse(SourceFile.fromCode("template", template)); diff --git a/test/com/google/javascript/jscomp/TypeMatchingStrategyTest.java b/test/com/google/javascript/jscomp/TypeMatchingStrategyTest.java index 0b5f9ea4c1c..7ff5418b183 100644 --- a/test/com/google/javascript/jscomp/TypeMatchingStrategyTest.java +++ b/test/com/google/javascript/jscomp/TypeMatchingStrategyTest.java @@ -23,6 +23,7 @@ import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; +import com.google.javascript.jscomp.CompilerOptions.LanguageMode; import com.google.javascript.jscomp.TypeMatchingStrategy.MatchResult; import com.google.javascript.rhino.Node; import com.google.javascript.rhino.jstype.JSType; @@ -128,6 +129,7 @@ private static void assertMatch( Compiler compiler = new Compiler(); compiler.disableThreads(); CompilerOptions options = new CompilerOptions(); + options.setLanguageIn(LanguageMode.ECMASCRIPT3); options.setCheckTypes(true); compiler.compile(