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

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

Issue 1496363002: Skip assignments and argument lists. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 1cb626f0071248e2c17056b98d71bb71e8766137..46a6e670122794d2646f24eb83b74b4b9a7dc137 100644
--- a/pkg/analysis_server/test/services/refactoring/extract_local_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/extract_local_test.dart
@@ -332,16 +332,40 @@ main() {
_createRefactoring(testCode.indexOf('bb * 2'), 0);
// check conditions
await refactoring.checkInitialConditions();
- List<String> subExpressions = <String>[];
- for (int i = 0; i < refactoring.coveringExpressionOffsets.length; i++) {
- int offset = refactoring.coveringExpressionOffsets[i];
- int length = refactoring.coveringExpressionLengths[i];
- subExpressions.add(testCode.substring(offset, offset + length));
- }
+ List<String> subExpressions = _getCoveringExpressions();
expect(subExpressions,
['bbb', 'bbb * 2', 'aaa + bbb * 2', 'aaa + bbb * 2 + 3']);
}
+ test_coveringExpressions_inArgumentList() async {
+ indexTestUnit('''
+main() {
+ foo(111 + 222);
+}
+int foo(int x) => x;
+''');
+ _createRefactoring(testCode.indexOf('11 +'), 0);
+ // check conditions
+ await refactoring.checkInitialConditions();
+ List<String> subExpressions = _getCoveringExpressions();
+ expect(subExpressions, ['111', '111 + 222', 'foo(111 + 222)']);
+ }
+
+ test_coveringExpressions_skipAssignments() async {
+ indexTestUnit('''
+main() {
+ int v;
+ foo(v = 111 + 222);
+}
+int foo(x) => 42;
+''');
+ _createRefactoring(testCode.indexOf('11 +'), 0);
+ // check conditions
+ await refactoring.checkInitialConditions();
+ List<String> subExpressions = _getCoveringExpressions();
+ expect(subExpressions, ['111', '111 + 222', 'foo(v = 111 + 222)']);
+ }
+
test_fragmentExpression() {
indexTestUnit('''
main() {
@@ -1053,4 +1077,14 @@ main() {
int length = selectionSearch.length;
_createRefactoring(offset, length);
}
+
+ List<String> _getCoveringExpressions() {
+ List<String> subExpressions = <String>[];
+ for (int i = 0; i < refactoring.coveringExpressionOffsets.length; i++) {
+ int offset = refactoring.coveringExpressionOffsets[i];
+ int length = refactoring.coveringExpressionLengths[i];
+ subExpressions.add(testCode.substring(offset, offset + length));
+ }
+ return subExpressions;
+ }
}
« 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