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/src/generated/engine.dart'; | 7 import 'package:analyzer/src/generated/engine.dart'; |
8 import 'package:analyzer/src/generated/error.dart'; | 8 import 'package:analyzer/src/generated/error.dart'; |
9 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | 9 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
10 import 'package:analyzer/src/generated/source_io.dart'; | 10 import 'package:analyzer/src/generated/source_io.dart'; |
(...skipping 5657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5668 | 5668 |
5669 void test_referencedBeforeDeclaration_inInitializer_directly() { | 5669 void test_referencedBeforeDeclaration_inInitializer_directly() { |
5670 Source source = addSource(r''' | 5670 Source source = addSource(r''' |
5671 main() { | 5671 main() { |
5672 var v = v; | 5672 var v = v; |
5673 }'''); | 5673 }'''); |
5674 computeLibrarySourceErrors(source); | 5674 computeLibrarySourceErrors(source); |
5675 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); | 5675 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); |
5676 } | 5676 } |
5677 | 5677 |
| 5678 void test_referencedBeforeDeclaration_type_localFunction() { |
| 5679 Source source = addSource(r''' |
| 5680 void testTypeRef() { |
| 5681 String s = ''; |
| 5682 int String(int x) => x + 1; |
| 5683 } |
| 5684 '''); |
| 5685 computeLibrarySourceErrors(source); |
| 5686 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); |
| 5687 } |
| 5688 |
| 5689 void test_referencedBeforeDeclaration_type_localVariable() { |
| 5690 Source source = addSource(r''' |
| 5691 void testTypeRef() { |
| 5692 String s = ''; |
| 5693 var String = ''; |
| 5694 } |
| 5695 '''); |
| 5696 computeLibrarySourceErrors(source); |
| 5697 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); |
| 5698 } |
| 5699 |
5678 void test_rethrowOutsideCatch() { | 5700 void test_rethrowOutsideCatch() { |
5679 Source source = addSource(r''' | 5701 Source source = addSource(r''' |
5680 f() { | 5702 f() { |
5681 rethrow; | 5703 rethrow; |
5682 }'''); | 5704 }'''); |
5683 computeLibrarySourceErrors(source); | 5705 computeLibrarySourceErrors(source); |
5684 assertErrors(source, [CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH]); | 5706 assertErrors(source, [CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH]); |
5685 verify([source]); | 5707 verify([source]); |
5686 } | 5708 } |
5687 | 5709 |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6352 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); | 6374 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); |
6353 verify([source]); | 6375 verify([source]); |
6354 reset(); | 6376 reset(); |
6355 } | 6377 } |
6356 | 6378 |
6357 void _check_wrongNumberOfParametersForOperator1(String name) { | 6379 void _check_wrongNumberOfParametersForOperator1(String name) { |
6358 _check_wrongNumberOfParametersForOperator(name, ""); | 6380 _check_wrongNumberOfParametersForOperator(name, ""); |
6359 _check_wrongNumberOfParametersForOperator(name, "a, b"); | 6381 _check_wrongNumberOfParametersForOperator(name, "a, b"); |
6360 } | 6382 } |
6361 } | 6383 } |
OLD | NEW |