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 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1553 class C { | 1553 class C { |
1554 const C(); | 1554 const C(); |
1555 } | 1555 } |
1556 | 1556 |
1557 @x | 1557 @x |
1558 f() {} | 1558 f() {} |
1559 | 1559 |
1560 const x = const C(); | 1560 const x = const C(); |
1561 '''); | 1561 '''); |
1562 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 1562 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
1563 _computeResult(target, CONSTANT_RESOLVED_UNIT); | 1563 _computeResult(target, RESOLVED_UNIT); |
1564 expect(task, new isInstanceOf<EvaluateUnitConstantsTask>()); | 1564 expect(task, new isInstanceOf<EvaluateUnitConstantsTask>()); |
1565 CompilationUnit unit = outputs[CONSTANT_RESOLVED_UNIT]; | 1565 CompilationUnit unit = outputs[RESOLVED_UNIT]; |
1566 CompilationUnitElement unitElement = unit.element; | 1566 CompilationUnitElement unitElement = unit.element; |
1567 expect((unitElement.types[0].constructors[ | 1567 expect((unitElement.types[0].constructors[ |
1568 0] as ConstructorElementImpl).isCycleFree, isTrue); | 1568 0] as ConstructorElementImpl).isCycleFree, isTrue); |
1569 expect((unitElement.functions[0].metadata[ | 1569 expect((unitElement.functions[0].metadata[ |
1570 0] as ElementAnnotationImpl).evaluationResult, isNotNull); | 1570 0] as ElementAnnotationImpl).evaluationResult, isNotNull); |
1571 expect((unitElement.topLevelVariables[ | 1571 expect((unitElement.topLevelVariables[ |
1572 0] as TopLevelVariableElementImpl).evaluationResult, isNotNull); | 1572 0] as TopLevelVariableElementImpl).evaluationResult, isNotNull); |
1573 } | 1573 } |
1574 } | 1574 } |
1575 | 1575 |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2114 Source source = newSource('/test.dart', ''' | 2114 Source source = newSource('/test.dart', ''' |
2115 class A { | 2115 class A { |
2116 m() {} | 2116 m() {} |
2117 } | 2117 } |
2118 main(A a) { | 2118 main(A a) { |
2119 a.m(); | 2119 a.m(); |
2120 } | 2120 } |
2121 '''); | 2121 '''); |
2122 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2122 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2123 // prepare unit and "a.m()" invocation | 2123 // prepare unit and "a.m()" invocation |
2124 _computeResult(target, RESOLVED_UNIT); | 2124 _computeResult(target, RESOLVED_UNIT6); |
2125 CompilationUnit unit = outputs[RESOLVED_UNIT]; | 2125 CompilationUnit unit = outputs[RESOLVED_UNIT6]; |
2126 // walk the AST | 2126 // walk the AST |
2127 FunctionDeclaration function = unit.declarations[1]; | 2127 FunctionDeclaration function = unit.declarations[1]; |
2128 BlockFunctionBody body = function.functionExpression.body; | 2128 BlockFunctionBody body = function.functionExpression.body; |
2129 ExpressionStatement statement = body.block.statements[0]; | 2129 ExpressionStatement statement = body.block.statements[0]; |
2130 MethodInvocation invocation = statement.expression; | 2130 MethodInvocation invocation = statement.expression; |
2131 expect(task, new isInstanceOf<ResolveReferencesTask>()); | 2131 expect(task, new isInstanceOf<ResolveReferencesTask>()); |
2132 expect(unit, same(outputs[RESOLVED_UNIT])); | 2132 expect(unit, same(outputs[RESOLVED_UNIT6])); |
2133 // a.m() is resolved now | 2133 // a.m() is resolved now |
2134 expect(invocation.methodName.staticElement, isNotNull); | 2134 expect(invocation.methodName.staticElement, isNotNull); |
2135 } | 2135 } |
2136 | 2136 |
2137 test_perform_errors() { | 2137 test_perform_errors() { |
2138 Source source = newSource('/test.dart', ''' | 2138 Source source = newSource('/test.dart', ''' |
2139 class A { | 2139 class A { |
2140 } | 2140 } |
2141 main(A a) { | 2141 main(A a) { |
2142 a.unknownMethod(); | 2142 a.unknownMethod(); |
2143 } | 2143 } |
2144 '''); | 2144 '''); |
2145 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2145 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2146 _computeResult(target, RESOLVED_UNIT); | 2146 _computeResult(target, RESOLVED_UNIT6); |
2147 expect(task, new isInstanceOf<ResolveReferencesTask>()); | 2147 expect(task, new isInstanceOf<ResolveReferencesTask>()); |
2148 // validate | 2148 // validate |
2149 _fillErrorListener(RESOLVE_REFERENCES_ERRORS); | 2149 _fillErrorListener(RESOLVE_REFERENCES_ERRORS); |
2150 errorListener.assertErrorsWithCodes( | 2150 errorListener.assertErrorsWithCodes( |
2151 <ErrorCode>[StaticTypeWarningCode.UNDEFINED_METHOD]); | 2151 <ErrorCode>[StaticTypeWarningCode.UNDEFINED_METHOD]); |
2152 } | 2152 } |
2153 } | 2153 } |
2154 | 2154 |
2155 @reflectiveTest | 2155 @reflectiveTest |
2156 class ResolveUnitTypeNamesTaskTest extends _AbstractDartTaskTest { | 2156 class ResolveUnitTypeNamesTaskTest extends _AbstractDartTaskTest { |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2374 /** | 2374 /** |
2375 * Fill [errorListener] with [result] errors in the current [task]. | 2375 * Fill [errorListener] with [result] errors in the current [task]. |
2376 */ | 2376 */ |
2377 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 2377 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
2378 List<AnalysisError> errors = task.outputs[result]; | 2378 List<AnalysisError> errors = task.outputs[result]; |
2379 expect(errors, isNotNull, reason: result.name); | 2379 expect(errors, isNotNull, reason: result.name); |
2380 errorListener = new GatheringErrorListener(); | 2380 errorListener = new GatheringErrorListener(); |
2381 errorListener.addAll(errors); | 2381 errorListener.addAll(errors); |
2382 } | 2382 } |
2383 } | 2383 } |
OLD | NEW |