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

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

Issue 1642993003: Resynthesize untyped List / Map. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 expect(resynthesized.isNull, isTrue, reason: desc); 215 expect(resynthesized.isNull, isTrue, reason: desc);
216 } else if (original.toBoolValue() != null) { 216 } else if (original.toBoolValue() != null) {
217 expect(resynthesized.toBoolValue(), original.toBoolValue(), 217 expect(resynthesized.toBoolValue(), original.toBoolValue(),
218 reason: desc); 218 reason: desc);
219 } else if (original.toIntValue() != null) { 219 } else if (original.toIntValue() != null) {
220 expect(resynthesized.toIntValue(), original.toIntValue(), reason: desc); 220 expect(resynthesized.toIntValue(), original.toIntValue(), reason: desc);
221 } else if (original.toDoubleValue() != null) { 221 } else if (original.toDoubleValue() != null) {
222 expect(resynthesized.toDoubleValue(), original.toDoubleValue(), 222 expect(resynthesized.toDoubleValue(), original.toDoubleValue(),
223 reason: desc); 223 reason: desc);
224 } else if (original.toListValue() != null) { 224 } else if (original.toListValue() != null) {
225 fail('Not implemented'); 225 List<DartObject> resynthesizedList = resynthesized.toListValue();
226 List<DartObject> originalList = original.toListValue();
227 expect(resynthesizedList, hasLength(originalList.length));
228 for (int i = 0; i < originalList.length; i++) {
229 compareConstantValues(resynthesizedList[i], originalList[i], desc);
230 }
226 } else if (original.toMapValue() != null) { 231 } else if (original.toMapValue() != null) {
227 fail('Not implemented'); 232 Map<DartObject, DartObject> resynthesizedMap =
233 resynthesized.toMapValue();
234 Map<DartObject, DartObject> originalMap = original.toMapValue();
235 expect(resynthesizedMap, hasLength(originalMap.length));
236 originalMap.forEach((originalKey, originalValue) {
Paul Berry 2016/01/28 23:43:07 In Dart, maps are ordered, so there are subtle sem
scheglov 2016/01/29 17:07:08 Thanks, I will add better validation. It turned ou
237 DartObject resynthesizedValue = resynthesizedMap[originalKey];
238 compareConstantValues(resynthesizedValue, originalValue, desc);
239 });
228 } else if (original.toStringValue() != null) { 240 } else if (original.toStringValue() != null) {
229 expect(resynthesized.toStringValue(), original.toStringValue(), 241 expect(resynthesized.toStringValue(), original.toStringValue(),
230 reason: desc); 242 reason: desc);
231 } else if (original.toSymbolValue() != null) { 243 } else if (original.toSymbolValue() != null) {
232 expect(resynthesized.toSymbolValue(), original.toSymbolValue(), 244 expect(resynthesized.toSymbolValue(), original.toSymbolValue(),
233 reason: desc); 245 reason: desc);
234 } else if (original.toTypeValue() != null) { 246 } else if (original.toTypeValue() != null) {
235 fail('Not implemented'); 247 fail('Not implemented');
236 } 248 }
237 // TODO(scheglov) implement 249 // TODO(scheglov) implement
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 test_const_topLevel_unary() { 1022 test_const_topLevel_unary() {
1011 shouldCompareConstValues = true; 1023 shouldCompareConstValues = true;
1012 checkLibrary(r''' 1024 checkLibrary(r'''
1013 const vNotEqual = 1 != 2; 1025 const vNotEqual = 1 != 2;
1014 const vNot = !true; 1026 const vNot = !true;
1015 const vNegate = -1; 1027 const vNegate = -1;
1016 const vComplement = ~1; 1028 const vComplement = ~1;
1017 '''); 1029 ''');
1018 } 1030 }
1019 1031
1032 test_const_topLevel_untypedList() {
1033 shouldCompareConstValues = true;
1034 checkLibrary(r'''
1035 const v = const [1, 2, 3];
1036 ''');
1037 }
1038
1039 test_const_topLevel_untypedMap() {
1040 shouldCompareConstValues = true;
1041 checkLibrary(r'''
1042 const v = const {0: 'aaa', 1: 'bbb', 2: 'ccc'};
1043 ''');
1044 }
1045
1020 test_constructor_documented() { 1046 test_constructor_documented() {
1021 checkLibrary(''' 1047 checkLibrary('''
1022 class C { 1048 class C {
1023 /** 1049 /**
1024 * Docs 1050 * Docs
1025 */ 1051 */
1026 C(); 1052 C();
1027 }'''); 1053 }''');
1028 } 1054 }
1029 1055
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
1957 fail('Unexpectedly tried to get unlinked summary for $uri'); 1983 fail('Unexpectedly tried to get unlinked summary for $uri');
1958 } 1984 }
1959 return serializedUnit; 1985 return serializedUnit;
1960 } 1986 }
1961 1987
1962 @override 1988 @override
1963 bool hasLibrarySummary(String uri) { 1989 bool hasLibrarySummary(String uri) {
1964 return true; 1990 return true;
1965 } 1991 }
1966 } 1992 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698