Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: pkg/analyzer/test/generated/compile_time_error_code_test.dart

Issue 1177833002: Ensure that prefix?.loadLibrary() generates the proper compile-time error. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/element_resolver.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4705 matching lines...) Expand 10 before | Expand all | Expand 10 after
4716 f() { 4716 f() {
4717 p?.g(); 4717 p?.g();
4718 } 4718 }
4719 '''); 4719 ''');
4720 resolve(source); 4720 resolve(source);
4721 assertErrors( 4721 assertErrors(
4722 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); 4722 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4723 verify([source]); 4723 verify([source]);
4724 } 4724 }
4725 4725
4726 void test_prefix_conditionalPropertyAccess_call_loadLibrary() {
4727 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
4728 options.enableNullAwareOperators = true;
4729 resetWithOptions(options);
4730 addNamedSource('/lib.dart', '''
4731 library lib;
4732 ''');
4733 Source source = addSource('''
4734 import 'lib.dart' deferred as p;
4735 f() {
4736 p?.loadLibrary();
4737 }
4738 ''');
4739 resolve(source);
4740 assertErrors(
4741 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4742 verify([source]);
4743 }
4744
4745 void test_prefix_conditionalPropertyAccess_get() {
4746 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
4747 options.enableNullAwareOperators = true;
4748 resetWithOptions(options);
4749 addNamedSource('/lib.dart', '''
4750 library lib;
4751 var x;
4752 ''');
4753 Source source = addSource('''
4754 import 'lib.dart' as p;
4755 f() {
4756 return p?.x;
4757 }
4758 ''');
4759 resolve(source);
4760 assertErrors(
4761 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4762 verify([source]);
4763 }
4764
4765 void test_prefix_conditionalPropertyAccess_get_loadLibrary() {
4766 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
4767 options.enableNullAwareOperators = true;
4768 resetWithOptions(options);
4769 addNamedSource('/lib.dart', '''
4770 library lib;
4771 ''');
4772 Source source = addSource('''
4773 import 'lib.dart' deferred as p;
4774 f() {
4775 return p?.loadLibrary;
4776 }
4777 ''');
4778 resolve(source);
4779 assertErrors(
4780 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4781 verify([source]);
4782 }
4783
4784 void test_prefix_conditionalPropertyAccess_set() {
4785 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
4786 options.enableNullAwareOperators = true;
4787 resetWithOptions(options);
4788 addNamedSource('/lib.dart', '''
4789 library lib;
4790 var x;
4791 ''');
4792 Source source = addSource('''
4793 import 'lib.dart' as p;
4794 f() {
4795 p?.x = null;
4796 }
4797 ''');
4798 resolve(source);
4799 assertErrors(
4800 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4801 verify([source]);
4802 }
4803
4804 void test_prefix_conditionalPropertyAccess_set_loadLibrary() {
4805 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
4806 options.enableNullAwareOperators = true;
4807 resetWithOptions(options);
4808 addNamedSource('/lib.dart', '''
4809 library lib;
4810 ''');
4811 Source source = addSource('''
4812 import 'lib.dart' deferred as p;
4813 f() {
4814 p?.loadLibrary = null;
4815 }
4816 ''');
4817 resolve(source);
4818 assertErrors(
4819 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4820 verify([source]);
4821 }
4822
4726 void test_prefixCollidesWithTopLevelMembers_functionTypeAlias() { 4823 void test_prefixCollidesWithTopLevelMembers_functionTypeAlias() {
4727 addNamedSource("/lib.dart", r''' 4824 addNamedSource("/lib.dart", r'''
4728 library lib; 4825 library lib;
4729 class A{}'''); 4826 class A{}''');
4730 Source source = addSource(r''' 4827 Source source = addSource(r'''
4731 import 'lib.dart' as p; 4828 import 'lib.dart' as p;
4732 typedef p(); 4829 typedef p();
4733 p.A a;'''); 4830 p.A a;''');
4734 computeLibrarySourceErrors(source); 4831 computeLibrarySourceErrors(source);
4735 assertErrors( 4832 assertErrors(
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after
5945 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); 6042 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]);
5946 verify([source]); 6043 verify([source]);
5947 reset(); 6044 reset();
5948 } 6045 }
5949 6046
5950 void _check_wrongNumberOfParametersForOperator1(String name) { 6047 void _check_wrongNumberOfParametersForOperator1(String name) {
5951 _check_wrongNumberOfParametersForOperator(name, ""); 6048 _check_wrongNumberOfParametersForOperator(name, "");
5952 _check_wrongNumberOfParametersForOperator(name, "a, b"); 6049 _check_wrongNumberOfParametersForOperator(name, "a, b");
5953 } 6050 }
5954 } 6051 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/element_resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698