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 4687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4698 | 4698 |
4699 void test_partOfNonPart_self() { | 4699 void test_partOfNonPart_self() { |
4700 Source source = addSource(r''' | 4700 Source source = addSource(r''' |
4701 library lib; | 4701 library lib; |
4702 part 'test.dart';'''); | 4702 part 'test.dart';'''); |
4703 computeLibrarySourceErrors(source); | 4703 computeLibrarySourceErrors(source); |
4704 assertErrors(source, [CompileTimeErrorCode.PART_OF_NON_PART]); | 4704 assertErrors(source, [CompileTimeErrorCode.PART_OF_NON_PART]); |
4705 verify([source]); | 4705 verify([source]); |
4706 } | 4706 } |
4707 | 4707 |
| 4708 void test_prefix_assignment_compound_in_method() { |
| 4709 addNamedSource('/lib.dart', 'library lib;'); |
| 4710 Source source = addSource(''' |
| 4711 import 'lib.dart' as p; |
| 4712 class C { |
| 4713 f() { |
| 4714 p += 1; |
| 4715 } |
| 4716 } |
| 4717 '''); |
| 4718 computeLibrarySourceErrors(source); |
| 4719 assertErrors( |
| 4720 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 4721 verify([source]); |
| 4722 } |
| 4723 |
| 4724 void test_prefix_assignment_compound_not_in_method() { |
| 4725 addNamedSource('/lib.dart', 'library lib;'); |
| 4726 Source source = addSource(''' |
| 4727 import 'lib.dart' as p; |
| 4728 f() { |
| 4729 p += 1; |
| 4730 } |
| 4731 '''); |
| 4732 computeLibrarySourceErrors(source); |
| 4733 assertErrors( |
| 4734 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 4735 verify([source]); |
| 4736 } |
| 4737 |
| 4738 void test_prefix_assignment_in_method() { |
| 4739 addNamedSource('/lib.dart', 'library lib;'); |
| 4740 Source source = addSource(''' |
| 4741 import 'lib.dart' as p; |
| 4742 class C { |
| 4743 f() { |
| 4744 p = 1; |
| 4745 } |
| 4746 } |
| 4747 '''); |
| 4748 computeLibrarySourceErrors(source); |
| 4749 assertErrors( |
| 4750 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 4751 verify([source]); |
| 4752 } |
| 4753 |
| 4754 void test_prefix_assignment_not_in_method() { |
| 4755 addNamedSource('/lib.dart', 'library lib;'); |
| 4756 Source source = addSource(''' |
| 4757 import 'lib.dart' as p; |
| 4758 f() { |
| 4759 p = 1; |
| 4760 } |
| 4761 '''); |
| 4762 computeLibrarySourceErrors(source); |
| 4763 assertErrors( |
| 4764 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 4765 verify([source]); |
| 4766 } |
| 4767 |
4708 void test_prefix_conditionalPropertyAccess_call() { | 4768 void test_prefix_conditionalPropertyAccess_call() { |
4709 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 4769 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
4710 options.enableNullAwareOperators = true; | 4770 options.enableNullAwareOperators = true; |
4711 resetWithOptions(options); | 4771 resetWithOptions(options); |
4712 addNamedSource('/lib.dart', ''' | 4772 addNamedSource('/lib.dart', ''' |
4713 library lib; | 4773 library lib; |
4714 g() {} | 4774 g() {} |
4715 '''); | 4775 '''); |
4716 Source source = addSource(''' | 4776 Source source = addSource(''' |
4717 import 'lib.dart' as p; | 4777 import 'lib.dart' as p; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4815 f() { | 4875 f() { |
4816 p?.loadLibrary = null; | 4876 p?.loadLibrary = null; |
4817 } | 4877 } |
4818 '''); | 4878 '''); |
4819 computeLibrarySourceErrors(source); | 4879 computeLibrarySourceErrors(source); |
4820 assertErrors( | 4880 assertErrors( |
4821 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); | 4881 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
4822 verify([source]); | 4882 verify([source]); |
4823 } | 4883 } |
4824 | 4884 |
| 4885 void test_prefix_unqualified_invocation_in_method() { |
| 4886 addNamedSource('/lib.dart', 'librarylib;'); |
| 4887 Source source = addSource(''' |
| 4888 import 'lib.dart' as p; |
| 4889 class C { |
| 4890 f() { |
| 4891 p(); |
| 4892 } |
| 4893 } |
| 4894 '''); |
| 4895 computeLibrarySourceErrors(source); |
| 4896 assertErrors( |
| 4897 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 4898 verify([source]); |
| 4899 } |
| 4900 |
| 4901 void test_prefix_unqualified_invocation_not_in_method() { |
| 4902 addNamedSource('/lib.dart', 'librarylib;'); |
| 4903 Source source = addSource(''' |
| 4904 import 'lib.dart' as p; |
| 4905 f() { |
| 4906 p(); |
| 4907 } |
| 4908 '''); |
| 4909 computeLibrarySourceErrors(source); |
| 4910 assertErrors( |
| 4911 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 4912 verify([source]); |
| 4913 } |
| 4914 |
4825 void test_prefixCollidesWithTopLevelMembers_functionTypeAlias() { | 4915 void test_prefixCollidesWithTopLevelMembers_functionTypeAlias() { |
4826 addNamedSource("/lib.dart", r''' | 4916 addNamedSource("/lib.dart", r''' |
4827 library lib; | 4917 library lib; |
4828 class A{}'''); | 4918 class A{}'''); |
4829 Source source = addSource(r''' | 4919 Source source = addSource(r''' |
4830 import 'lib.dart' as p; | 4920 import 'lib.dart' as p; |
4831 typedef p(); | 4921 typedef p(); |
4832 p.A a;'''); | 4922 p.A a;'''); |
4833 computeLibrarySourceErrors(source); | 4923 computeLibrarySourceErrors(source); |
4834 assertErrors( | 4924 assertErrors( |
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6046 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); | 6136 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); |
6047 verify([source]); | 6137 verify([source]); |
6048 reset(); | 6138 reset(); |
6049 } | 6139 } |
6050 | 6140 |
6051 void _check_wrongNumberOfParametersForOperator1(String name) { | 6141 void _check_wrongNumberOfParametersForOperator1(String name) { |
6052 _check_wrongNumberOfParametersForOperator(name, ""); | 6142 _check_wrongNumberOfParametersForOperator(name, ""); |
6053 _check_wrongNumberOfParametersForOperator(name, "a, b"); | 6143 _check_wrongNumberOfParametersForOperator(name, "a, b"); |
6054 } | 6144 } |
6055 } | 6145 } |
OLD | NEW |