| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 analyzer.test.generated.non_hint_code_test; | 5 library analyzer.test.generated.non_hint_code_test; |
| 6 | 6 |
| 7 import 'package:analyzer/error/error.dart'; | 7 import 'package:analyzer/error/error.dart'; |
| 8 import 'package:analyzer/src/error/codes.dart'; | 8 import 'package:analyzer/src/error/codes.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/source_io.dart'; | 10 import 'package:analyzer/src/generated/source_io.dart'; |
| 11 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 11 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 12 | 12 |
| 13 import 'resolver_test_case.dart'; | 13 import 'resolver_test_case.dart'; |
| 14 | 14 |
| 15 main() { | 15 main() { |
| 16 defineReflectiveSuite(() { | 16 defineReflectiveSuite(() { |
| 17 defineReflectiveTests(NonHintCodeTest); | 17 defineReflectiveTests(NonHintCodeTest); |
| 18 defineReflectiveTests(NonHintCodeTest_Driver); |
| 18 }); | 19 }); |
| 19 } | 20 } |
| 20 | 21 |
| 21 @reflectiveTest | 22 @reflectiveTest |
| 22 class NonHintCodeTest extends ResolverTestCase { | 23 class NonHintCodeTest extends ResolverTestCase { |
| 23 test_() async { | |
| 24 resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true); | |
| 25 Source source = addSource(r''' | |
| 26 abstract class A { | |
| 27 void test(); | |
| 28 } | |
| 29 class B extends A { | |
| 30 void test() { | |
| 31 super.test; | |
| 32 } | |
| 33 } | |
| 34 '''); | |
| 35 await computeAnalysisResult(source); | |
| 36 assertNoErrors(source); | |
| 37 verify([source]); | |
| 38 } | |
| 39 | |
| 40 test_deadCode_afterTryCatch() async { | 24 test_deadCode_afterTryCatch() async { |
| 41 Source source = addSource(''' | 25 Source source = addSource(''' |
| 42 main() { | 26 main() { |
| 43 try { | 27 try { |
| 44 return f(); | 28 return f(); |
| 45 } catch (e) { | 29 } catch (e) { |
| 46 print(e); | 30 print(e); |
| 47 } | 31 } |
| 48 print('not dead'); | 32 print('not dead'); |
| 49 } | 33 } |
| (...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1271 test_useOfVoidResult_nonVoidReturnValue() async { | 1255 test_useOfVoidResult_nonVoidReturnValue() async { |
| 1272 Source source = addSource(r''' | 1256 Source source = addSource(r''' |
| 1273 int f() => 1; | 1257 int f() => 1; |
| 1274 g() { | 1258 g() { |
| 1275 var a = f(); | 1259 var a = f(); |
| 1276 }'''); | 1260 }'''); |
| 1277 await computeAnalysisResult(source); | 1261 await computeAnalysisResult(source); |
| 1278 assertNoErrors(source); | 1262 assertNoErrors(source); |
| 1279 verify([source]); | 1263 verify([source]); |
| 1280 } | 1264 } |
| 1265 |
| 1266 test_withSuperMixin() async { |
| 1267 resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true); |
| 1268 Source source = addSource(r''' |
| 1269 abstract class A { |
| 1270 void test(); |
| 1271 } |
| 1272 class B extends A { |
| 1273 void test() { |
| 1274 super.test; |
| 1275 } |
| 1276 } |
| 1277 '''); |
| 1278 await computeAnalysisResult(source); |
| 1279 assertNoErrors(source); |
| 1280 verify([source]); |
| 1281 } |
| 1281 } | 1282 } |
| 1282 | 1283 |
| 1284 @reflectiveTest |
| 1285 class NonHintCodeTest_Driver extends NonHintCodeTest { |
| 1286 @override |
| 1287 bool get enableNewAnalysisDriver => true; |
| 1288 } |
| 1289 |
| 1283 class PubSuggestionCodeTest extends ResolverTestCase { | 1290 class PubSuggestionCodeTest extends ResolverTestCase { |
| 1284 test_import_package() async { | 1291 test_import_package() async { |
| 1285 Source source = addSource("import 'package:somepackage/other.dart';"); | 1292 Source source = addSource("import 'package:somepackage/other.dart';"); |
| 1286 await computeAnalysisResult(source); | 1293 await computeAnalysisResult(source); |
| 1287 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); | 1294 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); |
| 1288 } | 1295 } |
| 1289 | 1296 |
| 1290 test_import_packageWithDotDot() async { | 1297 test_import_packageWithDotDot() async { |
| 1291 Source source = addSource("import 'package:somepackage/../other.dart';"); | 1298 Source source = addSource("import 'package:somepackage/../other.dart';"); |
| 1292 await computeAnalysisResult(source); | 1299 await computeAnalysisResult(source); |
| 1293 assertErrors(source, [ | 1300 assertErrors(source, [ |
| 1294 CompileTimeErrorCode.URI_DOES_NOT_EXIST, | 1301 CompileTimeErrorCode.URI_DOES_NOT_EXIST, |
| 1295 HintCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT | 1302 HintCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT |
| 1296 ]); | 1303 ]); |
| 1297 } | 1304 } |
| 1298 | 1305 |
| 1299 test_import_packageWithLeadingDotDot() async { | 1306 test_import_packageWithLeadingDotDot() async { |
| 1300 Source source = addSource("import 'package:../other.dart';"); | 1307 Source source = addSource("import 'package:../other.dart';"); |
| 1301 await computeAnalysisResult(source); | 1308 await computeAnalysisResult(source); |
| 1302 assertErrors(source, [ | 1309 assertErrors(source, [ |
| 1303 CompileTimeErrorCode.URI_DOES_NOT_EXIST, | 1310 CompileTimeErrorCode.URI_DOES_NOT_EXIST, |
| 1304 HintCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT | 1311 HintCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT |
| 1305 ]); | 1312 ]); |
| 1306 } | 1313 } |
| 1307 | 1314 |
| 1308 test_import_referenceIntoLibDirectory() async { | 1315 test_import_referenceIntoLibDirectory() async { |
| 1309 cacheSource("/myproj/pubspec.yaml", ""); | 1316 addNamedSource("/myproj/pubspec.yaml", ""); |
| 1310 cacheSource("/myproj/lib/other.dart", ""); | 1317 addNamedSource("/myproj/lib/other.dart", ""); |
| 1311 Source source = | 1318 Source source = |
| 1312 addNamedSource("/myproj/web/test.dart", "import '../lib/other.dart';"); | 1319 addNamedSource("/myproj/web/test.dart", "import '../lib/other.dart';"); |
| 1313 await computeAnalysisResult(source); | 1320 await computeAnalysisResult(source); |
| 1314 assertErrors( | 1321 assertErrors( |
| 1315 source, [HintCode.FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE]); | 1322 source, [HintCode.FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE]); |
| 1316 } | 1323 } |
| 1317 | 1324 |
| 1318 test_import_referenceIntoLibDirectory_no_pubspec() async { | 1325 test_import_referenceIntoLibDirectory_no_pubspec() async { |
| 1319 cacheSource("/myproj/lib/other.dart", ""); | 1326 addNamedSource("/myproj/lib/other.dart", ""); |
| 1320 Source source = | 1327 Source source = |
| 1321 addNamedSource("/myproj/web/test.dart", "import '../lib/other.dart';"); | 1328 addNamedSource("/myproj/web/test.dart", "import '../lib/other.dart';"); |
| 1322 await computeAnalysisResult(source); | 1329 await computeAnalysisResult(source); |
| 1323 assertNoErrors(source); | 1330 assertNoErrors(source); |
| 1324 } | 1331 } |
| 1325 | 1332 |
| 1326 test_import_referenceOutOfLibDirectory() async { | 1333 test_import_referenceOutOfLibDirectory() async { |
| 1327 cacheSource("/myproj/pubspec.yaml", ""); | 1334 addNamedSource("/myproj/pubspec.yaml", ""); |
| 1328 cacheSource("/myproj/web/other.dart", ""); | 1335 addNamedSource("/myproj/web/other.dart", ""); |
| 1329 Source source = | 1336 Source source = |
| 1330 addNamedSource("/myproj/lib/test.dart", "import '../web/other.dart';"); | 1337 addNamedSource("/myproj/lib/test.dart", "import '../web/other.dart';"); |
| 1331 await computeAnalysisResult(source); | 1338 await computeAnalysisResult(source); |
| 1332 assertErrors( | 1339 assertErrors( |
| 1333 source, [HintCode.FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE]); | 1340 source, [HintCode.FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE]); |
| 1334 } | 1341 } |
| 1335 | 1342 |
| 1336 test_import_referenceOutOfLibDirectory_no_pubspec() async { | 1343 test_import_referenceOutOfLibDirectory_no_pubspec() async { |
| 1337 cacheSource("/myproj/web/other.dart", ""); | 1344 addNamedSource("/myproj/web/other.dart", ""); |
| 1338 Source source = | 1345 Source source = |
| 1339 addNamedSource("/myproj/lib/test.dart", "import '../web/other.dart';"); | 1346 addNamedSource("/myproj/lib/test.dart", "import '../web/other.dart';"); |
| 1340 await computeAnalysisResult(source); | 1347 await computeAnalysisResult(source); |
| 1341 assertNoErrors(source); | 1348 assertNoErrors(source); |
| 1342 } | 1349 } |
| 1343 | 1350 |
| 1344 test_import_valid_inside_lib1() async { | 1351 test_import_valid_inside_lib1() async { |
| 1345 cacheSource("/myproj/pubspec.yaml", ""); | 1352 addNamedSource("/myproj/pubspec.yaml", ""); |
| 1346 cacheSource("/myproj/lib/other.dart", ""); | 1353 addNamedSource("/myproj/lib/other.dart", ""); |
| 1347 Source source = | 1354 Source source = |
| 1348 addNamedSource("/myproj/lib/test.dart", "import 'other.dart';"); | 1355 addNamedSource("/myproj/lib/test.dart", "import 'other.dart';"); |
| 1349 await computeAnalysisResult(source); | 1356 await computeAnalysisResult(source); |
| 1350 assertNoErrors(source); | 1357 assertNoErrors(source); |
| 1351 } | 1358 } |
| 1352 | 1359 |
| 1353 test_import_valid_inside_lib2() async { | 1360 test_import_valid_inside_lib2() async { |
| 1354 cacheSource("/myproj/pubspec.yaml", ""); | 1361 addNamedSource("/myproj/pubspec.yaml", ""); |
| 1355 cacheSource("/myproj/lib/bar/other.dart", ""); | 1362 addNamedSource("/myproj/lib/bar/other.dart", ""); |
| 1356 Source source = addNamedSource( | 1363 Source source = addNamedSource( |
| 1357 "/myproj/lib/foo/test.dart", "import '../bar/other.dart';"); | 1364 "/myproj/lib/foo/test.dart", "import '../bar/other.dart';"); |
| 1358 await computeAnalysisResult(source); | 1365 await computeAnalysisResult(source); |
| 1359 assertNoErrors(source); | 1366 assertNoErrors(source); |
| 1360 } | 1367 } |
| 1361 | 1368 |
| 1362 test_import_valid_outside_lib() async { | 1369 test_import_valid_outside_lib() async { |
| 1363 cacheSource("/myproj/pubspec.yaml", ""); | 1370 addNamedSource("/myproj/pubspec.yaml", ""); |
| 1364 cacheSource("/myproj/web/other.dart", ""); | 1371 addNamedSource("/myproj/web/other.dart", ""); |
| 1365 Source source = | 1372 Source source = |
| 1366 addNamedSource("/myproj/lib2/test.dart", "import '../web/other.dart';"); | 1373 addNamedSource("/myproj/lib2/test.dart", "import '../web/other.dart';"); |
| 1367 await computeAnalysisResult(source); | 1374 await computeAnalysisResult(source); |
| 1368 assertNoErrors(source); | 1375 assertNoErrors(source); |
| 1369 } | 1376 } |
| 1370 } | 1377 } |
| OLD | NEW |