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.refactoring.extract_method; | 5 library test.services.refactoring.extract_method; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/src/protocol.dart'; | 9 import 'package:analysis_server/src/protocol.dart'; |
10 import 'package:analysis_server/src/services/correction/status.dart'; | 10 import 'package:analysis_server/src/services/correction/status.dart'; |
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 // end | 1051 // end |
1052 print(v); | 1052 print(v); |
1053 } | 1053 } |
1054 '''); | 1054 '''); |
1055 _createRefactoringForStartEndComments(); | 1055 _createRefactoringForStartEndComments(); |
1056 // do check | 1056 // do check |
1057 await refactoring.checkInitialConditions(); | 1057 await refactoring.checkInitialConditions(); |
1058 expect(refactoring.returnType, 'double'); | 1058 expect(refactoring.returnType, 'double'); |
1059 } | 1059 } |
1060 | 1060 |
| 1061 test_returnType_closure() async { |
| 1062 indexTestUnit(''' |
| 1063 process(f(x)) {} |
| 1064 main() { |
| 1065 process((x) => x * 2); |
| 1066 } |
| 1067 '''); |
| 1068 _createRefactoringForString('(x) => x * 2'); |
| 1069 // do check |
| 1070 await refactoring.checkInitialConditions(); |
| 1071 expect(refactoring.returnType, ''); |
| 1072 } |
| 1073 |
1061 test_returnType_statements_nullMix() async { | 1074 test_returnType_statements_nullMix() async { |
1062 indexTestUnit(''' | 1075 indexTestUnit(''' |
1063 main(bool p) { | 1076 main(bool p) { |
1064 // start | 1077 // start |
1065 if (p) { | 1078 if (p) { |
1066 return 42; | 1079 return 42; |
1067 } | 1080 } |
1068 return null; | 1081 return null; |
1069 // end | 1082 // end |
1070 } | 1083 } |
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2525 * Returns a deep copy of [refactoring] parameters. | 2538 * Returns a deep copy of [refactoring] parameters. |
2526 * There was a bug masked by updating parameter instances shared between the | 2539 * There was a bug masked by updating parameter instances shared between the |
2527 * refactoring and the test. | 2540 * refactoring and the test. |
2528 */ | 2541 */ |
2529 List<RefactoringMethodParameter> _getParametersCopy() { | 2542 List<RefactoringMethodParameter> _getParametersCopy() { |
2530 return refactoring.parameters.map((p) { | 2543 return refactoring.parameters.map((p) { |
2531 return new RefactoringMethodParameter(p.kind, p.type, p.name, id: p.id); | 2544 return new RefactoringMethodParameter(p.kind, p.type, p.name, id: p.id); |
2532 }).toList(); | 2545 }).toList(); |
2533 } | 2546 } |
2534 } | 2547 } |
OLD | NEW |