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 10022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10033 | 10033 |
10034 void test_parseArgumentList_trailing_comma() { | 10034 void test_parseArgumentList_trailing_comma() { |
10035 createParser('(x, y, z,)'); | 10035 createParser('(x, y, z,)'); |
10036 ArgumentList argumentList = parser.parseArgumentList(); | 10036 ArgumentList argumentList = parser.parseArgumentList(); |
10037 expectNotNullIfNoErrors(argumentList); | 10037 expectNotNullIfNoErrors(argumentList); |
10038 listener.assertNoErrors(); | 10038 listener.assertNoErrors(); |
10039 NodeList<Expression> arguments = argumentList.arguments; | 10039 NodeList<Expression> arguments = argumentList.arguments; |
10040 expect(arguments, hasLength(3)); | 10040 expect(arguments, hasLength(3)); |
10041 } | 10041 } |
10042 | 10042 |
| 10043 void test_parseClassMember_field_gftType_noReturnType() { |
| 10044 createParser(''' |
| 10045 Function(int, String) v; |
| 10046 '''); |
| 10047 ClassMember member = parser.parseClassMember('C'); |
| 10048 listener.assertNoErrors(); |
| 10049 expect(member, new isInstanceOf<FieldDeclaration>()); |
| 10050 VariableDeclarationList fields = (member as FieldDeclaration).fields; |
| 10051 expect(fields.type, new isInstanceOf<GenericFunctionType>()); |
| 10052 } |
| 10053 |
10043 void test_parseClassMember_method_gftReturnType() { | 10054 void test_parseClassMember_method_gftReturnType() { |
10044 createParser(''' | 10055 createParser(''' |
10045 void Function<A>(core.List<core.int> x) m() => null; | 10056 void Function<A>(core.List<core.int> x) m() => null; |
10046 '''); | 10057 '''); |
10047 ClassMember member = parser.parseClassMember('C'); | 10058 ClassMember member = parser.parseClassMember('C'); |
| 10059 listener.assertNoErrors(); |
10048 expect(member, new isInstanceOf<MethodDeclaration>()); | 10060 expect(member, new isInstanceOf<MethodDeclaration>()); |
10049 expect((member as MethodDeclaration).body, | 10061 expect((member as MethodDeclaration).body, |
10050 new isInstanceOf<ExpressionFunctionBody>()); | 10062 new isInstanceOf<ExpressionFunctionBody>()); |
10051 } | 10063 } |
10052 | 10064 |
10053 void test_parseClassMember_method_noReturnType() { | 10065 void test_parseClassMember_method_noReturnType() { |
10054 createParser(''' | 10066 createParser(''' |
10055 Function<A>(core.List<core.int> x) m() => null; | 10067 Function<A>(core.List<core.int> x) m() => null; |
10056 '''); | 10068 '''); |
10057 ClassMember member = parser.parseClassMember('C'); | 10069 ClassMember member = parser.parseClassMember('C'); |
| 10070 listener.assertNoErrors(); |
10058 expect(member, new isInstanceOf<MethodDeclaration>()); | 10071 expect(member, new isInstanceOf<MethodDeclaration>()); |
10059 expect((member as MethodDeclaration).body, | 10072 expect((member as MethodDeclaration).body, |
10060 new isInstanceOf<ExpressionFunctionBody>()); | 10073 new isInstanceOf<ExpressionFunctionBody>()); |
10061 } | 10074 } |
10062 | 10075 |
10063 void test_parseCombinator_hide() { | 10076 void test_parseCombinator_hide() { |
10064 createParser('hide a;'); | 10077 createParser('hide a;'); |
10065 Combinator combinator = parser.parseCombinator(); | 10078 Combinator combinator = parser.parseCombinator(); |
10066 expectNotNullIfNoErrors(combinator); | 10079 expectNotNullIfNoErrors(combinator); |
10067 listener.assertNoErrors(); | 10080 listener.assertNoErrors(); |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10658 expect(reference, isNotNull); | 10671 expect(reference, isNotNull); |
10659 expect(reference.identifier, isNotNull); | 10672 expect(reference.identifier, isNotNull); |
10660 expect(reference.offset, 15); | 10673 expect(reference.offset, 15); |
10661 } | 10674 } |
10662 | 10675 |
10663 void test_parseCompilationUnitMember_function_gftReturnType() { | 10676 void test_parseCompilationUnitMember_function_gftReturnType() { |
10664 createParser(''' | 10677 createParser(''' |
10665 void Function<A>(core.List<core.int> x) f() => null; | 10678 void Function<A>(core.List<core.int> x) f() => null; |
10666 '''); | 10679 '''); |
10667 CompilationUnit unit = parser.parseCompilationUnit2(); | 10680 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 10681 listener.assertNoErrors(); |
10668 expect(unit, isNotNull); | 10682 expect(unit, isNotNull); |
10669 expect(unit.declarations, hasLength(1)); | 10683 expect(unit.declarations, hasLength(1)); |
10670 } | 10684 } |
10671 | 10685 |
10672 void test_parseCompilationUnitMember_function_noReturnType() { | 10686 void test_parseCompilationUnitMember_function_noReturnType() { |
10673 createParser(''' | 10687 createParser(''' |
10674 Function<A>(core.List<core.int> x) f() => null; | 10688 Function<A>(core.List<core.int> x) f() => null; |
10675 '''); | 10689 '''); |
10676 CompilationUnit unit = parser.parseCompilationUnit2(); | 10690 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 10691 listener.assertNoErrors(); |
10677 expect(unit, isNotNull); | 10692 expect(unit, isNotNull); |
10678 expect(unit.declarations, hasLength(1)); | 10693 expect(unit.declarations, hasLength(1)); |
10679 } | 10694 } |
| 10695 |
| 10696 void test_parseCompilationUnitMember_variable_gftType_noReturnType() { |
| 10697 createParser(''' |
| 10698 Function(int, String) v; |
| 10699 '''); |
| 10700 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 10701 listener.assertNoErrors(); |
| 10702 expect(unit, isNotNull); |
| 10703 expect(unit.declarations, hasLength(1)); |
| 10704 } |
10680 | 10705 |
10681 void test_parseConfiguration_noOperator_dottedIdentifier() { | 10706 void test_parseConfiguration_noOperator_dottedIdentifier() { |
10682 createParser("if (a.b) 'c.dart'"); | 10707 createParser("if (a.b) 'c.dart'"); |
10683 Configuration configuration = parser.parseConfiguration(); | 10708 Configuration configuration = parser.parseConfiguration(); |
10684 expectNotNullIfNoErrors(configuration); | 10709 expectNotNullIfNoErrors(configuration); |
10685 listener.assertNoErrors(); | 10710 listener.assertNoErrors(); |
10686 expect(configuration.ifKeyword, isNotNull); | 10711 expect(configuration.ifKeyword, isNotNull); |
10687 expect(configuration.leftParenthesis, isNotNull); | 10712 expect(configuration.leftParenthesis, isNotNull); |
10688 expectDottedName(configuration.name, ["a", "b"]); | 10713 expectDottedName(configuration.name, ["a", "b"]); |
10689 expect(configuration.equalToken, isNull); | 10714 expect(configuration.equalToken, isNull); |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11271 } | 11296 } |
11272 | 11297 |
11273 void test_parseModifiers_var() { | 11298 void test_parseModifiers_var() { |
11274 createParser('var A'); | 11299 createParser('var A'); |
11275 Modifiers modifiers = parser.parseModifiers(); | 11300 Modifiers modifiers = parser.parseModifiers(); |
11276 expectNotNullIfNoErrors(modifiers); | 11301 expectNotNullIfNoErrors(modifiers); |
11277 listener.assertNoErrors(); | 11302 listener.assertNoErrors(); |
11278 expect(modifiers.varKeyword, isNotNull); | 11303 expect(modifiers.varKeyword, isNotNull); |
11279 } | 11304 } |
11280 | 11305 |
| 11306 void test_parseNonLabeledStatement_localFunction_gftReturnType() { |
| 11307 createParser('int Function(int) f(String s) => null;'); |
| 11308 Statement statement = parser.parseNonLabeledStatement(); |
| 11309 expectNotNullIfNoErrors(statement); |
| 11310 listener.assertNoErrors(); |
| 11311 } |
| 11312 |
11281 void test_parseNonLabeledStatement_variableDeclaration_final_namedFunction() { | 11313 void test_parseNonLabeledStatement_variableDeclaration_final_namedFunction() { |
11282 createParser('final int Function = 0;'); | 11314 createParser('final int Function = 0;'); |
11283 Statement statement = parser.parseNonLabeledStatement(); | 11315 Statement statement = parser.parseNonLabeledStatement(); |
11284 expectNotNullIfNoErrors(statement); | 11316 expectNotNullIfNoErrors(statement); |
11285 listener.assertNoErrors(); | 11317 listener.assertNoErrors(); |
11286 } | 11318 } |
11287 | 11319 |
| 11320 void test_parseNonLabeledStatement_variableDeclaration_gftType() { |
| 11321 createParser('int Function(int) v;'); |
| 11322 Statement statement = parser.parseNonLabeledStatement(); |
| 11323 expectNotNullIfNoErrors(statement); |
| 11324 listener.assertNoErrors(); |
| 11325 } |
| 11326 |
| 11327 void |
| 11328 test_parseNonLabeledStatement_variableDeclaration_gftType_noReturnType() { |
| 11329 createParser('Function(int) v;'); |
| 11330 Statement statement = parser.parseNonLabeledStatement(); |
| 11331 expectNotNullIfNoErrors(statement); |
| 11332 listener.assertNoErrors(); |
| 11333 } |
| 11334 |
11288 void test_parseOptionalReturnType() { | 11335 void test_parseOptionalReturnType() { |
11289 // TODO(brianwilkerson) Implement tests for this method. | 11336 // TODO(brianwilkerson) Implement tests for this method. |
11290 } | 11337 } |
11291 | 11338 |
11292 void test_Parser() { | 11339 void test_Parser() { |
11293 expect(new Parser(null, null), isNotNull); | 11340 expect(new Parser(null, null), isNotNull); |
11294 } | 11341 } |
11295 | 11342 |
11296 void test_parseReturnStatement_noValue() { | 11343 void test_parseReturnStatement_noValue() { |
11297 createParser('return;'); | 11344 createParser('return;'); |
(...skipping 3518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14816 expectCommentText(typeVariable.documentationComment, '/// Doc'); | 14863 expectCommentText(typeVariable.documentationComment, '/// Doc'); |
14817 } | 14864 } |
14818 | 14865 |
14819 /** | 14866 /** |
14820 * Assert that the given [name] is in declaration context. | 14867 * Assert that the given [name] is in declaration context. |
14821 */ | 14868 */ |
14822 void _assertIsDeclarationName(SimpleIdentifier name) { | 14869 void _assertIsDeclarationName(SimpleIdentifier name) { |
14823 expect(name.inDeclarationContext(), isTrue); | 14870 expect(name.inDeclarationContext(), isTrue); |
14824 } | 14871 } |
14825 } | 14872 } |
OLD | NEW |