| OLD | NEW |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
| 3 library engine.parser_test; | 3 library engine.parser_test; |
| 4 import 'dart:collection'; | 4 import 'dart:collection'; |
| 5 import 'package:analyzer_experimental/src/generated/java_core.dart'; | 5 import 'package:analyzer_experimental/src/generated/java_core.dart'; |
| 6 import 'package:analyzer_experimental/src/generated/java_engine.dart'; | 6 import 'package:analyzer_experimental/src/generated/java_engine.dart'; |
| 7 import 'package:analyzer_experimental/src/generated/java_junit.dart'; | 7 import 'package:analyzer_experimental/src/generated/java_junit.dart'; |
| 8 import 'package:analyzer_experimental/src/generated/source.dart'; | 8 import 'package:analyzer_experimental/src/generated/source.dart'; |
| 9 import 'package:analyzer_experimental/src/generated/error.dart'; | 9 import 'package:analyzer_experimental/src/generated/error.dart'; |
| 10 import 'package:analyzer_experimental/src/generated/scanner.dart'; | 10 import 'package:analyzer_experimental/src/generated/scanner.dart'; |
| (...skipping 3651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3662 JUnitTestCase.assertEquals(TokenType.PLUS, following.type); | 3662 JUnitTestCase.assertEquals(TokenType.PLUS, following.type); |
| 3663 } | 3663 } |
| 3664 void test_skipTypeName_simple() { | 3664 void test_skipTypeName_simple() { |
| 3665 Token following = skip("skipTypeName", "C +"); | 3665 Token following = skip("skipTypeName", "C +"); |
| 3666 JUnitTestCase.assertNotNull(following); | 3666 JUnitTestCase.assertNotNull(following); |
| 3667 JUnitTestCase.assertEquals(TokenType.PLUS, following.type); | 3667 JUnitTestCase.assertEquals(TokenType.PLUS, following.type); |
| 3668 } | 3668 } |
| 3669 | 3669 |
| 3670 /** | 3670 /** |
| 3671 * Invoke the method [Parser#computeStringValue] with the given argument. | 3671 * Invoke the method [Parser#computeStringValue] with the given argument. |
| 3672 * |
| 3672 * @param lexeme the argument to the method | 3673 * @param lexeme the argument to the method |
| 3673 * @return the result of invoking the method | 3674 * @return the result of invoking the method |
| 3674 * @throws Exception if the method could not be invoked or throws an exception | 3675 * @throws Exception if the method could not be invoked or throws an exception |
| 3675 */ | 3676 */ |
| 3676 String computeStringValue(String lexeme) { | 3677 String computeStringValue(String lexeme) { |
| 3677 AnalysisErrorListener listener = new AnalysisErrorListener_19(); | 3678 AnalysisErrorListener listener = new AnalysisErrorListener_20(); |
| 3678 Parser parser = new Parser(null, listener); | 3679 Parser parser = new Parser(null, listener); |
| 3679 return invokeParserMethodImpl(parser, "computeStringValue", <Object> [lexeme
], null) as String; | 3680 return invokeParserMethodImpl(parser, "computeStringValue", <Object> [lexeme
], null) as String; |
| 3680 } | 3681 } |
| 3681 | 3682 |
| 3682 /** | 3683 /** |
| 3683 * Invoke the method [Parser#createSyntheticIdentifier] with the parser set to
the token | 3684 * Invoke the method [Parser#createSyntheticIdentifier] with the parser set to
the token |
| 3684 * stream produced by scanning the given source. | 3685 * stream produced by scanning the given source. |
| 3686 * |
| 3685 * @param source the source to be scanned to produce the token stream being te
sted | 3687 * @param source the source to be scanned to produce the token stream being te
sted |
| 3686 * @return the result of invoking the method | 3688 * @return the result of invoking the method |
| 3687 * @throws Exception if the method could not be invoked or throws an exception | 3689 * @throws Exception if the method could not be invoked or throws an exception |
| 3688 */ | 3690 */ |
| 3689 SimpleIdentifier createSyntheticIdentifier() { | 3691 SimpleIdentifier createSyntheticIdentifier() { |
| 3690 GatheringErrorListener listener = new GatheringErrorListener(); | 3692 GatheringErrorListener listener = new GatheringErrorListener(); |
| 3691 return ParserTestCase.invokeParserMethod2("createSyntheticIdentifier", "", l
istener); | 3693 return ParserTestCase.invokeParserMethod2("createSyntheticIdentifier", "", l
istener); |
| 3692 } | 3694 } |
| 3693 | 3695 |
| 3694 /** | 3696 /** |
| 3695 * Invoke the method [Parser#createSyntheticIdentifier] with the parser set to
the token | 3697 * Invoke the method [Parser#createSyntheticIdentifier] with the parser set to
the token |
| 3696 * stream produced by scanning the given source. | 3698 * stream produced by scanning the given source. |
| 3699 * |
| 3697 * @param source the source to be scanned to produce the token stream being te
sted | 3700 * @param source the source to be scanned to produce the token stream being te
sted |
| 3698 * @return the result of invoking the method | 3701 * @return the result of invoking the method |
| 3699 * @throws Exception if the method could not be invoked or throws an exception | 3702 * @throws Exception if the method could not be invoked or throws an exception |
| 3700 */ | 3703 */ |
| 3701 SimpleStringLiteral createSyntheticStringLiteral() { | 3704 SimpleStringLiteral createSyntheticStringLiteral() { |
| 3702 GatheringErrorListener listener = new GatheringErrorListener(); | 3705 GatheringErrorListener listener = new GatheringErrorListener(); |
| 3703 return ParserTestCase.invokeParserMethod2("createSyntheticStringLiteral", ""
, listener); | 3706 return ParserTestCase.invokeParserMethod2("createSyntheticStringLiteral", ""
, listener); |
| 3704 } | 3707 } |
| 3705 | 3708 |
| 3706 /** | 3709 /** |
| 3707 * Invoke the method [Parser#isFunctionDeclaration] with the parser set to the
token | 3710 * Invoke the method [Parser#isFunctionDeclaration] with the parser set to the
token |
| 3708 * stream produced by scanning the given source. | 3711 * stream produced by scanning the given source. |
| 3712 * |
| 3709 * @param source the source to be scanned to produce the token stream being te
sted | 3713 * @param source the source to be scanned to produce the token stream being te
sted |
| 3710 * @return the result of invoking the method | 3714 * @return the result of invoking the method |
| 3711 * @throws Exception if the method could not be invoked or throws an exception | 3715 * @throws Exception if the method could not be invoked or throws an exception |
| 3712 */ | 3716 */ |
| 3713 bool isFunctionDeclaration(String source) { | 3717 bool isFunctionDeclaration(String source) { |
| 3714 GatheringErrorListener listener = new GatheringErrorListener(); | 3718 GatheringErrorListener listener = new GatheringErrorListener(); |
| 3715 return ParserTestCase.invokeParserMethod2("isFunctionDeclaration", source, l
istener) as bool; | 3719 return ParserTestCase.invokeParserMethod2("isFunctionDeclaration", source, l
istener) as bool; |
| 3716 } | 3720 } |
| 3717 | 3721 |
| 3718 /** | 3722 /** |
| 3719 * Invoke the method [Parser#isFunctionExpression] with the parser set to the
token stream | 3723 * Invoke the method [Parser#isFunctionExpression] with the parser set to the
token stream |
| 3720 * produced by scanning the given source. | 3724 * produced by scanning the given source. |
| 3725 * |
| 3721 * @param source the source to be scanned to produce the token stream being te
sted | 3726 * @param source the source to be scanned to produce the token stream being te
sted |
| 3722 * @return the result of invoking the method | 3727 * @return the result of invoking the method |
| 3723 * @throws Exception if the method could not be invoked or throws an exception | 3728 * @throws Exception if the method could not be invoked or throws an exception |
| 3724 */ | 3729 */ |
| 3725 bool isFunctionExpression(String source) { | 3730 bool isFunctionExpression(String source) { |
| 3726 GatheringErrorListener listener = new GatheringErrorListener(); | 3731 GatheringErrorListener listener = new GatheringErrorListener(); |
| 3727 StringScanner scanner = new StringScanner(null, source, listener); | 3732 StringScanner scanner = new StringScanner(null, source, listener); |
| 3728 Token tokenStream = scanner.tokenize(); | 3733 Token tokenStream = scanner.tokenize(); |
| 3729 Parser parser = new Parser(null, listener); | 3734 Parser parser = new Parser(null, listener); |
| 3730 return invokeParserMethodImpl(parser, "isFunctionExpression", <Object> [toke
nStream], tokenStream) as bool; | 3735 return invokeParserMethodImpl(parser, "isFunctionExpression", <Object> [toke
nStream], tokenStream) as bool; |
| 3731 } | 3736 } |
| 3732 | 3737 |
| 3733 /** | 3738 /** |
| 3734 * Invoke the method [Parser#isInitializedVariableDeclaration] with the parser
set to the | 3739 * Invoke the method [Parser#isInitializedVariableDeclaration] with the parser
set to the |
| 3735 * token stream produced by scanning the given source. | 3740 * token stream produced by scanning the given source. |
| 3741 * |
| 3736 * @param source the source to be scanned to produce the token stream being te
sted | 3742 * @param source the source to be scanned to produce the token stream being te
sted |
| 3737 * @return the result of invoking the method | 3743 * @return the result of invoking the method |
| 3738 * @throws Exception if the method could not be invoked or throws an exception | 3744 * @throws Exception if the method could not be invoked or throws an exception |
| 3739 */ | 3745 */ |
| 3740 bool isInitializedVariableDeclaration(String source) { | 3746 bool isInitializedVariableDeclaration(String source) { |
| 3741 GatheringErrorListener listener = new GatheringErrorListener(); | 3747 GatheringErrorListener listener = new GatheringErrorListener(); |
| 3742 return ParserTestCase.invokeParserMethod2("isInitializedVariableDeclaration"
, source, listener) as bool; | 3748 return ParserTestCase.invokeParserMethod2("isInitializedVariableDeclaration"
, source, listener) as bool; |
| 3743 } | 3749 } |
| 3744 | 3750 |
| 3745 /** | 3751 /** |
| 3746 * Invoke the method [Parser#isSwitchMember] with the parser set to the token
stream | 3752 * Invoke the method [Parser#isSwitchMember] with the parser set to the token
stream |
| 3747 * produced by scanning the given source. | 3753 * produced by scanning the given source. |
| 3754 * |
| 3748 * @param source the source to be scanned to produce the token stream being te
sted | 3755 * @param source the source to be scanned to produce the token stream being te
sted |
| 3749 * @return the result of invoking the method | 3756 * @return the result of invoking the method |
| 3750 * @throws Exception if the method could not be invoked or throws an exception | 3757 * @throws Exception if the method could not be invoked or throws an exception |
| 3751 */ | 3758 */ |
| 3752 bool isSwitchMember(String source) { | 3759 bool isSwitchMember(String source) { |
| 3753 GatheringErrorListener listener = new GatheringErrorListener(); | 3760 GatheringErrorListener listener = new GatheringErrorListener(); |
| 3754 return ParserTestCase.invokeParserMethod2("isSwitchMember", source, listener
) as bool; | 3761 return ParserTestCase.invokeParserMethod2("isSwitchMember", source, listener
) as bool; |
| 3755 } | 3762 } |
| 3756 | 3763 |
| 3757 /** | 3764 /** |
| 3758 * Invoke a "skip" method in [Parser]. The method is assumed to take a token a
s it's | 3765 * Invoke a "skip" method in [Parser]. The method is assumed to take a token a
s it's |
| 3759 * parameter and is given the first token in the scanned source. | 3766 * parameter and is given the first token in the scanned source. |
| 3767 * |
| 3760 * @param methodName the name of the method that should be invoked | 3768 * @param methodName the name of the method that should be invoked |
| 3761 * @param source the source to be processed by the method | 3769 * @param source the source to be processed by the method |
| 3762 * @return the result of invoking the method | 3770 * @return the result of invoking the method |
| 3763 * @throws Exception if the method could not be invoked or throws an exception | 3771 * @throws Exception if the method could not be invoked or throws an exception |
| 3764 * @throws AssertionFailedError if the result is `null` | 3772 * @throws AssertionFailedError if the result is `null` |
| 3765 */ | 3773 */ |
| 3766 Token skip(String methodName, String source) { | 3774 Token skip(String methodName, String source) { |
| 3767 GatheringErrorListener listener = new GatheringErrorListener(); | 3775 GatheringErrorListener listener = new GatheringErrorListener(); |
| 3768 StringScanner scanner = new StringScanner(null, source, listener); | 3776 StringScanner scanner = new StringScanner(null, source, listener); |
| 3769 Token tokenStream = scanner.tokenize(); | 3777 Token tokenStream = scanner.tokenize(); |
| (...skipping 2070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5840 final __test = new SimpleParserTest(); | 5848 final __test = new SimpleParserTest(); |
| 5841 runJUnitTest(__test, __test.test_skipTypeName_parameterized); | 5849 runJUnitTest(__test, __test.test_skipTypeName_parameterized); |
| 5842 }); | 5850 }); |
| 5843 _ut.test('test_skipTypeName_simple', () { | 5851 _ut.test('test_skipTypeName_simple', () { |
| 5844 final __test = new SimpleParserTest(); | 5852 final __test = new SimpleParserTest(); |
| 5845 runJUnitTest(__test, __test.test_skipTypeName_simple); | 5853 runJUnitTest(__test, __test.test_skipTypeName_simple); |
| 5846 }); | 5854 }); |
| 5847 }); | 5855 }); |
| 5848 } | 5856 } |
| 5849 } | 5857 } |
| 5850 class AnalysisErrorListener_19 implements AnalysisErrorListener { | 5858 class AnalysisErrorListener_20 implements AnalysisErrorListener { |
| 5851 void onError(AnalysisError event) { | 5859 void onError(AnalysisError event) { |
| 5852 JUnitTestCase.fail("Unexpected compilation error: ${event.message} (${event.
offset}, ${event.length})"); | 5860 JUnitTestCase.fail("Unexpected compilation error: ${event.message} (${event.
offset}, ${event.length})"); |
| 5853 } | 5861 } |
| 5854 } | 5862 } |
| 5855 /** | 5863 /** |
| 5856 * The class `ComplexParserTest` defines parser tests that test the parsing of m
ore complex | 5864 * The class `ComplexParserTest` defines parser tests that test the parsing of m
ore complex |
| 5857 * code fragments or the interactions between multiple parsing methods. For exam
ple, tests to ensure | 5865 * code fragments or the interactions between multiple parsing methods. For exam
ple, tests to ensure |
| 5858 * that the precedence of operations is being handled correctly should be define
d in this class. | 5866 * that the precedence of operations is being handled correctly should be define
d in this class. |
| 5859 * | 5867 * |
| 5860 * Simpler tests should be defined in the class [SimpleParserTest]. | 5868 * Simpler tests should be defined in the class [SimpleParserTest]. |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6288 JUnitTestCase.fail(builder.toString()); | 6296 JUnitTestCase.fail(builder.toString()); |
| 6289 } | 6297 } |
| 6290 } | 6298 } |
| 6291 Object visitNode(ASTNode node) { | 6299 Object visitNode(ASTNode node) { |
| 6292 validate(node); | 6300 validate(node); |
| 6293 return super.visitNode(node); | 6301 return super.visitNode(node); |
| 6294 } | 6302 } |
| 6295 | 6303 |
| 6296 /** | 6304 /** |
| 6297 * Validate that the given AST node is correctly constructed. | 6305 * Validate that the given AST node is correctly constructed. |
| 6306 * |
| 6298 * @param node the AST node being validated | 6307 * @param node the AST node being validated |
| 6299 */ | 6308 */ |
| 6300 void validate(ASTNode node) { | 6309 void validate(ASTNode node) { |
| 6301 ASTNode parent = node.parent; | 6310 ASTNode parent = node.parent; |
| 6302 if (node is CompilationUnit) { | 6311 if (node is CompilationUnit) { |
| 6303 if (parent != null) { | 6312 if (parent != null) { |
| 6304 _errors.add("Compilation units should not have a parent"); | 6313 _errors.add("Compilation units should not have a parent"); |
| 6305 } | 6314 } |
| 6306 } else { | 6315 } else { |
| 6307 if (parent == null) { | 6316 if (parent == null) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 6338 * An empty array of objects used as arguments to zero-argument methods. | 6347 * An empty array of objects used as arguments to zero-argument methods. |
| 6339 */ | 6348 */ |
| 6340 static List<Object> _EMPTY_ARGUMENTS = new List<Object>(0); | 6349 static List<Object> _EMPTY_ARGUMENTS = new List<Object>(0); |
| 6341 | 6350 |
| 6342 /** | 6351 /** |
| 6343 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and | 6352 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and |
| 6344 * type of parameters and will be invoked with the given arguments. | 6353 * type of parameters and will be invoked with the given arguments. |
| 6345 * | 6354 * |
| 6346 * The given source is scanned and the parser is initialized to start with the
first token in the | 6355 * The given source is scanned and the parser is initialized to start with the
first token in the |
| 6347 * source before the parse method is invoked. | 6356 * source before the parse method is invoked. |
| 6357 * |
| 6348 * @param methodName the name of the parse method that should be invoked to pa
rse the source | 6358 * @param methodName the name of the parse method that should be invoked to pa
rse the source |
| 6349 * @param objects the values of the arguments to the method | 6359 * @param objects the values of the arguments to the method |
| 6350 * @param source the source to be parsed by the parse method | 6360 * @param source the source to be parsed by the parse method |
| 6351 * @return the result of invoking the method | 6361 * @return the result of invoking the method |
| 6352 * @throws Exception if the method could not be invoked or throws an exception | 6362 * @throws Exception if the method could not be invoked or throws an exception |
| 6353 * @throws AssertionFailedError if the result is `null` or if any errors are p
roduced | 6363 * @throws AssertionFailedError if the result is `null` or if any errors are p
roduced |
| 6354 */ | 6364 */ |
| 6355 static Object parse(String methodName, List<Object> objects, String source) =>
parse3(methodName, objects, source, new List<AnalysisError>(0)); | 6365 static Object parse(String methodName, List<Object> objects, String source) =>
parse3(methodName, objects, source, new List<AnalysisError>(0)); |
| 6356 | 6366 |
| 6357 /** | 6367 /** |
| 6358 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and | 6368 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and |
| 6359 * type of parameters and will be invoked with the given arguments. | 6369 * type of parameters and will be invoked with the given arguments. |
| 6360 * | 6370 * |
| 6361 * The given source is scanned and the parser is initialized to start with the
first token in the | 6371 * The given source is scanned and the parser is initialized to start with the
first token in the |
| 6362 * source before the parse method is invoked. | 6372 * source before the parse method is invoked. |
| 6373 * |
| 6363 * @param methodName the name of the parse method that should be invoked to pa
rse the source | 6374 * @param methodName the name of the parse method that should be invoked to pa
rse the source |
| 6364 * @param objects the values of the arguments to the method | 6375 * @param objects the values of the arguments to the method |
| 6365 * @param source the source to be parsed by the parse method | 6376 * @param source the source to be parsed by the parse method |
| 6366 * @param errorCodes the error codes of the errors that should be generated | 6377 * @param errorCodes the error codes of the errors that should be generated |
| 6367 * @return the result of invoking the method | 6378 * @return the result of invoking the method |
| 6368 * @throws Exception if the method could not be invoked or throws an exception | 6379 * @throws Exception if the method could not be invoked or throws an exception |
| 6369 * @throws AssertionFailedError if the result is `null` or the errors produced
while | 6380 * @throws AssertionFailedError if the result is `null` or the errors produced
while |
| 6370 * scanning and parsing the source do not match the expected errors | 6381 * scanning and parsing the source do not match the expected errors |
| 6371 */ | 6382 */ |
| 6372 static Object parse3(String methodName, List<Object> objects, String source, L
ist<AnalysisError> errors) { | 6383 static Object parse3(String methodName, List<Object> objects, String source, L
ist<AnalysisError> errors) { |
| 6373 GatheringErrorListener listener = new GatheringErrorListener(); | 6384 GatheringErrorListener listener = new GatheringErrorListener(); |
| 6374 Object result = invokeParserMethod(methodName, objects, source, listener); | 6385 Object result = invokeParserMethod(methodName, objects, source, listener); |
| 6375 listener.assertErrors(errors); | 6386 listener.assertErrors(errors); |
| 6376 return result; | 6387 return result; |
| 6377 } | 6388 } |
| 6378 | 6389 |
| 6379 /** | 6390 /** |
| 6380 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and | 6391 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and |
| 6381 * type of parameters and will be invoked with the given arguments. | 6392 * type of parameters and will be invoked with the given arguments. |
| 6382 * | 6393 * |
| 6383 * The given source is scanned and the parser is initialized to start with the
first token in the | 6394 * The given source is scanned and the parser is initialized to start with the
first token in the |
| 6384 * source before the parse method is invoked. | 6395 * source before the parse method is invoked. |
| 6396 * |
| 6385 * @param methodName the name of the parse method that should be invoked to pa
rse the source | 6397 * @param methodName the name of the parse method that should be invoked to pa
rse the source |
| 6386 * @param objects the values of the arguments to the method | 6398 * @param objects the values of the arguments to the method |
| 6387 * @param source the source to be parsed by the parse method | 6399 * @param source the source to be parsed by the parse method |
| 6388 * @param errorCodes the error codes of the errors that should be generated | 6400 * @param errorCodes the error codes of the errors that should be generated |
| 6389 * @return the result of invoking the method | 6401 * @return the result of invoking the method |
| 6390 * @throws Exception if the method could not be invoked or throws an exception | 6402 * @throws Exception if the method could not be invoked or throws an exception |
| 6391 * @throws AssertionFailedError if the result is `null` or the errors produced
while | 6403 * @throws AssertionFailedError if the result is `null` or the errors produced
while |
| 6392 * scanning and parsing the source do not match the expected errors | 6404 * scanning and parsing the source do not match the expected errors |
| 6393 */ | 6405 */ |
| 6394 static Object parse4(String methodName, List<Object> objects, String source, L
ist<ErrorCode> errorCodes) { | 6406 static Object parse4(String methodName, List<Object> objects, String source, L
ist<ErrorCode> errorCodes) { |
| 6395 GatheringErrorListener listener = new GatheringErrorListener(); | 6407 GatheringErrorListener listener = new GatheringErrorListener(); |
| 6396 Object result = invokeParserMethod(methodName, objects, source, listener); | 6408 Object result = invokeParserMethod(methodName, objects, source, listener); |
| 6397 listener.assertErrors2(errorCodes); | 6409 listener.assertErrors2(errorCodes); |
| 6398 return result; | 6410 return result; |
| 6399 } | 6411 } |
| 6400 | 6412 |
| 6401 /** | 6413 /** |
| 6402 * Invoke a parse method in [Parser]. The method is assumed to have no argumen
ts. | 6414 * Invoke a parse method in [Parser]. The method is assumed to have no argumen
ts. |
| 6403 * | 6415 * |
| 6404 * The given source is scanned and the parser is initialized to start with the
first token in the | 6416 * The given source is scanned and the parser is initialized to start with the
first token in the |
| 6405 * source before the parse method is invoked. | 6417 * source before the parse method is invoked. |
| 6418 * |
| 6406 * @param methodName the name of the parse method that should be invoked to pa
rse the source | 6419 * @param methodName the name of the parse method that should be invoked to pa
rse the source |
| 6407 * @param source the source to be parsed by the parse method | 6420 * @param source the source to be parsed by the parse method |
| 6408 * @param errorCodes the error codes of the errors that should be generated | 6421 * @param errorCodes the error codes of the errors that should be generated |
| 6409 * @return the result of invoking the method | 6422 * @return the result of invoking the method |
| 6410 * @throws Exception if the method could not be invoked or throws an exception | 6423 * @throws Exception if the method could not be invoked or throws an exception |
| 6411 * @throws AssertionFailedError if the result is `null` or the errors produced
while | 6424 * @throws AssertionFailedError if the result is `null` or the errors produced
while |
| 6412 * scanning and parsing the source do not match the expected errors | 6425 * scanning and parsing the source do not match the expected errors |
| 6413 */ | 6426 */ |
| 6414 static Object parse5(String methodName, String source, List<ErrorCode> errorCo
des) => parse4(methodName, _EMPTY_ARGUMENTS, source, errorCodes); | 6427 static Object parse5(String methodName, String source, List<ErrorCode> errorCo
des) => parse4(methodName, _EMPTY_ARGUMENTS, source, errorCodes); |
| 6415 | 6428 |
| 6416 /** | 6429 /** |
| 6417 * Parse the given source as a compilation unit. | 6430 * Parse the given source as a compilation unit. |
| 6431 * |
| 6418 * @param source the source to be parsed | 6432 * @param source the source to be parsed |
| 6419 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 6433 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 6420 * @return the compilation unit that was parsed | 6434 * @return the compilation unit that was parsed |
| 6421 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 6435 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 6422 * not match those that are expected, or if the result would have been `null` | 6436 * not match those that are expected, or if the result would have be
en `null` |
| 6423 */ | 6437 */ |
| 6424 static CompilationUnit parseCompilationUnit(String source, List<ErrorCode> err
orCodes) { | 6438 static CompilationUnit parseCompilationUnit(String source, List<ErrorCode> err
orCodes) { |
| 6425 GatheringErrorListener listener = new GatheringErrorListener(); | 6439 GatheringErrorListener listener = new GatheringErrorListener(); |
| 6426 StringScanner scanner = new StringScanner(null, source, listener); | 6440 StringScanner scanner = new StringScanner(null, source, listener); |
| 6427 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 6441 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 6428 Token token = scanner.tokenize(); | 6442 Token token = scanner.tokenize(); |
| 6429 Parser parser = new Parser(null, listener); | 6443 Parser parser = new Parser(null, listener); |
| 6430 CompilationUnit unit = parser.parseCompilationUnit(token); | 6444 CompilationUnit unit = parser.parseCompilationUnit(token); |
| 6431 JUnitTestCase.assertNotNull(unit); | 6445 JUnitTestCase.assertNotNull(unit); |
| 6432 listener.assertErrors2(errorCodes); | 6446 listener.assertErrors2(errorCodes); |
| 6433 return unit; | 6447 return unit; |
| 6434 } | 6448 } |
| 6435 | 6449 |
| 6436 /** | 6450 /** |
| 6437 * Parse the given source as an expression. | 6451 * Parse the given source as an expression. |
| 6452 * |
| 6438 * @param source the source to be parsed | 6453 * @param source the source to be parsed |
| 6439 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 6454 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 6440 * @return the expression that was parsed | 6455 * @return the expression that was parsed |
| 6441 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 6456 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 6442 * not match those that are expected, or if the result would have been `null` | 6457 * not match those that are expected, or if the result would have be
en `null` |
| 6443 */ | 6458 */ |
| 6444 static Expression parseExpression(String source, List<ErrorCode> errorCodes) { | 6459 static Expression parseExpression(String source, List<ErrorCode> errorCodes) { |
| 6445 GatheringErrorListener listener = new GatheringErrorListener(); | 6460 GatheringErrorListener listener = new GatheringErrorListener(); |
| 6446 StringScanner scanner = new StringScanner(null, source, listener); | 6461 StringScanner scanner = new StringScanner(null, source, listener); |
| 6447 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 6462 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 6448 Token token = scanner.tokenize(); | 6463 Token token = scanner.tokenize(); |
| 6449 Parser parser = new Parser(null, listener); | 6464 Parser parser = new Parser(null, listener); |
| 6450 Expression expression = parser.parseExpression(token); | 6465 Expression expression = parser.parseExpression(token); |
| 6451 JUnitTestCase.assertNotNull(expression); | 6466 JUnitTestCase.assertNotNull(expression); |
| 6452 listener.assertErrors2(errorCodes); | 6467 listener.assertErrors2(errorCodes); |
| 6453 return expression as Expression; | 6468 return expression as Expression; |
| 6454 } | 6469 } |
| 6455 | 6470 |
| 6456 /** | 6471 /** |
| 6457 * Parse the given source as a statement. | 6472 * Parse the given source as a statement. |
| 6473 * |
| 6458 * @param source the source to be parsed | 6474 * @param source the source to be parsed |
| 6459 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 6475 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 6460 * @return the statement that was parsed | 6476 * @return the statement that was parsed |
| 6461 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 6477 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 6462 * not match those that are expected, or if the result would have been `null` | 6478 * not match those that are expected, or if the result would have be
en `null` |
| 6463 */ | 6479 */ |
| 6464 static Statement parseStatement(String source, List<ErrorCode> errorCodes) { | 6480 static Statement parseStatement(String source, List<ErrorCode> errorCodes) { |
| 6465 GatheringErrorListener listener = new GatheringErrorListener(); | 6481 GatheringErrorListener listener = new GatheringErrorListener(); |
| 6466 StringScanner scanner = new StringScanner(null, source, listener); | 6482 StringScanner scanner = new StringScanner(null, source, listener); |
| 6467 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 6483 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 6468 Token token = scanner.tokenize(); | 6484 Token token = scanner.tokenize(); |
| 6469 Parser parser = new Parser(null, listener); | 6485 Parser parser = new Parser(null, listener); |
| 6470 Statement statement = parser.parseStatement(token); | 6486 Statement statement = parser.parseStatement(token); |
| 6471 JUnitTestCase.assertNotNull(statement); | 6487 JUnitTestCase.assertNotNull(statement); |
| 6472 listener.assertErrors2(errorCodes); | 6488 listener.assertErrors2(errorCodes); |
| 6473 return statement as Statement; | 6489 return statement as Statement; |
| 6474 } | 6490 } |
| 6475 | 6491 |
| 6476 /** | 6492 /** |
| 6477 * Parse the given source as a sequence of statements. | 6493 * Parse the given source as a sequence of statements. |
| 6494 * |
| 6478 * @param source the source to be parsed | 6495 * @param source the source to be parsed |
| 6479 * @param expectedCount the number of statements that are expected | 6496 * @param expectedCount the number of statements that are expected |
| 6480 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 6497 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 6481 * @return the statements that were parsed | 6498 * @return the statements that were parsed |
| 6482 * @throws Exception if the source could not be parsed, if the number of state
ments does not match | 6499 * @throws Exception if the source could not be parsed, if the number of state
ments does not match |
| 6483 * the expected count, if the compilation errors in the source do not match th
ose that | 6500 * the expected count, if the compilation errors in the source do no
t match those that |
| 6484 * are expected, or if the result would have been `null` | 6501 * are expected, or if the result would have been `null` |
| 6485 */ | 6502 */ |
| 6486 static List<Statement> parseStatements(String source, int expectedCount, List<
ErrorCode> errorCodes) { | 6503 static List<Statement> parseStatements(String source, int expectedCount, List<
ErrorCode> errorCodes) { |
| 6487 GatheringErrorListener listener = new GatheringErrorListener(); | 6504 GatheringErrorListener listener = new GatheringErrorListener(); |
| 6488 StringScanner scanner = new StringScanner(null, source, listener); | 6505 StringScanner scanner = new StringScanner(null, source, listener); |
| 6489 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 6506 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 6490 Token token = scanner.tokenize(); | 6507 Token token = scanner.tokenize(); |
| 6491 Parser parser = new Parser(null, listener); | 6508 Parser parser = new Parser(null, listener); |
| 6492 List<Statement> statements = parser.parseStatements(token); | 6509 List<Statement> statements = parser.parseStatements(token); |
| 6493 EngineTestCase.assertSize(expectedCount, statements); | 6510 EngineTestCase.assertSize(expectedCount, statements); |
| 6494 listener.assertErrors2(errorCodes); | 6511 listener.assertErrors2(errorCodes); |
| 6495 return statements; | 6512 return statements; |
| 6496 } | 6513 } |
| 6497 | 6514 |
| 6498 /** | 6515 /** |
| 6499 * Invoke a method in [Parser]. The method is assumed to have the given number
and type of | 6516 * Invoke a method in [Parser]. The method is assumed to have the given number
and type of |
| 6500 * parameters and will be invoked with the given arguments. | 6517 * parameters and will be invoked with the given arguments. |
| 6501 * | 6518 * |
| 6502 * The given source is scanned and the parser is initialized to start with the
first token in the | 6519 * The given source is scanned and the parser is initialized to start with the
first token in the |
| 6503 * source before the method is invoked. | 6520 * source before the method is invoked. |
| 6521 * |
| 6504 * @param methodName the name of the method that should be invoked | 6522 * @param methodName the name of the method that should be invoked |
| 6505 * @param objects the values of the arguments to the method | 6523 * @param objects the values of the arguments to the method |
| 6506 * @param source the source to be processed by the parse method | 6524 * @param source the source to be processed by the parse method |
| 6507 * @param listener the error listener that will be used for both scanning and
parsing | 6525 * @param listener the error listener that will be used for both scanning and
parsing |
| 6508 * @return the result of invoking the method | 6526 * @return the result of invoking the method |
| 6509 * @throws Exception if the method could not be invoked or throws an exception | 6527 * @throws Exception if the method could not be invoked or throws an exception |
| 6510 * @throws AssertionFailedError if the result is `null` or the errors produced
while | 6528 * @throws AssertionFailedError if the result is `null` or the errors produced
while |
| 6511 * scanning and parsing the source do not match the expected errors | 6529 * scanning and parsing the source do not match the expected errors |
| 6512 */ | 6530 */ |
| 6513 static Object invokeParserMethod(String methodName, List<Object> objects, Stri
ng source, GatheringErrorListener listener) { | 6531 static Object invokeParserMethod(String methodName, List<Object> objects, Stri
ng source, GatheringErrorListener listener) { |
| 6514 StringScanner scanner = new StringScanner(null, source, listener); | 6532 StringScanner scanner = new StringScanner(null, source, listener); |
| 6515 Token tokenStream = scanner.tokenize(); | 6533 Token tokenStream = scanner.tokenize(); |
| 6516 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 6534 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 6517 Parser parser = new Parser(null, listener); | 6535 Parser parser = new Parser(null, listener); |
| 6518 Object result = invokeParserMethodImpl(parser, methodName, objects, tokenStr
eam); | 6536 Object result = invokeParserMethodImpl(parser, methodName, objects, tokenStr
eam); |
| 6519 if (!listener.hasErrors()) { | 6537 if (!listener.hasErrors()) { |
| 6520 JUnitTestCase.assertNotNull(result); | 6538 JUnitTestCase.assertNotNull(result); |
| 6521 } | 6539 } |
| 6522 return result as Object; | 6540 return result as Object; |
| 6523 } | 6541 } |
| 6524 | 6542 |
| 6525 /** | 6543 /** |
| 6526 * Invoke a method in [Parser]. The method is assumed to have no arguments. | 6544 * Invoke a method in [Parser]. The method is assumed to have no arguments. |
| 6527 * | 6545 * |
| 6528 * The given source is scanned and the parser is initialized to start with the
first token in the | 6546 * The given source is scanned and the parser is initialized to start with the
first token in the |
| 6529 * source before the method is invoked. | 6547 * source before the method is invoked. |
| 6548 * |
| 6530 * @param methodName the name of the method that should be invoked | 6549 * @param methodName the name of the method that should be invoked |
| 6531 * @param source the source to be processed by the parse method | 6550 * @param source the source to be processed by the parse method |
| 6532 * @param listener the error listener that will be used for both scanning and
parsing | 6551 * @param listener the error listener that will be used for both scanning and
parsing |
| 6533 * @return the result of invoking the method | 6552 * @return the result of invoking the method |
| 6534 * @throws Exception if the method could not be invoked or throws an exception | 6553 * @throws Exception if the method could not be invoked or throws an exception |
| 6535 * @throws AssertionFailedError if the result is `null` or the errors produced
while | 6554 * @throws AssertionFailedError if the result is `null` or the errors produced
while |
| 6536 * scanning and parsing the source do not match the expected errors | 6555 * scanning and parsing the source do not match the expected errors |
| 6537 */ | 6556 */ |
| 6538 static Object invokeParserMethod2(String methodName, String source, GatheringE
rrorListener listener) => invokeParserMethod(methodName, _EMPTY_ARGUMENTS, sourc
e, listener); | 6557 static Object invokeParserMethod2(String methodName, String source, GatheringE
rrorListener listener) => invokeParserMethod(methodName, _EMPTY_ARGUMENTS, sourc
e, listener); |
| 6539 | 6558 |
| 6540 /** | 6559 /** |
| 6541 * Return a CommentAndMetadata object with the given values that can be used f
or testing. | 6560 * Return a CommentAndMetadata object with the given values that can be used f
or testing. |
| 6561 * |
| 6542 * @param comment the comment to be wrapped in the object | 6562 * @param comment the comment to be wrapped in the object |
| 6543 * @param annotations the annotations to be wrapped in the object | 6563 * @param annotations the annotations to be wrapped in the object |
| 6544 * @return a CommentAndMetadata object that can be used for testing | 6564 * @return a CommentAndMetadata object that can be used for testing |
| 6545 */ | 6565 */ |
| 6546 CommentAndMetadata commentAndMetadata(Comment comment, List<Annotation> annota
tions) { | 6566 CommentAndMetadata commentAndMetadata(Comment comment, List<Annotation> annota
tions) { |
| 6547 List<Annotation> metadata = new List<Annotation>(); | 6567 List<Annotation> metadata = new List<Annotation>(); |
| 6548 for (Annotation annotation in annotations) { | 6568 for (Annotation annotation in annotations) { |
| 6549 metadata.add(annotation); | 6569 metadata.add(annotation); |
| 6550 } | 6570 } |
| 6551 return new CommentAndMetadata(comment, metadata); | 6571 return new CommentAndMetadata(comment, metadata); |
| 6552 } | 6572 } |
| 6553 | 6573 |
| 6554 /** | 6574 /** |
| 6555 * Return an empty CommentAndMetadata object that can be used for testing. | 6575 * Return an empty CommentAndMetadata object that can be used for testing. |
| 6576 * |
| 6556 * @return an empty CommentAndMetadata object that can be used for testing | 6577 * @return an empty CommentAndMetadata object that can be used for testing |
| 6557 */ | 6578 */ |
| 6558 CommentAndMetadata emptyCommentAndMetadata() => new CommentAndMetadata(null, n
ew List<Annotation>()); | 6579 CommentAndMetadata emptyCommentAndMetadata() => new CommentAndMetadata(null, n
ew List<Annotation>()); |
| 6559 static dartSuite() { | 6580 static dartSuite() { |
| 6560 _ut.group('ParserTestCase', () { | 6581 _ut.group('ParserTestCase', () { |
| 6561 }); | 6582 }); |
| 6562 } | 6583 } |
| 6563 } | 6584 } |
| 6564 /** | 6585 /** |
| 6565 * The class `RecoveryParserTest` defines parser tests that test the parsing of
invalid code | 6586 * The class `RecoveryParserTest` defines parser tests that test the parsing of
invalid code |
| (...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7644 void test_invalidUnicodeEscape_tooManyDigits_variable() { | 7665 void test_invalidUnicodeEscape_tooManyDigits_variable() { |
| 7645 ParserTestCase.parse5("parseStringLiteral", "'\\u{12345678}'", [ParserErrorC
ode.INVALID_UNICODE_ESCAPE, ParserErrorCode.INVALID_CODE_POINT]); | 7666 ParserTestCase.parse5("parseStringLiteral", "'\\u{12345678}'", [ParserErrorC
ode.INVALID_UNICODE_ESCAPE, ParserErrorCode.INVALID_CODE_POINT]); |
| 7646 } | 7667 } |
| 7647 void test_libraryDirectiveNotFirst() { | 7668 void test_libraryDirectiveNotFirst() { |
| 7648 ParserTestCase.parseCompilationUnit("import 'x.dart'; library l;", [ParserEr
rorCode.LIBRARY_DIRECTIVE_NOT_FIRST]); | 7669 ParserTestCase.parseCompilationUnit("import 'x.dart'; library l;", [ParserEr
rorCode.LIBRARY_DIRECTIVE_NOT_FIRST]); |
| 7649 } | 7670 } |
| 7650 void test_libraryDirectiveNotFirst_afterPart() { | 7671 void test_libraryDirectiveNotFirst_afterPart() { |
| 7651 CompilationUnit unit = ParserTestCase.parseCompilationUnit("part 'a.dart';\n
library l;", [ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST]); | 7672 CompilationUnit unit = ParserTestCase.parseCompilationUnit("part 'a.dart';\n
library l;", [ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST]); |
| 7652 JUnitTestCase.assertNotNull(unit); | 7673 JUnitTestCase.assertNotNull(unit); |
| 7653 } | 7674 } |
| 7675 void test_localFunctionDeclarationModifier_abstract() { |
| 7676 ParserTestCase.parseStatement("abstract f() {}", [ParserErrorCode.LOCAL_FUNC
TION_DECLARATION_MODIFIER]); |
| 7677 } |
| 7678 void test_localFunctionDeclarationModifier_external() { |
| 7679 ParserTestCase.parseStatement("external f() {}", [ParserErrorCode.LOCAL_FUNC
TION_DECLARATION_MODIFIER]); |
| 7680 } |
| 7681 void test_localFunctionDeclarationModifier_factory() { |
| 7682 ParserTestCase.parseStatement("factory f() {}", [ParserErrorCode.LOCAL_FUNCT
ION_DECLARATION_MODIFIER]); |
| 7683 } |
| 7684 void test_localFunctionDeclarationModifier_static() { |
| 7685 ParserTestCase.parseStatement("static f() {}", [ParserErrorCode.LOCAL_FUNCTI
ON_DECLARATION_MODIFIER]); |
| 7686 } |
| 7654 void test_missingAssignableSelector_identifiersAssigned() { | 7687 void test_missingAssignableSelector_identifiersAssigned() { |
| 7655 ParserTestCase.parseExpression("x.y = y;", []); | 7688 ParserTestCase.parseExpression("x.y = y;", []); |
| 7656 } | 7689 } |
| 7690 void test_missingAssignableSelector_postfix_minusMinus_literal() { |
| 7691 ParserTestCase.parseExpression("0--", [ParserErrorCode.MISSING_ASSIGNABLE_SE
LECTOR]); |
| 7692 } |
| 7693 void test_missingAssignableSelector_postfix_plusPlus_literal() { |
| 7694 ParserTestCase.parseExpression("0++", [ParserErrorCode.MISSING_ASSIGNABLE_SE
LECTOR]); |
| 7695 } |
| 7696 void test_missingAssignableSelector_prefix_minusMinus_literal() { |
| 7697 ParserTestCase.parseExpression("--0", [ParserErrorCode.MISSING_ASSIGNABLE_SE
LECTOR]); |
| 7698 } |
| 7699 void test_missingAssignableSelector_prefix_plusPlus_literal() { |
| 7700 ParserTestCase.parseExpression("++0", [ParserErrorCode.MISSING_ASSIGNABLE_SE
LECTOR]); |
| 7701 } |
| 7657 void test_missingAssignableSelector_primarySelectorPostfix() { | 7702 void test_missingAssignableSelector_primarySelectorPostfix() { |
| 7658 ParserTestCase.parseExpression("x(y)(z)++", [ParserErrorCode.MISSING_ASSIGNA
BLE_SELECTOR]); | 7703 ParserTestCase.parseExpression("x(y)(z)++", [ParserErrorCode.MISSING_ASSIGNA
BLE_SELECTOR]); |
| 7659 } | 7704 } |
| 7660 void test_missingAssignableSelector_selector() { | 7705 void test_missingAssignableSelector_selector() { |
| 7661 ParserTestCase.parseExpression("x(y)(z).a++", []); | 7706 ParserTestCase.parseExpression("x(y)(z).a++", []); |
| 7662 } | 7707 } |
| 7663 void test_missingAssignableSelector_superPrimaryExpression() { | 7708 void test_missingAssignableSelector_superPrimaryExpression() { |
| 7664 SuperExpression expression = ParserTestCase.parse5("parsePrimaryExpression",
"super", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); | 7709 SuperExpression expression = ParserTestCase.parse5("parsePrimaryExpression",
"super", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); |
| 7665 JUnitTestCase.assertNotNull(expression.keyword); | 7710 JUnitTestCase.assertNotNull(expression.keyword); |
| 7666 } | 7711 } |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7789 } | 7834 } |
| 7790 void test_nonPartOfDirectiveInPart_after() { | 7835 void test_nonPartOfDirectiveInPart_after() { |
| 7791 ParserTestCase.parseCompilationUnit("part of l; part 'f.dart';", [ParserErro
rCode.NON_PART_OF_DIRECTIVE_IN_PART]); | 7836 ParserTestCase.parseCompilationUnit("part of l; part 'f.dart';", [ParserErro
rCode.NON_PART_OF_DIRECTIVE_IN_PART]); |
| 7792 } | 7837 } |
| 7793 void test_nonPartOfDirectiveInPart_before() { | 7838 void test_nonPartOfDirectiveInPart_before() { |
| 7794 ParserTestCase.parseCompilationUnit("part 'f.dart'; part of m;", [ParserErro
rCode.NON_PART_OF_DIRECTIVE_IN_PART]); | 7839 ParserTestCase.parseCompilationUnit("part 'f.dart'; part of m;", [ParserErro
rCode.NON_PART_OF_DIRECTIVE_IN_PART]); |
| 7795 } | 7840 } |
| 7796 void test_nonUserDefinableOperator() { | 7841 void test_nonUserDefinableOperator() { |
| 7797 ParserTestCase.parse4("parseClassMember", <Object> ["C"], "operator +=(int x
) => x + 1;", [ParserErrorCode.NON_USER_DEFINABLE_OPERATOR]); | 7842 ParserTestCase.parse4("parseClassMember", <Object> ["C"], "operator +=(int x
) => x + 1;", [ParserErrorCode.NON_USER_DEFINABLE_OPERATOR]); |
| 7798 } | 7843 } |
| 7844 void test_optionalAfterNormalParameters_named() { |
| 7845 ParserTestCase.parseCompilationUnit("f({a}, b) {}", [ParserErrorCode.NORMAL_
BEFORE_OPTIONAL_PARAMETERS]); |
| 7846 } |
| 7847 void test_optionalAfterNormalParameters_positional() { |
| 7848 ParserTestCase.parseCompilationUnit("f([a], b) {}", [ParserErrorCode.NORMAL_
BEFORE_OPTIONAL_PARAMETERS]); |
| 7849 } |
| 7799 void test_positionalAfterNamedArgument() { | 7850 void test_positionalAfterNamedArgument() { |
| 7800 ParserTestCase.parse5("parseArgumentList", "(x: 1, 2)", [ParserErrorCode.POS
ITIONAL_AFTER_NAMED_ARGUMENT]); | 7851 ParserTestCase.parse5("parseArgumentList", "(x: 1, 2)", [ParserErrorCode.POS
ITIONAL_AFTER_NAMED_ARGUMENT]); |
| 7801 } | 7852 } |
| 7802 void test_positionalParameterOutsideGroup() { | 7853 void test_positionalParameterOutsideGroup() { |
| 7803 ParserTestCase.parse5("parseFormalParameterList", "(a, b = 0)", [ParserError
Code.POSITIONAL_PARAMETER_OUTSIDE_GROUP]); | 7854 ParserTestCase.parse5("parseFormalParameterList", "(a, b = 0)", [ParserError
Code.POSITIONAL_PARAMETER_OUTSIDE_GROUP]); |
| 7804 } | 7855 } |
| 7805 void test_staticAfterConst() { | 7856 void test_staticAfterConst() { |
| 7806 ParserTestCase.parse4("parseClassMember", <Object> ["C"], "final static int
f;", [ParserErrorCode.STATIC_AFTER_FINAL]); | 7857 ParserTestCase.parse4("parseClassMember", <Object> ["C"], "final static int
f;", [ParserErrorCode.STATIC_AFTER_FINAL]); |
| 7807 } | 7858 } |
| 7808 void test_staticAfterFinal() { | 7859 void test_staticAfterFinal() { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 7822 } | 7873 } |
| 7823 void test_staticOperator_returnType() { | 7874 void test_staticOperator_returnType() { |
| 7824 ParserTestCase.parse4("parseClassMember", <Object> ["C"], "static int operat
or +(int x) => x + 1;", [ParserErrorCode.STATIC_OPERATOR]); | 7875 ParserTestCase.parse4("parseClassMember", <Object> ["C"], "static int operat
or +(int x) => x + 1;", [ParserErrorCode.STATIC_OPERATOR]); |
| 7825 } | 7876 } |
| 7826 void test_staticSetterWithoutBody() { | 7877 void test_staticSetterWithoutBody() { |
| 7827 ParserTestCase.parse4("parseClassMember", <Object> ["C"], "static set m(x);"
, [ParserErrorCode.STATIC_SETTER_WITHOUT_BODY]); | 7878 ParserTestCase.parse4("parseClassMember", <Object> ["C"], "static set m(x);"
, [ParserErrorCode.STATIC_SETTER_WITHOUT_BODY]); |
| 7828 } | 7879 } |
| 7829 void test_staticTopLevelDeclaration_class() { | 7880 void test_staticTopLevelDeclaration_class() { |
| 7830 ParserTestCase.parseCompilationUnit("static class C {}", [ParserErrorCode.ST
ATIC_TOP_LEVEL_DECLARATION]); | 7881 ParserTestCase.parseCompilationUnit("static class C {}", [ParserErrorCode.ST
ATIC_TOP_LEVEL_DECLARATION]); |
| 7831 } | 7882 } |
| 7883 void test_staticTopLevelDeclaration_function() { |
| 7884 ParserTestCase.parseCompilationUnit("static f() {}", [ParserErrorCode.STATIC
_TOP_LEVEL_DECLARATION]); |
| 7885 } |
| 7832 void test_staticTopLevelDeclaration_typedef() { | 7886 void test_staticTopLevelDeclaration_typedef() { |
| 7833 ParserTestCase.parseCompilationUnit("static typedef F();", [ParserErrorCode.
STATIC_TOP_LEVEL_DECLARATION]); | 7887 ParserTestCase.parseCompilationUnit("static typedef F();", [ParserErrorCode.
STATIC_TOP_LEVEL_DECLARATION]); |
| 7834 } | 7888 } |
| 7835 void test_staticTopLevelDeclaration_variable() { | 7889 void test_staticTopLevelDeclaration_variable() { |
| 7836 ParserTestCase.parseCompilationUnit("static var x;", [ParserErrorCode.STATIC
_TOP_LEVEL_DECLARATION]); | 7890 ParserTestCase.parseCompilationUnit("static var x;", [ParserErrorCode.STATIC
_TOP_LEVEL_DECLARATION]); |
| 7837 } | 7891 } |
| 7838 void test_switchHasCaseAfterDefaultCase() { | 7892 void test_switchHasCaseAfterDefaultCase() { |
| 7839 ParserTestCase.parse5("parseSwitchStatement", "switch (a) {default: return 0
; case 1: return 1;}", [ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE]); | 7893 ParserTestCase.parse5("parseSwitchStatement", "switch (a) {default: return 0
; case 1: return 1;}", [ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE]); |
| 7840 } | 7894 } |
| 7841 void test_switchHasCaseAfterDefaultCase_repeated() { | 7895 void test_switchHasCaseAfterDefaultCase_repeated() { |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8331 runJUnitTest(__test, __test.test_invalidUnicodeEscape_tooManyDigits_vari
able); | 8385 runJUnitTest(__test, __test.test_invalidUnicodeEscape_tooManyDigits_vari
able); |
| 8332 }); | 8386 }); |
| 8333 _ut.test('test_libraryDirectiveNotFirst', () { | 8387 _ut.test('test_libraryDirectiveNotFirst', () { |
| 8334 final __test = new ErrorParserTest(); | 8388 final __test = new ErrorParserTest(); |
| 8335 runJUnitTest(__test, __test.test_libraryDirectiveNotFirst); | 8389 runJUnitTest(__test, __test.test_libraryDirectiveNotFirst); |
| 8336 }); | 8390 }); |
| 8337 _ut.test('test_libraryDirectiveNotFirst_afterPart', () { | 8391 _ut.test('test_libraryDirectiveNotFirst_afterPart', () { |
| 8338 final __test = new ErrorParserTest(); | 8392 final __test = new ErrorParserTest(); |
| 8339 runJUnitTest(__test, __test.test_libraryDirectiveNotFirst_afterPart); | 8393 runJUnitTest(__test, __test.test_libraryDirectiveNotFirst_afterPart); |
| 8340 }); | 8394 }); |
| 8395 _ut.test('test_localFunctionDeclarationModifier_abstract', () { |
| 8396 final __test = new ErrorParserTest(); |
| 8397 runJUnitTest(__test, __test.test_localFunctionDeclarationModifier_abstra
ct); |
| 8398 }); |
| 8399 _ut.test('test_localFunctionDeclarationModifier_external', () { |
| 8400 final __test = new ErrorParserTest(); |
| 8401 runJUnitTest(__test, __test.test_localFunctionDeclarationModifier_extern
al); |
| 8402 }); |
| 8403 _ut.test('test_localFunctionDeclarationModifier_factory', () { |
| 8404 final __test = new ErrorParserTest(); |
| 8405 runJUnitTest(__test, __test.test_localFunctionDeclarationModifier_factor
y); |
| 8406 }); |
| 8407 _ut.test('test_localFunctionDeclarationModifier_static', () { |
| 8408 final __test = new ErrorParserTest(); |
| 8409 runJUnitTest(__test, __test.test_localFunctionDeclarationModifier_static
); |
| 8410 }); |
| 8341 _ut.test('test_missingAssignableSelector_identifiersAssigned', () { | 8411 _ut.test('test_missingAssignableSelector_identifiersAssigned', () { |
| 8342 final __test = new ErrorParserTest(); | 8412 final __test = new ErrorParserTest(); |
| 8343 runJUnitTest(__test, __test.test_missingAssignableSelector_identifiersAs
signed); | 8413 runJUnitTest(__test, __test.test_missingAssignableSelector_identifiersAs
signed); |
| 8344 }); | 8414 }); |
| 8415 _ut.test('test_missingAssignableSelector_postfix_minusMinus_literal', () { |
| 8416 final __test = new ErrorParserTest(); |
| 8417 runJUnitTest(__test, __test.test_missingAssignableSelector_postfix_minus
Minus_literal); |
| 8418 }); |
| 8419 _ut.test('test_missingAssignableSelector_postfix_plusPlus_literal', () { |
| 8420 final __test = new ErrorParserTest(); |
| 8421 runJUnitTest(__test, __test.test_missingAssignableSelector_postfix_plusP
lus_literal); |
| 8422 }); |
| 8423 _ut.test('test_missingAssignableSelector_prefix_minusMinus_literal', () { |
| 8424 final __test = new ErrorParserTest(); |
| 8425 runJUnitTest(__test, __test.test_missingAssignableSelector_prefix_minusM
inus_literal); |
| 8426 }); |
| 8427 _ut.test('test_missingAssignableSelector_prefix_plusPlus_literal', () { |
| 8428 final __test = new ErrorParserTest(); |
| 8429 runJUnitTest(__test, __test.test_missingAssignableSelector_prefix_plusPl
us_literal); |
| 8430 }); |
| 8345 _ut.test('test_missingAssignableSelector_primarySelectorPostfix', () { | 8431 _ut.test('test_missingAssignableSelector_primarySelectorPostfix', () { |
| 8346 final __test = new ErrorParserTest(); | 8432 final __test = new ErrorParserTest(); |
| 8347 runJUnitTest(__test, __test.test_missingAssignableSelector_primarySelect
orPostfix); | 8433 runJUnitTest(__test, __test.test_missingAssignableSelector_primarySelect
orPostfix); |
| 8348 }); | 8434 }); |
| 8349 _ut.test('test_missingAssignableSelector_selector', () { | 8435 _ut.test('test_missingAssignableSelector_selector', () { |
| 8350 final __test = new ErrorParserTest(); | 8436 final __test = new ErrorParserTest(); |
| 8351 runJUnitTest(__test, __test.test_missingAssignableSelector_selector); | 8437 runJUnitTest(__test, __test.test_missingAssignableSelector_selector); |
| 8352 }); | 8438 }); |
| 8353 _ut.test('test_missingAssignableSelector_superPrimaryExpression', () { | 8439 _ut.test('test_missingAssignableSelector_superPrimaryExpression', () { |
| 8354 final __test = new ErrorParserTest(); | 8440 final __test = new ErrorParserTest(); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8515 runJUnitTest(__test, __test.test_nonPartOfDirectiveInPart_after); | 8601 runJUnitTest(__test, __test.test_nonPartOfDirectiveInPart_after); |
| 8516 }); | 8602 }); |
| 8517 _ut.test('test_nonPartOfDirectiveInPart_before', () { | 8603 _ut.test('test_nonPartOfDirectiveInPart_before', () { |
| 8518 final __test = new ErrorParserTest(); | 8604 final __test = new ErrorParserTest(); |
| 8519 runJUnitTest(__test, __test.test_nonPartOfDirectiveInPart_before); | 8605 runJUnitTest(__test, __test.test_nonPartOfDirectiveInPart_before); |
| 8520 }); | 8606 }); |
| 8521 _ut.test('test_nonUserDefinableOperator', () { | 8607 _ut.test('test_nonUserDefinableOperator', () { |
| 8522 final __test = new ErrorParserTest(); | 8608 final __test = new ErrorParserTest(); |
| 8523 runJUnitTest(__test, __test.test_nonUserDefinableOperator); | 8609 runJUnitTest(__test, __test.test_nonUserDefinableOperator); |
| 8524 }); | 8610 }); |
| 8611 _ut.test('test_optionalAfterNormalParameters_named', () { |
| 8612 final __test = new ErrorParserTest(); |
| 8613 runJUnitTest(__test, __test.test_optionalAfterNormalParameters_named); |
| 8614 }); |
| 8615 _ut.test('test_optionalAfterNormalParameters_positional', () { |
| 8616 final __test = new ErrorParserTest(); |
| 8617 runJUnitTest(__test, __test.test_optionalAfterNormalParameters_positiona
l); |
| 8618 }); |
| 8525 _ut.test('test_positionalAfterNamedArgument', () { | 8619 _ut.test('test_positionalAfterNamedArgument', () { |
| 8526 final __test = new ErrorParserTest(); | 8620 final __test = new ErrorParserTest(); |
| 8527 runJUnitTest(__test, __test.test_positionalAfterNamedArgument); | 8621 runJUnitTest(__test, __test.test_positionalAfterNamedArgument); |
| 8528 }); | 8622 }); |
| 8529 _ut.test('test_positionalParameterOutsideGroup', () { | 8623 _ut.test('test_positionalParameterOutsideGroup', () { |
| 8530 final __test = new ErrorParserTest(); | 8624 final __test = new ErrorParserTest(); |
| 8531 runJUnitTest(__test, __test.test_positionalParameterOutsideGroup); | 8625 runJUnitTest(__test, __test.test_positionalParameterOutsideGroup); |
| 8532 }); | 8626 }); |
| 8533 _ut.test('test_staticAfterConst', () { | 8627 _ut.test('test_staticAfterConst', () { |
| 8534 final __test = new ErrorParserTest(); | 8628 final __test = new ErrorParserTest(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 8559 runJUnitTest(__test, __test.test_staticOperator_returnType); | 8653 runJUnitTest(__test, __test.test_staticOperator_returnType); |
| 8560 }); | 8654 }); |
| 8561 _ut.test('test_staticSetterWithoutBody', () { | 8655 _ut.test('test_staticSetterWithoutBody', () { |
| 8562 final __test = new ErrorParserTest(); | 8656 final __test = new ErrorParserTest(); |
| 8563 runJUnitTest(__test, __test.test_staticSetterWithoutBody); | 8657 runJUnitTest(__test, __test.test_staticSetterWithoutBody); |
| 8564 }); | 8658 }); |
| 8565 _ut.test('test_staticTopLevelDeclaration_class', () { | 8659 _ut.test('test_staticTopLevelDeclaration_class', () { |
| 8566 final __test = new ErrorParserTest(); | 8660 final __test = new ErrorParserTest(); |
| 8567 runJUnitTest(__test, __test.test_staticTopLevelDeclaration_class); | 8661 runJUnitTest(__test, __test.test_staticTopLevelDeclaration_class); |
| 8568 }); | 8662 }); |
| 8663 _ut.test('test_staticTopLevelDeclaration_function', () { |
| 8664 final __test = new ErrorParserTest(); |
| 8665 runJUnitTest(__test, __test.test_staticTopLevelDeclaration_function); |
| 8666 }); |
| 8569 _ut.test('test_staticTopLevelDeclaration_typedef', () { | 8667 _ut.test('test_staticTopLevelDeclaration_typedef', () { |
| 8570 final __test = new ErrorParserTest(); | 8668 final __test = new ErrorParserTest(); |
| 8571 runJUnitTest(__test, __test.test_staticTopLevelDeclaration_typedef); | 8669 runJUnitTest(__test, __test.test_staticTopLevelDeclaration_typedef); |
| 8572 }); | 8670 }); |
| 8573 _ut.test('test_staticTopLevelDeclaration_variable', () { | 8671 _ut.test('test_staticTopLevelDeclaration_variable', () { |
| 8574 final __test = new ErrorParserTest(); | 8672 final __test = new ErrorParserTest(); |
| 8575 runJUnitTest(__test, __test.test_staticTopLevelDeclaration_variable); | 8673 runJUnitTest(__test, __test.test_staticTopLevelDeclaration_variable); |
| 8576 }); | 8674 }); |
| 8577 _ut.test('test_switchHasCaseAfterDefaultCase', () { | 8675 _ut.test('test_switchHasCaseAfterDefaultCase', () { |
| 8578 final __test = new ErrorParserTest(); | 8676 final __test = new ErrorParserTest(); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8838 'skipStringInterpolation_1': new MethodTrampoline(1, (Parser target, arg0) =>
target.skipStringInterpolation(arg0)), | 8936 'skipStringInterpolation_1': new MethodTrampoline(1, (Parser target, arg0) =>
target.skipStringInterpolation(arg0)), |
| 8839 'skipStringLiteral_1': new MethodTrampoline(1, (Parser target, arg0) => target
.skipStringLiteral(arg0)), | 8937 'skipStringLiteral_1': new MethodTrampoline(1, (Parser target, arg0) => target
.skipStringLiteral(arg0)), |
| 8840 'skipTypeArgumentList_1': new MethodTrampoline(1, (Parser target, arg0) => tar
get.skipTypeArgumentList(arg0)), | 8938 'skipTypeArgumentList_1': new MethodTrampoline(1, (Parser target, arg0) => tar
get.skipTypeArgumentList(arg0)), |
| 8841 'skipTypeName_1': new MethodTrampoline(1, (Parser target, arg0) => target.skip
TypeName(arg0)), | 8939 'skipTypeName_1': new MethodTrampoline(1, (Parser target, arg0) => target.skip
TypeName(arg0)), |
| 8842 'skipTypeParameterList_1': new MethodTrampoline(1, (Parser target, arg0) => ta
rget.skipTypeParameterList(arg0)), | 8940 'skipTypeParameterList_1': new MethodTrampoline(1, (Parser target, arg0) => ta
rget.skipTypeParameterList(arg0)), |
| 8843 'translateCharacter_3': new MethodTrampoline(3, (Parser target, arg0, arg1, ar
g2) => target.translateCharacter(arg0, arg1, arg2)), | 8941 'translateCharacter_3': new MethodTrampoline(3, (Parser target, arg0, arg1, ar
g2) => target.translateCharacter(arg0, arg1, arg2)), |
| 8844 'validateFormalParameterList_1': new MethodTrampoline(1, (Parser target, arg0)
=> target.validateFormalParameterList(arg0)), | 8942 'validateFormalParameterList_1': new MethodTrampoline(1, (Parser target, arg0)
=> target.validateFormalParameterList(arg0)), |
| 8845 'validateModifiersForClass_1': new MethodTrampoline(1, (Parser target, arg0) =
> target.validateModifiersForClass(arg0)), | 8943 'validateModifiersForClass_1': new MethodTrampoline(1, (Parser target, arg0) =
> target.validateModifiersForClass(arg0)), |
| 8846 'validateModifiersForConstructor_1': new MethodTrampoline(1, (Parser target, a
rg0) => target.validateModifiersForConstructor(arg0)), | 8944 'validateModifiersForConstructor_1': new MethodTrampoline(1, (Parser target, a
rg0) => target.validateModifiersForConstructor(arg0)), |
| 8847 'validateModifiersForField_1': new MethodTrampoline(1, (Parser target, arg0) =
> target.validateModifiersForField(arg0)), | 8945 'validateModifiersForField_1': new MethodTrampoline(1, (Parser target, arg0) =
> target.validateModifiersForField(arg0)), |
| 8946 'validateModifiersForFunctionDeclarationStatement_1': new MethodTrampoline(1,
(Parser target, arg0) => target.validateModifiersForFunctionDeclarationStatement
(arg0)), |
| 8848 'validateModifiersForGetterOrSetterOrMethod_1': new MethodTrampoline(1, (Parse
r target, arg0) => target.validateModifiersForGetterOrSetterOrMethod(arg0)), | 8947 'validateModifiersForGetterOrSetterOrMethod_1': new MethodTrampoline(1, (Parse
r target, arg0) => target.validateModifiersForGetterOrSetterOrMethod(arg0)), |
| 8849 'validateModifiersForOperator_1': new MethodTrampoline(1, (Parser target, arg0
) => target.validateModifiersForOperator(arg0)), | 8948 'validateModifiersForOperator_1': new MethodTrampoline(1, (Parser target, arg0
) => target.validateModifiersForOperator(arg0)), |
| 8850 'validateModifiersForTopLevelDeclaration_1': new MethodTrampoline(1, (Parser t
arget, arg0) => target.validateModifiersForTopLevelDeclaration(arg0)), | 8949 'validateModifiersForTopLevelDeclaration_1': new MethodTrampoline(1, (Parser t
arget, arg0) => target.validateModifiersForTopLevelDeclaration(arg0)), |
| 8851 'validateModifiersForTopLevelFunction_1': new MethodTrampoline(1, (Parser targ
et, arg0) => target.validateModifiersForTopLevelFunction(arg0)), | 8950 'validateModifiersForTopLevelFunction_1': new MethodTrampoline(1, (Parser targ
et, arg0) => target.validateModifiersForTopLevelFunction(arg0)), |
| 8852 'validateModifiersForTopLevelVariable_1': new MethodTrampoline(1, (Parser targ
et, arg0) => target.validateModifiersForTopLevelVariable(arg0)), | 8951 'validateModifiersForTopLevelVariable_1': new MethodTrampoline(1, (Parser targ
et, arg0) => target.validateModifiersForTopLevelVariable(arg0)), |
| 8853 'validateModifiersForTypedef_1': new MethodTrampoline(1, (Parser target, arg0)
=> target.validateModifiersForTypedef(arg0)),}; | 8952 'validateModifiersForTypedef_1': new MethodTrampoline(1, (Parser target, arg0)
=> target.validateModifiersForTypedef(arg0)),}; |
| 8854 | 8953 |
| 8855 | 8954 |
| 8856 Object invokeParserMethodImpl(Parser parser, String methodName, List<Object> obj
ects, Token tokenStream) { | 8955 Object invokeParserMethodImpl(Parser parser, String methodName, List<Object> obj
ects, Token tokenStream) { |
| 8857 parser.currentToken = tokenStream; | 8956 parser.currentToken = tokenStream; |
| 8858 MethodTrampoline method = _methodTable_Parser['${methodName}_${objects.length}
']; | 8957 MethodTrampoline method = _methodTable_Parser['${methodName}_${objects.length}
']; |
| 8859 return method.invoke(parser, objects); | 8958 return method.invoke(parser, objects); |
| 8860 } | 8959 } |
| OLD | NEW |