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 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 expect(method.modifierKeyword, isNull); | 777 expect(method.modifierKeyword, isNull); |
778 expect(method.propertyKeyword, isNull); | 778 expect(method.propertyKeyword, isNull); |
779 expect(method.returnType, isNotNull); | 779 expect(method.returnType, isNotNull); |
780 expect(method.name, isNotNull); | 780 expect(method.name, isNotNull); |
781 expect(method.operatorKeyword, isNull); | 781 expect(method.operatorKeyword, isNull); |
782 expect(method.typeParameters, isNull); | 782 expect(method.typeParameters, isNull); |
783 expect(method.parameters, isNotNull); | 783 expect(method.parameters, isNotNull); |
784 expect(method.body, isNotNull); | 784 expect(method.body, isNotNull); |
785 } | 785 } |
786 | 786 |
| 787 void test_parseClassMember_method_native() { |
| 788 createParser('m() native "str";'); |
| 789 var method = parser.parseClassMember('C') as MethodDeclaration; |
| 790 assertNoErrors(); |
| 791 |
| 792 var body = method.body as NativeFunctionBody; |
| 793 expect(body.nativeKeyword, isNotNull); |
| 794 expect(body.stringLiteral, isNotNull); |
| 795 expect(body.semicolon, isNotNull); |
| 796 } |
| 797 |
787 void test_parseClassMember_method_operator_noType() { | 798 void test_parseClassMember_method_operator_noType() { |
788 createParser('operator() {}'); | 799 createParser('operator() {}'); |
789 ClassMember member = parser.parseClassMember('C'); | 800 ClassMember member = parser.parseClassMember('C'); |
790 expect(member, isNotNull); | 801 expect(member, isNotNull); |
791 assertNoErrors(); | 802 assertNoErrors(); |
792 expect(member, new isInstanceOf<MethodDeclaration>()); | 803 expect(member, new isInstanceOf<MethodDeclaration>()); |
793 MethodDeclaration method = member; | 804 MethodDeclaration method = member; |
794 expect(method.documentationComment, isNull); | 805 expect(method.documentationComment, isNull); |
795 expect(method.externalKeyword, isNull); | 806 expect(method.externalKeyword, isNull); |
796 expect(method.modifierKeyword, isNull); | 807 expect(method.modifierKeyword, isNull); |
(...skipping 10252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11049 expect(body.keyword, isNotNull); | 11060 expect(body.keyword, isNotNull); |
11050 expect(body.keyword.lexeme, Parser.ASYNC); | 11061 expect(body.keyword.lexeme, Parser.ASYNC); |
11051 expect(body.functionDefinition, isNotNull); | 11062 expect(body.functionDefinition, isNotNull); |
11052 expect(body.expression, isNotNull); | 11063 expect(body.expression, isNotNull); |
11053 expect(body.semicolon, isNotNull); | 11064 expect(body.semicolon, isNotNull); |
11054 expect(body.isAsynchronous, isTrue); | 11065 expect(body.isAsynchronous, isTrue); |
11055 expect(body.isGenerator, isFalse); | 11066 expect(body.isGenerator, isFalse); |
11056 expect(body.isSynchronous, isFalse); | 11067 expect(body.isSynchronous, isFalse); |
11057 } | 11068 } |
11058 | 11069 |
11059 void test_parseFunctionBody_nativeFunctionBody() { | |
11060 createParser('native "str";'); | |
11061 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); | |
11062 expectNotNullIfNoErrors(functionBody); | |
11063 listener.assertNoErrors(); | |
11064 expect(functionBody, new isInstanceOf<NativeFunctionBody>()); | |
11065 NativeFunctionBody body = functionBody; | |
11066 expect(body.nativeKeyword, isNotNull); | |
11067 expect(body.stringLiteral, isNotNull); | |
11068 expect(body.semicolon, isNotNull); | |
11069 } | |
11070 | |
11071 void test_parseFunctionBody_skip_block() { | 11070 void test_parseFunctionBody_skip_block() { |
11072 ParserTestCase.parseFunctionBodies = false; | 11071 ParserTestCase.parseFunctionBodies = false; |
11073 createParser('{}'); | 11072 createParser('{}'); |
11074 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); | 11073 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); |
11075 expectNotNullIfNoErrors(functionBody); | 11074 expectNotNullIfNoErrors(functionBody); |
11076 listener.assertNoErrors(); | 11075 listener.assertNoErrors(); |
11077 expect(functionBody, new isInstanceOf<EmptyFunctionBody>()); | 11076 expect(functionBody, new isInstanceOf<EmptyFunctionBody>()); |
11078 } | 11077 } |
11079 | 11078 |
11080 void test_parseFunctionBody_skip_block_invalid() { | 11079 void test_parseFunctionBody_skip_block_invalid() { |
(...skipping 3649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14730 expectCommentText(typeVariable.documentationComment, '/// Doc'); | 14729 expectCommentText(typeVariable.documentationComment, '/// Doc'); |
14731 } | 14730 } |
14732 | 14731 |
14733 /** | 14732 /** |
14734 * Assert that the given [name] is in declaration context. | 14733 * Assert that the given [name] is in declaration context. |
14735 */ | 14734 */ |
14736 void _assertIsDeclarationName(SimpleIdentifier name) { | 14735 void _assertIsDeclarationName(SimpleIdentifier name) { |
14737 expect(name.inDeclarationContext(), isTrue); | 14736 expect(name.inDeclarationContext(), isTrue); |
14738 } | 14737 } |
14739 } | 14738 } |
OLD | NEW |