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

Side by Side Diff: pkg/analysis_server/test/services/correction/assist_test.dart

Issue 1324323004: Issue 24298. Fix for 'async' function body conversion. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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.correction.assist; 5 library test.services.correction.assist;
6 6
7 import 'package:analysis_server/edit/assist/assist_core.dart'; 7 import 'package:analysis_server/edit/assist/assist_core.dart';
8 import 'package:analysis_server/src/plugin/server_plugin.dart'; 8 import 'package:analysis_server/src/plugin/server_plugin.dart';
9 import 'package:analysis_server/src/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
10 import 'package:analysis_server/src/services/correction/assist.dart'; 10 import 'package:analysis_server/src/services/correction/assist.dart';
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 void test_assignToLocalVariable_void() { 816 void test_assignToLocalVariable_void() {
817 resolveTestUnit(''' 817 resolveTestUnit('''
818 main() { 818 main() {
819 f(); 819 f();
820 } 820 }
821 void f() {} 821 void f() {}
822 '''); 822 ''');
823 assertNoAssistAt('f();', DartAssistKind.ASSIGN_TO_LOCAL_VARIABLE); 823 assertNoAssistAt('f();', DartAssistKind.ASSIGN_TO_LOCAL_VARIABLE);
824 } 824 }
825 825
826 void test_convertToBlockBody_OK_async() {
827 resolveTestUnit('''
828 class A {
829 mmm() async => 123;
830 }
831 ''');
832 assertHasAssistAt(
833 'mmm()',
834 DartAssistKind.CONVERT_INTO_BLOCK_BODY,
835 '''
836 class A {
837 mmm() async {
838 return 123;
839 }
840 }
841 ''');
842 }
843
826 void test_convertToBlockBody_OK_closure() { 844 void test_convertToBlockBody_OK_closure() {
827 resolveTestUnit(''' 845 resolveTestUnit('''
828 setup(x) {} 846 setup(x) {}
829 main() { 847 main() {
830 setup(() => 42); 848 setup(() => 42);
831 } 849 }
832 '''); 850 ''');
833 assertHasAssistAt( 851 assertHasAssistAt(
834 '() => 42', 852 '() => 42',
835 DartAssistKind.CONVERT_INTO_BLOCK_BODY, 853 DartAssistKind.CONVERT_INTO_BLOCK_BODY,
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 966
949 void test_convertToBlockBody_wrong_notExpressionBlock() { 967 void test_convertToBlockBody_wrong_notExpressionBlock() {
950 resolveTestUnit(''' 968 resolveTestUnit('''
951 fff() { 969 fff() {
952 return 123; 970 return 123;
953 } 971 }
954 '''); 972 ''');
955 assertNoAssistAt('fff() {', DartAssistKind.CONVERT_INTO_BLOCK_BODY); 973 assertNoAssistAt('fff() {', DartAssistKind.CONVERT_INTO_BLOCK_BODY);
956 } 974 }
957 975
976 void test_convertToExpressionBody_OK_async() {
977 resolveTestUnit('''
978 class A {
979 mmm() async {
980 return 42;
981 }
982 }
983 ''');
984 assertHasAssistAt(
985 'mmm',
986 DartAssistKind.CONVERT_INTO_EXPRESSION_BODY,
987 '''
988 class A {
989 mmm() async => 42;
990 }
991 ''');
992 }
993
958 void test_convertToExpressionBody_OK_closure() { 994 void test_convertToExpressionBody_OK_closure() {
959 resolveTestUnit(''' 995 resolveTestUnit('''
960 setup(x) {} 996 setup(x) {}
961 main() { 997 main() {
962 setup(() { 998 setup(() {
963 return 42; 999 return 42;
964 }); 1000 });
965 } 1001 }
966 '''); 1002 ''');
967 assertHasAssistAt( 1003 assertHasAssistAt(
(...skipping 2673 matching lines...) Expand 10 before | Expand all | Expand 10 after
3641 positions.add(new Position(testFile, offset)); 3677 positions.add(new Position(testFile, offset));
3642 } 3678 }
3643 return positions; 3679 return positions;
3644 } 3680 }
3645 3681
3646 void _setStartEndSelection() { 3682 void _setStartEndSelection() {
3647 offset = findOffset('// start\n') + '// start\n'.length; 3683 offset = findOffset('// start\n') + '// start\n'.length;
3648 length = findOffset('// end') - offset; 3684 length = findOffset('// end') - offset;
3649 } 3685 }
3650 } 3686 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698