OLD | NEW |
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'; |
| 8 import 'package:analyzer/src/error/codes.dart'; |
7 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
8 import 'package:analyzer/src/generated/error.dart'; | |
9 import 'package:analyzer/src/generated/parser.dart'; | 10 import 'package:analyzer/src/generated/parser.dart'; |
10 import 'package:analyzer/src/generated/source_io.dart'; | 11 import 'package:analyzer/src/generated/source_io.dart'; |
11 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 12 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
12 import 'package:unittest/unittest.dart'; | 13 import 'package:unittest/unittest.dart'; |
13 | 14 |
14 import '../utils.dart'; | 15 import '../utils.dart'; |
15 import 'analysis_context_factory.dart'; | 16 import 'analysis_context_factory.dart'; |
16 import 'resolver_test_case.dart'; | 17 import 'resolver_test_case.dart'; |
17 | 18 |
18 main() { | 19 main() { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 Source source = addSource(r''' | 102 Source source = addSource(r''' |
102 m(x) { | 103 m(x) { |
103 x?.a()?.b(); | 104 x?.a()?.b(); |
104 } | 105 } |
105 '''); | 106 '''); |
106 computeLibrarySourceErrors(source); | 107 computeLibrarySourceErrors(source); |
107 assertNoErrors(source); | 108 assertNoErrors(source); |
108 verify([source]); | 109 verify([source]); |
109 } | 110 } |
110 | 111 |
111 void test_canBeNullAfterNullAware_false_propertyAccess() { | 112 void test_canBeNullAfterNullAware_false_null() { |
112 Source source = addSource(r''' | 113 Source source = addSource(r''' |
113 m(x) { | 114 m(x) { |
114 x?.a?.b; | 115 x?.a.hashCode; |
| 116 x?.a.runtimeType; |
| 117 x?.a.toString(); |
| 118 x?.b().hashCode; |
| 119 x?.b().runtimeType; |
| 120 x?.b().toString(); |
115 } | 121 } |
116 '''); | 122 '''); |
117 computeLibrarySourceErrors(source); | 123 computeLibrarySourceErrors(source); |
118 assertNoErrors(source); | 124 assertNoErrors(source); |
119 verify([source]); | 125 verify([source]); |
120 } | 126 } |
121 | 127 |
122 void test_canBeNullAfterNullAware_false_null() { | 128 void test_canBeNullAfterNullAware_false_propertyAccess() { |
123 Source source = addSource(r''' | 129 Source source = addSource(r''' |
124 m(x) { | 130 m(x) { |
125 x?.a.hashCode; | 131 x?.a?.b; |
126 x?.a.runtimeType; | |
127 x?.a.toString(); | |
128 x?.b().hashCode; | |
129 x?.b().runtimeType; | |
130 x?.b().toString(); | |
131 } | 132 } |
132 '''); | 133 '''); |
133 computeLibrarySourceErrors(source); | 134 computeLibrarySourceErrors(source); |
134 assertNoErrors(source); | 135 assertNoErrors(source); |
135 verify([source]); | 136 verify([source]); |
136 } | 137 } |
137 | 138 |
138 void test_canBeNullAfterNullAware_methodInvocation() { | 139 void test_canBeNullAfterNullAware_methodInvocation() { |
139 Source source = addSource(r''' | 140 Source source = addSource(r''' |
140 m(x) { | 141 m(x) { |
(...skipping 3788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3929 n() { | 3930 n() { |
3930 var a = m(), b = m(); | 3931 var a = m(), b = m(); |
3931 } | 3932 } |
3932 }'''); | 3933 }'''); |
3933 computeLibrarySourceErrors(source); | 3934 computeLibrarySourceErrors(source); |
3934 assertErrors( | 3935 assertErrors( |
3935 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); | 3936 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); |
3936 verify([source]); | 3937 verify([source]); |
3937 } | 3938 } |
3938 } | 3939 } |
OLD | NEW |