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 engine.parser_test; | 5 library engine.parser_test; |
6 | 6 |
7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
10 import 'package:analyzer/src/generated/error.dart'; | 10 import 'package:analyzer/src/generated/error.dart'; |
(...skipping 3531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3542 (obj) => obj is FieldDeclaration, FieldDeclaration, classMember); | 3542 (obj) => obj is FieldDeclaration, FieldDeclaration, classMember); |
3543 VariableDeclarationList fieldList = | 3543 VariableDeclarationList fieldList = |
3544 (classMember as FieldDeclaration).fields; | 3544 (classMember as FieldDeclaration).fields; |
3545 expect((fieldList.keyword as KeywordToken).keyword, Keyword.VAR); | 3545 expect((fieldList.keyword as KeywordToken).keyword, Keyword.VAR); |
3546 NodeList<VariableDeclaration> fields = fieldList.variables; | 3546 NodeList<VariableDeclaration> fields = fieldList.variables; |
3547 expect(fields, hasLength(1)); | 3547 expect(fields, hasLength(1)); |
3548 VariableDeclaration field = fields[0]; | 3548 VariableDeclaration field = fields[0]; |
3549 expect(field.name.isSynthetic, isTrue); | 3549 expect(field.name.isSynthetic, isTrue); |
3550 } | 3550 } |
3551 | 3551 |
| 3552 void test_incompleteForEach() { |
| 3553 ForStatement statement = ParserTestCase.parseStatement( |
| 3554 'for (String item i) {}', |
| 3555 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.EXPECTED_TOKEN]); |
| 3556 expect(statement, new isInstanceOf<ForStatement>()); |
| 3557 expect(statement.toSource(), 'for (String item; i;) {}'); |
| 3558 expect(statement.leftSeparator, isNotNull); |
| 3559 expect(statement.leftSeparator.type, TokenType.SEMICOLON); |
| 3560 expect(statement.rightSeparator, isNotNull); |
| 3561 expect(statement.rightSeparator.type, TokenType.SEMICOLON); |
| 3562 } |
| 3563 |
3552 void test_incompleteLocalVariable_atTheEndOfBlock() { | 3564 void test_incompleteLocalVariable_atTheEndOfBlock() { |
3553 Statement statement = ParserTestCase.parseStatement( | 3565 Statement statement = ParserTestCase.parseStatement( |
3554 'String v }', [ParserErrorCode.EXPECTED_TOKEN]); | 3566 'String v }', [ParserErrorCode.EXPECTED_TOKEN]); |
3555 expect(statement, new isInstanceOf<VariableDeclarationStatement>()); | 3567 expect(statement, new isInstanceOf<VariableDeclarationStatement>()); |
3556 expect(statement.toSource(), 'String v;'); | 3568 expect(statement.toSource(), 'String v;'); |
3557 } | 3569 } |
3558 | 3570 |
3559 void test_incompleteLocalVariable_beforeIdentifier() { | 3571 void test_incompleteLocalVariable_beforeIdentifier() { |
3560 Statement statement = ParserTestCase.parseStatement( | 3572 Statement statement = ParserTestCase.parseStatement( |
3561 'String v String v2;', [ParserErrorCode.EXPECTED_TOKEN]); | 3573 'String v String v2;', [ParserErrorCode.EXPECTED_TOKEN]); |
(...skipping 7158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10720 new Scanner(null, new CharSequenceReader(source), listener); | 10732 new Scanner(null, new CharSequenceReader(source), listener); |
10721 Token tokenStream = scanner.tokenize(); | 10733 Token tokenStream = scanner.tokenize(); |
10722 // | 10734 // |
10723 // Parse the source. | 10735 // Parse the source. |
10724 // | 10736 // |
10725 Parser parser = new Parser(null, listener); | 10737 Parser parser = new Parser(null, listener); |
10726 return invokeParserMethodImpl( | 10738 return invokeParserMethodImpl( |
10727 parser, methodName, <Object>[tokenStream], tokenStream) as Token; | 10739 parser, methodName, <Object>[tokenStream], tokenStream) as Token; |
10728 } | 10740 } |
10729 } | 10741 } |
OLD | NEW |