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

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

Issue 2619053002: Run 'Inline Method' refactoring tests with the new analysis driver. (Closed)
Patch Set: Created 3 years, 11 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/lib/src/services/refactoring/inline_method.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.inline_method; 5 library test.services.refactoring.inline_method;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/protocol/protocol.dart' hide Element; 9 import 'package:analysis_server/plugin/protocol/protocol.dart' hide Element;
10 import 'package:analysis_server/src/services/correction/status.dart'; 10 import 'package:analysis_server/src/services/correction/status.dart';
11 import 'package:analysis_server/src/services/refactoring/inline_method.dart'; 11 import 'package:analysis_server/src/services/refactoring/inline_method.dart';
12 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; 12 import 'package:analysis_server/src/services/refactoring/refactoring.dart';
13 import 'package:analyzer/src/generated/source.dart'; 13 import 'package:analyzer/src/generated/source.dart';
14 import 'package:test/test.dart'; 14 import 'package:test/test.dart';
15 import 'package:test_reflective_loader/test_reflective_loader.dart'; 15 import 'package:test_reflective_loader/test_reflective_loader.dart';
16 16
17 import 'abstract_refactoring.dart'; 17 import 'abstract_refactoring.dart';
18 18
19 main() { 19 main() {
20 defineReflectiveSuite(() { 20 defineReflectiveSuite(() {
21 defineReflectiveTests(InlineMethodTest); 21 defineReflectiveTests(InlineMethodTest);
22 defineReflectiveTests(InlineMethodTest_Driver);
22 }); 23 });
23 } 24 }
24 25
25 @reflectiveTest 26 @reflectiveTest
26 class InlineMethodTest extends RefactoringTest { 27 class InlineMethodTest extends RefactoringTest {
27 InlineMethodRefactoringImpl refactoring; 28 InlineMethodRefactoringImpl refactoring;
28 bool deleteSource; 29 bool deleteSource;
29 bool inlineAll; 30 bool inlineAll;
30 31
31 test_access_FunctionElement() async { 32 test_access_FunctionElement() async {
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 } 782 }
782 } 783 }
783 '''); 784 ''');
784 } 785 }
785 786
786 test_getter_async_targetIsAsyncStar() async { 787 test_getter_async_targetIsAsyncStar() async {
787 await indexTestUnit(r''' 788 await indexTestUnit(r'''
788 import 'dart:async'; 789 import 'dart:async';
789 class A { 790 class A {
790 Future<int> get test async => 42; 791 Future<int> get test async => 42;
791 Stream<int> foo() async { 792 Stream<int> foo() async* {
792 return await test; 793 yield await test;
793 } 794 }
794 } 795 }
795 '''); 796 ''');
796 _createRefactoring('test async'); 797 _createRefactoring('test async');
797 // validate change 798 // validate change
798 return _assertSuccessfulRefactoring(r''' 799 return _assertSuccessfulRefactoring(r'''
799 import 'dart:async'; 800 import 'dart:async';
800 class A { 801 class A {
801 Stream<int> foo() async { 802 Stream<int> foo() async* {
802 return await 42; 803 yield await 42;
803 } 804 }
804 } 805 }
805 '''); 806 ''');
806 } 807 }
807 808
808 test_getter_async_targetIsSync() async { 809 test_getter_async_targetIsSync() async {
809 await indexTestUnit(r''' 810 await indexTestUnit(r'''
810 import 'dart:async'; 811 import 'dart:async';
811 class A { 812 class A {
812 Future<int> get test async => 42; 813 Future<int> get test async => 42;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 return 42; 967 return 42;
967 } 968 }
968 } 969 }
969 '''); 970 ''');
970 } 971 }
971 972
972 test_method_async2() async { 973 test_method_async2() async {
973 await indexTestUnit(r''' 974 await indexTestUnit(r'''
974 import 'dart:async'; 975 import 'dart:async';
975 class A { 976 class A {
976 Future<int> test() async => 42; 977 Future<int> foo() async => 42;
977 Future foo() { 978 Future<int> test() async => await foo();
978 return [test(), test()]; 979 Future bar() {
980 return new Future.value([test(), test()]);
979 } 981 }
980 } 982 }
981 '''); 983 ''');
982 _createRefactoring('test() async'); 984 _createRefactoring('test() async');
983 // validate change 985 // validate change
984 return _assertSuccessfulRefactoring(r''' 986 return _assertSuccessfulRefactoring(r'''
985 import 'dart:async'; 987 import 'dart:async';
986 class A { 988 class A {
987 Future foo() async { 989 Future<int> foo() async => 42;
988 return [42, 42]; 990 Future bar() async {
991 return new Future.value([(await foo()), (await foo())]);
989 } 992 }
990 } 993 }
991 '''); 994 ''');
992 } 995 }
993 996
994 test_method_emptyBody() async { 997 test_method_emptyBody() async {
995 await indexTestUnit(r''' 998 await indexTestUnit(r'''
996 abstract class A { 999 abstract class A {
997 test(); 1000 test();
998 } 1001 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 } 1047 }
1045 1048
1046 test_method_fieldStatic() async { 1049 test_method_fieldStatic() async {
1047 await indexTestUnit(r''' 1050 await indexTestUnit(r'''
1048 class A { 1051 class A {
1049 static var FA = 1; 1052 static var FA = 1;
1050 } 1053 }
1051 class B extends A { 1054 class B extends A {
1052 static var FB = 2; 1055 static var FB = 2;
1053 test() { 1056 test() {
1054 print(FA);
1055 print(FB); 1057 print(FB);
1056 print(A.FA); 1058 print(A.FA);
1057 print(B.FB); 1059 print(B.FB);
1058 } 1060 }
1059 } 1061 }
1060 main() { 1062 main() {
1061 B b = new B(); 1063 B b = new B();
1062 b.test(); 1064 b.test();
1063 } 1065 }
1064 '''); 1066 ''');
1065 _createRefactoring('test() {'); 1067 _createRefactoring('test() {');
1066 // validate change 1068 // validate change
1067 return _assertSuccessfulRefactoring(r''' 1069 return _assertSuccessfulRefactoring(r'''
1068 class A { 1070 class A {
1069 static var FA = 1; 1071 static var FA = 1;
1070 } 1072 }
1071 class B extends A { 1073 class B extends A {
1072 static var FB = 2; 1074 static var FB = 2;
1073 } 1075 }
1074 main() { 1076 main() {
1075 B b = new B(); 1077 B b = new B();
1076 print(A.FA);
1077 print(B.FB); 1078 print(B.FB);
1078 print(A.FA); 1079 print(A.FA);
1079 print(B.FB); 1080 print(B.FB);
1080 } 1081 }
1081 '''); 1082 ''');
1082 } 1083 }
1083 1084
1084 test_method_fieldStatic_sameClass() async { 1085 test_method_fieldStatic_sameClass() async {
1085 await indexTestUnit(r''' 1086 await indexTestUnit(r'''
1086 class A { 1087 class A {
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 this.refactoringChange = change; 1710 this.refactoringChange = change;
1710 assertTestChangeResult(expectedCode); 1711 assertTestChangeResult(expectedCode);
1711 } 1712 }
1712 1713
1713 void _createRefactoring(String search) { 1714 void _createRefactoring(String search) {
1714 int offset = findOffset(search); 1715 int offset = findOffset(search);
1715 refactoring = new InlineMethodRefactoring( 1716 refactoring = new InlineMethodRefactoring(
1716 searchEngine, getResolvedUnitWithElement, testUnit, offset); 1717 searchEngine, getResolvedUnitWithElement, testUnit, offset);
1717 } 1718 }
1718 } 1719 }
1720
1721 @reflectiveTest
1722 class InlineMethodTest_Driver extends InlineMethodTest {
1723 @override
1724 bool get enableNewAnalysisDriver => true;
1725 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/inline_method.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698