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