Skip to content

Commit 0c34ece

Browse files
lauraharkercopybara-github
authored andcommitted
Delete methods accepting DiagnosticTypes in IntegrationTestCase
PiperOrigin-RevId: 321051603
1 parent e48c609 commit 0c34ece

File tree

5 files changed

+31
-71
lines changed

5 files changed

+31
-71
lines changed

src/com/google/javascript/jscomp/DiagnosticGroups.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ public static DiagnosticGroup forName(String name) {
148148
+ "missingReturn, "
149149
+ "missingSourcesWarnings, "
150150
+ "moduleLoad, "
151+
+ "moduleImports, "
151152
+ "msgDescriptions, "
152153
+ "nonStandardJsDocs, "
153154
+ "partialAlias, "
@@ -182,12 +183,19 @@ public static DiagnosticGroup forName(String name) {
182183
"featuresNotSupportedByPass", PhaseOptimizer.FEATURES_NOT_SUPPORTED_BY_PASS);
183184

184185
public static final DiagnosticGroup MODULE_LOAD =
185-
DiagnosticGroups.registerGroup("moduleLoad",
186+
DiagnosticGroups.registerGroup(
187+
"moduleLoad",
186188
ModuleLoader.LOAD_WARNING,
187189
ModuleMapCreator.MISSING_NAMESPACE_IMPORT,
188190
ProcessCommonJSModules.SUSPICIOUS_EXPORTS_ASSIGNMENT,
189191
ProcessCommonJSModules.UNKNOWN_REQUIRE_ENSURE);
190192

193+
public static final DiagnosticGroup MODULE_IMPORT =
194+
DiagnosticGroups.registerGroup( // undocumented
195+
"moduleImport",
196+
ModuleMapCreator.DOES_NOT_HAVE_EXPORT,
197+
ModuleMapCreator.DOES_NOT_HAVE_EXPORT_WITH_DETAILS);
198+
191199
public static final DiagnosticGroup GLOBAL_THIS =
192200
DiagnosticGroups.registerGroup("globalThis",
193201
CheckGlobalThis.GLOBAL_THIS);
@@ -714,6 +722,10 @@ public static DiagnosticGroup forName(String name) {
714722
public static final DiagnosticGroup INVALID_CONST_PARAM =
715723
DiagnosticGroups.registerUnsuppressibleGroup(ConstParamCheck.CONST_NOT_STRING_LITERAL_ERROR);
716724

725+
public static final DiagnosticGroup CANNOT_TRANSPILE_FEATURE =
726+
DiagnosticGroups.registerUnsuppressibleGroup(
727+
Es6ToEs3Util.CANNOT_CONVERT, Es6ToEs3Util.CANNOT_CONVERT_YET);
728+
717729
public static final DiagnosticGroup MISSING_POLYFILL =
718730
DiagnosticGroups.registerGroup(
719731
"missingPolyfill", RewritePolyfills.INSUFFICIENT_OUTPUT_VERSION_ERROR);

test/com/google/javascript/jscomp/integration/AdvancedOptimizationsIntegrationTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@
3636
import com.google.javascript.jscomp.DiagnosticGroup;
3737
import com.google.javascript.jscomp.DiagnosticGroupWarningsGuard;
3838
import com.google.javascript.jscomp.DiagnosticGroups;
39-
import com.google.javascript.jscomp.Es6ToEs3Util;
4039
import com.google.javascript.jscomp.GoogleCodingConvention;
4140
import com.google.javascript.jscomp.PropertyRenamingPolicy;
4241
import com.google.javascript.jscomp.SourceFile;
43-
import com.google.javascript.jscomp.TypeCheck;
4442
import com.google.javascript.jscomp.VariableRenamingPolicy;
4543
import com.google.javascript.jscomp.WarningLevel;
4644
import com.google.javascript.jscomp.testing.NoninjectingCompiler;
@@ -417,7 +415,7 @@ public void testBug139862607() {
417415
options,
418416
new String[] {lines("var x = 1;"), lines("import * as y from './i0.js';", "const z = y.x")},
419417
// Property x never defined on module$i0
420-
TypeCheck.INEXISTENT_PROPERTY);
418+
DiagnosticGroups.MISSING_PROPERTIES);
421419
}
422420

423421
@Test
@@ -1851,7 +1849,7 @@ public void testImportMeta() {
18511849
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
18521850
options.setLanguage(LanguageMode.ECMASCRIPT_NEXT);
18531851

1854-
test(options, "import.meta", Es6ToEs3Util.CANNOT_CONVERT);
1852+
test(options, "import.meta", DiagnosticGroups.CANNOT_TRANSPILE_FEATURE);
18551853
}
18561854

18571855
@Test

test/com/google/javascript/jscomp/integration/CommonJSIntegrationTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.google.javascript.jscomp.GoogleCodingConvention;
2424
import com.google.javascript.jscomp.WarningLevel;
2525
import com.google.javascript.jscomp.deps.ModuleLoader;
26-
import com.google.javascript.jscomp.modules.ModuleMapCreator;
2726
import org.junit.Ignore;
2827
import org.junit.Test;
2928
import org.junit.runner.RunWith;
@@ -391,7 +390,7 @@ public void testEsModuleImportNonDefaultFromCJS() {
391390
"module.exports = {foo: 1, bar: function() { return 'bar'; }};",
392391
"import {foo} from './i0';"
393392
},
394-
ModuleMapCreator.DOES_NOT_HAVE_EXPORT);
393+
DiagnosticGroups.MODULE_IMPORT);
395394
}
396395

397396
@Test

test/com/google/javascript/jscomp/integration/IntegrationTest.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,11 @@
3939
import com.google.javascript.jscomp.CompilerPass;
4040
import com.google.javascript.jscomp.CrossChunkMethodMotion;
4141
import com.google.javascript.jscomp.CustomPassExecutionTime;
42+
import com.google.javascript.jscomp.DiagnosticGroup;
4243
import com.google.javascript.jscomp.DiagnosticGroupWarningsGuard;
4344
import com.google.javascript.jscomp.DiagnosticGroups;
44-
import com.google.javascript.jscomp.DiagnosticType;
4545
import com.google.javascript.jscomp.EmptyMessageBundle;
46-
import com.google.javascript.jscomp.Es6ToEs3Util;
4746
import com.google.javascript.jscomp.GoogleCodingConvention;
48-
import com.google.javascript.jscomp.MarkUntranspilableFeaturesAsRemoved;
49-
import com.google.javascript.jscomp.PropertyRenamingDiagnostics;
5047
import com.google.javascript.jscomp.PropertyRenamingPolicy;
5148
import com.google.javascript.jscomp.RenamingMap;
5249
import com.google.javascript.jscomp.SourceFile;
@@ -1355,7 +1352,7 @@ public void testDisambiguatePropertiesWithPropertyInvalidationError() {
13551352
"Foo.prototype.a = function(x) {};",
13561353
"function Bar(){}",
13571354
"Bar.prototype.a=function(x){};"),
1358-
PropertyRenamingDiagnostics.INVALIDATION);
1355+
DiagnosticGroups.TYPE_INVALIDATION);
13591356
}
13601357

13611358
@Test
@@ -3777,9 +3774,18 @@ public void testGithubIssue2874() {
37773774
public void testDestructuringCannotConvert() {
37783775
CompilerOptions options = createCompilerOptions();
37793776

3780-
test(options, "for (var [x] = [], {y} = {}, z = 2;;) {}", Es6ToEs3Util.CANNOT_CONVERT_YET);
3781-
test(options, "for (let [x] = [], {y} = {}, z = 2;;) {}", Es6ToEs3Util.CANNOT_CONVERT_YET);
3782-
test(options, "for (const [x] = [], {y} = {}, z = 2;;) {}", Es6ToEs3Util.CANNOT_CONVERT_YET);
3777+
test(
3778+
options,
3779+
"for (var [x] = [], {y} = {}, z = 2;;) {}",
3780+
DiagnosticGroups.CANNOT_TRANSPILE_FEATURE);
3781+
test(
3782+
options,
3783+
"for (let [x] = [], {y} = {}, z = 2;;) {}",
3784+
DiagnosticGroups.CANNOT_TRANSPILE_FEATURE);
3785+
test(
3786+
options,
3787+
"for (const [x] = [], {y} = {}, z = 2;;) {}",
3788+
DiagnosticGroups.CANNOT_TRANSPILE_FEATURE);
37833789
}
37843790

37853791
@Test
@@ -4224,8 +4230,7 @@ public void testBrowserFeaturesetYear2020() {
42244230
+ "const {foo,...bar}={foo:10,bar:20,...{baz:30}};console.log(foo);console.log(bar)");
42254231

42264232
// But we won't emit ES 2018 regexp features.
4227-
DiagnosticType untranspilable =
4228-
MarkUntranspilableFeaturesAsRemoved.UNTRANSPILABLE_FEATURE_PRESENT;
4233+
DiagnosticGroup untranspilable = DiagnosticGroups.UNSTRANSPILABLE_FEATURES;
42294234
test(options, lines(googDefine, "/foo/s"), untranspilable);
42304235
test(options, lines(googDefine, "/(?<foo>.)/"), untranspilable);
42314236
test(options, lines(googDefine, "/(?<=foo)/"), untranspilable);

test/com/google/javascript/jscomp/integration/IntegrationTestCase.java

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import static com.google.common.truth.Truth.assertThat;
2020
import static com.google.common.truth.Truth.assertWithMessage;
21-
import static com.google.javascript.jscomp.testing.JSErrorSubject.assertError;
2221
import static com.google.javascript.rhino.testing.NodeSubject.assertNode;
2322

2423
import com.google.common.base.Joiner;
@@ -205,15 +204,11 @@ protected void test(CompilerOptions options,
205204
}
206205
}
207206

208-
// TODO(lharker): delete all the methods checking for a DiagnosticType after migrating existing
209-
// usages.
210207
/** Asserts that when compiling with the given compiler options, there is an error or warning. */
211208
protected void test(CompilerOptions options, String original, DiagnosticGroup warning) {
212209
test(options, new String[] {original}, null, warning);
213210
}
214211

215-
// TODO(lharker): delete all the methods checking for a DiagnosticType after migrating existing
216-
// usages.
217212
/** Asserts that when compiling with the given compiler options, there is an error or warning. */
218213
protected void test(
219214
CompilerOptions options, String original, String compiled, DiagnosticGroup warning) {
@@ -225,55 +220,6 @@ protected void test(CompilerOptions options, String[] original, DiagnosticGroup
225220
test(options, original, null, warning);
226221
}
227222

228-
/**
229-
* Asserts that when compiling with the given compiler options, there is an error or warning.
230-
*
231-
* @deprecated prefer to check for the corresponding DiagnosticGroup
232-
*/
233-
@Deprecated
234-
protected void test(CompilerOptions options, String original, DiagnosticType warning) {
235-
test(options, new String[] {original}, warning);
236-
}
237-
238-
/** @deprecated prefer to check for the corresponding DiagnosticGroup */
239-
@Deprecated
240-
protected void test(
241-
CompilerOptions options, String original, String compiled, DiagnosticType warning) {
242-
test(options, new String[] {original}, new String[] {compiled}, warning);
243-
}
244-
245-
/** @deprecated prefer to check for the corresponding DiagnosticGroup */
246-
@Deprecated
247-
protected void test(CompilerOptions options, String[] original, DiagnosticType warning) {
248-
test(options, original, null, warning);
249-
}
250-
251-
/**
252-
* Asserts that when compiling with the given compiler options, there is an error or warning.
253-
*
254-
* @deprecated prefer to check for the corresponding DiagnosticGroup
255-
*/
256-
@Deprecated
257-
protected void test(
258-
CompilerOptions options, String[] original, String[] compiled, DiagnosticType warning) {
259-
Compiler compiler = compile(options, original);
260-
checkUnexpectedErrorsOrWarnings(compiler, 1);
261-
assertWithMessage("Expected exactly one warning or error")
262-
.that(compiler.getErrors().size() + compiler.getWarnings().size())
263-
.isEqualTo(1);
264-
if (!compiler.getErrors().isEmpty()) {
265-
assertError(compiler.getErrors().get(0)).hasType(warning);
266-
} else {
267-
assertError(compiler.getWarnings().get(0)).hasType(warning);
268-
}
269-
270-
if (compiled != null) {
271-
Node root = compiler.getRoot().getLastChild();
272-
Node expectedRoot = parseExpectedCode(compiled, options);
273-
assertNode(root).usingSerializer(compiler::toSource).isEqualTo(expectedRoot);
274-
}
275-
}
276-
277223
/** Asserts that when compiling with the given compiler options, there is an error or warning. */
278224
protected void test(
279225
CompilerOptions options, String[] original, String[] compiled, DiagnosticGroup[] warnings) {

0 commit comments

Comments
 (0)