From cdaddb77e08baccf1158564701df0a02d339e908 Mon Sep 17 00:00:00 2001 From: nickreid Date: Fri, 26 Oct 2018 10:07:09 -0700 Subject: [PATCH] Disinherit "tests/com/google/javascript/jscomp/....java" from `TestCase`. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=218870829 --- .../javascript/jscomp/AstFactoryTest.java | 5 +--- .../jscomp/BaseReplaceScriptTestCase.java | 5 +--- .../javascript/jscomp/ChangeVerifierTest.java | 6 ++--- .../jscomp/CheckPathsBetweenNodesTest.java | 3 +-- .../javascript/jscomp/CleanupPassesTest.java | 3 +-- .../jscomp/ClosureCodingConventionTest.java | 3 +-- .../jscomp/CodePrinterEs6TypedTest.java | 9 +++++-- .../javascript/jscomp/CodePrinterTest.java | 26 +++++++++++-------- .../jscomp/CodePrinterTestBase.java | 5 +--- 9 files changed, 31 insertions(+), 34 deletions(-) diff --git a/test/com/google/javascript/jscomp/AstFactoryTest.java b/test/com/google/javascript/jscomp/AstFactoryTest.java index d416beefc7b..685a9863026 100644 --- a/test/com/google/javascript/jscomp/AstFactoryTest.java +++ b/test/com/google/javascript/jscomp/AstFactoryTest.java @@ -31,22 +31,19 @@ import com.google.javascript.rhino.jstype.JSTypeNative; import com.google.javascript.rhino.jstype.JSTypeRegistry; import com.google.javascript.rhino.jstype.ObjectType; -import junit.framework.TestCase; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @RunWith(JUnit4.class) -public class AstFactoryTest extends TestCase { +public class AstFactoryTest { private static final Joiner LINE_JOINER = Joiner.on('\n'); private Compiler compiler; - @Override @Before public void setUp() throws Exception { - super.setUp(); compiler = new Compiler(); } diff --git a/test/com/google/javascript/jscomp/BaseReplaceScriptTestCase.java b/test/com/google/javascript/jscomp/BaseReplaceScriptTestCase.java index a1a13ef1748..37af5b9c2a9 100644 --- a/test/com/google/javascript/jscomp/BaseReplaceScriptTestCase.java +++ b/test/com/google/javascript/jscomp/BaseReplaceScriptTestCase.java @@ -26,10 +26,9 @@ import java.util.ArrayList; import java.util.List; import java.util.logging.Level; -import junit.framework.TestCase; import org.junit.Before; -public abstract class BaseReplaceScriptTestCase extends TestCase { +public abstract class BaseReplaceScriptTestCase { protected static final Joiner LINE_JOINER = Joiner.on('\n'); protected static final String CLOSURE_BASE = @@ -57,10 +56,8 @@ public abstract class BaseReplaceScriptTestCase extends TestCase { */ protected ImmutableList testExterns = EXTVAR_EXTERNS; - @Override @Before public void setUp() throws Exception { - super.setUp(); testExterns = EXTVAR_EXTERNS; } diff --git a/test/com/google/javascript/jscomp/ChangeVerifierTest.java b/test/com/google/javascript/jscomp/ChangeVerifierTest.java index 67adb5780bc..58ef321afca 100644 --- a/test/com/google/javascript/jscomp/ChangeVerifierTest.java +++ b/test/com/google/javascript/jscomp/ChangeVerifierTest.java @@ -22,13 +22,12 @@ import com.google.javascript.rhino.IR; import com.google.javascript.rhino.Node; -import junit.framework.TestCase; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @RunWith(JUnit4.class) -public final class ChangeVerifierTest extends TestCase { +public final class ChangeVerifierTest { @Test public void testCorrectValidationOfScriptWithChangeAfterFunction() { @@ -131,7 +130,8 @@ public void testNotDeletedFunction() { } } - public static void testChangeVerification() { + @Test + public void testChangeVerification() { Compiler compiler = new Compiler(); Node mainScript = IR.script(); diff --git a/test/com/google/javascript/jscomp/CheckPathsBetweenNodesTest.java b/test/com/google/javascript/jscomp/CheckPathsBetweenNodesTest.java index b77d52debbd..ab0854fe1d0 100644 --- a/test/com/google/javascript/jscomp/CheckPathsBetweenNodesTest.java +++ b/test/com/google/javascript/jscomp/CheckPathsBetweenNodesTest.java @@ -23,7 +23,6 @@ import com.google.javascript.jscomp.graph.DiGraph; import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; import com.google.javascript.jscomp.graph.LinkedDirectedGraph; -import junit.framework.TestCase; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -33,7 +32,7 @@ * */ @RunWith(JUnit4.class) -public final class CheckPathsBetweenNodesTest extends TestCase { +public final class CheckPathsBetweenNodesTest { /** * Predicate satisfied by strings with a given prefix. diff --git a/test/com/google/javascript/jscomp/CleanupPassesTest.java b/test/com/google/javascript/jscomp/CleanupPassesTest.java index 1b7c90e9a15..a420ea88291 100644 --- a/test/com/google/javascript/jscomp/CleanupPassesTest.java +++ b/test/com/google/javascript/jscomp/CleanupPassesTest.java @@ -19,14 +19,13 @@ import static com.google.common.truth.Truth.assertWithMessage; import java.util.List; -import junit.framework.TestCase; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; /** @author tylerg@google.com (Tyler Goodwin) */ @RunWith(JUnit4.class) -public final class CleanupPassesTest extends TestCase { +public final class CleanupPassesTest { private final AbstractCompiler compiler = new Compiler(); private final CompilerOptions options = new CompilerOptions(); diff --git a/test/com/google/javascript/jscomp/ClosureCodingConventionTest.java b/test/com/google/javascript/jscomp/ClosureCodingConventionTest.java index 941f21a623e..aa1083d8753 100644 --- a/test/com/google/javascript/jscomp/ClosureCodingConventionTest.java +++ b/test/com/google/javascript/jscomp/ClosureCodingConventionTest.java @@ -25,14 +25,13 @@ import com.google.javascript.rhino.jstype.FunctionType; import com.google.javascript.rhino.jstype.JSTypeRegistry; import com.google.javascript.rhino.jstype.NominalTypeBuilderOti; -import junit.framework.TestCase; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; /** Test class for {@link GoogleCodingConvention}. */ @RunWith(JUnit4.class) -public final class ClosureCodingConventionTest extends TestCase { +public final class ClosureCodingConventionTest { private final ClosureCodingConvention conv = new ClosureCodingConvention(); @Test diff --git a/test/com/google/javascript/jscomp/CodePrinterEs6TypedTest.java b/test/com/google/javascript/jscomp/CodePrinterEs6TypedTest.java index 7ef4eb50a45..f767067a3b2 100644 --- a/test/com/google/javascript/jscomp/CodePrinterEs6TypedTest.java +++ b/test/com/google/javascript/jscomp/CodePrinterEs6TypedTest.java @@ -19,6 +19,7 @@ import com.google.javascript.jscomp.CompilerOptions.LanguageMode; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -72,7 +73,9 @@ public void testFunctionParamDeclaration_defaultValue() { assertPrettyPrintSame("function foo(x: string = 'hello') {\n}"); } - public void disabled_testFunctionParamDeclaration_arrow() { + @Test + @Ignore + public void testFunctionParamDeclaration_arrow() { assertPrettyPrintSame("(x: string) => 'hello' + x;"); } @@ -81,7 +84,9 @@ public void testFunctionReturn() { assertPrettyPrintSame("function foo(): string {\n return 'hello';\n}"); } - public void disabled_testFunctionReturn_arrow() { + @Test + @Ignore + public void testFunctionReturn_arrow() { assertPrettyPrintSame("(): string => 'hello';"); } diff --git a/test/com/google/javascript/jscomp/CodePrinterTest.java b/test/com/google/javascript/jscomp/CodePrinterTest.java index 2cf4d006730..1ad5906069e 100644 --- a/test/com/google/javascript/jscomp/CodePrinterTest.java +++ b/test/com/google/javascript/jscomp/CodePrinterTest.java @@ -1793,20 +1793,24 @@ void setOptions(CompilerOptions options) { } private void assertTypeAnnotations(String js, String expected) { - assertEquals( - expected, + String actual = new CodePrinter.Builder(parse(js, /* typeChecked= */ true)) - .setCompilerOptions(newCompilerOptions(new CompilerOptionBuilder() { - @Override - void setOptions(CompilerOptions options) { - options.setPrettyPrint(true); - options.setLineBreak(false); - options.setLineLengthThreshold(CompilerOptions.DEFAULT_LINE_LENGTH_THRESHOLD); - } - })) + .setCompilerOptions( + newCompilerOptions( + new CompilerOptionBuilder() { + @Override + void setOptions(CompilerOptions options) { + options.setPrettyPrint(true); + options.setLineBreak(false); + options.setLineLengthThreshold( + CompilerOptions.DEFAULT_LINE_LENGTH_THRESHOLD); + } + })) .setOutputTypes(true) .setTypeRegistry(lastCompiler.getTypeRegistry()) - .build()); + .build(); + + assertThat(actual).isEqualTo(expected); } @Test diff --git a/test/com/google/javascript/jscomp/CodePrinterTestBase.java b/test/com/google/javascript/jscomp/CodePrinterTestBase.java index 00c9cc2109e..d16eb515759 100644 --- a/test/com/google/javascript/jscomp/CodePrinterTestBase.java +++ b/test/com/google/javascript/jscomp/CodePrinterTestBase.java @@ -21,11 +21,10 @@ import com.google.common.collect.ImmutableList; import com.google.javascript.jscomp.CompilerOptions.LanguageMode; import com.google.javascript.rhino.Node; -import junit.framework.TestCase; import org.junit.Before; /** Base class for tests that exercise {@link CodePrinter}. */ -public abstract class CodePrinterTestBase extends TestCase { +public abstract class CodePrinterTestBase { // If this is set, ignore parse warnings and only fail the test // for parse errors. protected boolean allowWarnings = false; @@ -34,10 +33,8 @@ public abstract class CodePrinterTestBase extends TestCase { protected LanguageMode languageMode = LanguageMode.ECMASCRIPT5; protected Compiler lastCompiler = null; - @Override @Before public void setUp() throws Exception { - super.setUp(); allowWarnings = false; preserveTypeAnnotations = false; trustedStrings = true;