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

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

Issue 2618993003: Run 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
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/plugin/protocol/protocol.dart'; 9 import 'package:analysis_server/plugin/protocol/protocol.dart';
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/extract_method.dart'; 11 import 'package:analysis_server/src/services/refactoring/extract_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:test/test.dart'; 13 import 'package:test/test.dart';
14 import 'package:test_reflective_loader/test_reflective_loader.dart'; 14 import 'package:test_reflective_loader/test_reflective_loader.dart';
15 15
16 import 'abstract_refactoring.dart'; 16 import 'abstract_refactoring.dart';
17 17
18 main() { 18 main() {
19 defineReflectiveSuite(() { 19 defineReflectiveSuite(() {
20 defineReflectiveTests(ExtractMethodTest); 20 defineReflectiveTests(ExtractMethodTest);
21 defineReflectiveTests(ExtractMethodTest_Driver);
21 }); 22 });
22 } 23 }
23 24
24 @reflectiveTest 25 @reflectiveTest
25 class ExtractMethodTest extends RefactoringTest { 26 class ExtractMethodTest extends RefactoringTest {
26 ExtractMethodRefactoringImpl refactoring; 27 ExtractMethodRefactoringImpl refactoring;
27 28
28 test_bad_assignmentLeftHandSide() async { 29 test_bad_assignmentLeftHandSide() async {
29 await indexTestUnit(''' 30 await indexTestUnit('''
30 main() { 31 main() {
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 var v = res(); // marker 1205 var v = res(); // marker
1205 } 1206 }
1206 1207
1207 res() => dynaFunction(); 1208 res() => dynaFunction();
1208 '''); 1209 ''');
1209 } 1210 }
1210 1211
1211 test_singleExpression_hasAwait() async { 1212 test_singleExpression_hasAwait() async {
1212 await indexTestUnit(''' 1213 await indexTestUnit('''
1213 import 'dart:async'; 1214 import 'dart:async';
1214 Future<int> getValue() => 42; 1215 Future<int> getValue() async => 42;
1215 main() async { 1216 main() async {
1216 int v = await getValue(); 1217 int v = await getValue();
1217 print(v); 1218 print(v);
1218 } 1219 }
1219 '''); 1220 ''');
1220 _createRefactoringForString('await getValue()'); 1221 _createRefactoringForString('await getValue()');
1221 // apply refactoring 1222 // apply refactoring
1222 return _assertSuccessfulRefactoring(''' 1223 return _assertSuccessfulRefactoring('''
1223 import 'dart:async'; 1224 import 'dart:async';
1224 Future<int> getValue() => 42; 1225 Future<int> getValue() async => 42;
1225 main() async { 1226 main() async {
1226 int v = await res(); 1227 int v = await res();
1227 print(v); 1228 print(v);
1228 } 1229 }
1229 1230
1230 Future<int> res() async => await getValue(); 1231 Future<int> res() async => await getValue();
1231 '''); 1232 ''');
1232 } 1233 }
1233 1234
1234 test_singleExpression_ignore_assignmentLeftHandSize() async { 1235 test_singleExpression_ignore_assignmentLeftHandSize() async {
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
2181 // end 2182 // end
2182 } 2183 }
2183 '''); 2184 ''');
2184 _createRefactoringForStartEndComments(); 2185 _createRefactoringForStartEndComments();
2185 await assertRefactoringConditionsOK(); 2186 await assertRefactoringConditionsOK();
2186 } 2187 }
2187 2188
2188 test_statements_hasAwait_dynamicReturnType() async { 2189 test_statements_hasAwait_dynamicReturnType() async {
2189 await indexTestUnit(''' 2190 await indexTestUnit('''
2190 import 'dart:async'; 2191 import 'dart:async';
2191 Future getValue() => 42; 2192 Future getValue() async => 42;
2192 main() async { 2193 main() async {
2193 // start 2194 // start
2194 var v = await getValue(); 2195 var v = await getValue();
2195 // end 2196 // end
2196 print(v); 2197 print(v);
2197 } 2198 }
2198 '''); 2199 ''');
2199 _createRefactoringForStartEndComments(); 2200 _createRefactoringForStartEndComments();
2200 // apply refactoring 2201 // apply refactoring
2201 return _assertSuccessfulRefactoring(''' 2202 return _assertSuccessfulRefactoring('''
2202 import 'dart:async'; 2203 import 'dart:async';
2203 Future getValue() => 42; 2204 Future getValue() async => 42;
2204 main() async { 2205 main() async {
2205 // start 2206 // start
2206 var v = await res(); 2207 var v = await res();
2207 // end 2208 // end
2208 print(v); 2209 print(v);
2209 } 2210 }
2210 2211
2211 Future res() async { 2212 Future res() async {
2212 var v = await getValue(); 2213 var v = await getValue();
2213 return v; 2214 return v;
2214 } 2215 }
2215 '''); 2216 ''');
2216 } 2217 }
2217 2218
2218 test_statements_hasAwait_expression() async { 2219 test_statements_hasAwait_expression() async {
2219 await indexTestUnit(''' 2220 await indexTestUnit('''
2220 import 'dart:async'; 2221 import 'dart:async';
2221 Future<int> getValue() => 42; 2222 Future<int> getValue() async => 42;
2222 main() async { 2223 main() async {
2223 // start 2224 // start
2224 int v = await getValue(); 2225 int v = await getValue();
2225 v += 2; 2226 v += 2;
2226 // end 2227 // end
2227 print(v); 2228 print(v);
2228 } 2229 }
2229 '''); 2230 ''');
2230 _createRefactoringForStartEndComments(); 2231 _createRefactoringForStartEndComments();
2231 // apply refactoring 2232 // apply refactoring
2232 return _assertSuccessfulRefactoring(''' 2233 return _assertSuccessfulRefactoring('''
2233 import 'dart:async'; 2234 import 'dart:async';
2234 Future<int> getValue() => 42; 2235 Future<int> getValue() async => 42;
2235 main() async { 2236 main() async {
2236 // start 2237 // start
2237 int v = await res(); 2238 int v = await res();
2238 // end 2239 // end
2239 print(v); 2240 print(v);
2240 } 2241 }
2241 2242
2242 Future<int> res() async { 2243 Future<int> res() async {
2243 int v = await getValue(); 2244 int v = await getValue();
2244 v += 2; 2245 v += 2;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2279 sum += v; 2280 sum += v;
2280 } 2281 }
2281 return sum; 2282 return sum;
2282 } 2283 }
2283 '''); 2284 ''');
2284 } 2285 }
2285 2286
2286 test_statements_hasAwait_voidReturnType() async { 2287 test_statements_hasAwait_voidReturnType() async {
2287 await indexTestUnit(''' 2288 await indexTestUnit('''
2288 import 'dart:async'; 2289 import 'dart:async';
2289 Future<int> getValue() => 42; 2290 Future<int> getValue() async => 42;
2290 main() async { 2291 main() async {
2291 // start 2292 // start
2292 int v = await getValue(); 2293 int v = await getValue();
2293 print(v); 2294 print(v);
2294 // end 2295 // end
2295 } 2296 }
2296 '''); 2297 ''');
2297 _createRefactoringForStartEndComments(); 2298 _createRefactoringForStartEndComments();
2298 // apply refactoring 2299 // apply refactoring
2299 return _assertSuccessfulRefactoring(''' 2300 return _assertSuccessfulRefactoring('''
2300 import 'dart:async'; 2301 import 'dart:async';
2301 Future<int> getValue() => 42; 2302 Future<int> getValue() async => 42;
2302 main() async { 2303 main() async {
2303 // start 2304 // start
2304 await res(); 2305 await res();
2305 // end 2306 // end
2306 } 2307 }
2307 2308
2308 Future res() async { 2309 Future res() async {
2309 int v = await getValue(); 2310 int v = await getValue();
2310 print(v); 2311 print(v);
2311 } 2312 }
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
2835 * Returns a deep copy of [refactoring] parameters. 2836 * Returns a deep copy of [refactoring] parameters.
2836 * There was a bug masked by updating parameter instances shared between the 2837 * There was a bug masked by updating parameter instances shared between the
2837 * refactoring and the test. 2838 * refactoring and the test.
2838 */ 2839 */
2839 List<RefactoringMethodParameter> _getParametersCopy() { 2840 List<RefactoringMethodParameter> _getParametersCopy() {
2840 return refactoring.parameters.map((p) { 2841 return refactoring.parameters.map((p) {
2841 return new RefactoringMethodParameter(p.kind, p.type, p.name, id: p.id); 2842 return new RefactoringMethodParameter(p.kind, p.type, p.name, id: p.id);
2842 }).toList(); 2843 }).toList();
2843 } 2844 }
2844 } 2845 }
2846
2847 @reflectiveTest
2848 class ExtractMethodTest_Driver extends ExtractMethodTest {
2849 @override
2850 bool get enableNewAnalysisDriver => true;
2851 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698