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 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analyzer/error/error.dart'; | 9 import 'package:analyzer/error/error.dart'; |
10 import 'package:analyzer/src/error/codes.dart'; | 10 import 'package:analyzer/src/error/codes.dart'; |
(...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1253 verify([source]); | 1253 verify([source]); |
1254 } | 1254 } |
1255 | 1255 |
1256 test_constFormalParameter_simpleFormalParameter() async { | 1256 test_constFormalParameter_simpleFormalParameter() async { |
1257 Source source = addSource("f(const x) {}"); | 1257 Source source = addSource("f(const x) {}"); |
1258 await computeAnalysisResult(source); | 1258 await computeAnalysisResult(source); |
1259 assertErrors(source, [CompileTimeErrorCode.CONST_FORMAL_PARAMETER]); | 1259 assertErrors(source, [CompileTimeErrorCode.CONST_FORMAL_PARAMETER]); |
1260 verify([source]); | 1260 verify([source]); |
1261 } | 1261 } |
1262 | 1262 |
| 1263 test_nonConstValueInInitializer_instanceCreation_inDifferentFile() async { |
| 1264 resetWith(options: new AnalysisOptionsImpl()..strongMode = true); |
| 1265 Source source = addNamedSource( |
| 1266 '/a.dart', |
| 1267 r''' |
| 1268 import 'b.dart'; |
| 1269 const v = const MyClass(); |
| 1270 '''); |
| 1271 addNamedSource( |
| 1272 '/b.dart', |
| 1273 r''' |
| 1274 class MyClass { |
| 1275 const MyClass([p = foo]); |
| 1276 } |
| 1277 '''); |
| 1278 await computeAnalysisResult(source); |
| 1279 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); |
| 1280 } |
| 1281 |
1263 test_constInitializedWithNonConstValue() async { | 1282 test_constInitializedWithNonConstValue() async { |
1264 Source source = addSource(r''' | 1283 Source source = addSource(r''' |
1265 f(p) { | 1284 f(p) { |
1266 const C = p; | 1285 const C = p; |
1267 }'''); | 1286 }'''); |
1268 await computeAnalysisResult(source); | 1287 await computeAnalysisResult(source); |
1269 assertErrors(source, | 1288 assertErrors(source, |
1270 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); | 1289 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); |
1271 verify([source]); | 1290 verify([source]); |
1272 } | 1291 } |
(...skipping 3494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4767 test_nonConstValueInInitializer_instanceCreation() async { | 4786 test_nonConstValueInInitializer_instanceCreation() async { |
4768 Source source = addSource(r''' | 4787 Source source = addSource(r''' |
4769 class A { | 4788 class A { |
4770 A(); | 4789 A(); |
4771 } | 4790 } |
4772 class B { | 4791 class B { |
4773 const B() : a = new A(); | 4792 const B() : a = new A(); |
4774 final a; | 4793 final a; |
4775 } | 4794 } |
4776 var b = const B();'''); | 4795 var b = const B();'''); |
4777 // TODO(paulberry): the error INVALID_CONSTAT is redundant and ought to be | 4796 // TODO(scheglov): the error CONST_EVAL_THROWS_EXCEPTION is redundant and |
4778 // suppressed. | 4797 // ought to be suppressed. Or not? |
4779 await computeAnalysisResult(source); | 4798 await computeAnalysisResult(source); |
4780 assertErrors(source, [ | 4799 assertErrors(source, [ |
4781 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER, | 4800 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER, |
4782 CompileTimeErrorCode.INVALID_CONSTANT | 4801 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION |
4783 ]); | 4802 ]); |
4784 verify([source]); | 4803 verify([source]); |
4785 } | 4804 } |
4786 | 4805 |
4787 test_nonConstValueInInitializer_redirecting() async { | 4806 test_nonConstValueInInitializer_redirecting() async { |
4788 Source source = addSource(r''' | 4807 Source source = addSource(r''' |
4789 class A { | 4808 class A { |
4790 static var C; | 4809 static var C; |
4791 const A.named(p); | 4810 const A.named(p); |
4792 const A() : this.named(C); | 4811 const A() : this.named(C); |
(...skipping 1827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6620 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); | 6639 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); |
6621 verify([source]); | 6640 verify([source]); |
6622 reset(); | 6641 reset(); |
6623 } | 6642 } |
6624 | 6643 |
6625 Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async { | 6644 Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async { |
6626 await _check_wrongNumberOfParametersForOperator(name, ""); | 6645 await _check_wrongNumberOfParametersForOperator(name, ""); |
6627 await _check_wrongNumberOfParametersForOperator(name, "a, b"); | 6646 await _check_wrongNumberOfParametersForOperator(name, "a, b"); |
6628 } | 6647 } |
6629 } | 6648 } |
OLD | NEW |