Skip to content

Commit

Permalink
Clean up CompilerTestCase.
Browse files Browse the repository at this point in the history
1. Make all fields private.
2. Remove dead parameters from setters.
3. Ensure subclasses all call super.setUp().
4. Move a bunch of initialization from constructor into setUp().
5. Make it an error to initialize subclasses before setUp().

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=158091476
  • Loading branch information
shicks authored and brad4d committed Jun 6, 2017
1 parent 8b406d6 commit 05b267d
Show file tree
Hide file tree
Showing 129 changed files with 786 additions and 696 deletions.
Expand Up @@ -41,7 +41,8 @@ protected CompilerPass getProcessor(Compiler compiler) {
}

@Override
public void setUp() {
protected void setUp() throws Exception {
super.setUp();
enableNormalize();
}

Expand Down Expand Up @@ -450,8 +451,6 @@ public void testGlobalWriteToNonAncestor() {
}

public void testInlineCtorInObjLit() {
compareJsDoc = true;

test(
LINE_JOINER.join("function Foo() {}", "var Bar = Foo;", "var objlit = { 'prop' : Bar };"),
LINE_JOINER.join("function Foo() {}", "var Bar = null;", "var objlit = { 'prop': Foo };"));
Expand Down
Expand Up @@ -39,6 +39,11 @@ public final class AmbiguatePropertiesTest extends CompilerTestCase {

public AmbiguatePropertiesTest() {
super(EXTERNS);
}

@Override
protected void setUp() throws Exception {
super.setUp();
enableNormalize();
enableTypeCheck();
enableClosurePass();
Expand Down
3 changes: 2 additions & 1 deletion test/com/google/javascript/jscomp/AngularPassTest.java
Expand Up @@ -24,7 +24,8 @@
public final class AngularPassTest extends CompilerTestCase {

@Override
public void setUp() {
protected void setUp() throws Exception {
super.setUp();
setAcceptedLanguage(LanguageMode.ECMASCRIPT_2017);
}

Expand Down
6 changes: 3 additions & 3 deletions test/com/google/javascript/jscomp/AstValidatorTest.java
Expand Up @@ -53,10 +53,10 @@ protected int getNumRepetitions() {

@Override
protected void setUp() throws Exception {
super.enableAstValidation(false);
super.disableNormalize();
super.enableLineNumberCheck(false);
super.setUp();
disableAstValidation();
disableNormalize();
disableLineNumberCheck();
}

public void testForIn() {
Expand Down
Expand Up @@ -31,9 +31,14 @@ public final class CheckAccessControlsPolymerTest extends TypeICompilerTestCase

public CheckAccessControlsPolymerTest() {
super(EXTERNS);
parseTypeInfo = true;
}

@Override
protected void setUp() throws Exception {
super.setUp();
enableParseTypeInfo();
enablePolymerPass();
allowExternsChanges(true);
allowExternsChanges();
}

@Override
Expand Down
Expand Up @@ -55,7 +55,12 @@ public final class CheckAccessControlsTest extends TypeICompilerTestCase {

public CheckAccessControlsTest() {
super(CompilerTypeTestCase.DEFAULT_EXTERNS);
parseTypeInfo = true;
}

@Override
protected void setUp() throws Exception {
super.setUp();
enableParseTypeInfo();
enableClosurePass();
enableRewriteClosureCode();
}
Expand Down
14 changes: 7 additions & 7 deletions test/com/google/javascript/jscomp/CheckConformanceTest.java
Expand Up @@ -70,18 +70,18 @@ public final class CheckConformanceTest extends TypeICompilerTestCase {
"}");

public CheckConformanceTest() {
super(EXTERNS, true);
enableTranspile();
enableClosurePass();
enableClosurePassForExpected();
enableRewriteClosureCode();
setLanguage(LanguageMode.ECMASCRIPT_2015, LanguageMode.ECMASCRIPT5_STRICT);
super(EXTERNS);
}

@Override
protected void setUp() throws Exception {
super.setUp();
super.enableClosurePass();
enableTranspile();
enableClosurePass();
enableClosurePassForExpected();
enableRewriteClosureCode();
setLanguage(LanguageMode.ECMASCRIPT_2015, LanguageMode.ECMASCRIPT5_STRICT);
enableClosurePass();
configuration = DEFAULT_CONFORMANCE;
ignoreWarnings(DiagnosticGroups.MISSING_PROPERTIES);
}
Expand Down
3 changes: 2 additions & 1 deletion test/com/google/javascript/jscomp/CheckGlobalNamesTest.java
Expand Up @@ -66,7 +66,8 @@ public void process(Node externs, Node js) {
}

@Override
public void setUp() {
protected void setUp() throws Exception {
super.setUp();
injectNamespace = false;
setAcceptedLanguage(LanguageMode.ECMASCRIPT_2015);
}
Expand Down
7 changes: 5 additions & 2 deletions test/com/google/javascript/jscomp/CheckGlobalThisTest.java
Expand Up @@ -22,8 +22,11 @@
* Tests {@link CheckGlobalThis}.
*/
public final class CheckGlobalThisTest extends CompilerTestCase {
public CheckGlobalThisTest() {
this.parseTypeInfo = true;

@Override
protected void setUp() throws Exception {
super.setUp();
enableParseTypeInfo();
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion test/com/google/javascript/jscomp/CheckJsDocTest.java
Expand Up @@ -41,7 +41,8 @@ protected CompilerPass getProcessor(final Compiler compiler) {
}

@Override
public void setUp() {
protected void setUp() throws Exception {
super.setUp();
setAcceptedLanguage(LanguageMode.ECMASCRIPT_2017);
}

Expand Down
Expand Up @@ -30,7 +30,8 @@ protected CompilerPass getProcessor(final Compiler compiler) {
}

@Override
public void setUp() {
protected void setUp() throws Exception {
super.setUp();
setAcceptedLanguage(LanguageMode.ECMASCRIPT_2017);
}

Expand Down
Expand Up @@ -24,7 +24,9 @@
*/
public final class CheckMissingReturnTest extends CompilerTestCase {

public CheckMissingReturnTest() {
@Override
protected void setUp() throws Exception {
super.setUp();
enableTypeCheck();
}

Expand Down
3 changes: 2 additions & 1 deletion test/com/google/javascript/jscomp/CheckMissingSuperTest.java
Expand Up @@ -27,7 +27,8 @@ protected CompilerPass getProcessor(Compiler compiler) {
}

@Override
public void setUp() {
protected void setUp() throws Exception {
super.setUp();
setAcceptedLanguage(LanguageMode.ECMASCRIPT_2017);
}

Expand Down
3 changes: 2 additions & 1 deletion test/com/google/javascript/jscomp/CheckProvidesTest.java
Expand Up @@ -25,7 +25,8 @@
*/
public final class CheckProvidesTest extends CompilerTestCase {
@Override
public void setUp() {
protected void setUp() throws Exception {
super.setUp();
setAcceptedLanguage(LanguageMode.ECMASCRIPT_2017);
}

Expand Down
2 changes: 1 addition & 1 deletion test/com/google/javascript/jscomp/CheckRegExpTest.java
Expand Up @@ -25,7 +25,7 @@ public final class CheckRegExpTest extends CompilerTestCase {
CheckRegExp last = null;

public CheckRegExpTest() {
super("var RegExp;", true);
super("var RegExp;");
}

@Override
Expand Down
8 changes: 3 additions & 5 deletions test/com/google/javascript/jscomp/CheckSideEffectsTest.java
Expand Up @@ -19,15 +19,13 @@
import com.google.javascript.jscomp.CompilerOptions.LanguageMode;

public final class CheckSideEffectsTest extends CompilerTestCase {
public CheckSideEffectsTest() {
this.parseTypeInfo = true;
allowExternsChanges(true);
}

@Override
public void setUp() throws Exception {
protected void setUp() throws Exception {
super.setUp();
setAcceptedLanguage(LanguageMode.ECMASCRIPT_2017);
enableParseTypeInfo();
allowExternsChanges();
}

@Override
Expand Down
Expand Up @@ -22,9 +22,6 @@
* Tests for CheckSuspiciousCode
*/
public final class CheckSuspiciousCodeTest extends CompilerTestCase {
public CheckSuspiciousCodeTest() {
this.parseTypeInfo = true;
}

@Override
protected CompilerPass getProcessor(Compiler compiler) {
Expand All @@ -33,8 +30,10 @@ protected CompilerPass getProcessor(Compiler compiler) {
}

@Override
public void setUp() {
protected void setUp() throws Exception {
super.setUp();
setAcceptedLanguage(LanguageMode.ECMASCRIPT_2017);
enableParseTypeInfo();
}

@Override
Expand Down
Expand Up @@ -17,7 +17,6 @@
package com.google.javascript.jscomp;

import com.google.javascript.rhino.Node;
import java.io.IOException;

/**
* Tests for the "Too many template parameters" warning. Ideally this would be part of
Expand All @@ -26,7 +25,8 @@
*/
public final class CheckTemplateParamsTest extends CompilerTestCase {
@Override
public void setUp() throws IOException {
protected void setUp() throws Exception {
super.setUp();
enableTypeCheck();
}

Expand Down
Expand Up @@ -30,7 +30,8 @@ protected CompilerPass getProcessor(Compiler compiler) {
}

@Override
public void setUp() {
public void setUp() throws Exception {
super.setUp();
setAcceptedLanguage(LanguageMode.ECMASCRIPT_2017);
}

Expand Down
Expand Up @@ -34,13 +34,13 @@ public final class CheckUnusedPrivatePropertiesInPolymerElementTest

public CheckUnusedPrivatePropertiesInPolymerElementTest() {
super(EXTERNS);
enableGatherExternProperties();
setAcceptedLanguage(LanguageMode.ECMASCRIPT_NEXT);
}

@Override
protected void setUp() throws Exception {
super.setUp();
enableGatherExternProperties();
setAcceptedLanguage(LanguageMode.ECMASCRIPT_NEXT);
}

@Override
Expand Down Expand Up @@ -71,7 +71,7 @@ protected int getNumRepetitions() {
}

public void testPolymerPropertyUsedAsObserver1() {
allowExternsChanges(true);
allowExternsChanges();
testNoWarning(
LINE_JOINER.join(
"Polymer({",
Expand All @@ -89,7 +89,7 @@ public void testPolymerPropertyUsedAsObserver1() {
}

public void testPolymerPropertyUsedAsObserver2() {
allowExternsChanges(true);
allowExternsChanges();
testNoWarning(
LINE_JOINER.join(
"Polymer({",
Expand All @@ -107,7 +107,7 @@ public void testPolymerPropertyUsedAsObserver2() {
}

public void testBehaviorPropertyUsedAsObserver() {
allowExternsChanges(true);
allowExternsChanges();
test(
new String[] {
LINE_JOINER.join(
Expand Down
Expand Up @@ -40,6 +40,11 @@ public final class CheckUnusedPrivatePropertiesTest extends TypeICompilerTestCas

public CheckUnusedPrivatePropertiesTest() {
super(EXTERNS);
}

@Override
protected void setUp() throws Exception {
super.setUp();
enableGatherExternProperties();
setAcceptedLanguage(LanguageMode.ECMASCRIPT_2015);
}
Expand Down
Expand Up @@ -42,7 +42,8 @@ protected CompilerPass getProcessor(Compiler compiler) {
}

@Override
public void setUp() {
protected void setUp() throws Exception {
super.setUp();
setLanguage(LanguageMode.ECMASCRIPT_NEXT, LanguageMode.ECMASCRIPT_NEXT);
}

Expand Down
Expand Up @@ -54,8 +54,7 @@ protected CompilerPass getProcessor(Compiler compiler) {
protected void setUp() throws Exception {
super.setUp();
disableTypeCheck();
runTypeCheckAfterProcessing = true;
compareJsDoc = true;
enableRunTypeCheckAfterProcessing();
}

@Override
Expand Down
Expand Up @@ -51,7 +51,8 @@ protected int getNumRepetitions() {
}

@Override
public void setUp() {
protected void setUp() throws Exception {
super.setUp();
setAcceptedLanguage(LanguageMode.ECMASCRIPT_2017);
}

Expand Down Expand Up @@ -104,7 +105,7 @@ public void testBasic3() {
}

public void testIjsModule() {
allowExternsChanges(true);
allowExternsChanges();
test(
// .i.js file
"goog.module('external'); /** @constructor */ exports = function() {};",
Expand Down Expand Up @@ -2129,7 +2130,7 @@ public void testMultiplyExportedSymbolDoesntCrash() {
}

public void testIjsFileInExterns() {
allowExternsChanges(true);
allowExternsChanges();
test(
LINE_JOINER.join(
"/** @externs */",
Expand Down
Expand Up @@ -34,7 +34,8 @@ protected int getNumRepetitions() {
}

@Override
public void setUp() {
protected void setUp() throws Exception {
super.setUp();
usePseudoName = false;
}

Expand Down
Expand Up @@ -28,7 +28,7 @@
public final class CodePrinterEs6TypedTest extends CodePrinterTestBase {

@Override
public void setUp() {
protected void setUp() throws Exception {
super.setUp();
languageMode = LanguageMode.ECMASCRIPT6_TYPED;
}
Expand Down
4 changes: 3 additions & 1 deletion test/com/google/javascript/jscomp/CodePrinterTestBase.java
Expand Up @@ -32,7 +32,9 @@ public abstract class CodePrinterTestBase extends TestCase {
protected LanguageMode languageMode = LanguageMode.ECMASCRIPT5;
protected Compiler lastCompiler = null;

@Override public void setUp() {
@Override
protected void setUp() throws Exception {
super.setUp();
allowWarnings = false;
preserveTypeAnnotations = false;
trustedStrings = true;
Expand Down

0 comments on commit 05b267d

Please sign in to comment.