Chromium Code Reviews| 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 test.services.correction.fix; | 5 library test.services.correction.fix; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; | 9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; |
| 10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart'; | 10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart'; |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 ''' | 420 ''' |
| 421 class A { | 421 class A { |
| 422 test(int i) {} | 422 test(int i) {} |
| 423 main() { | 423 main() { |
| 424 test(1); | 424 test(1); |
| 425 } | 425 } |
| 426 } | 426 } |
| 427 '''); | 427 '''); |
| 428 } | 428 } |
| 429 | 429 |
| 430 test_addMissingRequiredArg_cons_single() async { | |
| 431 _addMetaPackageSource(); | |
| 432 | |
| 433 await resolveTestUnit(''' | |
| 434 import 'package:meta/meta.dart'; | |
| 435 | |
| 436 class A { | |
| 437 A({@required int a}) {} | |
| 438 } | |
| 439 main() { | |
| 440 A a = new A(); | |
| 441 } | |
| 442 '''); | |
| 443 await assertHasFix( | |
| 444 DartFixKind.ADD_MISSING_REQUIRED_ARGUMENT, | |
| 445 ''' | |
| 446 import 'package:meta/meta.dart'; | |
| 447 | |
| 448 class A { | |
| 449 A({@required int a}) {} | |
| 450 } | |
| 451 main() { | |
| 452 A a = new A(a: null); | |
| 453 } | |
| 454 '''); | |
| 455 } | |
| 456 | |
| 457 test_addMissingRequiredArg_multiple() async { | |
| 458 _addMetaPackageSource(); | |
| 459 | |
| 460 await resolveTestUnit(''' | |
| 461 import 'package:meta/meta.dart'; | |
| 462 | |
| 463 test({@required int a, @required int bcd}) {} | |
| 464 main() { | |
| 465 test(a: 3); | |
| 466 } | |
| 467 '''); | |
| 468 await assertHasFix( | |
| 469 DartFixKind.ADD_MISSING_REQUIRED_ARGUMENT, | |
| 470 ''' | |
| 471 import 'package:meta/meta.dart'; | |
| 472 | |
| 473 test({@required int a, @required int bcd}) {} | |
| 474 main() { | |
| 475 test(a: 3, bcd: null); | |
| 476 } | |
| 477 '''); | |
| 478 } | |
| 479 | |
| 480 test_addMissingRequiredArg_single() async { | |
| 481 _addMetaPackageSource(); | |
| 482 | |
| 483 await resolveTestUnit(''' | |
| 484 import 'package:meta/meta.dart'; | |
| 485 | |
| 486 test({@required int abc}) {} | |
| 487 main() { | |
| 488 test(); | |
| 489 } | |
| 490 '''); | |
| 491 await assertHasFix( | |
| 492 DartFixKind.ADD_MISSING_REQUIRED_ARGUMENT, | |
| 493 ''' | |
| 494 import 'package:meta/meta.dart'; | |
| 495 | |
| 496 test({@required int abc}) {} | |
| 497 main() { | |
| 498 test(abc: null); | |
| 499 } | |
| 500 '''); | |
| 501 } | |
|
Brian Wilkerson
2017/02/14 23:58:20
Possibly add a test case where there is a normal (
| |
| 502 | |
| 430 test_addSync_asyncFor() async { | 503 test_addSync_asyncFor() async { |
| 431 await resolveTestUnit(''' | 504 await resolveTestUnit(''' |
| 432 import 'dart:async'; | 505 import 'dart:async'; |
| 433 void main(Stream<String> names) { | 506 void main(Stream<String> names) { |
| 434 await for (String name in names) { | 507 await for (String name in names) { |
| 435 print(name); | 508 print(name); |
| 436 } | 509 } |
| 437 } | 510 } |
| 438 '''); | 511 '''); |
| 439 await assertHasFix( | 512 await assertHasFix( |
| (...skipping 4889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5329 await assertHasFix( | 5402 await assertHasFix( |
| 5330 DartFixKind.IMPORT_LIBRARY_PREFIX, | 5403 DartFixKind.IMPORT_LIBRARY_PREFIX, |
| 5331 ''' | 5404 ''' |
| 5332 import 'dart:math' as pref; | 5405 import 'dart:math' as pref; |
| 5333 main() { | 5406 main() { |
| 5334 print(pref.E); | 5407 print(pref.E); |
| 5335 print(pref.PI); | 5408 print(pref.PI); |
| 5336 } | 5409 } |
| 5337 '''); | 5410 '''); |
| 5338 } | 5411 } |
| 5412 | |
| 5413 void _addMetaPackageSource() { | |
| 5414 addPackageSource('meta', 'meta.dart', r''' | |
| 5415 library meta; | |
| 5416 | |
| 5417 const Required required = const Required(); | |
| 5418 | |
| 5419 class Required { | |
| 5420 final String reason; | |
| 5421 const Required([this.reason]); | |
| 5422 } | |
| 5423 '''); | |
| 5424 } | |
| 5339 } | 5425 } |
| 5340 | 5426 |
| 5341 @reflectiveTest | 5427 @reflectiveTest |
| 5342 class FixProcessorTest_Driver extends FixProcessorTest { | 5428 class FixProcessorTest_Driver extends FixProcessorTest { |
| 5343 @override | 5429 @override |
| 5344 bool get enableNewAnalysisDriver => true; | 5430 bool get enableNewAnalysisDriver => true; |
| 5345 | 5431 |
| 5346 @failingTest | 5432 @failingTest |
| 5347 @override | 5433 @override |
| 5348 test_importLibrarySdk_withClass_AsExpression() { | 5434 test_importLibrarySdk_withClass_AsExpression() { |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5654 | 5740 |
| 5655 @override | 5741 @override |
| 5656 final CompilationUnit unit; | 5742 final CompilationUnit unit; |
| 5657 | 5743 |
| 5658 @override | 5744 @override |
| 5659 final AnalysisError error; | 5745 final AnalysisError error; |
| 5660 | 5746 |
| 5661 _DartFixContextImpl(this.resourceProvider, this.getTopLevelDeclarations, | 5747 _DartFixContextImpl(this.resourceProvider, this.getTopLevelDeclarations, |
| 5662 this.analysisContext, this.astProvider, this.unit, this.error); | 5748 this.analysisContext, this.astProvider, this.unit, this.error); |
| 5663 } | 5749 } |
| OLD | NEW |