| 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/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 Loading... |
| 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 List<DartObject> resynthesizedKeys = resynthesizedMap.keys.toList(); |
| 237 List<DartObject> originalKeys = originalMap.keys.toList(); |
| 238 for (int i = 0; i < originalKeys.length; i++) { |
| 239 DartObject resynthesizedKey = resynthesizedKeys[i]; |
| 240 DartObject originalKey = originalKeys[i]; |
| 241 compareConstantValues(resynthesizedKey, originalKey, desc); |
| 242 DartObject resynthesizedValue = resynthesizedMap[resynthesizedKey]; |
| 243 DartObject originalValue = originalMap[originalKey]; |
| 244 compareConstantValues(resynthesizedValue, originalValue, desc); |
| 245 } |
| 228 } else if (original.toStringValue() != null) { | 246 } else if (original.toStringValue() != null) { |
| 229 expect(resynthesized.toStringValue(), original.toStringValue(), | 247 expect(resynthesized.toStringValue(), original.toStringValue(), |
| 230 reason: desc); | 248 reason: desc); |
| 231 } else if (original.toSymbolValue() != null) { | 249 } else if (original.toSymbolValue() != null) { |
| 232 expect(resynthesized.toSymbolValue(), original.toSymbolValue(), | 250 expect(resynthesized.toSymbolValue(), original.toSymbolValue(), |
| 233 reason: desc); | 251 reason: desc); |
| 234 } else if (original.toTypeValue() != null) { | 252 } else if (original.toTypeValue() != null) { |
| 235 fail('Not implemented'); | 253 fail('Not implemented'); |
| 236 } | 254 } |
| 237 // TODO(scheglov) implement | 255 // TODO(scheglov) implement |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 test_const_topLevel_unary() { | 1028 test_const_topLevel_unary() { |
| 1011 shouldCompareConstValues = true; | 1029 shouldCompareConstValues = true; |
| 1012 checkLibrary(r''' | 1030 checkLibrary(r''' |
| 1013 const vNotEqual = 1 != 2; | 1031 const vNotEqual = 1 != 2; |
| 1014 const vNot = !true; | 1032 const vNot = !true; |
| 1015 const vNegate = -1; | 1033 const vNegate = -1; |
| 1016 const vComplement = ~1; | 1034 const vComplement = ~1; |
| 1017 '''); | 1035 '''); |
| 1018 } | 1036 } |
| 1019 | 1037 |
| 1038 test_const_topLevel_untypedList() { |
| 1039 shouldCompareConstValues = true; |
| 1040 checkLibrary(r''' |
| 1041 const v = const [1, 2, 3]; |
| 1042 '''); |
| 1043 } |
| 1044 |
| 1045 test_const_topLevel_untypedMap() { |
| 1046 shouldCompareConstValues = true; |
| 1047 checkLibrary(r''' |
| 1048 const v = const {0: 'aaa', 1: 'bbb', 2: 'ccc'}; |
| 1049 '''); |
| 1050 } |
| 1051 |
| 1020 test_constructor_documented() { | 1052 test_constructor_documented() { |
| 1021 checkLibrary(''' | 1053 checkLibrary(''' |
| 1022 class C { | 1054 class C { |
| 1023 /** | 1055 /** |
| 1024 * Docs | 1056 * Docs |
| 1025 */ | 1057 */ |
| 1026 C(); | 1058 C(); |
| 1027 }'''); | 1059 }'''); |
| 1028 } | 1060 } |
| 1029 | 1061 |
| (...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1957 fail('Unexpectedly tried to get unlinked summary for $uri'); | 1989 fail('Unexpectedly tried to get unlinked summary for $uri'); |
| 1958 } | 1990 } |
| 1959 return serializedUnit; | 1991 return serializedUnit; |
| 1960 } | 1992 } |
| 1961 | 1993 |
| 1962 @override | 1994 @override |
| 1963 bool hasLibrarySummary(String uri) { | 1995 bool hasLibrarySummary(String uri) { |
| 1964 return true; | 1996 return true; |
| 1965 } | 1997 } |
| 1966 } | 1998 } |
| OLD | NEW |