OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library test.src.task.options_test; |
| 6 |
| 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/src/generated/engine.dart'; |
| 9 import 'package:analyzer/src/generated/source.dart'; |
| 10 import 'package:analyzer/src/task/options.dart'; |
| 11 import 'package:analyzer/task/model.dart'; |
| 12 import 'package:unittest/unittest.dart'; |
| 13 |
| 14 import '../../reflective_tests.dart'; |
| 15 import '../../utils.dart'; |
| 16 import '../context/abstract_context.dart'; |
| 17 |
| 18 main() { |
| 19 initializeTestEnvironment(); |
| 20 runReflectiveTests(GenerateOptionsErrorsTaskTest); |
| 21 } |
| 22 |
| 23 isInstanceOf isGenerateOptionsErrorsTask = |
| 24 new isInstanceOf<GenerateOptionsErrorsTask>(); |
| 25 |
| 26 @reflectiveTest |
| 27 class GenerateOptionsErrorsTaskTest extends AbstractContextTest { |
| 28 final optionsFilePath = '/${AnalysisEngine.ANALYSIS_OPTIONS_FILE}'; |
| 29 |
| 30 Source source; |
| 31 @override |
| 32 setUp() { |
| 33 super.setUp(); |
| 34 source = newSource(optionsFilePath); |
| 35 } |
| 36 |
| 37 test_buildInputs() { |
| 38 Map<String, TaskInput> inputs = |
| 39 GenerateOptionsErrorsTask.buildInputs(source); |
| 40 expect(inputs, isNotNull); |
| 41 expect(inputs.keys, |
| 42 unorderedEquals([GenerateOptionsErrorsTask.CONTENT_INPUT_NAME])); |
| 43 } |
| 44 |
| 45 test_constructor() { |
| 46 GenerateOptionsErrorsTask task = |
| 47 new GenerateOptionsErrorsTask(context, source); |
| 48 expect(task, isNotNull); |
| 49 expect(task.context, context); |
| 50 expect(task.target, source); |
| 51 } |
| 52 |
| 53 test_createTask() { |
| 54 GenerateOptionsErrorsTask task = |
| 55 GenerateOptionsErrorsTask.createTask(context, source); |
| 56 expect(task, isNotNull); |
| 57 expect(task.context, context); |
| 58 expect(task.target, source); |
| 59 } |
| 60 |
| 61 test_description() { |
| 62 GenerateOptionsErrorsTask task = |
| 63 new GenerateOptionsErrorsTask(null, source); |
| 64 expect(task.description, isNotNull); |
| 65 } |
| 66 |
| 67 test_descriptor() { |
| 68 TaskDescriptor descriptor = GenerateOptionsErrorsTask.DESCRIPTOR; |
| 69 expect(descriptor, isNotNull); |
| 70 } |
| 71 |
| 72 test_perform_bad_yaml() { |
| 73 String code = r''' |
| 74 : |
| 75 '''; |
| 76 AnalysisTarget target = newSource(optionsFilePath, code); |
| 77 computeResult(target, ANALYSIS_OPTIONS_ERRORS); |
| 78 expect(task, isGenerateOptionsErrorsTask); |
| 79 List<AnalysisError> errors = outputs[ANALYSIS_OPTIONS_ERRORS]; |
| 80 expect(errors, hasLength(1)); |
| 81 expect(errors[0].errorCode, AnalysisOptionsErrorCode.PARSE_ERROR); |
| 82 } |
| 83 |
| 84 test_perform_OK() { |
| 85 String code = r''' |
| 86 analyzer: |
| 87 strong-mode: true |
| 88 '''; |
| 89 AnalysisTarget target = newSource(optionsFilePath, code); |
| 90 computeResult(target, ANALYSIS_OPTIONS_ERRORS); |
| 91 expect(task, isGenerateOptionsErrorsTask); |
| 92 expect(outputs[ANALYSIS_OPTIONS_ERRORS], isEmpty); |
| 93 } |
| 94 } |
OLD | NEW |