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

Unified Diff: pkg/analysis_server/test/services/refactoring/extract_local_test.dart

Issue 489413003: Finish 'Extract Local' refactoring. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/extract_local.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/services/refactoring/extract_local_test.dart
diff --git a/pkg/analysis_server/test/services/refactoring/extract_local_test.dart b/pkg/analysis_server/test/services/refactoring/extract_local_test.dart
index 1276ac97247db5b094e31982d34b038d0e1e89a0..501949a98e5581ea97ba1f88a9fd02678d11dd9f 100644
--- a/pkg/analysis_server/test/services/refactoring/extract_local_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/extract_local_test.dart
@@ -469,6 +469,50 @@ main() {
''');
}
+ test_guessNames_fragmentExpression() {
+ indexTestUnit('''
+main() {
+ var a = 111 + 222 + 333 + 444;
+}
+''');
+ _createRefactoringForString('222 + 333');
+ // check guesses
+ return refactoring.checkInitialConditions().then((_) {
+ expect(refactoring.names, isEmpty);
+ });
+ }
+
+ test_guessNames_singleExpression() {
+ indexTestUnit('''
+class TreeItem {}
+TreeItem getSelectedItem() => null;
+process(my) {}
+main() {
+ process(getSelectedItem()); // marker
+}
+''');
+ _createRefactoringWithSuffix('getSelectedItem()', '); // marker');
+ // check guesses
+ return refactoring.checkInitialConditions().then((_) {
+ expect(
+ refactoring.names,
+ unorderedEquals(['selectedItem', 'item', 'my', 'treeItem']));
+ });
+ }
+
+ test_guessNames_stringPart() {
+ indexTestUnit('''
+main() {
+ var s = 'Hello Bob... welcome to Dart!';
+}
+''');
+ _createRefactoringForString('Hello Bob');
+ // check guesses
+ return refactoring.checkInitialConditions().then((_) {
+ expect(refactoring.names, unorderedEquals(['helloBob', 'bob']));
+ });
+ }
+
test_occurences_disableOccurences() {
indexTestUnit('''
int foo() => 42;
@@ -617,7 +661,21 @@ main() {
}
test_offsets_lengths() {
- // TODO(scheglov) implement and test
+ indexTestUnit('''
+int foo() => 42;
+main() {
+ int a = 1 + foo(); // marker
+ int b = 2 + foo( );
+}
+''');
+ _createRefactoringWithSuffix('foo()', '; // marker');
+ // apply refactoring
+ return refactoring.checkInitialConditions().then((_) {
+ expect(
+ refactoring.offsets,
+ unorderedEquals([findOffset('foo();'), findOffset('foo( );')]));
+ expect(refactoring.lengths, unorderedEquals([5, 6]));
+ });
}
test_singleExpression() {
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/extract_local.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698