| 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 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| (...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 } else if (resynthesized is VoidTypeImpl && original is VoidTypeImpl) { | 1137 } else if (resynthesized is VoidTypeImpl && original is VoidTypeImpl) { |
| 1138 expect(resynthesized, same(original)); | 1138 expect(resynthesized, same(original)); |
| 1139 } else if (resynthesized is DynamicTypeImpl && | 1139 } else if (resynthesized is DynamicTypeImpl && |
| 1140 original is UndefinedTypeImpl) { | 1140 original is UndefinedTypeImpl) { |
| 1141 // TODO(scheglov) In the strong mode constant variable like | 1141 // TODO(scheglov) In the strong mode constant variable like |
| 1142 // `var V = new Unresolved()` gets `UndefinedTypeImpl`, and it gets | 1142 // `var V = new Unresolved()` gets `UndefinedTypeImpl`, and it gets |
| 1143 // `DynamicTypeImpl` in the spec mode. | 1143 // `DynamicTypeImpl` in the spec mode. |
| 1144 } else if (resynthesized is BottomTypeImpl && original is BottomTypeImpl) { | 1144 } else if (resynthesized is BottomTypeImpl && original is BottomTypeImpl) { |
| 1145 expect(resynthesized, same(original)); | 1145 expect(resynthesized, same(original)); |
| 1146 } else if (resynthesized.runtimeType != original.runtimeType) { | 1146 } else if (resynthesized.runtimeType != original.runtimeType) { |
| 1147 fail('Type mismatch: expected ${original.runtimeType},' | 1147 fail('Type mismatch: expected $original,' |
| 1148 ' got ${resynthesized.runtimeType} ($desc)'); | 1148 ' got $resynthesized ($desc)'); |
| 1149 } else { | 1149 } else { |
| 1150 fail('Unimplemented comparison for ${original.runtimeType}'); | 1150 fail('Unimplemented comparison for ${original.runtimeType}'); |
| 1151 } | 1151 } |
| 1152 } | 1152 } |
| 1153 | 1153 |
| 1154 void compareVariableElements( | 1154 void compareVariableElements( |
| 1155 VariableElement resynthesized, VariableElement original, String desc) { | 1155 VariableElement resynthesized, VariableElement original, String desc) { |
| 1156 compareElements(resynthesized, original, desc); | 1156 compareElements(resynthesized, original, desc); |
| 1157 compareTypes(resynthesized.type, original.type, '$desc.type'); | 1157 compareTypes(resynthesized.type, original.type, '$desc.type'); |
| 1158 VariableElementImpl resynthesizedActual = | 1158 VariableElementImpl resynthesizedActual = |
| (...skipping 2520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3679 const v = 'abc'.length; | 3679 const v = 'abc'.length; |
| 3680 '''); | 3680 '''); |
| 3681 if (isStrongMode) { | 3681 if (isStrongMode) { |
| 3682 if (isSharedFrontEnd) { | 3682 if (isSharedFrontEnd) { |
| 3683 checkElementText(library, r''' | 3683 checkElementText(library, r''' |
| 3684 const int v = 'abc'. | 3684 const int v = 'abc'. |
| 3685 length/*location: dart:core;String;length?*/; | 3685 length/*location: dart:core;String;length?*/; |
| 3686 '''); | 3686 '''); |
| 3687 } else { | 3687 } else { |
| 3688 checkElementText(library, r''' | 3688 checkElementText(library, r''' |
| 3689 const dynamic v/*error: instanceGetter*/ = 'abc'. | 3689 const int v = 'abc'. |
| 3690 length/*location: dart:core;String;length?*/; | 3690 length/*location: dart:core;String;length?*/; |
| 3691 '''); | 3691 '''); |
| 3692 } | 3692 } |
| 3693 } else { | 3693 } else { |
| 3694 checkElementText(library, r''' | 3694 checkElementText(library, r''' |
| 3695 const dynamic v = 'abc'. | 3695 const dynamic v = 'abc'. |
| 3696 length/*location: dart:core;String;length?*/; | 3696 length/*location: dart:core;String;length?*/; |
| 3697 '''); | 3697 '''); |
| 3698 } | 3698 } |
| 3699 } | 3699 } |
| 3700 | 3700 |
| 3701 test_const_length_ofTopLevelVariable() async { | 3701 test_const_length_ofTopLevelVariable() async { |
| 3702 var library = await checkLibrary(r''' | 3702 var library = await checkLibrary(r''' |
| 3703 const String S = 'abc'; | 3703 const String S = 'abc'; |
| 3704 const v = S.length; | 3704 const v = S.length; |
| 3705 '''); | 3705 '''); |
| 3706 if (isStrongMode) { | 3706 if (isStrongMode) { |
| 3707 if (isSharedFrontEnd) { | 3707 if (isSharedFrontEnd) { |
| 3708 checkElementText(library, r''' | 3708 checkElementText(library, r''' |
| 3709 const String S = 'abc'; | 3709 const String S = 'abc'; |
| 3710 const int v = | 3710 const int v = |
| 3711 S/*location: test.dart;S?*/. | 3711 S/*location: test.dart;S?*/. |
| 3712 length/*location: dart:core;String;length?*/; | 3712 length/*location: dart:core;String;length?*/; |
| 3713 '''); | 3713 '''); |
| 3714 } else { | 3714 } else { |
| 3715 checkElementText(library, r''' | 3715 checkElementText(library, r''' |
| 3716 const String S = 'abc'; | 3716 const String S = 'abc'; |
| 3717 const dynamic v/*error: instanceGetter*/ = | 3717 const int v = |
| 3718 S/*location: test.dart;S?*/. | 3718 S/*location: test.dart;S?*/. |
| 3719 length/*location: dart:core;String;length?*/; | 3719 length/*location: dart:core;String;length?*/; |
| 3720 '''); | 3720 '''); |
| 3721 } | 3721 } |
| 3722 } else { | 3722 } else { |
| 3723 checkElementText(library, r''' | 3723 checkElementText(library, r''' |
| 3724 const String S = 'abc'; | 3724 const String S = 'abc'; |
| 3725 const dynamic v = | 3725 const dynamic v = |
| 3726 S/*location: test.dart;S?*/. | 3726 S/*location: test.dart;S?*/. |
| 3727 length/*location: dart:core;String;length?*/; | 3727 length/*location: dart:core;String;length?*/; |
| 3728 '''); | 3728 '''); |
| 3729 } | 3729 } |
| 3730 } | 3730 } |
| 3731 | 3731 |
| 3732 test_const_length_ofTopLevelVariable_imported() async { | 3732 test_const_length_ofTopLevelVariable_imported() async { |
| 3733 addLibrarySource('/a.dart', r''' | 3733 addLibrarySource('/a.dart', r''' |
| 3734 const String S = 'abc'; | 3734 const String S = 'abc'; |
| 3735 '''); | 3735 '''); |
| 3736 var library = await checkLibrary(r''' | 3736 var library = await checkLibrary(r''' |
| 3737 import 'a.dart'; | 3737 import 'a.dart'; |
| 3738 const v = S.length; | 3738 const v = S.length; |
| 3739 '''); | 3739 '''); |
| 3740 if (isStrongMode) { | 3740 if (isStrongMode) { |
| 3741 checkElementText(library, r''' | 3741 checkElementText(library, r''' |
| 3742 import 'a.dart'; | 3742 import 'a.dart'; |
| 3743 const dynamic v/*error: instanceGetter*/ = | 3743 const int v = |
| 3744 S/*location: a.dart;S?*/. | 3744 S/*location: a.dart;S?*/. |
| 3745 length/*location: dart:core;String;length?*/; | 3745 length/*location: dart:core;String;length?*/; |
| 3746 '''); | 3746 '''); |
| 3747 } else { | 3747 } else { |
| 3748 checkElementText(library, r''' | 3748 checkElementText(library, r''' |
| 3749 import 'a.dart'; | 3749 import 'a.dart'; |
| 3750 const dynamic v = | 3750 const dynamic v = |
| 3751 S/*location: a.dart;S?*/. | 3751 S/*location: a.dart;S?*/. |
| 3752 length/*location: dart:core;String;length?*/; | 3752 length/*location: dart:core;String;length?*/; |
| 3753 '''); | 3753 '''); |
| 3754 } | 3754 } |
| 3755 } | 3755 } |
| 3756 | 3756 |
| 3757 test_const_length_ofTopLevelVariable_imported_withPrefix() async { | 3757 test_const_length_ofTopLevelVariable_imported_withPrefix() async { |
| 3758 addLibrarySource('/a.dart', r''' | 3758 addLibrarySource('/a.dart', r''' |
| 3759 const String S = 'abc'; | 3759 const String S = 'abc'; |
| 3760 '''); | 3760 '''); |
| 3761 var library = await checkLibrary(r''' | 3761 var library = await checkLibrary(r''' |
| 3762 import 'a.dart' as p; | 3762 import 'a.dart' as p; |
| 3763 const v = p.S.length; | 3763 const v = p.S.length; |
| 3764 '''); | 3764 '''); |
| 3765 if (isStrongMode) { | 3765 if (isStrongMode) { |
| 3766 checkElementText(library, r''' | 3766 checkElementText(library, r''' |
| 3767 import 'a.dart' as p; | 3767 import 'a.dart' as p; |
| 3768 const dynamic v/*error: instanceGetter*/ = | 3768 const int v = |
| 3769 p/*location: test.dart;p*/. | 3769 p/*location: test.dart;p*/. |
| 3770 S/*location: a.dart;S?*/. | 3770 S/*location: a.dart;S?*/. |
| 3771 length/*location: dart:core;String;length?*/; | 3771 length/*location: dart:core;String;length?*/; |
| 3772 '''); | 3772 '''); |
| 3773 } else { | 3773 } else { |
| 3774 checkElementText(library, r''' | 3774 checkElementText(library, r''' |
| 3775 import 'a.dart' as p; | 3775 import 'a.dart' as p; |
| 3776 const dynamic v = | 3776 const dynamic v = |
| 3777 p/*location: test.dart;p*/. | 3777 p/*location: test.dart;p*/. |
| 3778 S/*location: a.dart;S?*/. | 3778 S/*location: a.dart;S?*/. |
| (...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4914 checkElementText(library, r''' | 4914 checkElementText(library, r''' |
| 4915 enum E { | 4915 enum E { |
| 4916 synthetic final int index; | 4916 synthetic final int index; |
| 4917 synthetic static const List<E> values; | 4917 synthetic static const List<E> values; |
| 4918 static const E a; | 4918 static const E a; |
| 4919 static const E b; | 4919 static const E b; |
| 4920 static const E c; | 4920 static const E c; |
| 4921 } | 4921 } |
| 4922 final E vValue; | 4922 final E vValue; |
| 4923 final List<E> vValues; | 4923 final List<E> vValues; |
| 4924 final dynamic vIndex/*error: instanceGetter*/; | 4924 final int vIndex; |
| 4925 '''); | 4925 '''); |
| 4926 } else { | 4926 } else { |
| 4927 checkElementText(library, r''' | 4927 checkElementText(library, r''' |
| 4928 enum E { | 4928 enum E { |
| 4929 synthetic final int index; | 4929 synthetic final int index; |
| 4930 synthetic static const List<E> values; | 4930 synthetic static const List<E> values; |
| 4931 static const E a; | 4931 static const E a; |
| 4932 static const E b; | 4932 static const E b; |
| 4933 static const E c; | 4933 static const E c; |
| 4934 } | 4934 } |
| (...skipping 8235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13170 fail('Unexpectedly tried to get unlinked summary for $uri'); | 13170 fail('Unexpectedly tried to get unlinked summary for $uri'); |
| 13171 } | 13171 } |
| 13172 return serializedUnit; | 13172 return serializedUnit; |
| 13173 } | 13173 } |
| 13174 | 13174 |
| 13175 @override | 13175 @override |
| 13176 bool hasLibrarySummary(String uri) { | 13176 bool hasLibrarySummary(String uri) { |
| 13177 return true; | 13177 return true; |
| 13178 } | 13178 } |
| 13179 } | 13179 } |
| OLD | NEW |