| 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 import 'package:unittest/unittest.dart' as _ut; | 10 import 'package:unittest/unittest.dart' as _ut; |
| (...skipping 3233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3244 f() { | 3244 f() { |
| 3245 x: while (true) { | 3245 x: while (true) { |
| 3246 continue y; | 3246 continue y; |
| 3247 } | 3247 } |
| 3248 }'''); | 3248 }'''); |
| 3249 resolve(source); | 3249 resolve(source); |
| 3250 assertErrors(source, [CompileTimeErrorCode.LABEL_UNDEFINED]); | 3250 assertErrors(source, [CompileTimeErrorCode.LABEL_UNDEFINED]); |
| 3251 // We cannot verify resolution with undefined labels | 3251 // We cannot verify resolution with undefined labels |
| 3252 } | 3252 } |
| 3253 | 3253 |
| 3254 void test_length_of_erroneous_constant() { |
| 3255 // Attempting to compute the length of constant that couldn't be evaluated |
| 3256 // (due to an error) should not crash the analyzer (see dartbug.com/23383) |
| 3257 Source source = addSource("const int i = (1 ? 'alpha' : 'beta').length;"); |
| 3258 resolve(source); |
| 3259 assertErrors(source, [ |
| 3260 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE, |
| 3261 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL, |
| 3262 StaticTypeWarningCode.NON_BOOL_CONDITION |
| 3263 ]); |
| 3264 verify([source]); |
| 3265 } |
| 3266 |
| 3254 void test_memberWithClassName_field() { | 3267 void test_memberWithClassName_field() { |
| 3255 Source source = addSource(r''' | 3268 Source source = addSource(r''' |
| 3256 class A { | 3269 class A { |
| 3257 int A = 0; | 3270 int A = 0; |
| 3258 }'''); | 3271 }'''); |
| 3259 resolve(source); | 3272 resolve(source); |
| 3260 assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]); | 3273 assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]); |
| 3261 verify([source]); | 3274 verify([source]); |
| 3262 } | 3275 } |
| 3263 | 3276 |
| (...skipping 2426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5690 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); | 5703 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); |
| 5691 verify([source]); | 5704 verify([source]); |
| 5692 reset(); | 5705 reset(); |
| 5693 } | 5706 } |
| 5694 | 5707 |
| 5695 void _check_wrongNumberOfParametersForOperator1(String name) { | 5708 void _check_wrongNumberOfParametersForOperator1(String name) { |
| 5696 _check_wrongNumberOfParametersForOperator(name, ""); | 5709 _check_wrongNumberOfParametersForOperator(name, ""); |
| 5697 _check_wrongNumberOfParametersForOperator(name, "a, b"); | 5710 _check_wrongNumberOfParametersForOperator(name, "a, b"); |
| 5698 } | 5711 } |
| 5699 } | 5712 } |
| OLD | NEW |