| 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/error.dart'; | 9 import 'package:analyzer/src/generated/error.dart'; |
| 10 import 'package:analyzer/src/generated/incremental_scanner.dart'; | 10 import 'package:analyzer/src/generated/incremental_scanner.dart'; |
| (...skipping 8748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8759 expect(identifier.name, lexeme); | 8759 expect(identifier.name, lexeme); |
| 8760 } | 8760 } |
| 8761 | 8761 |
| 8762 void test_parseSimpleIdentifier_normalIdentifier() { | 8762 void test_parseSimpleIdentifier_normalIdentifier() { |
| 8763 String lexeme = "foo"; | 8763 String lexeme = "foo"; |
| 8764 SimpleIdentifier identifier = parse4("parseSimpleIdentifier", lexeme); | 8764 SimpleIdentifier identifier = parse4("parseSimpleIdentifier", lexeme); |
| 8765 expect(identifier.token, isNotNull); | 8765 expect(identifier.token, isNotNull); |
| 8766 expect(identifier.name, lexeme); | 8766 expect(identifier.name, lexeme); |
| 8767 } | 8767 } |
| 8768 | 8768 |
| 8769 void test_parseStatement_emptyTypeArgumentListt() { |
| 8770 VariableDeclarationStatement statement = ParserTestCase.parse4( |
| 8771 "parseStatement", "C<> c;", [ParserErrorCode.EXPECTED_TYPE_NAME]); |
| 8772 VariableDeclarationList variables = statement.variables; |
| 8773 TypeName type = variables.type; |
| 8774 TypeArgumentList argumentList = type.typeArguments; |
| 8775 expect(argumentList.leftBracket, isNotNull); |
| 8776 expect(argumentList.arguments, hasLength(1)); |
| 8777 expect(argumentList.arguments[0].isSynthetic, isTrue); |
| 8778 expect(argumentList.rightBracket, isNotNull); |
| 8779 } |
| 8780 |
| 8769 void test_parseStatement_functionDeclaration() { | 8781 void test_parseStatement_functionDeclaration() { |
| 8770 // TODO(brianwilkerson) Implement more tests for this method. | 8782 // TODO(brianwilkerson) Implement more tests for this method. |
| 8771 FunctionDeclarationStatement statement = | 8783 FunctionDeclarationStatement statement = |
| 8772 parse4("parseStatement", "int f(a, b) {};"); | 8784 parse4("parseStatement", "int f(a, b) {};"); |
| 8773 expect(statement.functionDeclaration, isNotNull); | 8785 expect(statement.functionDeclaration, isNotNull); |
| 8774 } | 8786 } |
| 8775 | 8787 |
| 8776 void test_parseStatement_mulipleLabels() { | 8788 void test_parseStatement_mulipleLabels() { |
| 8777 LabeledStatement statement = parse4("parseStatement", "l: m: return x;"); | 8789 LabeledStatement statement = parse4("parseStatement", "l: m: return x;"); |
| 8778 expect(statement.labels, hasLength(2)); | 8790 expect(statement.labels, hasLength(2)); |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9124 FunctionTypeAlias typeAlias = parse("parseTypeAlias", | 9136 FunctionTypeAlias typeAlias = parse("parseTypeAlias", |
| 9125 <Object>[emptyCommentAndMetadata()], "typedef void F();"); | 9137 <Object>[emptyCommentAndMetadata()], "typedef void F();"); |
| 9126 expect(typeAlias.typedefKeyword, isNotNull); | 9138 expect(typeAlias.typedefKeyword, isNotNull); |
| 9127 expect(typeAlias.name, isNotNull); | 9139 expect(typeAlias.name, isNotNull); |
| 9128 expect(typeAlias.parameters, isNotNull); | 9140 expect(typeAlias.parameters, isNotNull); |
| 9129 expect(typeAlias.returnType, isNotNull); | 9141 expect(typeAlias.returnType, isNotNull); |
| 9130 expect(typeAlias.semicolon, isNotNull); | 9142 expect(typeAlias.semicolon, isNotNull); |
| 9131 expect(typeAlias.typeParameters, isNull); | 9143 expect(typeAlias.typeParameters, isNull); |
| 9132 } | 9144 } |
| 9133 | 9145 |
| 9146 void test_parseTypeArgumentList_empty() { |
| 9147 TypeArgumentList argumentList = ParserTestCase.parse4( |
| 9148 "parseTypeArgumentList", "<>", [ParserErrorCode.EXPECTED_TYPE_NAME]); |
| 9149 expect(argumentList.leftBracket, isNotNull); |
| 9150 expect(argumentList.arguments, hasLength(1)); |
| 9151 expect(argumentList.rightBracket, isNotNull); |
| 9152 } |
| 9153 |
| 9134 void test_parseTypeArgumentList_multiple() { | 9154 void test_parseTypeArgumentList_multiple() { |
| 9135 TypeArgumentList argumentList = | 9155 TypeArgumentList argumentList = |
| 9136 parse4("parseTypeArgumentList", "<int, int, int>"); | 9156 parse4("parseTypeArgumentList", "<int, int, int>"); |
| 9137 expect(argumentList.leftBracket, isNotNull); | 9157 expect(argumentList.leftBracket, isNotNull); |
| 9138 expect(argumentList.arguments, hasLength(3)); | 9158 expect(argumentList.arguments, hasLength(3)); |
| 9139 expect(argumentList.rightBracket, isNotNull); | 9159 expect(argumentList.rightBracket, isNotNull); |
| 9140 } | 9160 } |
| 9141 | 9161 |
| 9142 void test_parseTypeArgumentList_nested() { | 9162 void test_parseTypeArgumentList_nested() { |
| 9143 TypeArgumentList argumentList = parse4("parseTypeArgumentList", "<A<B>>"); | 9163 TypeArgumentList argumentList = parse4("parseTypeArgumentList", "<A<B>>"); |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9805 new Scanner(null, new CharSequenceReader(source), listener); | 9825 new Scanner(null, new CharSequenceReader(source), listener); |
| 9806 Token tokenStream = scanner.tokenize(); | 9826 Token tokenStream = scanner.tokenize(); |
| 9807 // | 9827 // |
| 9808 // Parse the source. | 9828 // Parse the source. |
| 9809 // | 9829 // |
| 9810 Parser parser = new Parser(null, listener); | 9830 Parser parser = new Parser(null, listener); |
| 9811 return invokeParserMethodImpl( | 9831 return invokeParserMethodImpl( |
| 9812 parser, methodName, <Object>[tokenStream], tokenStream) as Token; | 9832 parser, methodName, <Object>[tokenStream], tokenStream) as Token; |
| 9813 } | 9833 } |
| 9814 } | 9834 } |
| OLD | NEW |