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/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 3271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3282 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); | 3282 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); |
3283 } | 3283 } |
3284 | 3284 |
3285 void test_invalidUri_import() { | 3285 void test_invalidUri_import() { |
3286 Source source = addSource("import 'ht:';"); | 3286 Source source = addSource("import 'ht:';"); |
3287 computeLibrarySourceErrors(source); | 3287 computeLibrarySourceErrors(source); |
3288 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); | 3288 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); |
3289 } | 3289 } |
3290 | 3290 |
3291 void test_invalidUri_part() { | 3291 void test_invalidUri_part() { |
3292 Source source = addSource("part 'ht:';"); | 3292 Source source = addSource(r''' |
| 3293 library lib; |
| 3294 part 'ht:';'''); |
3293 computeLibrarySourceErrors(source); | 3295 computeLibrarySourceErrors(source); |
3294 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); | 3296 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); |
3295 } | 3297 } |
3296 | 3298 |
3297 void test_isInConstInstanceCreation_restored() { | 3299 void test_isInConstInstanceCreation_restored() { |
3298 // If ErrorVerifier._isInConstInstanceCreation is not properly restored on | 3300 // If ErrorVerifier._isInConstInstanceCreation is not properly restored on |
3299 // exit from visitInstanceCreationExpression, the error at (1) will be | 3301 // exit from visitInstanceCreationExpression, the error at (1) will be |
3300 // treated as a warning rather than an error. | 3302 // treated as a warning rather than an error. |
3301 Source source = addSource(r''' | 3303 Source source = addSource(r''' |
3302 class Foo<T extends num> { | 3304 class Foo<T extends num> { |
(...skipping 2494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5797 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); | 5799 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); |
5798 } | 5800 } |
5799 | 5801 |
5800 void test_uriDoesNotExist_import() { | 5802 void test_uriDoesNotExist_import() { |
5801 Source source = addSource("import 'unknown.dart';"); | 5803 Source source = addSource("import 'unknown.dart';"); |
5802 computeLibrarySourceErrors(source); | 5804 computeLibrarySourceErrors(source); |
5803 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); | 5805 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); |
5804 } | 5806 } |
5805 | 5807 |
5806 void test_uriDoesNotExist_part() { | 5808 void test_uriDoesNotExist_part() { |
5807 Source source = addSource("part 'unknown.dart';"); | 5809 Source source = addSource(r''' |
| 5810 library lib; |
| 5811 part 'unknown.dart';'''); |
5808 computeLibrarySourceErrors(source); | 5812 computeLibrarySourceErrors(source); |
5809 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); | 5813 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); |
5810 } | 5814 } |
5811 | 5815 |
5812 void test_uriWithInterpolation_constant() { | 5816 void test_uriWithInterpolation_constant() { |
5813 Source source = addSource("import 'stuff_\$platform.dart';"); | 5817 Source source = addSource("import 'stuff_\$platform.dart';"); |
5814 computeLibrarySourceErrors(source); | 5818 computeLibrarySourceErrors(source); |
5815 assertErrors(source, [ | 5819 assertErrors(source, [ |
5816 CompileTimeErrorCode.URI_WITH_INTERPOLATION, | 5820 CompileTimeErrorCode.URI_WITH_INTERPOLATION, |
5817 StaticWarningCode.UNDEFINED_IDENTIFIER | 5821 StaticWarningCode.UNDEFINED_IDENTIFIER |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6042 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); | 6046 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); |
6043 verify([source]); | 6047 verify([source]); |
6044 reset(); | 6048 reset(); |
6045 } | 6049 } |
6046 | 6050 |
6047 void _check_wrongNumberOfParametersForOperator1(String name) { | 6051 void _check_wrongNumberOfParametersForOperator1(String name) { |
6048 _check_wrongNumberOfParametersForOperator(name, ""); | 6052 _check_wrongNumberOfParametersForOperator(name, ""); |
6049 _check_wrongNumberOfParametersForOperator(name, "a, b"); | 6053 _check_wrongNumberOfParametersForOperator(name, "a, b"); |
6050 } | 6054 } |
6051 } | 6055 } |
OLD | NEW |