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'; | 8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
9 import 'package:analyzer/dart/ast/token.dart'; | 9 import 'package:analyzer/dart/ast/token.dart'; |
10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
(...skipping 2491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2502 void test_visitFunctionTypedFormalParameter_typeParameters() { | 2502 void test_visitFunctionTypedFormalParameter_typeParameters() { |
2503 _assertSource( | 2503 _assertSource( |
2504 "T f<E>()", | 2504 "T f<E>()", |
2505 astFactory.functionTypedFormalParameter2( | 2505 astFactory.functionTypedFormalParameter2( |
2506 returnType: AstTestFactory.typeName4("T"), | 2506 returnType: AstTestFactory.typeName4("T"), |
2507 identifier: AstTestFactory.identifier3('f'), | 2507 identifier: AstTestFactory.identifier3('f'), |
2508 typeParameters: AstTestFactory.typeParameterList(['E']), | 2508 typeParameters: AstTestFactory.typeParameterList(['E']), |
2509 parameters: AstTestFactory.formalParameterList([]))); | 2509 parameters: AstTestFactory.formalParameterList([]))); |
2510 } | 2510 } |
2511 | 2511 |
| 2512 void test_visitGenericFunctionType() { |
| 2513 _assertSource( |
| 2514 "int Function<T>(T)", |
| 2515 AstTestFactory.genericFunctionType( |
| 2516 AstTestFactory.typeName4("int"), |
| 2517 AstTestFactory.typeParameterList(['T']), |
| 2518 AstTestFactory.formalParameterList([ |
| 2519 AstTestFactory.simpleFormalParameter4( |
| 2520 AstTestFactory.typeName4("T"), null) |
| 2521 ]))); |
| 2522 } |
| 2523 |
| 2524 void test_visitGenericTypeAlias() { |
| 2525 _assertSource( |
| 2526 "typedef X<S> = S Function<T>(T)", |
| 2527 AstTestFactory.genericTypeAlias( |
| 2528 'X', |
| 2529 AstTestFactory.typeParameterList(['S']), |
| 2530 AstTestFactory.genericFunctionType( |
| 2531 AstTestFactory.typeName4("S"), |
| 2532 AstTestFactory.typeParameterList(['T']), |
| 2533 AstTestFactory.formalParameterList([ |
| 2534 AstTestFactory.simpleFormalParameter4( |
| 2535 AstTestFactory.typeName4("T"), null) |
| 2536 ])))); |
| 2537 } |
| 2538 |
2512 void test_visitIfStatement_withElse() { | 2539 void test_visitIfStatement_withElse() { |
2513 _assertSource( | 2540 _assertSource( |
2514 "if (c) {} else {}", | 2541 "if (c) {} else {}", |
2515 AstTestFactory.ifStatement2(AstTestFactory.identifier3("c"), | 2542 AstTestFactory.ifStatement2(AstTestFactory.identifier3("c"), |
2516 AstTestFactory.block(), AstTestFactory.block())); | 2543 AstTestFactory.block(), AstTestFactory.block())); |
2517 } | 2544 } |
2518 | 2545 |
2519 void test_visitIfStatement_withoutElse() { | 2546 void test_visitIfStatement_withoutElse() { |
2520 _assertSource( | 2547 _assertSource( |
2521 "if (c) {}", | 2548 "if (c) {}", |
(...skipping 2329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4851 void test_visitFunctionTypedFormalParameter_typeParameters() { | 4878 void test_visitFunctionTypedFormalParameter_typeParameters() { |
4852 _assertSource( | 4879 _assertSource( |
4853 "T f<E>()", | 4880 "T f<E>()", |
4854 astFactory.functionTypedFormalParameter2( | 4881 astFactory.functionTypedFormalParameter2( |
4855 returnType: AstTestFactory.typeName4("T"), | 4882 returnType: AstTestFactory.typeName4("T"), |
4856 identifier: AstTestFactory.identifier3('f'), | 4883 identifier: AstTestFactory.identifier3('f'), |
4857 typeParameters: AstTestFactory.typeParameterList(['E']), | 4884 typeParameters: AstTestFactory.typeParameterList(['E']), |
4858 parameters: AstTestFactory.formalParameterList([]))); | 4885 parameters: AstTestFactory.formalParameterList([]))); |
4859 } | 4886 } |
4860 | 4887 |
| 4888 void test_visitGenericFunctionType() { |
| 4889 _assertSource( |
| 4890 "int Function<T>(T)", |
| 4891 AstTestFactory.genericFunctionType( |
| 4892 AstTestFactory.typeName4("int"), |
| 4893 AstTestFactory.typeParameterList(['T']), |
| 4894 AstTestFactory.formalParameterList([ |
| 4895 AstTestFactory.simpleFormalParameter4( |
| 4896 AstTestFactory.typeName4("T"), null) |
| 4897 ]))); |
| 4898 } |
| 4899 |
| 4900 void test_visitGenericTypeAlias() { |
| 4901 _assertSource( |
| 4902 "typedef X<S> = S Function<T>(T)", |
| 4903 AstTestFactory.genericTypeAlias( |
| 4904 'X', |
| 4905 AstTestFactory.typeParameterList(['S']), |
| 4906 AstTestFactory.genericFunctionType( |
| 4907 AstTestFactory.typeName4("S"), |
| 4908 AstTestFactory.typeParameterList(['T']), |
| 4909 AstTestFactory.formalParameterList([ |
| 4910 AstTestFactory.simpleFormalParameter4( |
| 4911 AstTestFactory.typeName4("T"), null) |
| 4912 ])))); |
| 4913 } |
| 4914 |
4861 void test_visitIfStatement_withElse() { | 4915 void test_visitIfStatement_withElse() { |
4862 _assertSource( | 4916 _assertSource( |
4863 "if (c) {} else {}", | 4917 "if (c) {} else {}", |
4864 AstTestFactory.ifStatement2(AstTestFactory.identifier3("c"), | 4918 AstTestFactory.ifStatement2(AstTestFactory.identifier3("c"), |
4865 AstTestFactory.block(), AstTestFactory.block())); | 4919 AstTestFactory.block(), AstTestFactory.block())); |
4866 } | 4920 } |
4867 | 4921 |
4868 void test_visitIfStatement_withoutElse() { | 4922 void test_visitIfStatement_withoutElse() { |
4869 _assertSource( | 4923 _assertSource( |
4870 "if (c) {}", | 4924 "if (c) {}", |
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5830 /** | 5884 /** |
5831 * Assert that a `ToSourceVisitor` will produce the [expectedSource] when | 5885 * Assert that a `ToSourceVisitor` will produce the [expectedSource] when |
5832 * visiting the given [node]. | 5886 * visiting the given [node]. |
5833 */ | 5887 */ |
5834 void _assertSource(String expectedSource, AstNode node) { | 5888 void _assertSource(String expectedSource, AstNode node) { |
5835 PrintStringWriter writer = new PrintStringWriter(); | 5889 PrintStringWriter writer = new PrintStringWriter(); |
5836 node.accept(new ToSourceVisitor(writer)); | 5890 node.accept(new ToSourceVisitor(writer)); |
5837 expect(writer.toString(), expectedSource); | 5891 expect(writer.toString(), expectedSource); |
5838 } | 5892 } |
5839 } | 5893 } |
OLD | NEW |