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

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

Issue 24481002: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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.ast_test; 3 library engine.ast_test;
4 import 'package:analyzer_experimental/src/generated/java_core.dart'; 4 import 'package:analyzer_experimental/src/generated/java_core.dart';
5 import 'package:analyzer_experimental/src/generated/java_junit.dart'; 5 import 'package:analyzer_experimental/src/generated/java_junit.dart';
6 import 'package:analyzer_experimental/src/generated/scanner.dart'; 6 import 'package:analyzer_experimental/src/generated/scanner.dart';
7 import 'package:analyzer_experimental/src/generated/ast.dart'; 7 import 'package:analyzer_experimental/src/generated/ast.dart';
8 import 'package:analyzer_experimental/src/generated/utilities_dart.dart'; 8 import 'package:analyzer_experimental/src/generated/utilities_dart.dart';
9 import 'package:analyzer_experimental/src/generated/element.dart' show ClassElem ent; 9 import 'package:analyzer_experimental/src/generated/element.dart' show ClassElem ent;
10 import 'package:unittest/unittest.dart' as _ut; 10 import 'package:unittest/unittest.dart' as _ut;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 static AdjacentStrings adjacentStrings(List<StringLiteral> strings) => new Adj acentStrings.full(list(strings)); 232 static AdjacentStrings adjacentStrings(List<StringLiteral> strings) => new Adj acentStrings.full(list(strings));
233 static Annotation annotation(Identifier name) => new Annotation.full(TokenFact ory.token3(TokenType.AT), name, null, null, null); 233 static Annotation annotation(Identifier name) => new Annotation.full(TokenFact ory.token3(TokenType.AT), name, null, null, null);
234 static Annotation annotation2(Identifier name, SimpleIdentifier constructorNam e, ArgumentList arguments) => new Annotation.full(TokenFactory.token3(TokenType. AT), name, TokenFactory.token3(TokenType.PERIOD), constructorName, arguments); 234 static Annotation annotation2(Identifier name, SimpleIdentifier constructorNam e, ArgumentList arguments) => new Annotation.full(TokenFactory.token3(TokenType. AT), name, TokenFactory.token3(TokenType.PERIOD), constructorName, arguments);
235 static ArgumentDefinitionTest argumentDefinitionTest(String identifier) => new ArgumentDefinitionTest.full(TokenFactory.token3(TokenType.QUESTION), identifier 3(identifier)); 235 static ArgumentDefinitionTest argumentDefinitionTest(String identifier) => new ArgumentDefinitionTest.full(TokenFactory.token3(TokenType.QUESTION), identifier 3(identifier));
236 static ArgumentList argumentList(List<Expression> arguments) => new ArgumentLi st.full(TokenFactory.token3(TokenType.OPEN_PAREN), list(arguments), TokenFactory .token3(TokenType.CLOSE_PAREN)); 236 static ArgumentList argumentList(List<Expression> arguments) => new ArgumentLi st.full(TokenFactory.token3(TokenType.OPEN_PAREN), list(arguments), TokenFactory .token3(TokenType.CLOSE_PAREN));
237 static AsExpression asExpression(Expression expression, TypeName type) => new AsExpression.full(expression, TokenFactory.token(Keyword.AS), type); 237 static AsExpression asExpression(Expression expression, TypeName type) => new AsExpression.full(expression, TokenFactory.token(Keyword.AS), type);
238 static AssertStatement assertStatement(Expression condition) => new AssertStat ement.full(TokenFactory.token(Keyword.ASSERT), TokenFactory.token3(TokenType.OPE N_PAREN), condition, TokenFactory.token3(TokenType.CLOSE_PAREN), TokenFactory.to ken3(TokenType.SEMICOLON)); 238 static AssertStatement assertStatement(Expression condition) => new AssertStat ement.full(TokenFactory.token(Keyword.ASSERT), TokenFactory.token3(TokenType.OPE N_PAREN), condition, TokenFactory.token3(TokenType.CLOSE_PAREN), TokenFactory.to ken3(TokenType.SEMICOLON));
239 static AssignmentExpression assignmentExpression(Expression leftHandSide, Toke nType operator, Expression rightHandSide) => new AssignmentExpression.full(leftH andSide, TokenFactory.token3(operator), rightHandSide); 239 static AssignmentExpression assignmentExpression(Expression leftHandSide, Toke nType operator, Expression rightHandSide) => new AssignmentExpression.full(leftH andSide, TokenFactory.token3(operator), rightHandSide);
240 static BinaryExpression binaryExpression(Expression leftOperand, TokenType ope rator, Expression rightOperand) => new BinaryExpression.full(leftOperand, TokenF actory.token3(operator), rightOperand); 240 static BinaryExpression binaryExpression(Expression leftOperand, TokenType ope rator, Expression rightOperand) => new BinaryExpression.full(leftOperand, TokenF actory.token3(operator), rightOperand);
241 static Block block(List<Statement> statements) => new Block.full(TokenFactory. token3(TokenType.OPEN_CURLY_BRACKET), list(statements), TokenFactory.token3(Toke nType.CLOSE_CURLY_BRACKET)); 241 static Block block(List<Statement> statements) => new Block.full(TokenFactory. token3(TokenType.OPEN_CURLY_BRACKET), list(statements), TokenFactory.token3(Toke nType.CLOSE_CURLY_BRACKET));
242 static BlockFunctionBody blockFunctionBody(List<Statement> statements) => new BlockFunctionBody.full(block(statements)); 242 static BlockFunctionBody blockFunctionBody(Block block) => new BlockFunctionBo dy.full(block);
243 static BlockFunctionBody blockFunctionBody2(List<Statement> statements) => new BlockFunctionBody.full(block(statements));
243 static BooleanLiteral booleanLiteral(bool value) => new BooleanLiteral.full(va lue ? TokenFactory.token(Keyword.TRUE) : TokenFactory.token(Keyword.FALSE), valu e); 244 static BooleanLiteral booleanLiteral(bool value) => new BooleanLiteral.full(va lue ? TokenFactory.token(Keyword.TRUE) : TokenFactory.token(Keyword.FALSE), valu e);
244 static BreakStatement breakStatement() => new BreakStatement.full(TokenFactory .token(Keyword.BREAK), null, TokenFactory.token3(TokenType.SEMICOLON)); 245 static BreakStatement breakStatement() => new BreakStatement.full(TokenFactory .token(Keyword.BREAK), null, TokenFactory.token3(TokenType.SEMICOLON));
245 static BreakStatement breakStatement2(String label) => new BreakStatement.full (TokenFactory.token(Keyword.BREAK), identifier3(label), TokenFactory.token3(Toke nType.SEMICOLON)); 246 static BreakStatement breakStatement2(String label) => new BreakStatement.full (TokenFactory.token(Keyword.BREAK), identifier3(label), TokenFactory.token3(Toke nType.SEMICOLON));
246 static IndexExpression cascadedIndexExpression(Expression index) => new IndexE xpression.forCascade_full(TokenFactory.token3(TokenType.PERIOD_PERIOD), TokenFac tory.token3(TokenType.OPEN_SQUARE_BRACKET), index, TokenFactory.token3(TokenType .CLOSE_SQUARE_BRACKET)); 247 static IndexExpression cascadedIndexExpression(Expression index) => new IndexE xpression.forCascade_full(TokenFactory.token3(TokenType.PERIOD_PERIOD), TokenFac tory.token3(TokenType.OPEN_SQUARE_BRACKET), index, TokenFactory.token3(TokenType .CLOSE_SQUARE_BRACKET));
247 static MethodInvocation cascadedMethodInvocation(String methodName, List<Expre ssion> arguments) => new MethodInvocation.full(null, TokenFactory.token3(TokenTy pe.PERIOD_PERIOD), identifier3(methodName), argumentList(arguments)); 248 static MethodInvocation cascadedMethodInvocation(String methodName, List<Expre ssion> arguments) => new MethodInvocation.full(null, TokenFactory.token3(TokenTy pe.PERIOD_PERIOD), identifier3(methodName), argumentList(arguments));
248 static PropertyAccess cascadedPropertyAccess(String propertyName) => new Prope rtyAccess.full(null, TokenFactory.token3(TokenType.PERIOD_PERIOD), identifier3(p ropertyName)); 249 static PropertyAccess cascadedPropertyAccess(String propertyName) => new Prope rtyAccess.full(null, TokenFactory.token3(TokenType.PERIOD_PERIOD), identifier3(p ropertyName));
249 static CascadeExpression cascadeExpression(Expression target, List<Expression> cascadeSections) => new CascadeExpression.full(target, list(cascadeSections)); 250 static CascadeExpression cascadeExpression(Expression target, List<Expression> cascadeSections) => new CascadeExpression.full(target, list(cascadeSections));
250 static CatchClause catchClause(String exceptionParameter, List<Statement> stat ements) => catchClause5(null, exceptionParameter, null, statements); 251 static CatchClause catchClause(String exceptionParameter, List<Statement> stat ements) => catchClause5(null, exceptionParameter, null, statements);
251 static CatchClause catchClause2(String exceptionParameter, String stackTracePa rameter, List<Statement> statements) => catchClause5(null, exceptionParameter, s tackTraceParameter, statements); 252 static CatchClause catchClause2(String exceptionParameter, String stackTracePa rameter, List<Statement> statements) => catchClause5(null, exceptionParameter, s tackTraceParameter, statements);
252 static CatchClause catchClause3(TypeName exceptionType, List<Statement> statem ents) => catchClause5(exceptionType, null, null, statements); 253 static CatchClause catchClause3(TypeName exceptionType, List<Statement> statem ents) => catchClause5(exceptionType, null, null, statements);
(...skipping 27 matching lines...) Expand all
280 static ExportDirective exportDirective(List<Annotation> metadata, String uri, List<Combinator> combinators) => new ExportDirective.full(null, metadata, TokenF actory.token(Keyword.EXPORT), string2(uri), list(combinators), TokenFactory.toke n3(TokenType.SEMICOLON)); 281 static ExportDirective exportDirective(List<Annotation> metadata, String uri, List<Combinator> combinators) => new ExportDirective.full(null, metadata, TokenF actory.token(Keyword.EXPORT), string2(uri), list(combinators), TokenFactory.toke n3(TokenType.SEMICOLON));
281 static ExportDirective exportDirective2(String uri, List<Combinator> combinato rs) => exportDirective(new List<Annotation>(), uri, combinators); 282 static ExportDirective exportDirective2(String uri, List<Combinator> combinato rs) => exportDirective(new List<Annotation>(), uri, combinators);
282 static ExpressionFunctionBody expressionFunctionBody(Expression expression) => new ExpressionFunctionBody.full(TokenFactory.token3(TokenType.FUNCTION), expres sion, TokenFactory.token3(TokenType.SEMICOLON)); 283 static ExpressionFunctionBody expressionFunctionBody(Expression expression) => new ExpressionFunctionBody.full(TokenFactory.token3(TokenType.FUNCTION), expres sion, TokenFactory.token3(TokenType.SEMICOLON));
283 static ExpressionStatement expressionStatement(Expression expression) => new E xpressionStatement.full(expression, TokenFactory.token3(TokenType.SEMICOLON)); 284 static ExpressionStatement expressionStatement(Expression expression) => new E xpressionStatement.full(expression, TokenFactory.token3(TokenType.SEMICOLON));
284 static ExtendsClause extendsClause(TypeName type) => new ExtendsClause.full(To kenFactory.token(Keyword.EXTENDS), type); 285 static ExtendsClause extendsClause(TypeName type) => new ExtendsClause.full(To kenFactory.token(Keyword.EXTENDS), type);
285 static FieldDeclaration fieldDeclaration(bool isStatic, Keyword keyword, TypeN ame type, List<VariableDeclaration> variables) => new FieldDeclaration.full(null , null, isStatic ? TokenFactory.token(Keyword.STATIC) : null, variableDeclaratio nList(keyword, type, variables), TokenFactory.token3(TokenType.SEMICOLON)); 286 static FieldDeclaration fieldDeclaration(bool isStatic, Keyword keyword, TypeN ame type, List<VariableDeclaration> variables) => new FieldDeclaration.full(null , null, isStatic ? TokenFactory.token(Keyword.STATIC) : null, variableDeclaratio nList(keyword, type, variables), TokenFactory.token3(TokenType.SEMICOLON));
286 static FieldDeclaration fieldDeclaration2(bool isStatic, Keyword keyword, List <VariableDeclaration> variables) => fieldDeclaration(isStatic, keyword, null, va riables); 287 static FieldDeclaration fieldDeclaration2(bool isStatic, Keyword keyword, List <VariableDeclaration> variables) => fieldDeclaration(isStatic, keyword, null, va riables);
287 static FieldFormalParameter fieldFormalParameter(Keyword keyword, TypeName typ e, String identifier) => new FieldFormalParameter.full(null, null, keyword == nu ll ? null : TokenFactory.token(keyword), type, TokenFactory.token(Keyword.THIS), TokenFactory.token3(TokenType.PERIOD), identifier3(identifier), null); 288 static FieldFormalParameter fieldFormalParameter(Keyword keyword, TypeName typ e, String identifier) => new FieldFormalParameter.full(null, null, keyword == nu ll ? null : TokenFactory.token(keyword), type, TokenFactory.token(Keyword.THIS), TokenFactory.token3(TokenType.PERIOD), identifier3(identifier), null);
288 static FieldFormalParameter fieldFormalParameter2(Keyword keyword, TypeName ty pe, String identifier, FormalParameterList parameterList) => new FieldFormalPara meter.full(null, null, keyword == null ? null : TokenFactory.token(keyword), typ e, TokenFactory.token(Keyword.THIS), TokenFactory.token3(TokenType.PERIOD), iden tifier3(identifier), parameterList); 289 static FieldFormalParameter fieldFormalParameter2(Keyword keyword, TypeName ty pe, String identifier, FormalParameterList parameterList) => new FieldFormalPara meter.full(null, null, keyword == null ? null : TokenFactory.token(keyword), typ e, TokenFactory.token(Keyword.THIS), TokenFactory.token3(TokenType.PERIOD), iden tifier3(identifier), parameterList);
289 static FieldFormalParameter fieldFormalParameter3(String identifier) => fieldF ormalParameter(null, null, identifier); 290 static FieldFormalParameter fieldFormalParameter3(String identifier) => fieldF ormalParameter(null, null, identifier);
290 static ForEachStatement forEachStatement(DeclaredIdentifier loopVariable, Expr ession iterator, Statement body) => new ForEachStatement.full(TokenFactory.token (Keyword.FOR), TokenFactory.token3(TokenType.OPEN_PAREN), loopVariable, TokenFac tory.token(Keyword.IN), iterator, TokenFactory.token3(TokenType.CLOSE_PAREN), bo dy); 291 static ForEachStatement forEachStatement(DeclaredIdentifier loopVariable, Expr ession iterator, Statement body) => new ForEachStatement.con1_full(TokenFactory. token(Keyword.FOR), TokenFactory.token3(TokenType.OPEN_PAREN), loopVariable, Tok enFactory.token(Keyword.IN), iterator, TokenFactory.token3(TokenType.CLOSE_PAREN ), body);
291 static FormalParameterList formalParameterList(List<FormalParameter> parameter s) => new FormalParameterList.full(TokenFactory.token3(TokenType.OPEN_PAREN), li st(parameters), null, null, TokenFactory.token3(TokenType.CLOSE_PAREN)); 292 static FormalParameterList formalParameterList(List<FormalParameter> parameter s) => new FormalParameterList.full(TokenFactory.token3(TokenType.OPEN_PAREN), li st(parameters), null, null, TokenFactory.token3(TokenType.CLOSE_PAREN));
292 static ForStatement forStatement(Expression initialization, Expression conditi on, List<Expression> updaters, Statement body) => new ForStatement.full(TokenFac tory.token(Keyword.FOR), TokenFactory.token3(TokenType.OPEN_PAREN), null, initia lization, TokenFactory.token3(TokenType.SEMICOLON), condition, TokenFactory.toke n3(TokenType.SEMICOLON), updaters, TokenFactory.token3(TokenType.CLOSE_PAREN), b ody); 293 static ForStatement forStatement(Expression initialization, Expression conditi on, List<Expression> updaters, Statement body) => new ForStatement.full(TokenFac tory.token(Keyword.FOR), TokenFactory.token3(TokenType.OPEN_PAREN), null, initia lization, TokenFactory.token3(TokenType.SEMICOLON), condition, TokenFactory.toke n3(TokenType.SEMICOLON), updaters, TokenFactory.token3(TokenType.CLOSE_PAREN), b ody);
293 static ForStatement forStatement2(VariableDeclarationList variableList, Expres sion condition, List<Expression> updaters, Statement body) => new ForStatement.f ull(TokenFactory.token(Keyword.FOR), TokenFactory.token3(TokenType.OPEN_PAREN), variableList, null, TokenFactory.token3(TokenType.SEMICOLON), condition, TokenFa ctory.token3(TokenType.SEMICOLON), updaters, TokenFactory.token3(TokenType.CLOSE _PAREN), body); 294 static ForStatement forStatement2(VariableDeclarationList variableList, Expres sion condition, List<Expression> updaters, Statement body) => new ForStatement.f ull(TokenFactory.token(Keyword.FOR), TokenFactory.token3(TokenType.OPEN_PAREN), variableList, null, TokenFactory.token3(TokenType.SEMICOLON), condition, TokenFa ctory.token3(TokenType.SEMICOLON), updaters, TokenFactory.token3(TokenType.CLOSE _PAREN), body);
294 static FunctionDeclaration functionDeclaration(TypeName type, Keyword keyword, String name, FunctionExpression functionExpression) => new FunctionDeclaration. full(null, null, null, type, keyword == null ? null : TokenFactory.token(keyword ), identifier3(name), functionExpression); 295 static FunctionDeclaration functionDeclaration(TypeName type, Keyword keyword, String name, FunctionExpression functionExpression) => new FunctionDeclaration. full(null, null, null, type, keyword == null ? null : TokenFactory.token(keyword ), identifier3(name), functionExpression);
295 static FunctionDeclarationStatement functionDeclarationStatement(TypeName type , Keyword keyword, String name, FunctionExpression functionExpression) => new Fu nctionDeclarationStatement.full(functionDeclaration(type, keyword, name, functio nExpression)); 296 static FunctionDeclarationStatement functionDeclarationStatement(TypeName type , Keyword keyword, String name, FunctionExpression functionExpression) => new Fu nctionDeclarationStatement.full(functionDeclaration(type, keyword, name, functio nExpression));
296 static FunctionExpression functionExpression() => new FunctionExpression.full( formalParameterList([]), blockFunctionBody([])); 297 static FunctionExpression functionExpression() => new FunctionExpression.full( formalParameterList([]), blockFunctionBody2([]));
297 static FunctionExpression functionExpression2(FormalParameterList parameters, FunctionBody body) => new FunctionExpression.full(parameters, body); 298 static FunctionExpression functionExpression2(FormalParameterList parameters, FunctionBody body) => new FunctionExpression.full(parameters, body);
298 static FunctionExpressionInvocation functionExpressionInvocation(Expression fu nction, List<Expression> arguments) => new FunctionExpressionInvocation.full(fun ction, argumentList(arguments)); 299 static FunctionExpressionInvocation functionExpressionInvocation(Expression fu nction, List<Expression> arguments) => new FunctionExpressionInvocation.full(fun ction, argumentList(arguments));
299 static FunctionTypedFormalParameter functionTypedFormalParameter(TypeName retu rnType, String identifier, List<FormalParameter> parameters) => new FunctionType dFormalParameter.full(null, null, returnType, identifier3(identifier), formalPar ameterList(parameters)); 300 static FunctionTypedFormalParameter functionTypedFormalParameter(TypeName retu rnType, String identifier, List<FormalParameter> parameters) => new FunctionType dFormalParameter.full(null, null, returnType, identifier3(identifier), formalPar ameterList(parameters));
300 static HideCombinator hideCombinator(List<SimpleIdentifier> identifiers) => ne w HideCombinator.full(TokenFactory.token2("hide"), list(identifiers)); 301 static HideCombinator hideCombinator(List<SimpleIdentifier> identifiers) => ne w HideCombinator.full(TokenFactory.token2("hide"), list(identifiers));
301 static HideCombinator hideCombinator2(List<String> identifiers) { 302 static HideCombinator hideCombinator2(List<String> identifiers) {
302 List<SimpleIdentifier> identifierList = new List<SimpleIdentifier>(); 303 List<SimpleIdentifier> identifierList = new List<SimpleIdentifier>();
303 for (String identifier in identifiers) { 304 for (String identifier in identifiers) {
304 identifierList.add(identifier3(identifier)); 305 identifierList.add(identifier3(identifier));
305 } 306 }
306 return new HideCombinator.full(TokenFactory.token2("hide"), identifierList); 307 return new HideCombinator.full(TokenFactory.token2("hide"), identifierList);
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 "}", 768 "}",
768 "A f(var p) {", 769 "A f(var p) {",
769 " if ((p as A).g) {", 770 " if ((p as A).g) {",
770 " return p;", 771 " return p;",
771 " } else {", 772 " } else {",
772 " return null;", 773 " return null;",
773 " }", 774 " }",
774 "}"]); 775 "}"]);
775 CompilationUnit unit = ParserTestCase.parseCompilationUnit(source, []); 776 CompilationUnit unit = ParserTestCase.parseCompilationUnit(source, []);
776 List<ASTNode> nodes = new List<ASTNode>(); 777 List<ASTNode> nodes = new List<ASTNode>();
777 BreadthFirstVisitor<Object> visitor = new BreadthFirstVisitor_18(nodes); 778 BreadthFirstVisitor<Object> visitor = new BreadthFirstVisitor_17(nodes);
778 visitor.visitAllNodes(unit); 779 visitor.visitAllNodes(unit);
779 EngineTestCase.assertSize(59, nodes); 780 EngineTestCase.assertSize(59, nodes);
780 EngineTestCase.assertInstanceOf(CompilationUnit, nodes[0]); 781 EngineTestCase.assertInstanceOf(CompilationUnit, nodes[0]);
781 EngineTestCase.assertInstanceOf(ClassDeclaration, nodes[2]); 782 EngineTestCase.assertInstanceOf(ClassDeclaration, nodes[2]);
782 EngineTestCase.assertInstanceOf(FunctionDeclaration, nodes[3]); 783 EngineTestCase.assertInstanceOf(FunctionDeclaration, nodes[3]);
783 EngineTestCase.assertInstanceOf(FunctionDeclarationStatement, nodes[27]); 784 EngineTestCase.assertInstanceOf(FunctionDeclarationStatement, nodes[27]);
784 EngineTestCase.assertInstanceOf(IntegerLiteral, nodes[58]); 785 EngineTestCase.assertInstanceOf(IntegerLiteral, nodes[58]);
785 } 786 }
786 static dartSuite() { 787 static dartSuite() {
787 _ut.group('BreadthFirstVisitorTest', () { 788 _ut.group('BreadthFirstVisitorTest', () {
788 _ut.test('testIt', () { 789 _ut.test('testIt', () {
789 final __test = new BreadthFirstVisitorTest(); 790 final __test = new BreadthFirstVisitorTest();
790 runJUnitTest(__test, __test.testIt); 791 runJUnitTest(__test, __test.testIt);
791 }); 792 });
792 }); 793 });
793 } 794 }
794 } 795 }
795 class BreadthFirstVisitor_18 extends BreadthFirstVisitor<Object> { 796 class BreadthFirstVisitor_17 extends BreadthFirstVisitor<Object> {
796 List<ASTNode> nodes; 797 List<ASTNode> nodes;
797 BreadthFirstVisitor_18(this.nodes) : super(); 798 BreadthFirstVisitor_17(this.nodes) : super();
798 Object visitNode(ASTNode node) { 799 Object visitNode(ASTNode node) {
799 nodes.add(node); 800 nodes.add(node);
800 return super.visitNode(node); 801 return super.visitNode(node);
801 } 802 }
802 } 803 }
803 class ConstantEvaluatorTest extends ParserTestCase { 804 class ConstantEvaluatorTest extends ParserTestCase {
804 void fail_constructor() { 805 void fail_constructor() {
805 Object value = getConstantValue("?"); 806 Object value = getConstantValue("?");
806 JUnitTestCase.assertEquals(null, value); 807 JUnitTestCase.assertEquals(null, value);
807 } 808 }
(...skipping 10 matching lines...) Expand all
818 JUnitTestCase.assertEquals(null, value); 819 JUnitTestCase.assertEquals(null, value);
819 } 820 }
820 void fail_identifier_staticMethod() { 821 void fail_identifier_staticMethod() {
821 Object value = getConstantValue("?"); 822 Object value = getConstantValue("?");
822 JUnitTestCase.assertEquals(null, value); 823 JUnitTestCase.assertEquals(null, value);
823 } 824 }
824 void fail_identifier_topLevel() { 825 void fail_identifier_topLevel() {
825 Object value = getConstantValue("?"); 826 Object value = getConstantValue("?");
826 JUnitTestCase.assertEquals(null, value); 827 JUnitTestCase.assertEquals(null, value);
827 } 828 }
828 void fail_identifier_typeVariable() { 829 void fail_identifier_typeParameter() {
829 Object value = getConstantValue("?"); 830 Object value = getConstantValue("?");
830 JUnitTestCase.assertEquals(null, value); 831 JUnitTestCase.assertEquals(null, value);
831 } 832 }
832 void test_binary_bitAnd() { 833 void test_binary_bitAnd() {
833 Object value = getConstantValue("74 & 42"); 834 Object value = getConstantValue("74 & 42");
834 EngineTestCase.assertInstanceOf(int, value); 835 EngineTestCase.assertInstanceOf(int, value);
835 JUnitTestCase.assertEquals(74 & 42, value as int); 836 JUnitTestCase.assertEquals(74 & 42, value as int);
836 } 837 }
837 void test_binary_bitOr() { 838 void test_binary_bitOr() {
838 Object value = getConstantValue("74 | 42"); 839 Object value = getConstantValue("74 | 42");
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 void test_visitBinaryExpression() { 1288 void test_visitBinaryExpression() {
1288 assertSource("a + b", ASTFactory.binaryExpression(ASTFactory.identifier3("a" ), TokenType.PLUS, ASTFactory.identifier3("b"))); 1289 assertSource("a + b", ASTFactory.binaryExpression(ASTFactory.identifier3("a" ), TokenType.PLUS, ASTFactory.identifier3("b")));
1289 } 1290 }
1290 void test_visitBlock_empty() { 1291 void test_visitBlock_empty() {
1291 assertSource("{}", ASTFactory.block([])); 1292 assertSource("{}", ASTFactory.block([]));
1292 } 1293 }
1293 void test_visitBlock_nonEmpty() { 1294 void test_visitBlock_nonEmpty() {
1294 assertSource("{break; break;}", ASTFactory.block([ASTFactory.breakStatement( ), ASTFactory.breakStatement()])); 1295 assertSource("{break; break;}", ASTFactory.block([ASTFactory.breakStatement( ), ASTFactory.breakStatement()]));
1295 } 1296 }
1296 void test_visitBlockFunctionBody() { 1297 void test_visitBlockFunctionBody() {
1297 assertSource("{}", ASTFactory.blockFunctionBody([])); 1298 assertSource("{}", ASTFactory.blockFunctionBody2([]));
1298 } 1299 }
1299 void test_visitBooleanLiteral_false() { 1300 void test_visitBooleanLiteral_false() {
1300 assertSource("false", ASTFactory.booleanLiteral(false)); 1301 assertSource("false", ASTFactory.booleanLiteral(false));
1301 } 1302 }
1302 void test_visitBooleanLiteral_true() { 1303 void test_visitBooleanLiteral_true() {
1303 assertSource("true", ASTFactory.booleanLiteral(true)); 1304 assertSource("true", ASTFactory.booleanLiteral(true));
1304 } 1305 }
1305 void test_visitBreakStatement_label() { 1306 void test_visitBreakStatement_label() {
1306 assertSource("break l;", ASTFactory.breakStatement2("l")); 1307 assertSource("break l;", ASTFactory.breakStatement2("l"));
1307 } 1308 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 void test_visitCompilationUnit_script_directive() { 1434 void test_visitCompilationUnit_script_directive() {
1434 assertSource("!#/bin/dartvm library l;", ASTFactory.compilationUnit7("!#/bin /dartvm", [ASTFactory.libraryDirective2("l")])); 1435 assertSource("!#/bin/dartvm library l;", ASTFactory.compilationUnit7("!#/bin /dartvm", [ASTFactory.libraryDirective2("l")]));
1435 } 1436 }
1436 void test_visitCompilationUnit_script_directives_declarations() { 1437 void test_visitCompilationUnit_script_directives_declarations() {
1437 assertSource("!#/bin/dartvm library l; var a;", ASTFactory.compilationUnit8( "!#/bin/dartvm", ASTFactory.list([(ASTFactory.libraryDirective2("l") as Directiv e)]), ASTFactory.list([(ASTFactory.topLevelVariableDeclaration2(Keyword.VAR, [AS TFactory.variableDeclaration("a")]) as CompilationUnitMember)]))); 1438 assertSource("!#/bin/dartvm library l; var a;", ASTFactory.compilationUnit8( "!#/bin/dartvm", ASTFactory.list([(ASTFactory.libraryDirective2("l") as Directiv e)]), ASTFactory.list([(ASTFactory.topLevelVariableDeclaration2(Keyword.VAR, [AS TFactory.variableDeclaration("a")]) as CompilationUnitMember)])));
1438 } 1439 }
1439 void test_visitConditionalExpression() { 1440 void test_visitConditionalExpression() {
1440 assertSource("a ? b : c", ASTFactory.conditionalExpression(ASTFactory.identi fier3("a"), ASTFactory.identifier3("b"), ASTFactory.identifier3("c"))); 1441 assertSource("a ? b : c", ASTFactory.conditionalExpression(ASTFactory.identi fier3("a"), ASTFactory.identifier3("b"), ASTFactory.identifier3("c")));
1441 } 1442 }
1442 void test_visitConstructorDeclaration_const() { 1443 void test_visitConstructorDeclaration_const() {
1443 assertSource("const C() {}", ASTFactory.constructorDeclaration2(Keyword.CONS T, null, ASTFactory.identifier3("C"), null, ASTFactory.formalParameterList([]), null, ASTFactory.blockFunctionBody([]))); 1444 assertSource("const C() {}", ASTFactory.constructorDeclaration2(Keyword.CONS T, null, ASTFactory.identifier3("C"), null, ASTFactory.formalParameterList([]), null, ASTFactory.blockFunctionBody2([])));
1444 } 1445 }
1445 void test_visitConstructorDeclaration_external() { 1446 void test_visitConstructorDeclaration_external() {
1446 assertSource("external C();", ASTFactory.constructorDeclaration(ASTFactory.i dentifier3("C"), null, ASTFactory.formalParameterList([]), null)); 1447 assertSource("external C();", ASTFactory.constructorDeclaration(ASTFactory.i dentifier3("C"), null, ASTFactory.formalParameterList([]), null));
1447 } 1448 }
1448 void test_visitConstructorDeclaration_minimal() { 1449 void test_visitConstructorDeclaration_minimal() {
1449 assertSource("C() {}", ASTFactory.constructorDeclaration2(null, null, ASTFac tory.identifier3("C"), null, ASTFactory.formalParameterList([]), null, ASTFactor y.blockFunctionBody([]))); 1450 assertSource("C() {}", ASTFactory.constructorDeclaration2(null, null, ASTFac tory.identifier3("C"), null, ASTFactory.formalParameterList([]), null, ASTFactor y.blockFunctionBody2([])));
1450 } 1451 }
1451 void test_visitConstructorDeclaration_multipleInitializers() { 1452 void test_visitConstructorDeclaration_multipleInitializers() {
1452 assertSource("C() : a = b, c = d {}", ASTFactory.constructorDeclaration2(nul l, null, ASTFactory.identifier3("C"), null, ASTFactory.formalParameterList([]), ASTFactory.list([ 1453 assertSource("C() : a = b, c = d {}", ASTFactory.constructorDeclaration2(nul l, null, ASTFactory.identifier3("C"), null, ASTFactory.formalParameterList([]), ASTFactory.list([
1453 (ASTFactory.constructorFieldInitializer(false, "a", ASTFactory.identifie r3("b")) as ConstructorInitializer), 1454 (ASTFactory.constructorFieldInitializer(false, "a", ASTFactory.identifie r3("b")) as ConstructorInitializer),
1454 ASTFactory.constructorFieldInitializer(false, "c", ASTFactory.identifier 3("d"))]), ASTFactory.blockFunctionBody([]))); 1455 ASTFactory.constructorFieldInitializer(false, "c", ASTFactory.identifier 3("d"))]), ASTFactory.blockFunctionBody2([])));
1455 } 1456 }
1456 void test_visitConstructorDeclaration_multipleParameters() { 1457 void test_visitConstructorDeclaration_multipleParameters() {
1457 assertSource("C(var a, var b) {}", ASTFactory.constructorDeclaration2(null, null, ASTFactory.identifier3("C"), null, ASTFactory.formalParameterList([ 1458 assertSource("C(var a, var b) {}", ASTFactory.constructorDeclaration2(null, null, ASTFactory.identifier3("C"), null, ASTFactory.formalParameterList([
1458 ASTFactory.simpleFormalParameter(Keyword.VAR, "a"), 1459 ASTFactory.simpleFormalParameter(Keyword.VAR, "a"),
1459 ASTFactory.simpleFormalParameter(Keyword.VAR, "b")]), null, ASTFactory.b lockFunctionBody([]))); 1460 ASTFactory.simpleFormalParameter(Keyword.VAR, "b")]), null, ASTFactory.b lockFunctionBody2([])));
1460 } 1461 }
1461 void test_visitConstructorDeclaration_named() { 1462 void test_visitConstructorDeclaration_named() {
1462 assertSource("C.m() {}", ASTFactory.constructorDeclaration2(null, null, ASTF actory.identifier3("C"), "m", ASTFactory.formalParameterList([]), null, ASTFacto ry.blockFunctionBody([]))); 1463 assertSource("C.m() {}", ASTFactory.constructorDeclaration2(null, null, ASTF actory.identifier3("C"), "m", ASTFactory.formalParameterList([]), null, ASTFacto ry.blockFunctionBody2([])));
1463 } 1464 }
1464 void test_visitConstructorDeclaration_singleInitializer() { 1465 void test_visitConstructorDeclaration_singleInitializer() {
1465 assertSource("C() : a = b {}", ASTFactory.constructorDeclaration2(null, null , ASTFactory.identifier3("C"), null, ASTFactory.formalParameterList([]), ASTFact ory.list([(ASTFactory.constructorFieldInitializer(false, "a", ASTFactory.identif ier3("b")) as ConstructorInitializer)]), ASTFactory.blockFunctionBody([]))); 1466 assertSource("C() : a = b {}", ASTFactory.constructorDeclaration2(null, null , ASTFactory.identifier3("C"), null, ASTFactory.formalParameterList([]), ASTFact ory.list([(ASTFactory.constructorFieldInitializer(false, "a", ASTFactory.identif ier3("b")) as ConstructorInitializer)]), ASTFactory.blockFunctionBody2([])));
1466 } 1467 }
1467 void test_visitConstructorFieldInitializer_withoutThis() { 1468 void test_visitConstructorFieldInitializer_withoutThis() {
1468 assertSource("a = b", ASTFactory.constructorFieldInitializer(false, "a", AST Factory.identifier3("b"))); 1469 assertSource("a = b", ASTFactory.constructorFieldInitializer(false, "a", AST Factory.identifier3("b")));
1469 } 1470 }
1470 void test_visitConstructorFieldInitializer_withThis() { 1471 void test_visitConstructorFieldInitializer_withThis() {
1471 assertSource("this.a = b", ASTFactory.constructorFieldInitializer(true, "a", ASTFactory.identifier3("b"))); 1472 assertSource("this.a = b", ASTFactory.constructorFieldInitializer(true, "a", ASTFactory.identifier3("b")));
1472 } 1473 }
1473 void test_visitConstructorName_named_prefix() { 1474 void test_visitConstructorName_named_prefix() {
1474 assertSource("p.C.n", ASTFactory.constructorName(ASTFactory.typeName4("p.C.n ", []), null)); 1475 assertSource("p.C.n", ASTFactory.constructorName(ASTFactory.typeName4("p.C.n ", []), null));
1475 } 1476 }
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1808 void test_visitMapLiteralEntry() { 1809 void test_visitMapLiteralEntry() {
1809 assertSource("'a' : b", ASTFactory.mapLiteralEntry("a", ASTFactory.identifie r3("b"))); 1810 assertSource("'a' : b", ASTFactory.mapLiteralEntry("a", ASTFactory.identifie r3("b")));
1810 } 1811 }
1811 void test_visitMethodDeclaration_external() { 1812 void test_visitMethodDeclaration_external() {
1812 assertSource("external m();", ASTFactory.methodDeclaration(null, null, null, null, ASTFactory.identifier3("m"), ASTFactory.formalParameterList([]))); 1813 assertSource("external m();", ASTFactory.methodDeclaration(null, null, null, null, ASTFactory.identifier3("m"), ASTFactory.formalParameterList([])));
1813 } 1814 }
1814 void test_visitMethodDeclaration_external_returnType() { 1815 void test_visitMethodDeclaration_external_returnType() {
1815 assertSource("external T m();", ASTFactory.methodDeclaration(null, ASTFactor y.typeName4("T", []), null, null, ASTFactory.identifier3("m"), ASTFactory.formal ParameterList([]))); 1816 assertSource("external T m();", ASTFactory.methodDeclaration(null, ASTFactor y.typeName4("T", []), null, null, ASTFactory.identifier3("m"), ASTFactory.formal ParameterList([])));
1816 } 1817 }
1817 void test_visitMethodDeclaration_getter() { 1818 void test_visitMethodDeclaration_getter() {
1818 assertSource("get m {}", ASTFactory.methodDeclaration2(null, null, Keyword.G ET, null, ASTFactory.identifier3("m"), null, ASTFactory.blockFunctionBody([]))); 1819 assertSource("get m {}", ASTFactory.methodDeclaration2(null, null, Keyword.G ET, null, ASTFactory.identifier3("m"), null, ASTFactory.blockFunctionBody2([]))) ;
1819 } 1820 }
1820 void test_visitMethodDeclaration_getter_returnType() { 1821 void test_visitMethodDeclaration_getter_returnType() {
1821 assertSource("T get m {}", ASTFactory.methodDeclaration2(null, ASTFactory.ty peName4("T", []), Keyword.GET, null, ASTFactory.identifier3("m"), null, ASTFacto ry.blockFunctionBody([]))); 1822 assertSource("T get m {}", ASTFactory.methodDeclaration2(null, ASTFactory.ty peName4("T", []), Keyword.GET, null, ASTFactory.identifier3("m"), null, ASTFacto ry.blockFunctionBody2([])));
1822 } 1823 }
1823 void test_visitMethodDeclaration_getter_seturnType() { 1824 void test_visitMethodDeclaration_getter_seturnType() {
1824 assertSource("T set m(var v) {}", ASTFactory.methodDeclaration2(null, ASTFac tory.typeName4("T", []), Keyword.SET, null, ASTFactory.identifier3("m"), ASTFact ory.formalParameterList([ASTFactory.simpleFormalParameter(Keyword.VAR, "v")]), A STFactory.blockFunctionBody([]))); 1825 assertSource("T set m(var v) {}", ASTFactory.methodDeclaration2(null, ASTFac tory.typeName4("T", []), Keyword.SET, null, ASTFactory.identifier3("m"), ASTFact ory.formalParameterList([ASTFactory.simpleFormalParameter(Keyword.VAR, "v")]), A STFactory.blockFunctionBody2([])));
1825 } 1826 }
1826 void test_visitMethodDeclaration_minimal() { 1827 void test_visitMethodDeclaration_minimal() {
1827 assertSource("m() {}", ASTFactory.methodDeclaration2(null, null, null, null, ASTFactory.identifier3("m"), ASTFactory.formalParameterList([]), ASTFactory.blo ckFunctionBody([]))); 1828 assertSource("m() {}", ASTFactory.methodDeclaration2(null, null, null, null, ASTFactory.identifier3("m"), ASTFactory.formalParameterList([]), ASTFactory.blo ckFunctionBody2([])));
1828 } 1829 }
1829 void test_visitMethodDeclaration_multipleParameters() { 1830 void test_visitMethodDeclaration_multipleParameters() {
1830 assertSource("m(var a, var b) {}", ASTFactory.methodDeclaration2(null, null, null, null, ASTFactory.identifier3("m"), ASTFactory.formalParameterList([ 1831 assertSource("m(var a, var b) {}", ASTFactory.methodDeclaration2(null, null, null, null, ASTFactory.identifier3("m"), ASTFactory.formalParameterList([
1831 ASTFactory.simpleFormalParameter(Keyword.VAR, "a"), 1832 ASTFactory.simpleFormalParameter(Keyword.VAR, "a"),
1832 ASTFactory.simpleFormalParameter(Keyword.VAR, "b")]), ASTFactory.blockFu nctionBody([]))); 1833 ASTFactory.simpleFormalParameter(Keyword.VAR, "b")]), ASTFactory.blockFu nctionBody2([])));
1833 } 1834 }
1834 void test_visitMethodDeclaration_operator() { 1835 void test_visitMethodDeclaration_operator() {
1835 assertSource("operator +() {}", ASTFactory.methodDeclaration2(null, null, nu ll, Keyword.OPERATOR, ASTFactory.identifier3("+"), ASTFactory.formalParameterLis t([]), ASTFactory.blockFunctionBody([]))); 1836 assertSource("operator +() {}", ASTFactory.methodDeclaration2(null, null, nu ll, Keyword.OPERATOR, ASTFactory.identifier3("+"), ASTFactory.formalParameterLis t([]), ASTFactory.blockFunctionBody2([])));
1836 } 1837 }
1837 void test_visitMethodDeclaration_operator_returnType() { 1838 void test_visitMethodDeclaration_operator_returnType() {
1838 assertSource("T operator +() {}", ASTFactory.methodDeclaration2(null, ASTFac tory.typeName4("T", []), null, Keyword.OPERATOR, ASTFactory.identifier3("+"), AS TFactory.formalParameterList([]), ASTFactory.blockFunctionBody([]))); 1839 assertSource("T operator +() {}", ASTFactory.methodDeclaration2(null, ASTFac tory.typeName4("T", []), null, Keyword.OPERATOR, ASTFactory.identifier3("+"), AS TFactory.formalParameterList([]), ASTFactory.blockFunctionBody2([])));
1839 } 1840 }
1840 void test_visitMethodDeclaration_returnType() { 1841 void test_visitMethodDeclaration_returnType() {
1841 assertSource("T m() {}", ASTFactory.methodDeclaration2(null, ASTFactory.type Name4("T", []), null, null, ASTFactory.identifier3("m"), ASTFactory.formalParame terList([]), ASTFactory.blockFunctionBody([]))); 1842 assertSource("T m() {}", ASTFactory.methodDeclaration2(null, ASTFactory.type Name4("T", []), null, null, ASTFactory.identifier3("m"), ASTFactory.formalParame terList([]), ASTFactory.blockFunctionBody2([])));
1842 } 1843 }
1843 void test_visitMethodDeclaration_setter() { 1844 void test_visitMethodDeclaration_setter() {
1844 assertSource("set m(var v) {}", ASTFactory.methodDeclaration2(null, null, Ke yword.SET, null, ASTFactory.identifier3("m"), ASTFactory.formalParameterList([AS TFactory.simpleFormalParameter(Keyword.VAR, "v")]), ASTFactory.blockFunctionBody ([]))); 1845 assertSource("set m(var v) {}", ASTFactory.methodDeclaration2(null, null, Ke yword.SET, null, ASTFactory.identifier3("m"), ASTFactory.formalParameterList([AS TFactory.simpleFormalParameter(Keyword.VAR, "v")]), ASTFactory.blockFunctionBody 2([])));
1845 } 1846 }
1846 void test_visitMethodDeclaration_static() { 1847 void test_visitMethodDeclaration_static() {
1847 assertSource("static m() {}", ASTFactory.methodDeclaration2(Keyword.STATIC, null, null, null, ASTFactory.identifier3("m"), ASTFactory.formalParameterList([] ), ASTFactory.blockFunctionBody([]))); 1848 assertSource("static m() {}", ASTFactory.methodDeclaration2(Keyword.STATIC, null, null, null, ASTFactory.identifier3("m"), ASTFactory.formalParameterList([] ), ASTFactory.blockFunctionBody2([])));
1848 } 1849 }
1849 void test_visitMethodDeclaration_static_returnType() { 1850 void test_visitMethodDeclaration_static_returnType() {
1850 assertSource("static T m() {}", ASTFactory.methodDeclaration2(Keyword.STATIC , ASTFactory.typeName4("T", []), null, null, ASTFactory.identifier3("m"), ASTFac tory.formalParameterList([]), ASTFactory.blockFunctionBody([]))); 1851 assertSource("static T m() {}", ASTFactory.methodDeclaration2(Keyword.STATIC , ASTFactory.typeName4("T", []), null, null, ASTFactory.identifier3("m"), ASTFac tory.formalParameterList([]), ASTFactory.blockFunctionBody2([])));
1851 } 1852 }
1852 void test_visitMethodInvocation_noTarget() { 1853 void test_visitMethodInvocation_noTarget() {
1853 assertSource("m()", ASTFactory.methodInvocation2("m", [])); 1854 assertSource("m()", ASTFactory.methodInvocation2("m", []));
1854 } 1855 }
1855 void test_visitMethodInvocation_target() { 1856 void test_visitMethodInvocation_target() {
1856 assertSource("t.m()", ASTFactory.methodInvocation(ASTFactory.identifier3("t" ), "m", [])); 1857 assertSource("t.m()", ASTFactory.methodInvocation(ASTFactory.identifier3("t" ), "m", []));
1857 } 1858 }
1858 void test_visitNamedExpression() { 1859 void test_visitNamedExpression() {
1859 assertSource("a: b", ASTFactory.namedExpression2("a", ASTFactory.identifier3 ("b"))); 1860 assertSource("a: b", ASTFactory.namedExpression2("a", ASTFactory.identifier3 ("b")));
1860 } 1861 }
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
3096 } 3097 }
3097 main() { 3098 main() {
3098 ConstantEvaluatorTest.dartSuite(); 3099 ConstantEvaluatorTest.dartSuite();
3099 NodeLocatorTest.dartSuite(); 3100 NodeLocatorTest.dartSuite();
3100 ToSourceVisitorTest.dartSuite(); 3101 ToSourceVisitorTest.dartSuite();
3101 BreadthFirstVisitorTest.dartSuite(); 3102 BreadthFirstVisitorTest.dartSuite();
3102 IndexExpressionTest.dartSuite(); 3103 IndexExpressionTest.dartSuite();
3103 SimpleIdentifierTest.dartSuite(); 3104 SimpleIdentifierTest.dartSuite();
3104 VariableDeclarationTest.dartSuite(); 3105 VariableDeclarationTest.dartSuite();
3105 } 3106 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/lib/src/generated/source_io.dart ('k') | pkg/analyzer_experimental/test/generated/element_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698