OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.test.src.dart.ast.utilities_test; | 5 library analyzer.test.src.dart.ast.utilities_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; | |
9 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
10 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
11 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
12 import 'package:analyzer/src/dart/ast/utilities.dart'; | 11 import 'package:analyzer/src/dart/ast/utilities.dart'; |
13 import 'package:analyzer/src/dart/element/element.dart'; | 12 import 'package:analyzer/src/dart/element/element.dart'; |
14 import 'package:analyzer/src/generated/java_core.dart'; | 13 import 'package:analyzer/src/generated/java_core.dart'; |
15 import 'package:analyzer/src/generated/java_engine.dart' show Predicate; | 14 import 'package:analyzer/src/generated/java_engine.dart' show Predicate; |
16 import 'package:analyzer/src/generated/java_engine.dart'; | 15 import 'package:analyzer/src/generated/java_engine.dart'; |
17 import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; | 16 import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; |
18 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 17 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 expect(node.offset <= start, isTrue, reason: "Node starts after range"); | 430 expect(node.offset <= start, isTrue, reason: "Node starts after range"); |
432 expect(node.offset + node.length > end, isTrue, | 431 expect(node.offset + node.length > end, isTrue, |
433 reason: "Node ends before range"); | 432 reason: "Node ends before range"); |
434 EngineTestCase.assertInstanceOf(predicate, expectedClass, node); | 433 EngineTestCase.assertInstanceOf(predicate, expectedClass, node); |
435 } | 434 } |
436 } | 435 } |
437 | 436 |
438 @reflectiveTest | 437 @reflectiveTest |
439 class ResolutionCopierTest extends EngineTestCase { | 438 class ResolutionCopierTest extends EngineTestCase { |
440 void test_visitAdjacentStrings() { | 439 void test_visitAdjacentStrings() { |
441 AdjacentStrings createNode() => astFactory.adjacentStrings([ | 440 AdjacentStrings createNode() => new AdjacentStrings([ |
442 astFactory.simpleStringLiteral(null, 'hello'), | 441 new SimpleStringLiteral(null, 'hello'), |
443 astFactory.simpleStringLiteral(null, 'world') | 442 new SimpleStringLiteral(null, 'world') |
444 ]); | 443 ]); |
445 | 444 |
446 AdjacentStrings fromNode = createNode(); | 445 AdjacentStrings fromNode = createNode(); |
447 DartType propagatedType = ElementFactory.classElement2("A").type; | 446 DartType propagatedType = ElementFactory.classElement2("A").type; |
448 fromNode.propagatedType = propagatedType; | 447 fromNode.propagatedType = propagatedType; |
449 DartType staticType = ElementFactory.classElement2("B").type; | 448 DartType staticType = ElementFactory.classElement2("B").type; |
450 fromNode.staticType = staticType; | 449 fromNode.staticType = staticType; |
451 | 450 |
452 AdjacentStrings toNode = createNode(); | 451 AdjacentStrings toNode = createNode(); |
453 ResolutionCopier.copyResolutionData(fromNode, toNode); | 452 ResolutionCopier.copyResolutionData(fromNode, toNode); |
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1549 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]), | 1548 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]), |
1550 null); | 1549 null); |
1551 declaration.metadata.add( | 1550 declaration.metadata.add( |
1552 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated"))); | 1551 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated"))); |
1553 _assertSource("@deprecated class C = S with M1;", declaration); | 1552 _assertSource("@deprecated class C = S with M1;", declaration); |
1554 } | 1553 } |
1555 | 1554 |
1556 void test_visitComment() { | 1555 void test_visitComment() { |
1557 _assertSource( | 1556 _assertSource( |
1558 "", | 1557 "", |
1559 astFactory.blockComment( | 1558 Comment.createBlockComment( |
1560 <Token>[TokenFactory.tokenFromString("/* comment */")])); | 1559 <Token>[TokenFactory.tokenFromString("/* comment */")])); |
1561 } | 1560 } |
1562 | 1561 |
1563 void test_visitCommentReference() { | 1562 void test_visitCommentReference() { |
1564 _assertSource( | 1563 _assertSource( |
1565 "", astFactory.commentReference(null, AstTestFactory.identifier3("a"))); | 1564 "", new CommentReference(null, AstTestFactory.identifier3("a"))); |
1566 } | 1565 } |
1567 | 1566 |
1568 void test_visitCompilationUnit_declaration() { | 1567 void test_visitCompilationUnit_declaration() { |
1569 _assertSource( | 1568 _assertSource( |
1570 "var a;", | 1569 "var a;", |
1571 AstTestFactory.compilationUnit2([ | 1570 AstTestFactory.compilationUnit2([ |
1572 AstTestFactory.topLevelVariableDeclaration2( | 1571 AstTestFactory.topLevelVariableDeclaration2( |
1573 Keyword.VAR, [AstTestFactory.variableDeclaration("a")]) | 1572 Keyword.VAR, [AstTestFactory.variableDeclaration("a")]) |
1574 ])); | 1573 ])); |
1575 } | 1574 } |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1941 null, | 1940 null, |
1942 AstTestFactory.typeName4("A"), | 1941 AstTestFactory.typeName4("A"), |
1943 "a", | 1942 "a", |
1944 AstTestFactory.formalParameterList( | 1943 AstTestFactory.formalParameterList( |
1945 [AstTestFactory.simpleFormalParameter3("b")]))); | 1944 [AstTestFactory.simpleFormalParameter3("b")]))); |
1946 } | 1945 } |
1947 | 1946 |
1948 void test_visitFieldFormalParameter_functionTyped_typeParameters() { | 1947 void test_visitFieldFormalParameter_functionTyped_typeParameters() { |
1949 _assertSource( | 1948 _assertSource( |
1950 "A this.a<E, F>(b)", | 1949 "A this.a<E, F>(b)", |
1951 astFactory.fieldFormalParameter( | 1950 new FieldFormalParameter( |
1952 null, | 1951 null, |
1953 null, | 1952 null, |
1954 null, | 1953 null, |
1955 AstTestFactory.typeName4('A'), | 1954 AstTestFactory.typeName4('A'), |
1956 TokenFactory.tokenFromKeyword(Keyword.THIS), | 1955 TokenFactory.tokenFromKeyword(Keyword.THIS), |
1957 TokenFactory.tokenFromType(TokenType.PERIOD), | 1956 TokenFactory.tokenFromType(TokenType.PERIOD), |
1958 AstTestFactory.identifier3('a'), | 1957 AstTestFactory.identifier3('a'), |
1959 AstTestFactory.typeParameterList(['E', 'F']), | 1958 AstTestFactory.typeParameterList(['E', 'F']), |
1960 AstTestFactory.formalParameterList( | 1959 AstTestFactory.formalParameterList( |
1961 [AstTestFactory.simpleFormalParameter3("b")]))); | 1960 [AstTestFactory.simpleFormalParameter3("b")]))); |
(...skipping 21 matching lines...) Expand all Loading... |
1983 void test_visitForEachStatement_declared() { | 1982 void test_visitForEachStatement_declared() { |
1984 _assertSource( | 1983 _assertSource( |
1985 "for (var a in b) {}", | 1984 "for (var a in b) {}", |
1986 AstTestFactory.forEachStatement(AstTestFactory.declaredIdentifier3("a"), | 1985 AstTestFactory.forEachStatement(AstTestFactory.declaredIdentifier3("a"), |
1987 AstTestFactory.identifier3("b"), AstTestFactory.block())); | 1986 AstTestFactory.identifier3("b"), AstTestFactory.block())); |
1988 } | 1987 } |
1989 | 1988 |
1990 void test_visitForEachStatement_variable() { | 1989 void test_visitForEachStatement_variable() { |
1991 _assertSource( | 1990 _assertSource( |
1992 "for (a in b) {}", | 1991 "for (a in b) {}", |
1993 astFactory.forEachStatementWithReference( | 1992 new ForEachStatement.withReference( |
1994 null, | 1993 null, |
1995 TokenFactory.tokenFromKeyword(Keyword.FOR), | 1994 TokenFactory.tokenFromKeyword(Keyword.FOR), |
1996 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), | 1995 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), |
1997 AstTestFactory.identifier3("a"), | 1996 AstTestFactory.identifier3("a"), |
1998 TokenFactory.tokenFromKeyword(Keyword.IN), | 1997 TokenFactory.tokenFromKeyword(Keyword.IN), |
1999 AstTestFactory.identifier3("b"), | 1998 AstTestFactory.identifier3("b"), |
2000 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), | 1999 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), |
2001 AstTestFactory.block())); | 2000 AstTestFactory.block())); |
2002 } | 2001 } |
2003 | 2002 |
2004 void test_visitForEachStatement_variable_await() { | 2003 void test_visitForEachStatement_variable_await() { |
2005 _assertSource( | 2004 _assertSource( |
2006 "await for (a in b) {}", | 2005 "await for (a in b) {}", |
2007 astFactory.forEachStatementWithReference( | 2006 new ForEachStatement.withReference( |
2008 TokenFactory.tokenFromString("await"), | 2007 TokenFactory.tokenFromString("await"), |
2009 TokenFactory.tokenFromKeyword(Keyword.FOR), | 2008 TokenFactory.tokenFromKeyword(Keyword.FOR), |
2010 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), | 2009 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), |
2011 AstTestFactory.identifier3("a"), | 2010 AstTestFactory.identifier3("a"), |
2012 TokenFactory.tokenFromKeyword(Keyword.IN), | 2011 TokenFactory.tokenFromKeyword(Keyword.IN), |
2013 AstTestFactory.identifier3("b"), | 2012 AstTestFactory.identifier3("b"), |
2014 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), | 2013 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), |
2015 AstTestFactory.block())); | 2014 AstTestFactory.block())); |
2016 } | 2015 } |
2017 | 2016 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2299 _assertSource( | 2298 _assertSource( |
2300 "get f() {}", | 2299 "get f() {}", |
2301 AstTestFactory.functionDeclaration( | 2300 AstTestFactory.functionDeclaration( |
2302 null, Keyword.GET, "f", AstTestFactory.functionExpression())); | 2301 null, Keyword.GET, "f", AstTestFactory.functionExpression())); |
2303 } | 2302 } |
2304 | 2303 |
2305 void test_visitFunctionDeclaration_local_blockBody() { | 2304 void test_visitFunctionDeclaration_local_blockBody() { |
2306 FunctionDeclaration f = AstTestFactory.functionDeclaration( | 2305 FunctionDeclaration f = AstTestFactory.functionDeclaration( |
2307 null, null, "f", AstTestFactory.functionExpression()); | 2306 null, null, "f", AstTestFactory.functionExpression()); |
2308 FunctionDeclarationStatement fStatement = | 2307 FunctionDeclarationStatement fStatement = |
2309 astFactory.functionDeclarationStatement(f); | 2308 new FunctionDeclarationStatement(f); |
2310 _assertSource( | 2309 _assertSource( |
2311 "main() {f() {} 42;}", | 2310 "main() {f() {} 42;}", |
2312 AstTestFactory.functionDeclaration( | 2311 AstTestFactory.functionDeclaration( |
2313 null, | 2312 null, |
2314 null, | 2313 null, |
2315 "main", | 2314 "main", |
2316 AstTestFactory.functionExpression2( | 2315 AstTestFactory.functionExpression2( |
2317 AstTestFactory.formalParameterList(), | 2316 AstTestFactory.formalParameterList(), |
2318 AstTestFactory.blockFunctionBody2([ | 2317 AstTestFactory.blockFunctionBody2([ |
2319 fStatement, | 2318 fStatement, |
2320 AstTestFactory.expressionStatement(AstTestFactory.integer(42)) | 2319 AstTestFactory.expressionStatement(AstTestFactory.integer(42)) |
2321 ])))); | 2320 ])))); |
2322 } | 2321 } |
2323 | 2322 |
2324 void test_visitFunctionDeclaration_local_expressionBody() { | 2323 void test_visitFunctionDeclaration_local_expressionBody() { |
2325 FunctionDeclaration f = AstTestFactory.functionDeclaration( | 2324 FunctionDeclaration f = AstTestFactory.functionDeclaration( |
2326 null, | 2325 null, |
2327 null, | 2326 null, |
2328 "f", | 2327 "f", |
2329 AstTestFactory.functionExpression2(AstTestFactory.formalParameterList(), | 2328 AstTestFactory.functionExpression2(AstTestFactory.formalParameterList(), |
2330 AstTestFactory.expressionFunctionBody(AstTestFactory.integer(1)))); | 2329 AstTestFactory.expressionFunctionBody(AstTestFactory.integer(1)))); |
2331 FunctionDeclarationStatement fStatement = | 2330 FunctionDeclarationStatement fStatement = |
2332 astFactory.functionDeclarationStatement(f); | 2331 new FunctionDeclarationStatement(f); |
2333 _assertSource( | 2332 _assertSource( |
2334 "main() {f() => 1; 2;}", | 2333 "main() {f() => 1; 2;}", |
2335 AstTestFactory.functionDeclaration( | 2334 AstTestFactory.functionDeclaration( |
2336 null, | 2335 null, |
2337 null, | 2336 null, |
2338 "main", | 2337 "main", |
2339 AstTestFactory.functionExpression2( | 2338 AstTestFactory.functionExpression2( |
2340 AstTestFactory.formalParameterList(), | 2339 AstTestFactory.formalParameterList(), |
2341 AstTestFactory.blockFunctionBody2([ | 2340 AstTestFactory.blockFunctionBody2([ |
2342 fStatement, | 2341 fStatement, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2458 void test_visitFunctionTypedFormalParameter_type() { | 2457 void test_visitFunctionTypedFormalParameter_type() { |
2459 _assertSource( | 2458 _assertSource( |
2460 "T f()", | 2459 "T f()", |
2461 AstTestFactory.functionTypedFormalParameter( | 2460 AstTestFactory.functionTypedFormalParameter( |
2462 AstTestFactory.typeName4("T"), "f")); | 2461 AstTestFactory.typeName4("T"), "f")); |
2463 } | 2462 } |
2464 | 2463 |
2465 void test_visitFunctionTypedFormalParameter_typeParameters() { | 2464 void test_visitFunctionTypedFormalParameter_typeParameters() { |
2466 _assertSource( | 2465 _assertSource( |
2467 "T f<E>()", | 2466 "T f<E>()", |
2468 astFactory.functionTypedFormalParameter( | 2467 new FunctionTypedFormalParameter( |
2469 null, | 2468 null, |
2470 null, | 2469 null, |
2471 AstTestFactory.typeName4("T"), | 2470 AstTestFactory.typeName4("T"), |
2472 AstTestFactory.identifier3('f'), | 2471 AstTestFactory.identifier3('f'), |
2473 AstTestFactory.typeParameterList(['E']), | 2472 AstTestFactory.typeParameterList(['E']), |
2474 AstTestFactory.formalParameterList([]))); | 2473 AstTestFactory.formalParameterList([]))); |
2475 } | 2474 } |
2476 | 2475 |
2477 void test_visitIfStatement_withElse() { | 2476 void test_visitIfStatement_withElse() { |
2478 _assertSource( | 2477 _assertSource( |
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3879 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]), | 3878 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]), |
3880 null); | 3879 null); |
3881 declaration.metadata.add( | 3880 declaration.metadata.add( |
3882 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated"))); | 3881 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated"))); |
3883 _assertSource("@deprecated class C = S with M1;", declaration); | 3882 _assertSource("@deprecated class C = S with M1;", declaration); |
3884 } | 3883 } |
3885 | 3884 |
3886 void test_visitComment() { | 3885 void test_visitComment() { |
3887 _assertSource( | 3886 _assertSource( |
3888 "", | 3887 "", |
3889 astFactory.blockComment( | 3888 Comment.createBlockComment( |
3890 <Token>[TokenFactory.tokenFromString("/* comment */")])); | 3889 <Token>[TokenFactory.tokenFromString("/* comment */")])); |
3891 } | 3890 } |
3892 | 3891 |
3893 void test_visitCommentReference() { | 3892 void test_visitCommentReference() { |
3894 _assertSource( | 3893 _assertSource( |
3895 "", astFactory.commentReference(null, AstTestFactory.identifier3("a"))); | 3894 "", new CommentReference(null, AstTestFactory.identifier3("a"))); |
3896 } | 3895 } |
3897 | 3896 |
3898 void test_visitCompilationUnit_declaration() { | 3897 void test_visitCompilationUnit_declaration() { |
3899 _assertSource( | 3898 _assertSource( |
3900 "var a;", | 3899 "var a;", |
3901 AstTestFactory.compilationUnit2([ | 3900 AstTestFactory.compilationUnit2([ |
3902 AstTestFactory.topLevelVariableDeclaration2( | 3901 AstTestFactory.topLevelVariableDeclaration2( |
3903 Keyword.VAR, [AstTestFactory.variableDeclaration("a")]) | 3902 Keyword.VAR, [AstTestFactory.variableDeclaration("a")]) |
3904 ])); | 3903 ])); |
3905 } | 3904 } |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4271 null, | 4270 null, |
4272 AstTestFactory.typeName4("A"), | 4271 AstTestFactory.typeName4("A"), |
4273 "a", | 4272 "a", |
4274 AstTestFactory.formalParameterList( | 4273 AstTestFactory.formalParameterList( |
4275 [AstTestFactory.simpleFormalParameter3("b")]))); | 4274 [AstTestFactory.simpleFormalParameter3("b")]))); |
4276 } | 4275 } |
4277 | 4276 |
4278 void test_visitFieldFormalParameter_functionTyped_typeParameters() { | 4277 void test_visitFieldFormalParameter_functionTyped_typeParameters() { |
4279 _assertSource( | 4278 _assertSource( |
4280 "A this.a<E, F>(b)", | 4279 "A this.a<E, F>(b)", |
4281 astFactory.fieldFormalParameter( | 4280 new FieldFormalParameter( |
4282 null, | 4281 null, |
4283 null, | 4282 null, |
4284 null, | 4283 null, |
4285 AstTestFactory.typeName4('A'), | 4284 AstTestFactory.typeName4('A'), |
4286 TokenFactory.tokenFromKeyword(Keyword.THIS), | 4285 TokenFactory.tokenFromKeyword(Keyword.THIS), |
4287 TokenFactory.tokenFromType(TokenType.PERIOD), | 4286 TokenFactory.tokenFromType(TokenType.PERIOD), |
4288 AstTestFactory.identifier3('a'), | 4287 AstTestFactory.identifier3('a'), |
4289 AstTestFactory.typeParameterList(['E', 'F']), | 4288 AstTestFactory.typeParameterList(['E', 'F']), |
4290 AstTestFactory.formalParameterList( | 4289 AstTestFactory.formalParameterList( |
4291 [AstTestFactory.simpleFormalParameter3("b")]))); | 4290 [AstTestFactory.simpleFormalParameter3("b")]))); |
(...skipping 21 matching lines...) Expand all Loading... |
4313 void test_visitForEachStatement_declared() { | 4312 void test_visitForEachStatement_declared() { |
4314 _assertSource( | 4313 _assertSource( |
4315 "for (var a in b) {}", | 4314 "for (var a in b) {}", |
4316 AstTestFactory.forEachStatement(AstTestFactory.declaredIdentifier3("a"), | 4315 AstTestFactory.forEachStatement(AstTestFactory.declaredIdentifier3("a"), |
4317 AstTestFactory.identifier3("b"), AstTestFactory.block())); | 4316 AstTestFactory.identifier3("b"), AstTestFactory.block())); |
4318 } | 4317 } |
4319 | 4318 |
4320 void test_visitForEachStatement_variable() { | 4319 void test_visitForEachStatement_variable() { |
4321 _assertSource( | 4320 _assertSource( |
4322 "for (a in b) {}", | 4321 "for (a in b) {}", |
4323 astFactory.forEachStatementWithReference( | 4322 new ForEachStatement.withReference( |
4324 null, | 4323 null, |
4325 TokenFactory.tokenFromKeyword(Keyword.FOR), | 4324 TokenFactory.tokenFromKeyword(Keyword.FOR), |
4326 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), | 4325 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), |
4327 AstTestFactory.identifier3("a"), | 4326 AstTestFactory.identifier3("a"), |
4328 TokenFactory.tokenFromKeyword(Keyword.IN), | 4327 TokenFactory.tokenFromKeyword(Keyword.IN), |
4329 AstTestFactory.identifier3("b"), | 4328 AstTestFactory.identifier3("b"), |
4330 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), | 4329 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), |
4331 AstTestFactory.block())); | 4330 AstTestFactory.block())); |
4332 } | 4331 } |
4333 | 4332 |
4334 void test_visitForEachStatement_variable_await() { | 4333 void test_visitForEachStatement_variable_await() { |
4335 _assertSource( | 4334 _assertSource( |
4336 "await for (a in b) {}", | 4335 "await for (a in b) {}", |
4337 astFactory.forEachStatementWithReference( | 4336 new ForEachStatement.withReference( |
4338 TokenFactory.tokenFromString("await"), | 4337 TokenFactory.tokenFromString("await"), |
4339 TokenFactory.tokenFromKeyword(Keyword.FOR), | 4338 TokenFactory.tokenFromKeyword(Keyword.FOR), |
4340 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), | 4339 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), |
4341 AstTestFactory.identifier3("a"), | 4340 AstTestFactory.identifier3("a"), |
4342 TokenFactory.tokenFromKeyword(Keyword.IN), | 4341 TokenFactory.tokenFromKeyword(Keyword.IN), |
4343 AstTestFactory.identifier3("b"), | 4342 AstTestFactory.identifier3("b"), |
4344 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), | 4343 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), |
4345 AstTestFactory.block())); | 4344 AstTestFactory.block())); |
4346 } | 4345 } |
4347 | 4346 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4629 _assertSource( | 4628 _assertSource( |
4630 "get f() {}", | 4629 "get f() {}", |
4631 AstTestFactory.functionDeclaration( | 4630 AstTestFactory.functionDeclaration( |
4632 null, Keyword.GET, "f", AstTestFactory.functionExpression())); | 4631 null, Keyword.GET, "f", AstTestFactory.functionExpression())); |
4633 } | 4632 } |
4634 | 4633 |
4635 void test_visitFunctionDeclaration_local_blockBody() { | 4634 void test_visitFunctionDeclaration_local_blockBody() { |
4636 FunctionDeclaration f = AstTestFactory.functionDeclaration( | 4635 FunctionDeclaration f = AstTestFactory.functionDeclaration( |
4637 null, null, "f", AstTestFactory.functionExpression()); | 4636 null, null, "f", AstTestFactory.functionExpression()); |
4638 FunctionDeclarationStatement fStatement = | 4637 FunctionDeclarationStatement fStatement = |
4639 astFactory.functionDeclarationStatement(f); | 4638 new FunctionDeclarationStatement(f); |
4640 _assertSource( | 4639 _assertSource( |
4641 "main() {f() {} 42;}", | 4640 "main() {f() {} 42;}", |
4642 AstTestFactory.functionDeclaration( | 4641 AstTestFactory.functionDeclaration( |
4643 null, | 4642 null, |
4644 null, | 4643 null, |
4645 "main", | 4644 "main", |
4646 AstTestFactory.functionExpression2( | 4645 AstTestFactory.functionExpression2( |
4647 AstTestFactory.formalParameterList(), | 4646 AstTestFactory.formalParameterList(), |
4648 AstTestFactory.blockFunctionBody2([ | 4647 AstTestFactory.blockFunctionBody2([ |
4649 fStatement, | 4648 fStatement, |
4650 AstTestFactory.expressionStatement(AstTestFactory.integer(42)) | 4649 AstTestFactory.expressionStatement(AstTestFactory.integer(42)) |
4651 ])))); | 4650 ])))); |
4652 } | 4651 } |
4653 | 4652 |
4654 void test_visitFunctionDeclaration_local_expressionBody() { | 4653 void test_visitFunctionDeclaration_local_expressionBody() { |
4655 FunctionDeclaration f = AstTestFactory.functionDeclaration( | 4654 FunctionDeclaration f = AstTestFactory.functionDeclaration( |
4656 null, | 4655 null, |
4657 null, | 4656 null, |
4658 "f", | 4657 "f", |
4659 AstTestFactory.functionExpression2(AstTestFactory.formalParameterList(), | 4658 AstTestFactory.functionExpression2(AstTestFactory.formalParameterList(), |
4660 AstTestFactory.expressionFunctionBody(AstTestFactory.integer(1)))); | 4659 AstTestFactory.expressionFunctionBody(AstTestFactory.integer(1)))); |
4661 FunctionDeclarationStatement fStatement = | 4660 FunctionDeclarationStatement fStatement = |
4662 astFactory.functionDeclarationStatement(f); | 4661 new FunctionDeclarationStatement(f); |
4663 _assertSource( | 4662 _assertSource( |
4664 "main() {f() => 1; 2;}", | 4663 "main() {f() => 1; 2;}", |
4665 AstTestFactory.functionDeclaration( | 4664 AstTestFactory.functionDeclaration( |
4666 null, | 4665 null, |
4667 null, | 4666 null, |
4668 "main", | 4667 "main", |
4669 AstTestFactory.functionExpression2( | 4668 AstTestFactory.functionExpression2( |
4670 AstTestFactory.formalParameterList(), | 4669 AstTestFactory.formalParameterList(), |
4671 AstTestFactory.blockFunctionBody2([ | 4670 AstTestFactory.blockFunctionBody2([ |
4672 fStatement, | 4671 fStatement, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4788 void test_visitFunctionTypedFormalParameter_type() { | 4787 void test_visitFunctionTypedFormalParameter_type() { |
4789 _assertSource( | 4788 _assertSource( |
4790 "T f()", | 4789 "T f()", |
4791 AstTestFactory.functionTypedFormalParameter( | 4790 AstTestFactory.functionTypedFormalParameter( |
4792 AstTestFactory.typeName4("T"), "f")); | 4791 AstTestFactory.typeName4("T"), "f")); |
4793 } | 4792 } |
4794 | 4793 |
4795 void test_visitFunctionTypedFormalParameter_typeParameters() { | 4794 void test_visitFunctionTypedFormalParameter_typeParameters() { |
4796 _assertSource( | 4795 _assertSource( |
4797 "T f<E>()", | 4796 "T f<E>()", |
4798 astFactory.functionTypedFormalParameter( | 4797 new FunctionTypedFormalParameter( |
4799 null, | 4798 null, |
4800 null, | 4799 null, |
4801 AstTestFactory.typeName4("T"), | 4800 AstTestFactory.typeName4("T"), |
4802 AstTestFactory.identifier3('f'), | 4801 AstTestFactory.identifier3('f'), |
4803 AstTestFactory.typeParameterList(['E']), | 4802 AstTestFactory.typeParameterList(['E']), |
4804 AstTestFactory.formalParameterList([]))); | 4803 AstTestFactory.formalParameterList([]))); |
4805 } | 4804 } |
4806 | 4805 |
4807 void test_visitIfStatement_withElse() { | 4806 void test_visitIfStatement_withElse() { |
4808 _assertSource( | 4807 _assertSource( |
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5768 /** | 5767 /** |
5769 * Assert that a `ToSourceVisitor` will produce the [expectedSource] when | 5768 * Assert that a `ToSourceVisitor` will produce the [expectedSource] when |
5770 * visiting the given [node]. | 5769 * visiting the given [node]. |
5771 */ | 5770 */ |
5772 void _assertSource(String expectedSource, AstNode node) { | 5771 void _assertSource(String expectedSource, AstNode node) { |
5773 PrintStringWriter writer = new PrintStringWriter(); | 5772 PrintStringWriter writer = new PrintStringWriter(); |
5774 node.accept(new ToSourceVisitor(writer)); | 5773 node.accept(new ToSourceVisitor(writer)); |
5775 expect(writer.toString(), expectedSource); | 5774 expect(writer.toString(), expectedSource); |
5776 } | 5775 } |
5777 } | 5776 } |
OLD | NEW |