Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: pkg/analyzer/test/src/task/dart_test.dart

Issue 1012543002: Include the common library name used in 'part of' directives. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/file_system/file_system.dart'; 7 import 'package:analyzer/file_system/file_system.dart';
8 import 'package:analyzer/file_system/memory_file_system.dart'; 8 import 'package:analyzer/file_system/memory_file_system.dart';
9 import 'package:analyzer/src/context/cache.dart'; 9 import 'package:analyzer/src/context/cache.dart';
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 Source source = _newSource('/test.dart', ''' 378 Source source = _newSource('/test.dart', '''
379 enum MyEnum { 379 enum MyEnum {
380 A, B 380 A, B
381 } 381 }
382 '''); 382 ''');
383 _computeResult(source, RESOLVED_UNIT4); 383 _computeResult(source, RESOLVED_UNIT4);
384 expect(task, new isInstanceOf<BuildEnumMemberElementsTask>()); 384 expect(task, new isInstanceOf<BuildEnumMemberElementsTask>());
385 CompilationUnit unit = outputs[RESOLVED_UNIT4]; 385 CompilationUnit unit = outputs[RESOLVED_UNIT4];
386 // validate Element 386 // validate Element
387 ClassElement enumElement = unit.element.getEnum('MyEnum'); 387 ClassElement enumElement = unit.element.getEnum('MyEnum');
388 print(enumElement.fields);
389 List<FieldElement> fields = enumElement.fields; 388 List<FieldElement> fields = enumElement.fields;
390 expect(fields, hasLength(4)); 389 expect(fields, hasLength(4));
391 { 390 {
392 FieldElementImpl index = fields[0]; 391 FieldElementImpl index = fields[0];
393 expect(index, isNotNull); 392 expect(index, isNotNull);
394 expect(index.name, 'index'); 393 expect(index.name, 'index');
395 expect(index.isStatic, isFalse); 394 expect(index.isStatic, isFalse);
396 expect(index.evaluationResult, isNull); 395 expect(index.evaluationResult, isNull);
397 _assertGetter(index); 396 _assertGetter(index);
398 } 397 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 { 547 {
549 CompilationUnitElement unitElement = partUnits[1].element; 548 CompilationUnitElement unitElement = partUnits[1].element;
550 expect(unitElement.uri, 'part2.dart'); 549 expect(unitElement.uri, 'part2.dart');
551 expect(unitElement.uriOffset, 37); 550 expect(unitElement.uriOffset, 37);
552 expect(unitElement.uriEnd, 49); 551 expect(unitElement.uriEnd, 49);
553 expect((libraryUnit.directives[2] as PartDirective).element, 552 expect((libraryUnit.directives[2] as PartDirective).element,
554 same(unitElement)); 553 same(unitElement));
555 } 554 }
556 } 555 }
557 556
558 test_perform_error_missingLibraryDirectiveWithPart() { 557 test_perform_error_missingLibraryDirectiveWithPart_hasCommon() {
559 _performBuildTask({ 558 _performBuildTask({
560 '/lib.dart': ''' 559 '/lib.dart': '''
561 part 'part.dart'; 560 part 'partA.dart';
561 part 'partB.dart';
562 ''', 562 ''',
563 '/part.dart': ''' 563 '/partA.dart': '''
564 part of lib; 564 part of my_lib;
565 ''',
566 '/partB.dart': '''
567 part of my_lib;
565 ''' 568 '''
566 }); 569 });
567 _assertErrorsWithCodes( 570 _assertErrorsWithCodes(
568 [ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART]); 571 [ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART]);
572 AnalysisError error = errorListener.errors[0];
573 expect(error.getProperty(ErrorProperty.PARTS_LIBRARY_NAME), 'my_lib');
574 }
575
576 test_perform_error_missingLibraryDirectiveWithPart_noCommon() {
577 _performBuildTask({
578 '/lib.dart': '''
579 part 'partA.dart';
580 part 'partB.dart';
581 ''',
582 '/partA.dart': '''
583 part of libA;
584 ''',
585 '/partB.dart': '''
586 part of libB;
587 '''
588 });
589 _assertErrorsWithCodes(
590 [ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART]);
591 AnalysisError error = errorListener.errors[0];
592 expect(error.getProperty(ErrorProperty.PARTS_LIBRARY_NAME), isNull);
569 } 593 }
570 594
571 test_perform_error_partOfDifferentLibrary() { 595 test_perform_error_partOfDifferentLibrary() {
572 _performBuildTask({ 596 _performBuildTask({
573 '/lib.dart': ''' 597 '/lib.dart': '''
574 library lib; 598 library lib;
575 part 'part.dart'; 599 part 'part.dart';
576 ''', 600 ''',
577 '/part.dart': ''' 601 '/part.dart': '''
578 part of someOtherLib; 602 part of someOtherLib;
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 return entryMap.putIfAbsent(target, () => new CacheEntry()); 1013 return entryMap.putIfAbsent(target, () => new CacheEntry());
990 } 1014 }
991 1015
992 TimestampedData<String> getContents(Source source) => source.contents; 1016 TimestampedData<String> getContents(Source source) => source.contents;
993 1017
994 noSuchMethod(Invocation invocation) { 1018 noSuchMethod(Invocation invocation) {
995 print('noSuchMethod: ${invocation.memberName}'); 1019 print('noSuchMethod: ${invocation.memberName}');
996 return super.noSuchMethod(invocation); 1020 return super.noSuchMethod(invocation);
997 } 1021 }
998 } 1022 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698