| 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 4739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4750 p = 1; | 4750 p = 1; |
| 4751 } | 4751 } |
| 4752 '''); | 4752 '''); |
| 4753 computeLibrarySourceErrors(source); | 4753 computeLibrarySourceErrors(source); |
| 4754 assertErrors( | 4754 assertErrors( |
| 4755 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); | 4755 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 4756 verify([source]); | 4756 verify([source]); |
| 4757 } | 4757 } |
| 4758 | 4758 |
| 4759 void test_prefix_conditionalPropertyAccess_call() { | 4759 void test_prefix_conditionalPropertyAccess_call() { |
| 4760 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | |
| 4761 options.enableNullAwareOperators = true; | |
| 4762 resetWithOptions(options); | |
| 4763 addNamedSource('/lib.dart', ''' | 4760 addNamedSource('/lib.dart', ''' |
| 4764 library lib; | 4761 library lib; |
| 4765 g() {} | 4762 g() {} |
| 4766 '''); | 4763 '''); |
| 4767 Source source = addSource(''' | 4764 Source source = addSource(''' |
| 4768 import 'lib.dart' as p; | 4765 import 'lib.dart' as p; |
| 4769 f() { | 4766 f() { |
| 4770 p?.g(); | 4767 p?.g(); |
| 4771 } | 4768 } |
| 4772 '''); | 4769 '''); |
| 4773 computeLibrarySourceErrors(source); | 4770 computeLibrarySourceErrors(source); |
| 4774 assertErrors( | 4771 assertErrors( |
| 4775 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); | 4772 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 4776 verify([source]); | 4773 verify([source]); |
| 4777 } | 4774 } |
| 4778 | 4775 |
| 4779 void test_prefix_conditionalPropertyAccess_call_loadLibrary() { | 4776 void test_prefix_conditionalPropertyAccess_call_loadLibrary() { |
| 4780 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | |
| 4781 options.enableNullAwareOperators = true; | |
| 4782 resetWithOptions(options); | |
| 4783 addNamedSource('/lib.dart', ''' | 4777 addNamedSource('/lib.dart', ''' |
| 4784 library lib; | 4778 library lib; |
| 4785 '''); | 4779 '''); |
| 4786 Source source = addSource(''' | 4780 Source source = addSource(''' |
| 4787 import 'lib.dart' deferred as p; | 4781 import 'lib.dart' deferred as p; |
| 4788 f() { | 4782 f() { |
| 4789 p?.loadLibrary(); | 4783 p?.loadLibrary(); |
| 4790 } | 4784 } |
| 4791 '''); | 4785 '''); |
| 4792 computeLibrarySourceErrors(source); | 4786 computeLibrarySourceErrors(source); |
| 4793 assertErrors( | 4787 assertErrors( |
| 4794 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); | 4788 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 4795 verify([source]); | 4789 verify([source]); |
| 4796 } | 4790 } |
| 4797 | 4791 |
| 4798 void test_prefix_conditionalPropertyAccess_get() { | 4792 void test_prefix_conditionalPropertyAccess_get() { |
| 4799 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | |
| 4800 options.enableNullAwareOperators = true; | |
| 4801 resetWithOptions(options); | |
| 4802 addNamedSource('/lib.dart', ''' | 4793 addNamedSource('/lib.dart', ''' |
| 4803 library lib; | 4794 library lib; |
| 4804 var x; | 4795 var x; |
| 4805 '''); | 4796 '''); |
| 4806 Source source = addSource(''' | 4797 Source source = addSource(''' |
| 4807 import 'lib.dart' as p; | 4798 import 'lib.dart' as p; |
| 4808 f() { | 4799 f() { |
| 4809 return p?.x; | 4800 return p?.x; |
| 4810 } | 4801 } |
| 4811 '''); | 4802 '''); |
| 4812 computeLibrarySourceErrors(source); | 4803 computeLibrarySourceErrors(source); |
| 4813 assertErrors( | 4804 assertErrors( |
| 4814 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); | 4805 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 4815 verify([source]); | 4806 verify([source]); |
| 4816 } | 4807 } |
| 4817 | 4808 |
| 4818 void test_prefix_conditionalPropertyAccess_get_loadLibrary() { | 4809 void test_prefix_conditionalPropertyAccess_get_loadLibrary() { |
| 4819 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | |
| 4820 options.enableNullAwareOperators = true; | |
| 4821 resetWithOptions(options); | |
| 4822 addNamedSource('/lib.dart', ''' | 4810 addNamedSource('/lib.dart', ''' |
| 4823 library lib; | 4811 library lib; |
| 4824 '''); | 4812 '''); |
| 4825 Source source = addSource(''' | 4813 Source source = addSource(''' |
| 4826 import 'lib.dart' deferred as p; | 4814 import 'lib.dart' deferred as p; |
| 4827 f() { | 4815 f() { |
| 4828 return p?.loadLibrary; | 4816 return p?.loadLibrary; |
| 4829 } | 4817 } |
| 4830 '''); | 4818 '''); |
| 4831 computeLibrarySourceErrors(source); | 4819 computeLibrarySourceErrors(source); |
| 4832 assertErrors( | 4820 assertErrors( |
| 4833 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); | 4821 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 4834 verify([source]); | 4822 verify([source]); |
| 4835 } | 4823 } |
| 4836 | 4824 |
| 4837 void test_prefix_conditionalPropertyAccess_set() { | 4825 void test_prefix_conditionalPropertyAccess_set() { |
| 4838 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | |
| 4839 options.enableNullAwareOperators = true; | |
| 4840 resetWithOptions(options); | |
| 4841 addNamedSource('/lib.dart', ''' | 4826 addNamedSource('/lib.dart', ''' |
| 4842 library lib; | 4827 library lib; |
| 4843 var x; | 4828 var x; |
| 4844 '''); | 4829 '''); |
| 4845 Source source = addSource(''' | 4830 Source source = addSource(''' |
| 4846 import 'lib.dart' as p; | 4831 import 'lib.dart' as p; |
| 4847 f() { | 4832 f() { |
| 4848 p?.x = null; | 4833 p?.x = null; |
| 4849 } | 4834 } |
| 4850 '''); | 4835 '''); |
| 4851 computeLibrarySourceErrors(source); | 4836 computeLibrarySourceErrors(source); |
| 4852 assertErrors( | 4837 assertErrors( |
| 4853 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); | 4838 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 4854 verify([source]); | 4839 verify([source]); |
| 4855 } | 4840 } |
| 4856 | 4841 |
| 4857 void test_prefix_conditionalPropertyAccess_set_loadLibrary() { | 4842 void test_prefix_conditionalPropertyAccess_set_loadLibrary() { |
| 4858 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | |
| 4859 options.enableNullAwareOperators = true; | |
| 4860 resetWithOptions(options); | |
| 4861 addNamedSource('/lib.dart', ''' | 4843 addNamedSource('/lib.dart', ''' |
| 4862 library lib; | 4844 library lib; |
| 4863 '''); | 4845 '''); |
| 4864 Source source = addSource(''' | 4846 Source source = addSource(''' |
| 4865 import 'lib.dart' deferred as p; | 4847 import 'lib.dart' deferred as p; |
| 4866 f() { | 4848 f() { |
| 4867 p?.loadLibrary = null; | 4849 p?.loadLibrary = null; |
| 4868 } | 4850 } |
| 4869 '''); | 4851 '''); |
| 4870 computeLibrarySourceErrors(source); | 4852 computeLibrarySourceErrors(source); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4981 p += 1; | 4963 p += 1; |
| 4982 } | 4964 } |
| 4983 '''); | 4965 '''); |
| 4984 computeLibrarySourceErrors(source); | 4966 computeLibrarySourceErrors(source); |
| 4985 assertErrors( | 4967 assertErrors( |
| 4986 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); | 4968 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 4987 verify([source]); | 4969 verify([source]); |
| 4988 } | 4970 } |
| 4989 | 4971 |
| 4990 void test_prefixNotFollowedByDot_conditionalMethodInvocation() { | 4972 void test_prefixNotFollowedByDot_conditionalMethodInvocation() { |
| 4991 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | |
| 4992 options.enableNullAwareOperators = true; | |
| 4993 resetWithOptions(options); | |
| 4994 addNamedSource('/lib.dart', ''' | 4973 addNamedSource('/lib.dart', ''' |
| 4995 library lib; | 4974 library lib; |
| 4996 g() {} | 4975 g() {} |
| 4997 '''); | 4976 '''); |
| 4998 Source source = addSource(''' | 4977 Source source = addSource(''' |
| 4999 import 'lib.dart' as p; | 4978 import 'lib.dart' as p; |
| 5000 f() { | 4979 f() { |
| 5001 p?.g(); | 4980 p?.g(); |
| 5002 } | 4981 } |
| 5003 '''); | 4982 '''); |
| (...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6143 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); | 6122 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); |
| 6144 verify([source]); | 6123 verify([source]); |
| 6145 reset(); | 6124 reset(); |
| 6146 } | 6125 } |
| 6147 | 6126 |
| 6148 void _check_wrongNumberOfParametersForOperator1(String name) { | 6127 void _check_wrongNumberOfParametersForOperator1(String name) { |
| 6149 _check_wrongNumberOfParametersForOperator(name, ""); | 6128 _check_wrongNumberOfParametersForOperator(name, ""); |
| 6150 _check_wrongNumberOfParametersForOperator(name, "a, b"); | 6129 _check_wrongNumberOfParametersForOperator(name, "a, b"); |
| 6151 } | 6130 } |
| 6152 } | 6131 } |
| OLD | NEW |