Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: pkg/analyzer_experimental/test/generated/parser_test.dart

Issue 18129004: Simplify constructors translation, improve code style. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 6087 matching lines...) Expand 10 before | Expand all | Expand 10 after
6098 EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand); 6098 EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
6099 } 6099 }
6100 void test_shiftExpression_precedence_additive_right() { 6100 void test_shiftExpression_precedence_additive_right() {
6101 BinaryExpression expression = ParserTestCase.parseExpression("x << y + z", [ ]); 6101 BinaryExpression expression = ParserTestCase.parseExpression("x << y + z", [ ]);
6102 EngineTestCase.assertInstanceOf(BinaryExpression, expression.rightOperand); 6102 EngineTestCase.assertInstanceOf(BinaryExpression, expression.rightOperand);
6103 } 6103 }
6104 void test_shiftExpression_super() { 6104 void test_shiftExpression_super() {
6105 BinaryExpression expression = ParserTestCase.parseExpression("super >> 4 << 3", []); 6105 BinaryExpression expression = ParserTestCase.parseExpression("super >> 4 << 3", []);
6106 EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand); 6106 EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
6107 } 6107 }
6108 void test_topLevelVariable_withMetadata() {
6109 ParserTestCase.parseCompilationUnit("String @A string;", []);
6110 }
6108 static dartSuite() { 6111 static dartSuite() {
6109 _ut.group('ComplexParserTest', () { 6112 _ut.group('ComplexParserTest', () {
6110 _ut.test('test_additiveExpression_noSpaces', () { 6113 _ut.test('test_additiveExpression_noSpaces', () {
6111 final __test = new ComplexParserTest(); 6114 final __test = new ComplexParserTest();
6112 runJUnitTest(__test, __test.test_additiveExpression_noSpaces); 6115 runJUnitTest(__test, __test.test_additiveExpression_noSpaces);
6113 }); 6116 });
6114 _ut.test('test_additiveExpression_normal', () { 6117 _ut.test('test_additiveExpression_normal', () {
6115 final __test = new ComplexParserTest(); 6118 final __test = new ComplexParserTest();
6116 runJUnitTest(__test, __test.test_additiveExpression_normal); 6119 runJUnitTest(__test, __test.test_additiveExpression_normal);
6117 }); 6120 });
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
6284 runJUnitTest(__test, __test.test_shiftExpression_precedence_additive_lef t); 6287 runJUnitTest(__test, __test.test_shiftExpression_precedence_additive_lef t);
6285 }); 6288 });
6286 _ut.test('test_shiftExpression_precedence_additive_right', () { 6289 _ut.test('test_shiftExpression_precedence_additive_right', () {
6287 final __test = new ComplexParserTest(); 6290 final __test = new ComplexParserTest();
6288 runJUnitTest(__test, __test.test_shiftExpression_precedence_additive_rig ht); 6291 runJUnitTest(__test, __test.test_shiftExpression_precedence_additive_rig ht);
6289 }); 6292 });
6290 _ut.test('test_shiftExpression_super', () { 6293 _ut.test('test_shiftExpression_super', () {
6291 final __test = new ComplexParserTest(); 6294 final __test = new ComplexParserTest();
6292 runJUnitTest(__test, __test.test_shiftExpression_super); 6295 runJUnitTest(__test, __test.test_shiftExpression_super);
6293 }); 6296 });
6297 _ut.test('test_topLevelVariable_withMetadata', () {
6298 final __test = new ComplexParserTest();
6299 runJUnitTest(__test, __test.test_topLevelVariable_withMetadata);
6300 });
6294 }); 6301 });
6295 } 6302 }
6296 } 6303 }
6297 /** 6304 /**
6298 * Instances of the class `ASTValidator` are used to validate the correct constr uction of an 6305 * Instances of the class `ASTValidator` are used to validate the correct constr uction of an
6299 * AST structure. 6306 * AST structure.
6300 */ 6307 */
6301 class ASTValidator extends GeneralizingASTVisitor<Object> { 6308 class ASTValidator extends GeneralizingASTVisitor<Object> {
6302 6309
6303 /** 6310 /**
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
6604 static dartSuite() { 6611 static dartSuite() {
6605 _ut.group('ParserTestCase', () { 6612 _ut.group('ParserTestCase', () {
6606 }); 6613 });
6607 } 6614 }
6608 } 6615 }
6609 /** 6616 /**
6610 * The class `RecoveryParserTest` defines parser tests that test the parsing of invalid code 6617 * The class `RecoveryParserTest` defines parser tests that test the parsing of invalid code
6611 * sequences to ensure that the correct recovery steps are taken in the parser. 6618 * sequences to ensure that the correct recovery steps are taken in the parser.
6612 */ 6619 */
6613 class RecoveryParserTest extends ParserTestCase { 6620 class RecoveryParserTest extends ParserTestCase {
6614 void fail_incompleteReturnType() { 6621 void fail_incomplete_returnType() {
6615 ParserTestCase.parseCompilationUnit(EngineTestCase.createSource(["Map<Symbol , convertStringToSymbolMap(Map<String, dynamic> map) {", " if (map == null) ret urn null;", " Map<Symbol, dynamic> result = new Map<Symbol, dynamic>();", " ma p.forEach((name, value) {", " result[new Symbol(name)] = value;", " });", " return result;", "}"]), []); 6622 ParserTestCase.parseCompilationUnit(EngineTestCase.createSource(["Map<Symbol , convertStringToSymbolMap(Map<String, dynamic> map) {", " if (map == null) ret urn null;", " Map<Symbol, dynamic> result = new Map<Symbol, dynamic>();", " ma p.forEach((name, value) {", " result[new Symbol(name)] = value;", " });", " return result;", "}"]), []);
6616 } 6623 }
6617 void test_additiveExpression_missing_LHS() { 6624 void test_additiveExpression_missing_LHS() {
6618 BinaryExpression expression = ParserTestCase.parseExpression("+ y", [ParserE rrorCode.MISSING_IDENTIFIER]); 6625 BinaryExpression expression = ParserTestCase.parseExpression("+ y", [ParserE rrorCode.MISSING_IDENTIFIER]);
6619 EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.leftOperand); 6626 EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.leftOperand);
6620 JUnitTestCase.assertTrue(expression.leftOperand.isSynthetic); 6627 JUnitTestCase.assertTrue(expression.leftOperand.isSynthetic);
6621 } 6628 }
6622 void test_additiveExpression_missing_LHS_RHS() { 6629 void test_additiveExpression_missing_LHS_RHS() {
6623 BinaryExpression expression = ParserTestCase.parseExpression("+", [ParserErr orCode.MISSING_IDENTIFIER, ParserErrorCode.MISSING_IDENTIFIER]); 6630 BinaryExpression expression = ParserTestCase.parseExpression("+", [ParserErr orCode.MISSING_IDENTIFIER, ParserErrorCode.MISSING_IDENTIFIER]);
6624 EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.leftOperand); 6631 EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.leftOperand);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
6839 EngineTestCase.assertInstanceOf(SimpleIdentifier, syntheticExpression); 6846 EngineTestCase.assertInstanceOf(SimpleIdentifier, syntheticExpression);
6840 JUnitTestCase.assertTrue(syntheticExpression.isSynthetic); 6847 JUnitTestCase.assertTrue(syntheticExpression.isSynthetic);
6841 } 6848 }
6842 void test_expressionList_multiple_start() { 6849 void test_expressionList_multiple_start() {
6843 List<Expression> result = ParserTestCase.parse5("parseExpressionList", "1, 2 , 3,", [ParserErrorCode.MISSING_IDENTIFIER]); 6850 List<Expression> result = ParserTestCase.parse5("parseExpressionList", "1, 2 , 3,", [ParserErrorCode.MISSING_IDENTIFIER]);
6844 EngineTestCase.assertSize(4, result); 6851 EngineTestCase.assertSize(4, result);
6845 Expression syntheticExpression = result[3]; 6852 Expression syntheticExpression = result[3];
6846 EngineTestCase.assertInstanceOf(SimpleIdentifier, syntheticExpression); 6853 EngineTestCase.assertInstanceOf(SimpleIdentifier, syntheticExpression);
6847 JUnitTestCase.assertTrue(syntheticExpression.isSynthetic); 6854 JUnitTestCase.assertTrue(syntheticExpression.isSynthetic);
6848 } 6855 }
6856 void test_incomplete_topLevelVariable() {
6857 CompilationUnit unit = ParserTestCase.parseCompilationUnit("String", [Parser ErrorCode.EXPECTED_EXECUTABLE]);
6858 NodeList<CompilationUnitMember> declarations = unit.declarations;
6859 EngineTestCase.assertSize(1, declarations);
6860 CompilationUnitMember member = declarations[0];
6861 EngineTestCase.assertInstanceOf(TopLevelVariableDeclaration, member);
6862 NodeList<VariableDeclaration> variables = ((member as TopLevelVariableDeclar ation)).variables.variables;
6863 EngineTestCase.assertSize(1, variables);
6864 SimpleIdentifier name = variables[0].name;
6865 JUnitTestCase.assertTrue(name.isSynthetic);
6866 }
6849 void test_isExpression_noType() { 6867 void test_isExpression_noType() {
6850 CompilationUnit unit = ParserTestCase.parseCompilationUnit("class Bar<T exte nds Foo> {m(x){if (x is ) return;if (x is !)}}", [ParserErrorCode.EXPECTED_TYPE_ NAME, ParserErrorCode.EXPECTED_TYPE_NAME, ParserErrorCode.MISSING_STATEMENT]); 6868 CompilationUnit unit = ParserTestCase.parseCompilationUnit("class Bar<T exte nds Foo> {m(x){if (x is ) return;if (x is !)}}", [ParserErrorCode.EXPECTED_TYPE_ NAME, ParserErrorCode.EXPECTED_TYPE_NAME, ParserErrorCode.MISSING_STATEMENT]);
6851 ClassDeclaration declaration = unit.declarations[0] as ClassDeclaration; 6869 ClassDeclaration declaration = unit.declarations[0] as ClassDeclaration;
6852 MethodDeclaration method = declaration.members[0] as MethodDeclaration; 6870 MethodDeclaration method = declaration.members[0] as MethodDeclaration;
6853 BlockFunctionBody body = method.body as BlockFunctionBody; 6871 BlockFunctionBody body = method.body as BlockFunctionBody;
6854 IfStatement ifStatement = body.block.statements[1] as IfStatement; 6872 IfStatement ifStatement = body.block.statements[1] as IfStatement;
6855 IsExpression expression = ifStatement.condition as IsExpression; 6873 IsExpression expression = ifStatement.condition as IsExpression;
6856 JUnitTestCase.assertNotNull(expression.expression); 6874 JUnitTestCase.assertNotNull(expression.expression);
6857 JUnitTestCase.assertNotNull(expression.isOperator); 6875 JUnitTestCase.assertNotNull(expression.isOperator);
6858 JUnitTestCase.assertNotNull(expression.notOperator); 6876 JUnitTestCase.assertNotNull(expression.notOperator);
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
7192 runJUnitTest(__test, __test.test_expressionList_multiple_end); 7210 runJUnitTest(__test, __test.test_expressionList_multiple_end);
7193 }); 7211 });
7194 _ut.test('test_expressionList_multiple_middle', () { 7212 _ut.test('test_expressionList_multiple_middle', () {
7195 final __test = new RecoveryParserTest(); 7213 final __test = new RecoveryParserTest();
7196 runJUnitTest(__test, __test.test_expressionList_multiple_middle); 7214 runJUnitTest(__test, __test.test_expressionList_multiple_middle);
7197 }); 7215 });
7198 _ut.test('test_expressionList_multiple_start', () { 7216 _ut.test('test_expressionList_multiple_start', () {
7199 final __test = new RecoveryParserTest(); 7217 final __test = new RecoveryParserTest();
7200 runJUnitTest(__test, __test.test_expressionList_multiple_start); 7218 runJUnitTest(__test, __test.test_expressionList_multiple_start);
7201 }); 7219 });
7220 _ut.test('test_incomplete_topLevelVariable', () {
7221 final __test = new RecoveryParserTest();
7222 runJUnitTest(__test, __test.test_incomplete_topLevelVariable);
7223 });
7202 _ut.test('test_isExpression_noType', () { 7224 _ut.test('test_isExpression_noType', () {
7203 final __test = new RecoveryParserTest(); 7225 final __test = new RecoveryParserTest();
7204 runJUnitTest(__test, __test.test_isExpression_noType); 7226 runJUnitTest(__test, __test.test_isExpression_noType);
7205 }); 7227 });
7206 _ut.test('test_logicalAndExpression_missing_LHS', () { 7228 _ut.test('test_logicalAndExpression_missing_LHS', () {
7207 final __test = new RecoveryParserTest(); 7229 final __test = new RecoveryParserTest();
7208 runJUnitTest(__test, __test.test_logicalAndExpression_missing_LHS); 7230 runJUnitTest(__test, __test.test_logicalAndExpression_missing_LHS);
7209 }); 7231 });
7210 _ut.test('test_logicalAndExpression_missing_LHS_RHS', () { 7232 _ut.test('test_logicalAndExpression_missing_LHS_RHS', () {
7211 final __test = new RecoveryParserTest(); 7233 final __test = new RecoveryParserTest();
(...skipping 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after
9031 'validateModifiersForTopLevelFunction_1': new MethodTrampoline(1, (Parser targ et, arg0) => target.validateModifiersForTopLevelFunction(arg0)), 9053 'validateModifiersForTopLevelFunction_1': new MethodTrampoline(1, (Parser targ et, arg0) => target.validateModifiersForTopLevelFunction(arg0)),
9032 'validateModifiersForTopLevelVariable_1': new MethodTrampoline(1, (Parser targ et, arg0) => target.validateModifiersForTopLevelVariable(arg0)), 9054 'validateModifiersForTopLevelVariable_1': new MethodTrampoline(1, (Parser targ et, arg0) => target.validateModifiersForTopLevelVariable(arg0)),
9033 'validateModifiersForTypedef_1': new MethodTrampoline(1, (Parser target, arg0) => target.validateModifiersForTypedef(arg0)),}; 9055 'validateModifiersForTypedef_1': new MethodTrampoline(1, (Parser target, arg0) => target.validateModifiersForTypedef(arg0)),};
9034 9056
9035 9057
9036 Object invokeParserMethodImpl(Parser parser, String methodName, List<Object> obj ects, Token tokenStream) { 9058 Object invokeParserMethodImpl(Parser parser, String methodName, List<Object> obj ects, Token tokenStream) {
9037 parser.currentToken = tokenStream; 9059 parser.currentToken = tokenStream;
9038 MethodTrampoline method = _methodTable_Parser['${methodName}_${objects.length} ']; 9060 MethodTrampoline method = _methodTable_Parser['${methodName}_${objects.length} '];
9039 return method.invoke(parser, objects); 9061 return method.invoke(parser, objects);
9040 } 9062 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698