Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: pkg/analyzer/test/generated/parser_test.dart

Issue 3011643002: Fix several failing tests (Closed)
Patch Set: fix sort and metadata parsing Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 11119 matching lines...) Expand 10 before | Expand all | Expand 10 after
11130 void test_parseArgumentList_trailing_comma() { 11130 void test_parseArgumentList_trailing_comma() {
11131 createParser('(x, y, z,)'); 11131 createParser('(x, y, z,)');
11132 ArgumentList argumentList = parser.parseArgumentList(); 11132 ArgumentList argumentList = parser.parseArgumentList();
11133 expectNotNullIfNoErrors(argumentList); 11133 expectNotNullIfNoErrors(argumentList);
11134 listener.assertNoErrors(); 11134 listener.assertNoErrors();
11135 NodeList<Expression> arguments = argumentList.arguments; 11135 NodeList<Expression> arguments = argumentList.arguments;
11136 expect(arguments, hasLength(3)); 11136 expect(arguments, hasLength(3));
11137 } 11137 }
11138 11138
11139 void test_parseCombinator_hide() { 11139 void test_parseCombinator_hide() {
11140 createParser('hide a;'); 11140 createParser('hide a');
11141 Combinator combinator = parser.parseCombinator(); 11141 Combinator combinator = parser.parseCombinator();
11142 expectNotNullIfNoErrors(combinator); 11142 expectNotNullIfNoErrors(combinator);
11143 listener.assertNoErrors(); 11143 listener.assertNoErrors();
11144 expect(combinator, new isInstanceOf<HideCombinator>()); 11144 expect(combinator, new isInstanceOf<HideCombinator>());
11145 HideCombinator hideCombinator = combinator; 11145 HideCombinator hideCombinator = combinator;
11146 expect(hideCombinator.keyword, isNotNull); 11146 expect(hideCombinator.keyword, isNotNull);
11147 expect(hideCombinator.hiddenNames, hasLength(1)); 11147 expect(hideCombinator.hiddenNames, hasLength(1));
11148 } 11148 }
11149 11149
11150 void test_parseCombinator_show() { 11150 void test_parseCombinator_show() {
11151 createParser('show a;'); 11151 createParser('show a');
11152 Combinator combinator = parser.parseCombinator(); 11152 Combinator combinator = parser.parseCombinator();
11153 expectNotNullIfNoErrors(combinator); 11153 expectNotNullIfNoErrors(combinator);
11154 listener.assertNoErrors(); 11154 listener.assertNoErrors();
11155 expect(combinator, new isInstanceOf<ShowCombinator>()); 11155 expect(combinator, new isInstanceOf<ShowCombinator>());
11156 ShowCombinator showCombinator = combinator; 11156 ShowCombinator showCombinator = combinator;
11157 expect(showCombinator.keyword, isNotNull); 11157 expect(showCombinator.keyword, isNotNull);
11158 expect(showCombinator.shownNames, hasLength(1)); 11158 expect(showCombinator.shownNames, hasLength(1));
11159 } 11159 }
11160 11160
11161 void test_parseCombinators_h() { 11161 void test_parseCombinators_h() {
11162 createParser('hide a;'); 11162 createParser('hide a');
11163 List<Combinator> combinators = parser.parseCombinators(); 11163 List<Combinator> combinators = parser.parseCombinators();
11164 expectNotNullIfNoErrors(combinators); 11164 expectNotNullIfNoErrors(combinators);
11165 listener.assertNoErrors(); 11165 listener.assertNoErrors();
11166 expect(combinators, hasLength(1)); 11166 expect(combinators, hasLength(1));
11167 HideCombinator combinator = combinators[0] as HideCombinator; 11167 HideCombinator combinator = combinators[0] as HideCombinator;
11168 expect(combinator, isNotNull); 11168 expect(combinator, isNotNull);
11169 expect(combinator.keyword, isNotNull); 11169 expect(combinator.keyword, isNotNull);
11170 expect(combinator.hiddenNames, hasLength(1)); 11170 expect(combinator.hiddenNames, hasLength(1));
11171 } 11171 }
11172 11172
11173 void test_parseCombinators_hs() { 11173 void test_parseCombinators_hs() {
11174 createParser('hide a show b;'); 11174 createParser('hide a show b');
11175 List<Combinator> combinators = parser.parseCombinators(); 11175 List<Combinator> combinators = parser.parseCombinators();
11176 expectNotNullIfNoErrors(combinators); 11176 expectNotNullIfNoErrors(combinators);
11177 listener.assertNoErrors(); 11177 listener.assertNoErrors();
11178 expect(combinators, hasLength(2)); 11178 expect(combinators, hasLength(2));
11179 HideCombinator hideCombinator = combinators[0] as HideCombinator; 11179 HideCombinator hideCombinator = combinators[0] as HideCombinator;
11180 expect(hideCombinator, isNotNull); 11180 expect(hideCombinator, isNotNull);
11181 expect(hideCombinator.keyword, isNotNull); 11181 expect(hideCombinator.keyword, isNotNull);
11182 expect(hideCombinator.hiddenNames, hasLength(1)); 11182 expect(hideCombinator.hiddenNames, hasLength(1));
11183 ShowCombinator showCombinator = combinators[1] as ShowCombinator; 11183 ShowCombinator showCombinator = combinators[1] as ShowCombinator;
11184 expect(showCombinator, isNotNull); 11184 expect(showCombinator, isNotNull);
11185 expect(showCombinator.keyword, isNotNull); 11185 expect(showCombinator.keyword, isNotNull);
11186 expect(showCombinator.shownNames, hasLength(1)); 11186 expect(showCombinator.shownNames, hasLength(1));
11187 } 11187 }
11188 11188
11189 void test_parseCombinators_hshs() { 11189 void test_parseCombinators_hshs() {
11190 createParser('hide a show b hide c show d;'); 11190 createParser('hide a show b hide c show d');
11191 List<Combinator> combinators = parser.parseCombinators(); 11191 List<Combinator> combinators = parser.parseCombinators();
11192 expectNotNullIfNoErrors(combinators); 11192 expectNotNullIfNoErrors(combinators);
11193 listener.assertNoErrors(); 11193 listener.assertNoErrors();
11194 expect(combinators, hasLength(4)); 11194 expect(combinators, hasLength(4));
11195 } 11195 }
11196 11196
11197 void test_parseCombinators_s() { 11197 void test_parseCombinators_s() {
11198 createParser('show a;'); 11198 createParser('show a');
11199 List<Combinator> combinators = parser.parseCombinators(); 11199 List<Combinator> combinators = parser.parseCombinators();
11200 expectNotNullIfNoErrors(combinators); 11200 expectNotNullIfNoErrors(combinators);
11201 listener.assertNoErrors(); 11201 listener.assertNoErrors();
11202 expect(combinators, hasLength(1)); 11202 expect(combinators, hasLength(1));
11203 ShowCombinator combinator = combinators[0] as ShowCombinator; 11203 ShowCombinator combinator = combinators[0] as ShowCombinator;
11204 expect(combinator, isNotNull); 11204 expect(combinator, isNotNull);
11205 expect(combinator.keyword, isNotNull); 11205 expect(combinator.keyword, isNotNull);
11206 expect(combinator.shownNames, hasLength(1)); 11206 expect(combinator.shownNames, hasLength(1));
11207 } 11207 }
11208 11208
11209 void test_parseCommentAndMetadata_c() { 11209 void test_parseCommentAndMetadata_c() {
11210 createParser('/** 1 */ void'); 11210 createParser('/** 1 */');
11211 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); 11211 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata();
11212 expectNotNullIfNoErrors(commentAndMetadata); 11212 expectNotNullIfNoErrors(commentAndMetadata);
11213 listener.assertNoErrors(); 11213 listener.assertNoErrors();
11214 expect(commentAndMetadata.comment, isNotNull); 11214 expect(commentAndMetadata.comment, isNotNull);
11215 expect(commentAndMetadata.metadata, isNull); 11215 expect(commentAndMetadata.metadata, isNull);
11216 } 11216 }
11217 11217
11218 void test_parseCommentAndMetadata_cmc() { 11218 void test_parseCommentAndMetadata_cmc() {
11219 createParser('/** 1 */ @A /** 2 */ void'); 11219 createParser('/** 1 */ @A /** 2 */');
11220 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); 11220 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata();
11221 expectNotNullIfNoErrors(commentAndMetadata); 11221 expectNotNullIfNoErrors(commentAndMetadata);
11222 listener.assertNoErrors(); 11222 listener.assertNoErrors();
11223 expect(commentAndMetadata.comment, isNotNull); 11223 expect(commentAndMetadata.comment, isNotNull);
11224 expect(commentAndMetadata.metadata, hasLength(1)); 11224 expect(commentAndMetadata.metadata, hasLength(1));
11225 } 11225 }
11226 11226
11227 void test_parseCommentAndMetadata_cmcm() { 11227 void test_parseCommentAndMetadata_cmcm() {
11228 createParser('/** 1 */ @A /** 2 */ @B void'); 11228 createParser('/** 1 */ @A /** 2 */ @B');
11229 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); 11229 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata();
11230 expectNotNullIfNoErrors(commentAndMetadata); 11230 expectNotNullIfNoErrors(commentAndMetadata);
11231 listener.assertNoErrors(); 11231 listener.assertNoErrors();
11232 expect(commentAndMetadata.comment, isNotNull); 11232 expect(commentAndMetadata.comment, isNotNull);
11233 expect(commentAndMetadata.metadata, hasLength(2)); 11233 expect(commentAndMetadata.metadata, hasLength(2));
11234 } 11234 }
11235 11235
11236 void test_parseCommentAndMetadata_cmm() { 11236 void test_parseCommentAndMetadata_cmm() {
11237 createParser('/** 1 */ @A @B void'); 11237 createParser('/** 1 */ @A @B');
11238 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); 11238 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata();
11239 expectNotNullIfNoErrors(commentAndMetadata); 11239 expectNotNullIfNoErrors(commentAndMetadata);
11240 listener.assertNoErrors(); 11240 listener.assertNoErrors();
11241 expect(commentAndMetadata.comment, isNotNull); 11241 expect(commentAndMetadata.comment, isNotNull);
11242 expect(commentAndMetadata.metadata, hasLength(2)); 11242 expect(commentAndMetadata.metadata, hasLength(2));
11243 } 11243 }
11244 11244
11245 void test_parseCommentAndMetadata_m() { 11245 void test_parseCommentAndMetadata_m() {
11246 createParser('@A void'); 11246 createParser('@A');
11247 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); 11247 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata();
11248 expectNotNullIfNoErrors(commentAndMetadata); 11248 expectNotNullIfNoErrors(commentAndMetadata);
11249 listener.assertNoErrors(); 11249 listener.assertNoErrors();
11250 expect(commentAndMetadata.comment, isNull); 11250 expect(commentAndMetadata.comment, isNull);
11251 expect(commentAndMetadata.metadata, hasLength(1)); 11251 expect(commentAndMetadata.metadata, hasLength(1));
11252 } 11252 }
11253 11253
11254 void test_parseCommentAndMetadata_mcm() { 11254 void test_parseCommentAndMetadata_mcm() {
11255 createParser('@A /** 1 */ @B void'); 11255 createParser('@A /** 1 */ @B');
11256 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); 11256 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata();
11257 expectNotNullIfNoErrors(commentAndMetadata); 11257 expectNotNullIfNoErrors(commentAndMetadata);
11258 listener.assertNoErrors(); 11258 listener.assertNoErrors();
11259 expect(commentAndMetadata.comment, isNotNull); 11259 expect(commentAndMetadata.comment, isNotNull);
11260 expect(commentAndMetadata.metadata, hasLength(2)); 11260 expect(commentAndMetadata.metadata, hasLength(2));
11261 } 11261 }
11262 11262
11263 void test_parseCommentAndMetadata_mcmc() { 11263 void test_parseCommentAndMetadata_mcmc() {
11264 createParser('@A /** 1 */ @B /** 2 */ void'); 11264 createParser('@A /** 1 */ @B /** 2 */');
11265 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); 11265 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata();
11266 expectNotNullIfNoErrors(commentAndMetadata); 11266 expectNotNullIfNoErrors(commentAndMetadata);
11267 listener.assertNoErrors(); 11267 listener.assertNoErrors();
11268 expect(commentAndMetadata.comment, isNotNull); 11268 expect(commentAndMetadata.comment, isNotNull);
11269 expect(commentAndMetadata.metadata, hasLength(2)); 11269 expect(commentAndMetadata.metadata, hasLength(2));
11270 } 11270 }
11271 11271
11272 void test_parseCommentAndMetadata_mm() { 11272 void test_parseCommentAndMetadata_mm() {
11273 createParser('@A @B(x) void'); 11273 createParser('@A @B(x)');
11274 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); 11274 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata();
11275 expectNotNullIfNoErrors(commentAndMetadata); 11275 expectNotNullIfNoErrors(commentAndMetadata);
11276 listener.assertNoErrors(); 11276 listener.assertNoErrors();
11277 expect(commentAndMetadata.comment, isNull); 11277 expect(commentAndMetadata.comment, isNull);
11278 expect(commentAndMetadata.metadata, hasLength(2)); 11278 expect(commentAndMetadata.metadata, hasLength(2));
11279 } 11279 }
11280 11280
11281 void test_parseCommentAndMetadata_none() { 11281 void test_parseCommentAndMetadata_none() {
11282 createParser('void'); 11282 createParser('');
11283 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); 11283 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata();
11284 expectNotNullIfNoErrors(commentAndMetadata); 11284 expectNotNullIfNoErrors(commentAndMetadata);
11285 listener.assertNoErrors(); 11285 listener.assertNoErrors();
11286 expect(commentAndMetadata.comment, isNull); 11286 expect(commentAndMetadata.comment, isNull);
11287 expect(commentAndMetadata.metadata, isNull); 11287 expect(commentAndMetadata.metadata, isNull);
11288 } 11288 }
11289 11289
11290 void test_parseCommentAndMetadata_singleLine() { 11290 void test_parseCommentAndMetadata_singleLine() {
11291 createParser(r''' 11291 createParser(r'''
11292 /// 1 11292 /// 1
11293 /// 2 11293 /// 2
11294 void'''); 11294 ''');
11295 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); 11295 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata();
11296 expectNotNullIfNoErrors(commentAndMetadata); 11296 expectNotNullIfNoErrors(commentAndMetadata);
11297 listener.assertNoErrors(); 11297 listener.assertNoErrors();
11298 expect(commentAndMetadata.comment, isNotNull); 11298 expect(commentAndMetadata.comment, isNotNull);
11299 expect(commentAndMetadata.metadata, isNull); 11299 expect(commentAndMetadata.metadata, isNull);
11300 } 11300 }
11301 11301
11302 void test_parseConfiguration_noOperator_dottedIdentifier() { 11302 void test_parseConfiguration_noOperator_dottedIdentifier() {
11303 createParser("if (a.b) 'c.dart'"); 11303 createParser("if (a.b) 'c.dart'");
11304 Configuration configuration = parser.parseConfiguration(); 11304 Configuration configuration = parser.parseConfiguration();
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
11976 11976
11977 void test_parseStatements_multiple() { 11977 void test_parseStatements_multiple() {
11978 parseStatementList("return; return;", 2); 11978 parseStatementList("return; return;", 2);
11979 } 11979 }
11980 11980
11981 void test_parseStatements_single() { 11981 void test_parseStatements_single() {
11982 parseStatementList("return;", 1); 11982 parseStatementList("return;", 1);
11983 } 11983 }
11984 11984
11985 void test_parseTypeAnnotation_function_noReturnType_noParameters() { 11985 void test_parseTypeAnnotation_function_noReturnType_noParameters() {
11986 createParser('Function() v'); 11986 createParser('Function()');
11987 GenericFunctionType functionType = parser.parseTypeAnnotation(false); 11987 GenericFunctionType functionType = parser.parseTypeAnnotation(false);
11988 expectNotNullIfNoErrors(functionType); 11988 expectNotNullIfNoErrors(functionType);
11989 listener.assertNoErrors(); 11989 listener.assertNoErrors();
11990 expect(functionType.returnType, isNull); 11990 expect(functionType.returnType, isNull);
11991 expect(functionType.functionKeyword, isNotNull); 11991 expect(functionType.functionKeyword, isNotNull);
11992 expect(functionType.typeParameters, isNull); 11992 expect(functionType.typeParameters, isNull);
11993 FormalParameterList parameterList = functionType.parameters; 11993 FormalParameterList parameterList = functionType.parameters;
11994 expect(parameterList, isNotNull); 11994 expect(parameterList, isNotNull);
11995 expect(parameterList.parameters, hasLength(0)); 11995 expect(parameterList.parameters, hasLength(0));
11996 } 11996 }
11997 11997
11998 void test_parseTypeAnnotation_function_noReturnType_parameters() { 11998 void test_parseTypeAnnotation_function_noReturnType_parameters() {
11999 createParser('Function(int, int) v'); 11999 createParser('Function(int, int)');
12000 GenericFunctionType functionType = parser.parseTypeAnnotation(false); 12000 GenericFunctionType functionType = parser.parseTypeAnnotation(false);
12001 expectNotNullIfNoErrors(functionType); 12001 expectNotNullIfNoErrors(functionType);
12002 listener.assertNoErrors(); 12002 listener.assertNoErrors();
12003 expect(functionType.returnType, isNull); 12003 expect(functionType.returnType, isNull);
12004 expect(functionType.functionKeyword, isNotNull); 12004 expect(functionType.functionKeyword, isNotNull);
12005 expect(functionType.typeParameters, isNull); 12005 expect(functionType.typeParameters, isNull);
12006 FormalParameterList parameterList = functionType.parameters; 12006 FormalParameterList parameterList = functionType.parameters;
12007 expect(parameterList, isNotNull); 12007 expect(parameterList, isNotNull);
12008 NodeList<FormalParameter> parameters = parameterList.parameters; 12008 NodeList<FormalParameter> parameters = parameterList.parameters;
12009 expect(parameters, hasLength(2)); 12009 expect(parameters, hasLength(2));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
12046 expect(functionType.functionKeyword, isNotNull); 12046 expect(functionType.functionKeyword, isNotNull);
12047 TypeParameterList typeParameters = functionType.typeParameters; 12047 TypeParameterList typeParameters = functionType.typeParameters;
12048 expect(typeParameters, isNotNull); 12048 expect(typeParameters, isNotNull);
12049 expect(typeParameters.typeParameters, hasLength(1)); 12049 expect(typeParameters.typeParameters, hasLength(1));
12050 FormalParameterList parameterList = functionType.parameters; 12050 FormalParameterList parameterList = functionType.parameters;
12051 expect(parameterList, isNotNull); 12051 expect(parameterList, isNotNull);
12052 expect(parameterList.parameters, hasLength(2)); 12052 expect(parameterList.parameters, hasLength(2));
12053 } 12053 }
12054 12054
12055 void test_parseTypeAnnotation_function_returnType_classFunction() { 12055 void test_parseTypeAnnotation_function_returnType_classFunction() {
12056 createParser('Function v'); 12056 createParser('Function');
12057 TypeName functionType = parser.parseTypeAnnotation(false); 12057 TypeName functionType = parser.parseTypeAnnotation(false);
12058 expectNotNullIfNoErrors(functionType); 12058 expectNotNullIfNoErrors(functionType);
12059 listener.assertNoErrors(); 12059 listener.assertNoErrors();
12060 } 12060 }
12061 12061
12062 void test_parseTypeAnnotation_function_returnType_function() { 12062 void test_parseTypeAnnotation_function_returnType_function() {
12063 createParser('A Function(B, C) Function(D) v'); 12063 createParser('A Function(B, C) Function(D)');
12064 // TODO(scheglov) improve the test to verify also the node properties 12064 // TODO(scheglov) improve the test to verify also the node properties
12065 var functionType = parser.parseTypeAnnotation(false) as GenericFunctionType; 12065 var functionType = parser.parseTypeAnnotation(false) as GenericFunctionType;
12066 expectNotNullIfNoErrors(functionType); 12066 expectNotNullIfNoErrors(functionType);
12067 listener.assertNoErrors(); 12067 listener.assertNoErrors();
12068 } 12068 }
12069 12069
12070 void test_parseTypeAnnotation_function_returnType_noParameters() { 12070 void test_parseTypeAnnotation_function_returnType_noParameters() {
12071 createParser('List<int> Function()'); 12071 createParser('List<int> Function()');
12072 GenericFunctionType functionType = parser.parseTypeAnnotation(false); 12072 GenericFunctionType functionType = parser.parseTypeAnnotation(false);
12073 expectNotNullIfNoErrors(functionType); 12073 expectNotNullIfNoErrors(functionType);
(...skipping 28 matching lines...) Expand all
12102 12102
12103 expect(parameters[1], new isInstanceOf<SimpleFormalParameter>()); 12103 expect(parameters[1], new isInstanceOf<SimpleFormalParameter>());
12104 parameter = parameters[1]; 12104 parameter = parameters[1];
12105 expect(parameter.identifier, isNotNull); 12105 expect(parameter.identifier, isNotNull);
12106 expect(parameter.identifier.name, 'i'); 12106 expect(parameter.identifier.name, 'i');
12107 expect(parameter.type, new isInstanceOf<TypeName>()); 12107 expect(parameter.type, new isInstanceOf<TypeName>());
12108 expect((parameter.type as TypeName).name.name, 'int'); 12108 expect((parameter.type as TypeName).name.name, 'int');
12109 } 12109 }
12110 12110
12111 void test_parseTypeAnnotation_function_returnType_simple() { 12111 void test_parseTypeAnnotation_function_returnType_simple() {
12112 createParser('A Function(B, C) v'); 12112 createParser('A Function(B, C)');
12113 // TODO(scheglov) improve the test to verify also the node properties 12113 // TODO(scheglov) improve the test to verify also the node properties
12114 var functionType = parser.parseTypeAnnotation(false) as GenericFunctionType; 12114 var functionType = parser.parseTypeAnnotation(false) as GenericFunctionType;
12115 expectNotNullIfNoErrors(functionType); 12115 expectNotNullIfNoErrors(functionType);
12116 listener.assertNoErrors(); 12116 listener.assertNoErrors();
12117 } 12117 }
12118 12118
12119 void test_parseTypeAnnotation_function_returnType_typeParameters() { 12119 void test_parseTypeAnnotation_function_returnType_typeParameters() {
12120 createParser('List<T> Function<T>()'); 12120 createParser('List<T> Function<T>()');
12121 GenericFunctionType functionType = parser.parseTypeAnnotation(false); 12121 GenericFunctionType functionType = parser.parseTypeAnnotation(false);
12122 expectNotNullIfNoErrors(functionType); 12122 expectNotNullIfNoErrors(functionType);
(...skipping 18 matching lines...) Expand all
12141 expect(functionType.functionKeyword, isNotNull); 12141 expect(functionType.functionKeyword, isNotNull);
12142 TypeParameterList typeParameters = functionType.typeParameters; 12142 TypeParameterList typeParameters = functionType.typeParameters;
12143 expect(typeParameters, isNotNull); 12143 expect(typeParameters, isNotNull);
12144 expect(typeParameters.typeParameters, hasLength(1)); 12144 expect(typeParameters.typeParameters, hasLength(1));
12145 FormalParameterList parameterList = functionType.parameters; 12145 FormalParameterList parameterList = functionType.parameters;
12146 expect(parameterList, isNotNull); 12146 expect(parameterList, isNotNull);
12147 expect(parameterList.parameters, hasLength(2)); 12147 expect(parameterList.parameters, hasLength(2));
12148 } 12148 }
12149 12149
12150 void test_parseTypeAnnotation_function_returnType_withArguments() { 12150 void test_parseTypeAnnotation_function_returnType_withArguments() {
12151 createParser('A<B> Function(C) v'); 12151 createParser('A<B> Function(C)');
12152 // TODO(scheglov) improve this test to verify also the node properties 12152 // TODO(scheglov) improve this test to verify also the node properties
12153 var functionType = parser.parseTypeAnnotation(false) as GenericFunctionType; 12153 var functionType = parser.parseTypeAnnotation(false) as GenericFunctionType;
12154 expectNotNullIfNoErrors(functionType); 12154 expectNotNullIfNoErrors(functionType);
12155 listener.assertNoErrors(); 12155 listener.assertNoErrors();
12156 } 12156 }
12157 12157
12158 void test_parseTypeAnnotation_named() { 12158 void test_parseTypeAnnotation_named() {
12159 createParser('A<B> v'); 12159 createParser('A<B>');
12160 TypeName typeName = parser.parseTypeAnnotation(false); 12160 TypeName typeName = parser.parseTypeAnnotation(false);
12161 expectNotNullIfNoErrors(typeName); 12161 expectNotNullIfNoErrors(typeName);
12162 listener.assertNoErrors(); 12162 listener.assertNoErrors();
12163 } 12163 }
12164 12164
12165 void test_parseTypeArgumentList_empty() { 12165 void test_parseTypeArgumentList_empty() {
12166 createParser('<>'); 12166 createParser('<>');
12167 TypeArgumentList argumentList = parser.parseTypeArgumentList(); 12167 TypeArgumentList argumentList = parser.parseTypeArgumentList();
12168 expectNotNullIfNoErrors(argumentList); 12168 expectNotNullIfNoErrors(argumentList);
12169 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_TYPE_NAME]); 12169 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_TYPE_NAME]);
(...skipping 3310 matching lines...) Expand 10 before | Expand all | Expand 10 after
15480 expectCommentText(typeVariable.documentationComment, '/// Doc'); 15480 expectCommentText(typeVariable.documentationComment, '/// Doc');
15481 } 15481 }
15482 15482
15483 /** 15483 /**
15484 * Assert that the given [name] is in declaration context. 15484 * Assert that the given [name] is in declaration context.
15485 */ 15485 */
15486 void _assertIsDeclarationName(SimpleIdentifier name) { 15486 void _assertIsDeclarationName(SimpleIdentifier name) {
15487 expect(name.inDeclarationContext(), isTrue); 15487 expect(name.inDeclarationContext(), isTrue);
15488 } 15488 }
15489 } 15489 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698