| OLD | NEW |
| 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.compile_time_error_code_test; | 5 library engine.compile_time_error_code_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/error.dart'; | 7 import 'package:analyzer/src/generated/error.dart'; |
| 8 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | 8 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
| 9 import 'package:analyzer/src/generated/source_io.dart'; | 9 import 'package:analyzer/src/generated/source_io.dart'; |
| 10 | 10 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 addNamedSource( | 215 addNamedSource( |
| 216 "/lib2.dart", | 216 "/lib2.dart", |
| 217 r''' | 217 r''' |
| 218 library lib2; | 218 library lib2; |
| 219 class N {}'''); | 219 class N {}'''); |
| 220 computeLibrarySourceErrors(source); | 220 computeLibrarySourceErrors(source); |
| 221 assertErrors(source, [CompileTimeErrorCode.AMBIGUOUS_EXPORT]); | 221 assertErrors(source, [CompileTimeErrorCode.AMBIGUOUS_EXPORT]); |
| 222 verify([source]); | 222 verify([source]); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void test_annotationWithNotClass() { |
| 226 Source source = addSource(''' |
| 227 class Property { |
| 228 final int value; |
| 229 const Property(this.value); |
| 230 } |
| 231 |
| 232 const Property property = const Property(42); |
| 233 |
| 234 @property(123) |
| 235 main() { |
| 236 } |
| 237 '''); |
| 238 computeLibrarySourceErrors(source); |
| 239 assertErrors(source, [CompileTimeErrorCode.ANNOTATION_WITH_NON_CLASS]); |
| 240 verify([source]); |
| 241 } |
| 242 |
| 243 void test_annotationWithNotClass_prefixed() { |
| 244 addNamedSource( |
| 245 "/annotations.dart", |
| 246 r''' |
| 247 class Property { |
| 248 final int value; |
| 249 const Property(this.value); |
| 250 } |
| 251 |
| 252 const Property property = const Property(42); |
| 253 '''); |
| 254 Source source = addSource(''' |
| 255 import 'annotations.dart' as pref; |
| 256 @pref.property(123) |
| 257 main() { |
| 258 } |
| 259 '''); |
| 260 computeLibrarySourceErrors(source); |
| 261 assertErrors(source, [CompileTimeErrorCode.ANNOTATION_WITH_NON_CLASS]); |
| 262 verify([source]); |
| 263 } |
| 264 |
| 225 void test_async_used_as_identifier_in_annotation() { | 265 void test_async_used_as_identifier_in_annotation() { |
| 226 Source source = addSource(''' | 266 Source source = addSource(''' |
| 227 const int async = 0; | 267 const int async = 0; |
| 228 f() async { | 268 f() async { |
| 229 g(@async x) {} | 269 g(@async x) {} |
| 230 g(0); | 270 g(0); |
| 231 } | 271 } |
| 232 '''); | 272 '''); |
| 233 computeLibrarySourceErrors(source); | 273 computeLibrarySourceErrors(source); |
| 234 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); | 274 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); |
| (...skipping 5958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6193 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); | 6233 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); |
| 6194 verify([source]); | 6234 verify([source]); |
| 6195 reset(); | 6235 reset(); |
| 6196 } | 6236 } |
| 6197 | 6237 |
| 6198 void _check_wrongNumberOfParametersForOperator1(String name) { | 6238 void _check_wrongNumberOfParametersForOperator1(String name) { |
| 6199 _check_wrongNumberOfParametersForOperator(name, ""); | 6239 _check_wrongNumberOfParametersForOperator(name, ""); |
| 6200 _check_wrongNumberOfParametersForOperator(name, "a, b"); | 6240 _check_wrongNumberOfParametersForOperator(name, "a, b"); |
| 6201 } | 6241 } |
| 6202 } | 6242 } |
| OLD | NEW |