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.serialization.elements_test; | 5 library test.src.serialization.elements_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
9 import 'package:analyzer/dart/constant/value.dart'; | 9 import 'package:analyzer/dart/constant/value.dart'; |
10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 } | 890 } |
891 if (original is! Member) { | 891 if (original is! Member) { |
892 List<LabelElement> rLabels = resynthesized.labels; | 892 List<LabelElement> rLabels = resynthesized.labels; |
893 List<LabelElement> oLabels = original.labels; | 893 List<LabelElement> oLabels = original.labels; |
894 expect(rLabels, hasLength(oLabels.length)); | 894 expect(rLabels, hasLength(oLabels.length)); |
895 for (int i = 0; i < oLabels.length; i++) { | 895 for (int i = 0; i < oLabels.length; i++) { |
896 compareLabelElements( | 896 compareLabelElements( |
897 rLabels[i], oLabels[i], '$desc label ${oLabels[i].name}'); | 897 rLabels[i], oLabels[i], '$desc label ${oLabels[i].name}'); |
898 } | 898 } |
899 } | 899 } |
900 if (original is! Member) { | |
901 List<LocalVariableElement> rVariables = resynthesized.localVariables; | |
902 List<LocalVariableElement> oVariables = original.localVariables; | |
903 expect(rVariables, hasLength(oVariables.length)); | |
904 for (int i = 0; i < oVariables.length; i++) { | |
905 compareVariableElements(rVariables[i], oVariables[i], | |
906 '$desc local variable ${oVariables[i].name}'); | |
907 } | |
908 } | |
909 } | 900 } |
910 | 901 |
911 void compareMetadata(List<ElementAnnotation> resynthesized, | 902 void compareMetadata(List<ElementAnnotation> resynthesized, |
912 List<ElementAnnotation> original, String desc) { | 903 List<ElementAnnotation> original, String desc) { |
913 expect(resynthesized, hasLength(original.length), reason: desc); | 904 expect(resynthesized, hasLength(original.length), reason: desc); |
914 for (int i = 0; i < original.length; i++) { | 905 for (int i = 0; i < original.length; i++) { |
915 compareElementAnnotations( | 906 compareElementAnnotations( |
916 resynthesized[i], original[i], '$desc annotation $i'); | 907 resynthesized[i], original[i], '$desc annotation $i'); |
917 } | 908 } |
918 } | 909 } |
(...skipping 9681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10600 '''); | 10591 '''); |
10601 } else { | 10592 } else { |
10602 checkElementText( | 10593 checkElementText( |
10603 library, | 10594 library, |
10604 r''' | 10595 r''' |
10605 dynamic main() {} | 10596 dynamic main() {} |
10606 '''); | 10597 '''); |
10607 } | 10598 } |
10608 } | 10599 } |
10609 | 10600 |
10610 test_localVariables_inConstructor() { | |
10611 var library = checkLibrary(r''' | |
10612 class C { | |
10613 C() { | |
10614 int v; | |
10615 f() {} | |
10616 } | |
10617 } | |
10618 '''); | |
10619 if (isStrongMode) { | |
10620 checkElementText( | |
10621 library, | |
10622 r''' | |
10623 class C { | |
10624 C(); | |
10625 } | |
10626 '''); | |
10627 } else { | |
10628 checkElementText( | |
10629 library, | |
10630 r''' | |
10631 class C { | |
10632 C(); | |
10633 } | |
10634 '''); | |
10635 } | |
10636 } | |
10637 | |
10638 test_localVariables_inLocalFunction() { | |
10639 var library = checkLibrary(r''' | |
10640 f() { | |
10641 f1() { | |
10642 int v1 = 1; | |
10643 } // 2 | |
10644 f2() { | |
10645 int v1 = 1; | |
10646 f3() { | |
10647 int v2 = 1; | |
10648 } | |
10649 } | |
10650 } | |
10651 '''); | |
10652 if (isStrongMode) { | |
10653 checkElementText( | |
10654 library, | |
10655 r''' | |
10656 dynamic f() {} | |
10657 '''); | |
10658 } else { | |
10659 checkElementText( | |
10660 library, | |
10661 r''' | |
10662 dynamic f() {} | |
10663 '''); | |
10664 } | |
10665 } | |
10666 | |
10667 test_localVariables_inMethod() { | |
10668 var library = checkLibrary(r''' | |
10669 class C { | |
10670 m() { | |
10671 int v; | |
10672 } | |
10673 } | |
10674 '''); | |
10675 if (isStrongMode) { | |
10676 checkElementText( | |
10677 library, | |
10678 r''' | |
10679 class C { | |
10680 dynamic m() {} | |
10681 } | |
10682 '''); | |
10683 } else { | |
10684 checkElementText( | |
10685 library, | |
10686 r''' | |
10687 class C { | |
10688 dynamic m() {} | |
10689 } | |
10690 '''); | |
10691 } | |
10692 } | |
10693 | |
10694 test_localVariables_inTopLevelFunction() { | |
10695 var library = checkLibrary(r''' | |
10696 main() { | |
10697 int v1 = 1; | |
10698 { | |
10699 const String v2 = 'bbb'; | |
10700 } | |
10701 Map<int, List<double>> v3; | |
10702 } | |
10703 '''); | |
10704 if (isStrongMode) { | |
10705 checkElementText( | |
10706 library, | |
10707 r''' | |
10708 dynamic main() {} | |
10709 '''); | |
10710 } else { | |
10711 checkElementText( | |
10712 library, | |
10713 r''' | |
10714 dynamic main() {} | |
10715 '''); | |
10716 } | |
10717 } | |
10718 | |
10719 test_localVariables_inTopLevelGetter() { | |
10720 var library = checkLibrary(r''' | |
10721 get g { | |
10722 int v; | |
10723 } | |
10724 '''); | |
10725 if (isStrongMode) { | |
10726 checkElementText( | |
10727 library, | |
10728 r''' | |
10729 dynamic get g {} | |
10730 '''); | |
10731 } else { | |
10732 checkElementText( | |
10733 library, | |
10734 r''' | |
10735 dynamic get g {} | |
10736 '''); | |
10737 } | |
10738 } | |
10739 | |
10740 test_main_class() { | 10601 test_main_class() { |
10741 var library = checkLibrary('class main {}'); | 10602 var library = checkLibrary('class main {}'); |
10742 if (isStrongMode) { | 10603 if (isStrongMode) { |
10743 checkElementText( | 10604 checkElementText( |
10744 library, | 10605 library, |
10745 r''' | 10606 r''' |
10746 class main { | 10607 class main { |
10747 } | 10608 } |
10748 '''); | 10609 '''); |
10749 } else { | 10610 } else { |
(...skipping 4562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15312 fail('Unexpectedly tried to get unlinked summary for $uri'); | 15173 fail('Unexpectedly tried to get unlinked summary for $uri'); |
15313 } | 15174 } |
15314 return serializedUnit; | 15175 return serializedUnit; |
15315 } | 15176 } |
15316 | 15177 |
15317 @override | 15178 @override |
15318 bool hasLibrarySummary(String uri) { | 15179 bool hasLibrarySummary(String uri) { |
15319 return true; | 15180 return true; |
15320 } | 15181 } |
15321 } | 15182 } |
OLD | NEW |