| 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 24 matching lines...) Expand all Loading... |
| 35 defineReflectiveTests(StatementParserTest); | 35 defineReflectiveTests(StatementParserTest); |
| 36 defineReflectiveTests(TopLevelParserTest); | 36 defineReflectiveTests(TopLevelParserTest); |
| 37 }); | 37 }); |
| 38 } | 38 } |
| 39 | 39 |
| 40 /** | 40 /** |
| 41 * Abstract base class for parser tests, which does not make assumptions about | 41 * Abstract base class for parser tests, which does not make assumptions about |
| 42 * which parser is used. | 42 * which parser is used. |
| 43 */ | 43 */ |
| 44 abstract class AbstractParserTestCase implements ParserTestHelpers { | 44 abstract class AbstractParserTestCase implements ParserTestHelpers { |
| 45 bool get allowNativeClause; |
| 46 |
| 45 void set enableAssertInitializer(bool value); | 47 void set enableAssertInitializer(bool value); |
| 46 | 48 |
| 47 void set enableGenericMethodComments(bool value); | 49 void set enableGenericMethodComments(bool value); |
| 48 | 50 |
| 49 void set enableLazyAssignmentOperators(bool value); | 51 void set enableLazyAssignmentOperators(bool value); |
| 50 | 52 |
| 51 void set enableNnbd(bool value); | 53 void set enableNnbd(bool value); |
| 52 | 54 |
| 53 /** | 55 /** |
| 54 * Set a flag indicating whether the parser is to parse part-of directives | 56 * Set a flag indicating whether the parser is to parse part-of directives |
| (...skipping 8222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8277 * analyzer parser. | 8279 * analyzer parser. |
| 8278 */ | 8280 */ |
| 8279 class ParserTestCase extends EngineTestCase | 8281 class ParserTestCase extends EngineTestCase |
| 8280 with ParserTestHelpers | 8282 with ParserTestHelpers |
| 8281 implements AbstractParserTestCase { | 8283 implements AbstractParserTestCase { |
| 8282 /** | 8284 /** |
| 8283 * A flag indicating whether parser is to parse function bodies. | 8285 * A flag indicating whether parser is to parse function bodies. |
| 8284 */ | 8286 */ |
| 8285 static bool parseFunctionBodies = true; | 8287 static bool parseFunctionBodies = true; |
| 8286 | 8288 |
| 8289 @override |
| 8290 bool allowNativeClause = true; |
| 8291 |
| 8287 /** | 8292 /** |
| 8288 * A flag indicating whether the parser is to parse asserts in the initializer | 8293 * A flag indicating whether the parser is to parse asserts in the initializer |
| 8289 * list of a constructor. | 8294 * list of a constructor. |
| 8290 */ | 8295 */ |
| 8291 bool enableAssertInitializer = false; | 8296 bool enableAssertInitializer = false; |
| 8292 | 8297 |
| 8293 /** | 8298 /** |
| 8294 * A flag indicating whether parser is to parse async. | 8299 * A flag indicating whether parser is to parse async. |
| 8295 */ | 8300 */ |
| 8296 bool parseAsync = true; | 8301 bool parseAsync = true; |
| (...skipping 5505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13802 expect(annotation.constructorName.name, 'bar'); | 13807 expect(annotation.constructorName.name, 'bar'); |
| 13803 expect(annotation.arguments, isNotNull); | 13808 expect(annotation.arguments, isNotNull); |
| 13804 expect(annotation.arguments.arguments, hasLength(2)); | 13809 expect(annotation.arguments.arguments, hasLength(2)); |
| 13805 } | 13810 } |
| 13806 } | 13811 } |
| 13807 | 13812 |
| 13808 void test_parseClassDeclaration_native() { | 13813 void test_parseClassDeclaration_native() { |
| 13809 createParser('class A native "nativeValue" {}'); | 13814 createParser('class A native "nativeValue" {}'); |
| 13810 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13815 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13811 expect(member, isNotNull); | 13816 expect(member, isNotNull); |
| 13812 assertNoErrors(); | 13817 if (!allowNativeClause) { |
| 13818 assertErrorsWithCodes([ |
| 13819 ParserErrorCode.NATIVE_CLAUSE_SHOULD_BE_ANNOTATION, |
| 13820 ]); |
| 13821 } else { |
| 13822 assertNoErrors(); |
| 13823 } |
| 13813 expect(member, new isInstanceOf<ClassDeclaration>()); | 13824 expect(member, new isInstanceOf<ClassDeclaration>()); |
| 13814 ClassDeclaration declaration = member; | 13825 ClassDeclaration declaration = member; |
| 13815 NativeClause nativeClause = declaration.nativeClause; | 13826 NativeClause nativeClause = declaration.nativeClause; |
| 13816 expect(nativeClause, isNotNull); | 13827 expect(nativeClause, isNotNull); |
| 13817 expect(nativeClause.nativeKeyword, isNotNull); | 13828 expect(nativeClause.nativeKeyword, isNotNull); |
| 13818 expect(nativeClause.name.stringValue, "nativeValue"); | 13829 expect(nativeClause.name.stringValue, "nativeValue"); |
| 13819 expect(nativeClause.beginToken, same(nativeClause.nativeKeyword)); | 13830 expect(nativeClause.beginToken, same(nativeClause.nativeKeyword)); |
| 13820 expect(nativeClause.endToken, same(nativeClause.name.endToken)); | 13831 expect(nativeClause.endToken, same(nativeClause.name.endToken)); |
| 13821 } | 13832 } |
| 13822 | 13833 |
| (...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15433 expectCommentText(typeVariable.documentationComment, '/// Doc'); | 15444 expectCommentText(typeVariable.documentationComment, '/// Doc'); |
| 15434 } | 15445 } |
| 15435 | 15446 |
| 15436 /** | 15447 /** |
| 15437 * Assert that the given [name] is in declaration context. | 15448 * Assert that the given [name] is in declaration context. |
| 15438 */ | 15449 */ |
| 15439 void _assertIsDeclarationName(SimpleIdentifier name) { | 15450 void _assertIsDeclarationName(SimpleIdentifier name) { |
| 15440 expect(name.inDeclarationContext(), isTrue); | 15451 expect(name.inDeclarationContext(), isTrue); |
| 15441 } | 15452 } |
| 15442 } | 15453 } |
| OLD | NEW |