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

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

Issue 633823002: Issue 21233. Improve inlining strings into string interpolations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix the single/multi issue. Created 6 years, 2 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/pubspec.yaml ('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/inline_local_test.dart
diff --git a/pkg/analysis_server/test/services/refactoring/inline_local_test.dart b/pkg/analysis_server/test/services/refactoring/inline_local_test.dart
index 7af239514772d3b5da51587169b7d246c7e4e4df..17e0b73b2c7f1248934ed9ea0f73db346fb0a827 100644
--- a/pkg/analysis_server/test/services/refactoring/inline_local_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/inline_local_test.dart
@@ -72,7 +72,7 @@ main() {
''');
}
- test_OK_intoStringInterpolation() {
+ test_OK_intoStringInterpolation_binaryExpression() {
indexTestUnit(r'''
main() {
int test = 1 + 2;
@@ -94,6 +94,210 @@ process(x) {}
''');
}
+ test_OK_intoStringInterpolation_simpleIdentifier() {
+ indexTestUnit(r'''
+main() {
+ int foo = 1 + 2;
+ int test = foo;
+ print('test = $test');
+ print('test = ${test}');
+ print('test = ${process(test)}');
+}
+process(x) {}
+''');
+ _createRefactoring('test =');
+ // validate change
+ return assertSuccessfulRefactoring(r'''
+main() {
+ int foo = 1 + 2;
+ print('test = $foo');
+ print('test = ${foo}');
+ print('test = ${process(foo)}');
+}
+process(x) {}
+''');
+ }
+
+ test_OK_intoStringInterpolation_stringInterpolation() {
+ indexTestUnit(r'''
+main() {
+ String a = 'aaa';
+ String b = '$a bbb';
+ String c = '$b ccc';
+}
+''');
+ _createRefactoring('b =');
+ // validate change
+ return assertSuccessfulRefactoring(r'''
+main() {
+ String a = 'aaa';
+ String c = '$a bbb ccc';
+}
+''');
+ }
+
+ test_OK_intoStringInterpolation_string_differentQuotes() {
+ indexTestUnit(r'''
+main() {
+ String a = "aaa";
+ String b = '$a bbb';
+}
+''');
+ _createRefactoring('a =');
+ // validate change
+ return assertSuccessfulRefactoring(r'''
+main() {
+ String b = '${"aaa"} bbb';
+}
+''');
+ }
+
+ test_OK_intoStringInterpolation_string_doubleQuotes() {
+ indexTestUnit(r'''
+main() {
+ String a = "aaa";
+ String b = "$a bbb";
+}
+''');
+ _createRefactoring('a =');
+ // validate change
+ return assertSuccessfulRefactoring(r'''
+main() {
+ String b = "aaa bbb";
+}
+''');
+ }
+
+ test_OK_intoStringInterpolation_string_multiLineIntoMulti_unixEOL() {
+ indexTestUnit(r"""
+main() {
+ String a = '''
+a
+a
+a''';
+ String b = '''
+$a
+bbb''';
+}
+""");
+ _createRefactoring('a =');
+ // validate change
+ return assertSuccessfulRefactoring(r"""
+main() {
+ String b = '''
+a
+a
+a
+bbb''';
+}
+""");
+ }
+
+ test_OK_intoStringInterpolation_string_multiLineIntoMulti_windowsEOL() {
+ indexTestUnit(r"""
+main() {
+ String a = '''
+a
+a
+a''';
+ String b = '''
+$a
+bbb''';
+}
+""".replaceAll('\n', '\r\n'));
+ _createRefactoring('a =');
+ // validate change
+ return assertSuccessfulRefactoring(r"""
+main() {
+ String b = '''
+a
+a
+a
+bbb''';
+}
+""".replaceAll('\n', '\r\n'));
+ }
+
+ test_OK_intoStringInterpolation_string_multiLineIntoSingle() {
+ indexTestUnit(r'''
+main() {
+ String a = """aaa""";
+ String b = "$a bbb";
+}
+''');
+ _createRefactoring('a =');
+ // validate change
+ return assertSuccessfulRefactoring(r'''
+main() {
+ String b = "${"""aaa"""} bbb";
+}
+''');
+ }
+
+ test_OK_intoStringInterpolation_string_raw() {
+ indexTestUnit(r'''
+main() {
+ String a = r'an $ignored interpolation';
+ String b = '$a bbb';
+}
+''');
+ _createRefactoring('a =');
+ // we don't unwrap raw strings
+ return assertSuccessfulRefactoring(r'''
+main() {
+ String b = '${r'an $ignored interpolation'} bbb';
+}
+''');
+ }
+
+ test_OK_intoStringInterpolation_string_singleLineIntoMulti_doubleQuotes() {
+ indexTestUnit(r'''
+main() {
+ String a = "aaa";
+ String b = """$a bbb""";
+}
+''');
+ _createRefactoring('a =');
+ // validate change
+ return assertSuccessfulRefactoring(r'''
+main() {
+ String b = """aaa bbb""";
+}
+''');
+ }
+
+ test_OK_intoStringInterpolation_string_singleLineIntoMulti_singleQuotes() {
+ indexTestUnit(r"""
+main() {
+ String a = 'aaa';
+ String b = '''$a bbb''';
+}
+""");
+ _createRefactoring('a =');
+ // validate change
+ return assertSuccessfulRefactoring(r"""
+main() {
+ String b = '''aaa bbb''';
+}
+""");
+ }
+
+ test_OK_intoStringInterpolation_string_singleQuotes() {
+ indexTestUnit(r'''
+main() {
+ String a = 'aaa';
+ String b = '$a bbb';
+}
+''');
+ _createRefactoring('a =');
+ // validate change
+ return assertSuccessfulRefactoring(r'''
+main() {
+ String b = 'aaa bbb';
+}
+''');
+ }
+
/**
* <p>
* https://code.google.com/p/dart/issues/detail?id=18587
« no previous file with comments | « pkg/analysis_server/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698