| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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 test.src.task.dart_test; | 5 library test.src.task.dart_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/context/cache.dart'; | 7 import 'package:analyzer/src/context/cache.dart'; |
| 8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 import 'package:analyzer/src/generated/constant.dart'; | 9 import 'package:analyzer/src/generated/constant.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| (...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1282 Element x = accessors.firstWhere((PropertyAccessorElement accessor) => | 1282 Element x = accessors.firstWhere((PropertyAccessorElement accessor) => |
| 1283 accessor.isGetter && accessor.name == 'x').variable; | 1283 accessor.isGetter && accessor.name == 'x').variable; |
| 1284 Annotation annotation = findClassAnnotation(unit, 'C'); | 1284 Annotation annotation = findClassAnnotation(unit, 'C'); |
| 1285 // Now compute the dependencies for the annotation, and check that it is | 1285 // Now compute the dependencies for the annotation, and check that it is |
| 1286 // the list [x]. | 1286 // the list [x]. |
| 1287 _computeResult(new ConstantEvaluationTarget_Annotation( | 1287 _computeResult(new ConstantEvaluationTarget_Annotation( |
| 1288 context, source, source, annotation), CONSTANT_DEPENDENCIES); | 1288 context, source, source, annotation), CONSTANT_DEPENDENCIES); |
| 1289 expect(outputs[CONSTANT_DEPENDENCIES], [x]); | 1289 expect(outputs[CONSTANT_DEPENDENCIES], [x]); |
| 1290 } | 1290 } |
| 1291 | 1291 |
| 1292 test_enumConstant() { |
| 1293 Source source = newSource('/test.dart', ''' |
| 1294 enum E {A, B, C} |
| 1295 '''); |
| 1296 // First compute the resolved unit for the source. |
| 1297 LibrarySpecificUnit librarySpecificUnit = |
| 1298 new LibrarySpecificUnit(source, source); |
| 1299 _computeResult(librarySpecificUnit, RESOLVED_UNIT2); |
| 1300 CompilationUnit unit = outputs[RESOLVED_UNIT2]; |
| 1301 // Find the element for 'A' |
| 1302 EnumDeclaration enumDeclaration = unit.declarations[0]; |
| 1303 EnumConstantDeclaration constantDeclaration = enumDeclaration.constants[0]; |
| 1304 FieldElement constantElement = constantDeclaration.element; |
| 1305 // Now compute the dependencies for the constant and check that there are |
| 1306 // none. |
| 1307 _computeResult(constantElement, CONSTANT_DEPENDENCIES); |
| 1308 expect(outputs[CONSTANT_DEPENDENCIES], isEmpty); |
| 1309 } |
| 1310 |
| 1292 test_perform() { | 1311 test_perform() { |
| 1293 Source source = newSource('/test.dart', ''' | 1312 Source source = newSource('/test.dart', ''' |
| 1294 const x = y; | 1313 const x = y; |
| 1295 const y = 1; | 1314 const y = 1; |
| 1296 '''); | 1315 '''); |
| 1297 // First compute the resolved unit for the source. | 1316 // First compute the resolved unit for the source. |
| 1298 LibrarySpecificUnit librarySpecificUnit = | 1317 LibrarySpecificUnit librarySpecificUnit = |
| 1299 new LibrarySpecificUnit(source, source); | 1318 new LibrarySpecificUnit(source, source); |
| 1300 _computeResult(librarySpecificUnit, RESOLVED_UNIT1); | 1319 _computeResult(librarySpecificUnit, RESOLVED_UNIT1); |
| 1301 CompilationUnit unit = outputs[RESOLVED_UNIT1]; | 1320 CompilationUnit unit = outputs[RESOLVED_UNIT1]; |
| (...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2495 /** | 2514 /** |
| 2496 * Fill [errorListener] with [result] errors in the current [task]. | 2515 * Fill [errorListener] with [result] errors in the current [task]. |
| 2497 */ | 2516 */ |
| 2498 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 2517 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
| 2499 List<AnalysisError> errors = task.outputs[result]; | 2518 List<AnalysisError> errors = task.outputs[result]; |
| 2500 expect(errors, isNotNull, reason: result.name); | 2519 expect(errors, isNotNull, reason: result.name); |
| 2501 errorListener = new GatheringErrorListener(); | 2520 errorListener = new GatheringErrorListener(); |
| 2502 errorListener.addAll(errors); | 2521 errorListener.addAll(errors); |
| 2503 } | 2522 } |
| 2504 } | 2523 } |
| OLD | NEW |