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

Unified Diff: pkg/analyzer/test/src/task/options_test.dart

Issue 1423333002: Option support for `enableSuperMixins` (and more). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merge with master. Created 5 years, 2 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/pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/task/options_test.dart
diff --git a/pkg/analyzer/test/src/task/options_test.dart b/pkg/analyzer/test/src/task/options_test.dart
index 869b6385e70e9bdb99593cd0517c1032ab0e2943..3b39f0baf4dbb55f6eb0fa038aeffab2117eb05e 100644
--- a/pkg/analyzer/test/src/task/options_test.dart
+++ b/pkg/analyzer/test/src/task/options_test.dart
@@ -6,12 +6,13 @@ library test.src.task.options_test;
import 'package:analyzer/analyzer.dart';
import 'package:analyzer/source/analysis_options_provider.dart';
-import 'package:analyzer/src/generated/engine.dart';
+import 'package:analyzer/src/generated/engine.dart' hide AnalysisContextImpl;
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/task/options.dart';
import 'package:analyzer/task/general.dart';
import 'package:analyzer/task/model.dart';
import 'package:unittest/unittest.dart';
+import 'package:yaml/yaml.dart';
import '../../generated/test_support.dart';
import '../../reflective_tests.dart';
@@ -20,6 +21,7 @@ import '../context/abstract_context.dart';
main() {
initializeTestEnvironment();
+ runReflectiveTests(ContextConfigurationTest);
runReflectiveTests(GenerateOptionsErrorsTaskTest);
runReflectiveTests(OptionsFileValidatorTest);
}
@@ -28,6 +30,62 @@ isInstanceOf isGenerateOptionsErrorsTask =
new isInstanceOf<GenerateOptionsErrorsTask>();
@reflectiveTest
+class ContextConfigurationTest extends AbstractContextTest {
+ final AnalysisOptionsProvider optionsProvider = new AnalysisOptionsProvider();
+
+ AnalysisOptions get analysisOptions => context.analysisOptions;
+
+ configureContext(String optionsSource) =>
+ configureContextOptions(context, parseOptions(optionsSource));
+
+ Map<String, YamlNode> parseOptions(String source) =>
+ optionsProvider.getOptionsFromString(source);
+
+ test_configure_enableSuperMixins() {
+ configureContext('''
+analyzer:
+ language:
+ enableSuperMixins: true
+''');
+ expect(analysisOptions.enableSuperMixins, true);
+ }
+
+ test_configure_error_filters() {
+ configureContext('''
+analyzer:
+ errors:
+ invalid_assignment: ignore
+ unused_local_variable: ignore
+''');
+
+ List<ErrorFilter> filters =
+ context.getConfigurationData(CONFIGURED_ERROR_FILTERS);
+ expect(filters, hasLength(2));
+
+ var unused_error = new AnalysisError(
+ new TestSource(), 0, 1, HintCode.UNUSED_LOCAL_VARIABLE, [
+ ['x']
+ ]);
+ var invalid_assignment_error =
+ new AnalysisError(new TestSource(), 0, 1, HintCode.INVALID_ASSIGNMENT, [
+ ['x'],
+ ['y']
+ ]);
+
+ expect(filters.any((filter) => filter(unused_error)), isTrue);
+ expect(filters.any((filter) => filter(invalid_assignment_error)), isTrue);
+ }
+
+ test_configure_strong_mode() {
+ configureContext('''
+analyzer:
+ strong-mode: true
+''');
+ expect(analysisOptions.strongMode, true);
+ }
+}
+
+@reflectiveTest
class GenerateOptionsErrorsTaskTest extends AbstractContextTest {
final optionsFilePath = '/${AnalysisEngine.ANALYSIS_OPTIONS_FILE}';
@@ -129,8 +187,8 @@ analyzer:
AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUES);
expect(
errors[0].message,
- "The option 'not_supported' is not supported by analyzer, "
- "supported values are 'errors', 'exclude', 'plugins' and 'strong-mode'");
+ "The option 'not_supported' is not supported by analyzer, supported "
+ "values are 'errors', 'exclude', 'language', 'plugins' and 'strong-mode'");
}
}
@@ -146,7 +204,7 @@ class OptionsFileValidatorTest {
analyzer:
errors:
unused_local_variable: ignore
- ''',
+''',
[]);
}
@@ -170,6 +228,36 @@ analyzer:
[AnalysisOptionsWarningCode.UNRECOGNIZED_ERROR_CODE]);
}
+ test_analyzer_language_supported() {
+ validate(
+ '''
+analyzer:
+ language:
+ enableSuperMixins: true
+''',
+ []);
+ }
+
+ test_analyzer_language_unsupported_key() {
+ validate(
+ '''
+analyzer:
+ language:
+ unsupported: true
+''',
+ [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUE]);
+ }
+
+ test_analyzer_language_unsupported_value() {
+ validate(
+ '''
+analyzer:
+ language:
+ enableSuperMixins: foo
+''',
+ [AnalysisOptionsWarningCode.UNSUPPORTED_VALUE]);
+ }
+
test_analyzer_supported_exclude() {
validate(
'''
« no previous file with comments | « pkg/analyzer/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698