Chromium Code Reviews| 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 | |
| 4778 // suppressed. | |
| 4779 await computeAnalysisResult(source); | 4796 await computeAnalysisResult(source); |
| 4780 assertErrors(source, [ | 4797 assertErrors(source, [ |
| 4781 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER, | 4798 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER, |
| 4782 CompileTimeErrorCode.INVALID_CONSTANT | 4799 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION |
|
Brian Wilkerson
2017/04/18 18:53:21
Seems like we still have redundant errors and ough
scheglov
2017/04/18 19:11:03
I'm restoring it (because removing it later is eas
| |
| 4783 ]); | 4800 ]); |
| 4784 verify([source]); | 4801 verify([source]); |
| 4785 } | 4802 } |
| 4786 | 4803 |
| 4787 test_nonConstValueInInitializer_redirecting() async { | 4804 test_nonConstValueInInitializer_redirecting() async { |
| 4788 Source source = addSource(r''' | 4805 Source source = addSource(r''' |
| 4789 class A { | 4806 class A { |
| 4790 static var C; | 4807 static var C; |
| 4791 const A.named(p); | 4808 const A.named(p); |
| 4792 const A() : this.named(C); | 4809 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]); | 6637 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); |
| 6621 verify([source]); | 6638 verify([source]); |
| 6622 reset(); | 6639 reset(); |
| 6623 } | 6640 } |
| 6624 | 6641 |
| 6625 Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async { | 6642 Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async { |
| 6626 await _check_wrongNumberOfParametersForOperator(name, ""); | 6643 await _check_wrongNumberOfParametersForOperator(name, ""); |
| 6627 await _check_wrongNumberOfParametersForOperator(name, "a, b"); | 6644 await _check_wrongNumberOfParametersForOperator(name, "a, b"); |
| 6628 } | 6645 } |
| 6629 } | 6646 } |
| OLD | NEW |