| 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 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1639 expect(units1, hasLength(2)); | 1639 expect(units1, hasLength(2)); |
| 1640 expect(units2, hasLength(2)); | 1640 expect(units2, hasLength(2)); |
| 1641 expect(units3, hasLength(2)); | 1641 expect(units3, hasLength(2)); |
| 1642 | 1642 |
| 1643 List<CompilationUnitElement> dep0 = results[0][LIBRARY_CYCLE_DEPENDENCIES]; | 1643 List<CompilationUnitElement> dep0 = results[0][LIBRARY_CYCLE_DEPENDENCIES]; |
| 1644 List<CompilationUnitElement> dep1 = results[1][LIBRARY_CYCLE_DEPENDENCIES]; | 1644 List<CompilationUnitElement> dep1 = results[1][LIBRARY_CYCLE_DEPENDENCIES]; |
| 1645 List<CompilationUnitElement> dep2 = results[2][LIBRARY_CYCLE_DEPENDENCIES]; | 1645 List<CompilationUnitElement> dep2 = results[2][LIBRARY_CYCLE_DEPENDENCIES]; |
| 1646 List<CompilationUnitElement> dep3 = results[3][LIBRARY_CYCLE_DEPENDENCIES]; | 1646 List<CompilationUnitElement> dep3 = results[3][LIBRARY_CYCLE_DEPENDENCIES]; |
| 1647 expect(dep0, hasLength(1)); // dart:core | 1647 expect(dep0, hasLength(1)); // dart:core |
| 1648 expect(dep1, hasLength(1)); // dart:core | 1648 expect(dep1, hasLength(1)); // dart:core |
| 1649 expect(dep3, hasLength(3)); // dart:core, a.dart, b.dart | 1649 expect(dep2, hasLength(3)); // dart:core, a.dart, b.dart |
| 1650 expect(dep3, hasLength(3)); // dart:core, a.dart, b.dart | 1650 expect(dep3, hasLength(3)); // dart:core, a.dart, b.dart |
| 1651 } | 1651 } |
| 1652 | 1652 |
| 1653 void test_library_double_loop_parts() { | 1653 void test_library_double_loop_parts() { |
| 1654 List<Source> sources = newSources({ | 1654 List<Source> sources = newSources({ |
| 1655 '/a.dart': ''' | 1655 '/a.dart': ''' |
| 1656 import 'b.dart'; | 1656 import 'b.dart'; |
| 1657 part 'aa.dart'; | 1657 part 'aa.dart'; |
| 1658 part 'ab.dart'; | 1658 part 'ab.dart'; |
| 1659 ''', | 1659 ''', |
| (...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3026 // B.b2 should now be fully resolved and inferred. | 3026 // B.b2 should now be fully resolved and inferred. |
| 3027 assertVariableDeclarationTypes( | 3027 assertVariableDeclarationTypes( |
| 3028 getFieldInClass(unit1, "B", "b2"), intType, intType); | 3028 getFieldInClass(unit1, "B", "b2"), intType, intType); |
| 3029 | 3029 |
| 3030 // A.a2 should now be resolved on the rhs, but not yet inferred. | 3030 // A.a2 should now be resolved on the rhs, but not yet inferred. |
| 3031 assertVariableDeclarationTypes( | 3031 assertVariableDeclarationTypes( |
| 3032 getFieldInClass(unit0, "A", "a2"), dynamicType, intType); | 3032 getFieldInClass(unit0, "A", "a2"), dynamicType, intType); |
| 3033 | 3033 |
| 3034 computeResult( | 3034 computeResult( |
| 3035 new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT7); | 3035 new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT7); |
| 3036 CompilationUnit unit2 = outputs[RESOLVED_UNIT7]; | |
| 3037 | 3036 |
| 3038 // A.a2 should now be fully resolved and inferred. | 3037 // A.a2 should now be fully resolved and inferred. |
| 3039 assertVariableDeclarationTypes( | 3038 assertVariableDeclarationTypes( |
| 3040 getFieldInClass(unit0, "A", "a2"), intType, intType); | 3039 getFieldInClass(unit0, "A", "a2"), intType, intType); |
| 3041 | 3040 |
| 3042 assertVariableDeclarationTypes( | 3041 assertVariableDeclarationTypes( |
| 3043 getFieldInClass(unit1, "B", "b2"), intType, intType); | 3042 getFieldInClass(unit1, "B", "b2"), intType, intType); |
| 3044 } | 3043 } |
| 3045 | 3044 |
| 3046 // Test inference of instance fields across units | 3045 // Test inference of instance fields across units |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3060 ''', | 3059 ''', |
| 3061 '/main.dart': ''' | 3060 '/main.dart': ''' |
| 3062 import "a.dart"; | 3061 import "a.dart"; |
| 3063 | 3062 |
| 3064 test1() { | 3063 test1() { |
| 3065 int x = 0; | 3064 int x = 0; |
| 3066 x = new A().a2; | 3065 x = new A().a2; |
| 3067 } | 3066 } |
| 3068 ''' | 3067 ''' |
| 3069 }); | 3068 }); |
| 3070 InterfaceType intType = context.typeProvider.intType; | |
| 3071 DartType dynamicType = context.typeProvider.dynamicType; | 3069 DartType dynamicType = context.typeProvider.dynamicType; |
| 3072 | 3070 |
| 3073 computeResult( | 3071 computeResult( |
| 3074 new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT7); | 3072 new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT7); |
| 3075 CompilationUnit unit0 = outputs[RESOLVED_UNIT7]; | 3073 CompilationUnit unit0 = outputs[RESOLVED_UNIT7]; |
| 3076 | 3074 |
| 3077 // A.a2 should now be resolved on the rhs, but not yet inferred. | 3075 // A.a2 should now be resolved on the rhs, but not yet inferred. |
| 3078 assertVariableDeclarationTypes( | 3076 assertVariableDeclarationTypes( |
| 3079 getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); | 3077 getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); |
| 3080 | 3078 |
| 3081 computeResult( | 3079 computeResult( |
| 3082 new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT7); | 3080 new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT7); |
| 3083 CompilationUnit unit2 = outputs[RESOLVED_UNIT7]; | |
| 3084 | 3081 |
| 3085 // A.a2 should now be fully resolved and inferred. | 3082 // A.a2 should now be fully resolved and inferred. |
| 3086 assertVariableDeclarationTypes( | 3083 assertVariableDeclarationTypes( |
| 3087 getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); | 3084 getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); |
| 3088 } | 3085 } |
| 3089 | 3086 |
| 3090 // Test inference of instance fields across units with cycles | 3087 // Test inference of instance fields across units with cycles |
| 3091 void test_perform_inference_cross_unit_static_instance() { | 3088 void test_perform_inference_cross_unit_static_instance() { |
| 3092 List<Source> sources = newSources({ | 3089 List<Source> sources = newSources({ |
| 3093 '/a.dart': ''' | 3090 '/a.dart': ''' |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3135 assertVariableDeclarationTypes( | 3132 assertVariableDeclarationTypes( |
| 3136 getFieldInClass(unit0, "A", "a2"), dynamicType, intType); | 3133 getFieldInClass(unit0, "A", "a2"), dynamicType, intType); |
| 3137 | 3134 |
| 3138 assertVariableDeclarationTypes( | 3135 assertVariableDeclarationTypes( |
| 3139 getFieldInClass(unit1, "B", "b1"), intType, intType); | 3136 getFieldInClass(unit1, "B", "b1"), intType, intType); |
| 3140 assertVariableDeclarationTypes( | 3137 assertVariableDeclarationTypes( |
| 3141 getFieldInClass(unit1, "B", "b2"), intType, intType); | 3138 getFieldInClass(unit1, "B", "b2"), intType, intType); |
| 3142 | 3139 |
| 3143 computeResult( | 3140 computeResult( |
| 3144 new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT7); | 3141 new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT7); |
| 3145 CompilationUnit unit2 = outputs[RESOLVED_UNIT7]; | |
| 3146 | 3142 |
| 3147 assertVariableDeclarationTypes( | 3143 assertVariableDeclarationTypes( |
| 3148 getFieldInClass(unit0, "A", "a1"), intType, intType); | 3144 getFieldInClass(unit0, "A", "a1"), intType, intType); |
| 3149 assertVariableDeclarationTypes( | 3145 assertVariableDeclarationTypes( |
| 3150 getFieldInClass(unit0, "A", "a2"), intType, intType); | 3146 getFieldInClass(unit0, "A", "a2"), intType, intType); |
| 3151 | 3147 |
| 3152 assertVariableDeclarationTypes( | 3148 assertVariableDeclarationTypes( |
| 3153 getFieldInClass(unit1, "B", "b1"), intType, intType); | 3149 getFieldInClass(unit1, "B", "b1"), intType, intType); |
| 3154 assertVariableDeclarationTypes( | 3150 assertVariableDeclarationTypes( |
| 3155 getFieldInClass(unit1, "B", "b2"), intType, intType); | 3151 getFieldInClass(unit1, "B", "b2"), intType, intType); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3187 // A.a2 should now be resolved on the rhs, but not yet inferred. | 3183 // A.a2 should now be resolved on the rhs, but not yet inferred. |
| 3188 assertVariableDeclarationTypes( | 3184 assertVariableDeclarationTypes( |
| 3189 getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); | 3185 getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); |
| 3190 | 3186 |
| 3191 // B.b2 shoud be resolved on the rhs, but not yet inferred. | 3187 // B.b2 shoud be resolved on the rhs, but not yet inferred. |
| 3192 assertVariableDeclarationTypes( | 3188 assertVariableDeclarationTypes( |
| 3193 getFieldInClass(unit0, "B", "b2"), dynamicType, intType); | 3189 getFieldInClass(unit0, "B", "b2"), dynamicType, intType); |
| 3194 | 3190 |
| 3195 computeResult( | 3191 computeResult( |
| 3196 new LibrarySpecificUnit(sources[1], sources[1]), RESOLVED_UNIT7); | 3192 new LibrarySpecificUnit(sources[1], sources[1]), RESOLVED_UNIT7); |
| 3197 CompilationUnit unit1 = outputs[RESOLVED_UNIT7]; | |
| 3198 | 3193 |
| 3199 // A.a2 should now be fully resolved and inferred. | 3194 // A.a2 should now be fully resolved and inferred. |
| 3200 assertVariableDeclarationTypes( | 3195 assertVariableDeclarationTypes( |
| 3201 getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); | 3196 getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); |
| 3202 | 3197 |
| 3203 // B.b2 should now be fully resolved and inferred. | 3198 // B.b2 should now be fully resolved and inferred. |
| 3204 assertVariableDeclarationTypes( | 3199 assertVariableDeclarationTypes( |
| 3205 getFieldInClass(unit0, "B", "b2"), intType, intType); | 3200 getFieldInClass(unit0, "B", "b2"), intType, intType); |
| 3206 } | 3201 } |
| 3207 } | 3202 } |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3671 import 'b.dart'; | 3666 import 'b.dart'; |
| 3672 var bar = new B(); | 3667 var bar = new B(); |
| 3673 void foo() { | 3668 void foo() { |
| 3674 String x = bar.f.z; | 3669 String x = bar.f.z; |
| 3675 } | 3670 } |
| 3676 ''' | 3671 ''' |
| 3677 }); | 3672 }); |
| 3678 List<dynamic> units = | 3673 List<dynamic> units = |
| 3679 computeLibraryResults(sources, RESOLVED_UNIT9).toList(); | 3674 computeLibraryResults(sources, RESOLVED_UNIT9).toList(); |
| 3680 CompilationUnit unit0 = units[0]; | 3675 CompilationUnit unit0 = units[0]; |
| 3681 CompilationUnit unit1 = units[1]; | |
| 3682 CompilationUnit unit2 = units[2]; | 3676 CompilationUnit unit2 = units[2]; |
| 3683 | 3677 |
| 3684 InterfaceType intType = context.typeProvider.intType; | 3678 InterfaceType intType = context.typeProvider.intType; |
| 3685 InterfaceType stringType = context.typeProvider.stringType; | 3679 InterfaceType stringType = context.typeProvider.stringType; |
| 3686 | 3680 |
| 3687 assertVariableDeclarationStatementTypes( | 3681 assertVariableDeclarationStatementTypes( |
| 3688 getStatementsInTopLevelFunction(unit0, "foo")[0], stringType, intType); | 3682 getStatementsInTopLevelFunction(unit0, "foo")[0], stringType, intType); |
| 3689 assertVariableDeclarationStatementTypes( | 3683 assertVariableDeclarationStatementTypes( |
| 3690 getStatementsInTopLevelFunction(unit2, "foo")[0], stringType, intType); | 3684 getStatementsInTopLevelFunction(unit2, "foo")[0], stringType, intType); |
| 3691 } | 3685 } |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4336 /** | 4330 /** |
| 4337 * Fill [errorListener] with [result] errors in the current [task]. | 4331 * Fill [errorListener] with [result] errors in the current [task]. |
| 4338 */ | 4332 */ |
| 4339 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 4333 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
| 4340 List<AnalysisError> errors = task.outputs[result]; | 4334 List<AnalysisError> errors = task.outputs[result]; |
| 4341 expect(errors, isNotNull, reason: result.name); | 4335 expect(errors, isNotNull, reason: result.name); |
| 4342 errorListener = new GatheringErrorListener(); | 4336 errorListener = new GatheringErrorListener(); |
| 4343 errorListener.addAll(errors); | 4337 errorListener.addAll(errors); |
| 4344 } | 4338 } |
| 4345 } | 4339 } |
| OLD | NEW |