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/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
9 import 'package:analyzer/dart/ast/visitor.dart'; | 9 import 'package:analyzer/dart/ast/visitor.dart'; |
10 import 'package:analyzer/src/dart/ast/token.dart'; | 10 import 'package:analyzer/src/dart/ast/token.dart'; |
(...skipping 3482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3493 ParserErrorCode.MISSING_IDENTIFIER, | 3493 ParserErrorCode.MISSING_IDENTIFIER, |
3494 ParserErrorCode.MISSING_IDENTIFIER, | 3494 ParserErrorCode.MISSING_IDENTIFIER, |
3495 ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND | 3495 ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND |
3496 ]); | 3496 ]); |
3497 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 3497 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
3498 BinaryExpression, expression.leftOperand); | 3498 BinaryExpression, expression.leftOperand); |
3499 } | 3499 } |
3500 | 3500 |
3501 void test_expressionList_multiple_end() { | 3501 void test_expressionList_multiple_end() { |
3502 List<Expression> result = parse4("parseExpressionList", ", 2, 3, 4", | 3502 List<Expression> result = parse4("parseExpressionList", ", 2, 3, 4", |
3503 [ParserErrorCode.MISSING_IDENTIFIER]); | 3503 [ParserErrorCode.MISSING_IDENTIFIER]) as List<Expression>; |
Bob Nystrom
2016/03/30 19:59:04
Do you think it might be worth making parse4() its
Brian Wilkerson
2016/03/31 00:23:11
I'm open to doing that if you want.
Longer term I
| |
3504 expect(result, hasLength(4)); | 3504 expect(result, hasLength(4)); |
3505 Expression syntheticExpression = result[0]; | 3505 Expression syntheticExpression = result[0]; |
3506 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3506 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
3507 SimpleIdentifier, syntheticExpression); | 3507 SimpleIdentifier, syntheticExpression); |
3508 expect(syntheticExpression.isSynthetic, isTrue); | 3508 expect(syntheticExpression.isSynthetic, isTrue); |
3509 } | 3509 } |
3510 | 3510 |
3511 void test_expressionList_multiple_middle() { | 3511 void test_expressionList_multiple_middle() { |
3512 List<Expression> result = parse4("parseExpressionList", "1, 2, , 4", | 3512 List<Expression> result = parse4("parseExpressionList", "1, 2, , 4", |
3513 [ParserErrorCode.MISSING_IDENTIFIER]); | 3513 [ParserErrorCode.MISSING_IDENTIFIER]) as List<Expression>; |
3514 expect(result, hasLength(4)); | 3514 expect(result, hasLength(4)); |
3515 Expression syntheticExpression = result[2]; | 3515 Expression syntheticExpression = result[2]; |
3516 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3516 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
3517 SimpleIdentifier, syntheticExpression); | 3517 SimpleIdentifier, syntheticExpression); |
3518 expect(syntheticExpression.isSynthetic, isTrue); | 3518 expect(syntheticExpression.isSynthetic, isTrue); |
3519 } | 3519 } |
3520 | 3520 |
3521 void test_expressionList_multiple_start() { | 3521 void test_expressionList_multiple_start() { |
3522 List<Expression> result = parse4("parseExpressionList", "1, 2, 3,", | 3522 List<Expression> result = parse4("parseExpressionList", "1, 2, 3,", |
3523 [ParserErrorCode.MISSING_IDENTIFIER]); | 3523 [ParserErrorCode.MISSING_IDENTIFIER]) as List<Expression>; |
3524 expect(result, hasLength(4)); | 3524 expect(result, hasLength(4)); |
3525 Expression syntheticExpression = result[3]; | 3525 Expression syntheticExpression = result[3]; |
3526 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3526 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
3527 SimpleIdentifier, syntheticExpression); | 3527 SimpleIdentifier, syntheticExpression); |
3528 expect(syntheticExpression.isSynthetic, isTrue); | 3528 expect(syntheticExpression.isSynthetic, isTrue); |
3529 } | 3529 } |
3530 | 3530 |
3531 void test_functionExpression_in_ConstructorFieldInitializer() { | 3531 void test_functionExpression_in_ConstructorFieldInitializer() { |
3532 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 3532 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
3533 "class A { A() : a = (){}; var v; }", | 3533 "class A { A() : a = (){}; var v; }", |
(...skipping 2526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6060 } | 6060 } |
6061 | 6061 |
6062 void test_parseCombinator_show() { | 6062 void test_parseCombinator_show() { |
6063 ShowCombinator combinator = parse4('parseCombinator', 'show a;'); | 6063 ShowCombinator combinator = parse4('parseCombinator', 'show a;'); |
6064 expect(combinator, new isInstanceOf<ShowCombinator>()); | 6064 expect(combinator, new isInstanceOf<ShowCombinator>()); |
6065 expect(combinator.keyword, isNotNull); | 6065 expect(combinator.keyword, isNotNull); |
6066 expect(combinator.shownNames, hasLength(1)); | 6066 expect(combinator.shownNames, hasLength(1)); |
6067 } | 6067 } |
6068 | 6068 |
6069 void test_parseCombinators_h() { | 6069 void test_parseCombinators_h() { |
6070 List<Combinator> combinators = parse4("parseCombinators", "hide a;"); | 6070 List<Combinator> combinators = |
6071 parse4("parseCombinators", "hide a;") as List<Combinator>; | |
6071 expect(combinators, hasLength(1)); | 6072 expect(combinators, hasLength(1)); |
6072 HideCombinator combinator = combinators[0] as HideCombinator; | 6073 HideCombinator combinator = combinators[0] as HideCombinator; |
6073 expect(combinator, isNotNull); | 6074 expect(combinator, isNotNull); |
6074 expect(combinator.keyword, isNotNull); | 6075 expect(combinator.keyword, isNotNull); |
6075 expect(combinator.hiddenNames, hasLength(1)); | 6076 expect(combinator.hiddenNames, hasLength(1)); |
6076 } | 6077 } |
6077 | 6078 |
6078 void test_parseCombinators_hs() { | 6079 void test_parseCombinators_hs() { |
6079 List<Combinator> combinators = parse4("parseCombinators", "hide a show b;"); | 6080 List<Combinator> combinators = |
6081 parse4("parseCombinators", "hide a show b;") as List<Combinator>; | |
6080 expect(combinators, hasLength(2)); | 6082 expect(combinators, hasLength(2)); |
6081 HideCombinator hideCombinator = combinators[0] as HideCombinator; | 6083 HideCombinator hideCombinator = combinators[0] as HideCombinator; |
6082 expect(hideCombinator, isNotNull); | 6084 expect(hideCombinator, isNotNull); |
6083 expect(hideCombinator.keyword, isNotNull); | 6085 expect(hideCombinator.keyword, isNotNull); |
6084 expect(hideCombinator.hiddenNames, hasLength(1)); | 6086 expect(hideCombinator.hiddenNames, hasLength(1)); |
6085 ShowCombinator showCombinator = combinators[1] as ShowCombinator; | 6087 ShowCombinator showCombinator = combinators[1] as ShowCombinator; |
6086 expect(showCombinator, isNotNull); | 6088 expect(showCombinator, isNotNull); |
6087 expect(showCombinator.keyword, isNotNull); | 6089 expect(showCombinator.keyword, isNotNull); |
6088 expect(showCombinator.shownNames, hasLength(1)); | 6090 expect(showCombinator.shownNames, hasLength(1)); |
6089 } | 6091 } |
6090 | 6092 |
6091 void test_parseCombinators_hshs() { | 6093 void test_parseCombinators_hshs() { |
6092 List<Combinator> combinators = | 6094 List<Combinator> combinators = |
6093 parse4("parseCombinators", "hide a show b hide c show d;"); | 6095 parse4("parseCombinators", "hide a show b hide c show d;") |
6096 as List<Combinator>; | |
6094 expect(combinators, hasLength(4)); | 6097 expect(combinators, hasLength(4)); |
6095 } | 6098 } |
6096 | 6099 |
6097 void test_parseCombinators_s() { | 6100 void test_parseCombinators_s() { |
6098 List<Combinator> combinators = parse4("parseCombinators", "show a;"); | 6101 List<Combinator> combinators = |
6102 parse4("parseCombinators", "show a;") as List<Combinator>; | |
6099 expect(combinators, hasLength(1)); | 6103 expect(combinators, hasLength(1)); |
6100 ShowCombinator combinator = combinators[0] as ShowCombinator; | 6104 ShowCombinator combinator = combinators[0] as ShowCombinator; |
6101 expect(combinator, isNotNull); | 6105 expect(combinator, isNotNull); |
6102 expect(combinator.keyword, isNotNull); | 6106 expect(combinator.keyword, isNotNull); |
6103 expect(combinator.shownNames, hasLength(1)); | 6107 expect(combinator.shownNames, hasLength(1)); |
6104 } | 6108 } |
6105 | 6109 |
6106 void test_parseCommentAndMetadata_c() { | 6110 void test_parseCommentAndMetadata_c() { |
6107 CommentAndMetadata commentAndMetadata = | 6111 CommentAndMetadata commentAndMetadata = |
6108 parse4("parseCommentAndMetadata", "/** 1 */ void"); | 6112 parse4("parseCommentAndMetadata", "/** 1 */ void"); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6249 expect(identifier.token, isNotNull); | 6253 expect(identifier.token, isNotNull); |
6250 expect(identifier.name, ""); | 6254 expect(identifier.name, ""); |
6251 expect(identifier.offset, 5); | 6255 expect(identifier.offset, 5); |
6252 } | 6256 } |
6253 | 6257 |
6254 void test_parseCommentReferences_multiLine() { | 6258 void test_parseCommentReferences_multiLine() { |
6255 DocumentationCommentToken token = new DocumentationCommentToken( | 6259 DocumentationCommentToken token = new DocumentationCommentToken( |
6256 TokenType.MULTI_LINE_COMMENT, "/** xxx [a] yyy [bb] zzz */", 3); | 6260 TokenType.MULTI_LINE_COMMENT, "/** xxx [a] yyy [bb] zzz */", 3); |
6257 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[token]; | 6261 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[token]; |
6258 List<CommentReference> references = | 6262 List<CommentReference> references = |
6259 parse("parseCommentReferences", <Object>[tokens], ""); | 6263 parse("parseCommentReferences", <Object>[tokens], "") |
6264 as List<CommentReference>; | |
6260 List<Token> tokenReferences = token.references; | 6265 List<Token> tokenReferences = token.references; |
6261 expect(references, hasLength(2)); | 6266 expect(references, hasLength(2)); |
6262 expect(tokenReferences, hasLength(2)); | 6267 expect(tokenReferences, hasLength(2)); |
6263 { | 6268 { |
6264 CommentReference reference = references[0]; | 6269 CommentReference reference = references[0]; |
6265 expect(reference, isNotNull); | 6270 expect(reference, isNotNull); |
6266 expect(reference.identifier, isNotNull); | 6271 expect(reference.identifier, isNotNull); |
6267 expect(reference.offset, 12); | 6272 expect(reference.offset, 12); |
6268 // the reference is recorded in the comment token | 6273 // the reference is recorded in the comment token |
6269 Token referenceToken = tokenReferences[0]; | 6274 Token referenceToken = tokenReferences[0]; |
(...skipping 11 matching lines...) Expand all Loading... | |
6281 expect(referenceToken.lexeme, 'bb'); | 6286 expect(referenceToken.lexeme, 'bb'); |
6282 } | 6287 } |
6283 } | 6288 } |
6284 | 6289 |
6285 void test_parseCommentReferences_notClosed_noIdentifier() { | 6290 void test_parseCommentReferences_notClosed_noIdentifier() { |
6286 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 6291 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
6287 new DocumentationCommentToken( | 6292 new DocumentationCommentToken( |
6288 TokenType.MULTI_LINE_COMMENT, "/** [ some text", 5) | 6293 TokenType.MULTI_LINE_COMMENT, "/** [ some text", 5) |
6289 ]; | 6294 ]; |
6290 List<CommentReference> references = | 6295 List<CommentReference> references = |
6291 parse("parseCommentReferences", <Object>[tokens], ""); | 6296 parse("parseCommentReferences", <Object>[tokens], "") |
6297 as List<CommentReference>; | |
6292 expect(references, hasLength(1)); | 6298 expect(references, hasLength(1)); |
6293 CommentReference reference = references[0]; | 6299 CommentReference reference = references[0]; |
6294 expect(reference, isNotNull); | 6300 expect(reference, isNotNull); |
6295 expect(reference.identifier, isNotNull); | 6301 expect(reference.identifier, isNotNull); |
6296 expect(reference.identifier.isSynthetic, isTrue); | 6302 expect(reference.identifier.isSynthetic, isTrue); |
6297 expect(reference.identifier.name, ""); | 6303 expect(reference.identifier.name, ""); |
6298 } | 6304 } |
6299 | 6305 |
6300 void test_parseCommentReferences_notClosed_withIdentifier() { | 6306 void test_parseCommentReferences_notClosed_withIdentifier() { |
6301 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 6307 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
6302 new DocumentationCommentToken( | 6308 new DocumentationCommentToken( |
6303 TokenType.MULTI_LINE_COMMENT, "/** [namePrefix some text", 5) | 6309 TokenType.MULTI_LINE_COMMENT, "/** [namePrefix some text", 5) |
6304 ]; | 6310 ]; |
6305 List<CommentReference> references = | 6311 List<CommentReference> references = |
6306 parse("parseCommentReferences", <Object>[tokens], ""); | 6312 parse("parseCommentReferences", <Object>[tokens], "") |
6313 as List<CommentReference>; | |
6307 expect(references, hasLength(1)); | 6314 expect(references, hasLength(1)); |
6308 CommentReference reference = references[0]; | 6315 CommentReference reference = references[0]; |
6309 expect(reference, isNotNull); | 6316 expect(reference, isNotNull); |
6310 expect(reference.identifier, isNotNull); | 6317 expect(reference.identifier, isNotNull); |
6311 expect(reference.identifier.isSynthetic, isFalse); | 6318 expect(reference.identifier.isSynthetic, isFalse); |
6312 expect(reference.identifier.name, "namePrefix"); | 6319 expect(reference.identifier.name, "namePrefix"); |
6313 } | 6320 } |
6314 | 6321 |
6315 void test_parseCommentReferences_singleLine() { | 6322 void test_parseCommentReferences_singleLine() { |
6316 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 6323 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
6317 new DocumentationCommentToken( | 6324 new DocumentationCommentToken( |
6318 TokenType.SINGLE_LINE_COMMENT, "/// xxx [a] yyy [b] zzz", 3), | 6325 TokenType.SINGLE_LINE_COMMENT, "/// xxx [a] yyy [b] zzz", 3), |
6319 new DocumentationCommentToken( | 6326 new DocumentationCommentToken( |
6320 TokenType.SINGLE_LINE_COMMENT, "/// x [c]", 28) | 6327 TokenType.SINGLE_LINE_COMMENT, "/// x [c]", 28) |
6321 ]; | 6328 ]; |
6322 List<CommentReference> references = | 6329 List<CommentReference> references = |
6323 parse("parseCommentReferences", <Object>[tokens], ""); | 6330 parse("parseCommentReferences", <Object>[tokens], "") |
6331 as List<CommentReference>; | |
6324 expect(references, hasLength(3)); | 6332 expect(references, hasLength(3)); |
6325 CommentReference reference = references[0]; | 6333 CommentReference reference = references[0]; |
6326 expect(reference, isNotNull); | 6334 expect(reference, isNotNull); |
6327 expect(reference.identifier, isNotNull); | 6335 expect(reference.identifier, isNotNull); |
6328 expect(reference.offset, 12); | 6336 expect(reference.offset, 12); |
6329 reference = references[1]; | 6337 reference = references[1]; |
6330 expect(reference, isNotNull); | 6338 expect(reference, isNotNull); |
6331 expect(reference.identifier, isNotNull); | 6339 expect(reference.identifier, isNotNull); |
6332 expect(reference.offset, 20); | 6340 expect(reference.offset, 20); |
6333 reference = references[2]; | 6341 reference = references[2]; |
6334 expect(reference, isNotNull); | 6342 expect(reference, isNotNull); |
6335 expect(reference.identifier, isNotNull); | 6343 expect(reference.identifier, isNotNull); |
6336 expect(reference.offset, 35); | 6344 expect(reference.offset, 35); |
6337 } | 6345 } |
6338 | 6346 |
6339 void test_parseCommentReferences_skipCodeBlock_4spaces_block() { | 6347 void test_parseCommentReferences_skipCodeBlock_4spaces_block() { |
6340 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 6348 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
6341 new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT, | 6349 new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT, |
6342 "/**\n * a[i]\n * non-code line\n */", 3) | 6350 "/**\n * a[i]\n * non-code line\n */", 3) |
6343 ]; | 6351 ]; |
6344 List<CommentReference> references = | 6352 List<CommentReference> references = |
6345 parse("parseCommentReferences", <Object>[tokens], ""); | 6353 parse("parseCommentReferences", <Object>[tokens], "") |
6354 as List<CommentReference>; | |
6346 expect(references, isEmpty); | 6355 expect(references, isEmpty); |
6347 } | 6356 } |
6348 | 6357 |
6349 void test_parseCommentReferences_skipCodeBlock_4spaces_lines() { | 6358 void test_parseCommentReferences_skipCodeBlock_4spaces_lines() { |
6350 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 6359 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
6351 new DocumentationCommentToken( | 6360 new DocumentationCommentToken( |
6352 TokenType.SINGLE_LINE_COMMENT, "/// Code block:", 0), | 6361 TokenType.SINGLE_LINE_COMMENT, "/// Code block:", 0), |
6353 new DocumentationCommentToken( | 6362 new DocumentationCommentToken( |
6354 TokenType.SINGLE_LINE_COMMENT, "/// a[i] == b[i]", 0) | 6363 TokenType.SINGLE_LINE_COMMENT, "/// a[i] == b[i]", 0) |
6355 ]; | 6364 ]; |
6356 List<CommentReference> references = | 6365 List<CommentReference> references = |
6357 parse("parseCommentReferences", <Object>[tokens], ""); | 6366 parse("parseCommentReferences", <Object>[tokens], "") |
6367 as List<CommentReference>; | |
6358 expect(references, isEmpty); | 6368 expect(references, isEmpty); |
6359 } | 6369 } |
6360 | 6370 |
6361 void test_parseCommentReferences_skipCodeBlock_bracketed() { | 6371 void test_parseCommentReferences_skipCodeBlock_bracketed() { |
6362 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 6372 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
6363 new DocumentationCommentToken( | 6373 new DocumentationCommentToken( |
6364 TokenType.MULTI_LINE_COMMENT, "/** [:xxx [a] yyy:] [b] zzz */", 3) | 6374 TokenType.MULTI_LINE_COMMENT, "/** [:xxx [a] yyy:] [b] zzz */", 3) |
6365 ]; | 6375 ]; |
6366 List<CommentReference> references = | 6376 List<CommentReference> references = |
6367 parse("parseCommentReferences", <Object>[tokens], ""); | 6377 parse("parseCommentReferences", <Object>[tokens], "") |
6378 as List<CommentReference>; | |
6368 expect(references, hasLength(1)); | 6379 expect(references, hasLength(1)); |
6369 CommentReference reference = references[0]; | 6380 CommentReference reference = references[0]; |
6370 expect(reference, isNotNull); | 6381 expect(reference, isNotNull); |
6371 expect(reference.identifier, isNotNull); | 6382 expect(reference.identifier, isNotNull); |
6372 expect(reference.offset, 24); | 6383 expect(reference.offset, 24); |
6373 } | 6384 } |
6374 | 6385 |
6375 void test_parseCommentReferences_skipCodeBlock_gitHub() { | 6386 void test_parseCommentReferences_skipCodeBlock_gitHub() { |
6376 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 6387 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
6377 new DocumentationCommentToken( | 6388 new DocumentationCommentToken( |
6378 TokenType.MULTI_LINE_COMMENT, "/** `a[i]` and [b] */", 0) | 6389 TokenType.MULTI_LINE_COMMENT, "/** `a[i]` and [b] */", 0) |
6379 ]; | 6390 ]; |
6380 List<CommentReference> references = | 6391 List<CommentReference> references = |
6381 parse("parseCommentReferences", <Object>[tokens], ""); | 6392 parse("parseCommentReferences", <Object>[tokens], "") |
6393 as List<CommentReference>; | |
6382 expect(references, hasLength(1)); | 6394 expect(references, hasLength(1)); |
6383 CommentReference reference = references[0]; | 6395 CommentReference reference = references[0]; |
6384 expect(reference, isNotNull); | 6396 expect(reference, isNotNull); |
6385 expect(reference.identifier, isNotNull); | 6397 expect(reference.identifier, isNotNull); |
6386 expect(reference.offset, 16); | 6398 expect(reference.offset, 16); |
6387 } | 6399 } |
6388 | 6400 |
6389 void test_parseCommentReferences_skipCodeBlock_gitHub_notTerminated() { | 6401 void test_parseCommentReferences_skipCodeBlock_gitHub_notTerminated() { |
6390 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 6402 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
6391 new DocumentationCommentToken( | 6403 new DocumentationCommentToken( |
6392 TokenType.MULTI_LINE_COMMENT, "/** `a[i] and [b] */", 0) | 6404 TokenType.MULTI_LINE_COMMENT, "/** `a[i] and [b] */", 0) |
6393 ]; | 6405 ]; |
6394 List<CommentReference> references = | 6406 List<CommentReference> references = |
6395 parse("parseCommentReferences", <Object>[tokens], ""); | 6407 parse("parseCommentReferences", <Object>[tokens], "") |
6408 as List<CommentReference>; | |
6396 expect(references, hasLength(2)); | 6409 expect(references, hasLength(2)); |
6397 } | 6410 } |
6398 | 6411 |
6399 void test_parseCommentReferences_skipCodeBlock_spaces() { | 6412 void test_parseCommentReferences_skipCodeBlock_spaces() { |
6400 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 6413 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
6401 new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT, | 6414 new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT, |
6402 "/**\n * a[i]\n * xxx [i] zzz\n */", 3) | 6415 "/**\n * a[i]\n * xxx [i] zzz\n */", 3) |
6403 ]; | 6416 ]; |
6404 List<CommentReference> references = | 6417 List<CommentReference> references = |
6405 parse("parseCommentReferences", <Object>[tokens], ""); | 6418 parse("parseCommentReferences", <Object>[tokens], "") |
6419 as List<CommentReference>; | |
6406 expect(references, hasLength(1)); | 6420 expect(references, hasLength(1)); |
6407 CommentReference reference = references[0]; | 6421 CommentReference reference = references[0]; |
6408 expect(reference, isNotNull); | 6422 expect(reference, isNotNull); |
6409 expect(reference.identifier, isNotNull); | 6423 expect(reference.identifier, isNotNull); |
6410 expect(reference.offset, 27); | 6424 expect(reference.offset, 27); |
6411 } | 6425 } |
6412 | 6426 |
6413 void test_parseCommentReferences_skipLinkDefinition() { | 6427 void test_parseCommentReferences_skipLinkDefinition() { |
6414 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 6428 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
6415 new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT, | 6429 new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT, |
6416 "/** [a]: http://www.google.com (Google) [b] zzz */", 3) | 6430 "/** [a]: http://www.google.com (Google) [b] zzz */", 3) |
6417 ]; | 6431 ]; |
6418 List<CommentReference> references = | 6432 List<CommentReference> references = |
6419 parse("parseCommentReferences", <Object>[tokens], ""); | 6433 parse("parseCommentReferences", <Object>[tokens], "") |
6434 as List<CommentReference>; | |
6420 expect(references, hasLength(1)); | 6435 expect(references, hasLength(1)); |
6421 CommentReference reference = references[0]; | 6436 CommentReference reference = references[0]; |
6422 expect(reference, isNotNull); | 6437 expect(reference, isNotNull); |
6423 expect(reference.identifier, isNotNull); | 6438 expect(reference.identifier, isNotNull); |
6424 expect(reference.offset, 44); | 6439 expect(reference.offset, 44); |
6425 } | 6440 } |
6426 | 6441 |
6427 void test_parseCommentReferences_skipLinked() { | 6442 void test_parseCommentReferences_skipLinked() { |
6428 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 6443 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
6429 new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT, | 6444 new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT, |
6430 "/** [a](http://www.google.com) [b] zzz */", 3) | 6445 "/** [a](http://www.google.com) [b] zzz */", 3) |
6431 ]; | 6446 ]; |
6432 List<CommentReference> references = | 6447 List<CommentReference> references = |
6433 parse("parseCommentReferences", <Object>[tokens], ""); | 6448 parse("parseCommentReferences", <Object>[tokens], "") |
6449 as List<CommentReference>; | |
6434 expect(references, hasLength(1)); | 6450 expect(references, hasLength(1)); |
6435 CommentReference reference = references[0]; | 6451 CommentReference reference = references[0]; |
6436 expect(reference, isNotNull); | 6452 expect(reference, isNotNull); |
6437 expect(reference.identifier, isNotNull); | 6453 expect(reference.identifier, isNotNull); |
6438 expect(reference.offset, 35); | 6454 expect(reference.offset, 35); |
6439 } | 6455 } |
6440 | 6456 |
6441 void test_parseCommentReferences_skipReferenceLink() { | 6457 void test_parseCommentReferences_skipReferenceLink() { |
6442 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 6458 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
6443 new DocumentationCommentToken( | 6459 new DocumentationCommentToken( |
6444 TokenType.MULTI_LINE_COMMENT, "/** [a][c] [b] zzz */", 3) | 6460 TokenType.MULTI_LINE_COMMENT, "/** [a][c] [b] zzz */", 3) |
6445 ]; | 6461 ]; |
6446 List<CommentReference> references = | 6462 List<CommentReference> references = |
6447 parse("parseCommentReferences", <Object>[tokens], ""); | 6463 parse("parseCommentReferences", <Object>[tokens], "") |
6464 as List<CommentReference>; | |
6448 expect(references, hasLength(1)); | 6465 expect(references, hasLength(1)); |
6449 CommentReference reference = references[0]; | 6466 CommentReference reference = references[0]; |
6450 expect(reference, isNotNull); | 6467 expect(reference, isNotNull); |
6451 expect(reference.identifier, isNotNull); | 6468 expect(reference.identifier, isNotNull); |
6452 expect(reference.offset, 15); | 6469 expect(reference.offset, 15); |
6453 } | 6470 } |
6454 | 6471 |
6455 void test_parseCompilationUnit_abstractAsPrefix_parameterized() { | 6472 void test_parseCompilationUnit_abstractAsPrefix_parameterized() { |
6456 CompilationUnit unit = parse4("parseCompilationUnit", | 6473 CompilationUnit unit = parse4("parseCompilationUnit", |
6457 "abstract<dynamic> _abstract = new abstract.A();"); | 6474 "abstract<dynamic> _abstract = new abstract.A();"); |
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7398 void test_parseExpression_superMethodInvocation_typeArguments() { | 7415 void test_parseExpression_superMethodInvocation_typeArguments() { |
7399 enableGenericMethods = true; | 7416 enableGenericMethods = true; |
7400 MethodInvocation invocation = parse4("parseExpression", "super.m<E>()"); | 7417 MethodInvocation invocation = parse4("parseExpression", "super.m<E>()"); |
7401 expect(invocation.target, isNotNull); | 7418 expect(invocation.target, isNotNull); |
7402 expect(invocation.methodName, isNotNull); | 7419 expect(invocation.methodName, isNotNull); |
7403 expect(invocation.typeArguments, isNotNull); | 7420 expect(invocation.typeArguments, isNotNull); |
7404 expect(invocation.argumentList, isNotNull); | 7421 expect(invocation.argumentList, isNotNull); |
7405 } | 7422 } |
7406 | 7423 |
7407 void test_parseExpressionList_multiple() { | 7424 void test_parseExpressionList_multiple() { |
7408 List<Expression> result = parse4("parseExpressionList", "1, 2, 3"); | 7425 List<Expression> result = |
7426 parse4("parseExpressionList", "1, 2, 3") as List<Expression>; | |
7409 expect(result, hasLength(3)); | 7427 expect(result, hasLength(3)); |
7410 } | 7428 } |
7411 | 7429 |
7412 void test_parseExpressionList_single() { | 7430 void test_parseExpressionList_single() { |
7413 List<Expression> result = parse4("parseExpressionList", "1"); | 7431 List<Expression> result = |
7432 parse4("parseExpressionList", "1") as List<Expression>; | |
7414 expect(result, hasLength(1)); | 7433 expect(result, hasLength(1)); |
7415 } | 7434 } |
7416 | 7435 |
7417 void test_parseExpressionWithoutCascade_assign() { | 7436 void test_parseExpressionWithoutCascade_assign() { |
7418 // TODO(brianwilkerson) Implement more tests for this method. | 7437 // TODO(brianwilkerson) Implement more tests for this method. |
7419 AssignmentExpression expression = | 7438 AssignmentExpression expression = |
7420 parse4("parseExpressionWithoutCascade", "x = y"); | 7439 parse4("parseExpressionWithoutCascade", "x = y"); |
7421 expect(expression.leftHandSide, isNotNull); | 7440 expect(expression.leftHandSide, isNotNull); |
7422 expect(expression.operator, isNotNull); | 7441 expect(expression.operator, isNotNull); |
7423 expect(expression.operator.type, TokenType.EQ); | 7442 expect(expression.operator.type, TokenType.EQ); |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8358 expect(method.modifierKeyword, staticKeyword); | 8377 expect(method.modifierKeyword, staticKeyword); |
8359 expect(method.name, isNotNull); | 8378 expect(method.name, isNotNull); |
8360 expect(method.operatorKeyword, isNull); | 8379 expect(method.operatorKeyword, isNull); |
8361 expect(method.typeParameters, isNull); | 8380 expect(method.typeParameters, isNull); |
8362 expect(method.parameters, isNull); | 8381 expect(method.parameters, isNull); |
8363 expect(method.propertyKeyword, isNotNull); | 8382 expect(method.propertyKeyword, isNotNull); |
8364 expect(method.returnType, returnType); | 8383 expect(method.returnType, returnType); |
8365 } | 8384 } |
8366 | 8385 |
8367 void test_parseIdentifierList_multiple() { | 8386 void test_parseIdentifierList_multiple() { |
8368 List<SimpleIdentifier> list = parse4("parseIdentifierList", "a, b, c"); | 8387 List<SimpleIdentifier> list = |
8388 parse4("parseIdentifierList", "a, b, c") as List<SimpleIdentifier>; | |
8369 expect(list, hasLength(3)); | 8389 expect(list, hasLength(3)); |
8370 } | 8390 } |
8371 | 8391 |
8372 void test_parseIdentifierList_single() { | 8392 void test_parseIdentifierList_single() { |
8373 List<SimpleIdentifier> list = parse4("parseIdentifierList", "a"); | 8393 List<SimpleIdentifier> list = |
8394 parse4("parseIdentifierList", "a") as List<SimpleIdentifier>; | |
8374 expect(list, hasLength(1)); | 8395 expect(list, hasLength(1)); |
8375 } | 8396 } |
8376 | 8397 |
8377 void test_parseIfStatement_else_block() { | 8398 void test_parseIfStatement_else_block() { |
8378 IfStatement statement = parse4("parseIfStatement", "if (x) {} else {}"); | 8399 IfStatement statement = parse4("parseIfStatement", "if (x) {} else {}"); |
8379 expect(statement.ifKeyword, isNotNull); | 8400 expect(statement.ifKeyword, isNotNull); |
8380 expect(statement.leftParenthesis, isNotNull); | 8401 expect(statement.leftParenthesis, isNotNull); |
8381 expect(statement.condition, isNotNull); | 8402 expect(statement.condition, isNotNull); |
8382 expect(statement.rightParenthesis, isNotNull); | 8403 expect(statement.rightParenthesis, isNotNull); |
8383 expect(statement.thenStatement, isNotNull); | 8404 expect(statement.thenStatement, isNotNull); |
(...skipping 2626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11010 new Scanner(null, new CharSequenceReader(source), listener); | 11031 new Scanner(null, new CharSequenceReader(source), listener); |
11011 Token tokenStream = scanner.tokenize(); | 11032 Token tokenStream = scanner.tokenize(); |
11012 // | 11033 // |
11013 // Parse the source. | 11034 // Parse the source. |
11014 // | 11035 // |
11015 Parser parser = new Parser(null, listener); | 11036 Parser parser = new Parser(null, listener); |
11016 return invokeParserMethodImpl( | 11037 return invokeParserMethodImpl( |
11017 parser, methodName, <Object>[tokenStream], tokenStream) as Token; | 11038 parser, methodName, <Object>[tokenStream], tokenStream) as Token; |
11018 } | 11039 } |
11019 } | 11040 } |
OLD | NEW |