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

Side by Side Diff: pkg/analysis_server/test/services/refactoring/extract_local_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_local; 5 library test.services.refactoring.extract_local;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 9
10 import 'package:analysis_server/plugin/protocol/protocol.dart'; 10 import 'package:analysis_server/plugin/protocol/protocol.dart';
11 import 'package:analysis_server/src/services/correction/status.dart'; 11 import 'package:analysis_server/src/services/correction/status.dart';
12 import 'package:analysis_server/src/services/refactoring/extract_local.dart'; 12 import 'package:analysis_server/src/services/refactoring/extract_local.dart';
13 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; 13 import 'package:analysis_server/src/services/refactoring/refactoring.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(ExtractLocalTest); 21 defineReflectiveTests(ExtractLocalTest);
22 defineReflectiveTests(ExtractLocalTest_Driver);
22 }); 23 });
23 } 24 }
24 25
25 @reflectiveTest 26 @reflectiveTest
26 class ExtractLocalTest extends RefactoringTest { 27 class ExtractLocalTest extends RefactoringTest {
27 ExtractLocalRefactoringImpl refactoring; 28 ExtractLocalRefactoringImpl refactoring;
28 29
29 test_checkFinalConditions_sameVariable_after() async { 30 test_checkFinalConditions_sameVariable_after() async {
30 await indexTestUnit(''' 31 await indexTestUnit('''
31 main() { 32 main() {
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 List<String> subExpressions = _getCoveringExpressions(); 455 List<String> subExpressions = _getCoveringExpressions();
455 expect(subExpressions, ['111', '111 + 222', 'foo(v = 111 + 222)']); 456 expect(subExpressions, ['111', '111 + 222', 'foo(v = 111 + 222)']);
456 } 457 }
457 458
458 test_coveringExpressions_skip_constructorName() async { 459 test_coveringExpressions_skip_constructorName() async {
459 await indexTestUnit(''' 460 await indexTestUnit('''
460 class AAA { 461 class AAA {
461 AAA.name() {} 462 AAA.name() {}
462 } 463 }
463 main() { 464 main() {
464 int v = new AAA.name(); 465 var v = new AAA.name();
465 } 466 }
466 '''); 467 ''');
467 _createRefactoring(testCode.indexOf('AA.name();'), 5); 468 _createRefactoring(testCode.indexOf('AA.name();'), 5);
468 // check conditions 469 // check conditions
469 await refactoring.checkInitialConditions(); 470 await refactoring.checkInitialConditions();
470 List<String> subExpressions = _getCoveringExpressions(); 471 List<String> subExpressions = _getCoveringExpressions();
471 expect(subExpressions, ['new AAA.name()']); 472 expect(subExpressions, ['new AAA.name()']);
472 } 473 }
473 474
474 test_coveringExpressions_skip_constructorName_name() async { 475 test_coveringExpressions_skip_constructorName_name() async {
475 await indexTestUnit(''' 476 await indexTestUnit('''
476 class A { 477 class A {
477 A.name() {} 478 A.name() {}
478 } 479 }
479 main() { 480 main() {
480 int v = new A.name(); 481 var v = new A.name();
481 } 482 }
482 '''); 483 ''');
483 _createRefactoring(testCode.indexOf('ame();'), 0); 484 _createRefactoring(testCode.indexOf('ame();'), 0);
484 // check conditions 485 // check conditions
485 await refactoring.checkInitialConditions(); 486 await refactoring.checkInitialConditions();
486 List<String> subExpressions = _getCoveringExpressions(); 487 List<String> subExpressions = _getCoveringExpressions();
487 expect(subExpressions, ['new A.name()']); 488 expect(subExpressions, ['new A.name()']);
488 } 489 }
489 490
490 test_coveringExpressions_skip_constructorName_type() async { 491 test_coveringExpressions_skip_constructorName_type() async {
491 await indexTestUnit(''' 492 await indexTestUnit('''
492 class A {} 493 class A {}
493 main() { 494 main() {
494 int v = new A(); 495 var v = new A();
495 } 496 }
496 '''); 497 ''');
497 _createRefactoring(testCode.indexOf('A();'), 0); 498 _createRefactoring(testCode.indexOf('A();'), 0);
498 // check conditions 499 // check conditions
499 await refactoring.checkInitialConditions(); 500 await refactoring.checkInitialConditions();
500 List<String> subExpressions = _getCoveringExpressions(); 501 List<String> subExpressions = _getCoveringExpressions();
501 expect(subExpressions, ['new A()']); 502 expect(subExpressions, ['new A()']);
502 } 503 }
503 504
504 test_coveringExpressions_skip_constructorName_typeArgument() async { 505 test_coveringExpressions_skip_constructorName_typeArgument() async {
505 await indexTestUnit(''' 506 await indexTestUnit('''
506 class A<T> {} 507 class A<T> {}
507 main() { 508 main() {
508 int v = new A<String>(); 509 var v = new A<String>();
509 } 510 }
510 '''); 511 ''');
511 _createRefactoring(testCode.indexOf('ring>'), 0); 512 _createRefactoring(testCode.indexOf('ring>'), 0);
512 // check conditions 513 // check conditions
513 await refactoring.checkInitialConditions(); 514 await refactoring.checkInitialConditions();
514 List<String> subExpressions = _getCoveringExpressions(); 515 List<String> subExpressions = _getCoveringExpressions();
515 expect(subExpressions, ['new A<String>()']); 516 expect(subExpressions, ['new A<String>()']);
516 } 517 }
517 518
518 test_coveringExpressions_skip_namedExpression() async { 519 test_coveringExpressions_skip_namedExpression() async {
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 List<String> _getCoveringExpressions() { 1340 List<String> _getCoveringExpressions() {
1340 List<String> subExpressions = <String>[]; 1341 List<String> subExpressions = <String>[];
1341 for (int i = 0; i < refactoring.coveringExpressionOffsets.length; i++) { 1342 for (int i = 0; i < refactoring.coveringExpressionOffsets.length; i++) {
1342 int offset = refactoring.coveringExpressionOffsets[i]; 1343 int offset = refactoring.coveringExpressionOffsets[i];
1343 int length = refactoring.coveringExpressionLengths[i]; 1344 int length = refactoring.coveringExpressionLengths[i];
1344 subExpressions.add(testCode.substring(offset, offset + length)); 1345 subExpressions.add(testCode.substring(offset, offset + length));
1345 } 1346 }
1346 return subExpressions; 1347 return subExpressions;
1347 } 1348 }
1348 } 1349 }
1350
1351 @reflectiveTest
1352 class ExtractLocalTest_Driver extends ExtractLocalTest {
1353 @override
1354 bool get enableNewAnalysisDriver => true;
1355 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698