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

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

Issue 1671413003: Remove shouldCompareConstValues. (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 | « no previous file | 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/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/dart/element/type.dart'; 9 import 'package:analyzer/dart/element/type.dart';
10 import 'package:analyzer/src/dart/element/element.dart'; 10 import 'package:analyzer/src/dart/element/element.dart';
(...skipping 13 matching lines...) Expand all
24 import '../../reflective_tests.dart'; 24 import '../../reflective_tests.dart';
25 25
26 main() { 26 main() {
27 groupSep = ' | '; 27 groupSep = ' | ';
28 runReflectiveTests(ResynthTest); 28 runReflectiveTests(ResynthTest);
29 } 29 }
30 30
31 @reflectiveTest 31 @reflectiveTest
32 class ResynthTest extends ResolverTestCase { 32 class ResynthTest extends ResolverTestCase {
33 Set<Source> otherLibrarySources = new Set<Source>(); 33 Set<Source> otherLibrarySources = new Set<Source>();
34 bool shouldCompareConstValues = false;
35 34
36 /** 35 /**
37 * Determine the analysis options that should be used for this test. 36 * Determine the analysis options that should be used for this test.
38 */ 37 */
39 AnalysisOptionsImpl get options => 38 AnalysisOptionsImpl get options =>
40 new AnalysisOptionsImpl()..enableGenericMethods = true; 39 new AnalysisOptionsImpl()..enableGenericMethods = true;
41 40
42 void addLibrary(String uri) { 41 void addLibrary(String uri) {
43 otherLibrarySources.add(analysisContext2.sourceFactory.forUri(uri)); 42 otherLibrarySources.add(analysisContext2.sourceFactory.forUri(uri));
44 } 43 }
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 compareElements(resynthesized, original, desc); 662 compareElements(resynthesized, original, desc);
664 expect(resynthesized.uri, original.uri); 663 expect(resynthesized.uri, original.uri);
665 expect(resynthesized.uriOffset, original.uriOffset, reason: desc); 664 expect(resynthesized.uriOffset, original.uriOffset, reason: desc);
666 expect(resynthesized.uriEnd, original.uriEnd, reason: desc); 665 expect(resynthesized.uriEnd, original.uriEnd, reason: desc);
667 } 666 }
668 667
669 void compareVariableElements(VariableElementImpl resynthesized, 668 void compareVariableElements(VariableElementImpl resynthesized,
670 VariableElementImpl original, String desc) { 669 VariableElementImpl original, String desc) {
671 compareElements(resynthesized, original, desc); 670 compareElements(resynthesized, original, desc);
672 compareTypes(resynthesized.type, original.type, desc); 671 compareTypes(resynthesized.type, original.type, desc);
673 // TODO(scheglov) enable for any ConstVariableElement 672 if (original is ConstVariableElement) {
674 if (shouldCompareConstValues) { 673 compareConstantExpressions(resynthesized.constantInitializer,
675 if (original is ConstVariableElement) { 674 original.constantInitializer, desc);
676 compareConstantExpressions(resynthesized.constantInitializer,
677 original.constantInitializer, desc);
678 }
679 } 675 }
680 } 676 }
681 677
682 /** 678 /**
683 * Serialize the given [library] into a summary. Then create a 679 * Serialize the given [library] into a summary. Then create a
684 * [_TestSummaryResynthesizer] which can deserialize it, along with any 680 * [_TestSummaryResynthesizer] which can deserialize it, along with any
685 * references it makes to `dart:core`. 681 * references it makes to `dart:core`.
686 * 682 *
687 * Errors will lead to a test failure unless [allowErrors] is `true`. 683 * Errors will lead to a test failure unless [allowErrors] is `true`.
688 */ 684 */
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 1072
1077 test_class_type_parameters_f_bound_simple() { 1073 test_class_type_parameters_f_bound_simple() {
1078 checkLibrary('class C<T extends U, U> {}'); 1074 checkLibrary('class C<T extends U, U> {}');
1079 } 1075 }
1080 1076
1081 test_classes() { 1077 test_classes() {
1082 checkLibrary('class C {} class D {}'); 1078 checkLibrary('class C {} class D {}');
1083 } 1079 }
1084 1080
1085 test_const_invokeConstructor_generic_named() { 1081 test_const_invokeConstructor_generic_named() {
1086 shouldCompareConstValues = true;
1087 checkLibrary(r''' 1082 checkLibrary(r'''
1088 class C<K, V> { 1083 class C<K, V> {
1089 const C.named(K k, V v); 1084 const C.named(K k, V v);
1090 } 1085 }
1091 const V = const C<int, String>.named(1, '222'); 1086 const V = const C<int, String>.named(1, '222');
1092 '''); 1087 ''');
1093 } 1088 }
1094 1089
1095 test_const_invokeConstructor_generic_named_imported() { 1090 test_const_invokeConstructor_generic_named_imported() {
1096 shouldCompareConstValues = true;
1097 addLibrarySource( 1091 addLibrarySource(
1098 '/a.dart', 1092 '/a.dart',
1099 r''' 1093 r'''
1100 class C<K, V> { 1094 class C<K, V> {
1101 const C.named(K k, V v); 1095 const C.named(K k, V v);
1102 } 1096 }
1103 '''); 1097 ''');
1104 checkLibrary(r''' 1098 checkLibrary(r'''
1105 import 'a.dart'; 1099 import 'a.dart';
1106 const V = const C<int, String>.named(1, '222'); 1100 const V = const C<int, String>.named(1, '222');
1107 '''); 1101 ''');
1108 } 1102 }
1109 1103
1110 test_const_invokeConstructor_generic_named_imported_withPrefix() { 1104 test_const_invokeConstructor_generic_named_imported_withPrefix() {
1111 shouldCompareConstValues = true;
1112 addLibrarySource( 1105 addLibrarySource(
1113 '/a.dart', 1106 '/a.dart',
1114 r''' 1107 r'''
1115 class C<K, V> { 1108 class C<K, V> {
1116 const C.named(K k, V v); 1109 const C.named(K k, V v);
1117 } 1110 }
1118 '''); 1111 ''');
1119 checkLibrary(r''' 1112 checkLibrary(r'''
1120 import 'a.dart' as p; 1113 import 'a.dart' as p;
1121 const V = const p.C<int, String>.named(1, '222'); 1114 const V = const p.C<int, String>.named(1, '222');
1122 '''); 1115 ''');
1123 } 1116 }
1124 1117
1125 test_const_invokeConstructor_generic_unnamed() { 1118 test_const_invokeConstructor_generic_unnamed() {
1126 shouldCompareConstValues = true;
1127 checkLibrary(r''' 1119 checkLibrary(r'''
1128 class C<K, V> { 1120 class C<K, V> {
1129 const C(); 1121 const C();
1130 } 1122 }
1131 const V = const C<int, String>(); 1123 const V = const C<int, String>();
1132 '''); 1124 ''');
1133 } 1125 }
1134 1126
1135 test_const_invokeConstructor_generic_unnamed_imported() { 1127 test_const_invokeConstructor_generic_unnamed_imported() {
1136 shouldCompareConstValues = true;
1137 addLibrarySource( 1128 addLibrarySource(
1138 '/a.dart', 1129 '/a.dart',
1139 r''' 1130 r'''
1140 class C<K, V> { 1131 class C<K, V> {
1141 const C(); 1132 const C();
1142 } 1133 }
1143 '''); 1134 ''');
1144 checkLibrary(r''' 1135 checkLibrary(r'''
1145 import 'a.dart'; 1136 import 'a.dart';
1146 const V = const C<int, String>(); 1137 const V = const C<int, String>();
1147 '''); 1138 ''');
1148 } 1139 }
1149 1140
1150 test_const_invokeConstructor_generic_unnamed_imported_withPrefix() { 1141 test_const_invokeConstructor_generic_unnamed_imported_withPrefix() {
1151 shouldCompareConstValues = true;
1152 addLibrarySource( 1142 addLibrarySource(
1153 '/a.dart', 1143 '/a.dart',
1154 r''' 1144 r'''
1155 class C<K, V> { 1145 class C<K, V> {
1156 const C(); 1146 const C();
1157 } 1147 }
1158 '''); 1148 ''');
1159 checkLibrary(r''' 1149 checkLibrary(r'''
1160 import 'a.dart' as p; 1150 import 'a.dart' as p;
1161 const V = const p.C<int, String>(); 1151 const V = const p.C<int, String>();
1162 '''); 1152 ''');
1163 } 1153 }
1164 1154
1165 test_const_invokeConstructor_named() { 1155 test_const_invokeConstructor_named() {
1166 shouldCompareConstValues = true;
1167 checkLibrary(r''' 1156 checkLibrary(r'''
1168 class C { 1157 class C {
1169 const C.named(bool a, int b, int c, {String d, double e}); 1158 const C.named(bool a, int b, int c, {String d, double e});
1170 } 1159 }
1171 const V = const C.named(true, 1, 2, d: 'ccc', e: 3.4); 1160 const V = const C.named(true, 1, 2, d: 'ccc', e: 3.4);
1172 '''); 1161 ''');
1173 } 1162 }
1174 1163
1175 test_const_invokeConstructor_named_imported() { 1164 test_const_invokeConstructor_named_imported() {
1176 shouldCompareConstValues = true;
1177 addLibrarySource( 1165 addLibrarySource(
1178 '/a.dart', 1166 '/a.dart',
1179 r''' 1167 r'''
1180 class C { 1168 class C {
1181 const C.named(); 1169 const C.named();
1182 } 1170 }
1183 '''); 1171 ''');
1184 checkLibrary(r''' 1172 checkLibrary(r'''
1185 import 'a.dart'; 1173 import 'a.dart';
1186 const V = const C.named(); 1174 const V = const C.named();
1187 '''); 1175 ''');
1188 } 1176 }
1189 1177
1190 test_const_invokeConstructor_named_imported_withPrefix() { 1178 test_const_invokeConstructor_named_imported_withPrefix() {
1191 shouldCompareConstValues = true;
1192 addLibrarySource( 1179 addLibrarySource(
1193 '/a.dart', 1180 '/a.dart',
1194 r''' 1181 r'''
1195 class C { 1182 class C {
1196 const C.named(); 1183 const C.named();
1197 } 1184 }
1198 '''); 1185 ''');
1199 checkLibrary(r''' 1186 checkLibrary(r'''
1200 import 'a.dart' as p; 1187 import 'a.dart' as p;
1201 const V = const p.C.named(); 1188 const V = const p.C.named();
1202 '''); 1189 ''');
1203 } 1190 }
1204 1191
1205 test_const_invokeConstructor_unnamed() { 1192 test_const_invokeConstructor_unnamed() {
1206 shouldCompareConstValues = true;
1207 checkLibrary(r''' 1193 checkLibrary(r'''
1208 class C { 1194 class C {
1209 const C(); 1195 const C();
1210 } 1196 }
1211 const V = const C(); 1197 const V = const C();
1212 '''); 1198 ''');
1213 } 1199 }
1214 1200
1215 test_const_invokeConstructor_unnamed_imported() { 1201 test_const_invokeConstructor_unnamed_imported() {
1216 shouldCompareConstValues = true;
1217 addLibrarySource( 1202 addLibrarySource(
1218 '/a.dart', 1203 '/a.dart',
1219 r''' 1204 r'''
1220 class C { 1205 class C {
1221 const C(); 1206 const C();
1222 } 1207 }
1223 '''); 1208 ''');
1224 checkLibrary(r''' 1209 checkLibrary(r'''
1225 import 'a.dart'; 1210 import 'a.dart';
1226 const V = const C(); 1211 const V = const C();
1227 '''); 1212 ''');
1228 } 1213 }
1229 1214
1230 test_const_invokeConstructor_unnamed_imported_withPrefix() { 1215 test_const_invokeConstructor_unnamed_imported_withPrefix() {
1231 shouldCompareConstValues = true;
1232 addLibrarySource( 1216 addLibrarySource(
1233 '/a.dart', 1217 '/a.dart',
1234 r''' 1218 r'''
1235 class C { 1219 class C {
1236 const C(); 1220 const C();
1237 } 1221 }
1238 '''); 1222 ''');
1239 checkLibrary(r''' 1223 checkLibrary(r'''
1240 import 'a.dart' as p; 1224 import 'a.dart' as p;
1241 const V = const p.C(); 1225 const V = const p.C();
1242 '''); 1226 ''');
1243 } 1227 }
1244 1228
1245 test_const_length_ofClassConstField() { 1229 test_const_length_ofClassConstField() {
1246 shouldCompareConstValues = true;
1247 checkLibrary(r''' 1230 checkLibrary(r'''
1248 class C { 1231 class C {
1249 static const String F = ''; 1232 static const String F = '';
1250 } 1233 }
1251 const int v = C.F.length; 1234 const int v = C.F.length;
1252 '''); 1235 ''');
1253 } 1236 }
1254 1237
1255 test_const_length_ofClassConstField_imported() { 1238 test_const_length_ofClassConstField_imported() {
1256 shouldCompareConstValues = true;
1257 addLibrarySource( 1239 addLibrarySource(
1258 '/a.dart', 1240 '/a.dart',
1259 r''' 1241 r'''
1260 class C { 1242 class C {
1261 static const String F = ''; 1243 static const String F = '';
1262 } 1244 }
1263 '''); 1245 ''');
1264 checkLibrary(r''' 1246 checkLibrary(r'''
1265 import 'a.dart'; 1247 import 'a.dart';
1266 const int v = C.F.length; 1248 const int v = C.F.length;
1267 '''); 1249 ''');
1268 } 1250 }
1269 1251
1270 test_const_length_ofClassConstField_imported_withPrefix() { 1252 test_const_length_ofClassConstField_imported_withPrefix() {
1271 shouldCompareConstValues = true;
1272 addLibrarySource( 1253 addLibrarySource(
1273 '/a.dart', 1254 '/a.dart',
1274 r''' 1255 r'''
1275 class C { 1256 class C {
1276 static const String F = ''; 1257 static const String F = '';
1277 } 1258 }
1278 '''); 1259 ''');
1279 checkLibrary(r''' 1260 checkLibrary(r'''
1280 import 'a.dart' as p; 1261 import 'a.dart' as p;
1281 const int v = p.C.F.length; 1262 const int v = p.C.F.length;
1282 '''); 1263 ''');
1283 } 1264 }
1284 1265
1285 test_const_length_ofStringLiteral() { 1266 test_const_length_ofStringLiteral() {
1286 shouldCompareConstValues = true;
1287 checkLibrary(r''' 1267 checkLibrary(r'''
1288 const v = 'abc'.length; 1268 const v = 'abc'.length;
1289 '''); 1269 ''');
1290 } 1270 }
1291 1271
1292 test_const_length_ofTopLevelVariable() { 1272 test_const_length_ofTopLevelVariable() {
1293 shouldCompareConstValues = true;
1294 checkLibrary(r''' 1273 checkLibrary(r'''
1295 const String S = 'abc'; 1274 const String S = 'abc';
1296 const v = S.length; 1275 const v = S.length;
1297 '''); 1276 ''');
1298 } 1277 }
1299 1278
1300 test_const_length_ofTopLevelVariable_imported() { 1279 test_const_length_ofTopLevelVariable_imported() {
1301 shouldCompareConstValues = true;
1302 addLibrarySource( 1280 addLibrarySource(
1303 '/a.dart', 1281 '/a.dart',
1304 r''' 1282 r'''
1305 const String S = 'abc'; 1283 const String S = 'abc';
1306 '''); 1284 ''');
1307 checkLibrary(r''' 1285 checkLibrary(r'''
1308 import 'a.dart'; 1286 import 'a.dart';
1309 const v = S.length; 1287 const v = S.length;
1310 '''); 1288 ''');
1311 } 1289 }
1312 1290
1313 test_const_length_ofTopLevelVariable_imported_withPrefix() { 1291 test_const_length_ofTopLevelVariable_imported_withPrefix() {
1314 shouldCompareConstValues = true;
1315 addLibrarySource( 1292 addLibrarySource(
1316 '/a.dart', 1293 '/a.dart',
1317 r''' 1294 r'''
1318 const String S = 'abc'; 1295 const String S = 'abc';
1319 '''); 1296 ''');
1320 checkLibrary(r''' 1297 checkLibrary(r'''
1321 import 'a.dart' as p; 1298 import 'a.dart' as p;
1322 const v = p.S.length; 1299 const v = p.S.length;
1323 '''); 1300 ''');
1324 } 1301 }
1325 1302
1326 test_const_length_staticMethod() { 1303 test_const_length_staticMethod() {
1327 shouldCompareConstValues = true;
1328 checkLibrary(r''' 1304 checkLibrary(r'''
1329 class C { 1305 class C {
1330 static int length() => 42; 1306 static int length() => 42;
1331 } 1307 }
1332 const v = C.length; 1308 const v = C.length;
1333 '''); 1309 ''');
1334 } 1310 }
1335 1311
1336 test_const_parameterDefaultValue_initializingFormal_functionTyped() { 1312 test_const_parameterDefaultValue_initializingFormal_functionTyped() {
1337 shouldCompareConstValues = true;
1338 checkLibrary(r''' 1313 checkLibrary(r'''
1339 class C { 1314 class C {
1340 final x; 1315 final x;
1341 const C({this.x: foo}); 1316 const C({this.x: foo});
1342 } 1317 }
1343 int foo() => 42; 1318 int foo() => 42;
1344 '''); 1319 ''');
1345 } 1320 }
1346 1321
1347 test_const_parameterDefaultValue_initializingFormal_named() { 1322 test_const_parameterDefaultValue_initializingFormal_named() {
1348 shouldCompareConstValues = true;
1349 checkLibrary(r''' 1323 checkLibrary(r'''
1350 class C { 1324 class C {
1351 final x; 1325 final x;
1352 const C({this.x: 1 + 2}); 1326 const C({this.x: 1 + 2});
1353 } 1327 }
1354 '''); 1328 ''');
1355 } 1329 }
1356 1330
1357 test_const_parameterDefaultValue_initializingFormal_positional() { 1331 test_const_parameterDefaultValue_initializingFormal_positional() {
1358 shouldCompareConstValues = true;
1359 checkLibrary(r''' 1332 checkLibrary(r'''
1360 class C { 1333 class C {
1361 final x; 1334 final x;
1362 const C([this.x = 1 + 2]); 1335 const C([this.x = 1 + 2]);
1363 } 1336 }
1364 '''); 1337 ''');
1365 } 1338 }
1366 1339
1367 test_const_parameterDefaultValue_normal() { 1340 test_const_parameterDefaultValue_normal() {
1368 shouldCompareConstValues = true;
1369 checkLibrary(r''' 1341 checkLibrary(r'''
1370 class C { 1342 class C {
1371 const C.positional([p = 1 + 2]); 1343 const C.positional([p = 1 + 2]);
1372 const C.named({p: 1 + 2}); 1344 const C.named({p: 1 + 2});
1373 void methodPositional([p = 1 + 2]) {} 1345 void methodPositional([p = 1 + 2]) {}
1374 void methodNamed({p: 1 + 2}) {} 1346 void methodNamed({p: 1 + 2}) {}
1375 } 1347 }
1376 '''); 1348 ''');
1377 } 1349 }
1378 1350
1379 test_const_reference_staticField() { 1351 test_const_reference_staticField() {
1380 shouldCompareConstValues = true;
1381 checkLibrary(r''' 1352 checkLibrary(r'''
1382 class C { 1353 class C {
1383 static const int F = 42; 1354 static const int F = 42;
1384 } 1355 }
1385 const V = C.F; 1356 const V = C.F;
1386 '''); 1357 ''');
1387 } 1358 }
1388 1359
1389 test_const_reference_staticField_imported() { 1360 test_const_reference_staticField_imported() {
1390 shouldCompareConstValues = true;
1391 addLibrarySource( 1361 addLibrarySource(
1392 '/a.dart', 1362 '/a.dart',
1393 r''' 1363 r'''
1394 class C { 1364 class C {
1395 static const int F = 42; 1365 static const int F = 42;
1396 } 1366 }
1397 '''); 1367 ''');
1398 checkLibrary(r''' 1368 checkLibrary(r'''
1399 import 'a.dart'; 1369 import 'a.dart';
1400 const V = C.F; 1370 const V = C.F;
1401 '''); 1371 ''');
1402 } 1372 }
1403 1373
1404 test_const_reference_staticField_imported_withPrefix() { 1374 test_const_reference_staticField_imported_withPrefix() {
1405 shouldCompareConstValues = true;
1406 addLibrarySource( 1375 addLibrarySource(
1407 '/a.dart', 1376 '/a.dart',
1408 r''' 1377 r'''
1409 class C { 1378 class C {
1410 static const int F = 42; 1379 static const int F = 42;
1411 } 1380 }
1412 '''); 1381 ''');
1413 checkLibrary(r''' 1382 checkLibrary(r'''
1414 import 'a.dart' as p; 1383 import 'a.dart' as p;
1415 const V = p.C.F; 1384 const V = p.C.F;
1416 '''); 1385 ''');
1417 } 1386 }
1418 1387
1419 test_const_reference_staticMethod() { 1388 test_const_reference_staticMethod() {
1420 shouldCompareConstValues = true;
1421 checkLibrary(r''' 1389 checkLibrary(r'''
1422 class C { 1390 class C {
1423 static int m(int a, String b) => 42; 1391 static int m(int a, String b) => 42;
1424 } 1392 }
1425 const V = C.m; 1393 const V = C.m;
1426 '''); 1394 ''');
1427 } 1395 }
1428 1396
1429 test_const_reference_staticMethod_imported() { 1397 test_const_reference_staticMethod_imported() {
1430 shouldCompareConstValues = true;
1431 addLibrarySource( 1398 addLibrarySource(
1432 '/a.dart', 1399 '/a.dart',
1433 r''' 1400 r'''
1434 class C { 1401 class C {
1435 static int m(int a, String b) => 42; 1402 static int m(int a, String b) => 42;
1436 } 1403 }
1437 '''); 1404 ''');
1438 checkLibrary(r''' 1405 checkLibrary(r'''
1439 import 'a.dart'; 1406 import 'a.dart';
1440 const V = C.m; 1407 const V = C.m;
1441 '''); 1408 ''');
1442 } 1409 }
1443 1410
1444 test_const_reference_staticMethod_imported_withPrefix() { 1411 test_const_reference_staticMethod_imported_withPrefix() {
1445 shouldCompareConstValues = true;
1446 addLibrarySource( 1412 addLibrarySource(
1447 '/a.dart', 1413 '/a.dart',
1448 r''' 1414 r'''
1449 class C { 1415 class C {
1450 static int m(int a, String b) => 42; 1416 static int m(int a, String b) => 42;
1451 } 1417 }
1452 '''); 1418 ''');
1453 checkLibrary(r''' 1419 checkLibrary(r'''
1454 import 'a.dart' as p; 1420 import 'a.dart' as p;
1455 const V = p.C.m; 1421 const V = p.C.m;
1456 '''); 1422 ''');
1457 } 1423 }
1458 1424
1459 test_const_reference_topLevelFunction() { 1425 test_const_reference_topLevelFunction() {
1460 shouldCompareConstValues = true;
1461 checkLibrary(r''' 1426 checkLibrary(r'''
1462 foo() {} 1427 foo() {}
1463 const V = foo; 1428 const V = foo;
1464 '''); 1429 ''');
1465 } 1430 }
1466 1431
1467 test_const_reference_topLevelFunction_imported() { 1432 test_const_reference_topLevelFunction_imported() {
1468 shouldCompareConstValues = true;
1469 addLibrarySource( 1433 addLibrarySource(
1470 '/a.dart', 1434 '/a.dart',
1471 r''' 1435 r'''
1472 foo() {} 1436 foo() {}
1473 '''); 1437 ''');
1474 checkLibrary(r''' 1438 checkLibrary(r'''
1475 import 'a.dart'; 1439 import 'a.dart';
1476 const V = foo; 1440 const V = foo;
1477 '''); 1441 ''');
1478 } 1442 }
1479 1443
1480 test_const_reference_topLevelFunction_imported_withPrefix() { 1444 test_const_reference_topLevelFunction_imported_withPrefix() {
1481 shouldCompareConstValues = true;
1482 addLibrarySource( 1445 addLibrarySource(
1483 '/a.dart', 1446 '/a.dart',
1484 r''' 1447 r'''
1485 foo() {} 1448 foo() {}
1486 '''); 1449 ''');
1487 checkLibrary(r''' 1450 checkLibrary(r'''
1488 import 'a.dart' as p; 1451 import 'a.dart' as p;
1489 const V = p.foo; 1452 const V = p.foo;
1490 '''); 1453 ''');
1491 } 1454 }
1492 1455
1493 test_const_reference_topLevelVariable() { 1456 test_const_reference_topLevelVariable() {
1494 shouldCompareConstValues = true;
1495 checkLibrary(r''' 1457 checkLibrary(r'''
1496 const A = 1; 1458 const A = 1;
1497 const B = A + 2; 1459 const B = A + 2;
1498 '''); 1460 ''');
1499 } 1461 }
1500 1462
1501 test_const_reference_topLevelVariable_imported() { 1463 test_const_reference_topLevelVariable_imported() {
1502 shouldCompareConstValues = true;
1503 addLibrarySource( 1464 addLibrarySource(
1504 '/a.dart', 1465 '/a.dart',
1505 r''' 1466 r'''
1506 const A = 1; 1467 const A = 1;
1507 '''); 1468 ''');
1508 checkLibrary(r''' 1469 checkLibrary(r'''
1509 import 'a.dart'; 1470 import 'a.dart';
1510 const B = A + 2; 1471 const B = A + 2;
1511 '''); 1472 ''');
1512 } 1473 }
1513 1474
1514 test_const_reference_topLevelVariable_imported_withPrefix() { 1475 test_const_reference_topLevelVariable_imported_withPrefix() {
1515 shouldCompareConstValues = true;
1516 addLibrarySource( 1476 addLibrarySource(
1517 '/a.dart', 1477 '/a.dart',
1518 r''' 1478 r'''
1519 const A = 1; 1479 const A = 1;
1520 '''); 1480 ''');
1521 checkLibrary(r''' 1481 checkLibrary(r'''
1522 import 'a.dart' as p; 1482 import 'a.dart' as p;
1523 const B = p.A + 2; 1483 const B = p.A + 2;
1524 '''); 1484 ''');
1525 } 1485 }
1526 1486
1527 test_const_reference_type() { 1487 test_const_reference_type() {
1528 shouldCompareConstValues = true;
1529 checkLibrary(r''' 1488 checkLibrary(r'''
1530 class C {} 1489 class C {}
1531 class D<T> {} 1490 class D<T> {}
1532 enum E {a, b, c} 1491 enum E {a, b, c}
1533 typedef F(int a, String b); 1492 typedef F(int a, String b);
1534 const vDynamic = dynamic; 1493 const vDynamic = dynamic;
1535 const vNull = Null; 1494 const vNull = Null;
1536 const vObject = Object; 1495 const vObject = Object;
1537 const vClass = C; 1496 const vClass = C;
1538 const vGenericClass = D; 1497 const vGenericClass = D;
1539 const vEnum = E; 1498 const vEnum = E;
1540 const vFunctionTypeAlias = F; 1499 const vFunctionTypeAlias = F;
1541 '''); 1500 ''');
1542 } 1501 }
1543 1502
1544 test_const_reference_type_imported() { 1503 test_const_reference_type_imported() {
1545 shouldCompareConstValues = true;
1546 addLibrarySource( 1504 addLibrarySource(
1547 '/a.dart', 1505 '/a.dart',
1548 r''' 1506 r'''
1549 class C {} 1507 class C {}
1550 enum E {a, b, c} 1508 enum E {a, b, c}
1551 typedef F(int a, String b); 1509 typedef F(int a, String b);
1552 '''); 1510 ''');
1553 checkLibrary(r''' 1511 checkLibrary(r'''
1554 import 'a.dart'; 1512 import 'a.dart';
1555 const vClass = C; 1513 const vClass = C;
1556 const vEnum = E; 1514 const vEnum = E;
1557 const vFunctionTypeAlias = F; 1515 const vFunctionTypeAlias = F;
1558 '''); 1516 ''');
1559 } 1517 }
1560 1518
1561 test_const_reference_type_imported_withPrefix() { 1519 test_const_reference_type_imported_withPrefix() {
1562 shouldCompareConstValues = true;
1563 addLibrarySource( 1520 addLibrarySource(
1564 '/a.dart', 1521 '/a.dart',
1565 r''' 1522 r'''
1566 class C {} 1523 class C {}
1567 enum E {a, b, c} 1524 enum E {a, b, c}
1568 typedef F(int a, String b); 1525 typedef F(int a, String b);
1569 '''); 1526 ''');
1570 checkLibrary(r''' 1527 checkLibrary(r'''
1571 import 'a.dart' as p; 1528 import 'a.dart' as p;
1572 const vClass = p.C; 1529 const vClass = p.C;
1573 const vEnum = p.E; 1530 const vEnum = p.E;
1574 const vFunctionTypeAlias = p.F; 1531 const vFunctionTypeAlias = p.F;
1575 '''); 1532 ''');
1576 } 1533 }
1577 1534
1578 test_const_topLevel_binary() { 1535 test_const_topLevel_binary() {
1579 shouldCompareConstValues = true;
1580 checkLibrary(r''' 1536 checkLibrary(r'''
1581 const vEqual = 1 == 2; 1537 const vEqual = 1 == 2;
1582 const vAnd = true && false; 1538 const vAnd = true && false;
1583 const vOr = false || true; 1539 const vOr = false || true;
1584 const vBitXor = 1 ^ 2; 1540 const vBitXor = 1 ^ 2;
1585 const vBitAnd = 1 & 2; 1541 const vBitAnd = 1 & 2;
1586 const vBitOr = 1 | 2; 1542 const vBitOr = 1 | 2;
1587 const vBitShiftLeft = 1 << 2; 1543 const vBitShiftLeft = 1 << 2;
1588 const vBitShiftRight = 1 >> 2; 1544 const vBitShiftRight = 1 >> 2;
1589 const vAdd = 1 + 2; 1545 const vAdd = 1 + 2;
1590 const vSubtract = 1 - 2; 1546 const vSubtract = 1 - 2;
1591 const vMiltiply = 1 * 2; 1547 const vMiltiply = 1 * 2;
1592 const vDivide = 1 / 2; 1548 const vDivide = 1 / 2;
1593 const vFloorDivide = 1 ~/ 2; 1549 const vFloorDivide = 1 ~/ 2;
1594 const vModulo = 1 % 2; 1550 const vModulo = 1 % 2;
1595 const vGreater = 1 > 2; 1551 const vGreater = 1 > 2;
1596 const vGreaterEqual = 1 >= 2; 1552 const vGreaterEqual = 1 >= 2;
1597 const vLess = 1 < 2; 1553 const vLess = 1 < 2;
1598 const vLessEqual = 1 <= 2; 1554 const vLessEqual = 1 <= 2;
1599 '''); 1555 ''');
1600 } 1556 }
1601 1557
1602 test_const_topLevel_conditional() { 1558 test_const_topLevel_conditional() {
1603 shouldCompareConstValues = true;
1604 checkLibrary(r''' 1559 checkLibrary(r'''
1605 const vConditional = (1 == 2) ? 11 : 22; 1560 const vConditional = (1 == 2) ? 11 : 22;
1606 '''); 1561 ''');
1607 } 1562 }
1608 1563
1609 test_const_topLevel_identical() { 1564 test_const_topLevel_identical() {
1610 shouldCompareConstValues = true;
1611 checkLibrary(r''' 1565 checkLibrary(r'''
1612 const vIdentical = (1 == 2) ? 11 : 22; 1566 const vIdentical = (1 == 2) ? 11 : 22;
1613 '''); 1567 ''');
1614 } 1568 }
1615 1569
1616 test_const_topLevel_literal() { 1570 test_const_topLevel_literal() {
1617 shouldCompareConstValues = true;
1618 checkLibrary(r''' 1571 checkLibrary(r'''
1619 const vNull = null; 1572 const vNull = null;
1620 const vBoolFalse = false; 1573 const vBoolFalse = false;
1621 const vBoolTrue = true; 1574 const vBoolTrue = true;
1622 const vInt = 1; 1575 const vInt = 1;
1623 const vIntLong = 0x9876543210987654321; 1576 const vIntLong = 0x9876543210987654321;
1624 const vDouble = 2.3; 1577 const vDouble = 2.3;
1625 const vString = 'abc'; 1578 const vString = 'abc';
1626 const vStringConcat = 'aaa' 'bbb'; 1579 const vStringConcat = 'aaa' 'bbb';
1627 const vStringInterpolation = 'aaa ${true} ${42} bbb'; 1580 const vStringInterpolation = 'aaa ${true} ${42} bbb';
1628 const vSymbol = #aaa.bbb.ccc; 1581 const vSymbol = #aaa.bbb.ccc;
1629 '''); 1582 ''');
1630 } 1583 }
1631 1584
1632 test_const_topLevel_prefix() { 1585 test_const_topLevel_prefix() {
1633 shouldCompareConstValues = true;
1634 checkLibrary(r''' 1586 checkLibrary(r'''
1635 const vNotEqual = 1 != 2; 1587 const vNotEqual = 1 != 2;
1636 const vNot = !true; 1588 const vNot = !true;
1637 const vNegate = -1; 1589 const vNegate = -1;
1638 const vComplement = ~1; 1590 const vComplement = ~1;
1639 '''); 1591 ''');
1640 } 1592 }
1641 1593
1642 test_const_topLevel_typedList() { 1594 test_const_topLevel_typedList() {
1643 shouldCompareConstValues = true;
1644 checkLibrary(r''' 1595 checkLibrary(r'''
1645 const vNull = const <Null>[]; 1596 const vNull = const <Null>[];
1646 const vDynamic = const <dynamic>[1, 2, 3]; 1597 const vDynamic = const <dynamic>[1, 2, 3];
1647 const vInterfaceNoTypeParameters = const <int>[1, 2, 3]; 1598 const vInterfaceNoTypeParameters = const <int>[1, 2, 3];
1648 const vInterfaceNoTypeArguments = const <List>[]; 1599 const vInterfaceNoTypeArguments = const <List>[];
1649 const vInterfaceWithTypeArguments = const <List<String>>[]; 1600 const vInterfaceWithTypeArguments = const <List<String>>[];
1650 const vInterfaceWithTypeArguments2 = const <Map<int, List<String>>>[]; 1601 const vInterfaceWithTypeArguments2 = const <Map<int, List<String>>>[];
1651 '''); 1602 ''');
1652 } 1603 }
1653 1604
1654 test_const_topLevel_typedList_imported() { 1605 test_const_topLevel_typedList_imported() {
1655 shouldCompareConstValues = true;
1656 addLibrarySource('/a.dart', 'class C {}'); 1606 addLibrarySource('/a.dart', 'class C {}');
1657 checkLibrary(r''' 1607 checkLibrary(r'''
1658 import 'a.dart'; 1608 import 'a.dart';
1659 const v = const <C>[]; 1609 const v = const <C>[];
1660 '''); 1610 ''');
1661 } 1611 }
1662 1612
1663 test_const_topLevel_typedList_importedWithPrefix() { 1613 test_const_topLevel_typedList_importedWithPrefix() {
1664 shouldCompareConstValues = true;
1665 addLibrarySource('/a.dart', 'class C {}'); 1614 addLibrarySource('/a.dart', 'class C {}');
1666 checkLibrary(r''' 1615 checkLibrary(r'''
1667 import 'a.dart' as p; 1616 import 'a.dart' as p;
1668 const v = const <p.C>[]; 1617 const v = const <p.C>[];
1669 '''); 1618 ''');
1670 } 1619 }
1671 1620
1672 test_const_topLevel_typedMap() { 1621 test_const_topLevel_typedMap() {
1673 shouldCompareConstValues = true;
1674 checkLibrary(r''' 1622 checkLibrary(r'''
1675 const vDynamic1 = const <dynamic, int>{}; 1623 const vDynamic1 = const <dynamic, int>{};
1676 const vDynamic2 = const <int, dynamic>{}; 1624 const vDynamic2 = const <int, dynamic>{};
1677 const vInterface = const <int, String>{}; 1625 const vInterface = const <int, String>{};
1678 const vInterfaceWithTypeArguments = const <int, List<String>>{}; 1626 const vInterfaceWithTypeArguments = const <int, List<String>>{};
1679 '''); 1627 ''');
1680 } 1628 }
1681 1629
1682 test_const_topLevel_untypedList() { 1630 test_const_topLevel_untypedList() {
1683 shouldCompareConstValues = true;
1684 checkLibrary(r''' 1631 checkLibrary(r'''
1685 const v = const [1, 2, 3]; 1632 const v = const [1, 2, 3];
1686 '''); 1633 ''');
1687 } 1634 }
1688 1635
1689 test_const_topLevel_untypedMap() { 1636 test_const_topLevel_untypedMap() {
1690 shouldCompareConstValues = true;
1691 checkLibrary(r''' 1637 checkLibrary(r'''
1692 const v = const {0: 'aaa', 1: 'bbb', 2: 'ccc'}; 1638 const v = const {0: 'aaa', 1: 'bbb', 2: 'ccc'};
1693 '''); 1639 ''');
1694 } 1640 }
1695 1641
1696 test_constructor_documented() { 1642 test_constructor_documented() {
1697 checkLibrary(''' 1643 checkLibrary('''
1698 class C { 1644 class C {
1699 /** 1645 /**
1700 * Docs 1646 * Docs
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
2662 fail('Unexpectedly tried to get unlinked summary for $uri'); 2608 fail('Unexpectedly tried to get unlinked summary for $uri');
2663 } 2609 }
2664 return serializedUnit; 2610 return serializedUnit;
2665 } 2611 }
2666 2612
2667 @override 2613 @override
2668 bool hasLibrarySummary(String uri) { 2614 bool hasLibrarySummary(String uri) {
2669 return true; 2615 return true;
2670 } 2616 }
2671 } 2617 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698