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.generated.utilities_test; | 5 library analyzer.test.generated.utilities_test; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/src/dart/ast/utilities.dart'; |
10 import 'package:analyzer/src/generated/java_core.dart'; | 11 import 'package:analyzer/src/generated/java_core.dart'; |
11 import 'package:analyzer/src/generated/java_engine.dart'; | 12 import 'package:analyzer/src/generated/java_engine.dart'; |
12 import 'package:analyzer/src/generated/scanner.dart'; | 13 import 'package:analyzer/src/generated/scanner.dart'; |
13 import 'package:analyzer/src/generated/source.dart'; | 14 import 'package:analyzer/src/generated/source.dart'; |
14 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 15 import 'package:analyzer/src/generated/testing/ast_factory.dart'; |
15 import 'package:analyzer/src/generated/testing/token_factory.dart'; | 16 import 'package:analyzer/src/generated/testing/token_factory.dart'; |
16 import 'package:analyzer/src/generated/utilities_collection.dart'; | 17 import 'package:analyzer/src/generated/utilities_collection.dart'; |
17 import 'package:unittest/unittest.dart'; | 18 import 'package:unittest/unittest.dart'; |
18 | 19 |
19 import '../reflective_tests.dart'; | 20 import '../reflective_tests.dart'; |
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1499 AstFactory.identifier3("a"), | 1500 AstFactory.identifier3("a"), |
1500 [AstFactory.block()])); | 1501 [AstFactory.block()])); |
1501 } | 1502 } |
1502 | 1503 |
1503 void test_visitSwitchCase_multipleStatements() { | 1504 void test_visitSwitchCase_multipleStatements() { |
1504 _assertClone(AstFactory.switchCase( | 1505 _assertClone(AstFactory.switchCase( |
1505 AstFactory.identifier3("a"), [AstFactory.block(), AstFactory.block()])); | 1506 AstFactory.identifier3("a"), [AstFactory.block(), AstFactory.block()])); |
1506 } | 1507 } |
1507 | 1508 |
1508 void test_visitSwitchCase_noLabels() { | 1509 void test_visitSwitchCase_noLabels() { |
1509 _assertClone(AstFactory.switchCase( | 1510 _assertClone(AstFactory |
1510 AstFactory.identifier3("a"), [AstFactory.block()])); | 1511 .switchCase(AstFactory.identifier3("a"), [AstFactory.block()])); |
1511 } | 1512 } |
1512 | 1513 |
1513 void test_visitSwitchCase_singleLabel() { | 1514 void test_visitSwitchCase_singleLabel() { |
1514 _assertClone(AstFactory.switchCase2([AstFactory.label2("l1")], | 1515 _assertClone(AstFactory.switchCase2([AstFactory.label2("l1")], |
1515 AstFactory.identifier3("a"), [AstFactory.block()])); | 1516 AstFactory.identifier3("a"), [AstFactory.block()])); |
1516 } | 1517 } |
1517 | 1518 |
1518 void test_visitSwitchDefault_multipleLabels() { | 1519 void test_visitSwitchDefault_multipleLabels() { |
1519 _assertClone(AstFactory.switchDefault( | 1520 _assertClone(AstFactory.switchDefault( |
1520 [AstFactory.label2("l1"), AstFactory.label2("l2")], | 1521 [AstFactory.label2("l1"), AstFactory.label2("l2")], |
1521 [AstFactory.block()])); | 1522 [AstFactory.block()])); |
1522 } | 1523 } |
1523 | 1524 |
1524 void test_visitSwitchDefault_multipleStatements() { | 1525 void test_visitSwitchDefault_multipleStatements() { |
1525 _assertClone( | 1526 _assertClone( |
1526 AstFactory.switchDefault2([AstFactory.block(), AstFactory.block()])); | 1527 AstFactory.switchDefault2([AstFactory.block(), AstFactory.block()])); |
1527 } | 1528 } |
1528 | 1529 |
1529 void test_visitSwitchDefault_noLabels() { | 1530 void test_visitSwitchDefault_noLabels() { |
1530 _assertClone(AstFactory.switchDefault2([AstFactory.block()])); | 1531 _assertClone(AstFactory.switchDefault2([AstFactory.block()])); |
1531 } | 1532 } |
1532 | 1533 |
1533 void test_visitSwitchDefault_singleLabel() { | 1534 void test_visitSwitchDefault_singleLabel() { |
1534 _assertClone(AstFactory.switchDefault( | 1535 _assertClone(AstFactory |
1535 [AstFactory.label2("l1")], [AstFactory.block()])); | 1536 .switchDefault([AstFactory.label2("l1")], [AstFactory.block()])); |
1536 } | 1537 } |
1537 | 1538 |
1538 void test_visitSwitchStatement() { | 1539 void test_visitSwitchStatement() { |
1539 _assertClone(AstFactory.switchStatement(AstFactory.identifier3("a"), [ | 1540 _assertClone(AstFactory.switchStatement(AstFactory.identifier3("a"), [ |
1540 AstFactory.switchCase(AstFactory.string2("b"), [AstFactory.block()]), | 1541 AstFactory.switchCase(AstFactory.string2("b"), [AstFactory.block()]), |
1541 AstFactory.switchDefault2([AstFactory.block()]) | 1542 AstFactory.switchDefault2([AstFactory.block()]) |
1542 ])); | 1543 ])); |
1543 } | 1544 } |
1544 | 1545 |
1545 void test_visitSymbolLiteral_multiple() { | 1546 void test_visitSymbolLiteral_multiple() { |
(...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3527 } | 3528 } |
3528 | 3529 |
3529 void test_classDeclaration() { | 3530 void test_classDeclaration() { |
3530 ClassDeclaration node = AstFactory.classDeclaration( | 3531 ClassDeclaration node = AstFactory.classDeclaration( |
3531 null, | 3532 null, |
3532 "A", | 3533 "A", |
3533 AstFactory.typeParameterList(["E"]), | 3534 AstFactory.typeParameterList(["E"]), |
3534 AstFactory.extendsClause(AstFactory.typeName4("B")), | 3535 AstFactory.extendsClause(AstFactory.typeName4("B")), |
3535 AstFactory.withClause([AstFactory.typeName4("C")]), | 3536 AstFactory.withClause([AstFactory.typeName4("C")]), |
3536 AstFactory.implementsClause([AstFactory.typeName4("D")]), [ | 3537 AstFactory.implementsClause([AstFactory.typeName4("D")]), [ |
3537 AstFactory.fieldDeclaration2( | 3538 AstFactory |
3538 false, null, [AstFactory.variableDeclaration("f")]) | 3539 .fieldDeclaration2(false, null, [AstFactory.variableDeclaration("f")]) |
3539 ]); | 3540 ]); |
3540 node.documentationComment = | 3541 node.documentationComment = |
3541 Comment.createEndOfLineComment(EMPTY_TOKEN_LIST); | 3542 Comment.createEndOfLineComment(EMPTY_TOKEN_LIST); |
3542 node.metadata.add(AstFactory.annotation(AstFactory.identifier3("a"))); | 3543 node.metadata.add(AstFactory.annotation(AstFactory.identifier3("a"))); |
3543 node.nativeClause = AstFactory.nativeClause(""); | 3544 node.nativeClause = AstFactory.nativeClause(""); |
3544 _assertReplace(node, new Getter_NodeReplacerTest_test_classDeclaration_6()); | 3545 _assertReplace(node, new Getter_NodeReplacerTest_test_classDeclaration_6()); |
3545 _assertReplace(node, new Getter_NodeReplacerTest_test_classDeclaration_5()); | 3546 _assertReplace(node, new Getter_NodeReplacerTest_test_classDeclaration_5()); |
3546 _assertReplace(node, new Getter_NodeReplacerTest_test_classDeclaration_4()); | 3547 _assertReplace(node, new Getter_NodeReplacerTest_test_classDeclaration_4()); |
3547 _assertReplace(node, new Getter_NodeReplacerTest_test_classDeclaration_2()); | 3548 _assertReplace(node, new Getter_NodeReplacerTest_test_classDeclaration_2()); |
3548 _assertReplace(node, new Getter_NodeReplacerTest_test_classDeclaration()); | 3549 _assertReplace(node, new Getter_NodeReplacerTest_test_classDeclaration()); |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3974 _assertReplace(node, new Getter_NodeReplacerTest_test_isExpression()); | 3975 _assertReplace(node, new Getter_NodeReplacerTest_test_isExpression()); |
3975 _assertReplace(node, new Getter_NodeReplacerTest_test_isExpression_2()); | 3976 _assertReplace(node, new Getter_NodeReplacerTest_test_isExpression_2()); |
3976 } | 3977 } |
3977 | 3978 |
3978 void test_label() { | 3979 void test_label() { |
3979 Label node = AstFactory.label2("l"); | 3980 Label node = AstFactory.label2("l"); |
3980 _assertReplace(node, new Getter_NodeReplacerTest_test_label()); | 3981 _assertReplace(node, new Getter_NodeReplacerTest_test_label()); |
3981 } | 3982 } |
3982 | 3983 |
3983 void test_labeledStatement() { | 3984 void test_labeledStatement() { |
3984 LabeledStatement node = AstFactory.labeledStatement( | 3985 LabeledStatement node = AstFactory |
3985 [AstFactory.label2("l")], AstFactory.block()); | 3986 .labeledStatement([AstFactory.label2("l")], AstFactory.block()); |
3986 _assertReplace( | 3987 _assertReplace( |
3987 node, new ListGetter_NodeReplacerTest_test_labeledStatement(0)); | 3988 node, new ListGetter_NodeReplacerTest_test_labeledStatement(0)); |
3988 _assertReplace(node, new Getter_NodeReplacerTest_test_labeledStatement()); | 3989 _assertReplace(node, new Getter_NodeReplacerTest_test_labeledStatement()); |
3989 } | 3990 } |
3990 | 3991 |
3991 void test_libraryDirective() { | 3992 void test_libraryDirective() { |
3992 LibraryDirective node = AstFactory.libraryDirective2("lib"); | 3993 LibraryDirective node = AstFactory.libraryDirective2("lib"); |
3993 node.documentationComment = | 3994 node.documentationComment = |
3994 Comment.createEndOfLineComment(EMPTY_TOKEN_LIST); | 3995 Comment.createEndOfLineComment(EMPTY_TOKEN_LIST); |
3995 node.metadata.add(AstFactory.annotation(AstFactory.identifier3("a"))); | 3996 node.metadata.add(AstFactory.annotation(AstFactory.identifier3("a"))); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4174 } | 4175 } |
4175 | 4176 |
4176 void test_switchCase() { | 4177 void test_switchCase() { |
4177 SwitchCase node = AstFactory.switchCase2( | 4178 SwitchCase node = AstFactory.switchCase2( |
4178 [AstFactory.label2("l")], AstFactory.integer(0), [AstFactory.block()]); | 4179 [AstFactory.label2("l")], AstFactory.integer(0), [AstFactory.block()]); |
4179 _assertReplace(node, new Getter_NodeReplacerTest_test_switchCase()); | 4180 _assertReplace(node, new Getter_NodeReplacerTest_test_switchCase()); |
4180 _testSwitchMember(node); | 4181 _testSwitchMember(node); |
4181 } | 4182 } |
4182 | 4183 |
4183 void test_switchDefault() { | 4184 void test_switchDefault() { |
4184 SwitchDefault node = AstFactory.switchDefault( | 4185 SwitchDefault node = AstFactory |
4185 [AstFactory.label2("l")], [AstFactory.block()]); | 4186 .switchDefault([AstFactory.label2("l")], [AstFactory.block()]); |
4186 _testSwitchMember(node); | 4187 _testSwitchMember(node); |
4187 } | 4188 } |
4188 | 4189 |
4189 void test_switchStatement() { | 4190 void test_switchStatement() { |
4190 SwitchStatement node = | 4191 SwitchStatement node = |
4191 AstFactory.switchStatement(AstFactory.identifier3("x"), [ | 4192 AstFactory.switchStatement(AstFactory.identifier3("x"), [ |
4192 AstFactory.switchCase2([AstFactory.label2("l")], AstFactory.integer(0), | 4193 AstFactory.switchCase2([AstFactory.label2("l")], AstFactory.integer(0), |
4193 [AstFactory.block()]), | 4194 [AstFactory.block()]), |
4194 AstFactory.switchDefault([AstFactory.label2("l")], [AstFactory.block()]) | 4195 AstFactory.switchDefault([AstFactory.label2("l")], [AstFactory.block()]) |
4195 ]); | 4196 ]); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4228 } | 4229 } |
4229 | 4230 |
4230 void test_typeArgumentList() { | 4231 void test_typeArgumentList() { |
4231 TypeArgumentList node = | 4232 TypeArgumentList node = |
4232 AstFactory.typeArgumentList([AstFactory.typeName4("A")]); | 4233 AstFactory.typeArgumentList([AstFactory.typeName4("A")]); |
4233 _assertReplace( | 4234 _assertReplace( |
4234 node, new ListGetter_NodeReplacerTest_test_typeArgumentList(0)); | 4235 node, new ListGetter_NodeReplacerTest_test_typeArgumentList(0)); |
4235 } | 4236 } |
4236 | 4237 |
4237 void test_typeName() { | 4238 void test_typeName() { |
4238 TypeName node = AstFactory.typeName4( | 4239 TypeName node = AstFactory |
4239 "T", [AstFactory.typeName4("E"), AstFactory.typeName4("F")]); | 4240 .typeName4("T", [AstFactory.typeName4("E"), AstFactory.typeName4("F")]); |
4240 _assertReplace(node, new Getter_NodeReplacerTest_test_typeName_2()); | 4241 _assertReplace(node, new Getter_NodeReplacerTest_test_typeName_2()); |
4241 _assertReplace(node, new Getter_NodeReplacerTest_test_typeName()); | 4242 _assertReplace(node, new Getter_NodeReplacerTest_test_typeName()); |
4242 } | 4243 } |
4243 | 4244 |
4244 void test_typeParameter() { | 4245 void test_typeParameter() { |
4245 TypeParameter node = | 4246 TypeParameter node = |
4246 AstFactory.typeParameter2("E", AstFactory.typeName4("B")); | 4247 AstFactory.typeParameter2("E", AstFactory.typeName4("B")); |
4247 _assertReplace(node, new Getter_NodeReplacerTest_test_typeParameter_2()); | 4248 _assertReplace(node, new Getter_NodeReplacerTest_test_typeParameter_2()); |
4248 _assertReplace(node, new Getter_NodeReplacerTest_test_typeParameter()); | 4249 _assertReplace(node, new Getter_NodeReplacerTest_test_typeParameter()); |
4249 } | 4250 } |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4850 } | 4851 } |
4851 | 4852 |
4852 void test_get_added() { | 4853 void test_get_added() { |
4853 TokenMap tokenMap = new TokenMap(); | 4854 TokenMap tokenMap = new TokenMap(); |
4854 Token key = TokenFactory.tokenFromType(TokenType.AT); | 4855 Token key = TokenFactory.tokenFromType(TokenType.AT); |
4855 Token value = TokenFactory.tokenFromType(TokenType.AT); | 4856 Token value = TokenFactory.tokenFromType(TokenType.AT); |
4856 tokenMap.put(key, value); | 4857 tokenMap.put(key, value); |
4857 expect(tokenMap.get(key), same(value)); | 4858 expect(tokenMap.get(key), same(value)); |
4858 } | 4859 } |
4859 } | 4860 } |
OLD | NEW |