| 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 analyzer.test.generated.compile_time_error_code_test; | 5 library analyzer.test.generated.compile_time_error_code_test; |
| 6 | 6 |
| 7 import 'package:analyzer/error/error.dart'; | 7 import 'package:analyzer/error/error.dart'; |
| 8 import 'package:analyzer/src/error/codes.dart'; | 8 import 'package:analyzer/src/error/codes.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | 10 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 import 'annotations.dart' as pref; | 249 import 'annotations.dart' as pref; |
| 250 @pref.property(123) | 250 @pref.property(123) |
| 251 main() { | 251 main() { |
| 252 } | 252 } |
| 253 '''); | 253 '''); |
| 254 computeLibrarySourceErrors(source); | 254 computeLibrarySourceErrors(source); |
| 255 assertErrors(source, [CompileTimeErrorCode.ANNOTATION_WITH_NON_CLASS]); | 255 assertErrors(source, [CompileTimeErrorCode.ANNOTATION_WITH_NON_CLASS]); |
| 256 verify([source]); | 256 verify([source]); |
| 257 } | 257 } |
| 258 | 258 |
| 259 void test_assertWithExtraArgument() { | |
| 260 // TODO(paulberry): once DEP 37 is turned on by default, this test should | |
| 261 // be removed. | |
| 262 Source source = addSource(''' | |
| 263 f(bool x) { | |
| 264 assert(x, 'foo'); | |
| 265 } | |
| 266 '''); | |
| 267 computeLibrarySourceErrors(source); | |
| 268 assertErrors(source, [CompileTimeErrorCode.EXTRA_ARGUMENT_TO_ASSERT]); | |
| 269 verify([source]); | |
| 270 } | |
| 271 | |
| 272 void test_async_used_as_identifier_in_annotation() { | 259 void test_async_used_as_identifier_in_annotation() { |
| 273 Source source = addSource(''' | 260 Source source = addSource(''' |
| 274 const int async = 0; | 261 const int async = 0; |
| 275 f() async { | 262 f() async { |
| 276 g(@async x) {} | 263 g(@async x) {} |
| 277 g(0); | 264 g(0); |
| 278 } | 265 } |
| 279 '''); | 266 '''); |
| 280 computeLibrarySourceErrors(source); | 267 computeLibrarySourceErrors(source); |
| 281 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); | 268 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); |
| (...skipping 4320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4602 class A { | 4589 class A { |
| 4603 const A(int i) : assert(i.isNegative); | 4590 const A(int i) : assert(i.isNegative); |
| 4604 }'''); | 4591 }'''); |
| 4605 computeLibrarySourceErrors(source); | 4592 computeLibrarySourceErrors(source); |
| 4606 assertErrors( | 4593 assertErrors( |
| 4607 source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]); | 4594 source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]); |
| 4608 verify([source]); | 4595 verify([source]); |
| 4609 } | 4596 } |
| 4610 | 4597 |
| 4611 void test_nonConstValueInInitializer_assert_message() { | 4598 void test_nonConstValueInInitializer_assert_message() { |
| 4612 resetWithOptions(new AnalysisOptionsImpl() | 4599 resetWithOptions(new AnalysisOptionsImpl()..enableAssertInitializer = true); |
| 4613 ..enableAssertInitializer = true | |
| 4614 ..enableAssertMessage = true); | |
| 4615 Source source = addSource(r''' | 4600 Source source = addSource(r''' |
| 4616 class A { | 4601 class A { |
| 4617 const A(int i) : assert(i < 0, 'isNegative = ${i.isNegative}'); | 4602 const A(int i) : assert(i < 0, 'isNegative = ${i.isNegative}'); |
| 4618 }'''); | 4603 }'''); |
| 4619 computeLibrarySourceErrors(source); | 4604 computeLibrarySourceErrors(source); |
| 4620 assertErrors( | 4605 assertErrors( |
| 4621 source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]); | 4606 source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]); |
| 4622 verify([source]); | 4607 verify([source]); |
| 4623 } | 4608 } |
| 4624 | 4609 |
| (...skipping 1816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6441 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); | 6426 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); |
| 6442 verify([source]); | 6427 verify([source]); |
| 6443 reset(); | 6428 reset(); |
| 6444 } | 6429 } |
| 6445 | 6430 |
| 6446 void _check_wrongNumberOfParametersForOperator1(String name) { | 6431 void _check_wrongNumberOfParametersForOperator1(String name) { |
| 6447 _check_wrongNumberOfParametersForOperator(name, ""); | 6432 _check_wrongNumberOfParametersForOperator(name, ""); |
| 6448 _check_wrongNumberOfParametersForOperator(name, "a, b"); | 6433 _check_wrongNumberOfParametersForOperator(name, "a, b"); |
| 6449 } | 6434 } |
| 6450 } | 6435 } |
| OLD | NEW |