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 2800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2811 | 2811 |
2812 InterfaceType stringType = context.typeProvider.stringType; | 2812 InterfaceType stringType = context.typeProvider.stringType; |
2813 expect(topLevel.type, stringType); | 2813 expect(topLevel.type, stringType); |
2814 expect(field.type, stringType); | 2814 expect(field.type, stringType); |
2815 expect(fieldDecl.initializer.staticType, stringType); | 2815 expect(fieldDecl.initializer.staticType, stringType); |
2816 } | 2816 } |
2817 } | 2817 } |
2818 | 2818 |
2819 @reflectiveTest | 2819 @reflectiveTest |
2820 class InferStaticVariableTypesInUnitTaskTest extends _AbstractDartTaskTest { | 2820 class InferStaticVariableTypesInUnitTaskTest extends _AbstractDartTaskTest { |
| 2821 @override |
| 2822 void setUp() { |
| 2823 super.setUp(); |
| 2824 enableStrongMode(); |
| 2825 } |
| 2826 |
2821 test_created_resolved_unit() { | 2827 test_created_resolved_unit() { |
2822 Source source = newSource( | 2828 Source source = newSource( |
2823 '/test.dart', | 2829 '/test.dart', |
2824 r''' | 2830 r''' |
2825 library lib; | 2831 library lib; |
2826 class A {} | 2832 class A {} |
2827 '''); | 2833 '''); |
2828 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2834 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2829 computeResult(target, RESOLVED_UNIT7); | 2835 computeResult(target, RESOLVED_UNIT7); |
2830 expect(outputs[RESOLVED_UNIT7], isNotNull); | 2836 expect(outputs[RESOLVED_UNIT7], isNotNull); |
(...skipping 10 matching lines...) Expand all Loading... |
2841 } | 2847 } |
2842 '''); | 2848 '''); |
2843 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT7, | 2849 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT7, |
2844 matcher: isInferStaticVariableTypesInUnitTask); | 2850 matcher: isInferStaticVariableTypesInUnitTask); |
2845 CompilationUnit unit = outputs[RESOLVED_UNIT7]; | 2851 CompilationUnit unit = outputs[RESOLVED_UNIT7]; |
2846 VariableDeclaration declaration = AstFinder.getFieldInClass(unit, 'M', 'X'); | 2852 VariableDeclaration declaration = AstFinder.getFieldInClass(unit, 'M', 'X'); |
2847 InterfaceType stringType = context.typeProvider.stringType; | 2853 InterfaceType stringType = context.typeProvider.stringType; |
2848 expect(declaration.element.type, stringType); | 2854 expect(declaration.element.type, stringType); |
2849 } | 2855 } |
2850 | 2856 |
| 2857 test_perform_hasParseError() { |
| 2858 Source source = newSource( |
| 2859 '/test.dart', |
| 2860 r''' |
| 2861 @(i $= |
| 2862 '''); |
| 2863 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 2864 computeResult(target, RESOLVED_UNIT7); |
| 2865 expect(outputs[RESOLVED_UNIT7], isNotNull); |
| 2866 expect(outputs[CREATED_RESOLVED_UNIT7], isTrue); |
| 2867 } |
| 2868 |
2851 void test_perform_nestedDeclarations() { | 2869 void test_perform_nestedDeclarations() { |
2852 enableStrongMode(); | 2870 enableStrongMode(); |
2853 AnalysisTarget source = newSource( | 2871 AnalysisTarget source = newSource( |
2854 '/test.dart', | 2872 '/test.dart', |
2855 ''' | 2873 ''' |
2856 var f = (int x) { | 2874 var f = (int x) { |
2857 int squared(int value) => value * value; | 2875 int squared(int value) => value * value; |
2858 var xSquared = squared(x); | 2876 var xSquared = squared(x); |
2859 return xSquared; | 2877 return xSquared; |
2860 }; | 2878 }; |
(...skipping 2223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5084 /** | 5102 /** |
5085 * Fill [errorListener] with [result] errors in the current [task]. | 5103 * Fill [errorListener] with [result] errors in the current [task]. |
5086 */ | 5104 */ |
5087 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 5105 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
5088 List<AnalysisError> errors = task.outputs[result]; | 5106 List<AnalysisError> errors = task.outputs[result]; |
5089 expect(errors, isNotNull, reason: result.name); | 5107 expect(errors, isNotNull, reason: result.name); |
5090 errorListener = new GatheringErrorListener(); | 5108 errorListener = new GatheringErrorListener(); |
5091 errorListener.addAll(errors); | 5109 errorListener.addAll(errors); |
5092 } | 5110 } |
5093 } | 5111 } |
OLD | NEW |