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 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1969 [AstTestFactory.simpleFormalParameter3("b")]))); | 1969 [AstTestFactory.simpleFormalParameter3("b")]))); |
1970 } | 1970 } |
1971 | 1971 |
1972 void test_visitFieldFormalParameter_functionTyped_typeParameters() { | 1972 void test_visitFieldFormalParameter_functionTyped_typeParameters() { |
1973 _assertSource( | 1973 _assertSource( |
1974 "A this.a<E, F>(b)", | 1974 "A this.a<E, F>(b)", |
1975 astFactory.fieldFormalParameter( | 1975 astFactory.fieldFormalParameter( |
1976 null, | 1976 null, |
1977 null, | 1977 null, |
1978 null, | 1978 null, |
| 1979 null, |
1979 AstTestFactory.typeName4('A'), | 1980 AstTestFactory.typeName4('A'), |
1980 TokenFactory.tokenFromKeyword(Keyword.THIS), | 1981 TokenFactory.tokenFromKeyword(Keyword.THIS), |
1981 TokenFactory.tokenFromType(TokenType.PERIOD), | 1982 TokenFactory.tokenFromType(TokenType.PERIOD), |
1982 AstTestFactory.identifier3('a'), | 1983 AstTestFactory.identifier3('a'), |
1983 AstTestFactory.typeParameterList(['E', 'F']), | 1984 AstTestFactory.typeParameterList(['E', 'F']), |
1984 AstTestFactory.formalParameterList( | 1985 AstTestFactory.formalParameterList( |
1985 [AstTestFactory.simpleFormalParameter3("b")]))); | 1986 [AstTestFactory.simpleFormalParameter3("b")]))); |
1986 } | 1987 } |
1987 | 1988 |
1988 void test_visitFieldFormalParameter_keyword() { | 1989 void test_visitFieldFormalParameter_keyword() { |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2501 TokenFactory.tokenFromKeyword(Keyword.COVARIANT); | 2502 TokenFactory.tokenFromKeyword(Keyword.COVARIANT); |
2502 _assertSource("covariant T f()", expected); | 2503 _assertSource("covariant T f()", expected); |
2503 } | 2504 } |
2504 | 2505 |
2505 void test_visitFunctionTypedFormalParameter_typeParameters() { | 2506 void test_visitFunctionTypedFormalParameter_typeParameters() { |
2506 _assertSource( | 2507 _assertSource( |
2507 "T f<E>()", | 2508 "T f<E>()", |
2508 astFactory.functionTypedFormalParameter( | 2509 astFactory.functionTypedFormalParameter( |
2509 null, | 2510 null, |
2510 null, | 2511 null, |
| 2512 null, |
2511 AstTestFactory.typeName4("T"), | 2513 AstTestFactory.typeName4("T"), |
2512 AstTestFactory.identifier3('f'), | 2514 AstTestFactory.identifier3('f'), |
2513 AstTestFactory.typeParameterList(['E']), | 2515 AstTestFactory.typeParameterList(['E']), |
2514 AstTestFactory.formalParameterList([]))); | 2516 AstTestFactory.formalParameterList([]))); |
2515 } | 2517 } |
2516 | 2518 |
2517 void test_visitIfStatement_withElse() { | 2519 void test_visitIfStatement_withElse() { |
2518 _assertSource( | 2520 _assertSource( |
2519 "if (c) {} else {}", | 2521 "if (c) {} else {}", |
2520 AstTestFactory.ifStatement2(AstTestFactory.identifier3("c"), | 2522 AstTestFactory.ifStatement2(AstTestFactory.identifier3("c"), |
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4323 [AstTestFactory.simpleFormalParameter3("b")]))); | 4325 [AstTestFactory.simpleFormalParameter3("b")]))); |
4324 } | 4326 } |
4325 | 4327 |
4326 void test_visitFieldFormalParameter_functionTyped_typeParameters() { | 4328 void test_visitFieldFormalParameter_functionTyped_typeParameters() { |
4327 _assertSource( | 4329 _assertSource( |
4328 "A this.a<E, F>(b)", | 4330 "A this.a<E, F>(b)", |
4329 astFactory.fieldFormalParameter( | 4331 astFactory.fieldFormalParameter( |
4330 null, | 4332 null, |
4331 null, | 4333 null, |
4332 null, | 4334 null, |
| 4335 null, |
4333 AstTestFactory.typeName4('A'), | 4336 AstTestFactory.typeName4('A'), |
4334 TokenFactory.tokenFromKeyword(Keyword.THIS), | 4337 TokenFactory.tokenFromKeyword(Keyword.THIS), |
4335 TokenFactory.tokenFromType(TokenType.PERIOD), | 4338 TokenFactory.tokenFromType(TokenType.PERIOD), |
4336 AstTestFactory.identifier3('a'), | 4339 AstTestFactory.identifier3('a'), |
4337 AstTestFactory.typeParameterList(['E', 'F']), | 4340 AstTestFactory.typeParameterList(['E', 'F']), |
4338 AstTestFactory.formalParameterList( | 4341 AstTestFactory.formalParameterList( |
4339 [AstTestFactory.simpleFormalParameter3("b")]))); | 4342 [AstTestFactory.simpleFormalParameter3("b")]))); |
4340 } | 4343 } |
4341 | 4344 |
4342 void test_visitFieldFormalParameter_keyword() { | 4345 void test_visitFieldFormalParameter_keyword() { |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4855 TokenFactory.tokenFromKeyword(Keyword.COVARIANT); | 4858 TokenFactory.tokenFromKeyword(Keyword.COVARIANT); |
4856 _assertSource("covariant T f()", expected); | 4859 _assertSource("covariant T f()", expected); |
4857 } | 4860 } |
4858 | 4861 |
4859 void test_visitFunctionTypedFormalParameter_typeParameters() { | 4862 void test_visitFunctionTypedFormalParameter_typeParameters() { |
4860 _assertSource( | 4863 _assertSource( |
4861 "T f<E>()", | 4864 "T f<E>()", |
4862 astFactory.functionTypedFormalParameter( | 4865 astFactory.functionTypedFormalParameter( |
4863 null, | 4866 null, |
4864 null, | 4867 null, |
| 4868 null, |
4865 AstTestFactory.typeName4("T"), | 4869 AstTestFactory.typeName4("T"), |
4866 AstTestFactory.identifier3('f'), | 4870 AstTestFactory.identifier3('f'), |
4867 AstTestFactory.typeParameterList(['E']), | 4871 AstTestFactory.typeParameterList(['E']), |
4868 AstTestFactory.formalParameterList([]))); | 4872 AstTestFactory.formalParameterList([]))); |
4869 } | 4873 } |
4870 | 4874 |
4871 void test_visitIfStatement_withElse() { | 4875 void test_visitIfStatement_withElse() { |
4872 _assertSource( | 4876 _assertSource( |
4873 "if (c) {} else {}", | 4877 "if (c) {} else {}", |
4874 AstTestFactory.ifStatement2(AstTestFactory.identifier3("c"), | 4878 AstTestFactory.ifStatement2(AstTestFactory.identifier3("c"), |
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5840 /** | 5844 /** |
5841 * Assert that a `ToSourceVisitor` will produce the [expectedSource] when | 5845 * Assert that a `ToSourceVisitor` will produce the [expectedSource] when |
5842 * visiting the given [node]. | 5846 * visiting the given [node]. |
5843 */ | 5847 */ |
5844 void _assertSource(String expectedSource, AstNode node) { | 5848 void _assertSource(String expectedSource, AstNode node) { |
5845 PrintStringWriter writer = new PrintStringWriter(); | 5849 PrintStringWriter writer = new PrintStringWriter(); |
5846 node.accept(new ToSourceVisitor(writer)); | 5850 node.accept(new ToSourceVisitor(writer)); |
5847 expect(writer.toString(), expectedSource); | 5851 expect(writer.toString(), expectedSource); |
5848 } | 5852 } |
5849 } | 5853 } |
OLD | NEW |