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

Side by Side Diff: pkg/analysis_server/test/services/completion/postfix/postfix_completion_test.dart

Issue 2975253002: Format analyzer, analysis_server, analyzer_plugin, front_end and kernel with the latest dartfmt. (Closed)
Patch Set: Created 3 years, 5 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'package:analysis_server/src/protocol_server.dart'; 5 import 'package:analysis_server/src/protocol_server.dart';
6 import 'package:analysis_server/src/services/completion/postfix/postfix_completi on.dart'; 6 import 'package:analysis_server/src/services/completion/postfix/postfix_completi on.dart';
7 import 'package:analyzer/src/dart/analysis/driver.dart'; 7 import 'package:analyzer/src/dart/analysis/driver.dart';
8 import 'package:test/test.dart'; 8 import 'package:test/test.dart';
9 import 'package:test_reflective_loader/test_reflective_loader.dart'; 9 import 'package:test_reflective_loader/test_reflective_loader.dart';
10 10
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 _prepareCompletionAt(int offset, String key, String sourceCode) async { 81 _prepareCompletionAt(int offset, String key, String sourceCode) async {
82 verifyNoTestUnitErrors = false; 82 verifyNoTestUnitErrors = false;
83 await resolveTestUnit(sourceCode); 83 await resolveTestUnit(sourceCode);
84 await _computeCompletion(offset, key); 84 await _computeCompletion(offset, key);
85 } 85 }
86 } 86 }
87 87
88 @reflectiveTest 88 @reflectiveTest
89 class _AssertTest extends PostfixCompletionTest { 89 class _AssertTest extends PostfixCompletionTest {
90 test_assert() async { 90 test_assert() async {
91 await _prepareCompletion( 91 await _prepareCompletion('.assert', '''
92 '.assert',
93 '''
94 f(bool expr) { 92 f(bool expr) {
95 expr.assert 93 expr.assert
96 } 94 }
97 '''); 95 ''');
98 _assertHasChange( 96 _assertHasChange('Expand .assert', '''
99 'Expand .assert',
100 '''
101 f(bool expr) { 97 f(bool expr) {
102 assert(expr); 98 assert(expr);
103 } 99 }
104 '''); 100 ''');
105 } 101 }
106 102
107 test_assertFunc() async { 103 test_assertFunc() async {
108 await _prepareCompletion( 104 await _prepareCompletion('.assert', '''
109 '.assert',
110 '''
111 f() { 105 f() {
112 () => true.assert 106 () => true.assert
113 } 107 }
114 '''); 108 ''');
115 _assertHasChange( 109 _assertHasChange('Expand .assert', '''
116 'Expand .assert',
117 '''
118 f() { 110 f() {
119 assert(() => true); 111 assert(() => true);
120 } 112 }
121 '''); 113 ''');
122 } 114 }
123 115
124 @failingTest 116 @failingTest
125 test_assertFunc_invalid() async { 117 test_assertFunc_invalid() async {
126 await _prepareCompletion( 118 await _prepareCompletion('.assert', '''
127 '.assert',
128 '''
129 f() { 119 f() {
130 () => null.assert 120 () => null.assert
131 } 121 }
132 '''); 122 ''');
133 } 123 }
134 124
135 test_assertFuncCmp() async { 125 test_assertFuncCmp() async {
136 await _prepareCompletion( 126 await _prepareCompletion('.assert', '''
137 '.assert',
138 '''
139 f(int x, int y) { 127 f(int x, int y) {
140 () => x + 3 > y + 4.assert 128 () => x + 3 > y + 4.assert
141 } 129 }
142 '''); 130 ''');
143 _assertHasChange( 131 _assertHasChange('Expand .assert', '''
144 'Expand .assert',
145 '''
146 f(int x, int y) { 132 f(int x, int y) {
147 assert(() => x + 3 > y + 4); 133 assert(() => x + 3 > y + 4);
148 } 134 }
149 '''); 135 ''');
150 } 136 }
151 } 137 }
152 138
153 @reflectiveTest 139 @reflectiveTest
154 class _ForTest extends PostfixCompletionTest { 140 class _ForTest extends PostfixCompletionTest {
155 @failingTest 141 @failingTest
156 test_for_invalid() async { 142 test_for_invalid() async {
157 await _prepareCompletion( 143 await _prepareCompletion('.for', '''
158 '.for',
159 '''
160 f() { 144 f() {
161 {}.for 145 {}.for
162 } 146 }
163 '''); 147 ''');
164 } 148 }
165 149
166 test_forEmptyDynamic() async { 150 test_forEmptyDynamic() async {
167 await _prepareCompletion( 151 await _prepareCompletion('.for', '''
168 '.for',
169 '''
170 f() { 152 f() {
171 [].for 153 [].for
172 } 154 }
173 '''); 155 ''');
174 _assertHasChange( 156 _assertHasChange('Expand .for', '''
175 'Expand .for',
176 '''
177 f() { 157 f() {
178 for (var value in []) { 158 for (var value in []) {
179 /*caret*/ 159 /*caret*/
180 } 160 }
181 } 161 }
182 '''); 162 ''');
183 } 163 }
184 164
185 test_forEmptyString() async { 165 test_forEmptyString() async {
186 await _prepareCompletion( 166 await _prepareCompletion('.for', '''
187 '.for',
188 '''
189 f() { 167 f() {
190 <String>[].for 168 <String>[].for
191 } 169 }
192 '''); 170 ''');
193 _assertHasChange( 171 _assertHasChange('Expand .for', '''
194 'Expand .for',
195 '''
196 f() { 172 f() {
197 for (var value in <String>[]) { 173 for (var value in <String>[]) {
198 /*caret*/ 174 /*caret*/
199 } 175 }
200 } 176 }
201 '''); 177 ''');
202 } 178 }
203 179
204 test_fori() async { 180 test_fori() async {
205 await _prepareCompletion( 181 await _prepareCompletion('.fori', '''
206 '.fori',
207 '''
208 f() { 182 f() {
209 100.fori 183 100.fori
210 } 184 }
211 '''); 185 ''');
212 _assertHasChange( 186 _assertHasChange('Expand .fori', '''
213 'Expand .fori',
214 '''
215 f() { 187 f() {
216 for (int i = 0; i < 100; i++) { 188 for (int i = 0; i < 100; i++) {
217 /*caret*/ 189 /*caret*/
218 } 190 }
219 } 191 }
220 '''); 192 ''');
221 } 193 }
222 194
223 @failingTest 195 @failingTest
224 test_fori_invalid() async { 196 test_fori_invalid() async {
225 await _prepareCompletion( 197 await _prepareCompletion('.fori', '''
226 '.fori',
227 '''
228 f() { 198 f() {
229 [].fori 199 [].fori
230 } 200 }
231 '''); 201 ''');
232 } 202 }
233 203
234 test_forIntList() async { 204 test_forIntList() async {
235 await _prepareCompletion( 205 await _prepareCompletion('.for', '''
236 '.for',
237 '''
238 f() { 206 f() {
239 [1,2,3].for 207 [1,2,3].for
240 } 208 }
241 '''); 209 ''');
242 _assertHasChange( 210 _assertHasChange('Expand .for', '''
243 'Expand .for',
244 '''
245 f() { 211 f() {
246 for (var value in [1,2,3]) { 212 for (var value in [1,2,3]) {
247 /*caret*/ 213 /*caret*/
248 } 214 }
249 } 215 }
250 '''); 216 ''');
251 } 217 }
252 218
253 test_foriVar() async { 219 test_foriVar() async {
254 await _prepareCompletion( 220 await _prepareCompletion('.fori', '''
255 '.fori',
256 '''
257 f() { 221 f() {
258 var n = 100; 222 var n = 100;
259 n.fori 223 n.fori
260 } 224 }
261 '''); 225 ''');
262 _assertHasChange( 226 _assertHasChange('Expand .fori', '''
263 'Expand .fori',
264 '''
265 f() { 227 f() {
266 var n = 100; 228 var n = 100;
267 for (int i = 0; i < n; i++) { 229 for (int i = 0; i < n; i++) {
268 /*caret*/ 230 /*caret*/
269 } 231 }
270 } 232 }
271 '''); 233 ''');
272 } 234 }
273 235
274 test_iterList() async { 236 test_iterList() async {
275 await _prepareCompletion( 237 await _prepareCompletion('.iter', '''
276 '.iter',
277 '''
278 f() { 238 f() {
279 [1,2,3].iter 239 [1,2,3].iter
280 } 240 }
281 '''); 241 ''');
282 _assertHasChange( 242 _assertHasChange('Expand .iter', '''
283 'Expand .iter',
284 '''
285 f() { 243 f() {
286 for (var value in [1,2,3]) { 244 for (var value in [1,2,3]) {
287 /*caret*/ 245 /*caret*/
288 } 246 }
289 } 247 }
290 '''); 248 ''');
291 } 249 }
292 250
293 test_iterName() async { 251 test_iterName() async {
294 await _prepareCompletion( 252 await _prepareCompletion('.iter', '''
295 '.iter',
296 '''
297 f() { 253 f() {
298 var value = [1,2,3]; 254 var value = [1,2,3];
299 value.iter 255 value.iter
300 } 256 }
301 '''); 257 ''');
302 _assertHasChange( 258 _assertHasChange('Expand .iter', '''
303 'Expand .iter',
304 '''
305 f() { 259 f() {
306 var value = [1,2,3]; 260 var value = [1,2,3];
307 for (var value1 in value) { 261 for (var value1 in value) {
308 /*caret*/ 262 /*caret*/
309 } 263 }
310 } 264 }
311 '''); 265 ''');
312 } 266 }
313 } 267 }
314 268
315 @reflectiveTest 269 @reflectiveTest
316 class _IfTest extends PostfixCompletionTest { 270 class _IfTest extends PostfixCompletionTest {
317 test_Else() async { 271 test_Else() async {
318 await _prepareCompletion( 272 await _prepareCompletion('.else', '''
319 '.else',
320 '''
321 f(bool val) { 273 f(bool val) {
322 val.else 274 val.else
323 } 275 }
324 '''); 276 ''');
325 _assertHasChange( 277 _assertHasChange('Expand .else', '''
326 'Expand .else',
327 '''
328 f(bool val) { 278 f(bool val) {
329 if (!val) { 279 if (!val) {
330 /*caret*/ 280 /*caret*/
331 } 281 }
332 } 282 }
333 '''); 283 ''');
334 } 284 }
335 285
336 test_if() async { 286 test_if() async {
337 await _prepareCompletion( 287 await _prepareCompletion('.if', '''
338 '.if',
339 '''
340 f() { 288 f() {
341 3 < 4.if 289 3 < 4.if
342 } 290 }
343 '''); 291 ''');
344 _assertHasChange( 292 _assertHasChange('Expand .if', '''
345 'Expand .if',
346 '''
347 f() { 293 f() {
348 if (3 < 4) { 294 if (3 < 4) {
349 /*caret*/ 295 /*caret*/
350 } 296 }
351 } 297 }
352 '''); 298 ''');
353 } 299 }
354 300
355 @failingTest 301 @failingTest
356 test_if_invalid() async { 302 test_if_invalid() async {
357 await _prepareCompletion( 303 await _prepareCompletion('.if', '''
358 '.if',
359 '''
360 f(List expr) { 304 f(List expr) {
361 expr.if 305 expr.if
362 } 306 }
363 '''); 307 ''');
364 } 308 }
365 309
366 test_ifDynamic() async { 310 test_ifDynamic() async {
367 await _prepareCompletion( 311 await _prepareCompletion('.if', '''
368 '.if',
369 '''
370 f(expr) { 312 f(expr) {
371 expr.if 313 expr.if
372 } 314 }
373 '''); 315 ''');
374 _assertHasChange( 316 _assertHasChange('Expand .if', '''
375 'Expand .if',
376 '''
377 f(expr) { 317 f(expr) {
378 if (expr) { 318 if (expr) {
379 /*caret*/ 319 /*caret*/
380 } 320 }
381 } 321 }
382 '''); 322 ''');
383 } 323 }
384 } 324 }
385 325
386 @reflectiveTest 326 @reflectiveTest
387 class _NegateTest extends PostfixCompletionTest { 327 class _NegateTest extends PostfixCompletionTest {
388 test_negate() async { 328 test_negate() async {
389 await _prepareCompletion( 329 await _prepareCompletion('.not', '''
390 '.not',
391 '''
392 f(expr) { 330 f(expr) {
393 if (expr.not) 331 if (expr.not)
394 } 332 }
395 '''); 333 ''');
396 _assertHasChange( 334 _assertHasChange('Expand .not', '''
397 'Expand .not',
398 '''
399 f(expr) { 335 f(expr) {
400 if (!expr) 336 if (!expr)
401 } 337 }
402 '''); 338 ''');
403 } 339 }
404 340
405 @failingTest 341 @failingTest
406 test_negate_invalid() async { 342 test_negate_invalid() async {
407 await _prepareCompletion( 343 await _prepareCompletion('.not', '''
408 '.not',
409 '''
410 f(int expr) { 344 f(int expr) {
411 if (expr.not) 345 if (expr.not)
412 } 346 }
413 '''); 347 ''');
414 } 348 }
415 349
416 test_negateCascade() async { 350 test_negateCascade() async {
417 await _prepareCompletion( 351 await _prepareCompletion('.not', '''
418 '.not',
419 '''
420 f(expr) { 352 f(expr) {
421 if (expr..a..b..c.not) 353 if (expr..a..b..c.not)
422 } 354 }
423 '''); 355 ''');
424 _assertHasChange( 356 _assertHasChange('Expand .not', '''
425 'Expand .not',
426 '''
427 f(expr) { 357 f(expr) {
428 if (!expr..a..b..c) 358 if (!expr..a..b..c)
429 } 359 }
430 '''); 360 ''');
431 } 361 }
432 362
433 test_negateExpr() async { 363 test_negateExpr() async {
434 await _prepareCompletion( 364 await _prepareCompletion('.not', '''
435 '.not',
436 '''
437 f(int i, int j) { 365 f(int i, int j) {
438 if (i + 3 < j - 4.not) 366 if (i + 3 < j - 4.not)
439 } 367 }
440 '''); 368 ''');
441 _assertHasChange( 369 _assertHasChange('Expand .not', '''
442 'Expand .not',
443 '''
444 f(int i, int j) { 370 f(int i, int j) {
445 if (i + 3 >= j - 4) 371 if (i + 3 >= j - 4)
446 } 372 }
447 '''); 373 ''');
448 } 374 }
449 375
450 test_negateProperty() async { 376 test_negateProperty() async {
451 await _prepareCompletion( 377 await _prepareCompletion('.not', '''
452 '.not',
453 '''
454 f(expr) { 378 f(expr) {
455 if (expr.a.b.c.not) 379 if (expr.a.b.c.not)
456 } 380 }
457 '''); 381 ''');
458 _assertHasChange( 382 _assertHasChange('Expand .not', '''
459 'Expand .not',
460 '''
461 f(expr) { 383 f(expr) {
462 if (!expr.a.b.c) 384 if (!expr.a.b.c)
463 } 385 }
464 '''); 386 ''');
465 } 387 }
466 388
467 test_notFalse() async { 389 test_notFalse() async {
468 await _prepareCompletion( 390 await _prepareCompletion('!', '''
469 '!',
470 '''
471 f() { 391 f() {
472 if (false!) 392 if (false!)
473 } 393 }
474 '''); 394 ''');
475 _assertHasChange( 395 _assertHasChange('Expand !', '''
476 'Expand !',
477 '''
478 f() { 396 f() {
479 if (true) 397 if (true)
480 } 398 }
481 '''); 399 ''');
482 } 400 }
483 401
484 test_notFunc() async { 402 test_notFunc() async {
485 await _prepareCompletion( 403 await _prepareCompletion('.not', '''
486 '.not',
487 '''
488 bool f() { 404 bool f() {
489 if (f().not) 405 if (f().not)
490 } 406 }
491 '''); 407 ''');
492 _assertHasChange( 408 _assertHasChange('Expand .not', '''
493 'Expand .not',
494 '''
495 bool f() { 409 bool f() {
496 if (!f()) 410 if (!f())
497 } 411 }
498 '''); 412 ''');
499 } 413 }
500 414
501 test_notTrue() async { 415 test_notTrue() async {
502 await _prepareCompletion( 416 await _prepareCompletion('.not', '''
503 '.not',
504 '''
505 f() { 417 f() {
506 if (true.not) 418 if (true.not)
507 } 419 }
508 '''); 420 ''');
509 _assertHasChange( 421 _assertHasChange('Expand .not', '''
510 'Expand .not',
511 '''
512 f() { 422 f() {
513 if (false) 423 if (false)
514 } 424 }
515 '''); 425 ''');
516 } 426 }
517 } 427 }
518 428
519 @reflectiveTest 429 @reflectiveTest
520 class _NotNullTest extends PostfixCompletionTest { 430 class _NotNullTest extends PostfixCompletionTest {
521 test_nn() async { 431 test_nn() async {
522 await _prepareCompletion( 432 await _prepareCompletion('.nn', '''
523 '.nn',
524 '''
525 f(expr) { 433 f(expr) {
526 var list = [1,2,3]; 434 var list = [1,2,3];
527 list.nn 435 list.nn
528 } 436 }
529 '''); 437 ''');
530 _assertHasChange( 438 _assertHasChange('Expand .nn', '''
531 'Expand .nn',
532 '''
533 f(expr) { 439 f(expr) {
534 var list = [1,2,3]; 440 var list = [1,2,3];
535 if (list != null) { 441 if (list != null) {
536 /*caret*/ 442 /*caret*/
537 } 443 }
538 } 444 }
539 '''); 445 ''');
540 } 446 }
541 447
542 @failingTest 448 @failingTest
543 test_nn_invalid() async { 449 test_nn_invalid() async {
544 await _prepareCompletion( 450 await _prepareCompletion('.nn', '''
545 '.nn',
546 '''
547 f(expr) { 451 f(expr) {
548 var list = [1,2,3]; 452 var list = [1,2,3];
549 }.nn 453 }.nn
550 '''); 454 ''');
551 } 455 }
552 456
553 test_nnDynamic() async { 457 test_nnDynamic() async {
554 await _prepareCompletion( 458 await _prepareCompletion('.nn', '''
555 '.nn',
556 '''
557 f(expr) { 459 f(expr) {
558 expr.nn 460 expr.nn
559 } 461 }
560 '''); 462 ''');
561 _assertHasChange( 463 _assertHasChange('Expand .nn', '''
562 'Expand .nn',
563 '''
564 f(expr) { 464 f(expr) {
565 if (expr != null) { 465 if (expr != null) {
566 /*caret*/ 466 /*caret*/
567 } 467 }
568 } 468 }
569 '''); 469 ''');
570 } 470 }
571 471
572 test_notnull() async { 472 test_notnull() async {
573 await _prepareCompletion( 473 await _prepareCompletion('.notnull', '''
574 '.notnull',
575 '''
576 f(expr) { 474 f(expr) {
577 var list = [1,2,3]; 475 var list = [1,2,3];
578 list.notnull 476 list.notnull
579 } 477 }
580 '''); 478 ''');
581 _assertHasChange( 479 _assertHasChange('Expand .notnull', '''
582 'Expand .notnull',
583 '''
584 f(expr) { 480 f(expr) {
585 var list = [1,2,3]; 481 var list = [1,2,3];
586 if (list != null) { 482 if (list != null) {
587 /*caret*/ 483 /*caret*/
588 } 484 }
589 } 485 }
590 '''); 486 ''');
591 } 487 }
592 488
593 test_null() async { 489 test_null() async {
594 await _prepareCompletion( 490 await _prepareCompletion('.null', '''
595 '.null',
596 '''
597 f(expr) { 491 f(expr) {
598 var list = [1,2,3]; 492 var list = [1,2,3];
599 list.null 493 list.null
600 } 494 }
601 '''); 495 ''');
602 _assertHasChange( 496 _assertHasChange('Expand .null', '''
603 'Expand .null',
604 '''
605 f(expr) { 497 f(expr) {
606 var list = [1,2,3]; 498 var list = [1,2,3];
607 if (list == null) { 499 if (list == null) {
608 /*caret*/ 500 /*caret*/
609 } 501 }
610 } 502 }
611 '''); 503 ''');
612 } 504 }
613 505
614 test_nullnn() async { 506 test_nullnn() async {
615 await _prepareCompletion( 507 await _prepareCompletion('.nn', '''
616 '.nn',
617 '''
618 f() { 508 f() {
619 null.nn 509 null.nn
620 } 510 }
621 '''); 511 ''');
622 _assertHasChange( 512 _assertHasChange('Expand .nn', '''
623 'Expand .nn',
624 '''
625 f() { 513 f() {
626 if (false) { 514 if (false) {
627 /*caret*/ 515 /*caret*/
628 } 516 }
629 } 517 }
630 '''); 518 ''');
631 } 519 }
632 520
633 test_nullnull() async { 521 test_nullnull() async {
634 await _prepareCompletion( 522 await _prepareCompletion('.null', '''
635 '.null',
636 '''
637 f() { 523 f() {
638 null.null 524 null.null
639 } 525 }
640 '''); 526 ''');
641 _assertHasChange( 527 _assertHasChange('Expand .null', '''
642 'Expand .null',
643 '''
644 f() { 528 f() {
645 if (true) { 529 if (true) {
646 /*caret*/ 530 /*caret*/
647 } 531 }
648 } 532 }
649 '''); 533 ''');
650 } 534 }
651 } 535 }
652 536
653 @reflectiveTest 537 @reflectiveTest
654 class _ParenTest extends PostfixCompletionTest { 538 class _ParenTest extends PostfixCompletionTest {
655 test_paren() async { 539 test_paren() async {
656 await _prepareCompletion( 540 await _prepareCompletion('.par', '''
657 '.par',
658 '''
659 f(expr) { 541 f(expr) {
660 expr.par 542 expr.par
661 } 543 }
662 '''); 544 ''');
663 _assertHasChange( 545 _assertHasChange('Expand .par', '''
664 'Expand .par',
665 '''
666 f(expr) { 546 f(expr) {
667 (expr) 547 (expr)
668 } 548 }
669 '''); 549 ''');
670 } 550 }
671 } 551 }
672 552
673 @reflectiveTest 553 @reflectiveTest
674 class _ReturnTest extends PostfixCompletionTest { 554 class _ReturnTest extends PostfixCompletionTest {
675 test_return() async { 555 test_return() async {
676 await _prepareCompletion( 556 await _prepareCompletion('.return', '''
677 '.return',
678 '''
679 f(expr) { 557 f(expr) {
680 expr.return 558 expr.return
681 } 559 }
682 '''); 560 ''');
683 _assertHasChange( 561 _assertHasChange('Expand .return', '''
684 'Expand .return',
685 '''
686 f(expr) { 562 f(expr) {
687 return expr; 563 return expr;
688 } 564 }
689 '''); 565 ''');
690 } 566 }
691 } 567 }
692 568
693 @reflectiveTest 569 @reflectiveTest
694 class _SwitchTest extends PostfixCompletionTest { 570 class _SwitchTest extends PostfixCompletionTest {
695 test_return() async { 571 test_return() async {
696 await _prepareCompletion( 572 await _prepareCompletion('.switch', '''
697 '.switch',
698 '''
699 f(expr) { 573 f(expr) {
700 expr.switch 574 expr.switch
701 } 575 }
702 '''); 576 ''');
703 _assertHasChange( 577 _assertHasChange('Expand .switch', '''
704 'Expand .switch',
705 '''
706 f(expr) { 578 f(expr) {
707 switch (expr) { 579 switch (expr) {
708 /*caret*/ 580 /*caret*/
709 } 581 }
710 } 582 }
711 '''); 583 ''');
712 } 584 }
713 } 585 }
714 586
715 @reflectiveTest 587 @reflectiveTest
716 class _TryTest extends PostfixCompletionTest { 588 class _TryTest extends PostfixCompletionTest {
717 test_try() async { 589 test_try() async {
718 await _prepareCompletion( 590 await _prepareCompletion('.try', '''
719 '.try',
720 '''
721 f() { 591 f() {
722 var x = 1.try 592 var x = 1.try
723 } 593 }
724 '''); 594 ''');
725 _assertHasChange( 595 _assertHasChange('Expand .try', '''
726 'Expand .try',
727 '''
728 f() { 596 f() {
729 try { 597 try {
730 var x = 1/*caret*/ 598 var x = 1/*caret*/
731 } catch (e, s) { 599 } catch (e, s) {
732 print(s); 600 print(s);
733 } 601 }
734 } 602 }
735 '''); 603 ''');
736 } 604 }
737 605
738 @failingTest 606 @failingTest
739 test_try_invalid() async { 607 test_try_invalid() async {
740 // The semicolon is fine; this fails because of the do-statement. 608 // The semicolon is fine; this fails because of the do-statement.
741 await _prepareCompletion( 609 await _prepareCompletion('.try', '''
742 '.try',
743 '''
744 f() { 610 f() {
745 do {} while (true);.try 611 do {} while (true);.try
746 } 612 }
747 '''); 613 ''');
748 } 614 }
749 615
750 test_tryMultiline() async { 616 test_tryMultiline() async {
751 await _prepareCompletion( 617 await _prepareCompletion('.try', '''
752 '.try',
753 '''
754 f(arg) { 618 f(arg) {
755 arg 619 arg
756 ..first 620 ..first
757 ..second 621 ..second
758 ..third 622 ..third
759 ..fourth.try 623 ..fourth.try
760 } 624 }
761 '''); 625 ''');
762 _assertHasChange( 626 _assertHasChange('Expand .try', '''
763 'Expand .try',
764 '''
765 f(arg) { 627 f(arg) {
766 try { 628 try {
767 arg 629 arg
768 ..first 630 ..first
769 ..second 631 ..second
770 ..third 632 ..third
771 ..fourth/*caret*/ 633 ..fourth/*caret*/
772 } catch (e, s) { 634 } catch (e, s) {
773 print(s); 635 print(s);
774 } 636 }
775 } 637 }
776 '''); 638 ''');
777 } 639 }
778 640
779 test_tryon() async { 641 test_tryon() async {
780 await _prepareCompletion( 642 await _prepareCompletion('.tryon', '''
781 '.tryon',
782 '''
783 f() { 643 f() {
784 var x = 1.tryon 644 var x = 1.tryon
785 } 645 }
786 '''); 646 ''');
787 _assertHasChange( 647 _assertHasChange('Expand .tryon', '''
788 'Expand .tryon',
789 '''
790 f() { 648 f() {
791 try { 649 try {
792 var x = 1/*caret*/ 650 var x = 1/*caret*/
793 } on Exception catch (e, s) { 651 } on Exception catch (e, s) {
794 print(s); 652 print(s);
795 } 653 }
796 } 654 }
797 '''); 655 ''');
798 } 656 }
799 657
800 test_tryonThrowStatement() async { 658 test_tryonThrowStatement() async {
801 await _prepareCompletion( 659 await _prepareCompletion('.tryon', '''
802 '.tryon',
803 '''
804 f() { 660 f() {
805 throw 'error';.tryon 661 throw 'error';.tryon
806 } 662 }
807 '''); 663 ''');
808 _assertHasChange( 664 _assertHasChange('Expand .tryon', '''
809 'Expand .tryon',
810 '''
811 f() { 665 f() {
812 try { 666 try {
813 throw 'error';/*caret*/ 667 throw 'error';/*caret*/
814 } on String catch (e, s) { 668 } on String catch (e, s) {
815 print(s); 669 print(s);
816 } 670 }
817 } 671 }
818 '''); 672 ''');
819 } 673 }
820 674
821 test_tryonThrowString() async { 675 test_tryonThrowString() async {
822 await _prepareCompletion( 676 await _prepareCompletion('.tryon', '''
823 '.tryon',
824 '''
825 f() { 677 f() {
826 throw 'error'.tryon 678 throw 'error'.tryon
827 } 679 }
828 '''); 680 ''');
829 _assertHasChange( 681 _assertHasChange('Expand .tryon', '''
830 'Expand .tryon',
831 '''
832 f() { 682 f() {
833 try { 683 try {
834 throw 'error'/*caret*/ 684 throw 'error'/*caret*/
835 } on String catch (e, s) { 685 } on String catch (e, s) {
836 print(s); 686 print(s);
837 } 687 }
838 } 688 }
839 '''); 689 ''');
840 } 690 }
841 } 691 }
842 692
843 @reflectiveTest 693 @reflectiveTest
844 class _WhileTest extends PostfixCompletionTest { 694 class _WhileTest extends PostfixCompletionTest {
845 test_while() async { 695 test_while() async {
846 await _prepareCompletion( 696 await _prepareCompletion('.while', '''
847 '.while',
848 '''
849 f(expr) { 697 f(expr) {
850 expr.while 698 expr.while
851 } 699 }
852 '''); 700 ''');
853 _assertHasChange( 701 _assertHasChange('Expand .while', '''
854 'Expand .while',
855 '''
856 f(expr) { 702 f(expr) {
857 while (expr) { 703 while (expr) {
858 /*caret*/ 704 /*caret*/
859 } 705 }
860 } 706 }
861 '''); 707 ''');
862 } 708 }
863 } 709 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698