| 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 import 'package:analyzer/src/error/codes.dart'; | 5 import 'package:analyzer/src/error/codes.dart'; |
| 6 import 'package:analyzer/src/generated/source.dart'; | 6 import 'package:analyzer/src/generated/source.dart'; |
| 7 import 'package:analyzer/src/generated/source_io.dart'; | 7 import 'package:analyzer/src/generated/source_io.dart'; |
| 8 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 8 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 9 | 9 |
| 10 import 'resolver_test_case.dart'; | 10 import 'resolver_test_case.dart'; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 Source source = addSource(''' | 46 Source source = addSource(''' |
| 47 int x = ''; // ignore: invalid_assignment | 47 int x = ''; // ignore: invalid_assignment |
| 48 // ... but no ignore here ... | 48 // ... but no ignore here ... |
| 49 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE | 49 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE |
| 50 '''); | 50 '''); |
| 51 await computeAnalysisResult(source); | 51 await computeAnalysisResult(source); |
| 52 assertErrors(source, | 52 assertErrors(source, |
| 53 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); | 53 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); |
| 54 } | 54 } |
| 55 | 55 |
| 56 test_ignore_for_file() async { |
| 57 Source source = addSource(''' |
| 58 int x = ''; //INVALID_ASSIGNMENT |
| 59 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE |
| 60 // ignore_for_file: invalid_assignment |
| 61 '''); |
| 62 await computeAnalysisResult(source); |
| 63 assertErrors(source, |
| 64 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); |
| 65 } |
| 66 |
| 67 test_ignore_for_file_whitespace_variant() async { |
| 68 Source source = addSource(''' |
| 69 //ignore_for_file: const_initialized_with_non_constant_value , invalid_assignm
ent |
| 70 int x = ''; //INVALID_ASSIGNMENT |
| 71 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE |
| 72 '''); |
| 73 await computeAnalysisResult(source); |
| 74 assertErrors(source, []); |
| 75 } |
| 76 |
| 56 test_ignore_only_trailing() async { | 77 test_ignore_only_trailing() async { |
| 57 Source source = addSource(''' | 78 Source source = addSource(''' |
| 58 int x = ''; // ignore: invalid_assignment | 79 int x = ''; // ignore: invalid_assignment |
| 59 '''); | 80 '''); |
| 60 await computeAnalysisResult(source); | 81 await computeAnalysisResult(source); |
| 61 assertErrors(source, []); | 82 assertErrors(source, []); |
| 62 } | 83 } |
| 63 | 84 |
| 64 test_ignore_second() async { | 85 test_ignore_second() async { |
| 65 Source source = addSource(''' | 86 Source source = addSource(''' |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 test_multiple_comments() async { | 149 test_multiple_comments() async { |
| 129 Source source = addSource(''' | 150 Source source = addSource(''' |
| 130 int x = ''; //This is the first comment... | 151 int x = ''; //This is the first comment... |
| 131 // ignore: const_initialized_with_non_constant_value | 152 // ignore: const_initialized_with_non_constant_value |
| 132 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE | 153 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE |
| 133 '''); | 154 '''); |
| 134 await computeAnalysisResult(source); | 155 await computeAnalysisResult(source); |
| 135 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 156 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 136 } | 157 } |
| 137 | 158 |
| 159 test_multiple_ignore_for_files() async { |
| 160 Source source = addSource(''' |
| 161 int x = ''; //INVALID_ASSIGNMENT |
| 162 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE |
| 163 // ignore_for_file: invalid_assignment,const_initialized_with_non_constant_value |
| 164 '''); |
| 165 await computeAnalysisResult(source); |
| 166 assertErrors(source, []); |
| 167 } |
| 168 |
| 138 test_multiple_ignores() async { | 169 test_multiple_ignores() async { |
| 139 Source source = addSource(''' | 170 Source source = addSource(''' |
| 140 int x = 3; | 171 int x = 3; |
| 141 // ignore: invalid_assignment, const_initialized_with_non_constant_value | 172 // ignore: invalid_assignment, const_initialized_with_non_constant_value |
| 142 const String y = x; //INVALID_ASSIGNMENT, CONST_INITIALIZED_WITH_NON_CONSTANT_VA
LUE | 173 const String y = x; //INVALID_ASSIGNMENT, CONST_INITIALIZED_WITH_NON_CONSTANT_VA
LUE |
| 143 '''); | 174 '''); |
| 144 await computeAnalysisResult(source); | 175 await computeAnalysisResult(source); |
| 145 assertErrors(source, []); | 176 assertErrors(source, []); |
| 146 } | 177 } |
| 147 | 178 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 Source source = addSource(''' | 219 Source source = addSource(''' |
| 189 int x = ''; //INVALID_ASSIGNMENT | 220 int x = ''; //INVALID_ASSIGNMENT |
| 190 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE | 221 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE |
| 191 '''); | 222 '''); |
| 192 await computeAnalysisResult(source); | 223 await computeAnalysisResult(source); |
| 193 assertErrors(source, [ | 224 assertErrors(source, [ |
| 194 StaticTypeWarningCode.INVALID_ASSIGNMENT, | 225 StaticTypeWarningCode.INVALID_ASSIGNMENT, |
| 195 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE | 226 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE |
| 196 ]); | 227 ]); |
| 197 } | 228 } |
| 198 | |
| 199 test_ignore_for_file() async { | |
| 200 Source source = addSource(''' | |
| 201 int x = ''; //INVALID_ASSIGNMENT | |
| 202 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE | |
| 203 // ignore_for_file: invalid_assignment | |
| 204 '''); | |
| 205 await computeAnalysisResult(source); | |
| 206 assertErrors(source, | |
| 207 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); | |
| 208 } | |
| 209 | |
| 210 test_multiple_ignore_for_files() async { | |
| 211 Source source = addSource(''' | |
| 212 int x = ''; //INVALID_ASSIGNMENT | |
| 213 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE | |
| 214 // ignore_for_file: invalid_assignment,const_initialized_with_non_constant_value | |
| 215 '''); | |
| 216 await computeAnalysisResult(source); | |
| 217 assertErrors(source, []); | |
| 218 } | |
| 219 | |
| 220 test_ignore_for_file_whitespace_variant() async { | |
| 221 Source source = addSource(''' | |
| 222 //ignore_for_file: const_initialized_with_non_constant_value , invalid_assignm
ent | |
| 223 int x = ''; //INVALID_ASSIGNMENT | |
| 224 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE | |
| 225 '''); | |
| 226 await computeAnalysisResult(source); | |
| 227 assertErrors(source, []); | |
| 228 } | |
| 229 } | 229 } |
| OLD | NEW |