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

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

Issue 2784473004: Take analysis options into account when computing the severity of a strong mode "error". (Closed)
Patch Set: Add test cases. Created 3 years, 8 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/task/strong/checker.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/error/error.dart'; 7 import 'package:analyzer/error/error.dart';
8 import 'package:analyzer/src/error/codes.dart'; 8 import 'package:analyzer/src/error/codes.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/parser.dart'; 10 import 'package:analyzer/src/generated/parser.dart';
11 import 'package:analyzer/src/generated/source_io.dart'; 11 import 'package:analyzer/src/generated/source_io.dart';
12 import 'package:analyzer/src/task/options.dart';
12 import 'package:test/test.dart'; 13 import 'package:test/test.dart';
13 import 'package:test_reflective_loader/test_reflective_loader.dart'; 14 import 'package:test_reflective_loader/test_reflective_loader.dart';
14 15
15 import 'resolver_test_case.dart'; 16 import 'resolver_test_case.dart';
16 17
17 main() { 18 main() {
18 defineReflectiveSuite(() { 19 defineReflectiveSuite(() {
19 defineReflectiveTests(HintCodeTest); 20 defineReflectiveTests(HintCodeTest);
20 }); 21 });
21 } 22 }
(...skipping 2469 matching lines...) Expand 10 before | Expand all | Expand 10 after
2491 2492
2492 class C { 2493 class C {
2493 F m() => ({@required String x}) => null; 2494 F m() => ({@required String x}) => null;
2494 } 2495 }
2495 '''); 2496 ''');
2496 await computeAnalysisResult(source); 2497 await computeAnalysisResult(source);
2497 assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM]); 2498 assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM]);
2498 verify([source]); 2499 verify([source]);
2499 } 2500 }
2500 2501
2502 test_strongMode_downCastCompositeNoHint() async {
2503 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
2504 options.strongMode = true;
2505 options.strongModeHints = false;
2506 resetWith(options: options);
2507 Source source = addSource(r'''
2508 main() {
2509 List dynamicList = [ ];
2510 List<int> list = dynamicList;
2511 print(list);
2512 }''');
2513 await computeAnalysisResult(source);
2514 assertNoErrors(source);
2515 verify([source]);
2516 }
2517
2518 test_strongMode_downCastCompositeHint() async {
2519 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
2520 options.strongMode = true;
2521 options.strongModeHints = true;
2522 resetWith(options: options);
2523 Source source = addSource(r'''
2524 main() {
2525 List dynamicList = [ ];
2526 List<int> list = dynamicList;
2527 print(list);
2528 }''');
2529 await computeAnalysisResult(source);
2530 assertErrors(source, [StrongModeCode.DOWN_CAST_COMPOSITE]);
2531 verify([source]);
2532 }
2533
2534 test_strongMode_downCastCompositeWarn() async {
2535 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
2536 applyToAnalysisOptions(options, {
2537 AnalyzerOptions.analyzer: {
2538 AnalyzerOptions.errors: {
2539 StrongModeCode.DOWN_CAST_COMPOSITE.name: 'warning'
2540 },
2541 }
2542 });
2543 options.strongMode = true;
2544 options.strongModeHints = false;
2545 resetWith(options: options);
2546 Source source = addSource(r'''
2547 main() {
2548 List dynamicList = [ ];
2549 List<int> list = dynamicList;
2550 print(list);
2551 }''');
2552 await computeAnalysisResult(source);
2553 assertErrors(source, [StrongModeCode.DOWN_CAST_COMPOSITE]);
2554 verify([source]);
2555 }
2556
2501 test_typeCheck_type_is_Null() async { 2557 test_typeCheck_type_is_Null() async {
2502 Source source = addSource(r''' 2558 Source source = addSource(r'''
2503 m(i) { 2559 m(i) {
2504 bool b = i is Null; 2560 bool b = i is Null;
2505 }'''); 2561 }''');
2506 await computeAnalysisResult(source); 2562 await computeAnalysisResult(source);
2507 assertErrors(source, [HintCode.TYPE_CHECK_IS_NULL]); 2563 assertErrors(source, [HintCode.TYPE_CHECK_IS_NULL]);
2508 verify([source]); 2564 verify([source]);
2509 } 2565 }
2510 2566
(...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after
4152 n() { 4208 n() {
4153 var a = m(), b = m(); 4209 var a = m(), b = m();
4154 } 4210 }
4155 }'''); 4211 }''');
4156 await computeAnalysisResult(source); 4212 await computeAnalysisResult(source);
4157 assertErrors( 4213 assertErrors(
4158 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); 4214 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]);
4159 verify([source]); 4215 verify([source]);
4160 } 4216 }
4161 } 4217 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/strong/checker.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698