Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Unified Diff: pkg/analyzer/test/src/command_line/arguments_test.dart

Issue 2976963002: Add --no-declaration-casts option to analyzer. (Closed)
Patch Set: Fix comment Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/task/strong/checker.dart ('k') | pkg/analyzer/test/src/context/builder_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/command_line/arguments_test.dart
diff --git a/pkg/analyzer/test/src/command_line/arguments_test.dart b/pkg/analyzer/test/src/command_line/arguments_test.dart
index e60bff20f331290aeffbf2c89646197a01767109..e2e9131a697d97667c8369547227fedf39379465 100644
--- a/pkg/analyzer/test/src/command_line/arguments_test.dart
+++ b/pkg/analyzer/test/src/command_line/arguments_test.dart
@@ -35,6 +35,7 @@ class ArgumentsTest {
'-Dfoo=1',
'-Dbar=2',
'--enable-strict-call-checks',
+ '--no-declaration-casts',
'--no-implicit-casts',
'--no-implicit-dynamic',
'--options=$defaultAnalysisOptionsFilePath',
@@ -59,6 +60,7 @@ class ArgumentsTest {
expect(defaultOptions, isNotNull);
expect(defaultOptions.enableStrictCallChecks, true);
expect(defaultOptions.strongMode, true);
+ expect(defaultOptions.declarationCasts, false);
expect(defaultOptions.implicitCasts, false);
expect(defaultOptions.implicitDynamic, false);
}
@@ -80,6 +82,7 @@ class ArgumentsTest {
expect(defaultOptions, isNotNull);
expect(defaultOptions.enableStrictCallChecks, false);
expect(defaultOptions.strongMode, false);
+ expect(defaultOptions.declarationCasts, true);
expect(defaultOptions.implicitCasts, true);
expect(defaultOptions.implicitDynamic, true);
}
@@ -134,10 +137,27 @@ class ArgumentsTest {
expect(manager.canUseSummaries, true);
}
+ void test_declarationCast_noImplicitCast() {
+ MemoryResourceProvider provider = new MemoryResourceProvider();
+ ArgParser parser = new ArgParser();
+ defineAnalysisArguments(parser);
+ List<String> args = [
+ '--declaration-casts',
+ '--no-implicit-casts',
+ ];
+ ArgResults result = parse(provider, parser, args);
+ ContextBuilderOptions options = createContextBuilderOptions(result);
+ expect(options, isNotNull);
+ AnalysisOptionsImpl defaultOptions = options.defaultOptions;
+ expect(defaultOptions, isNotNull);
+ expect(defaultOptions.declarationCasts, true);
+ expect(defaultOptions.implicitCasts, false);
+ }
+
void test_defineAnalysisArguments() {
ArgParser parser = new ArgParser();
defineAnalysisArguments(parser);
- expect(parser.options, hasLength(14));
+ expect(parser.options, hasLength(15));
}
void test_extractDefinedVariables() {
@@ -166,6 +186,55 @@ class ArgumentsTest {
expect(result, orderedEquals(['--a', '--c=0', '-e=2', '-f', 'bar']));
}
+ void test_noAssignmentCast() {
+ MemoryResourceProvider provider = new MemoryResourceProvider();
+ ArgParser parser = new ArgParser();
+ defineAnalysisArguments(parser);
+ List<String> args = [
+ '--no-declaration-casts',
+ ];
+ ArgResults result = parse(provider, parser, args);
+ ContextBuilderOptions options = createContextBuilderOptions(result);
+ expect(options, isNotNull);
+ AnalysisOptionsImpl defaultOptions = options.defaultOptions;
+ expect(defaultOptions, isNotNull);
+ expect(defaultOptions.declarationCasts, false);
+ expect(defaultOptions.implicitCasts, true);
+ }
+
+ void test_noAssignmentCast_implicitCast() {
+ MemoryResourceProvider provider = new MemoryResourceProvider();
+ ArgParser parser = new ArgParser();
+ defineAnalysisArguments(parser);
+ List<String> args = [
+ '--no-declaration-casts',
+ '--implicit-casts',
+ ];
+ ArgResults result = parse(provider, parser, args);
+ ContextBuilderOptions options = createContextBuilderOptions(result);
+ expect(options, isNotNull);
+ AnalysisOptionsImpl defaultOptions = options.defaultOptions;
+ expect(defaultOptions, isNotNull);
+ expect(defaultOptions.declarationCasts, false);
+ expect(defaultOptions.implicitCasts, true);
+ }
+
+ void test_noImplicitCast() {
+ MemoryResourceProvider provider = new MemoryResourceProvider();
+ ArgParser parser = new ArgParser();
+ defineAnalysisArguments(parser);
+ List<String> args = [
+ '--no-implicit-casts',
+ ];
+ ArgResults result = parse(provider, parser, args);
+ ContextBuilderOptions options = createContextBuilderOptions(result);
+ expect(options, isNotNull);
+ AnalysisOptionsImpl defaultOptions = options.defaultOptions;
+ expect(defaultOptions, isNotNull);
+ expect(defaultOptions.declarationCasts, false);
+ expect(defaultOptions.implicitCasts, false);
+ }
+
void test_parse_noReplacement_noIgnored() {
MemoryResourceProvider provider = new MemoryResourceProvider();
ArgParser parser = new ArgParser();
« no previous file with comments | « pkg/analyzer/lib/src/task/strong/checker.dart ('k') | pkg/analyzer/test/src/context/builder_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698