| 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/refactoring/extract_method.dart'; | 10 import 'package:analysis_server/src/services/refactoring/extract_method.dart'; |
| (...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1068 print(v); | 1068 print(v); |
| 1069 } | 1069 } |
| 1070 '''); | 1070 '''); |
| 1071 _createRefactoringForStartEndComments(); | 1071 _createRefactoringForStartEndComments(); |
| 1072 // do check | 1072 // do check |
| 1073 return refactoring.checkInitialConditions().then((_) { | 1073 return refactoring.checkInitialConditions().then((_) { |
| 1074 expect(refactoring.returnType, 'double'); | 1074 expect(refactoring.returnType, 'double'); |
| 1075 }); | 1075 }); |
| 1076 } | 1076 } |
| 1077 | 1077 |
| 1078 test_returnType_statements_nullMix() { |
| 1079 indexTestUnit(''' |
| 1080 main(bool p) { |
| 1081 // start |
| 1082 if (p) { |
| 1083 return 42; |
| 1084 } |
| 1085 return null; |
| 1086 // end |
| 1087 } |
| 1088 '''); |
| 1089 _createRefactoringForStartEndComments(); |
| 1090 // do check |
| 1091 return refactoring.checkInitialConditions().then((_) { |
| 1092 expect(refactoring.returnType, 'int'); |
| 1093 }); |
| 1094 } |
| 1095 |
| 1078 test_returnType_statements_void() { | 1096 test_returnType_statements_void() { |
| 1079 indexTestUnit(''' | 1097 indexTestUnit(''' |
| 1080 main() { | 1098 main() { |
| 1081 // start | 1099 // start |
| 1082 print(42); | 1100 print(42); |
| 1083 // end | 1101 // end |
| 1084 } | 1102 } |
| 1085 '''); | 1103 '''); |
| 1086 _createRefactoringForStartEndComments(); | 1104 _createRefactoringForStartEndComments(); |
| 1087 // do check | 1105 // do check |
| (...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2447 * Returns a deep copy of [refactoring] parameters. | 2465 * Returns a deep copy of [refactoring] parameters. |
| 2448 * There was a bug masked by updating parameter instances shared between the | 2466 * There was a bug masked by updating parameter instances shared between the |
| 2449 * refactoring and the test. | 2467 * refactoring and the test. |
| 2450 */ | 2468 */ |
| 2451 List<RefactoringMethodParameter> _getParametersCopy() { | 2469 List<RefactoringMethodParameter> _getParametersCopy() { |
| 2452 return refactoring.parameters.map((p) { | 2470 return refactoring.parameters.map((p) { |
| 2453 return new RefactoringMethodParameter(p.kind, p.type, p.name, id: p.id); | 2471 return new RefactoringMethodParameter(p.kind, p.type, p.name, id: p.id); |
| 2454 }).toList(); | 2472 }).toList(); |
| 2455 } | 2473 } |
| 2456 } | 2474 } |
| OLD | NEW |