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

Side by Side Diff: pkg/analysis_server/test/completion_test.dart

Issue 902983002: use propogated type for completions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge 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
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.completion.support; 5 library test.completion.support;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 287
288 // Type propagation. 288 // Type propagation.
289 buildTests('testCommentSnippets051', ''' 289 buildTests('testCommentSnippets051', '''
290 class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{ge tKeys(){}} 290 class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{ge tKeys(){}}
291 void r() { 291 void r() {
292 var v; 292 var v;
293 if (v is String) { 293 if (v is String) {
294 v.!1length; 294 v.!1length;
295 v.!2getKeys; 295 v.!2getKeys;
296 } 296 }
297 }''', <String>["1+length", "2-getKeys"], failingTests: '1'); 297 }''', <String>["1+length", "2-getKeys"]);
298 298
299 // Type propagation. 299 // Type propagation.
300 buildTests('testCommentSnippets052', ''' 300 buildTests('testCommentSnippets052', '''
301 class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{ge tKeys(){}} 301 class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{ge tKeys(){}}
302 void r() { 302 void r() {
303 List<String> values = ['a','b','c']; 303 List<String> values = ['a','b','c'];
304 for (var v in values) { 304 for (var v in values) {
305 v.!1toUpperCase; 305 v.!1toUpperCase;
306 v.!2getKeys; 306 v.!2getKeys;
307 } 307 }
308 }''', <String>["1+toUpperCase", "2-getKeys"], failingTests: '1'); 308 }''', <String>["1+toUpperCase", "2-getKeys"]);
309 309
310 // Type propagation. 310 // Type propagation.
311 buildTests('testCommentSnippets053', ''' 311 buildTests('testCommentSnippets053', '''
312 class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{ge tKeys(){}} 312 class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{ge tKeys(){}}
313 void r() { 313 void r() {
314 var v; 314 var v;
315 while (v is String) { 315 while (v is String) {
316 v.!1toUpperCase; 316 v.!1toUpperCase;
317 v.!2getKeys; 317 v.!2getKeys;
318 } 318 }
319 }''', <String>["1+toUpperCase", "2-getKeys"], failingTests: '1'); 319 }''', <String>["1+toUpperCase", "2-getKeys"]);
320 320
321 buildTests('testCommentSnippets054', ''' 321 buildTests('testCommentSnippets054', '''
322 class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{ge tKeys(){}} 322 class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{ge tKeys(){}}
323 void r() { 323 void r() {
324 var v; 324 var v;
325 for (; v is String; v.!1isEmpty) { 325 for (; v is String; v.!1isEmpty) {
326 v.!2toUpperCase; 326 v.!2toUpperCase;
327 v.!3getKeys; 327 v.!3getKeys;
328 } 328 }
329 }''', <String>["1+isEmpty", "2+toUpperCase", "3-getKeys"], failingTests: '12'); 329 }''', <String>["1+isEmpty", "2+toUpperCase", "3-getKeys"]);
330 330
331 buildTests('testCommentSnippets055', ''' 331 buildTests('testCommentSnippets055', '''
332 class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{ge tKeys(){}} 332 class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{ge tKeys(){}}
333 void r() { 333 void r() {
334 String v; 334 String v;
335 if (v is Object) { 335 if (v is Object) {
336 v.!1toUpperCase; 336 v.!1toUpperCase;
337 } 337 }
338 }''', <String>["1+toUpperCase"]); 338 }''', <String>["1+toUpperCase"]);
339 339
340 // Type propagation. 340 // Type propagation.
341 buildTests('testCommentSnippets056', ''' 341 buildTests('testCommentSnippets056', '''
342 class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{ge tKeys(){}} 342 class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{ge tKeys(){}}
343 void f(var v) { 343 void f(var v) {
344 if (v is!! String) { 344 if (v is!! String) {
345 return; 345 return;
346 } 346 }
347 v.!1toUpperCase; 347 v.!1toUpperCase;
348 }''', <String>["1+toUpperCase"], failingTests: '1'); 348 }''', <String>["1+toUpperCase"]);
349 349
350 // Type propagation. 350 // Type propagation.
351 buildTests('testCommentSnippets057', ''' 351 buildTests('testCommentSnippets057', '''
352 class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{ge tKeys(){}} 352 class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{ge tKeys(){}}
353 void f(var v) { 353 void f(var v) {
354 if ((v as String).length == 0) { 354 if ((v as String).!2length == 0) {
355 v.!1toUpperCase; 355 v.!1toUpperCase;
356 } 356 }
357 }''', <String>["1+toUpperCase"], failingTests: '1'); 357 }''', <String>["1+toUpperCase", "2+length"]);
358 358
359 buildTests('testCommentSnippets058', ''' 359 buildTests('testCommentSnippets058', '''
360 typedef vo!2id callback(int k); 360 typedef vo!2id callback(int k);
361 void x(callback q){} 361 void x(callback q){}
362 void r() { 362 void r() {
363 callback v; 363 callback v;
364 x(!1); 364 x(!1);
365 }''', <String>["1+v", "2+void"], failingTests: '2'); 365 }''', <String>["1+v", "2+void"], failingTests: '2');
366 366
367 buildTests('testCommentSnippets059', ''' 367 buildTests('testCommentSnippets059', '''
(...skipping 13 matching lines...) Expand all
381 class A{m(){!1f(3);!2}}n(){!3f(3);!4}f(x)=>x*3;''', 381 class A{m(){!1f(3);!2}}n(){!3f(3);!4}f(x)=>x*3;''',
382 <String>["1+f", "1+n", "2+f", "2+n", "3+f", "3+n", "4+f", "4+n"]); 382 <String>["1+f", "1+n", "2+f", "2+n", "3+f", "3+n", "4+f", "4+n"]);
383 383
384 // Type propagation. 384 // Type propagation.
385 buildTests('testCommentSnippets063', ''' 385 buildTests('testCommentSnippets063', '''
386 class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{ge tKeys(){}} 386 class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{ge tKeys(){}}
387 void r(var v) { 387 void r(var v) {
388 v.!1toUpperCase; 388 v.!1toUpperCase;
389 assert(v is String); 389 assert(v is String);
390 v.!2toUpperCase; 390 v.!2toUpperCase;
391 }''', <String>["1-toUpperCase", "2+toUpperCase"], failingTests: '2'); 391 }''', <String>["1-toUpperCase", "2+toUpperCase"]);
392 392
393 buildTests('testCommentSnippets064', ''' 393 buildTests('testCommentSnippets064', '''
394 class Spline { 394 class Spline {
395 Line c; 395 Line c;
396 Spline a() { 396 Spline a() {
397 return this; 397 return this;
398 } 398 }
399 Line b() { 399 Line b() {
400 return null; 400 return null;
401 } 401 }
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 "5+fqe", 749 "5+fqe",
750 "5+fqi", 750 "5+fqi",
751 "5+Q", 751 "5+Q",
752 "5-xya", 752 "5-xya",
753 "5-xyb", 753 "5-xyb",
754 "5-xza"], 754 "5-xza"],
755 failingTests: '123'); 755 failingTests: '123');
756 756
757 buildTests('testCommentSnippets090', ''' 757 buildTests('testCommentSnippets090', '''
758 class X { f() { var a = 'x'; a.!1 }}''', 758 class X { f() { var a = 'x'; a.!1 }}''',
759 <String>["1+length"], 759 <String>["1+length"]);
760 failingTests: '1');
761 } 760 }
762 761
763 void buildCompletionTests() { 762 void buildCompletionTests() {
764 buildTests('testCompletion_alias_field', ''' 763 buildTests('testCompletion_alias_field', '''
765 typedef int fnint(int k); fn!1int x;''', <String>["1+fnint"]); 764 typedef int fnint(int k); fn!1int x;''', <String>["1+fnint"]);
766 765
767 buildTests('testCompletion_annotation_argumentList', ''' 766 buildTests('testCompletion_annotation_argumentList', '''
768 class AAA {", 767 class AAA {",
769 const AAA({int aaa, int bbb});", 768 const AAA({int aaa, int bbb});",
770 }", 769 }",
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after
2239 test() { 2238 test() {
2240 topvar.!1top(); 2239 topvar.!1top();
2241 field.!2top(); 2240 field.!2top();
2242 } 2241 }
2243 }''', <String>["1+top", "2+top"], failingTests: '12'); 2242 }''', <String>["1+top", "2+top"], failingTests: '12');
2244 2243
2245 // test analysis of untyped fields and top-level vars 2244 // test analysis of untyped fields and top-level vars
2246 buildTests( 2245 buildTests(
2247 'test035', 2246 'test035',
2248 '''class Y {final x='hi';mth() {x.!1length;}}''', 2247 '''class Y {final x='hi';mth() {x.!1length;}}''',
2249 <String>["1+length"], 2248 <String>["1+length"]);
2250 failingTests: '1');
2251 2249
2252 // TODO(scheglov) decide what to do with Type for untyped field (not 2250 // TODO(scheglov) decide what to do with Type for untyped field (not
2253 // supported by the new store) 2251 // supported by the new store)
2254 // test analysis of untyped fields and top-level vars 2252 // test analysis of untyped fields and top-level vars
2255 buildTests('test036', ''' 2253 buildTests('test036', '''
2256 class A1 { 2254 class A1 {
2257 var field; 2255 var field;
2258 A1() : field = 0; 2256 A1() : field = 0;
2259 q() { 2257 q() {
2260 A1 a = new A1(); 2258 A1 a = new A1();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
2387 } else { 2385 } else {
2388 ++expectedPassCount; 2386 ++expectedPassCount;
2389 tester(testName, () { 2387 tester(testName, () {
2390 CompletionTestCase test = new CompletionTestCase(); 2388 CompletionTestCase test = new CompletionTestCase();
2391 return test.runTest(spec, extraFiles); 2389 return test.runTest(spec, extraFiles);
2392 }); 2390 });
2393 } 2391 }
2394 } 2392 }
2395 } 2393 }
2396 } 2394 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698