Chromium Code Reviews| 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 analyzer.test.src.task.dart_test; | 5 library analyzer.test.src.task.dart_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/dart/ast/visitor.dart'; | 9 import 'package:analyzer/dart/ast/visitor.dart'; |
| 10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
| (...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1138 Annotation annotation = findClassAnnotation(unit, 'C'); | 1138 Annotation annotation = findClassAnnotation(unit, 'C'); |
| 1139 // Now compute the dependencies for the annotation, and check that it is | 1139 // Now compute the dependencies for the annotation, and check that it is |
| 1140 // the set [x, constructorForD]. | 1140 // the set [x, constructorForD]. |
| 1141 // TODO(paulberry): test librarySource != source | 1141 // TODO(paulberry): test librarySource != source |
| 1142 computeResult(annotation.elementAnnotation, CONSTANT_DEPENDENCIES, | 1142 computeResult(annotation.elementAnnotation, CONSTANT_DEPENDENCIES, |
| 1143 matcher: isComputeConstantDependenciesTask); | 1143 matcher: isComputeConstantDependenciesTask); |
| 1144 expect( | 1144 expect( |
| 1145 outputs[CONSTANT_DEPENDENCIES].toSet(), [x, constructorForD].toSet()); | 1145 outputs[CONSTANT_DEPENDENCIES].toSet(), [x, constructorForD].toSet()); |
| 1146 } | 1146 } |
| 1147 | 1147 |
| 1148 test_annotation_with_nonConstArg() { | |
| 1149 Source source = newSource( | |
| 1150 '/test.dart', | |
| 1151 ''' | |
| 1152 class A { | |
| 1153 const A(x); | |
| 1154 } | |
| 1155 class C { | |
| 1156 @A(const [(_) => null]) | |
| 1157 String s; | |
| 1158 } | |
| 1159 '''); | |
| 1160 // First compute the resolved unit for the source. | |
| 1161 LibrarySpecificUnit librarySpecificUnit = | |
| 1162 new LibrarySpecificUnit(source, source); | |
| 1163 computeResult(librarySpecificUnit, RESOLVED_UNIT1); | |
| 1164 CompilationUnit unit = outputs[RESOLVED_UNIT1]; | |
| 1165 // Find the annotation on the field. | |
| 1166 ClassDeclaration classC = unit.declarations[1]; | |
| 1167 Annotation annotation = classC.members[0].metadata[0]; | |
| 1168 // Now compute the dependencies for the annotation, and check that it is | |
| 1169 // the set [x, constructorForD]. | |
|
scheglov
2016/02/18 19:29:13
I don't understand this comment.
Brian Wilkerson
2016/02/18 19:36:38
Sorry, copy-paste error.
| |
| 1170 computeResult(annotation.elementAnnotation, CONSTANT_DEPENDENCIES, | |
| 1171 matcher: isComputeConstantDependenciesTask); | |
| 1172 expect(outputs[CONSTANT_DEPENDENCIES], hasLength(1)); | |
| 1173 } | |
| 1174 | |
| 1148 test_annotation_without_args() { | 1175 test_annotation_without_args() { |
| 1149 Source source = newSource( | 1176 Source source = newSource( |
| 1150 '/test.dart', | 1177 '/test.dart', |
| 1151 ''' | 1178 ''' |
| 1152 const x = 1; | 1179 const x = 1; |
| 1153 @x class C {} | 1180 @x class C {} |
| 1154 '''); | 1181 '''); |
| 1155 // First compute the resolved unit for the source. | 1182 // First compute the resolved unit for the source. |
| 1156 LibrarySpecificUnit librarySpecificUnit = | 1183 LibrarySpecificUnit librarySpecificUnit = |
| 1157 new LibrarySpecificUnit(source, source); | 1184 new LibrarySpecificUnit(source, source); |
| (...skipping 3803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4961 /** | 4988 /** |
| 4962 * Fill [errorListener] with [result] errors in the current [task]. | 4989 * Fill [errorListener] with [result] errors in the current [task]. |
| 4963 */ | 4990 */ |
| 4964 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 4991 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
| 4965 List<AnalysisError> errors = task.outputs[result]; | 4992 List<AnalysisError> errors = task.outputs[result]; |
| 4966 expect(errors, isNotNull, reason: result.name); | 4993 expect(errors, isNotNull, reason: result.name); |
| 4967 errorListener = new GatheringErrorListener(); | 4994 errorListener = new GatheringErrorListener(); |
| 4968 errorListener.addAll(errors); | 4995 errorListener.addAll(errors); |
| 4969 } | 4996 } |
| 4970 } | 4997 } |
| OLD | NEW |