| 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 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 ClassMember member = parser.parseClassMember('C'); | 933 ClassMember member = parser.parseClassMember('C'); |
| 934 assertNoErrors(); | 934 assertNoErrors(); |
| 935 expect(member, new isInstanceOf<MethodDeclaration>()); | 935 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 936 expect((member as MethodDeclaration).body, | 936 expect((member as MethodDeclaration).body, |
| 937 new isInstanceOf<ExpressionFunctionBody>()); | 937 new isInstanceOf<ExpressionFunctionBody>()); |
| 938 } | 938 } |
| 939 | 939 |
| 940 void test_parseClassMember_method_native() { | 940 void test_parseClassMember_method_native() { |
| 941 createParser('m() native "str";'); | 941 createParser('m() native "str";'); |
| 942 var method = parser.parseClassMember('C') as MethodDeclaration; | 942 var method = parser.parseClassMember('C') as MethodDeclaration; |
| 943 assertNoErrors(); | 943 if (!allowNativeClause) { |
| 944 assertErrorsWithCodes([ |
| 945 ParserErrorCode.NATIVE_CLAUSE_SHOULD_BE_ANNOTATION, |
| 946 ]); |
| 947 } else { |
| 948 assertNoErrors(); |
| 949 } |
| 944 | 950 |
| 945 var body = method.body as NativeFunctionBody; | 951 var body = method.body as NativeFunctionBody; |
| 946 expect(body.nativeKeyword, isNotNull); | 952 expect(body.nativeKeyword, isNotNull); |
| 947 expect(body.stringLiteral, isNotNull); | 953 expect(body.stringLiteral, isNotNull); |
| 954 expect(body.stringLiteral?.stringValue, "str"); |
| 948 expect(body.semicolon, isNotNull); | 955 expect(body.semicolon, isNotNull); |
| 949 } | 956 } |
| 950 | 957 |
| 951 void test_parseClassMember_method_operator_noType() { | 958 void test_parseClassMember_method_operator_noType() { |
| 952 createParser('operator() {}'); | 959 createParser('operator() {}'); |
| 953 ClassMember member = parser.parseClassMember('C'); | 960 ClassMember member = parser.parseClassMember('C'); |
| 954 expect(member, isNotNull); | 961 expect(member, isNotNull); |
| 955 assertNoErrors(); | 962 assertNoErrors(); |
| 956 expect(member, new isInstanceOf<MethodDeclaration>()); | 963 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 957 MethodDeclaration method = member; | 964 MethodDeclaration method = member; |
| (...skipping 14509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15467 expectCommentText(typeVariable.documentationComment, '/// Doc'); | 15474 expectCommentText(typeVariable.documentationComment, '/// Doc'); |
| 15468 } | 15475 } |
| 15469 | 15476 |
| 15470 /** | 15477 /** |
| 15471 * Assert that the given [name] is in declaration context. | 15478 * Assert that the given [name] is in declaration context. |
| 15472 */ | 15479 */ |
| 15473 void _assertIsDeclarationName(SimpleIdentifier name) { | 15480 void _assertIsDeclarationName(SimpleIdentifier name) { |
| 15474 expect(name.inDeclarationContext(), isTrue); | 15481 expect(name.inDeclarationContext(), isTrue); |
| 15475 } | 15482 } |
| 15476 } | 15483 } |
| OLD | NEW |