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

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

Issue 1173523002: Fix analyzer's handling of import prefixes not followed by '.'. (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
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/error.dart'; 8 import 'package:analyzer/src/generated/error.dart';
8 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; 9 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode;
9 import 'package:analyzer/src/generated/source_io.dart'; 10 import 'package:analyzer/src/generated/source_io.dart';
10 import 'package:unittest/unittest.dart' as _ut; 11 import 'package:unittest/unittest.dart' as _ut;
11 12
12 import '../reflective_tests.dart'; 13 import '../reflective_tests.dart';
13 import 'resolver_test.dart'; 14 import 'resolver_test.dart';
14 15
15 main() { 16 main() {
16 _ut.groupSep = ' | '; 17 _ut.groupSep = ' | ';
(...skipping 4542 matching lines...) Expand 10 before | Expand all | Expand 10 after
4559 void test_partOfNonPart() { 4560 void test_partOfNonPart() {
4560 Source source = addSource(r''' 4561 Source source = addSource(r'''
4561 library l1; 4562 library l1;
4562 part 'l2.dart';'''); 4563 part 'l2.dart';''');
4563 addNamedSource("/l2.dart", "library l2;"); 4564 addNamedSource("/l2.dart", "library l2;");
4564 resolve(source); 4565 resolve(source);
4565 assertErrors(source, [CompileTimeErrorCode.PART_OF_NON_PART]); 4566 assertErrors(source, [CompileTimeErrorCode.PART_OF_NON_PART]);
4566 verify([source]); 4567 verify([source]);
4567 } 4568 }
4568 4569
4570 void test_prefix_conditionalPropertyAccess_call() {
4571 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
4572 options.enableNullAwareOperators = true;
4573 resetWithOptions(options);
4574 addNamedSource('/lib.dart', '''
4575 library lib;
4576 g() {}
4577 ''');
4578 Source source = addSource('''
4579 import 'lib.dart' as p;
4580 f() {
4581 p?.g();
4582 }
4583 ''');
4584 resolve(source);
4585 assertErrors(
4586 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4587 verify([source]);
4588 }
4589
4569 void test_prefixCollidesWithTopLevelMembers_functionTypeAlias() { 4590 void test_prefixCollidesWithTopLevelMembers_functionTypeAlias() {
4570 addNamedSource("/lib.dart", r''' 4591 addNamedSource("/lib.dart", r'''
4571 library lib; 4592 library lib;
4572 class A{}'''); 4593 class A{}''');
4573 Source source = addSource(r''' 4594 Source source = addSource(r'''
4574 import 'lib.dart' as p; 4595 import 'lib.dart' as p;
4575 typedef p(); 4596 typedef p();
4576 p.A a;'''); 4597 p.A a;''');
4577 resolve(source); 4598 resolve(source);
4578 assertErrors( 4599 assertErrors(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
4615 Source source = addSource(r''' 4636 Source source = addSource(r'''
4616 import 'lib.dart' as p; 4637 import 'lib.dart' as p;
4617 class p {} 4638 class p {}
4618 p.A a;'''); 4639 p.A a;''');
4619 resolve(source); 4640 resolve(source);
4620 assertErrors( 4641 assertErrors(
4621 source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]); 4642 source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]);
4622 verify([source]); 4643 verify([source]);
4623 } 4644 }
4624 4645
4646 void test_prefixNotFollowedByDot() {
4647 addNamedSource('/lib.dart', 'library lib;');
4648 Source source = addSource('''
4649 import 'lib.dart' as p;
4650 f() {
4651 return p;
4652 }
4653 ''');
4654 resolve(source);
4655 assertErrors(
4656 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4657 verify([source]);
4658 }
4659
4660 void test_prefixNotFollowedByDot_compoundAssignment() {
4661 addNamedSource('/lib.dart', 'library lib;');
4662 Source source = addSource('''
4663 import 'lib.dart' as p;
4664 f() {
4665 p += 1;
4666 }
4667 ''');
4668 resolve(source);
4669 assertErrors(
4670 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4671 verify([source]);
4672 }
4673
4674 void test_prefixNotFollowedByDot_conditionalMethodInvocation() {
4675 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
4676 options.enableNullAwareOperators = true;
4677 resetWithOptions(options);
4678 addNamedSource('/lib.dart', '''
4679 library lib;
4680 g() {}
4681 ''');
4682 Source source = addSource('''
4683 import 'lib.dart' as p;
4684 f() {
4685 p?.g();
4686 }
4687 ''');
4688 resolve(source);
4689 assertErrors(
4690 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
4691 verify([source]);
4692 }
4693
4625 void test_privateOptionalParameter() { 4694 void test_privateOptionalParameter() {
4626 Source source = addSource("f({var _p}) {}"); 4695 Source source = addSource("f({var _p}) {}");
4627 resolve(source); 4696 resolve(source);
4628 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]); 4697 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]);
4629 verify([source]); 4698 verify([source]);
4630 } 4699 }
4631 4700
4632 void test_privateOptionalParameter_fieldFormal() { 4701 void test_privateOptionalParameter_fieldFormal() {
4633 Source source = addSource(r''' 4702 Source source = addSource(r'''
4634 class A { 4703 class A {
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after
5740 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); 5809 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]);
5741 verify([source]); 5810 verify([source]);
5742 reset(); 5811 reset();
5743 } 5812 }
5744 5813
5745 void _check_wrongNumberOfParametersForOperator1(String name) { 5814 void _check_wrongNumberOfParametersForOperator1(String name) {
5746 _check_wrongNumberOfParametersForOperator(name, ""); 5815 _check_wrongNumberOfParametersForOperator(name, "");
5747 _check_wrongNumberOfParametersForOperator(name, "a, b"); 5816 _check_wrongNumberOfParametersForOperator(name, "a, b");
5748 } 5817 }
5749 } 5818 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/error.dart ('k') | pkg/analyzer/test/generated/non_error_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698