| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 engine.static_warning_code_test; | 5 library engine.static_warning_code_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/source_io.dart'; | 7 import 'package:analyzer/src/generated/source_io.dart'; |
| 8 import 'package:analyzer/src/generated/error.dart'; | 8 import 'package:analyzer/src/generated/error.dart'; |
| 9 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | 9 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 Source source = addSource(r''' | 1109 Source source = addSource(r''' |
| 1110 class A<T> { | 1110 class A<T> { |
| 1111 const A(); | 1111 const A(); |
| 1112 } | 1112 } |
| 1113 var m = {const A<int>(): 0, const A<num>(): 1};'''); | 1113 var m = {const A<int>(): 0, const A<num>(): 1};'''); |
| 1114 resolve(source); | 1114 resolve(source); |
| 1115 assertNoErrors(source); | 1115 assertNoErrors(source); |
| 1116 verify([source]); | 1116 verify([source]); |
| 1117 } | 1117 } |
| 1118 | 1118 |
| 1119 void test_exportDuplicatedLibraryName() { | 1119 void test_exportDuplicatedLibraryNamed() { |
| 1120 Source source = addSource(r''' | 1120 Source source = addSource(r''' |
| 1121 library test; | 1121 library test; |
| 1122 export 'lib1.dart'; | 1122 export 'lib1.dart'; |
| 1123 export 'lib2.dart';'''); | 1123 export 'lib2.dart';'''); |
| 1124 addNamedSource("/lib1.dart", "library lib;"); | 1124 addNamedSource("/lib1.dart", "library lib;"); |
| 1125 addNamedSource("/lib2.dart", "library lib;"); | 1125 addNamedSource("/lib2.dart", "library lib;"); |
| 1126 resolve(source); | 1126 resolve(source); |
| 1127 assertErrors(source, [StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAME]); | 1127 assertErrors(source, [StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAMED]); |
| 1128 verify([source]); | 1128 verify([source]); |
| 1129 } | 1129 } |
| 1130 | 1130 |
| 1131 void test_exportDuplicatedLibraryUnnamed() { |
| 1132 Source source = addSource(r''' |
| 1133 library test; |
| 1134 export 'lib1.dart'; |
| 1135 export 'lib2.dart';'''); |
| 1136 addNamedSource("/lib1.dart", ""); |
| 1137 addNamedSource("/lib2.dart", ""); |
| 1138 resolve(source); |
| 1139 assertErrors(source, [StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_UNNAMED]); |
| 1140 verify([source]); |
| 1141 } |
| 1142 |
| 1131 void test_extraPositionalArguments() { | 1143 void test_extraPositionalArguments() { |
| 1132 Source source = addSource(r''' | 1144 Source source = addSource(r''' |
| 1133 f() {} | 1145 f() {} |
| 1134 main() { | 1146 main() { |
| 1135 f(0, 1, '2'); | 1147 f(0, 1, '2'); |
| 1136 }'''); | 1148 }'''); |
| 1137 resolve(source); | 1149 resolve(source); |
| 1138 assertErrors(source, [StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS]); | 1150 assertErrors(source, [StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS]); |
| 1139 verify([source]); | 1151 verify([source]); |
| 1140 } | 1152 } |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 Source source = addSource(r''' | 1297 Source source = addSource(r''' |
| 1286 abstract class A implements Function { | 1298 abstract class A implements Function { |
| 1287 } | 1299 } |
| 1288 class B implements A { | 1300 class B implements A { |
| 1289 }'''); | 1301 }'''); |
| 1290 resolve(source); | 1302 resolve(source); |
| 1291 assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]); | 1303 assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]); |
| 1292 verify([source]); | 1304 verify([source]); |
| 1293 } | 1305 } |
| 1294 | 1306 |
| 1295 void test_importDuplicatedLibraryName() { | 1307 void test_importDuplicatedLibraryNamed() { |
| 1296 Source source = addSource(r''' | 1308 Source source = addSource(r''' |
| 1297 library test; | 1309 library test; |
| 1298 import 'lib1.dart'; | 1310 import 'lib1.dart'; |
| 1299 import 'lib2.dart';'''); | 1311 import 'lib2.dart';'''); |
| 1300 addNamedSource("/lib1.dart", "library lib;"); | 1312 addNamedSource("/lib1.dart", "library lib;"); |
| 1301 addNamedSource("/lib2.dart", "library lib;"); | 1313 addNamedSource("/lib2.dart", "library lib;"); |
| 1302 resolve(source); | 1314 resolve(source); |
| 1303 assertErrors(source, [ | 1315 assertErrors(source, [ |
| 1304 StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAME, | 1316 StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAMED, |
| 1305 HintCode.UNUSED_IMPORT, | 1317 HintCode.UNUSED_IMPORT, |
| 1306 HintCode.UNUSED_IMPORT]); | 1318 HintCode.UNUSED_IMPORT]); |
| 1307 verify([source]); | 1319 verify([source]); |
| 1320 } |
| 1321 |
| 1322 void test_importDuplicatedLibraryUnnamed() { |
| 1323 Source source = addSource(r''' |
| 1324 library test; |
| 1325 import 'lib1.dart'; |
| 1326 import 'lib2.dart';'''); |
| 1327 addNamedSource("/lib1.dart", ""); |
| 1328 addNamedSource("/lib2.dart", ""); |
| 1329 resolve(source); |
| 1330 assertErrors(source, [ |
| 1331 StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_UNNAMED, |
| 1332 HintCode.UNUSED_IMPORT, |
| 1333 HintCode.UNUSED_IMPORT]); |
| 1334 verify([source]); |
| 1308 } | 1335 } |
| 1309 | 1336 |
| 1310 void test_importOfNonLibrary() { | 1337 void test_importOfNonLibrary() { |
| 1311 resolveWithAndWithoutExperimental(<String> [ | 1338 resolveWithAndWithoutExperimental(<String> [ |
| 1312 r''' | 1339 r''' |
| 1313 part of lib; | 1340 part of lib; |
| 1314 class A {}''', | 1341 class A {}''', |
| 1315 r''' | 1342 r''' |
| 1316 library lib; | 1343 library lib; |
| 1317 import 'lib1.dart' deferred as p; | 1344 import 'lib1.dart' deferred as p; |
| (...skipping 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3279 }'''); | 3306 }'''); |
| 3280 resolve(source); | 3307 resolve(source); |
| 3281 assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]); | 3308 assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]); |
| 3282 } | 3309 } |
| 3283 } | 3310 } |
| 3284 | 3311 |
| 3285 main() { | 3312 main() { |
| 3286 groupSep = ' | '; | 3313 groupSep = ' | '; |
| 3287 runReflectiveTests(StaticWarningCodeTest); | 3314 runReflectiveTests(StaticWarningCodeTest); |
| 3288 } | 3315 } |
| OLD | NEW |