| 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 5140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5151 ArgumentList argumentList = parse4("parseArgumentList", "(x: x, y: y)"); | 5151 ArgumentList argumentList = parse4("parseArgumentList", "(x: x, y: y)"); |
| 5152 NodeList<Expression> arguments = argumentList.arguments; | 5152 NodeList<Expression> arguments = argumentList.arguments; |
| 5153 expect(arguments, hasLength(2)); | 5153 expect(arguments, hasLength(2)); |
| 5154 } | 5154 } |
| 5155 | 5155 |
| 5156 void test_parseAssertStatement() { | 5156 void test_parseAssertStatement() { |
| 5157 AssertStatement statement = parse4("parseAssertStatement", "assert (x);"); | 5157 AssertStatement statement = parse4("parseAssertStatement", "assert (x);"); |
| 5158 expect(statement.assertKeyword, isNotNull); | 5158 expect(statement.assertKeyword, isNotNull); |
| 5159 expect(statement.leftParenthesis, isNotNull); | 5159 expect(statement.leftParenthesis, isNotNull); |
| 5160 expect(statement.condition, isNotNull); | 5160 expect(statement.condition, isNotNull); |
| 5161 expect(statement.comma, isNull); |
| 5162 expect(statement.message, isNull); |
| 5161 expect(statement.rightParenthesis, isNotNull); | 5163 expect(statement.rightParenthesis, isNotNull); |
| 5162 expect(statement.semicolon, isNotNull); | 5164 expect(statement.semicolon, isNotNull); |
| 5163 } | 5165 } |
| 5166 |
| 5167 void test_parseAssertStatement_messageLowPrecedence() { |
| 5168 // Using a throw expression as an assert message would be silly in |
| 5169 // practice, but it's the lowest precedence expression type, so verifying |
| 5170 // that it works should give us high confidence that other expression types |
| 5171 // will work as well. |
| 5172 AssertStatement statement = |
| 5173 parse4('parseAssertStatement', 'assert (x, throw "foo");'); |
| 5174 expect(statement.assertKeyword, isNotNull); |
| 5175 expect(statement.leftParenthesis, isNotNull); |
| 5176 expect(statement.condition, isNotNull); |
| 5177 expect(statement.comma, isNotNull); |
| 5178 expect(statement.message, isNotNull); |
| 5179 expect(statement.rightParenthesis, isNotNull); |
| 5180 expect(statement.semicolon, isNotNull); |
| 5181 } |
| 5182 |
| 5183 void test_parseAssertStatement_messageString() { |
| 5184 AssertStatement statement = |
| 5185 parse4('parseAssertStatement', 'assert (x, "foo");'); |
| 5186 expect(statement.assertKeyword, isNotNull); |
| 5187 expect(statement.leftParenthesis, isNotNull); |
| 5188 expect(statement.condition, isNotNull); |
| 5189 expect(statement.comma, isNotNull); |
| 5190 expect(statement.message, isNotNull); |
| 5191 expect(statement.rightParenthesis, isNotNull); |
| 5192 expect(statement.semicolon, isNotNull); |
| 5193 } |
| 5164 | 5194 |
| 5165 void test_parseAssignableExpression_expression_args_dot() { | 5195 void test_parseAssignableExpression_expression_args_dot() { |
| 5166 PropertyAccess propertyAccess = | 5196 PropertyAccess propertyAccess = |
| 5167 parse("parseAssignableExpression", <Object>[false], "(x)(y).z"); | 5197 parse("parseAssignableExpression", <Object>[false], "(x)(y).z"); |
| 5168 FunctionExpressionInvocation invocation = | 5198 FunctionExpressionInvocation invocation = |
| 5169 propertyAccess.target as FunctionExpressionInvocation; | 5199 propertyAccess.target as FunctionExpressionInvocation; |
| 5170 expect(invocation.function, isNotNull); | 5200 expect(invocation.function, isNotNull); |
| 5171 expect(invocation.typeArguments, isNull); | 5201 expect(invocation.typeArguments, isNull); |
| 5172 ArgumentList argumentList = invocation.argumentList; | 5202 ArgumentList argumentList = invocation.argumentList; |
| 5173 expect(argumentList, isNotNull); | 5203 expect(argumentList, isNotNull); |
| (...skipping 5943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11117 new Scanner(null, new CharSequenceReader(source), listener); | 11147 new Scanner(null, new CharSequenceReader(source), listener); |
| 11118 Token tokenStream = scanner.tokenize(); | 11148 Token tokenStream = scanner.tokenize(); |
| 11119 // | 11149 // |
| 11120 // Parse the source. | 11150 // Parse the source. |
| 11121 // | 11151 // |
| 11122 Parser parser = new Parser(null, listener); | 11152 Parser parser = new Parser(null, listener); |
| 11123 return invokeParserMethodImpl( | 11153 return invokeParserMethodImpl( |
| 11124 parser, methodName, <Object>[tokenStream], tokenStream) as Token; | 11154 parser, methodName, <Object>[tokenStream], tokenStream) as Token; |
| 11125 } | 11155 } |
| 11126 } | 11156 } |
| OLD | NEW |