Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(386)

Side by Side Diff: pkg/analysis_server/test/services/refactoring/extract_method_test.dart

Issue 1364803003: Use TypeSystem in the 'Extract Method' refactoring. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analysis_server/test/services/refactoring/abstract_refactoring.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 main() { 1061 main() {
1062 int a = 1 + 2; 1062 int a = 1 + 2;
1063 } 1063 }
1064 '''); 1064 ''');
1065 _createRefactoringForString('1 + 2'); 1065 _createRefactoringForString('1 + 2');
1066 // do check 1066 // do check
1067 await refactoring.checkInitialConditions(); 1067 await refactoring.checkInitialConditions();
1068 expect(refactoring.returnType, 'int'); 1068 expect(refactoring.returnType, 'int');
1069 } 1069 }
1070 1070
1071 test_returnType_mixInterfaceFunction() async {
1072 indexTestUnit('''
1073 main() {
1074 // start
1075 if (true) {
1076 return 1;
1077 } else {
1078 return () {};
1079 }
1080 // end
1081 }
1082 ''');
1083 _createRefactoringForStartEndComments();
1084 // do check
1085 await refactoring.checkInitialConditions();
1086 expect(refactoring.returnType, 'Object');
1087 }
1088
1071 test_returnType_statements() async { 1089 test_returnType_statements() async {
1072 indexTestUnit(''' 1090 indexTestUnit('''
1073 main() { 1091 main() {
1074 // start 1092 // start
1075 double v = 5.0; 1093 double v = 5.0;
1076 // end 1094 // end
1077 print(v); 1095 print(v);
1078 } 1096 }
1079 '''); 1097 ''');
1080 _createRefactoringForStartEndComments(); 1098 _createRefactoringForStartEndComments();
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after
2574 2592
2575 int res() { 2593 int res() {
2576 localFunction() { 2594 localFunction() {
2577 return 'abc'; 2595 return 'abc';
2578 } 2596 }
2579 return 42; 2597 return 42;
2580 } 2598 }
2581 '''); 2599 ''');
2582 } 2600 }
2583 2601
2602 test_statements_return_multiple_interfaceFunction() {
2603 indexTestUnit('''
2604 main(bool b) {
2605 // start
2606 if (b) {
2607 return 1;
2608 }
2609 return () {};
2610 // end
2611 }
2612 ''');
2613 _createRefactoringForStartEndComments();
2614 // apply refactoring
2615 return _assertSuccessfulRefactoring('''
2616 main(bool b) {
2617 // start
2618 return res(b);
2619 // end
2620 }
2621
2622 Object res(bool b) {
2623 if (b) {
2624 return 1;
2625 }
2626 return () {};
2627 }
2628 ''');
2629 }
2630
2584 test_statements_return_multiple_sameElementDifferentTypeArgs() { 2631 test_statements_return_multiple_sameElementDifferentTypeArgs() {
2585 indexTestUnit(''' 2632 indexTestUnit('''
2586 main(bool b) { 2633 main(bool b) {
2587 // start 2634 // start
2588 if (b) { 2635 if (b) {
2589 print(true); 2636 print(true);
2590 return <int>[]; 2637 return <int>[];
2591 } else { 2638 } else {
2592 print(false); 2639 print(false);
2593 return <String>[]; 2640 return <String>[];
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2753 * Returns a deep copy of [refactoring] parameters. 2800 * Returns a deep copy of [refactoring] parameters.
2754 * There was a bug masked by updating parameter instances shared between the 2801 * There was a bug masked by updating parameter instances shared between the
2755 * refactoring and the test. 2802 * refactoring and the test.
2756 */ 2803 */
2757 List<RefactoringMethodParameter> _getParametersCopy() { 2804 List<RefactoringMethodParameter> _getParametersCopy() {
2758 return refactoring.parameters.map((p) { 2805 return refactoring.parameters.map((p) {
2759 return new RefactoringMethodParameter(p.kind, p.type, p.name, id: p.id); 2806 return new RefactoringMethodParameter(p.kind, p.type, p.name, id: p.id);
2760 }).toList(); 2807 }).toList();
2761 } 2808 }
2762 } 2809 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/services/refactoring/abstract_refactoring.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698