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

Side by Side Diff: pkg/analyzer/test/generated/hint_code_test.dart

Issue 2078493002: Don't flag improper @protected access in docs (#26713). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 analyzer.test.generated.hint_code_test; 5 library analyzer.test.generated.hint_code_test;
6 6
7 import 'package:analyzer/src/generated/engine.dart'; 7 import 'package:analyzer/src/generated/engine.dart';
8 import 'package:analyzer/src/generated/error.dart'; 8 import 'package:analyzer/src/generated/error.dart';
9 import 'package:analyzer/src/generated/source_io.dart'; 9 import 'package:analyzer/src/generated/source_io.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 class A {} 370 class A {}
371 class B extends A {} 371 class B extends A {}
372 f() { 372 f() {
373 try {} on A catch (e) {} on B catch (e) {if(false) {}} 373 try {} on A catch (e) {} on B catch (e) {if(false) {}}
374 }'''); 374 }''');
375 computeLibrarySourceErrors(source); 375 computeLibrarySourceErrors(source);
376 assertErrors(source, [HintCode.DEAD_CODE_ON_CATCH_SUBTYPE]); 376 assertErrors(source, [HintCode.DEAD_CODE_ON_CATCH_SUBTYPE]);
377 verify([source]); 377 verify([source]);
378 } 378 }
379 379
380 void test_deadCode_deadFinalReturnInCase() {
381 Source source = addSource(r'''
382 f() {
383 switch (true) {
384 case true:
385 try {
386 int a = 1;
387 } finally {
388 return;
389 }
390 return;
391 default:
392 break;
393 }
394 }''');
395 computeLibrarySourceErrors(source);
396 assertErrors(source, [HintCode.DEAD_CODE]);
397 verify([source]);
398 }
399
400 void test_deadCode_deadFinalStatementInCase() {
401 Source source = addSource(r'''
402 f() {
403 switch (true) {
404 case true:
405 try {
406 int a = 1;
407 } finally {
408 return;
409 }
410 int b = 1;
411 default:
412 break;
413 }
414 }''');
415 computeLibrarySourceErrors(source);
416 // A single dead statement at the end of a switch case that is not a
417 // terminating statement will yield two errors.
418 assertErrors(source,
419 [HintCode.DEAD_CODE, StaticWarningCode.CASE_BLOCK_NOT_TERMINATED]);
420 verify([source]);
421 }
422
380 void test_deadCode_deadOperandLHS_and() { 423 void test_deadCode_deadOperandLHS_and() {
381 Source source = addSource(r''' 424 Source source = addSource(r'''
382 f() { 425 f() {
383 bool b = false && false; 426 bool b = false && false;
384 }'''); 427 }''');
385 computeLibrarySourceErrors(source); 428 computeLibrarySourceErrors(source);
386 assertErrors(source, [HintCode.DEAD_CODE]); 429 assertErrors(source, [HintCode.DEAD_CODE]);
387 verify([source]); 430 verify([source]);
388 } 431 }
389 432
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 case 1: 509 case 1:
467 break; 510 break;
468 var a; 511 var a;
469 } 512 }
470 }'''); 513 }''');
471 computeLibrarySourceErrors(source); 514 computeLibrarySourceErrors(source);
472 assertErrors(source, [HintCode.DEAD_CODE]); 515 assertErrors(source, [HintCode.DEAD_CODE]);
473 verify([source]); 516 verify([source]);
474 } 517 }
475 518
476 void test_deadCode_deadFinalReturnInCase() {
477 Source source = addSource(r'''
478 f() {
479 switch (true) {
480 case true:
481 try {
482 int a = 1;
483 } finally {
484 return;
485 }
486 return;
487 default:
488 break;
489 }
490 }''');
491 computeLibrarySourceErrors(source);
492 assertErrors(source, [HintCode.DEAD_CODE]);
493 verify([source]);
494 }
495
496 void test_deadCode_deadFinalStatementInCase() {
497 Source source = addSource(r'''
498 f() {
499 switch (true) {
500 case true:
501 try {
502 int a = 1;
503 } finally {
504 return;
505 }
506 int b = 1;
507 default:
508 break;
509 }
510 }''');
511 computeLibrarySourceErrors(source);
512 // A single dead statement at the end of a switch case that is not a
513 // terminating statement will yield two errors.
514 assertErrors(source,
515 [HintCode.DEAD_CODE, StaticWarningCode.CASE_BLOCK_NOT_TERMINATED]);
516 verify([source]);
517 }
518
519 void test_deadCode_statementAfterBreak_inWhileStatement() { 519 void test_deadCode_statementAfterBreak_inWhileStatement() {
520 Source source = addSource(r''' 520 Source source = addSource(r'''
521 f(v) { 521 f(v) {
522 while(v) { 522 while(v) {
523 break; 523 break;
524 var a; 524 var a;
525 } 525 }
526 }'''); 526 }''');
527 computeLibrarySourceErrors(source); 527 computeLibrarySourceErrors(source);
528 assertErrors(source, [HintCode.DEAD_CODE]); 528 assertErrors(source, [HintCode.DEAD_CODE]);
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 int get a => 42; 1189 int get a => 42;
1190 } 1190 }
1191 abstract class B implements A { 1191 abstract class B implements A {
1192 int b() => a; 1192 int b() => a;
1193 }'''); 1193 }''');
1194 computeLibrarySourceErrors(source); 1194 computeLibrarySourceErrors(source);
1195 assertNoErrors(source); 1195 assertNoErrors(source);
1196 verify([source]); 1196 verify([source]);
1197 } 1197 }
1198 1198
1199 void test_invalidUseOfProtectedMember_in_docs_OK() {
1200 Source source = addSource(r'''
1201 import 'package:meta/meta.dart';
1202
1203 class A {
1204 @protected
1205 int a() => c;
1206 @protected
1207 int get b => a();
1208 @protected
1209 int c = 42;
1210 }
1211
1212 /// OK: [A.a], [A.b], [A.c].
1213 f() {}
1214 ''');
1215 computeLibrarySourceErrors(source);
1216 assertNoErrors(source);
1217 verify([source]);
1218 }
1219
1199 void test_invalidUseOfProtectedMember_message() { 1220 void test_invalidUseOfProtectedMember_message() {
1200 Source source = addSource(r''' 1221 Source source = addSource(r'''
1201 import 'package:meta/meta.dart'; 1222 import 'package:meta/meta.dart';
1202 class A { 1223 class A {
1203 @protected 1224 @protected
1204 void a(){ } 1225 void a(){ }
1205 } 1226 }
1206 class B { 1227 class B {
1207 void b() => new A().a(); 1228 void b() => new A().a();
1208 }'''); 1229 }''');
(...skipping 2383 matching lines...) Expand 10 before | Expand all | Expand 10 after
3592 n() { 3613 n() {
3593 var a = m(), b = m(); 3614 var a = m(), b = m();
3594 } 3615 }
3595 }'''); 3616 }''');
3596 computeLibrarySourceErrors(source); 3617 computeLibrarySourceErrors(source);
3597 assertErrors( 3618 assertErrors(
3598 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); 3619 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]);
3599 verify([source]); 3620 verify([source]);
3600 } 3621 }
3601 } 3622 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698