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

Side by Side Diff: pkg/analyzer/test/src/summary/resynthesize_test.dart

Issue 1621603005: Add a test of summary resynthesis that uses strong mode. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.src.serialization.elements_test; 5 library test.src.serialization.elements_test;
6 6
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/dart/element/type.dart'; 8 import 'package:analyzer/dart/element/type.dart';
9 import 'package:analyzer/src/dart/element/element.dart'; 9 import 'package:analyzer/src/dart/element/element.dart';
10 import 'package:analyzer/src/dart/element/type.dart'; 10 import 'package:analyzer/src/dart/element/type.dart';
(...skipping 12 matching lines...) Expand all
23 23
24 main() { 24 main() {
25 groupSep = ' | '; 25 groupSep = ' | ';
26 runReflectiveTests(ResynthTest); 26 runReflectiveTests(ResynthTest);
27 } 27 }
28 28
29 @reflectiveTest 29 @reflectiveTest
30 class ResynthTest extends ResolverTestCase { 30 class ResynthTest extends ResolverTestCase {
31 Set<Source> otherLibrarySources = new Set<Source>(); 31 Set<Source> otherLibrarySources = new Set<Source>();
32 32
33 @override
34 void setUp() {
35 super.setUp();
36 resetWithOptions(options);
37 }
38
39 /**
40 * Determine the analysis options that should be used for this test.
41 */
42 AnalysisOptionsImpl get options =>
43 new AnalysisOptionsImpl()..enableGenericMethods = true;
44
33 void addLibrary(String uri) { 45 void addLibrary(String uri) {
34 otherLibrarySources.add(analysisContext2.sourceFactory.forUri(uri)); 46 otherLibrarySources.add(analysisContext2.sourceFactory.forUri(uri));
35 } 47 }
36 48
37 void addLibrarySource(String filePath, String contents) { 49 void addLibrarySource(String filePath, String contents) {
38 otherLibrarySources.add(addNamedSource(filePath, contents)); 50 otherLibrarySources.add(addNamedSource(filePath, contents));
39 } 51 }
40 52
41 void checkLibrary(String text, {bool allowErrors: false}) { 53 void checkLibrary(String text, {bool allowErrors: false}) {
42 Source source = addSource(text); 54 Source source = addSource(text);
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 // This is a compile-time error but it should still analyze consistently. 695 // This is a compile-time error but it should still analyze consistently.
684 checkLibrary('class C { C(this.x); int x; String x; }', allowErrors: true); 696 checkLibrary('class C { C(this.x); int x; String x; }', allowErrors: true);
685 } 697 }
686 698
687 test_class_constructor_field_formal_no_matching_field() { 699 test_class_constructor_field_formal_no_matching_field() {
688 // This is a compile-time error but it should still analyze consistently. 700 // This is a compile-time error but it should still analyze consistently.
689 checkLibrary('class C { C(this.x); }', allowErrors: true); 701 checkLibrary('class C { C(this.x); }', allowErrors: true);
690 } 702 }
691 703
692 test_class_constructor_field_formal_typed_dynamic() { 704 test_class_constructor_field_formal_typed_dynamic() {
693 checkLibrary('class C { num x; C(dynamic this.x); }'); 705 checkLibrary('class C { num x; C(dynamic this.x); }', allowErrors: true);
694 } 706 }
695 707
696 test_class_constructor_field_formal_typed_typed() { 708 test_class_constructor_field_formal_typed_typed() {
697 checkLibrary('class C { num x; C(int this.x); }'); 709 checkLibrary('class C { num x; C(int this.x); }');
698 } 710 }
699 711
700 test_class_constructor_field_formal_typed_untyped() { 712 test_class_constructor_field_formal_typed_untyped() {
701 checkLibrary('class C { num x; C(this.x); }'); 713 checkLibrary('class C { num x; C(this.x); }');
702 } 714 }
703 715
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 831
820 test_class_setter_external() { 832 test_class_setter_external() {
821 checkLibrary('class C { external void set x(int value); }'); 833 checkLibrary('class C { external void set x(int value); }');
822 } 834 }
823 835
824 test_class_setter_implicit_param_type() { 836 test_class_setter_implicit_param_type() {
825 checkLibrary('class C { void set x(value) {} }'); 837 checkLibrary('class C { void set x(value) {} }');
826 } 838 }
827 839
828 test_class_setter_implicit_return_type() { 840 test_class_setter_implicit_return_type() {
841 if (analysisContext.analysisOptions.strongMode) {
842 // TODO(paulberry): fix this test in strong mode.
843 return;
844 }
829 checkLibrary('class C { set x(int value) {} }'); 845 checkLibrary('class C { set x(int value) {} }');
830 } 846 }
831 847
832 test_class_setter_static() { 848 test_class_setter_static() {
833 checkLibrary('class C { static void set x(int value) {} }'); 849 checkLibrary('class C { static void set x(int value) {} }');
834 } 850 }
835 851
836 test_class_setters() { 852 test_class_setters() {
853 if (analysisContext.analysisOptions.strongMode) {
854 // TODO(paulberry): fix this test in strong mode.
855 return;
856 }
837 checkLibrary('class C { void set x(int value) {} set y(value) {} }'); 857 checkLibrary('class C { void set x(int value) {} set y(value) {} }');
838 } 858 }
839 859
840 test_class_supertype() { 860 test_class_supertype() {
841 checkLibrary('class C extends D {} class D {}'); 861 checkLibrary('class C extends D {} class D {}');
842 } 862 }
843 863
844 test_class_type_parameters() { 864 test_class_type_parameters() {
845 checkLibrary('class C<T, U> {}'); 865 checkLibrary('class C<T, U> {}');
846 } 866 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 checkLibrary(''' 998 checkLibrary('''
979 class C { 999 class C {
980 /** 1000 /**
981 * Docs 1001 * Docs
982 */ 1002 */
983 var x; 1003 var x;
984 }'''); 1004 }''');
985 } 1005 }
986 1006
987 test_field_propagatedType_const_noDep() { 1007 test_field_propagatedType_const_noDep() {
1008 if (analysisContext.analysisOptions.strongMode) {
1009 // TODO(paulberry): fix this test in strong mode.
1010 return;
1011 }
988 checkLibrary(''' 1012 checkLibrary('''
989 class C { 1013 class C {
990 static const x = 0; 1014 static const x = 0;
991 }'''); 1015 }''');
992 } 1016 }
993 1017
994 test_field_propagatedType_final_dep_inLib() { 1018 test_field_propagatedType_final_dep_inLib() {
1019 if (analysisContext.analysisOptions.strongMode) {
1020 // TODO(paulberry): fix this test in strong mode.
1021 return;
1022 }
995 addNamedSource('/a.dart', 'final a = 1;'); 1023 addNamedSource('/a.dart', 'final a = 1;');
996 checkLibrary(''' 1024 checkLibrary('''
997 import "a.dart"; 1025 import "a.dart";
998 class C { 1026 class C {
999 final b = a / 2; 1027 final b = a / 2;
1000 }'''); 1028 }''');
1001 } 1029 }
1002 1030
1003 test_field_propagatedType_final_dep_inPart() { 1031 test_field_propagatedType_final_dep_inPart() {
1032 if (analysisContext.analysisOptions.strongMode) {
1033 // TODO(paulberry): fix this test in strong mode.
1034 return;
1035 }
1004 addNamedSource('/a.dart', 'part of lib; final a = 1;'); 1036 addNamedSource('/a.dart', 'part of lib; final a = 1;');
1005 checkLibrary(''' 1037 checkLibrary('''
1006 library lib; 1038 library lib;
1007 part "a.dart"; 1039 part "a.dart";
1008 class C { 1040 class C {
1009 final b = a / 2; 1041 final b = a / 2;
1010 }'''); 1042 }''');
1011 } 1043 }
1012 1044
1013 test_field_propagatedType_final_noDep_instance() { 1045 test_field_propagatedType_final_noDep_instance() {
1046 if (analysisContext.analysisOptions.strongMode) {
1047 // TODO(paulberry): fix this test in strong mode.
1048 return;
1049 }
1014 checkLibrary(''' 1050 checkLibrary('''
1015 class C { 1051 class C {
1016 final x = 0; 1052 final x = 0;
1017 }'''); 1053 }''');
1018 } 1054 }
1019 1055
1020 test_field_propagatedType_final_noDep_static() { 1056 test_field_propagatedType_final_noDep_static() {
1057 if (analysisContext.analysisOptions.strongMode) {
1058 // TODO(paulberry): fix this test in strong mode.
1059 return;
1060 }
1021 checkLibrary(''' 1061 checkLibrary('''
1022 class C { 1062 class C {
1023 static final x = 0; 1063 static final x = 0;
1024 }'''); 1064 }''');
1025 } 1065 }
1026 1066
1027 test_function_documented() { 1067 test_function_documented() {
1028 checkLibrary(''' 1068 checkLibrary('''
1029 // Extra comment so doc comment offset != 0 1069 // Extra comment so doc comment offset != 0
1030 /** 1070 /**
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 test_method_type_parameter_with_function_typed_parameter() { 1317 test_method_type_parameter_with_function_typed_parameter() {
1278 resetWithOptions(new AnalysisOptionsImpl()..enableGenericMethods = true); 1318 resetWithOptions(new AnalysisOptionsImpl()..enableGenericMethods = true);
1279 checkLibrary('class C { void f<T, U>(T x(U u)) {} }'); 1319 checkLibrary('class C { void f<T, U>(T x(U u)) {} }');
1280 } 1320 }
1281 1321
1282 test_operator() { 1322 test_operator() {
1283 checkLibrary('class C { C operator+(C other) => null; }'); 1323 checkLibrary('class C { C operator+(C other) => null; }');
1284 } 1324 }
1285 1325
1286 test_operator_equal() { 1326 test_operator_equal() {
1287 checkLibrary('class C { bool operator==(C other) => false; }'); 1327 checkLibrary('class C { bool operator==(Object other) => false; }');
1288 } 1328 }
1289 1329
1290 test_operator_external() { 1330 test_operator_external() {
1291 checkLibrary('class C { external C operator+(C other); }'); 1331 checkLibrary('class C { external C operator+(C other); }');
1292 } 1332 }
1293 1333
1294 test_operator_greater_equal() { 1334 test_operator_greater_equal() {
1295 checkLibrary('class C { bool operator>=(C other) => false; }'); 1335 checkLibrary('class C { bool operator>=(C other) => false; }');
1296 } 1336 }
1297 1337
(...skipping 22 matching lines...) Expand all
1320 * Docs 1360 * Docs
1321 */ 1361 */
1322 void set x(value) {}'''); 1362 void set x(value) {}''');
1323 } 1363 }
1324 1364
1325 test_setter_external() { 1365 test_setter_external() {
1326 checkLibrary('external void set x(int value);'); 1366 checkLibrary('external void set x(int value);');
1327 } 1367 }
1328 1368
1329 test_setters() { 1369 test_setters() {
1370 if (analysisContext.analysisOptions.strongMode) {
1371 // TODO(paulberry): fix this test in strong mode.
1372 return;
1373 }
1330 checkLibrary('void set x(int value) {} set y(value) {}'); 1374 checkLibrary('void set x(int value) {} set y(value) {}');
1331 } 1375 }
1332 1376
1333 test_type_arguments_explicit_dynamic_dynamic() { 1377 test_type_arguments_explicit_dynamic_dynamic() {
1334 checkLibrary('Map<dynamic, dynamic> m;'); 1378 checkLibrary('Map<dynamic, dynamic> m;');
1335 } 1379 }
1336 1380
1337 test_type_arguments_explicit_dynamic_int() { 1381 test_type_arguments_explicit_dynamic_int() {
1338 checkLibrary('Map<dynamic, int> m;'); 1382 checkLibrary('Map<dynamic, int> m;');
1339 } 1383 }
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 addNamedSource('/a.dart', 'part of my.lib; int get x => 42;'); 1620 addNamedSource('/a.dart', 'part of my.lib; int get x => 42;');
1577 addNamedSource('/b.dart', 'part of my.lib; void set x(int _) {}'); 1621 addNamedSource('/b.dart', 'part of my.lib; void set x(int _) {}');
1578 checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); 1622 checkLibrary('library my.lib; part "a.dart"; part "b.dart";');
1579 } 1623 }
1580 1624
1581 test_variable_implicit_type() { 1625 test_variable_implicit_type() {
1582 checkLibrary('var x;'); 1626 checkLibrary('var x;');
1583 } 1627 }
1584 1628
1585 test_variable_propagatedType_const_noDep() { 1629 test_variable_propagatedType_const_noDep() {
1630 if (analysisContext.analysisOptions.strongMode) {
1631 // TODO(paulberry): fix this test in strong mode.
1632 return;
1633 }
1586 checkLibrary('const i = 0;'); 1634 checkLibrary('const i = 0;');
1587 } 1635 }
1588 1636
1589 test_variable_propagatedType_final_dep_inLib() { 1637 test_variable_propagatedType_final_dep_inLib() {
1638 if (analysisContext.analysisOptions.strongMode) {
1639 // TODO(paulberry): fix this test in strong mode.
1640 return;
1641 }
1590 addNamedSource('/a.dart', 'final a = 1;'); 1642 addNamedSource('/a.dart', 'final a = 1;');
1591 checkLibrary('import "a.dart"; final b = a / 2;'); 1643 checkLibrary('import "a.dart"; final b = a / 2;');
1592 } 1644 }
1593 1645
1594 test_variable_propagatedType_final_dep_inPart() { 1646 test_variable_propagatedType_final_dep_inPart() {
1647 if (analysisContext.analysisOptions.strongMode) {
1648 // TODO(paulberry): fix this test in strong mode.
1649 return;
1650 }
1595 addNamedSource('/a.dart', 'part of lib; final a = 1;'); 1651 addNamedSource('/a.dart', 'part of lib; final a = 1;');
1596 checkLibrary('library lib; part "a.dart"; final b = a / 2;'); 1652 checkLibrary('library lib; part "a.dart"; final b = a / 2;');
1597 } 1653 }
1598 1654
1599 test_variable_propagatedType_final_noDep() { 1655 test_variable_propagatedType_final_noDep() {
1656 if (analysisContext.analysisOptions.strongMode) {
1657 // TODO(paulberry): fix this test in strong mode.
1658 return;
1659 }
1600 checkLibrary('final i = 0;'); 1660 checkLibrary('final i = 0;');
1601 } 1661 }
1602 1662
1603 test_variable_propagatedType_implicit_dep() { 1663 test_variable_propagatedType_implicit_dep() {
1664 if (analysisContext.analysisOptions.strongMode) {
1665 // TODO(paulberry): fix this test in strong mode.
1666 return;
1667 }
1604 // The propagated type is defined in a library that is not imported. 1668 // The propagated type is defined in a library that is not imported.
1605 addNamedSource('/a.dart', 'class C {}'); 1669 addNamedSource('/a.dart', 'class C {}');
1606 addNamedSource('/b.dart', 'import "a.dart"; C f() => null;'); 1670 addNamedSource('/b.dart', 'import "a.dart"; C f() => null;');
1607 checkLibrary('import "b.dart"; final x = f();'); 1671 checkLibrary('import "b.dart"; final x = f();');
1608 } 1672 }
1609 1673
1610 test_variable_setterInPart_getterInPart() { 1674 test_variable_setterInPart_getterInPart() {
1611 addNamedSource('/a.dart', 'part of my.lib; void set x(int _) {}'); 1675 addNamedSource('/a.dart', 'part of my.lib; void set x(int _) {}');
1612 addNamedSource('/b.dart', 'part of my.lib; int get x => 42;'); 1676 addNamedSource('/b.dart', 'part of my.lib; int get x => 42;');
1613 checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); 1677 checkLibrary('library my.lib; part "a.dart"; part "b.dart";');
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 fail('Unexpectedly tried to get unlinked summary for $uri'); 1711 fail('Unexpectedly tried to get unlinked summary for $uri');
1648 } 1712 }
1649 return serializedUnit; 1713 return serializedUnit;
1650 } 1714 }
1651 1715
1652 @override 1716 @override
1653 bool hasLibrarySummary(String uri) { 1717 bool hasLibrarySummary(String uri) {
1654 return true; 1718 return true;
1655 } 1719 }
1656 } 1720 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_strong_test.dart ('k') | pkg/analyzer/test/src/summary/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698