| 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 3519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3530 | 3530 |
| 3531 FunctionDeclaration f = unit.declarations[0]; | 3531 FunctionDeclaration f = unit.declarations[0]; |
| 3532 _assertResolved(f.functionExpression.body); | 3532 _assertResolved(f.functionExpression.body); |
| 3533 | 3533 |
| 3534 MethodDeclaration m = (unit.declarations[1] as ClassDeclaration).members[0]; | 3534 MethodDeclaration m = (unit.declarations[1] as ClassDeclaration).members[0]; |
| 3535 _assertResolved(m.body); | 3535 _assertResolved(m.body); |
| 3536 | 3536 |
| 3537 expect(outputs[RESOLVE_UNIT_ERRORS], hasLength(0)); | 3537 expect(outputs[RESOLVE_UNIT_ERRORS], hasLength(0)); |
| 3538 } | 3538 } |
| 3539 | 3539 |
| 3540 void test_perform_ensurePropagatedVariableTypes() { |
| 3541 newSource( |
| 3542 '/lib.dart', |
| 3543 ''' |
| 3544 class A { |
| 3545 final v = 1; |
| 3546 } |
| 3547 '''); |
| 3548 AnalysisTarget source = newSource( |
| 3549 '/test.dart', |
| 3550 ''' |
| 3551 import 'lib.dart'; |
| 3552 main(A a) { |
| 3553 a.v.isEven; |
| 3554 } |
| 3555 '''); |
| 3556 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT10, |
| 3557 matcher: isResolveUnitTask); |
| 3558 expect(outputs[RESOLVE_UNIT_ERRORS], hasLength(0)); |
| 3559 CompilationUnit unit = outputs[RESOLVED_UNIT10]; |
| 3560 FunctionDeclaration main = unit.declarations[0]; |
| 3561 BlockFunctionBody body = main.functionExpression.body; |
| 3562 ExpressionStatement statement = body.block.statements.single; |
| 3563 Expression expression = statement.expression; |
| 3564 expect(expression.bestType, context.typeProvider.boolType); |
| 3565 } |
| 3566 |
| 3540 void _assertResolved(FunctionBody body) { | 3567 void _assertResolved(FunctionBody body) { |
| 3541 ResolutionVerifier verifier = new ResolutionVerifier(); | 3568 ResolutionVerifier verifier = new ResolutionVerifier(); |
| 3542 body.accept(verifier); | 3569 body.accept(verifier); |
| 3543 verifier.assertResolved(); | 3570 verifier.assertResolved(); |
| 3544 } | 3571 } |
| 3545 } | 3572 } |
| 3546 | 3573 |
| 3547 @reflectiveTest | 3574 @reflectiveTest |
| 3548 class ResolveUnitTypeNamesTaskTest extends _AbstractDartTaskTest { | 3575 class ResolveUnitTypeNamesTaskTest extends _AbstractDartTaskTest { |
| 3549 test_perform() { | 3576 test_perform() { |
| (...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4593 /** | 4620 /** |
| 4594 * Fill [errorListener] with [result] errors in the current [task]. | 4621 * Fill [errorListener] with [result] errors in the current [task]. |
| 4595 */ | 4622 */ |
| 4596 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 4623 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
| 4597 List<AnalysisError> errors = task.outputs[result]; | 4624 List<AnalysisError> errors = task.outputs[result]; |
| 4598 expect(errors, isNotNull, reason: result.name); | 4625 expect(errors, isNotNull, reason: result.name); |
| 4599 errorListener = new GatheringErrorListener(); | 4626 errorListener = new GatheringErrorListener(); |
| 4600 errorListener.addAll(errors); | 4627 errorListener.addAll(errors); |
| 4601 } | 4628 } |
| 4602 } | 4629 } |
| OLD | NEW |