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

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

Issue 1610043002: Add propagated types to summary files. (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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 expect(resynthesized.uriEnd, original.uriEnd, reason: desc); 502 expect(resynthesized.uriEnd, original.uriEnd, reason: desc);
503 } 503 }
504 504
505 void compareVariableElements(VariableElementImpl resynthesized, 505 void compareVariableElements(VariableElementImpl resynthesized,
506 VariableElementImpl original, String desc) { 506 VariableElementImpl original, String desc) {
507 compareElements(resynthesized, original, desc); 507 compareElements(resynthesized, original, desc);
508 compareTypes(resynthesized.type, original.type, desc); 508 compareTypes(resynthesized.type, original.type, desc);
509 // TODO(paulberry): test initializer 509 // TODO(paulberry): test initializer
510 } 510 }
511 511
512 fail_field_propagatedType_const_noDep() {
513 checkLibrary('''
514 class C {
515 static const x = 0;
516 }''');
517 }
518
519 fail_field_propagatedType_final_dep_inLib() {
520 addNamedSource('/a.dart', 'final a = 1;');
521 checkLibrary('''
522 import "a.dart";
523 class C {
524 final b = a / 2;
525 }''');
526 }
527
528 fail_field_propagatedType_final_dep_inPart() {
529 addNamedSource('/a.dart', 'part of lib; final a = 1;');
530 checkLibrary('''
531 library lib;
532 part "a.dart";
533 class C {
534 final b = a / 2;
535 }''');
536 }
537
538 fail_field_propagatedType_final_noDep_instance() {
539 checkLibrary('''
540 class C {
541 final x = 0;
542 }''');
543 }
544
545 fail_field_propagatedType_final_noDep_static() {
546 checkLibrary('''
547 class C {
548 static final x = 0;
549 }''');
550 }
551
552 fail_library_hasExtUri() { 512 fail_library_hasExtUri() {
553 checkLibrary('import "dart-ext:doesNotExist.dart";'); 513 checkLibrary('import "dart-ext:doesNotExist.dart";');
554 } 514 }
555 515
556 fail_variable_propagatedType_const_noDep() {
557 checkLibrary('const i = 0;');
558 }
559
560 fail_variable_propagatedType_final_dep_inLib() {
561 addNamedSource('/a.dart', 'final a = 1;');
562 checkLibrary('import "a.dart"; final b = a / 2;');
563 }
564
565 fail_variable_propagatedType_final_dep_inPart() {
566 addNamedSource('/a.dart', 'part of lib; final a = 1;');
567 checkLibrary('library lib; part "a.dart"; final b = a / 2;');
568 }
569
570 fail_variable_propagatedType_final_noDep() {
571 checkLibrary('final i = 0;');
572 }
573
574 ElementImpl getActualElement(Element element, String desc) { 516 ElementImpl getActualElement(Element element, String desc) {
575 if (element is ElementHandle) { 517 if (element is ElementHandle) {
576 return element.actualElement; 518 return element.actualElement;
577 } else if (element is ElementImpl) { 519 } else if (element is ElementImpl) {
578 return element; 520 return element;
579 } else { 521 } else {
580 fail('Unexpected type for resynthesized ($desc):' 522 fail('Unexpected type for resynthesized ($desc):'
581 ' ${element.runtimeType}'); 523 ' ${element.runtimeType}');
582 return null; 524 return null;
583 } 525 }
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 test_field_documented() { 977 test_field_documented() {
1036 checkLibrary(''' 978 checkLibrary('''
1037 class C { 979 class C {
1038 /** 980 /**
1039 * Docs 981 * Docs
1040 */ 982 */
1041 var x; 983 var x;
1042 }'''); 984 }''');
1043 } 985 }
1044 986
987 test_field_propagatedType_const_noDep() {
988 checkLibrary('''
989 class C {
990 static const x = 0;
991 }''');
992 }
993
994 test_field_propagatedType_final_dep_inLib() {
995 addNamedSource('/a.dart', 'final a = 1;');
996 checkLibrary('''
997 import "a.dart";
998 class C {
999 final b = a / 2;
1000 }''');
1001 }
1002
1003 test_field_propagatedType_final_dep_inPart() {
1004 addNamedSource('/a.dart', 'part of lib; final a = 1;');
1005 checkLibrary('''
1006 library lib;
1007 part "a.dart";
1008 class C {
1009 final b = a / 2;
1010 }''');
1011 }
1012
1013 test_field_propagatedType_final_noDep_instance() {
1014 checkLibrary('''
1015 class C {
1016 final x = 0;
1017 }''');
1018 }
1019
1020 test_field_propagatedType_final_noDep_static() {
1021 checkLibrary('''
1022 class C {
1023 static final x = 0;
1024 }''');
1025 }
1026
1045 test_function_documented() { 1027 test_function_documented() {
1046 checkLibrary(''' 1028 checkLibrary('''
1047 // Extra comment so doc comment offset != 0 1029 // Extra comment so doc comment offset != 0
1048 /** 1030 /**
1049 * Docs 1031 * Docs
1050 */ 1032 */
1051 f() {}'''); 1033 f() {}''');
1052 } 1034 }
1053 1035
1054 test_function_entry_point() { 1036 test_function_entry_point() {
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 test_variable_getterInPart_setterInPart() { 1575 test_variable_getterInPart_setterInPart() {
1594 addNamedSource('/a.dart', 'part of my.lib; int get x => 42;'); 1576 addNamedSource('/a.dart', 'part of my.lib; int get x => 42;');
1595 addNamedSource('/b.dart', 'part of my.lib; void set x(int _) {}'); 1577 addNamedSource('/b.dart', 'part of my.lib; void set x(int _) {}');
1596 checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); 1578 checkLibrary('library my.lib; part "a.dart"; part "b.dart";');
1597 } 1579 }
1598 1580
1599 test_variable_implicit_type() { 1581 test_variable_implicit_type() {
1600 checkLibrary('var x;'); 1582 checkLibrary('var x;');
1601 } 1583 }
1602 1584
1585 test_variable_propagatedType_const_noDep() {
1586 checkLibrary('const i = 0;');
1587 }
1588
1589 test_variable_propagatedType_final_dep_inLib() {
1590 addNamedSource('/a.dart', 'final a = 1;');
1591 checkLibrary('import "a.dart"; final b = a / 2;');
1592 }
1593
1594 test_variable_propagatedType_final_dep_inPart() {
1595 addNamedSource('/a.dart', 'part of lib; final a = 1;');
1596 checkLibrary('library lib; part "a.dart"; final b = a / 2;');
1597 }
1598
1599 test_variable_propagatedType_final_noDep() {
1600 checkLibrary('final i = 0;');
1601 }
1602
1603 test_variable_propagatedType_implicit_dep() {
1604 // The propagated type is defined in a library that is not imported.
1605 addNamedSource('/a.dart', 'class C {}');
1606 addNamedSource('/b.dart', 'import "a.dart"; C f() => null;');
1607 checkLibrary('import "b.dart"; final x = f();');
1608 }
1609
1603 test_variable_setterInPart_getterInPart() { 1610 test_variable_setterInPart_getterInPart() {
1604 addNamedSource('/a.dart', 'part of my.lib; void set x(int _) {}'); 1611 addNamedSource('/a.dart', 'part of my.lib; void set x(int _) {}');
1605 addNamedSource('/b.dart', 'part of my.lib; int get x => 42;'); 1612 addNamedSource('/b.dart', 'part of my.lib; int get x => 42;');
1606 checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); 1613 checkLibrary('library my.lib; part "a.dart"; part "b.dart";');
1607 } 1614 }
1608 1615
1609 test_variables() { 1616 test_variables() {
1610 checkLibrary('int i; int j;'); 1617 checkLibrary('int i; int j;');
1611 } 1618 }
1612 } 1619 }
(...skipping 27 matching lines...) Expand all
1640 fail('Unexpectedly tried to get unlinked summary for $uri'); 1647 fail('Unexpectedly tried to get unlinked summary for $uri');
1641 } 1648 }
1642 return serializedUnit; 1649 return serializedUnit;
1643 } 1650 }
1644 1651
1645 @override 1652 @override
1646 bool hasLibrarySummary(String uri) { 1653 bool hasLibrarySummary(String uri) {
1647 return true; 1654 return true;
1648 } 1655 }
1649 } 1656 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_elements.dart ('k') | pkg/analyzer/test/src/summary/summary_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698