| 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/source_io.dart'; | 7 import 'package:analyzer/src/generated/source_io.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/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| (...skipping 2703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2714 resolve(source); | 2714 resolve(source); |
| 2715 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); | 2715 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); |
| 2716 } | 2716 } |
| 2717 | 2717 |
| 2718 void test_invalidUri_part() { | 2718 void test_invalidUri_part() { |
| 2719 Source source = addSource("part 'ht:';"); | 2719 Source source = addSource("part 'ht:';"); |
| 2720 resolve(source); | 2720 resolve(source); |
| 2721 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); | 2721 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); |
| 2722 } | 2722 } |
| 2723 | 2723 |
| 2724 void test_isInConstInstanceCreation_restored() { |
| 2725 // If ErrorVerifier._isInConstInstanceCreation is not properly restored on |
| 2726 // exit from visitInstanceCreationExpression, the error at (1) will be |
| 2727 // treated as a warning rather than an error. |
| 2728 Source source = addSource(r''' |
| 2729 class Foo<T extends num> { |
| 2730 const Foo(x, y); |
| 2731 } |
| 2732 const x = const Foo<int>(const Foo<int>(0, 1), |
| 2733 const <Foo<String>>[]); // (1) |
| 2734 '''); |
| 2735 resolve(source); |
| 2736 assertErrors(source, [CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
]); |
| 2737 verify([source]); |
| 2738 } |
| 2739 |
| 2740 void test_isInInstanceVariableInitializer_restored() { |
| 2741 // If ErrorVerifier._isInInstanceVariableInitializer is not properly |
| 2742 // restored on exit from visitVariableDeclaration, the error at (1) |
| 2743 // won't be detected. |
| 2744 Source source = addSource(r''' |
| 2745 class Foo { |
| 2746 var bar; |
| 2747 Map foo = { |
| 2748 'bar': () { |
| 2749 var _bar; |
| 2750 }, |
| 2751 'bop': _foo // (1) |
| 2752 }; |
| 2753 _foo() { |
| 2754 } |
| 2755 }'''); |
| 2756 resolve(source); |
| 2757 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); |
| 2758 verify([source]); |
| 2759 } |
| 2760 |
| 2724 void test_labelInOuterScope() { | 2761 void test_labelInOuterScope() { |
| 2725 Source source = addSource(r''' | 2762 Source source = addSource(r''' |
| 2726 class A { | 2763 class A { |
| 2727 void m(int i) { | 2764 void m(int i) { |
| 2728 l: while (i > 0) { | 2765 l: while (i > 0) { |
| 2729 void f() { | 2766 void f() { |
| 2730 break l; | 2767 break l; |
| 2731 }; | 2768 }; |
| 2732 } | 2769 } |
| 2733 } | 2770 } |
| (...skipping 1989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4723 void _check_wrongNumberOfParametersForOperator1(String name) { | 4760 void _check_wrongNumberOfParametersForOperator1(String name) { |
| 4724 _check_wrongNumberOfParametersForOperator(name, ""); | 4761 _check_wrongNumberOfParametersForOperator(name, ""); |
| 4725 _check_wrongNumberOfParametersForOperator(name, "a, b"); | 4762 _check_wrongNumberOfParametersForOperator(name, "a, b"); |
| 4726 } | 4763 } |
| 4727 } | 4764 } |
| 4728 | 4765 |
| 4729 main() { | 4766 main() { |
| 4730 _ut.groupSep = ' | '; | 4767 _ut.groupSep = ' | '; |
| 4731 runReflectiveTests(CompileTimeErrorCodeTest); | 4768 runReflectiveTests(CompileTimeErrorCodeTest); |
| 4732 } | 4769 } |
| OLD | NEW |