| 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 analyzer.test.generated.parser_test; | 5 library analyzer.test.generated.parser_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; | 8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
| 9 import 'package:analyzer/dart/ast/token.dart'; | 9 import 'package:analyzer/dart/ast/token.dart'; |
| 10 import 'package:analyzer/dart/ast/visitor.dart'; | 10 import 'package:analyzer/dart/ast/visitor.dart'; |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 } | 888 } |
| 889 | 889 |
| 890 void test_covariantConstructor() { | 890 void test_covariantConstructor() { |
| 891 createParser('class C { covariant C(); }'); | 891 createParser('class C { covariant C(); }'); |
| 892 ClassDeclaration member = | 892 ClassDeclaration member = |
| 893 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); | 893 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); |
| 894 expectNotNullIfNoErrors(member); | 894 expectNotNullIfNoErrors(member); |
| 895 listener.assertErrorsWithCodes([ParserErrorCode.COVARIANT_CONSTRUCTOR]); | 895 listener.assertErrorsWithCodes([ParserErrorCode.COVARIANT_CONSTRUCTOR]); |
| 896 } | 896 } |
| 897 | 897 |
| 898 void test_covariantMember_getter_noReturnType() { |
| 899 createParser('static covariant get x => 0;'); |
| 900 ClassMember member = parser.parseClassMember('C'); |
| 901 expectNotNullIfNoErrors(member); |
| 902 listener.assertErrorsWithCodes([ParserErrorCode.COVARIANT_MEMBER]); |
| 903 } |
| 904 |
| 905 void test_covariantMember_getter_returnType() { |
| 906 createParser('static covariant int get x => 0;'); |
| 907 ClassMember member = parser.parseClassMember('C'); |
| 908 expectNotNullIfNoErrors(member); |
| 909 listener.assertErrorsWithCodes([ParserErrorCode.COVARIANT_MEMBER]); |
| 910 } |
| 911 |
| 912 void test_covariantMember_method() { |
| 913 createParser('covariant int m() => 0;'); |
| 914 ClassMember member = parser.parseClassMember('C'); |
| 915 expectNotNullIfNoErrors(member); |
| 916 listener.assertErrorsWithCodes([ParserErrorCode.COVARIANT_MEMBER]); |
| 917 } |
| 918 |
| 898 void test_covariantTopLevelDeclaration_class() { | 919 void test_covariantTopLevelDeclaration_class() { |
| 899 createParser('covariant class C {}'); | 920 createParser('covariant class C {}'); |
| 900 ClassDeclaration member = | 921 ClassDeclaration member = |
| 901 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); | 922 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); |
| 902 expectNotNullIfNoErrors(member); | 923 expectNotNullIfNoErrors(member); |
| 903 listener.assertErrorsWithCodes( | 924 listener.assertErrorsWithCodes( |
| 904 [ParserErrorCode.COVARIANT_TOP_LEVEL_DECLARATION]); | 925 [ParserErrorCode.COVARIANT_TOP_LEVEL_DECLARATION]); |
| 905 } | 926 } |
| 906 | 927 |
| 907 void test_covariantTopLevelDeclaration_enum() { | 928 void test_covariantTopLevelDeclaration_enum() { |
| (...skipping 10764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11672 NormalFormalParameter parameter = parser.parseNormalFormalParameter(); | 11693 NormalFormalParameter parameter = parser.parseNormalFormalParameter(); |
| 11673 expectNotNullIfNoErrors(parameter); | 11694 expectNotNullIfNoErrors(parameter); |
| 11674 listener.assertNoErrors(); | 11695 listener.assertNoErrors(); |
| 11675 expect(parameter, new isInstanceOf<SimpleFormalParameter>()); | 11696 expect(parameter, new isInstanceOf<SimpleFormalParameter>()); |
| 11676 SimpleFormalParameter simpleParameter = parameter; | 11697 SimpleFormalParameter simpleParameter = parameter; |
| 11677 expect(simpleParameter.keyword, isNull); | 11698 expect(simpleParameter.keyword, isNull); |
| 11678 expect(simpleParameter.type, isNull); | 11699 expect(simpleParameter.type, isNull); |
| 11679 expect(simpleParameter.identifier, isNotNull); | 11700 expect(simpleParameter.identifier, isNotNull); |
| 11680 } | 11701 } |
| 11681 | 11702 |
| 11703 void test_parseNormalFormalParameter_simple_noType_namedCovariant() { |
| 11704 createParser('covariant)'); |
| 11705 NormalFormalParameter parameter = parser.parseNormalFormalParameter(); |
| 11706 expectNotNullIfNoErrors(parameter); |
| 11707 listener.assertNoErrors(); |
| 11708 expect(parameter, new isInstanceOf<SimpleFormalParameter>()); |
| 11709 SimpleFormalParameter simpleParameter = parameter; |
| 11710 expect(simpleParameter.covariantKeyword, isNull); |
| 11711 expect(simpleParameter.keyword, isNull); |
| 11712 expect(simpleParameter.type, isNull); |
| 11713 expect(simpleParameter.identifier, isNotNull); |
| 11714 } |
| 11715 |
| 11682 void test_parseNormalFormalParameter_simple_type() { | 11716 void test_parseNormalFormalParameter_simple_type() { |
| 11683 createParser('A a)'); | 11717 createParser('A a)'); |
| 11684 NormalFormalParameter parameter = parser.parseNormalFormalParameter(); | 11718 NormalFormalParameter parameter = parser.parseNormalFormalParameter(); |
| 11685 expectNotNullIfNoErrors(parameter); | 11719 expectNotNullIfNoErrors(parameter); |
| 11686 listener.assertNoErrors(); | 11720 listener.assertNoErrors(); |
| 11687 expect(parameter, new isInstanceOf<SimpleFormalParameter>()); | 11721 expect(parameter, new isInstanceOf<SimpleFormalParameter>()); |
| 11688 SimpleFormalParameter simpleParameter = parameter; | 11722 SimpleFormalParameter simpleParameter = parameter; |
| 11689 expect(simpleParameter.keyword, isNull); | 11723 expect(simpleParameter.keyword, isNull); |
| 11690 expect(simpleParameter.type, isNotNull); | 11724 expect(simpleParameter.type, isNotNull); |
| 11691 expect(simpleParameter.identifier, isNotNull); | 11725 expect(simpleParameter.identifier, isNotNull); |
| (...skipping 2875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14567 CompilationUnit _parseDirectives(String source, | 14601 CompilationUnit _parseDirectives(String source, |
| 14568 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { | 14602 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { |
| 14569 createParser(source); | 14603 createParser(source); |
| 14570 CompilationUnit unit = parser.parseDirectives2(); | 14604 CompilationUnit unit = parser.parseDirectives2(); |
| 14571 expect(unit, isNotNull); | 14605 expect(unit, isNotNull); |
| 14572 expect(unit.declarations, hasLength(0)); | 14606 expect(unit.declarations, hasLength(0)); |
| 14573 listener.assertErrorsWithCodes(errorCodes); | 14607 listener.assertErrorsWithCodes(errorCodes); |
| 14574 return unit; | 14608 return unit; |
| 14575 } | 14609 } |
| 14576 } | 14610 } |
| OLD | NEW |