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 2320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2331 { | 2331 { |
2332 ClassElement classB = library.getType('B'); | 2332 ClassElement classB = library.getType('B'); |
2333 expect(classB.supertype.displayName, 'A'); | 2333 expect(classB.supertype.displayName, 'A'); |
2334 } | 2334 } |
2335 { | 2335 { |
2336 ClassElement classC = library.getType('C'); | 2336 ClassElement classC = library.getType('C'); |
2337 expect(classC.supertype.displayName, 'A'); | 2337 expect(classC.supertype.displayName, 'A'); |
2338 } | 2338 } |
2339 } | 2339 } |
2340 | 2340 |
2341 test_perform_deep() { | 2341 test_perform_external() { |
2342 Source sourceA = newSource('/a.dart', ''' | 2342 Source sourceA = newSource('/a.dart', ''' |
2343 library a; | 2343 library a; |
2344 import 'b.dart'; | 2344 import 'b.dart'; |
2345 class A extends B {} | 2345 class A extends B {} |
2346 '''); | 2346 '''); |
2347 newSource('/b.dart', ''' | 2347 newSource('/b.dart', ''' |
2348 library b; | 2348 library b; |
2349 import 'c.dart'; | 2349 class B {} |
2350 part 'b2.dart'; | |
2351 class B extends B2 {} | |
2352 '''); | 2350 '''); |
2353 newSource('/b2.dart', ''' | 2351 // The reference A to B should be resolved, but there's no requirement that |
2354 part of b; | 2352 // the full class hierarchy be resolved. |
2355 class B2 extends C {} | |
2356 '''); | |
2357 newSource('/c.dart', ''' | |
2358 library c; | |
2359 class C {} | |
2360 '''); | |
2361 computeResult(sourceA, LIBRARY_ELEMENT5); | 2353 computeResult(sourceA, LIBRARY_ELEMENT5); |
2362 expect(task, new isInstanceOf<ResolveLibraryTypeNamesTask>()); | 2354 expect(task, new isInstanceOf<ResolveLibraryTypeNamesTask>()); |
2363 // validate | 2355 // validate |
2364 LibraryElement library = outputs[LIBRARY_ELEMENT5]; | 2356 LibraryElement library = outputs[LIBRARY_ELEMENT5]; |
2365 { | 2357 { |
2366 ClassElement clazz = library.getType('A'); | 2358 ClassElement clazz = library.getType('A'); |
2367 expect(clazz.displayName, 'A'); | 2359 expect(clazz.displayName, 'A'); |
2368 clazz = clazz.supertype.element; | 2360 clazz = clazz.supertype.element; |
2369 expect(clazz.displayName, 'B'); | 2361 expect(clazz.displayName, 'B'); |
2370 clazz = clazz.supertype.element; | |
2371 expect(clazz.displayName, 'B2'); | |
2372 clazz = clazz.supertype.element; | |
2373 expect(clazz.displayName, 'C'); | |
2374 clazz = clazz.supertype.element; | |
2375 expect(clazz.displayName, 'Object'); | |
2376 expect(clazz.supertype, isNull); | |
2377 } | 2362 } |
2378 } | 2363 } |
2379 } | 2364 } |
2380 | 2365 |
2381 @reflectiveTest | 2366 @reflectiveTest |
2382 class ResolveReferencesTaskTest extends _AbstractDartTaskTest { | 2367 class ResolveReferencesTaskTest extends _AbstractDartTaskTest { |
2383 test_perform() { | 2368 test_perform() { |
2384 Source source = newSource('/test.dart', ''' | 2369 Source source = newSource('/test.dart', ''' |
2385 class A { | 2370 class A { |
2386 m() {} | 2371 m() {} |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2796 /** | 2781 /** |
2797 * Fill [errorListener] with [result] errors in the current [task]. | 2782 * Fill [errorListener] with [result] errors in the current [task]. |
2798 */ | 2783 */ |
2799 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 2784 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
2800 List<AnalysisError> errors = task.outputs[result]; | 2785 List<AnalysisError> errors = task.outputs[result]; |
2801 expect(errors, isNotNull, reason: result.name); | 2786 expect(errors, isNotNull, reason: result.name); |
2802 errorListener = new GatheringErrorListener(); | 2787 errorListener = new GatheringErrorListener(); |
2803 errorListener.addAll(errors); | 2788 errorListener.addAll(errors); |
2804 } | 2789 } |
2805 } | 2790 } |
OLD | NEW |