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

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

Issue 924783005: Improve code generation for 'bottom' and 'dynamic' arguments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/util.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.fix; 5 library test.services.correction.fix;
6 6
7 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; 7 import 'package:analysis_server/src/protocol.dart' hide AnalysisError;
8 import 'package:analysis_server/src/services/correction/fix.dart'; 8 import 'package:analysis_server/src/services/correction/fix.dart';
9 import 'package:analysis_server/src/services/index/index.dart'; 9 import 'package:analysis_server/src/services/index/index.dart';
10 import 'package:analysis_server/src/services/index/local_memory_index.dart'; 10 import 'package:analysis_server/src/services/index/local_memory_index.dart';
(...skipping 2164 matching lines...) Expand 10 before | Expand all | Expand 10 after
2175 } 2175 }
2176 '''); 2176 ''');
2177 assertHasFix(FixKind.CHANGE_TO, ''' 2177 assertHasFix(FixKind.CHANGE_TO, '''
2178 class MyClass {} 2178 class MyClass {}
2179 main() { 2179 main() {
2180 MyClass v = null; 2180 MyClass v = null;
2181 } 2181 }
2182 '''); 2182 ''');
2183 } 2183 }
2184 2184
2185 void test_undefinedFunction_create_dynamicArgument() {
2186 _indexTestUnit('''
2187 main() {
2188 dynamic v;
2189 test(v);
2190 }
2191 ''');
2192 assertHasFix(FixKind.CREATE_FUNCTION, '''
2193 main() {
2194 dynamic v;
2195 test(v);
2196 }
2197
2198 void test(v) {
2199 }
2200 ''');
2201 }
2202
2203 void test_undefinedFunction_create_dynamicReturnType() {
2204 _indexTestUnit('''
2205 main() {
2206 dynamic v = test();
2207 }
2208 ''');
2209 assertHasFix(FixKind.CREATE_FUNCTION, '''
2210 main() {
2211 dynamic v = test();
2212 }
2213
2214 test() {
2215 }
2216 ''');
2217 }
2218
2185 void test_undefinedFunction_create_fromFunction() { 2219 void test_undefinedFunction_create_fromFunction() {
2186 _indexTestUnit(''' 2220 _indexTestUnit('''
2187 main() { 2221 main() {
2188 int v = myUndefinedFunction(1, 2.0, '3'); 2222 int v = myUndefinedFunction(1, 2.0, '3');
2189 } 2223 }
2190 '''); 2224 ''');
2191 assertHasFix(FixKind.CREATE_FUNCTION, ''' 2225 assertHasFix(FixKind.CREATE_FUNCTION, '''
2192 main() { 2226 main() {
2193 int v = myUndefinedFunction(1, 2.0, '3'); 2227 int v = myUndefinedFunction(1, 2.0, '3');
2194 } 2228 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 main() { 2289 main() {
2256 process(items); 2290 process(items);
2257 } 2291 }
2258 } 2292 }
2259 2293
2260 void process(List<int> items) { 2294 void process(List<int> items) {
2261 } 2295 }
2262 '''); 2296 ''');
2263 } 2297 }
2264 2298
2299 void test_undefinedFunction_create_nullArgument() {
2300 _indexTestUnit('''
2301 main() {
2302 test(null);
2303 }
2304 ''');
2305 assertHasFix(FixKind.CREATE_FUNCTION, '''
2306 main() {
2307 test(null);
2308 }
2309
2310 void test(arg0) {
2311 }
2312 ''');
2313 }
2314
2265 void test_undefinedFunction_create_returnType_bool_expressions() { 2315 void test_undefinedFunction_create_returnType_bool_expressions() {
2266 assert_undefinedFunction_create_returnType_bool("!test();"); 2316 assert_undefinedFunction_create_returnType_bool("!test();");
2267 assert_undefinedFunction_create_returnType_bool("b && test();"); 2317 assert_undefinedFunction_create_returnType_bool("b && test();");
2268 assert_undefinedFunction_create_returnType_bool("test() && b;"); 2318 assert_undefinedFunction_create_returnType_bool("test() && b;");
2269 assert_undefinedFunction_create_returnType_bool("b || test();"); 2319 assert_undefinedFunction_create_returnType_bool("b || test();");
2270 assert_undefinedFunction_create_returnType_bool("test() || b;"); 2320 assert_undefinedFunction_create_returnType_bool("test() || b;");
2271 } 2321 }
2272 2322
2273 void test_undefinedFunction_create_returnType_bool_statements() { 2323 void test_undefinedFunction_create_returnType_bool_statements() {
2274 assert_undefinedFunction_create_returnType_bool("assert ( test() );"); 2324 assert_undefinedFunction_create_returnType_bool("assert ( test() );");
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
2871 positions.add(new Position(testFile, offset)); 2921 positions.add(new Position(testFile, offset));
2872 } 2922 }
2873 return positions; 2923 return positions;
2874 } 2924 }
2875 2925
2876 void _indexTestUnit(String code) { 2926 void _indexTestUnit(String code) {
2877 resolveTestUnit(code); 2927 resolveTestUnit(code);
2878 index.indexUnit(context, testUnit); 2928 index.indexUnit(context, testUnit);
2879 } 2929 }
2880 } 2930 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/util.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698