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 | 3 |
4 library engine.parser_test; | 4 library engine.parser_test; |
5 | 5 |
6 import 'dart:collection'; | 6 import 'dart:collection'; |
7 import 'package:analyzer_experimental/src/generated/java_core.dart'; | 7 import 'package:analyzer_experimental/src/generated/java_core.dart'; |
8 import 'package:analyzer_experimental/src/generated/java_engine.dart'; | 8 import 'package:analyzer_experimental/src/generated/java_engine.dart'; |
9 import 'package:analyzer_experimental/src/generated/java_junit.dart'; | 9 import 'package:analyzer_experimental/src/generated/java_junit.dart'; |
10 import 'package:analyzer_experimental/src/generated/source.dart'; | 10 import 'package:analyzer_experimental/src/generated/source.dart'; |
(...skipping 6180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6191 } | 6191 } |
6192 Object visitNode(ASTNode node) { | 6192 Object visitNode(ASTNode node) { |
6193 validate(node); | 6193 validate(node); |
6194 return super.visitNode(node); | 6194 return super.visitNode(node); |
6195 } | 6195 } |
6196 /** | 6196 /** |
6197 * Validate that the given AST node is correctly constructed. | 6197 * Validate that the given AST node is correctly constructed. |
6198 * @param node the AST node being validated | 6198 * @param node the AST node being validated |
6199 */ | 6199 */ |
6200 void validate(ASTNode node) { | 6200 void validate(ASTNode node) { |
6201 ASTNode parent21 = node.parent; | 6201 ASTNode parent22 = node.parent; |
6202 if (node is CompilationUnit) { | 6202 if (node is CompilationUnit) { |
6203 if (parent21 != null) { | 6203 if (parent22 != null) { |
6204 _errors.add("Compilation units should not have a parent"); | 6204 _errors.add("Compilation units should not have a parent"); |
6205 } | 6205 } |
6206 } else { | 6206 } else { |
6207 if (parent21 == null) { | 6207 if (parent22 == null) { |
6208 _errors.add("No parent for ${node.runtimeType.toString()}"); | 6208 _errors.add("No parent for ${node.runtimeType.toString()}"); |
6209 } | 6209 } |
6210 } | 6210 } |
6211 if (node.beginToken == null) { | 6211 if (node.beginToken == null) { |
6212 _errors.add("No begin token for ${node.runtimeType.toString()}"); | 6212 _errors.add("No begin token for ${node.runtimeType.toString()}"); |
6213 } | 6213 } |
6214 if (node.endToken == null) { | 6214 if (node.endToken == null) { |
6215 _errors.add("No end token for ${node.runtimeType.toString()}"); | 6215 _errors.add("No end token for ${node.runtimeType.toString()}"); |
6216 } | 6216 } |
6217 int nodeStart = node.offset; | 6217 int nodeStart = node.offset; |
6218 int nodeLength = node.length; | 6218 int nodeLength = node.length; |
6219 if (nodeStart < 0 || nodeLength < 0) { | 6219 if (nodeStart < 0 || nodeLength < 0) { |
6220 _errors.add("No source info for ${node.runtimeType.toString()}"); | 6220 _errors.add("No source info for ${node.runtimeType.toString()}"); |
6221 } | 6221 } |
6222 if (parent21 != null) { | 6222 if (parent22 != null) { |
6223 int nodeEnd = nodeStart + nodeLength; | 6223 int nodeEnd = nodeStart + nodeLength; |
6224 int parentStart = parent21.offset; | 6224 int parentStart = parent22.offset; |
6225 int parentEnd = parentStart + parent21.length; | 6225 int parentEnd = parentStart + parent22.length; |
6226 if (nodeStart < parentStart) { | 6226 if (nodeStart < parentStart) { |
6227 _errors.add("Invalid source start (${nodeStart}) for ${node.runtimeType.
toString()} inside ${parent21.runtimeType.toString()} (${parentStart})"); | 6227 _errors.add("Invalid source start (${nodeStart}) for ${node.runtimeType.
toString()} inside ${parent22.runtimeType.toString()} (${parentStart})"); |
6228 } | 6228 } |
6229 if (nodeEnd > parentEnd) { | 6229 if (nodeEnd > parentEnd) { |
6230 _errors.add("Invalid source end (${nodeEnd}) for ${node.runtimeType.toSt
ring()} inside ${parent21.runtimeType.toString()} (${parentStart})"); | 6230 _errors.add("Invalid source end (${nodeEnd}) for ${node.runtimeType.toSt
ring()} inside ${parent22.runtimeType.toString()} (${parentStart})"); |
6231 } | 6231 } |
6232 } | 6232 } |
6233 } | 6233 } |
6234 } | 6234 } |
6235 class ParserTestCase extends EngineTestCase { | 6235 class ParserTestCase extends EngineTestCase { |
6236 /** | 6236 /** |
6237 * An empty array of objects used as arguments to zero-argument methods. | 6237 * An empty array of objects used as arguments to zero-argument methods. |
6238 */ | 6238 */ |
6239 static List<Object> _EMPTY_ARGUMENTS = new List<Object>(0); | 6239 static List<Object> _EMPTY_ARGUMENTS = new List<Object>(0); |
6240 /** | 6240 /** |
(...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7669 } | 7669 } |
7670 void test_staticTopLevelDeclaration_class() { | 7670 void test_staticTopLevelDeclaration_class() { |
7671 ParserTestCase.parse5("parseCompilationUnit", "static class C {}", [ParserEr
rorCode.STATIC_TOP_LEVEL_DECLARATION]); | 7671 ParserTestCase.parse5("parseCompilationUnit", "static class C {}", [ParserEr
rorCode.STATIC_TOP_LEVEL_DECLARATION]); |
7672 } | 7672 } |
7673 void test_staticTopLevelDeclaration_typedef() { | 7673 void test_staticTopLevelDeclaration_typedef() { |
7674 ParserTestCase.parse5("parseCompilationUnit", "static typedef F();", [Parser
ErrorCode.STATIC_TOP_LEVEL_DECLARATION]); | 7674 ParserTestCase.parse5("parseCompilationUnit", "static typedef F();", [Parser
ErrorCode.STATIC_TOP_LEVEL_DECLARATION]); |
7675 } | 7675 } |
7676 void test_staticTopLevelDeclaration_variable() { | 7676 void test_staticTopLevelDeclaration_variable() { |
7677 ParserTestCase.parse5("parseCompilationUnit", "static var x;", [ParserErrorC
ode.STATIC_TOP_LEVEL_DECLARATION]); | 7677 ParserTestCase.parse5("parseCompilationUnit", "static var x;", [ParserErrorC
ode.STATIC_TOP_LEVEL_DECLARATION]); |
7678 } | 7678 } |
| 7679 void test_switchHasCaseAfterDefaultCase() { |
| 7680 ParserTestCase.parse5("parseSwitchStatement", "switch (a) {default: return 0
; case 1: return 1;}", [ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE]); |
| 7681 } |
| 7682 void test_switchHasCaseAfterDefaultCase_repeated() { |
| 7683 ParserTestCase.parse5("parseSwitchStatement", "switch (a) {default: return 0
; case 1: return 1; case 2: return 2;}", [ParserErrorCode.SWITCH_HAS_CASE_AFTER_
DEFAULT_CASE, ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE]); |
| 7684 } |
| 7685 void test_switchHasMultipleDefaultCases() { |
| 7686 ParserTestCase.parse5("parseSwitchStatement", "switch (a) {default: return 0
; default: return 1;}", [ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES]); |
| 7687 } |
| 7688 void test_switchHasMultipleDefaultCases_repeated() { |
| 7689 ParserTestCase.parse5("parseSwitchStatement", "switch (a) {default: return 0
; default: return 1; default: return 2;}", [ParserErrorCode.SWITCH_HAS_MULTIPLE_
DEFAULT_CASES, ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES]); |
| 7690 } |
7679 void test_topLevelOperator_withoutType() { | 7691 void test_topLevelOperator_withoutType() { |
7680 ParserTestCase.parse4("parseCompilationUnitMember", <Object> [emptyCommentAn
dMetadata()], "operator +(bool x, bool y) => x | y;", [ParserErrorCode.TOP_LEVEL
_OPERATOR]); | 7692 ParserTestCase.parse4("parseCompilationUnitMember", <Object> [emptyCommentAn
dMetadata()], "operator +(bool x, bool y) => x | y;", [ParserErrorCode.TOP_LEVEL
_OPERATOR]); |
7681 } | 7693 } |
7682 void test_topLevelOperator_withType() { | 7694 void test_topLevelOperator_withType() { |
7683 ParserTestCase.parse4("parseCompilationUnitMember", <Object> [emptyCommentAn
dMetadata()], "bool operator +(bool x, bool y) => x | y;", [ParserErrorCode.TOP_
LEVEL_OPERATOR]); | 7695 ParserTestCase.parse4("parseCompilationUnitMember", <Object> [emptyCommentAn
dMetadata()], "bool operator +(bool x, bool y) => x | y;", [ParserErrorCode.TOP_
LEVEL_OPERATOR]); |
7684 } | 7696 } |
7685 void test_topLevelOperator_withVoid() { | 7697 void test_topLevelOperator_withVoid() { |
7686 ParserTestCase.parse4("parseCompilationUnitMember", <Object> [emptyCommentAn
dMetadata()], "void operator +(bool x, bool y) => x | y;", [ParserErrorCode.TOP_
LEVEL_OPERATOR]); | 7698 ParserTestCase.parse4("parseCompilationUnitMember", <Object> [emptyCommentAn
dMetadata()], "void operator +(bool x, bool y) => x | y;", [ParserErrorCode.TOP_
LEVEL_OPERATOR]); |
7687 } | 7699 } |
7688 void test_unexpectedTerminatorForParameterGroup_named() { | 7700 void test_unexpectedTerminatorForParameterGroup_named() { |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8330 runJUnitTest(__test, __test.test_staticTopLevelDeclaration_class); | 8342 runJUnitTest(__test, __test.test_staticTopLevelDeclaration_class); |
8331 }); | 8343 }); |
8332 _ut.test('test_staticTopLevelDeclaration_typedef', () { | 8344 _ut.test('test_staticTopLevelDeclaration_typedef', () { |
8333 final __test = new ErrorParserTest(); | 8345 final __test = new ErrorParserTest(); |
8334 runJUnitTest(__test, __test.test_staticTopLevelDeclaration_typedef); | 8346 runJUnitTest(__test, __test.test_staticTopLevelDeclaration_typedef); |
8335 }); | 8347 }); |
8336 _ut.test('test_staticTopLevelDeclaration_variable', () { | 8348 _ut.test('test_staticTopLevelDeclaration_variable', () { |
8337 final __test = new ErrorParserTest(); | 8349 final __test = new ErrorParserTest(); |
8338 runJUnitTest(__test, __test.test_staticTopLevelDeclaration_variable); | 8350 runJUnitTest(__test, __test.test_staticTopLevelDeclaration_variable); |
8339 }); | 8351 }); |
| 8352 _ut.test('test_switchHasCaseAfterDefaultCase', () { |
| 8353 final __test = new ErrorParserTest(); |
| 8354 runJUnitTest(__test, __test.test_switchHasCaseAfterDefaultCase); |
| 8355 }); |
| 8356 _ut.test('test_switchHasCaseAfterDefaultCase_repeated', () { |
| 8357 final __test = new ErrorParserTest(); |
| 8358 runJUnitTest(__test, __test.test_switchHasCaseAfterDefaultCase_repeated)
; |
| 8359 }); |
| 8360 _ut.test('test_switchHasMultipleDefaultCases', () { |
| 8361 final __test = new ErrorParserTest(); |
| 8362 runJUnitTest(__test, __test.test_switchHasMultipleDefaultCases); |
| 8363 }); |
| 8364 _ut.test('test_switchHasMultipleDefaultCases_repeated', () { |
| 8365 final __test = new ErrorParserTest(); |
| 8366 runJUnitTest(__test, __test.test_switchHasMultipleDefaultCases_repeated)
; |
| 8367 }); |
8340 _ut.test('test_topLevelOperator_withType', () { | 8368 _ut.test('test_topLevelOperator_withType', () { |
8341 final __test = new ErrorParserTest(); | 8369 final __test = new ErrorParserTest(); |
8342 runJUnitTest(__test, __test.test_topLevelOperator_withType); | 8370 runJUnitTest(__test, __test.test_topLevelOperator_withType); |
8343 }); | 8371 }); |
8344 _ut.test('test_topLevelOperator_withVoid', () { | 8372 _ut.test('test_topLevelOperator_withVoid', () { |
8345 final __test = new ErrorParserTest(); | 8373 final __test = new ErrorParserTest(); |
8346 runJUnitTest(__test, __test.test_topLevelOperator_withVoid); | 8374 runJUnitTest(__test, __test.test_topLevelOperator_withVoid); |
8347 }); | 8375 }); |
8348 _ut.test('test_topLevelOperator_withoutType', () { | 8376 _ut.test('test_topLevelOperator_withoutType', () { |
8349 final __test = new ErrorParserTest(); | 8377 final __test = new ErrorParserTest(); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8592 'validateModifiersForTopLevelFunction_1': new MethodTrampoline(1, (Parser targ
et, arg0) => target.validateModifiersForTopLevelFunction(arg0)), | 8620 'validateModifiersForTopLevelFunction_1': new MethodTrampoline(1, (Parser targ
et, arg0) => target.validateModifiersForTopLevelFunction(arg0)), |
8593 'validateModifiersForTopLevelVariable_1': new MethodTrampoline(1, (Parser targ
et, arg0) => target.validateModifiersForTopLevelVariable(arg0)), | 8621 'validateModifiersForTopLevelVariable_1': new MethodTrampoline(1, (Parser targ
et, arg0) => target.validateModifiersForTopLevelVariable(arg0)), |
8594 'validateModifiersForTypedef_1': new MethodTrampoline(1, (Parser target, arg0)
=> target.validateModifiersForTypedef(arg0)),}; | 8622 'validateModifiersForTypedef_1': new MethodTrampoline(1, (Parser target, arg0)
=> target.validateModifiersForTypedef(arg0)),}; |
8595 | 8623 |
8596 | 8624 |
8597 Object invokeParserMethodImpl(Parser parser, String methodName, List<Object> obj
ects, Token tokenStream) { | 8625 Object invokeParserMethodImpl(Parser parser, String methodName, List<Object> obj
ects, Token tokenStream) { |
8598 parser.currentToken = tokenStream; | 8626 parser.currentToken = tokenStream; |
8599 MethodTrampoline method = _methodTable_Parser['${methodName}_${objects.length}
']; | 8627 MethodTrampoline method = _methodTable_Parser['${methodName}_${objects.length}
']; |
8600 return method.invoke(parser, objects); | 8628 return method.invoke(parser, objects); |
8601 } | 8629 } |
OLD | NEW |