| 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 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 4122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4133 | 4133 |
| 4134 void test_typedefInClass_withReturnType() { | 4134 void test_typedefInClass_withReturnType() { |
| 4135 parseCompilationUnit("class C { typedef int F(int x); }", | 4135 parseCompilationUnit("class C { typedef int F(int x); }", |
| 4136 [ParserErrorCode.TYPEDEF_IN_CLASS]); | 4136 [ParserErrorCode.TYPEDEF_IN_CLASS]); |
| 4137 } | 4137 } |
| 4138 | 4138 |
| 4139 void test_unexpectedTerminatorForParameterGroup_named() { | 4139 void test_unexpectedTerminatorForParameterGroup_named() { |
| 4140 createParser('(a, b})'); | 4140 createParser('(a, b})'); |
| 4141 FormalParameterList list = parser.parseFormalParameterList(); | 4141 FormalParameterList list = parser.parseFormalParameterList(); |
| 4142 expectNotNullIfNoErrors(list); | 4142 expectNotNullIfNoErrors(list); |
| 4143 listener.assertErrorsWithCodes(fe.Scanner.useFasta | 4143 listener.assertErrorsWithCodes( |
| 4144 ? [ScannerErrorCode.EXPECTED_TOKEN] | 4144 [ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 4145 : [ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP]); | |
| 4146 } | 4145 } |
| 4147 | 4146 |
| 4148 void test_unexpectedTerminatorForParameterGroup_optional() { | 4147 void test_unexpectedTerminatorForParameterGroup_optional() { |
| 4149 createParser('(a, b])'); | 4148 createParser('(a, b])'); |
| 4150 FormalParameterList list = parser.parseFormalParameterList(); | 4149 FormalParameterList list = parser.parseFormalParameterList(); |
| 4151 expectNotNullIfNoErrors(list); | 4150 expectNotNullIfNoErrors(list); |
| 4152 listener.assertErrorsWithCodes(fe.Scanner.useFasta | 4151 listener.assertErrorsWithCodes( |
| 4153 ? [ScannerErrorCode.EXPECTED_TOKEN] | 4152 [ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 4154 : [ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP]); | |
| 4155 } | 4153 } |
| 4156 | 4154 |
| 4157 void test_unexpectedToken_endOfFieldDeclarationStatement() { | 4155 void test_unexpectedToken_endOfFieldDeclarationStatement() { |
| 4158 parseStatement("String s = (null));"); | 4156 parseStatement("String s = (null));"); |
| 4159 assertErrorsWithCodes([ParserErrorCode.UNEXPECTED_TOKEN]); | 4157 assertErrorsWithCodes([ParserErrorCode.UNEXPECTED_TOKEN]); |
| 4160 } | 4158 } |
| 4161 | 4159 |
| 4162 @failingTest | 4160 @failingTest |
| 4163 void test_unexpectedToken_invalidPostfixExpression() { | 4161 void test_unexpectedToken_invalidPostfixExpression() { |
| 4164 // Note: this might not be the right error to produce, but some error should | 4162 // Note: this might not be the right error to produce, but some error should |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4384 expectNotNullIfNoErrors(list); | 4382 expectNotNullIfNoErrors(list); |
| 4385 listener.assertErrorsWithCodes( | 4383 listener.assertErrorsWithCodes( |
| 4386 [ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER]); | 4384 [ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER]); |
| 4387 } | 4385 } |
| 4388 | 4386 |
| 4389 void test_wrongTerminatorForParameterGroup_named() { | 4387 void test_wrongTerminatorForParameterGroup_named() { |
| 4390 createParser('(a, {b, c])'); | 4388 createParser('(a, {b, c])'); |
| 4391 FormalParameterList list = parser.parseFormalParameterList(); | 4389 FormalParameterList list = parser.parseFormalParameterList(); |
| 4392 expectNotNullIfNoErrors(list); | 4390 expectNotNullIfNoErrors(list); |
| 4393 listener.assertErrorsWithCodes(fe.Scanner.useFasta | 4391 listener.assertErrorsWithCodes(fe.Scanner.useFasta |
| 4394 ? [ScannerErrorCode.EXPECTED_TOKEN, ScannerErrorCode.EXPECTED_TOKEN] | 4392 ? [ |
| 4393 // fasta scanner generates '(a, {b, c]})' where '}' is synthetic |
| 4394 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, |
| 4395 ScannerErrorCode.EXPECTED_TOKEN, |
| 4396 ] |
| 4395 : [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]); | 4397 : [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 4396 } | 4398 } |
| 4397 | 4399 |
| 4398 void test_wrongTerminatorForParameterGroup_optional() { | 4400 void test_wrongTerminatorForParameterGroup_optional() { |
| 4399 createParser('(a, [b, c})'); | 4401 createParser('(a, [b, c})'); |
| 4400 FormalParameterList list = parser.parseFormalParameterList(); | 4402 FormalParameterList list = parser.parseFormalParameterList(); |
| 4401 expectNotNullIfNoErrors(list); | 4403 expectNotNullIfNoErrors(list); |
| 4402 listener.assertErrorsWithCodes(fe.Scanner.useFasta | 4404 listener.assertErrorsWithCodes(usingFastaScanner |
| 4403 ? [ScannerErrorCode.EXPECTED_TOKEN, ScannerErrorCode.EXPECTED_TOKEN] | 4405 ? [ |
| 4406 // fasta scanner generates '(a, [b, c}])' where ']' is synthetic |
| 4407 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, |
| 4408 ScannerErrorCode.EXPECTED_TOKEN, |
| 4409 ] |
| 4404 : [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]); | 4410 : [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 4405 } | 4411 } |
| 4406 } | 4412 } |
| 4407 | 4413 |
| 4408 @reflectiveTest | 4414 @reflectiveTest |
| 4409 class ExpressionParserTest extends ParserTestCase | 4415 class ExpressionParserTest extends ParserTestCase |
| 4410 with ExpressionParserTestMixin {} | 4416 with ExpressionParserTestMixin {} |
| 4411 | 4417 |
| 4412 abstract class ExpressionParserTestMixin implements AbstractParserTestCase { | 4418 abstract class ExpressionParserTestMixin implements AbstractParserTestCase { |
| 4413 void test_namedArgument() { | 4419 void test_namedArgument() { |
| (...skipping 10754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15168 expectCommentText(typeVariable.documentationComment, '/// Doc'); | 15174 expectCommentText(typeVariable.documentationComment, '/// Doc'); |
| 15169 } | 15175 } |
| 15170 | 15176 |
| 15171 /** | 15177 /** |
| 15172 * Assert that the given [name] is in declaration context. | 15178 * Assert that the given [name] is in declaration context. |
| 15173 */ | 15179 */ |
| 15174 void _assertIsDeclarationName(SimpleIdentifier name) { | 15180 void _assertIsDeclarationName(SimpleIdentifier name) { |
| 15175 expect(name.inDeclarationContext(), isTrue); | 15181 expect(name.inDeclarationContext(), isTrue); |
| 15176 } | 15182 } |
| 15177 } | 15183 } |
| OLD | NEW |