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'; |
11 import 'package:analyzer/src/generated/engine.dart' | 11 import 'package:analyzer/src/generated/engine.dart' |
12 show AnalysisOptionsImpl, CacheState; | 12 show AnalysisOptionsImpl, CacheState; |
13 import 'package:analyzer/src/generated/error.dart'; | 13 import 'package:analyzer/src/generated/error.dart'; |
14 import 'package:analyzer/src/generated/resolver.dart'; | 14 import 'package:analyzer/src/generated/resolver.dart'; |
15 import 'package:analyzer/src/generated/scanner.dart'; | 15 import 'package:analyzer/src/generated/scanner.dart'; |
16 import 'package:analyzer/src/generated/sdk.dart'; | 16 import 'package:analyzer/src/generated/sdk.dart'; |
17 import 'package:analyzer/src/generated/source.dart'; | 17 import 'package:analyzer/src/generated/source.dart'; |
18 import 'package:analyzer/src/task/dart.dart'; | 18 import 'package:analyzer/src/task/dart.dart'; |
19 import 'package:analyzer/src/task/html.dart'; | 19 import 'package:analyzer/src/task/html.dart'; |
20 import 'package:analyzer/task/dart.dart'; | 20 import 'package:analyzer/task/dart.dart'; |
21 import 'package:analyzer/task/general.dart'; | 21 import 'package:analyzer/task/general.dart'; |
22 import 'package:analyzer/task/model.dart'; | 22 import 'package:analyzer/task/model.dart'; |
23 import 'package:unittest/unittest.dart'; | 23 import 'package:unittest/unittest.dart'; |
24 | 24 |
25 import '../../generated/test_support.dart'; | 25 import '../../generated/test_support.dart'; |
26 import '../../reflective_tests.dart'; | 26 import '../../reflective_tests.dart'; |
| 27 import '../../utils.dart'; |
27 import '../context/abstract_context.dart'; | 28 import '../context/abstract_context.dart'; |
28 | 29 |
29 main() { | 30 main() { |
30 groupSep = ' | '; | 31 initializeTestEnvironment(); |
31 runReflectiveTests(BuildCompilationUnitElementTaskTest); | 32 runReflectiveTests(BuildCompilationUnitElementTaskTest); |
32 runReflectiveTests(BuildDirectiveElementsTaskTest); | 33 runReflectiveTests(BuildDirectiveElementsTaskTest); |
33 runReflectiveTests(BuildEnumMemberElementsTaskTest); | 34 runReflectiveTests(BuildEnumMemberElementsTaskTest); |
34 runReflectiveTests(BuildSourceExportClosureTaskTest); | 35 runReflectiveTests(BuildSourceExportClosureTaskTest); |
35 runReflectiveTests(BuildSourceImportExportClosureTaskTest); | 36 runReflectiveTests(BuildSourceImportExportClosureTaskTest); |
36 runReflectiveTests(BuildExportNamespaceTaskTest); | 37 runReflectiveTests(BuildExportNamespaceTaskTest); |
37 runReflectiveTests(BuildLibraryElementTaskTest); | 38 runReflectiveTests(BuildLibraryElementTaskTest); |
38 runReflectiveTests(BuildPublicNamespaceTaskTest); | 39 runReflectiveTests(BuildPublicNamespaceTaskTest); |
39 runReflectiveTests(BuildTypeProviderTaskTest); | 40 runReflectiveTests(BuildTypeProviderTaskTest); |
40 runReflectiveTests(ComputeConstantDependenciesTaskTest); | 41 runReflectiveTests(ComputeConstantDependenciesTaskTest); |
(...skipping 19 matching lines...) Expand all Loading... |
60 class BuildCompilationUnitElementTaskTest extends _AbstractDartTaskTest { | 61 class BuildCompilationUnitElementTaskTest extends _AbstractDartTaskTest { |
61 Source source; | 62 Source source; |
62 LibrarySpecificUnit target; | 63 LibrarySpecificUnit target; |
63 | 64 |
64 test_buildInputs() { | 65 test_buildInputs() { |
65 LibrarySpecificUnit target = | 66 LibrarySpecificUnit target = |
66 new LibrarySpecificUnit(emptySource, emptySource); | 67 new LibrarySpecificUnit(emptySource, emptySource); |
67 Map<String, TaskInput> inputs = | 68 Map<String, TaskInput> inputs = |
68 BuildCompilationUnitElementTask.buildInputs(target); | 69 BuildCompilationUnitElementTask.buildInputs(target); |
69 expect(inputs, isNotNull); | 70 expect(inputs, isNotNull); |
70 expect(inputs.keys, unorderedEquals( | 71 expect( |
71 [BuildCompilationUnitElementTask.PARSED_UNIT_INPUT_NAME])); | 72 inputs.keys, |
| 73 unorderedEquals( |
| 74 [BuildCompilationUnitElementTask.PARSED_UNIT_INPUT_NAME])); |
72 } | 75 } |
73 | 76 |
74 test_constructor() { | 77 test_constructor() { |
75 BuildCompilationUnitElementTask task = | 78 BuildCompilationUnitElementTask task = |
76 new BuildCompilationUnitElementTask(context, emptySource); | 79 new BuildCompilationUnitElementTask(context, emptySource); |
77 expect(task, isNotNull); | 80 expect(task, isNotNull); |
78 expect(task.context, context); | 81 expect(task.context, context); |
79 expect(task.target, emptySource); | 82 expect(task.target, emptySource); |
80 } | 83 } |
81 | 84 |
(...skipping 24 matching lines...) Expand all Loading... |
106 const C([p = 1]); | 109 const C([p = 1]); |
107 } | 110 } |
108 @x | 111 @x |
109 f() { | 112 f() { |
110 const z = 1; | 113 const z = 1; |
111 } | 114 } |
112 '''); | 115 '''); |
113 CompilationUnit unit = outputs[RESOLVED_UNIT1]; | 116 CompilationUnit unit = outputs[RESOLVED_UNIT1]; |
114 CompilationUnitElement unitElement = outputs[COMPILATION_UNIT_ELEMENT]; | 117 CompilationUnitElement unitElement = outputs[COMPILATION_UNIT_ELEMENT]; |
115 Annotation annotation = unit.declarations | 118 Annotation annotation = unit.declarations |
116 .firstWhere((m) => m is FunctionDeclaration).metadata[0]; | 119 .firstWhere((m) => m is FunctionDeclaration) |
| 120 .metadata[0]; |
117 List<ConstantEvaluationTarget> expectedConstants = [ | 121 List<ConstantEvaluationTarget> expectedConstants = [ |
118 unitElement.accessors.firstWhere((e) => e.isGetter).variable, | 122 unitElement.accessors.firstWhere((e) => e.isGetter).variable, |
119 unitElement.types[0].fields[0], | 123 unitElement.types[0].fields[0], |
120 unitElement.functions[0].localVariables[0], | 124 unitElement.functions[0].localVariables[0], |
121 unitElement.types[0].constructors[0], | 125 unitElement.types[0].constructors[0], |
122 new ConstantEvaluationTarget_Annotation( | 126 new ConstantEvaluationTarget_Annotation( |
123 context, source, source, annotation), | 127 context, source, source, annotation), |
124 unitElement.types[0].constructors[0].parameters[0] | 128 unitElement.types[0].constructors[0].parameters[0] |
125 ]; | 129 ]; |
126 expect( | 130 expect( |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 | 443 |
440 _getImportLibraryInput(Source source) { | 444 _getImportLibraryInput(Source source) { |
441 var key = BuildDirectiveElementsTask.IMPORTS_LIBRARY_ELEMENT_INPUT_NAME; | 445 var key = BuildDirectiveElementsTask.IMPORTS_LIBRARY_ELEMENT_INPUT_NAME; |
442 return task.inputs[key][source]; | 446 return task.inputs[key][source]; |
443 } | 447 } |
444 } | 448 } |
445 | 449 |
446 @reflectiveTest | 450 @reflectiveTest |
447 class BuildEnumMemberElementsTaskTest extends _AbstractDartTaskTest { | 451 class BuildEnumMemberElementsTaskTest extends _AbstractDartTaskTest { |
448 test_perform() { | 452 test_perform() { |
449 Source source = newSource('/test.dart', ''' | 453 Source source = newSource( |
| 454 '/test.dart', |
| 455 ''' |
450 enum MyEnum { | 456 enum MyEnum { |
451 A, B | 457 A, B |
452 } | 458 } |
453 '''); | 459 '''); |
454 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT2); | 460 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT2); |
455 expect(task, new isInstanceOf<BuildEnumMemberElementsTask>()); | 461 expect(task, new isInstanceOf<BuildEnumMemberElementsTask>()); |
456 CompilationUnit unit = outputs[RESOLVED_UNIT2]; | 462 CompilationUnit unit = outputs[RESOLVED_UNIT2]; |
457 // validate Element | 463 // validate Element |
458 ClassElement enumElement = unit.element.getEnum('MyEnum'); | 464 ClassElement enumElement = unit.element.getEnum('MyEnum'); |
459 List<FieldElement> fields = enumElement.fields; | 465 List<FieldElement> fields = enumElement.fields; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 PropertyAccessorElement getter = field.getter; | 507 PropertyAccessorElement getter = field.getter; |
502 expect(getter, isNotNull); | 508 expect(getter, isNotNull); |
503 expect(getter.variable, same(field)); | 509 expect(getter.variable, same(field)); |
504 expect(getter.type, isNotNull); | 510 expect(getter.type, isNotNull); |
505 } | 511 } |
506 } | 512 } |
507 | 513 |
508 @reflectiveTest | 514 @reflectiveTest |
509 class BuildExportNamespaceTaskTest extends _AbstractDartTaskTest { | 515 class BuildExportNamespaceTaskTest extends _AbstractDartTaskTest { |
510 test_perform_entryPoint() { | 516 test_perform_entryPoint() { |
511 Source sourceA = newSource('/a.dart', ''' | 517 Source sourceA = newSource( |
| 518 '/a.dart', |
| 519 ''' |
512 library lib_a; | 520 library lib_a; |
513 export 'b.dart'; | 521 export 'b.dart'; |
514 '''); | 522 '''); |
515 Source sourceB = newSource('/b.dart', ''' | 523 Source sourceB = newSource( |
| 524 '/b.dart', |
| 525 ''' |
516 library lib_b; | 526 library lib_b; |
517 main() {} | 527 main() {} |
518 '''); | 528 '''); |
519 computeResult(sourceA, LIBRARY_ELEMENT4); | 529 computeResult(sourceA, LIBRARY_ELEMENT4); |
520 expect(task, new isInstanceOf<BuildExportNamespaceTask>()); | 530 expect(task, new isInstanceOf<BuildExportNamespaceTask>()); |
521 // validate | 531 // validate |
522 { | 532 { |
523 LibraryElement library = outputs[LIBRARY_ELEMENT4]; | 533 LibraryElement library = outputs[LIBRARY_ELEMENT4]; |
524 FunctionElement entryPoint = library.entryPoint; | 534 FunctionElement entryPoint = library.entryPoint; |
525 expect(entryPoint, isNotNull); | 535 expect(entryPoint, isNotNull); |
526 expect(entryPoint.source, sourceB); | 536 expect(entryPoint.source, sourceB); |
527 } | 537 } |
528 } | 538 } |
529 | 539 |
530 test_perform_hideCombinator() { | 540 test_perform_hideCombinator() { |
531 Source sourceA = newSource('/a.dart', ''' | 541 Source sourceA = newSource( |
| 542 '/a.dart', |
| 543 ''' |
532 library lib_a; | 544 library lib_a; |
533 export 'b.dart' hide B1; | 545 export 'b.dart' hide B1; |
534 class A1 {} | 546 class A1 {} |
535 class A2 {} | 547 class A2 {} |
536 class _A3 {} | 548 class _A3 {} |
537 '''); | 549 '''); |
538 newSource('/b.dart', ''' | 550 newSource( |
| 551 '/b.dart', |
| 552 ''' |
539 library lib_b; | 553 library lib_b; |
540 class B1 {} | 554 class B1 {} |
541 class B2 {} | 555 class B2 {} |
542 class B3 {} | 556 class B3 {} |
543 class _B4 {} | 557 class _B4 {} |
544 '''); | 558 '''); |
545 newSource('/c.dart', ''' | 559 newSource( |
| 560 '/c.dart', |
| 561 ''' |
546 library lib_c; | 562 library lib_c; |
547 class C1 {} | 563 class C1 {} |
548 class C2 {} | 564 class C2 {} |
549 class C3 {} | 565 class C3 {} |
550 '''); | 566 '''); |
551 computeResult(sourceA, LIBRARY_ELEMENT4); | 567 computeResult(sourceA, LIBRARY_ELEMENT4); |
552 expect(task, new isInstanceOf<BuildExportNamespaceTask>()); | 568 expect(task, new isInstanceOf<BuildExportNamespaceTask>()); |
553 // validate | 569 // validate |
554 { | 570 { |
555 LibraryElement library = outputs[LIBRARY_ELEMENT4]; | 571 LibraryElement library = outputs[LIBRARY_ELEMENT4]; |
556 Namespace namespace = library.exportNamespace; | 572 Namespace namespace = library.exportNamespace; |
557 Iterable<String> definedKeys = namespace.definedNames.keys; | 573 Iterable<String> definedKeys = namespace.definedNames.keys; |
558 expect(definedKeys, unorderedEquals(['A1', 'A2', 'B2', 'B3'])); | 574 expect(definedKeys, unorderedEquals(['A1', 'A2', 'B2', 'B3'])); |
559 } | 575 } |
560 } | 576 } |
561 | 577 |
562 test_perform_showCombinator() { | 578 test_perform_showCombinator() { |
563 Source sourceA = newSource('/a.dart', ''' | 579 Source sourceA = newSource( |
| 580 '/a.dart', |
| 581 ''' |
564 library lib_a; | 582 library lib_a; |
565 export 'b.dart' show B1; | 583 export 'b.dart' show B1; |
566 class A1 {} | 584 class A1 {} |
567 class A2 {} | 585 class A2 {} |
568 class _A3 {} | 586 class _A3 {} |
569 '''); | 587 '''); |
570 newSource('/b.dart', ''' | 588 newSource( |
| 589 '/b.dart', |
| 590 ''' |
571 library lib_b; | 591 library lib_b; |
572 class B1 {} | 592 class B1 {} |
573 class B2 {} | 593 class B2 {} |
574 class _B3 {} | 594 class _B3 {} |
575 '''); | 595 '''); |
576 computeResult(sourceA, LIBRARY_ELEMENT4); | 596 computeResult(sourceA, LIBRARY_ELEMENT4); |
577 expect(task, new isInstanceOf<BuildExportNamespaceTask>()); | 597 expect(task, new isInstanceOf<BuildExportNamespaceTask>()); |
578 // validate | 598 // validate |
579 { | 599 { |
580 LibraryElement library = outputs[LIBRARY_ELEMENT4]; | 600 LibraryElement library = outputs[LIBRARY_ELEMENT4]; |
581 Namespace namespace = library.exportNamespace; | 601 Namespace namespace = library.exportNamespace; |
582 Iterable<String> definedKeys = namespace.definedNames.keys; | 602 Iterable<String> definedKeys = namespace.definedNames.keys; |
583 expect(definedKeys, unorderedEquals(['A1', 'A2', 'B1'])); | 603 expect(definedKeys, unorderedEquals(['A1', 'A2', 'B1'])); |
584 } | 604 } |
585 } | 605 } |
586 | 606 |
587 test_perform_showCombinator_setter() { | 607 test_perform_showCombinator_setter() { |
588 Source sourceA = newSource('/a.dart', ''' | 608 Source sourceA = newSource( |
| 609 '/a.dart', |
| 610 ''' |
589 library lib_a; | 611 library lib_a; |
590 export 'b.dart' show topLevelB; | 612 export 'b.dart' show topLevelB; |
591 class A {} | 613 class A {} |
592 '''); | 614 '''); |
593 newSource('/b.dart', ''' | 615 newSource( |
| 616 '/b.dart', |
| 617 ''' |
594 library lib_b; | 618 library lib_b; |
595 int topLevelB; | 619 int topLevelB; |
596 '''); | 620 '''); |
597 computeResult(sourceA, LIBRARY_ELEMENT4); | 621 computeResult(sourceA, LIBRARY_ELEMENT4); |
598 expect(task, new isInstanceOf<BuildExportNamespaceTask>()); | 622 expect(task, new isInstanceOf<BuildExportNamespaceTask>()); |
599 // validate | 623 // validate |
600 { | 624 { |
601 LibraryElement library = outputs[LIBRARY_ELEMENT4]; | 625 LibraryElement library = outputs[LIBRARY_ELEMENT4]; |
602 Namespace namespace = library.exportNamespace; | 626 Namespace namespace = library.exportNamespace; |
603 Iterable<String> definedKeys = namespace.definedNames.keys; | 627 Iterable<String> definedKeys = namespace.definedNames.keys; |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 // validate | 954 // validate |
931 LibraryElement library = outputs[LIBRARY_ELEMENT3]; | 955 LibraryElement library = outputs[LIBRARY_ELEMENT3]; |
932 Namespace namespace = library.publicNamespace; | 956 Namespace namespace = library.publicNamespace; |
933 expect(namespace.definedNames.keys, unorderedEquals(['a', 'd'])); | 957 expect(namespace.definedNames.keys, unorderedEquals(['a', 'd'])); |
934 } | 958 } |
935 } | 959 } |
936 | 960 |
937 @reflectiveTest | 961 @reflectiveTest |
938 class BuildSourceExportClosureTaskTest extends _AbstractDartTaskTest { | 962 class BuildSourceExportClosureTaskTest extends _AbstractDartTaskTest { |
939 test_perform_exportClosure() { | 963 test_perform_exportClosure() { |
940 Source sourceA = newSource('/a.dart', ''' | 964 Source sourceA = newSource( |
| 965 '/a.dart', |
| 966 ''' |
941 library lib_a; | 967 library lib_a; |
942 export 'b.dart'; | 968 export 'b.dart'; |
943 '''); | 969 '''); |
944 Source sourceB = newSource('/b.dart', ''' | 970 Source sourceB = newSource( |
| 971 '/b.dart', |
| 972 ''' |
945 library lib_b; | 973 library lib_b; |
946 export 'c.dart'; | 974 export 'c.dart'; |
947 '''); | 975 '''); |
948 Source sourceC = newSource('/c.dart', ''' | 976 Source sourceC = newSource( |
| 977 '/c.dart', |
| 978 ''' |
949 library lib_c; | 979 library lib_c; |
950 export 'a.dart'; | 980 export 'a.dart'; |
951 '''); | 981 '''); |
952 Source sourceD = newSource('/d.dart', ''' | 982 Source sourceD = newSource( |
| 983 '/d.dart', |
| 984 ''' |
953 library lib_d; | 985 library lib_d; |
954 '''); | 986 '''); |
955 // a.dart | 987 // a.dart |
956 { | 988 { |
957 computeResult(sourceA, EXPORT_SOURCE_CLOSURE); | 989 computeResult(sourceA, EXPORT_SOURCE_CLOSURE); |
958 expect(task, new isInstanceOf<BuildSourceExportClosureTask>()); | 990 expect(task, new isInstanceOf<BuildSourceExportClosureTask>()); |
959 List<Source> closure = outputs[EXPORT_SOURCE_CLOSURE]; | 991 List<Source> closure = outputs[EXPORT_SOURCE_CLOSURE]; |
960 expect(closure, unorderedEquals([sourceA, sourceB, sourceC])); | 992 expect(closure, unorderedEquals([sourceA, sourceB, sourceC])); |
961 } | 993 } |
962 // c.dart | 994 // c.dart |
963 { | 995 { |
964 computeResult(sourceC, EXPORT_SOURCE_CLOSURE); | 996 computeResult(sourceC, EXPORT_SOURCE_CLOSURE); |
965 expect(task, new isInstanceOf<BuildSourceExportClosureTask>()); | 997 expect(task, new isInstanceOf<BuildSourceExportClosureTask>()); |
966 List<Source> closure = outputs[EXPORT_SOURCE_CLOSURE]; | 998 List<Source> closure = outputs[EXPORT_SOURCE_CLOSURE]; |
967 expect(closure, unorderedEquals([sourceA, sourceB, sourceC])); | 999 expect(closure, unorderedEquals([sourceA, sourceB, sourceC])); |
968 } | 1000 } |
969 // d.dart | 1001 // d.dart |
970 { | 1002 { |
971 computeResult(sourceD, EXPORT_SOURCE_CLOSURE); | 1003 computeResult(sourceD, EXPORT_SOURCE_CLOSURE); |
972 expect(task, new isInstanceOf<BuildSourceExportClosureTask>()); | 1004 expect(task, new isInstanceOf<BuildSourceExportClosureTask>()); |
973 List<Source> closure = outputs[EXPORT_SOURCE_CLOSURE]; | 1005 List<Source> closure = outputs[EXPORT_SOURCE_CLOSURE]; |
974 expect(closure, unorderedEquals([sourceD])); | 1006 expect(closure, unorderedEquals([sourceD])); |
975 } | 1007 } |
976 } | 1008 } |
977 } | 1009 } |
978 | 1010 |
979 @reflectiveTest | 1011 @reflectiveTest |
980 class BuildSourceImportExportClosureTaskTest extends _AbstractDartTaskTest { | 1012 class BuildSourceImportExportClosureTaskTest extends _AbstractDartTaskTest { |
981 test_perform_importExportClosure() { | 1013 test_perform_importExportClosure() { |
982 Source sourceA = newSource('/a.dart', ''' | 1014 Source sourceA = newSource( |
| 1015 '/a.dart', |
| 1016 ''' |
983 library lib_a; | 1017 library lib_a; |
984 '''); | 1018 '''); |
985 Source sourceB = newSource('/b.dart', ''' | 1019 Source sourceB = newSource( |
| 1020 '/b.dart', |
| 1021 ''' |
986 library lib_b; | 1022 library lib_b; |
987 export 'a.dart'; | 1023 export 'a.dart'; |
988 '''); | 1024 '''); |
989 Source sourceC = newSource('/c.dart', ''' | 1025 Source sourceC = newSource( |
| 1026 '/c.dart', |
| 1027 ''' |
990 library lib_c; | 1028 library lib_c; |
991 import 'b.dart'; | 1029 import 'b.dart'; |
992 '''); | 1030 '''); |
993 Source coreSource = context.sourceFactory.resolveUri(null, 'dart:core'); | 1031 Source coreSource = context.sourceFactory.resolveUri(null, 'dart:core'); |
994 // c.dart | 1032 // c.dart |
995 { | 1033 { |
996 computeResult(sourceC, IMPORT_EXPORT_SOURCE_CLOSURE); | 1034 computeResult(sourceC, IMPORT_EXPORT_SOURCE_CLOSURE); |
997 expect(task, new isInstanceOf<BuildSourceImportExportClosureTask>()); | 1035 expect(task, new isInstanceOf<BuildSourceImportExportClosureTask>()); |
998 List<Source> closure = outputs[IMPORT_EXPORT_SOURCE_CLOSURE]; | 1036 List<Source> closure = outputs[IMPORT_EXPORT_SOURCE_CLOSURE]; |
999 expect(closure, contains(sourceA)); | 1037 expect(closure, contains(sourceA)); |
1000 expect(closure, contains(sourceB)); | 1038 expect(closure, contains(sourceB)); |
1001 expect(closure, contains(sourceC)); | 1039 expect(closure, contains(sourceC)); |
1002 expect(closure, contains(coreSource)); | 1040 expect(closure, contains(coreSource)); |
1003 } | 1041 } |
1004 // b.dart | 1042 // b.dart |
1005 { | 1043 { |
1006 computeResult(sourceB, IMPORT_EXPORT_SOURCE_CLOSURE); | 1044 computeResult(sourceB, IMPORT_EXPORT_SOURCE_CLOSURE); |
1007 expect(task, new isInstanceOf<BuildSourceImportExportClosureTask>()); | 1045 expect(task, new isInstanceOf<BuildSourceImportExportClosureTask>()); |
1008 List<Source> closure = outputs[IMPORT_EXPORT_SOURCE_CLOSURE]; | 1046 List<Source> closure = outputs[IMPORT_EXPORT_SOURCE_CLOSURE]; |
1009 expect(closure, contains(sourceA)); | 1047 expect(closure, contains(sourceA)); |
1010 expect(closure, contains(sourceB)); | 1048 expect(closure, contains(sourceB)); |
1011 expect(closure, contains(coreSource)); | 1049 expect(closure, contains(coreSource)); |
1012 } | 1050 } |
1013 } | 1051 } |
1014 | 1052 |
1015 test_perform_isClient_false() { | 1053 test_perform_isClient_false() { |
1016 Source sourceA = newSource('/a.dart', ''' | 1054 Source sourceA = newSource( |
| 1055 '/a.dart', |
| 1056 ''' |
1017 library lib_a; | 1057 library lib_a; |
1018 import 'b.dart'; | 1058 import 'b.dart'; |
1019 '''); | 1059 '''); |
1020 newSource('/b.dart', ''' | 1060 newSource( |
| 1061 '/b.dart', |
| 1062 ''' |
1021 library lib_b; | 1063 library lib_b; |
1022 '''); | 1064 '''); |
1023 computeResult(sourceA, IS_CLIENT); | 1065 computeResult(sourceA, IS_CLIENT); |
1024 expect(task, new isInstanceOf<BuildSourceImportExportClosureTask>()); | 1066 expect(task, new isInstanceOf<BuildSourceImportExportClosureTask>()); |
1025 expect(outputs[IS_CLIENT], isFalse); | 1067 expect(outputs[IS_CLIENT], isFalse); |
1026 } | 1068 } |
1027 | 1069 |
1028 test_perform_isClient_true_export_indirect() { | 1070 test_perform_isClient_true_export_indirect() { |
1029 newSource('/exports_html.dart', ''' | 1071 newSource( |
| 1072 '/exports_html.dart', |
| 1073 ''' |
1030 library lib_exports_html; | 1074 library lib_exports_html; |
1031 export 'dart:html'; | 1075 export 'dart:html'; |
1032 '''); | 1076 '''); |
1033 Source source = newSource('/test.dart', ''' | 1077 Source source = newSource( |
| 1078 '/test.dart', |
| 1079 ''' |
1034 import 'exports_html.dart'; | 1080 import 'exports_html.dart'; |
1035 '''); | 1081 '''); |
1036 computeResult(source, IS_CLIENT); | 1082 computeResult(source, IS_CLIENT); |
1037 expect(task, new isInstanceOf<BuildSourceImportExportClosureTask>()); | 1083 expect(task, new isInstanceOf<BuildSourceImportExportClosureTask>()); |
1038 expect(outputs[IS_CLIENT], isTrue); | 1084 expect(outputs[IS_CLIENT], isTrue); |
1039 } | 1085 } |
1040 | 1086 |
1041 test_perform_isClient_true_import_direct() { | 1087 test_perform_isClient_true_import_direct() { |
1042 Source sourceA = newSource('/a.dart', ''' | 1088 Source sourceA = newSource( |
| 1089 '/a.dart', |
| 1090 ''' |
1043 library lib_a; | 1091 library lib_a; |
1044 import 'dart:html'; | 1092 import 'dart:html'; |
1045 '''); | 1093 '''); |
1046 computeResult(sourceA, IS_CLIENT); | 1094 computeResult(sourceA, IS_CLIENT); |
1047 expect(task, new isInstanceOf<BuildSourceImportExportClosureTask>()); | 1095 expect(task, new isInstanceOf<BuildSourceImportExportClosureTask>()); |
1048 expect(outputs[IS_CLIENT], isTrue); | 1096 expect(outputs[IS_CLIENT], isTrue); |
1049 } | 1097 } |
1050 | 1098 |
1051 test_perform_isClient_true_import_indirect() { | 1099 test_perform_isClient_true_import_indirect() { |
1052 Source sourceA = newSource('/a.dart', ''' | 1100 Source sourceA = newSource( |
| 1101 '/a.dart', |
| 1102 ''' |
1053 library lib_a; | 1103 library lib_a; |
1054 import 'b.dart'; | 1104 import 'b.dart'; |
1055 '''); | 1105 '''); |
1056 newSource('/b.dart', ''' | 1106 newSource( |
| 1107 '/b.dart', |
| 1108 ''' |
1057 library lib_b; | 1109 library lib_b; |
1058 import 'dart:html'; | 1110 import 'dart:html'; |
1059 '''); | 1111 '''); |
1060 computeResult(sourceA, IS_CLIENT); | 1112 computeResult(sourceA, IS_CLIENT); |
1061 expect(task, new isInstanceOf<BuildSourceImportExportClosureTask>()); | 1113 expect(task, new isInstanceOf<BuildSourceImportExportClosureTask>()); |
1062 expect(outputs[IS_CLIENT], isTrue); | 1114 expect(outputs[IS_CLIENT], isTrue); |
1063 } | 1115 } |
1064 } | 1116 } |
1065 | 1117 |
1066 @reflectiveTest | 1118 @reflectiveTest |
(...skipping 17 matching lines...) Expand all Loading... |
1084 if (member is ClassDeclaration && member.name.name == className) { | 1136 if (member is ClassDeclaration && member.name.name == className) { |
1085 expect(member.metadata, hasLength(1)); | 1137 expect(member.metadata, hasLength(1)); |
1086 return member.metadata[0]; | 1138 return member.metadata[0]; |
1087 } | 1139 } |
1088 } | 1140 } |
1089 fail('Annotation not found'); | 1141 fail('Annotation not found'); |
1090 return null; | 1142 return null; |
1091 } | 1143 } |
1092 | 1144 |
1093 test_annotation_with_args() { | 1145 test_annotation_with_args() { |
1094 Source source = newSource('/test.dart', ''' | 1146 Source source = newSource( |
| 1147 '/test.dart', |
| 1148 ''' |
1095 const x = 1; | 1149 const x = 1; |
1096 @D(x) class C {} | 1150 @D(x) class C {} |
1097 class D { const D(value); } | 1151 class D { const D(value); } |
1098 '''); | 1152 '''); |
1099 // First compute the resolved unit for the source. | 1153 // First compute the resolved unit for the source. |
1100 LibrarySpecificUnit librarySpecificUnit = | 1154 LibrarySpecificUnit librarySpecificUnit = |
1101 new LibrarySpecificUnit(source, source); | 1155 new LibrarySpecificUnit(source, source); |
1102 computeResult(librarySpecificUnit, RESOLVED_UNIT1); | 1156 computeResult(librarySpecificUnit, RESOLVED_UNIT1); |
1103 CompilationUnit unit = outputs[RESOLVED_UNIT1]; | 1157 CompilationUnit unit = outputs[RESOLVED_UNIT1]; |
1104 // Find the elements for x and D's constructor, and the annotation on C. | 1158 // Find the elements for x and D's constructor, and the annotation on C. |
1105 List<PropertyAccessorElement> accessors = unit.element.accessors; | 1159 List<PropertyAccessorElement> accessors = unit.element.accessors; |
1106 Element x = accessors.firstWhere((PropertyAccessorElement accessor) => | 1160 Element x = accessors |
1107 accessor.isGetter && accessor.name == 'x').variable; | 1161 .firstWhere((PropertyAccessorElement accessor) => |
| 1162 accessor.isGetter && accessor.name == 'x') |
| 1163 .variable; |
1108 List<ClassElement> types = unit.element.types; | 1164 List<ClassElement> types = unit.element.types; |
1109 Element constructorForD = | 1165 Element constructorForD = |
1110 types.firstWhere((ClassElement cls) => cls.name == 'D').constructors[0]; | 1166 types.firstWhere((ClassElement cls) => cls.name == 'D').constructors[0]; |
1111 Annotation annotation = findClassAnnotation(unit, 'C'); | 1167 Annotation annotation = findClassAnnotation(unit, 'C'); |
1112 // Now compute the dependencies for the annotation, and check that it is | 1168 // Now compute the dependencies for the annotation, and check that it is |
1113 // the set [x, constructorForD]. | 1169 // the set [x, constructorForD]. |
1114 // TODO(paulberry): test librarySource != source | 1170 // TODO(paulberry): test librarySource != source |
1115 computeResult(new ConstantEvaluationTarget_Annotation( | 1171 computeResult( |
1116 context, source, source, annotation), CONSTANT_DEPENDENCIES); | 1172 new ConstantEvaluationTarget_Annotation( |
| 1173 context, source, source, annotation), |
| 1174 CONSTANT_DEPENDENCIES); |
1117 expect( | 1175 expect( |
1118 outputs[CONSTANT_DEPENDENCIES].toSet(), [x, constructorForD].toSet()); | 1176 outputs[CONSTANT_DEPENDENCIES].toSet(), [x, constructorForD].toSet()); |
1119 } | 1177 } |
1120 | 1178 |
1121 test_annotation_without_args() { | 1179 test_annotation_without_args() { |
1122 Source source = newSource('/test.dart', ''' | 1180 Source source = newSource( |
| 1181 '/test.dart', |
| 1182 ''' |
1123 const x = 1; | 1183 const x = 1; |
1124 @x class C {} | 1184 @x class C {} |
1125 '''); | 1185 '''); |
1126 // First compute the resolved unit for the source. | 1186 // First compute the resolved unit for the source. |
1127 LibrarySpecificUnit librarySpecificUnit = | 1187 LibrarySpecificUnit librarySpecificUnit = |
1128 new LibrarySpecificUnit(source, source); | 1188 new LibrarySpecificUnit(source, source); |
1129 computeResult(librarySpecificUnit, RESOLVED_UNIT1); | 1189 computeResult(librarySpecificUnit, RESOLVED_UNIT1); |
1130 CompilationUnit unit = outputs[RESOLVED_UNIT1]; | 1190 CompilationUnit unit = outputs[RESOLVED_UNIT1]; |
1131 // Find the element for x and the annotation on C. | 1191 // Find the element for x and the annotation on C. |
1132 List<PropertyAccessorElement> accessors = unit.element.accessors; | 1192 List<PropertyAccessorElement> accessors = unit.element.accessors; |
1133 Element x = accessors.firstWhere((PropertyAccessorElement accessor) => | 1193 Element x = accessors |
1134 accessor.isGetter && accessor.name == 'x').variable; | 1194 .firstWhere((PropertyAccessorElement accessor) => |
| 1195 accessor.isGetter && accessor.name == 'x') |
| 1196 .variable; |
1135 Annotation annotation = findClassAnnotation(unit, 'C'); | 1197 Annotation annotation = findClassAnnotation(unit, 'C'); |
1136 // Now compute the dependencies for the annotation, and check that it is | 1198 // Now compute the dependencies for the annotation, and check that it is |
1137 // the list [x]. | 1199 // the list [x]. |
1138 computeResult(new ConstantEvaluationTarget_Annotation( | 1200 computeResult( |
1139 context, source, source, annotation), CONSTANT_DEPENDENCIES); | 1201 new ConstantEvaluationTarget_Annotation( |
| 1202 context, source, source, annotation), |
| 1203 CONSTANT_DEPENDENCIES); |
1140 expect(outputs[CONSTANT_DEPENDENCIES], [x]); | 1204 expect(outputs[CONSTANT_DEPENDENCIES], [x]); |
1141 } | 1205 } |
1142 | 1206 |
1143 test_enumConstant() { | 1207 test_enumConstant() { |
1144 Source source = newSource('/test.dart', ''' | 1208 Source source = newSource( |
| 1209 '/test.dart', |
| 1210 ''' |
1145 enum E {A, B, C} | 1211 enum E {A, B, C} |
1146 '''); | 1212 '''); |
1147 // First compute the resolved unit for the source. | 1213 // First compute the resolved unit for the source. |
1148 LibrarySpecificUnit librarySpecificUnit = | 1214 LibrarySpecificUnit librarySpecificUnit = |
1149 new LibrarySpecificUnit(source, source); | 1215 new LibrarySpecificUnit(source, source); |
1150 computeResult(librarySpecificUnit, RESOLVED_UNIT2); | 1216 computeResult(librarySpecificUnit, RESOLVED_UNIT2); |
1151 CompilationUnit unit = outputs[RESOLVED_UNIT2]; | 1217 CompilationUnit unit = outputs[RESOLVED_UNIT2]; |
1152 // Find the element for 'A' | 1218 // Find the element for 'A' |
1153 EnumDeclaration enumDeclaration = unit.declarations[0]; | 1219 EnumDeclaration enumDeclaration = unit.declarations[0]; |
1154 EnumConstantDeclaration constantDeclaration = enumDeclaration.constants[0]; | 1220 EnumConstantDeclaration constantDeclaration = enumDeclaration.constants[0]; |
1155 FieldElement constantElement = constantDeclaration.element; | 1221 FieldElement constantElement = constantDeclaration.element; |
1156 // Now compute the dependencies for the constant and check that there are | 1222 // Now compute the dependencies for the constant and check that there are |
1157 // none. | 1223 // none. |
1158 computeResult(constantElement, CONSTANT_DEPENDENCIES); | 1224 computeResult(constantElement, CONSTANT_DEPENDENCIES); |
1159 expect(outputs[CONSTANT_DEPENDENCIES], isEmpty); | 1225 expect(outputs[CONSTANT_DEPENDENCIES], isEmpty); |
1160 } | 1226 } |
1161 | 1227 |
1162 test_perform() { | 1228 test_perform() { |
1163 Source source = newSource('/test.dart', ''' | 1229 Source source = newSource( |
| 1230 '/test.dart', |
| 1231 ''' |
1164 const x = y; | 1232 const x = y; |
1165 const y = 1; | 1233 const y = 1; |
1166 '''); | 1234 '''); |
1167 // First compute the resolved unit for the source. | 1235 // First compute the resolved unit for the source. |
1168 LibrarySpecificUnit librarySpecificUnit = | 1236 LibrarySpecificUnit librarySpecificUnit = |
1169 new LibrarySpecificUnit(source, source); | 1237 new LibrarySpecificUnit(source, source); |
1170 computeResult(librarySpecificUnit, RESOLVED_UNIT1); | 1238 computeResult(librarySpecificUnit, RESOLVED_UNIT1); |
1171 CompilationUnit unit = outputs[RESOLVED_UNIT1]; | 1239 CompilationUnit unit = outputs[RESOLVED_UNIT1]; |
1172 // Find the elements for the constants x and y. | 1240 // Find the elements for the constants x and y. |
1173 List<PropertyAccessorElement> accessors = unit.element.accessors; | 1241 List<PropertyAccessorElement> accessors = unit.element.accessors; |
1174 Element x = accessors.firstWhere((PropertyAccessorElement accessor) => | 1242 Element x = accessors |
1175 accessor.isGetter && accessor.name == 'x').variable; | 1243 .firstWhere((PropertyAccessorElement accessor) => |
1176 Element y = accessors.firstWhere((PropertyAccessorElement accessor) => | 1244 accessor.isGetter && accessor.name == 'x') |
1177 accessor.isGetter && accessor.name == 'y').variable; | 1245 .variable; |
| 1246 Element y = accessors |
| 1247 .firstWhere((PropertyAccessorElement accessor) => |
| 1248 accessor.isGetter && accessor.name == 'y') |
| 1249 .variable; |
1178 // Now compute the dependencies for x, and check that it is the list [y]. | 1250 // Now compute the dependencies for x, and check that it is the list [y]. |
1179 computeResult(x, CONSTANT_DEPENDENCIES); | 1251 computeResult(x, CONSTANT_DEPENDENCIES); |
1180 expect(outputs[CONSTANT_DEPENDENCIES], [y]); | 1252 expect(outputs[CONSTANT_DEPENDENCIES], [y]); |
1181 } | 1253 } |
1182 } | 1254 } |
1183 | 1255 |
1184 @reflectiveTest | 1256 @reflectiveTest |
1185 class ComputeConstantValueTaskTest extends _AbstractDartTaskTest { | 1257 class ComputeConstantValueTaskTest extends _AbstractDartTaskTest { |
1186 EvaluationResultImpl computeClassAnnotation( | 1258 EvaluationResultImpl computeClassAnnotation( |
1187 Source source, CompilationUnit unit, String className) { | 1259 Source source, CompilationUnit unit, String className) { |
1188 for (CompilationUnitMember member in unit.declarations) { | 1260 for (CompilationUnitMember member in unit.declarations) { |
1189 if (member is ClassDeclaration && member.name.name == className) { | 1261 if (member is ClassDeclaration && member.name.name == className) { |
1190 expect(member.metadata, hasLength(1)); | 1262 expect(member.metadata, hasLength(1)); |
1191 Annotation annotation = member.metadata[0]; | 1263 Annotation annotation = member.metadata[0]; |
1192 ConstantEvaluationTarget_Annotation target = | 1264 ConstantEvaluationTarget_Annotation target = |
1193 new ConstantEvaluationTarget_Annotation( | 1265 new ConstantEvaluationTarget_Annotation( |
1194 context, source, source, annotation); | 1266 context, source, source, annotation); |
1195 computeResult(target, CONSTANT_VALUE); | 1267 computeResult(target, CONSTANT_VALUE); |
1196 expect(outputs[CONSTANT_VALUE], same(target)); | 1268 expect(outputs[CONSTANT_VALUE], same(target)); |
1197 EvaluationResultImpl evaluationResult = | 1269 EvaluationResultImpl evaluationResult = (annotation.elementAnnotation |
1198 (annotation.elementAnnotation as ElementAnnotationImpl).evaluationRe
sult; | 1270 as ElementAnnotationImpl).evaluationResult; |
1199 return evaluationResult; | 1271 return evaluationResult; |
1200 } | 1272 } |
1201 } | 1273 } |
1202 fail('Annotation not found'); | 1274 fail('Annotation not found'); |
1203 return null; | 1275 return null; |
1204 } | 1276 } |
1205 | 1277 |
1206 test_annotation_non_const_constructor() { | 1278 test_annotation_non_const_constructor() { |
1207 // Calling a non-const constructor from an annotation that is illegal, but | 1279 // Calling a non-const constructor from an annotation that is illegal, but |
1208 // shouldn't crash analysis. | 1280 // shouldn't crash analysis. |
1209 Source source = newSource('/test.dart', ''' | 1281 Source source = newSource( |
| 1282 '/test.dart', |
| 1283 ''' |
1210 class A { | 1284 class A { |
1211 final int i; | 1285 final int i; |
1212 A(this.i); | 1286 A(this.i); |
1213 } | 1287 } |
1214 | 1288 |
1215 @A(5) | 1289 @A(5) |
1216 class C {} | 1290 class C {} |
1217 '''); | 1291 '''); |
1218 // First compute the resolved unit for the source. | 1292 // First compute the resolved unit for the source. |
1219 CompilationUnit unit = _resolveSource(source); | 1293 CompilationUnit unit = _resolveSource(source); |
1220 // Compute the constant value of the annotation on C. | 1294 // Compute the constant value of the annotation on C. |
1221 EvaluationResultImpl evaluationResult = | 1295 EvaluationResultImpl evaluationResult = |
1222 computeClassAnnotation(source, unit, 'C'); | 1296 computeClassAnnotation(source, unit, 'C'); |
1223 // And check that it has no value stored in it. | 1297 // And check that it has no value stored in it. |
1224 expect(evaluationResult, isNotNull); | 1298 expect(evaluationResult, isNotNull); |
1225 expect(evaluationResult.value, isNull); | 1299 expect(evaluationResult.value, isNull); |
1226 } | 1300 } |
1227 | 1301 |
1228 test_annotation_with_args() { | 1302 test_annotation_with_args() { |
1229 Source source = newSource('/test.dart', ''' | 1303 Source source = newSource( |
| 1304 '/test.dart', |
| 1305 ''' |
1230 const x = 1; | 1306 const x = 1; |
1231 @D(x) class C {} | 1307 @D(x) class C {} |
1232 class D { | 1308 class D { |
1233 const D(this.value); | 1309 const D(this.value); |
1234 final value; | 1310 final value; |
1235 } | 1311 } |
1236 '''); | 1312 '''); |
1237 // First compute the resolved unit for the source. | 1313 // First compute the resolved unit for the source. |
1238 CompilationUnit unit = _resolveSource(source); | 1314 CompilationUnit unit = _resolveSource(source); |
1239 // Compute the constant value of the annotation on C. | 1315 // Compute the constant value of the annotation on C. |
1240 EvaluationResultImpl evaluationResult = | 1316 EvaluationResultImpl evaluationResult = |
1241 computeClassAnnotation(source, unit, 'C'); | 1317 computeClassAnnotation(source, unit, 'C'); |
1242 // And check that it has the expected value. | 1318 // And check that it has the expected value. |
1243 expect(evaluationResult, isNotNull); | 1319 expect(evaluationResult, isNotNull); |
1244 expect(evaluationResult.value, isNotNull); | 1320 expect(evaluationResult.value, isNotNull); |
1245 expect(evaluationResult.value.type, isNotNull); | 1321 expect(evaluationResult.value.type, isNotNull); |
1246 expect(evaluationResult.value.type.name, 'D'); | 1322 expect(evaluationResult.value.type.name, 'D'); |
1247 expect(evaluationResult.value.fields, contains('value')); | 1323 expect(evaluationResult.value.fields, contains('value')); |
1248 expect(evaluationResult.value.fields['value'].intValue, 1); | 1324 expect(evaluationResult.value.fields['value'].intValue, 1); |
1249 } | 1325 } |
1250 | 1326 |
1251 test_annotation_without_args() { | 1327 test_annotation_without_args() { |
1252 Source source = newSource('/test.dart', ''' | 1328 Source source = newSource( |
| 1329 '/test.dart', |
| 1330 ''' |
1253 const x = 1; | 1331 const x = 1; |
1254 @x class C {} | 1332 @x class C {} |
1255 '''); | 1333 '''); |
1256 // First compute the resolved unit for the source. | 1334 // First compute the resolved unit for the source. |
1257 CompilationUnit unit = _resolveSource(source); | 1335 CompilationUnit unit = _resolveSource(source); |
1258 // Compute the constant value of the annotation on C. | 1336 // Compute the constant value of the annotation on C. |
1259 EvaluationResultImpl evaluationResult = | 1337 EvaluationResultImpl evaluationResult = |
1260 computeClassAnnotation(source, unit, 'C'); | 1338 computeClassAnnotation(source, unit, 'C'); |
1261 // And check that it has the expected value. | 1339 // And check that it has the expected value. |
1262 expect(evaluationResult, isNotNull); | 1340 expect(evaluationResult, isNotNull); |
1263 expect(evaluationResult.value, isNotNull); | 1341 expect(evaluationResult.value, isNotNull); |
1264 expect(evaluationResult.value.intValue, 1); | 1342 expect(evaluationResult.value.intValue, 1); |
1265 } | 1343 } |
1266 | 1344 |
1267 test_circular_reference() { | 1345 test_circular_reference() { |
1268 _checkCircularities('x', ['y'], ''' | 1346 _checkCircularities( |
| 1347 'x', |
| 1348 ['y'], |
| 1349 ''' |
1269 const x = y + 1; | 1350 const x = y + 1; |
1270 const y = x + 1; | 1351 const y = x + 1; |
1271 '''); | 1352 '''); |
1272 } | 1353 } |
1273 | 1354 |
1274 test_circular_reference_one_element() { | 1355 test_circular_reference_one_element() { |
1275 // See dartbug.com/23490. | 1356 // See dartbug.com/23490. |
1276 _checkCircularities('x', [], 'const x = x;'); | 1357 _checkCircularities('x', [], 'const x = x;'); |
1277 } | 1358 } |
1278 | 1359 |
1279 test_circular_reference_strongly_connected_component() { | 1360 test_circular_reference_strongly_connected_component() { |
1280 // When there is a circularity, all elements in the strongly connected | 1361 // When there is a circularity, all elements in the strongly connected |
1281 // component should be marked as having an error. | 1362 // component should be marked as having an error. |
1282 _checkCircularities('a', ['b', 'c', 'd'], ''' | 1363 _checkCircularities( |
| 1364 'a', |
| 1365 ['b', 'c', 'd'], |
| 1366 ''' |
1283 const a = b; | 1367 const a = b; |
1284 const b = c + d; | 1368 const b = c + d; |
1285 const c = a; | 1369 const c = a; |
1286 const d = a; | 1370 const d = a; |
1287 '''); | 1371 '''); |
1288 } | 1372 } |
1289 | 1373 |
1290 test_const_constructor_calls_implicit_super_constructor_implicitly() { | 1374 test_const_constructor_calls_implicit_super_constructor_implicitly() { |
1291 // Note: the situation below is a compile-time error (since the synthetic | 1375 // Note: the situation below is a compile-time error (since the synthetic |
1292 // constructor for Base is non-const), but we need to handle it without | 1376 // constructor for Base is non-const), but we need to handle it without |
1293 // throwing an exception. | 1377 // throwing an exception. |
1294 EvaluationResultImpl evaluationResult = _computeTopLevelVariableConstValue( | 1378 EvaluationResultImpl evaluationResult = _computeTopLevelVariableConstValue( |
1295 'x', ''' | 1379 'x', |
| 1380 ''' |
1296 class Base {} | 1381 class Base {} |
1297 class Derived extends Base { | 1382 class Derived extends Base { |
1298 const Derived(); | 1383 const Derived(); |
1299 } | 1384 } |
1300 const x = const Derived(); | 1385 const x = const Derived(); |
1301 '''); | 1386 '''); |
1302 expect(evaluationResult, isNotNull); | 1387 expect(evaluationResult, isNotNull); |
1303 } | 1388 } |
1304 | 1389 |
1305 test_dependency() { | 1390 test_dependency() { |
1306 EvaluationResultImpl evaluationResult = _computeTopLevelVariableConstValue( | 1391 EvaluationResultImpl evaluationResult = _computeTopLevelVariableConstValue( |
1307 'x', ''' | 1392 'x', |
| 1393 ''' |
1308 const x = y + 1; | 1394 const x = y + 1; |
1309 const y = 1; | 1395 const y = 1; |
1310 '''); | 1396 '''); |
1311 expect(evaluationResult, isNotNull); | 1397 expect(evaluationResult, isNotNull); |
1312 expect(evaluationResult.value, isNotNull); | 1398 expect(evaluationResult.value, isNotNull); |
1313 expect(evaluationResult.value.intValue, 2); | 1399 expect(evaluationResult.value.intValue, 2); |
1314 } | 1400 } |
1315 | 1401 |
1316 test_external_const_factory() { | 1402 test_external_const_factory() { |
1317 EvaluationResultImpl evaluationResult = _computeTopLevelVariableConstValue( | 1403 EvaluationResultImpl evaluationResult = _computeTopLevelVariableConstValue( |
1318 'x', ''' | 1404 'x', |
| 1405 ''' |
1319 const x = const C.foo(); | 1406 const x = const C.foo(); |
1320 | 1407 |
1321 class C extends B { | 1408 class C extends B { |
1322 external const factory C.foo(); | 1409 external const factory C.foo(); |
1323 } | 1410 } |
1324 | 1411 |
1325 class B {} | 1412 class B {} |
1326 '''); | 1413 '''); |
1327 expect(evaluationResult, isNotNull); | 1414 expect(evaluationResult, isNotNull); |
1328 } | 1415 } |
1329 | 1416 |
1330 test_simple_constant() { | 1417 test_simple_constant() { |
1331 EvaluationResultImpl evaluationResult = _computeTopLevelVariableConstValue( | 1418 EvaluationResultImpl evaluationResult = _computeTopLevelVariableConstValue( |
1332 'x', ''' | 1419 'x', |
| 1420 ''' |
1333 const x = 1; | 1421 const x = 1; |
1334 '''); | 1422 '''); |
1335 expect(evaluationResult, isNotNull); | 1423 expect(evaluationResult, isNotNull); |
1336 expect(evaluationResult.value, isNotNull); | 1424 expect(evaluationResult.value, isNotNull); |
1337 expect(evaluationResult.value.intValue, 1); | 1425 expect(evaluationResult.value.intValue, 1); |
1338 } | 1426 } |
1339 | 1427 |
1340 void _checkCircularities( | 1428 void _checkCircularities( |
1341 String variableName, List<String> otherVariables, String content) { | 1429 String variableName, List<String> otherVariables, String content) { |
1342 // Evaluating the first constant should produce an error. | 1430 // Evaluating the first constant should produce an error. |
1343 CompilationUnit unit = _resolveUnit(content); | 1431 CompilationUnit unit = _resolveUnit(content); |
1344 _expectCircularityError(_evaluateConstant(unit, variableName)); | 1432 _expectCircularityError(_evaluateConstant(unit, variableName)); |
1345 // And all the other constants involved in the strongly connected component | 1433 // And all the other constants involved in the strongly connected component |
1346 // should be set to the same error state. | 1434 // should be set to the same error state. |
1347 for (String otherVariableName in otherVariables) { | 1435 for (String otherVariableName in otherVariables) { |
1348 PropertyInducingElement otherVariableElement = | 1436 PropertyInducingElement otherVariableElement = |
1349 _findVariable(unit, otherVariableName); | 1437 _findVariable(unit, otherVariableName); |
1350 _expectCircularityError( | 1438 _expectCircularityError((otherVariableElement |
1351 (otherVariableElement as TopLevelVariableElementImpl).evaluationResult
); | 1439 as TopLevelVariableElementImpl).evaluationResult); |
1352 } | 1440 } |
1353 } | 1441 } |
1354 | 1442 |
1355 EvaluationResultImpl _computeTopLevelVariableConstValue( | 1443 EvaluationResultImpl _computeTopLevelVariableConstValue( |
1356 String variableName, String content) { | 1444 String variableName, String content) { |
1357 return _evaluateConstant(_resolveUnit(content), variableName); | 1445 return _evaluateConstant(_resolveUnit(content), variableName); |
1358 } | 1446 } |
1359 | 1447 |
1360 EvaluationResultImpl _evaluateConstant( | 1448 EvaluationResultImpl _evaluateConstant( |
1361 CompilationUnit unit, String variableName) { | 1449 CompilationUnit unit, String variableName) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 List<Source> containingLibraries = outputs[CONTAINING_LIBRARIES]; | 1558 List<Source> containingLibraries = outputs[CONTAINING_LIBRARIES]; |
1471 expect(containingLibraries, unorderedEquals([library])); | 1559 expect(containingLibraries, unorderedEquals([library])); |
1472 } | 1560 } |
1473 } | 1561 } |
1474 | 1562 |
1475 @reflectiveTest | 1563 @reflectiveTest |
1476 class DartErrorsTaskTest extends _AbstractDartTaskTest { | 1564 class DartErrorsTaskTest extends _AbstractDartTaskTest { |
1477 test_buildInputs() { | 1565 test_buildInputs() { |
1478 Map<String, TaskInput> inputs = DartErrorsTask.buildInputs(emptySource); | 1566 Map<String, TaskInput> inputs = DartErrorsTask.buildInputs(emptySource); |
1479 expect(inputs, isNotNull); | 1567 expect(inputs, isNotNull); |
1480 expect(inputs.keys, unorderedEquals([ | 1568 expect( |
1481 DartErrorsTask.BUILD_DIRECTIVES_ERRORS_INPUT, | 1569 inputs.keys, |
1482 DartErrorsTask.BUILD_LIBRARY_ERRORS_INPUT, | 1570 unorderedEquals([ |
1483 DartErrorsTask.PARSE_ERRORS_INPUT, | 1571 DartErrorsTask.BUILD_DIRECTIVES_ERRORS_INPUT, |
1484 DartErrorsTask.SCAN_ERRORS_INPUT, | 1572 DartErrorsTask.BUILD_LIBRARY_ERRORS_INPUT, |
1485 DartErrorsTask.LIBRARY_UNIT_ERRORS_INPUT | 1573 DartErrorsTask.PARSE_ERRORS_INPUT, |
1486 ])); | 1574 DartErrorsTask.SCAN_ERRORS_INPUT, |
| 1575 DartErrorsTask.LIBRARY_UNIT_ERRORS_INPUT |
| 1576 ])); |
1487 } | 1577 } |
1488 | 1578 |
1489 test_constructor() { | 1579 test_constructor() { |
1490 DartErrorsTask task = new DartErrorsTask(context, emptySource); | 1580 DartErrorsTask task = new DartErrorsTask(context, emptySource); |
1491 expect(task, isNotNull); | 1581 expect(task, isNotNull); |
1492 expect(task.context, context); | 1582 expect(task.context, context); |
1493 expect(task.target, emptySource); | 1583 expect(task.target, emptySource); |
1494 } | 1584 } |
1495 | 1585 |
1496 test_createTask() { | 1586 test_createTask() { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1534 List<AnalysisError> errors = outputs[DART_ERRORS]; | 1624 List<AnalysisError> errors = outputs[DART_ERRORS]; |
1535 // This should contain only the errors in the part file, not the ones in the | 1625 // This should contain only the errors in the part file, not the ones in the |
1536 // library. | 1626 // library. |
1537 expect(errors, hasLength(1)); | 1627 expect(errors, hasLength(1)); |
1538 } | 1628 } |
1539 } | 1629 } |
1540 | 1630 |
1541 @reflectiveTest | 1631 @reflectiveTest |
1542 class EvaluateUnitConstantsTaskTest extends _AbstractDartTaskTest { | 1632 class EvaluateUnitConstantsTaskTest extends _AbstractDartTaskTest { |
1543 test_perform() { | 1633 test_perform() { |
1544 Source source = newSource('/test.dart', ''' | 1634 Source source = newSource( |
| 1635 '/test.dart', |
| 1636 ''' |
1545 class C { | 1637 class C { |
1546 const C(); | 1638 const C(); |
1547 } | 1639 } |
1548 | 1640 |
1549 @x | 1641 @x |
1550 f() {} | 1642 f() {} |
1551 | 1643 |
1552 const x = const C(); | 1644 const x = const C(); |
1553 '''); | 1645 '''); |
1554 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 1646 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
1555 computeResult(target, RESOLVED_UNIT); | 1647 computeResult(target, RESOLVED_UNIT); |
1556 expect(task, new isInstanceOf<EvaluateUnitConstantsTask>()); | 1648 expect(task, new isInstanceOf<EvaluateUnitConstantsTask>()); |
1557 CompilationUnit unit = outputs[RESOLVED_UNIT]; | 1649 CompilationUnit unit = outputs[RESOLVED_UNIT]; |
1558 CompilationUnitElement unitElement = unit.element; | 1650 CompilationUnitElement unitElement = unit.element; |
1559 expect((unitElement.types[0].constructors[ | 1651 expect( |
1560 0] as ConstructorElementImpl).isCycleFree, isTrue); | 1652 (unitElement.types[0].constructors[0] as ConstructorElementImpl) |
1561 expect((unitElement.functions[0].metadata[ | 1653 .isCycleFree, |
1562 0] as ElementAnnotationImpl).evaluationResult, isNotNull); | 1654 isTrue); |
1563 expect((unitElement.topLevelVariables[ | 1655 expect( |
1564 0] as TopLevelVariableElementImpl).evaluationResult, isNotNull); | 1656 (unitElement.functions[0].metadata[0] as ElementAnnotationImpl) |
| 1657 .evaluationResult, |
| 1658 isNotNull); |
| 1659 expect( |
| 1660 (unitElement.topLevelVariables[0] as TopLevelVariableElementImpl) |
| 1661 .evaluationResult, |
| 1662 isNotNull); |
1565 } | 1663 } |
1566 } | 1664 } |
1567 | 1665 |
1568 @reflectiveTest | 1666 @reflectiveTest |
1569 class GatherUsedImportedElementsTaskTest extends _AbstractDartTaskTest { | 1667 class GatherUsedImportedElementsTaskTest extends _AbstractDartTaskTest { |
1570 UsedImportedElements usedElements; | 1668 UsedImportedElements usedElements; |
1571 Set<String> usedElementNames; | 1669 Set<String> usedElementNames; |
1572 | 1670 |
1573 test_perform() { | 1671 test_perform() { |
1574 newSource('/a.dart', r''' | 1672 newSource( |
| 1673 '/a.dart', |
| 1674 r''' |
1575 library lib_a; | 1675 library lib_a; |
1576 class A {} | 1676 class A {} |
1577 '''); | 1677 '''); |
1578 newSource('/b.dart', r''' | 1678 newSource( |
| 1679 '/b.dart', |
| 1680 r''' |
1579 library lib_b; | 1681 library lib_b; |
1580 class B {} | 1682 class B {} |
1581 '''); | 1683 '''); |
1582 Source source = newSource('/test.dart', r''' | 1684 Source source = newSource( |
| 1685 '/test.dart', |
| 1686 r''' |
1583 import 'a.dart'; | 1687 import 'a.dart'; |
1584 import 'b.dart'; | 1688 import 'b.dart'; |
1585 main() { | 1689 main() { |
1586 new A(); | 1690 new A(); |
1587 }'''); | 1691 }'''); |
1588 _computeUsedElements(source); | 1692 _computeUsedElements(source); |
1589 // validate | 1693 // validate |
1590 expect(usedElementNames, unorderedEquals(['A'])); | 1694 expect(usedElementNames, unorderedEquals(['A'])); |
1591 } | 1695 } |
1592 | 1696 |
1593 void _computeUsedElements(Source source) { | 1697 void _computeUsedElements(Source source) { |
1594 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 1698 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
1595 computeResult(target, USED_IMPORTED_ELEMENTS); | 1699 computeResult(target, USED_IMPORTED_ELEMENTS); |
1596 expect(task, new isInstanceOf<GatherUsedImportedElementsTask>()); | 1700 expect(task, new isInstanceOf<GatherUsedImportedElementsTask>()); |
1597 usedElements = outputs[USED_IMPORTED_ELEMENTS]; | 1701 usedElements = outputs[USED_IMPORTED_ELEMENTS]; |
1598 usedElementNames = usedElements.elements.map((e) => e.name).toSet(); | 1702 usedElementNames = usedElements.elements.map((e) => e.name).toSet(); |
1599 } | 1703 } |
1600 } | 1704 } |
1601 | 1705 |
1602 @reflectiveTest | 1706 @reflectiveTest |
1603 class GatherUsedLocalElementsTaskTest extends _AbstractDartTaskTest { | 1707 class GatherUsedLocalElementsTaskTest extends _AbstractDartTaskTest { |
1604 UsedLocalElements usedElements; | 1708 UsedLocalElements usedElements; |
1605 Set<String> usedElementNames; | 1709 Set<String> usedElementNames; |
1606 | 1710 |
1607 test_perform_localVariable() { | 1711 test_perform_localVariable() { |
1608 Source source = newSource('/test.dart', r''' | 1712 Source source = newSource( |
| 1713 '/test.dart', |
| 1714 r''' |
1609 main() { | 1715 main() { |
1610 var v1 = 1; | 1716 var v1 = 1; |
1611 var v2 = 2; | 1717 var v2 = 2; |
1612 print(v2); | 1718 print(v2); |
1613 }'''); | 1719 }'''); |
1614 _computeUsedElements(source); | 1720 _computeUsedElements(source); |
1615 // validate | 1721 // validate |
1616 expect(usedElementNames, unorderedEquals(['v2'])); | 1722 expect(usedElementNames, unorderedEquals(['v2'])); |
1617 } | 1723 } |
1618 | 1724 |
1619 test_perform_method() { | 1725 test_perform_method() { |
1620 Source source = newSource('/test.dart', r''' | 1726 Source source = newSource( |
| 1727 '/test.dart', |
| 1728 r''' |
1621 class A { | 1729 class A { |
1622 _m1() {} | 1730 _m1() {} |
1623 _m2() {} | 1731 _m2() {} |
1624 } | 1732 } |
1625 | 1733 |
1626 main(A a, p) { | 1734 main(A a, p) { |
1627 a._m2(); | 1735 a._m2(); |
1628 p._m3(); | 1736 p._m3(); |
1629 } | 1737 } |
1630 '''); | 1738 '''); |
1631 _computeUsedElements(source); | 1739 _computeUsedElements(source); |
1632 // validate | 1740 // validate |
1633 expect(usedElementNames, unorderedEquals(['A', 'a', 'p', '_m2'])); | 1741 expect(usedElementNames, unorderedEquals(['A', 'a', 'p', '_m2'])); |
1634 expect(usedElements.members, unorderedEquals(['_m2', '_m3'])); | 1742 expect(usedElements.members, unorderedEquals(['_m2', '_m3'])); |
1635 } | 1743 } |
1636 | 1744 |
1637 void _computeUsedElements(Source source) { | 1745 void _computeUsedElements(Source source) { |
1638 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 1746 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
1639 computeResult(target, USED_LOCAL_ELEMENTS); | 1747 computeResult(target, USED_LOCAL_ELEMENTS); |
1640 expect(task, new isInstanceOf<GatherUsedLocalElementsTask>()); | 1748 expect(task, new isInstanceOf<GatherUsedLocalElementsTask>()); |
1641 usedElements = outputs[USED_LOCAL_ELEMENTS]; | 1749 usedElements = outputs[USED_LOCAL_ELEMENTS]; |
1642 usedElementNames = usedElements.elements.map((e) => e.name).toSet(); | 1750 usedElementNames = usedElements.elements.map((e) => e.name).toSet(); |
1643 } | 1751 } |
1644 } | 1752 } |
1645 | 1753 |
1646 @reflectiveTest | 1754 @reflectiveTest |
1647 class GenerateHintsTaskTest extends _AbstractDartTaskTest { | 1755 class GenerateHintsTaskTest extends _AbstractDartTaskTest { |
1648 test_perform_bestPractices_missingReturn() { | 1756 test_perform_bestPractices_missingReturn() { |
1649 Source source = newSource('/test.dart', ''' | 1757 Source source = newSource( |
| 1758 '/test.dart', |
| 1759 ''' |
1650 int main() { | 1760 int main() { |
1651 } | 1761 } |
1652 '''); | 1762 '''); |
1653 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 1763 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
1654 computeResult(target, HINTS); | 1764 computeResult(target, HINTS); |
1655 expect(task, new isInstanceOf<GenerateHintsTask>()); | 1765 expect(task, new isInstanceOf<GenerateHintsTask>()); |
1656 // validate | 1766 // validate |
1657 _fillErrorListener(HINTS); | 1767 _fillErrorListener(HINTS); |
1658 errorListener.assertErrorsWithCodes(<ErrorCode>[HintCode.MISSING_RETURN]); | 1768 errorListener.assertErrorsWithCodes(<ErrorCode>[HintCode.MISSING_RETURN]); |
1659 } | 1769 } |
1660 | 1770 |
1661 test_perform_dart2js() { | 1771 test_perform_dart2js() { |
1662 Source source = newSource('/test.dart', ''' | 1772 Source source = newSource( |
| 1773 '/test.dart', |
| 1774 ''' |
1663 main(p) { | 1775 main(p) { |
1664 if (p is double) { | 1776 if (p is double) { |
1665 print('double'); | 1777 print('double'); |
1666 } | 1778 } |
1667 } | 1779 } |
1668 '''); | 1780 '''); |
1669 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 1781 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
1670 computeResult(target, HINTS); | 1782 computeResult(target, HINTS); |
1671 expect(task, new isInstanceOf<GenerateHintsTask>()); | 1783 expect(task, new isInstanceOf<GenerateHintsTask>()); |
1672 // validate | 1784 // validate |
1673 _fillErrorListener(HINTS); | 1785 _fillErrorListener(HINTS); |
1674 errorListener.assertErrorsWithCodes(<ErrorCode>[HintCode.IS_DOUBLE]); | 1786 errorListener.assertErrorsWithCodes(<ErrorCode>[HintCode.IS_DOUBLE]); |
1675 } | 1787 } |
1676 | 1788 |
1677 test_perform_deadCode() { | 1789 test_perform_deadCode() { |
1678 Source source = newSource('/test.dart', ''' | 1790 Source source = newSource( |
| 1791 '/test.dart', |
| 1792 ''' |
1679 main() { | 1793 main() { |
1680 if (false) { | 1794 if (false) { |
1681 print('how?'); | 1795 print('how?'); |
1682 } | 1796 } |
1683 } | 1797 } |
1684 '''); | 1798 '''); |
1685 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 1799 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
1686 computeResult(target, HINTS); | 1800 computeResult(target, HINTS); |
1687 expect(task, new isInstanceOf<GenerateHintsTask>()); | 1801 expect(task, new isInstanceOf<GenerateHintsTask>()); |
1688 // validate | 1802 // validate |
1689 _fillErrorListener(HINTS); | 1803 _fillErrorListener(HINTS); |
1690 errorListener.assertErrorsWithCodes(<ErrorCode>[HintCode.DEAD_CODE]); | 1804 errorListener.assertErrorsWithCodes(<ErrorCode>[HintCode.DEAD_CODE]); |
1691 } | 1805 } |
1692 | 1806 |
1693 test_perform_disabled() { | 1807 test_perform_disabled() { |
1694 context.analysisOptions = | 1808 context.analysisOptions = |
1695 new AnalysisOptionsImpl.from(context.analysisOptions)..hint = false; | 1809 new AnalysisOptionsImpl.from(context.analysisOptions)..hint = false; |
1696 Source source = newSource('/test.dart', ''' | 1810 Source source = newSource( |
| 1811 '/test.dart', |
| 1812 ''' |
1697 int main() { | 1813 int main() { |
1698 } | 1814 } |
1699 '''); | 1815 '''); |
1700 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 1816 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
1701 computeResult(target, HINTS); | 1817 computeResult(target, HINTS); |
1702 expect(task, new isInstanceOf<GenerateHintsTask>()); | 1818 expect(task, new isInstanceOf<GenerateHintsTask>()); |
1703 // validate | 1819 // validate |
1704 _fillErrorListener(HINTS); | 1820 _fillErrorListener(HINTS); |
1705 errorListener.assertNoErrors(); | 1821 errorListener.assertNoErrors(); |
1706 } | 1822 } |
1707 | 1823 |
1708 test_perform_imports_duplicateImport() { | 1824 test_perform_imports_duplicateImport() { |
1709 newSource('/a.dart', r''' | 1825 newSource( |
| 1826 '/a.dart', |
| 1827 r''' |
1710 library lib_a; | 1828 library lib_a; |
1711 class A {} | 1829 class A {} |
1712 '''); | 1830 '''); |
1713 Source source = newSource('/test.dart', r''' | 1831 Source source = newSource( |
| 1832 '/test.dart', |
| 1833 r''' |
1714 import 'a.dart'; | 1834 import 'a.dart'; |
1715 import 'a.dart'; | 1835 import 'a.dart'; |
1716 main() { | 1836 main() { |
1717 new A(); | 1837 new A(); |
1718 } | 1838 } |
1719 '''); | 1839 '''); |
1720 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 1840 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
1721 computeResult(target, HINTS); | 1841 computeResult(target, HINTS); |
1722 expect(task, new isInstanceOf<GenerateHintsTask>()); | 1842 expect(task, new isInstanceOf<GenerateHintsTask>()); |
1723 // validate | 1843 // validate |
1724 _fillErrorListener(HINTS); | 1844 _fillErrorListener(HINTS); |
1725 errorListener.assertErrorsWithCodes(<ErrorCode>[HintCode.DUPLICATE_IMPORT]); | 1845 errorListener.assertErrorsWithCodes(<ErrorCode>[HintCode.DUPLICATE_IMPORT]); |
1726 } | 1846 } |
1727 | 1847 |
1728 test_perform_imports_unusedImport_one() { | 1848 test_perform_imports_unusedImport_one() { |
1729 newSource('/a.dart', r''' | 1849 newSource( |
| 1850 '/a.dart', |
| 1851 r''' |
1730 library lib_a; | 1852 library lib_a; |
1731 class A {} | 1853 class A {} |
1732 '''); | 1854 '''); |
1733 newSource('/b.dart', r''' | 1855 newSource( |
| 1856 '/b.dart', |
| 1857 r''' |
1734 library lib_b; | 1858 library lib_b; |
1735 class B {} | 1859 class B {} |
1736 '''); | 1860 '''); |
1737 Source source = newSource('/test.dart', r''' | 1861 Source source = newSource( |
| 1862 '/test.dart', |
| 1863 r''' |
1738 import 'a.dart'; | 1864 import 'a.dart'; |
1739 import 'b.dart'; | 1865 import 'b.dart'; |
1740 main() { | 1866 main() { |
1741 new A(); | 1867 new A(); |
1742 }'''); | 1868 }'''); |
1743 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 1869 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
1744 computeResult(target, HINTS); | 1870 computeResult(target, HINTS); |
1745 expect(task, new isInstanceOf<GenerateHintsTask>()); | 1871 expect(task, new isInstanceOf<GenerateHintsTask>()); |
1746 // validate | 1872 // validate |
1747 _fillErrorListener(HINTS); | 1873 _fillErrorListener(HINTS); |
1748 errorListener.assertErrorsWithCodes(<ErrorCode>[HintCode.UNUSED_IMPORT]); | 1874 errorListener.assertErrorsWithCodes(<ErrorCode>[HintCode.UNUSED_IMPORT]); |
1749 } | 1875 } |
1750 | 1876 |
1751 test_perform_imports_unusedImport_zero() { | 1877 test_perform_imports_unusedImport_zero() { |
1752 newSource('/a.dart', r''' | 1878 newSource( |
| 1879 '/a.dart', |
| 1880 r''' |
1753 library lib_a; | 1881 library lib_a; |
1754 class A {} | 1882 class A {} |
1755 '''); | 1883 '''); |
1756 Source source = newSource('/test.dart', r''' | 1884 Source source = newSource( |
| 1885 '/test.dart', |
| 1886 r''' |
1757 import 'a.dart'; | 1887 import 'a.dart'; |
1758 main() { | 1888 main() { |
1759 new A(); | 1889 new A(); |
1760 }'''); | 1890 }'''); |
1761 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 1891 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
1762 computeResult(target, HINTS); | 1892 computeResult(target, HINTS); |
1763 expect(task, new isInstanceOf<GenerateHintsTask>()); | 1893 expect(task, new isInstanceOf<GenerateHintsTask>()); |
1764 // validate | 1894 // validate |
1765 _fillErrorListener(HINTS); | 1895 _fillErrorListener(HINTS); |
1766 errorListener.assertNoErrors(); | 1896 errorListener.assertNoErrors(); |
1767 } | 1897 } |
1768 | 1898 |
1769 test_perform_overrideVerifier() { | 1899 test_perform_overrideVerifier() { |
1770 Source source = newSource('/test.dart', ''' | 1900 Source source = newSource( |
| 1901 '/test.dart', |
| 1902 ''' |
1771 class A {} | 1903 class A {} |
1772 class B { | 1904 class B { |
1773 @override | 1905 @override |
1774 m() {} | 1906 m() {} |
1775 } | 1907 } |
1776 '''); | 1908 '''); |
1777 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 1909 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
1778 computeResult(target, HINTS); | 1910 computeResult(target, HINTS); |
1779 expect(task, new isInstanceOf<GenerateHintsTask>()); | 1911 expect(task, new isInstanceOf<GenerateHintsTask>()); |
1780 // validate | 1912 // validate |
1781 _fillErrorListener(HINTS); | 1913 _fillErrorListener(HINTS); |
1782 errorListener.assertErrorsWithCodes( | 1914 errorListener.assertErrorsWithCodes( |
1783 <ErrorCode>[HintCode.OVERRIDE_ON_NON_OVERRIDING_METHOD]); | 1915 <ErrorCode>[HintCode.OVERRIDE_ON_NON_OVERRIDING_METHOD]); |
1784 } | 1916 } |
1785 | 1917 |
1786 test_perform_todo() { | 1918 test_perform_todo() { |
1787 Source source = newSource('/test.dart', ''' | 1919 Source source = newSource( |
| 1920 '/test.dart', |
| 1921 ''' |
1788 main() { | 1922 main() { |
1789 // TODO(developer) foo bar | 1923 // TODO(developer) foo bar |
1790 } | 1924 } |
1791 '''); | 1925 '''); |
1792 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 1926 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
1793 computeResult(target, HINTS); | 1927 computeResult(target, HINTS); |
1794 expect(task, new isInstanceOf<GenerateHintsTask>()); | 1928 expect(task, new isInstanceOf<GenerateHintsTask>()); |
1795 // validate | 1929 // validate |
1796 _fillErrorListener(HINTS); | 1930 _fillErrorListener(HINTS); |
1797 errorListener.assertErrorsWithCodes(<ErrorCode>[TodoCode.TODO]); | 1931 errorListener.assertErrorsWithCodes(<ErrorCode>[TodoCode.TODO]); |
1798 } | 1932 } |
1799 | 1933 |
1800 test_perform_unusedLocalElements_class() { | 1934 test_perform_unusedLocalElements_class() { |
1801 Source source = newSource('/test.dart', ''' | 1935 Source source = newSource( |
| 1936 '/test.dart', |
| 1937 ''' |
1802 class _A {} | 1938 class _A {} |
1803 class _B {} | 1939 class _B {} |
1804 main() { | 1940 main() { |
1805 new _A(); | 1941 new _A(); |
1806 } | 1942 } |
1807 '''); | 1943 '''); |
1808 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 1944 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
1809 computeResult(target, HINTS); | 1945 computeResult(target, HINTS); |
1810 expect(task, new isInstanceOf<GenerateHintsTask>()); | 1946 expect(task, new isInstanceOf<GenerateHintsTask>()); |
1811 // validate | 1947 // validate |
1812 _fillErrorListener(HINTS); | 1948 _fillErrorListener(HINTS); |
1813 errorListener.assertErrorsWithCodes(<ErrorCode>[HintCode.UNUSED_ELEMENT]); | 1949 errorListener.assertErrorsWithCodes(<ErrorCode>[HintCode.UNUSED_ELEMENT]); |
1814 } | 1950 } |
1815 | 1951 |
1816 test_perform_unusedLocalElements_localVariable() { | 1952 test_perform_unusedLocalElements_localVariable() { |
1817 Source source = newSource('/test.dart', ''' | 1953 Source source = newSource( |
| 1954 '/test.dart', |
| 1955 ''' |
1818 main() { | 1956 main() { |
1819 var v = 42; | 1957 var v = 42; |
1820 } | 1958 } |
1821 '''); | 1959 '''); |
1822 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 1960 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
1823 computeResult(target, HINTS); | 1961 computeResult(target, HINTS); |
1824 expect(task, new isInstanceOf<GenerateHintsTask>()); | 1962 expect(task, new isInstanceOf<GenerateHintsTask>()); |
1825 // validate | 1963 // validate |
1826 _fillErrorListener(HINTS); | 1964 _fillErrorListener(HINTS); |
1827 errorListener | 1965 errorListener |
1828 .assertErrorsWithCodes(<ErrorCode>[HintCode.UNUSED_LOCAL_VARIABLE]); | 1966 .assertErrorsWithCodes(<ErrorCode>[HintCode.UNUSED_LOCAL_VARIABLE]); |
1829 } | 1967 } |
1830 | 1968 |
1831 test_perform_unusedLocalElements_method() { | 1969 test_perform_unusedLocalElements_method() { |
1832 Source source = newSource('/my_lib.dart', ''' | 1970 Source source = newSource( |
| 1971 '/my_lib.dart', |
| 1972 ''' |
1833 library my_lib; | 1973 library my_lib; |
1834 part 'my_part.dart'; | 1974 part 'my_part.dart'; |
1835 class A { | 1975 class A { |
1836 _ma() {} | 1976 _ma() {} |
1837 _mb() {} | 1977 _mb() {} |
1838 _mc() {} | 1978 _mc() {} |
1839 } | 1979 } |
1840 '''); | 1980 '''); |
1841 newSource('/my_part.dart', ''' | 1981 newSource( |
| 1982 '/my_part.dart', |
| 1983 ''' |
1842 part of my_lib; | 1984 part of my_lib; |
1843 | 1985 |
1844 f(A a) { | 1986 f(A a) { |
1845 a._mb(); | 1987 a._mb(); |
1846 } | 1988 } |
1847 '''); | 1989 '''); |
1848 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 1990 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
1849 computeResult(target, HINTS); | 1991 computeResult(target, HINTS); |
1850 expect(task, new isInstanceOf<GenerateHintsTask>()); | 1992 expect(task, new isInstanceOf<GenerateHintsTask>()); |
1851 // validate | 1993 // validate |
1852 _fillErrorListener(HINTS); | 1994 _fillErrorListener(HINTS); |
1853 errorListener.assertErrorsWithCodes( | 1995 errorListener.assertErrorsWithCodes( |
1854 <ErrorCode>[HintCode.UNUSED_ELEMENT, HintCode.UNUSED_ELEMENT]); | 1996 <ErrorCode>[HintCode.UNUSED_ELEMENT, HintCode.UNUSED_ELEMENT]); |
1855 } | 1997 } |
1856 } | 1998 } |
1857 | 1999 |
1858 @reflectiveTest | 2000 @reflectiveTest |
1859 class LibraryErrorsReadyTaskTest extends _AbstractDartTaskTest { | 2001 class LibraryErrorsReadyTaskTest extends _AbstractDartTaskTest { |
1860 test_perform() { | 2002 test_perform() { |
1861 Source library = newSource('/lib.dart', r''' | 2003 Source library = newSource( |
| 2004 '/lib.dart', |
| 2005 r''' |
1862 library lib; | 2006 library lib; |
1863 part 'part1.dart'; | 2007 part 'part1.dart'; |
1864 part 'part2.dart'; | 2008 part 'part2.dart'; |
1865 X v1; | 2009 X v1; |
1866 '''); | 2010 '''); |
1867 Source part1 = newSource('/part1.dart', r''' | 2011 Source part1 = newSource( |
| 2012 '/part1.dart', |
| 2013 r''' |
1868 part of lib; | 2014 part of lib; |
1869 X v2; | 2015 X v2; |
1870 '''); | 2016 '''); |
1871 Source part2 = newSource('/part2.dart', r''' | 2017 Source part2 = newSource( |
| 2018 '/part2.dart', |
| 2019 r''' |
1872 part of lib; | 2020 part of lib; |
1873 X v3; | 2021 X v3; |
1874 '''); | 2022 '''); |
1875 computeResult(library, LIBRARY_ERRORS_READY); | 2023 computeResult(library, LIBRARY_ERRORS_READY); |
1876 expect(task, new isInstanceOf<LibraryErrorsReadyTask>()); | 2024 expect(task, new isInstanceOf<LibraryErrorsReadyTask>()); |
1877 expect(outputs, hasLength(1)); | 2025 expect(outputs, hasLength(1)); |
1878 bool ready = outputs[LIBRARY_ERRORS_READY]; | 2026 bool ready = outputs[LIBRARY_ERRORS_READY]; |
1879 expect(ready, isTrue); | 2027 expect(ready, isTrue); |
1880 expect(context.getErrors(library).errors, hasLength(1)); | 2028 expect(context.getErrors(library).errors, hasLength(1)); |
1881 expect(context.getErrors(part1).errors, hasLength(1)); | 2029 expect(context.getErrors(part1).errors, hasLength(1)); |
1882 expect(context.getErrors(part2).errors, hasLength(1)); | 2030 expect(context.getErrors(part2).errors, hasLength(1)); |
1883 } | 2031 } |
1884 } | 2032 } |
1885 | 2033 |
1886 @reflectiveTest | 2034 @reflectiveTest |
1887 class LibraryUnitErrorsTaskTest extends _AbstractDartTaskTest { | 2035 class LibraryUnitErrorsTaskTest extends _AbstractDartTaskTest { |
1888 test_buildInputs() { | 2036 test_buildInputs() { |
1889 Map<String, TaskInput> inputs = LibraryUnitErrorsTask | 2037 Map<String, TaskInput> inputs = LibraryUnitErrorsTask |
1890 .buildInputs(new LibrarySpecificUnit(emptySource, emptySource)); | 2038 .buildInputs(new LibrarySpecificUnit(emptySource, emptySource)); |
1891 expect(inputs, isNotNull); | 2039 expect(inputs, isNotNull); |
1892 expect(inputs.keys, unorderedEquals([ | 2040 expect( |
1893 LibraryUnitErrorsTask.HINTS_INPUT, | 2041 inputs.keys, |
1894 LibraryUnitErrorsTask.RESOLVE_REFERENCES_ERRORS_INPUT, | 2042 unorderedEquals([ |
1895 LibraryUnitErrorsTask.RESOLVE_TYPE_NAMES_ERRORS_INPUT, | 2043 LibraryUnitErrorsTask.HINTS_INPUT, |
1896 LibraryUnitErrorsTask.VARIABLE_REFERENCE_ERRORS_INPUT, | 2044 LibraryUnitErrorsTask.RESOLVE_REFERENCES_ERRORS_INPUT, |
1897 LibraryUnitErrorsTask.VERIFY_ERRORS_INPUT | 2045 LibraryUnitErrorsTask.RESOLVE_TYPE_NAMES_ERRORS_INPUT, |
1898 ])); | 2046 LibraryUnitErrorsTask.VARIABLE_REFERENCE_ERRORS_INPUT, |
| 2047 LibraryUnitErrorsTask.VERIFY_ERRORS_INPUT |
| 2048 ])); |
1899 } | 2049 } |
1900 | 2050 |
1901 test_constructor() { | 2051 test_constructor() { |
1902 LibraryUnitErrorsTask task = | 2052 LibraryUnitErrorsTask task = |
1903 new LibraryUnitErrorsTask(context, emptySource); | 2053 new LibraryUnitErrorsTask(context, emptySource); |
1904 expect(task, isNotNull); | 2054 expect(task, isNotNull); |
1905 expect(task.context, context); | 2055 expect(task.context, context); |
1906 expect(task.target, emptySource); | 2056 expect(task.target, emptySource); |
1907 } | 2057 } |
1908 | 2058 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1947 } | 2097 } |
1948 } | 2098 } |
1949 | 2099 |
1950 @reflectiveTest | 2100 @reflectiveTest |
1951 class ParseDartTaskTest extends _AbstractDartTaskTest { | 2101 class ParseDartTaskTest extends _AbstractDartTaskTest { |
1952 Source source; | 2102 Source source; |
1953 | 2103 |
1954 test_buildInputs() { | 2104 test_buildInputs() { |
1955 Map<String, TaskInput> inputs = ParseDartTask.buildInputs(emptySource); | 2105 Map<String, TaskInput> inputs = ParseDartTask.buildInputs(emptySource); |
1956 expect(inputs, isNotNull); | 2106 expect(inputs, isNotNull); |
1957 expect(inputs.keys, unorderedEquals([ | 2107 expect( |
1958 ParseDartTask.LINE_INFO_INPUT_NAME, | 2108 inputs.keys, |
1959 ParseDartTask.MODIFICATION_TIME_INPUT_NAME, | 2109 unorderedEquals([ |
1960 ParseDartTask.TOKEN_STREAM_INPUT_NAME | 2110 ParseDartTask.LINE_INFO_INPUT_NAME, |
1961 ])); | 2111 ParseDartTask.MODIFICATION_TIME_INPUT_NAME, |
| 2112 ParseDartTask.TOKEN_STREAM_INPUT_NAME |
| 2113 ])); |
1962 } | 2114 } |
1963 | 2115 |
1964 test_constructor() { | 2116 test_constructor() { |
1965 ParseDartTask task = new ParseDartTask(context, emptySource); | 2117 ParseDartTask task = new ParseDartTask(context, emptySource); |
1966 expect(task, isNotNull); | 2118 expect(task, isNotNull); |
1967 expect(task.context, context); | 2119 expect(task.context, context); |
1968 expect(task.target, emptySource); | 2120 expect(task.target, emptySource); |
1969 } | 2121 } |
1970 | 2122 |
1971 test_createTask() { | 2123 test_createTask() { |
(...skipping 23 matching lines...) Expand all Loading... |
1995 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1); | 2147 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1); |
1996 expect(outputs[INCLUDED_PARTS], hasLength(0)); | 2148 expect(outputs[INCLUDED_PARTS], hasLength(0)); |
1997 expect(outputs[PARSE_ERRORS], hasLength(0)); | 2149 expect(outputs[PARSE_ERRORS], hasLength(0)); |
1998 expect(outputs[PARSED_UNIT], isNotNull); | 2150 expect(outputs[PARSED_UNIT], isNotNull); |
1999 expect(outputs[SOURCE_KIND], SourceKind.PART); | 2151 expect(outputs[SOURCE_KIND], SourceKind.PART); |
2000 expect(outputs[UNITS], hasLength(1)); | 2152 expect(outputs[UNITS], hasLength(1)); |
2001 } | 2153 } |
2002 | 2154 |
2003 test_perform_computeSourceKind_noDirectives_hasContainingLibrary() { | 2155 test_perform_computeSourceKind_noDirectives_hasContainingLibrary() { |
2004 // Parse "lib.dart" to let the context know that "test.dart" is included. | 2156 // Parse "lib.dart" to let the context know that "test.dart" is included. |
2005 computeResult(newSource('/lib.dart', r''' | 2157 computeResult( |
| 2158 newSource( |
| 2159 '/lib.dart', |
| 2160 r''' |
2006 library lib; | 2161 library lib; |
2007 part 'test.dart'; | 2162 part 'test.dart'; |
2008 '''), PARSED_UNIT); | 2163 '''), |
| 2164 PARSED_UNIT); |
2009 // If there are no the "part of" directive, then it is not a part. | 2165 // If there are no the "part of" directive, then it is not a part. |
2010 _performParseTask(''); | 2166 _performParseTask(''); |
2011 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY); | 2167 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY); |
2012 } | 2168 } |
2013 | 2169 |
2014 test_perform_computeSourceKind_noDirectives_noContainingLibrary() { | 2170 test_perform_computeSourceKind_noDirectives_noContainingLibrary() { |
2015 _performParseTask(''); | 2171 _performParseTask(''); |
2016 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY); | 2172 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY); |
2017 } | 2173 } |
2018 | 2174 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2099 expect(sources, hasLength(lenght)); | 2255 expect(sources, hasLength(lenght)); |
2100 expect(sources, contains(predicate((Source s) { | 2256 expect(sources, contains(predicate((Source s) { |
2101 return s.fullName.endsWith('core.dart'); | 2257 return s.fullName.endsWith('core.dart'); |
2102 }))); | 2258 }))); |
2103 } | 2259 } |
2104 } | 2260 } |
2105 | 2261 |
2106 @reflectiveTest | 2262 @reflectiveTest |
2107 class ResolveLibraryTypeNamesTaskTest extends _AbstractDartTaskTest { | 2263 class ResolveLibraryTypeNamesTaskTest extends _AbstractDartTaskTest { |
2108 test_perform() { | 2264 test_perform() { |
2109 Source sourceLib = newSource('/my_lib.dart', ''' | 2265 Source sourceLib = newSource( |
| 2266 '/my_lib.dart', |
| 2267 ''' |
2110 library my_lib; | 2268 library my_lib; |
2111 part 'my_part.dart'; | 2269 part 'my_part.dart'; |
2112 class A {} | 2270 class A {} |
2113 class B extends A {} | 2271 class B extends A {} |
2114 '''); | 2272 '''); |
2115 newSource('/my_part.dart', ''' | 2273 newSource( |
| 2274 '/my_part.dart', |
| 2275 ''' |
2116 part of my_lib; | 2276 part of my_lib; |
2117 class C extends A {} | 2277 class C extends A {} |
2118 '''); | 2278 '''); |
2119 computeResult(sourceLib, LIBRARY_ELEMENT5); | 2279 computeResult(sourceLib, LIBRARY_ELEMENT5); |
2120 expect(task, new isInstanceOf<ResolveLibraryTypeNamesTask>()); | 2280 expect(task, new isInstanceOf<ResolveLibraryTypeNamesTask>()); |
2121 // validate | 2281 // validate |
2122 LibraryElement library = outputs[LIBRARY_ELEMENT5]; | 2282 LibraryElement library = outputs[LIBRARY_ELEMENT5]; |
2123 { | 2283 { |
2124 ClassElement classB = library.getType('B'); | 2284 ClassElement classB = library.getType('B'); |
2125 expect(classB.supertype.displayName, 'A'); | 2285 expect(classB.supertype.displayName, 'A'); |
2126 } | 2286 } |
2127 { | 2287 { |
2128 ClassElement classC = library.getType('C'); | 2288 ClassElement classC = library.getType('C'); |
2129 expect(classC.supertype.displayName, 'A'); | 2289 expect(classC.supertype.displayName, 'A'); |
2130 } | 2290 } |
2131 } | 2291 } |
2132 | 2292 |
2133 test_perform_external() { | 2293 test_perform_external() { |
2134 Source sourceA = newSource('/a.dart', ''' | 2294 Source sourceA = newSource( |
| 2295 '/a.dart', |
| 2296 ''' |
2135 library a; | 2297 library a; |
2136 import 'b.dart'; | 2298 import 'b.dart'; |
2137 class A extends B {} | 2299 class A extends B {} |
2138 '''); | 2300 '''); |
2139 newSource('/b.dart', ''' | 2301 newSource( |
| 2302 '/b.dart', |
| 2303 ''' |
2140 library b; | 2304 library b; |
2141 class B {} | 2305 class B {} |
2142 '''); | 2306 '''); |
2143 // The reference A to B should be resolved, but there's no requirement that | 2307 // The reference A to B should be resolved, but there's no requirement that |
2144 // the full class hierarchy be resolved. | 2308 // the full class hierarchy be resolved. |
2145 computeResult(sourceA, LIBRARY_ELEMENT5); | 2309 computeResult(sourceA, LIBRARY_ELEMENT5); |
2146 expect(task, new isInstanceOf<ResolveLibraryTypeNamesTask>()); | 2310 expect(task, new isInstanceOf<ResolveLibraryTypeNamesTask>()); |
2147 // validate | 2311 // validate |
2148 LibraryElement library = outputs[LIBRARY_ELEMENT5]; | 2312 LibraryElement library = outputs[LIBRARY_ELEMENT5]; |
2149 { | 2313 { |
2150 ClassElement clazz = library.getType('A'); | 2314 ClassElement clazz = library.getType('A'); |
2151 expect(clazz.displayName, 'A'); | 2315 expect(clazz.displayName, 'A'); |
2152 clazz = clazz.supertype.element; | 2316 clazz = clazz.supertype.element; |
2153 expect(clazz.displayName, 'B'); | 2317 expect(clazz.displayName, 'B'); |
2154 } | 2318 } |
2155 } | 2319 } |
2156 } | 2320 } |
2157 | 2321 |
2158 @reflectiveTest | 2322 @reflectiveTest |
2159 class ResolveReferencesTaskTest extends _AbstractDartTaskTest { | 2323 class ResolveReferencesTaskTest extends _AbstractDartTaskTest { |
2160 test_perform() { | 2324 test_perform() { |
2161 Source source = newSource('/test.dart', ''' | 2325 Source source = newSource( |
| 2326 '/test.dart', |
| 2327 ''' |
2162 class A { | 2328 class A { |
2163 m() {} | 2329 m() {} |
2164 } | 2330 } |
2165 main(A a) { | 2331 main(A a) { |
2166 a.m(); | 2332 a.m(); |
2167 } | 2333 } |
2168 '''); | 2334 '''); |
2169 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2335 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2170 // prepare unit and "a.m()" invocation | 2336 // prepare unit and "a.m()" invocation |
2171 computeResult(target, RESOLVED_UNIT5); | 2337 computeResult(target, RESOLVED_UNIT5); |
2172 CompilationUnit unit = outputs[RESOLVED_UNIT5]; | 2338 CompilationUnit unit = outputs[RESOLVED_UNIT5]; |
2173 // walk the AST | 2339 // walk the AST |
2174 FunctionDeclaration function = unit.declarations[1]; | 2340 FunctionDeclaration function = unit.declarations[1]; |
2175 BlockFunctionBody body = function.functionExpression.body; | 2341 BlockFunctionBody body = function.functionExpression.body; |
2176 ExpressionStatement statement = body.block.statements[0]; | 2342 ExpressionStatement statement = body.block.statements[0]; |
2177 MethodInvocation invocation = statement.expression; | 2343 MethodInvocation invocation = statement.expression; |
2178 expect(task, new isInstanceOf<ResolveUnitReferencesTask>()); | 2344 expect(task, new isInstanceOf<ResolveUnitReferencesTask>()); |
2179 expect(unit, same(outputs[RESOLVED_UNIT5])); | 2345 expect(unit, same(outputs[RESOLVED_UNIT5])); |
2180 // a.m() is resolved now | 2346 // a.m() is resolved now |
2181 expect(invocation.methodName.staticElement, isNotNull); | 2347 expect(invocation.methodName.staticElement, isNotNull); |
2182 } | 2348 } |
2183 | 2349 |
2184 test_perform_errors() { | 2350 test_perform_errors() { |
2185 Source source = newSource('/test.dart', ''' | 2351 Source source = newSource( |
| 2352 '/test.dart', |
| 2353 ''' |
2186 class A { | 2354 class A { |
2187 } | 2355 } |
2188 main(A a) { | 2356 main(A a) { |
2189 a.unknownMethod(); | 2357 a.unknownMethod(); |
2190 } | 2358 } |
2191 '''); | 2359 '''); |
2192 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2360 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2193 computeResult(target, RESOLVED_UNIT5); | 2361 computeResult(target, RESOLVED_UNIT5); |
2194 expect(task, new isInstanceOf<ResolveUnitReferencesTask>()); | 2362 expect(task, new isInstanceOf<ResolveUnitReferencesTask>()); |
2195 // validate | 2363 // validate |
2196 _fillErrorListener(RESOLVE_REFERENCES_ERRORS); | 2364 _fillErrorListener(RESOLVE_REFERENCES_ERRORS); |
2197 errorListener.assertErrorsWithCodes( | 2365 errorListener.assertErrorsWithCodes( |
2198 <ErrorCode>[StaticTypeWarningCode.UNDEFINED_METHOD]); | 2366 <ErrorCode>[StaticTypeWarningCode.UNDEFINED_METHOD]); |
2199 } | 2367 } |
2200 | 2368 |
2201 test_perform_importExport() { | 2369 test_perform_importExport() { |
2202 newSource('/a.dart', ''' | 2370 newSource( |
| 2371 '/a.dart', |
| 2372 ''' |
2203 library a; | 2373 library a; |
2204 class A<T> { | 2374 class A<T> { |
2205 T m() {} | 2375 T m() {} |
2206 } | 2376 } |
2207 '''); | 2377 '''); |
2208 newSource('/b.dart', ''' | 2378 newSource( |
| 2379 '/b.dart', |
| 2380 ''' |
2209 library b; | 2381 library b; |
2210 export 'a.dart'; | 2382 export 'a.dart'; |
2211 '''); | 2383 '''); |
2212 Source sourceC = newSource('/c.dart', ''' | 2384 Source sourceC = newSource( |
| 2385 '/c.dart', |
| 2386 ''' |
2213 library c; | 2387 library c; |
2214 import 'b.dart'; | 2388 import 'b.dart'; |
2215 main() { | 2389 main() { |
2216 new A<int>().m(); | 2390 new A<int>().m(); |
2217 } | 2391 } |
2218 '''); | 2392 '''); |
2219 computeResult(new LibrarySpecificUnit(sourceC, sourceC), RESOLVED_UNIT5); | 2393 computeResult(new LibrarySpecificUnit(sourceC, sourceC), RESOLVED_UNIT5); |
2220 expect(task, new isInstanceOf<ResolveUnitReferencesTask>()); | 2394 expect(task, new isInstanceOf<ResolveUnitReferencesTask>()); |
2221 // validate | 2395 // validate |
2222 CompilationUnit unit = outputs[RESOLVED_UNIT5]; | 2396 CompilationUnit unit = outputs[RESOLVED_UNIT5]; |
2223 expect(unit, isNotNull); | 2397 expect(unit, isNotNull); |
2224 { | 2398 { |
2225 FunctionDeclaration functionDeclaration = unit.declarations[0]; | 2399 FunctionDeclaration functionDeclaration = unit.declarations[0]; |
2226 BlockFunctionBody body = functionDeclaration.functionExpression.body; | 2400 BlockFunctionBody body = functionDeclaration.functionExpression.body; |
2227 List<Statement> statements = body.block.statements; | 2401 List<Statement> statements = body.block.statements; |
2228 ExpressionStatement statement = statements[0]; | 2402 ExpressionStatement statement = statements[0]; |
2229 MethodInvocation invocation = statement.expression; | 2403 MethodInvocation invocation = statement.expression; |
2230 MethodElement methodElement = invocation.methodName.staticElement; | 2404 MethodElement methodElement = invocation.methodName.staticElement; |
2231 expect(methodElement, isNotNull); | 2405 expect(methodElement, isNotNull); |
2232 expect(methodElement.type, isNotNull); | 2406 expect(methodElement.type, isNotNull); |
2233 expect(methodElement.returnType.toString(), 'int'); | 2407 expect(methodElement.returnType.toString(), 'int'); |
2234 } | 2408 } |
2235 } | 2409 } |
2236 } | 2410 } |
2237 | 2411 |
2238 @reflectiveTest | 2412 @reflectiveTest |
2239 class ResolveUnitTypeNamesTaskTest extends _AbstractDartTaskTest { | 2413 class ResolveUnitTypeNamesTaskTest extends _AbstractDartTaskTest { |
2240 test_perform() { | 2414 test_perform() { |
2241 Source source = newSource('/test.dart', ''' | 2415 Source source = newSource( |
| 2416 '/test.dart', |
| 2417 ''' |
2242 class A {} | 2418 class A {} |
2243 class B extends A {} | 2419 class B extends A {} |
2244 int f(String p) => p.length; | 2420 int f(String p) => p.length; |
2245 '''); | 2421 '''); |
2246 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2422 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2247 computeResult(target, RESOLVED_UNIT3); | 2423 computeResult(target, RESOLVED_UNIT3); |
2248 expect(task, new isInstanceOf<ResolveUnitTypeNamesTask>()); | 2424 expect(task, new isInstanceOf<ResolveUnitTypeNamesTask>()); |
2249 // validate | 2425 // validate |
2250 CompilationUnit unit = outputs[RESOLVED_UNIT3]; | 2426 CompilationUnit unit = outputs[RESOLVED_UNIT3]; |
2251 { | 2427 { |
2252 ClassDeclaration nodeA = unit.declarations[0]; | 2428 ClassDeclaration nodeA = unit.declarations[0]; |
2253 ClassDeclaration nodeB = unit.declarations[1]; | 2429 ClassDeclaration nodeB = unit.declarations[1]; |
2254 DartType extendsType = nodeB.extendsClause.superclass.type; | 2430 DartType extendsType = nodeB.extendsClause.superclass.type; |
2255 expect(extendsType, nodeA.element.type); | 2431 expect(extendsType, nodeA.element.type); |
2256 } | 2432 } |
2257 { | 2433 { |
2258 FunctionDeclaration functionNode = unit.declarations[2]; | 2434 FunctionDeclaration functionNode = unit.declarations[2]; |
2259 DartType returnType = functionNode.returnType.type; | 2435 DartType returnType = functionNode.returnType.type; |
2260 List<FormalParameter> parameters = | 2436 List<FormalParameter> parameters = |
2261 functionNode.functionExpression.parameters.parameters; | 2437 functionNode.functionExpression.parameters.parameters; |
2262 expect(returnType.displayName, 'int'); | 2438 expect(returnType.displayName, 'int'); |
2263 expect(parameters[0].element.type.displayName, 'String'); | 2439 expect(parameters[0].element.type.displayName, 'String'); |
2264 } | 2440 } |
2265 } | 2441 } |
2266 | 2442 |
2267 test_perform_errors() { | 2443 test_perform_errors() { |
2268 Source source = newSource('/test.dart', ''' | 2444 Source source = newSource( |
| 2445 '/test.dart', |
| 2446 ''' |
2269 NoSuchClass f() => null; | 2447 NoSuchClass f() => null; |
2270 '''); | 2448 '''); |
2271 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2449 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2272 computeResult(target, RESOLVE_TYPE_NAMES_ERRORS); | 2450 computeResult(target, RESOLVE_TYPE_NAMES_ERRORS); |
2273 expect(task, new isInstanceOf<ResolveUnitTypeNamesTask>()); | 2451 expect(task, new isInstanceOf<ResolveUnitTypeNamesTask>()); |
2274 // validate | 2452 // validate |
2275 _fillErrorListener(RESOLVE_TYPE_NAMES_ERRORS); | 2453 _fillErrorListener(RESOLVE_TYPE_NAMES_ERRORS); |
2276 errorListener | 2454 errorListener |
2277 .assertErrorsWithCodes(<ErrorCode>[StaticWarningCode.UNDEFINED_CLASS]); | 2455 .assertErrorsWithCodes(<ErrorCode>[StaticWarningCode.UNDEFINED_CLASS]); |
2278 } | 2456 } |
2279 | 2457 |
2280 test_perform_typedef() { | 2458 test_perform_typedef() { |
2281 Source source = newSource('/test.dart', ''' | 2459 Source source = newSource( |
| 2460 '/test.dart', |
| 2461 ''' |
2282 typedef int F(G g); | 2462 typedef int F(G g); |
2283 typedef String G(int p); | 2463 typedef String G(int p); |
2284 '''); | 2464 '''); |
2285 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2465 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2286 computeResult(target, RESOLVED_UNIT3); | 2466 computeResult(target, RESOLVED_UNIT3); |
2287 expect(task, new isInstanceOf<ResolveUnitTypeNamesTask>()); | 2467 expect(task, new isInstanceOf<ResolveUnitTypeNamesTask>()); |
2288 // validate | 2468 // validate |
2289 CompilationUnit unit = outputs[RESOLVED_UNIT3]; | 2469 CompilationUnit unit = outputs[RESOLVED_UNIT3]; |
2290 FunctionTypeAlias nodeF = unit.declarations[0]; | 2470 FunctionTypeAlias nodeF = unit.declarations[0]; |
2291 FunctionTypeAlias nodeG = unit.declarations[1]; | 2471 FunctionTypeAlias nodeG = unit.declarations[1]; |
2292 { | 2472 { |
2293 FormalParameter parameter = nodeF.parameters.parameters[0]; | 2473 FormalParameter parameter = nodeF.parameters.parameters[0]; |
2294 DartType parameterType = parameter.element.type; | 2474 DartType parameterType = parameter.element.type; |
2295 Element returnTypeElement = nodeF.returnType.type.element; | 2475 Element returnTypeElement = nodeF.returnType.type.element; |
2296 expect(returnTypeElement.displayName, 'int'); | 2476 expect(returnTypeElement.displayName, 'int'); |
2297 expect(parameterType.element, nodeG.element); | 2477 expect(parameterType.element, nodeG.element); |
2298 } | 2478 } |
2299 { | 2479 { |
2300 FormalParameter parameter = nodeG.parameters.parameters[0]; | 2480 FormalParameter parameter = nodeG.parameters.parameters[0]; |
2301 DartType parameterType = parameter.element.type; | 2481 DartType parameterType = parameter.element.type; |
2302 expect(nodeG.returnType.type.element.displayName, 'String'); | 2482 expect(nodeG.returnType.type.element.displayName, 'String'); |
2303 expect(parameterType.element.displayName, 'int'); | 2483 expect(parameterType.element.displayName, 'int'); |
2304 } | 2484 } |
2305 } | 2485 } |
2306 | 2486 |
2307 test_perform_typedef_errors() { | 2487 test_perform_typedef_errors() { |
2308 Source source = newSource('/test.dart', ''' | 2488 Source source = newSource( |
| 2489 '/test.dart', |
| 2490 ''' |
2309 typedef int F(NoSuchType p); | 2491 typedef int F(NoSuchType p); |
2310 '''); | 2492 '''); |
2311 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2493 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2312 computeResult(target, RESOLVE_TYPE_NAMES_ERRORS); | 2494 computeResult(target, RESOLVE_TYPE_NAMES_ERRORS); |
2313 expect(task, new isInstanceOf<ResolveUnitTypeNamesTask>()); | 2495 expect(task, new isInstanceOf<ResolveUnitTypeNamesTask>()); |
2314 // validate | 2496 // validate |
2315 _fillErrorListener(RESOLVE_TYPE_NAMES_ERRORS); | 2497 _fillErrorListener(RESOLVE_TYPE_NAMES_ERRORS); |
2316 errorListener | 2498 errorListener |
2317 .assertErrorsWithCodes(<ErrorCode>[StaticWarningCode.UNDEFINED_CLASS]); | 2499 .assertErrorsWithCodes(<ErrorCode>[StaticWarningCode.UNDEFINED_CLASS]); |
2318 } | 2500 } |
2319 } | 2501 } |
2320 | 2502 |
2321 @reflectiveTest | 2503 @reflectiveTest |
2322 class ResolveVariableReferencesTaskTest extends _AbstractDartTaskTest { | 2504 class ResolveVariableReferencesTaskTest extends _AbstractDartTaskTest { |
2323 /** | 2505 /** |
2324 * Verify that the mutated states of the given [variable] correspond to the | 2506 * Verify that the mutated states of the given [variable] correspond to the |
2325 * [mutatedInClosure] and [mutatedInScope] matchers. | 2507 * [mutatedInClosure] and [mutatedInScope] matchers. |
2326 */ | 2508 */ |
2327 void expectMutated(VariableElement variable, Matcher mutatedInClosure, | 2509 void expectMutated(VariableElement variable, Matcher mutatedInClosure, |
2328 Matcher mutatedInScope) { | 2510 Matcher mutatedInScope) { |
2329 expect(variable.isPotentiallyMutatedInClosure, mutatedInClosure); | 2511 expect(variable.isPotentiallyMutatedInClosure, mutatedInClosure); |
2330 expect(variable.isPotentiallyMutatedInScope, mutatedInScope); | 2512 expect(variable.isPotentiallyMutatedInScope, mutatedInScope); |
2331 } | 2513 } |
2332 | 2514 |
2333 test_perform_buildClosureLibraryElements() { | 2515 test_perform_buildClosureLibraryElements() { |
2334 Source source = newSource('/test.dart', ''' | 2516 Source source = newSource( |
| 2517 '/test.dart', |
| 2518 ''' |
2335 main() { | 2519 main() { |
2336 } | 2520 } |
2337 '''); | 2521 '''); |
2338 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2522 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2339 computeResult(target, RESOLVED_UNIT4); | 2523 computeResult(target, RESOLVED_UNIT4); |
2340 expect(task, new isInstanceOf<ResolveVariableReferencesTask>()); | 2524 expect(task, new isInstanceOf<ResolveVariableReferencesTask>()); |
2341 } | 2525 } |
2342 | 2526 |
2343 test_perform_local() { | 2527 test_perform_local() { |
2344 Source source = newSource('/test.dart', ''' | 2528 Source source = newSource( |
| 2529 '/test.dart', |
| 2530 ''' |
2345 main() { | 2531 main() { |
2346 var v1 = 1; | 2532 var v1 = 1; |
2347 var v2 = 1; | 2533 var v2 = 1; |
2348 var v3 = 1; | 2534 var v3 = 1; |
2349 var v4 = 1; | 2535 var v4 = 1; |
2350 v2 = 2; | 2536 v2 = 2; |
2351 v4 = 2; | 2537 v4 = 2; |
2352 localFunction() { | 2538 localFunction() { |
2353 v3 = 3; | 2539 v3 = 3; |
2354 v4 = 3; | 2540 v4 = 3; |
2355 } | 2541 } |
2356 } | 2542 } |
2357 '''); | 2543 '''); |
2358 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2544 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2359 computeResult(target, RESOLVED_UNIT4); | 2545 computeResult(target, RESOLVED_UNIT4); |
2360 expect(task, new isInstanceOf<ResolveVariableReferencesTask>()); | 2546 expect(task, new isInstanceOf<ResolveVariableReferencesTask>()); |
2361 // validate | 2547 // validate |
2362 CompilationUnit unit = outputs[RESOLVED_UNIT4]; | 2548 CompilationUnit unit = outputs[RESOLVED_UNIT4]; |
2363 FunctionElement main = unit.element.functions[0]; | 2549 FunctionElement main = unit.element.functions[0]; |
2364 expectMutated(main.localVariables[0], isFalse, isFalse); | 2550 expectMutated(main.localVariables[0], isFalse, isFalse); |
2365 expectMutated(main.localVariables[1], isFalse, isTrue); | 2551 expectMutated(main.localVariables[1], isFalse, isTrue); |
2366 expectMutated(main.localVariables[2], isTrue, isTrue); | 2552 expectMutated(main.localVariables[2], isTrue, isTrue); |
2367 expectMutated(main.localVariables[3], isTrue, isTrue); | 2553 expectMutated(main.localVariables[3], isTrue, isTrue); |
2368 } | 2554 } |
2369 | 2555 |
2370 test_perform_parameter() { | 2556 test_perform_parameter() { |
2371 Source source = newSource('/test.dart', ''' | 2557 Source source = newSource( |
| 2558 '/test.dart', |
| 2559 ''' |
2372 main(p1, p2, p3, p4) { | 2560 main(p1, p2, p3, p4) { |
2373 p2 = 2; | 2561 p2 = 2; |
2374 p4 = 2; | 2562 p4 = 2; |
2375 localFunction() { | 2563 localFunction() { |
2376 p3 = 3; | 2564 p3 = 3; |
2377 p4 = 3; | 2565 p4 = 3; |
2378 } | 2566 } |
2379 } | 2567 } |
2380 '''); | 2568 '''); |
2381 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2569 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2469 void _performScanTask(String content) { | 2657 void _performScanTask(String content) { |
2470 AnalysisTarget target = newSource('/test.dart', content); | 2658 AnalysisTarget target = newSource('/test.dart', content); |
2471 computeResult(target, TOKEN_STREAM); | 2659 computeResult(target, TOKEN_STREAM); |
2472 expect(task, new isInstanceOf<ScanDartTask>()); | 2660 expect(task, new isInstanceOf<ScanDartTask>()); |
2473 } | 2661 } |
2474 } | 2662 } |
2475 | 2663 |
2476 @reflectiveTest | 2664 @reflectiveTest |
2477 class VerifyUnitTaskTest extends _AbstractDartTaskTest { | 2665 class VerifyUnitTaskTest extends _AbstractDartTaskTest { |
2478 test_perform_constantError() { | 2666 test_perform_constantError() { |
2479 Source source = newSource('/test.dart', ''' | 2667 Source source = newSource( |
| 2668 '/test.dart', |
| 2669 ''' |
2480 main(int p) { | 2670 main(int p) { |
2481 const v = p; | 2671 const v = p; |
2482 } | 2672 } |
2483 '''); | 2673 '''); |
2484 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2674 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2485 computeResult(target, VERIFY_ERRORS); | 2675 computeResult(target, VERIFY_ERRORS); |
2486 expect(task, new isInstanceOf<VerifyUnitTask>()); | 2676 expect(task, new isInstanceOf<VerifyUnitTask>()); |
2487 // validate | 2677 // validate |
2488 _fillErrorListener(VERIFY_ERRORS); | 2678 _fillErrorListener(VERIFY_ERRORS); |
2489 errorListener.assertErrorsWithCodes(<ErrorCode>[ | 2679 errorListener.assertErrorsWithCodes(<ErrorCode>[ |
2490 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE | 2680 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE |
2491 ]); | 2681 ]); |
2492 } | 2682 } |
2493 | 2683 |
2494 test_perform_directiveError() { | 2684 test_perform_directiveError() { |
2495 Source source = newSource('/test.dart', ''' | 2685 Source source = newSource( |
| 2686 '/test.dart', |
| 2687 ''' |
2496 import 'no-such-file.dart'; | 2688 import 'no-such-file.dart'; |
2497 '''); | 2689 '''); |
2498 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2690 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2499 computeResult(target, VERIFY_ERRORS); | 2691 computeResult(target, VERIFY_ERRORS); |
2500 expect(task, new isInstanceOf<VerifyUnitTask>()); | 2692 expect(task, new isInstanceOf<VerifyUnitTask>()); |
2501 // validate | 2693 // validate |
2502 _fillErrorListener(VERIFY_ERRORS); | 2694 _fillErrorListener(VERIFY_ERRORS); |
2503 errorListener.assertErrorsWithCodes( | 2695 errorListener.assertErrorsWithCodes( |
2504 <ErrorCode>[CompileTimeErrorCode.URI_DOES_NOT_EXIST]); | 2696 <ErrorCode>[CompileTimeErrorCode.URI_DOES_NOT_EXIST]); |
2505 } | 2697 } |
2506 | 2698 |
2507 test_perform_verifyError() { | 2699 test_perform_verifyError() { |
2508 Source source = newSource('/test.dart', ''' | 2700 Source source = newSource( |
| 2701 '/test.dart', |
| 2702 ''' |
2509 main() { | 2703 main() { |
2510 if (42) { | 2704 if (42) { |
2511 print('Not bool!'); | 2705 print('Not bool!'); |
2512 } | 2706 } |
2513 } | 2707 } |
2514 '''); | 2708 '''); |
2515 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2709 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2516 computeResult(target, VERIFY_ERRORS); | 2710 computeResult(target, VERIFY_ERRORS); |
2517 expect(task, new isInstanceOf<VerifyUnitTask>()); | 2711 expect(task, new isInstanceOf<VerifyUnitTask>()); |
2518 // validate | 2712 // validate |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2573 /** | 2767 /** |
2574 * Fill [errorListener] with [result] errors in the current [task]. | 2768 * Fill [errorListener] with [result] errors in the current [task]. |
2575 */ | 2769 */ |
2576 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 2770 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
2577 List<AnalysisError> errors = task.outputs[result]; | 2771 List<AnalysisError> errors = task.outputs[result]; |
2578 expect(errors, isNotNull, reason: result.name); | 2772 expect(errors, isNotNull, reason: result.name); |
2579 errorListener = new GatheringErrorListener(); | 2773 errorListener = new GatheringErrorListener(); |
2580 errorListener.addAll(errors); | 2774 errorListener.addAll(errors); |
2581 } | 2775 } |
2582 } | 2776 } |
OLD | NEW |