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 import 'package:analyzer/dart/ast/ast.dart'; | 5 import 'package:analyzer/dart/ast/ast.dart'; |
6 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; | 6 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
7 import 'package:analyzer/dart/ast/token.dart'; | 7 import 'package:analyzer/dart/ast/token.dart'; |
8 import 'package:analyzer/dart/ast/visitor.dart'; | 8 import 'package:analyzer/dart/ast/visitor.dart'; |
9 import 'package:analyzer/error/error.dart'; | 9 import 'package:analyzer/error/error.dart'; |
10 import 'package:analyzer/error/listener.dart'; | 10 import 'package:analyzer/error/listener.dart'; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 void set enableUriInPartOf(bool value); | 56 void set enableUriInPartOf(bool value); |
57 | 57 |
58 /** | 58 /** |
59 * Get the parser used by the test. | 59 * Get the parser used by the test. |
60 * | 60 * |
61 * Caller must first invoke [createParser]. | 61 * Caller must first invoke [createParser]. |
62 */ | 62 */ |
63 Parser get parser; | 63 Parser get parser; |
64 | 64 |
65 /** | 65 /** |
| 66 * Flag indicating whether the fasta parser is being used. |
| 67 */ |
| 68 bool get usingFasta; |
| 69 |
| 70 /** |
66 * Assert that the number and codes of errors occurred during parsing is the | 71 * Assert that the number and codes of errors occurred during parsing is the |
67 * same as the [expectedErrorCodes]. | 72 * same as the [expectedErrorCodes]. |
68 */ | 73 */ |
69 void assertErrorsWithCodes(List<ErrorCode> expectedErrorCodes); | 74 void assertErrorsWithCodes(List<ErrorCode> expectedErrorCodes); |
70 | 75 |
71 /** | 76 /** |
72 * Asserts that no errors occurred during parsing. | 77 * Asserts that no errors occurred during parsing. |
73 */ | 78 */ |
74 void assertNoErrors(); | 79 void assertNoErrors(); |
75 | 80 |
(...skipping 8050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8126 GatheringErrorListener listener; | 8131 GatheringErrorListener listener; |
8127 | 8132 |
8128 /** | 8133 /** |
8129 * The parser used by the test. | 8134 * The parser used by the test. |
8130 * | 8135 * |
8131 * This field is typically initialized by invoking [createParser]. | 8136 * This field is typically initialized by invoking [createParser]. |
8132 */ | 8137 */ |
8133 Parser parser; | 8138 Parser parser; |
8134 | 8139 |
8135 @override | 8140 @override |
| 8141 bool get usingFasta => Parser.useFasta; |
| 8142 |
| 8143 @override |
8136 void assertErrorsWithCodes(List<ErrorCode> expectedErrorCodes) { | 8144 void assertErrorsWithCodes(List<ErrorCode> expectedErrorCodes) { |
8137 listener.assertErrorsWithCodes(expectedErrorCodes); | 8145 listener.assertErrorsWithCodes(expectedErrorCodes); |
8138 } | 8146 } |
8139 | 8147 |
8140 @override | 8148 @override |
8141 void assertNoErrors() { | 8149 void assertNoErrors() { |
8142 listener.assertNoErrors(); | 8150 listener.assertNoErrors(); |
8143 } | 8151 } |
8144 | 8152 |
8145 /** | 8153 /** |
(...skipping 5498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13644 expectCommentText(classDeclaration.documentationComment, '/// Doc'); | 13652 expectCommentText(classDeclaration.documentationComment, '/// Doc'); |
13645 } | 13653 } |
13646 | 13654 |
13647 void test_parseClassTypeAlias_withDocumentationComment() { | 13655 void test_parseClassTypeAlias_withDocumentationComment() { |
13648 createParser('/// Doc\nclass C = D with E;'); | 13656 createParser('/// Doc\nclass C = D with E;'); |
13649 var classTypeAlias = parseFullCompilationUnitMember() as ClassTypeAlias; | 13657 var classTypeAlias = parseFullCompilationUnitMember() as ClassTypeAlias; |
13650 expectCommentText(classTypeAlias.documentationComment, '/// Doc'); | 13658 expectCommentText(classTypeAlias.documentationComment, '/// Doc'); |
13651 } | 13659 } |
13652 | 13660 |
13653 void test_parseCompilationUnit_abstractAsPrefix_parameterized() { | 13661 void test_parseCompilationUnit_abstractAsPrefix_parameterized() { |
13654 createParser('abstract<dynamic> _abstract = new abstract.A();'); | 13662 var errorCodes = <ErrorCode>[]; |
13655 CompilationUnit unit = parser.parseCompilationUnit2(); | 13663 if (usingFasta) { |
13656 expect(unit, isNotNull); | 13664 // built-in "abstract" cannot be used as a type |
13657 assertNoErrors(); | 13665 errorCodes.add(ParserErrorCode.EXPECTED_TYPE_NAME); |
| 13666 } |
| 13667 CompilationUnit unit = parseCompilationUnit( |
| 13668 'abstract<dynamic> _abstract = new abstract.A();', errorCodes); |
13658 expect(unit.scriptTag, isNull); | 13669 expect(unit.scriptTag, isNull); |
13659 expect(unit.directives, hasLength(0)); | 13670 expect(unit.directives, hasLength(0)); |
13660 expect(unit.declarations, hasLength(1)); | 13671 expect(unit.declarations, hasLength(1)); |
13661 } | 13672 } |
13662 | 13673 |
13663 void test_parseCompilationUnit_builtIn_asFunctionName() { | 13674 void test_parseCompilationUnit_builtIn_asFunctionName() { |
13664 parseCompilationUnit('abstract(x) => 0;'); | 13675 parseCompilationUnit('abstract(x) => 0;'); |
13665 parseCompilationUnit('as(x) => 0;'); | 13676 parseCompilationUnit('as(x) => 0;'); |
13666 parseCompilationUnit('dynamic(x) => 0;'); | 13677 parseCompilationUnit('dynamic(x) => 0;'); |
13667 parseCompilationUnit('export(x) => 0;'); | 13678 parseCompilationUnit('export(x) => 0;'); |
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15144 expectCommentText(typeVariable.documentationComment, '/// Doc'); | 15155 expectCommentText(typeVariable.documentationComment, '/// Doc'); |
15145 } | 15156 } |
15146 | 15157 |
15147 /** | 15158 /** |
15148 * Assert that the given [name] is in declaration context. | 15159 * Assert that the given [name] is in declaration context. |
15149 */ | 15160 */ |
15150 void _assertIsDeclarationName(SimpleIdentifier name) { | 15161 void _assertIsDeclarationName(SimpleIdentifier name) { |
15151 expect(name.inDeclarationContext(), isTrue); | 15162 expect(name.inDeclarationContext(), isTrue); |
15152 } | 15163 } |
15153 } | 15164 } |
OLD | NEW |