| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.test.src.task.yaml_test; | 5 library analyzer.test.src.task.yaml_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/source.dart'; | 7 import 'package:analyzer/src/generated/source.dart'; |
| 8 import 'package:analyzer/src/task/yaml.dart'; | 8 import 'package:analyzer/src/task/yaml.dart'; |
| 9 import 'package:analyzer/task/general.dart'; |
| 9 import 'package:analyzer/task/yaml.dart'; | 10 import 'package:analyzer/task/yaml.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 11 import 'package:yaml/yaml.dart'; | 12 import 'package:yaml/yaml.dart'; |
| 12 | 13 |
| 13 import '../../reflective_tests.dart'; | 14 import '../../reflective_tests.dart'; |
| 14 import '../../utils.dart'; | 15 import '../../utils.dart'; |
| 15 import '../context/abstract_context.dart'; | 16 import '../context/abstract_context.dart'; |
| 16 | 17 |
| 17 main() { | 18 main() { |
| 18 initializeTestEnvironment(); | 19 initializeTestEnvironment(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 31 style_guide: | 32 style_guide: |
| 32 camel_case_types: false | 33 camel_case_types: false |
| 33 '''); | 34 '''); |
| 34 expect(outputs, hasLength(3)); | 35 expect(outputs, hasLength(3)); |
| 35 YamlDocument document = outputs[YAML_DOCUMENT]; | 36 YamlDocument document = outputs[YAML_DOCUMENT]; |
| 36 expect(document, isNotNull); | 37 expect(document, isNotNull); |
| 37 var value = document.contents.value; | 38 var value = document.contents.value; |
| 38 expect(value, new isInstanceOf<Map>()); | 39 expect(value, new isInstanceOf<Map>()); |
| 39 expect(value['rules']['style_guide']['camel_case_types'], isFalse); | 40 expect(value['rules']['style_guide']['camel_case_types'], isFalse); |
| 40 expect(outputs[YAML_ERRORS], hasLength(0)); | 41 expect(outputs[YAML_ERRORS], hasLength(0)); |
| 41 LineInfo lineInfo = outputs[YAML_LINE_INFO]; | 42 LineInfo lineInfo = outputs[LINE_INFO]; |
| 42 expect(lineInfo, isNotNull); | 43 expect(lineInfo, isNotNull); |
| 43 expect(lineInfo.getOffsetOfLine(0), 0); | 44 expect(lineInfo.getOffsetOfLine(0), 0); |
| 44 expect(lineInfo.getOffsetOfLine(1), 7); | 45 expect(lineInfo.getOffsetOfLine(1), 7); |
| 45 expect(lineInfo.getOffsetOfLine(2), 22); | 46 expect(lineInfo.getOffsetOfLine(2), 22); |
| 46 expect(lineInfo.getOffsetOfLine(3), 50); | 47 expect(lineInfo.getOffsetOfLine(3), 50); |
| 47 } | 48 } |
| 48 | 49 |
| 49 test_perform_doesNotExist() { | 50 test_perform_doesNotExist() { |
| 50 _performParseTask(null); | 51 _performParseTask(null); |
| 51 expect(outputs, hasLength(3)); | 52 expect(outputs, hasLength(3)); |
| 52 YamlDocument document = outputs[YAML_DOCUMENT]; | 53 YamlDocument document = outputs[YAML_DOCUMENT]; |
| 53 expect(document, isNotNull); | 54 expect(document, isNotNull); |
| 54 expect(document.contents.value, isNull); | 55 expect(document.contents.value, isNull); |
| 55 expect(outputs[YAML_ERRORS], hasLength(1)); | 56 expect(outputs[YAML_ERRORS], hasLength(1)); |
| 56 LineInfo lineInfo = outputs[YAML_LINE_INFO]; | 57 LineInfo lineInfo = outputs[LINE_INFO]; |
| 57 expect(lineInfo, isNotNull); | 58 expect(lineInfo, isNotNull); |
| 58 expect(lineInfo.getOffsetOfLine(0), 0); | 59 expect(lineInfo.getOffsetOfLine(0), 0); |
| 59 } | 60 } |
| 60 | 61 |
| 61 void _performParseTask(String content) { | 62 void _performParseTask(String content) { |
| 62 if (content == null) { | 63 if (content == null) { |
| 63 source = resourceProvider.getFile('/test.yaml').createSource(); | 64 source = resourceProvider.getFile('/test.yaml').createSource(); |
| 64 } else { | 65 } else { |
| 65 source = newSource('/test.yaml', content); | 66 source = newSource('/test.yaml', content); |
| 66 } | 67 } |
| 67 computeResult(source, YAML_DOCUMENT, matcher: isParseYamlTask); | 68 computeResult(source, YAML_DOCUMENT, matcher: isParseYamlTask); |
| 68 } | 69 } |
| 69 } | 70 } |
| OLD | NEW |