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

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

Issue 1427783003: Check for potential null operand in Not expressions. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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) 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 engine.resolver_test; 5 library engine.resolver_test;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/context/context.dart' as newContext; 9 import 'package:analyzer/src/context/context.dart' as newContext;
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 2744 matching lines...) Expand 10 before | Expand all | Expand 10 after
2755 } 2755 }
2756 f(A a) { 2756 f(A a) {
2757 A b; 2757 A b;
2758 a += b; 2758 a += b;
2759 }'''); 2759 }''');
2760 computeLibrarySourceErrors(source); 2760 computeLibrarySourceErrors(source);
2761 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); 2761 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
2762 verify([source]); 2762 verify([source]);
2763 } 2763 }
2764 2764
2765 void test_deprecatedAnnotationUse_Deprecated() { 2765 void test_deprecatedAnnotationUse_deprecated() {
2766 Source source = addSource(r''' 2766 Source source = addSource(r'''
2767 class A { 2767 class A {
2768 @Deprecated('0.9') 2768 @deprecated
2769 m() {} 2769 m() {}
2770 n() {m();} 2770 n() {m();}
2771 }'''); 2771 }''');
2772 computeLibrarySourceErrors(source); 2772 computeLibrarySourceErrors(source);
2773 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); 2773 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
2774 verify([source]); 2774 verify([source]);
2775 } 2775 }
2776 2776
2777 void test_deprecatedAnnotationUse_deprecated() { 2777 void test_deprecatedAnnotationUse_Deprecated() {
2778 Source source = addSource(r''' 2778 Source source = addSource(r'''
2779 class A { 2779 class A {
2780 @deprecated 2780 @Deprecated('0.9')
2781 m() {} 2781 m() {}
2782 n() {m();} 2782 n() {m();}
2783 }'''); 2783 }''');
2784 computeLibrarySourceErrors(source); 2784 computeLibrarySourceErrors(source);
2785 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); 2785 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
2786 verify([source]); 2786 verify([source]);
2787 } 2787 }
2788 2788
2789 void test_deprecatedAnnotationUse_export() { 2789 void test_deprecatedAnnotationUse_export() {
2790 Source source = addSource("export 'deprecated_library.dart';"); 2790 Source source = addSource("export 'deprecated_library.dart';");
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
3267 Source source = addSource(r''' 3267 Source source = addSource(r'''
3268 m(x) { 3268 m(x) {
3269 if (x.a || x.b || x?.c) {} 3269 if (x.a || x.b || x?.c) {}
3270 } 3270 }
3271 '''); 3271 ''');
3272 computeLibrarySourceErrors(source); 3272 computeLibrarySourceErrors(source);
3273 assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]); 3273 assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]);
3274 verify([source]); 3274 verify([source]);
3275 } 3275 }
3276 3276
3277 void test_nullAwareInCondition_if_not() {
3278 Source source = addSource(r'''
3279 m(x) {
3280 if (!x?.a) {}
3281 }
3282 ''');
3283 computeLibrarySourceErrors(source);
3284 assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]);
3285 verify([source]);
3286 }
3287
3277 void test_nullAwareInCondition_if_parenthesized() { 3288 void test_nullAwareInCondition_if_parenthesized() {
3278 Source source = addSource(r''' 3289 Source source = addSource(r'''
3279 m(x) { 3290 m(x) {
3280 if ((x?.a)) {} 3291 if ((x?.a)) {}
3281 } 3292 }
3282 '''); 3293 ''');
3283 computeLibrarySourceErrors(source); 3294 computeLibrarySourceErrors(source);
3284 assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]); 3295 assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]);
3285 verify([source]); 3296 verify([source]);
3286 } 3297 }
(...skipping 11731 matching lines...) Expand 10 before | Expand all | Expand 10 after
15018 15029
15019 void _resolveTestUnit(String code) { 15030 void _resolveTestUnit(String code) {
15020 testCode = code; 15031 testCode = code;
15021 testSource = addSource(testCode); 15032 testSource = addSource(testCode);
15022 LibraryElement library = resolve2(testSource); 15033 LibraryElement library = resolve2(testSource);
15023 assertNoErrors(testSource); 15034 assertNoErrors(testSource);
15024 verify([testSource]); 15035 verify([testSource]);
15025 testUnit = resolveCompilationUnit(testSource, library); 15036 testUnit = resolveCompilationUnit(testSource, library);
15026 } 15037 }
15027 } 15038 }
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