| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.ast_test; | 8 library engine.ast_test; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/java_core.dart'; | 10 import 'package:analyzer/src/generated/java_core.dart'; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 return q() + 4; | 71 return q() + 4; |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 A f(var p) { | 74 A f(var p) { |
| 75 if ((p as A).g) { | 75 if ((p as A).g) { |
| 76 return p; | 76 return p; |
| 77 } else { | 77 } else { |
| 78 return null; | 78 return null; |
| 79 } | 79 } |
| 80 }'''; | 80 }'''; |
| 81 CompilationUnit unit = ParserTestCase.parseCompilationUnit(source, []); | 81 CompilationUnit unit = ParserTestCase.parseCompilationUnit(source); |
| 82 List<AstNode> nodes = new List<AstNode>(); | 82 List<AstNode> nodes = new List<AstNode>(); |
| 83 BreadthFirstVisitor<Object> visitor = new BreadthFirstVisitor_BreadthFirstVi
sitorTest_testIt(nodes); | 83 BreadthFirstVisitor<Object> visitor = new BreadthFirstVisitor_BreadthFirstVi
sitorTest_testIt(nodes); |
| 84 visitor.visitAllNodes(unit); | 84 visitor.visitAllNodes(unit); |
| 85 expect(nodes, hasLength(59)); | 85 expect(nodes, hasLength(59)); |
| 86 EngineTestCase.assertInstanceOf((obj) => obj is CompilationUnit, Compilation
Unit, nodes[0]); | 86 EngineTestCase.assertInstanceOf((obj) => obj is CompilationUnit, Compilation
Unit, nodes[0]); |
| 87 EngineTestCase.assertInstanceOf((obj) => obj is ClassDeclaration, ClassDecla
ration, nodes[2]); | 87 EngineTestCase.assertInstanceOf((obj) => obj is ClassDeclaration, ClassDecla
ration, nodes[2]); |
| 88 EngineTestCase.assertInstanceOf((obj) => obj is FunctionDeclaration, Functio
nDeclaration, nodes[3]); | 88 EngineTestCase.assertInstanceOf((obj) => obj is FunctionDeclaration, Functio
nDeclaration, nodes[3]); |
| 89 EngineTestCase.assertInstanceOf((obj) => obj is FunctionDeclarationStatement
, FunctionDeclarationStatement, nodes[27]); | 89 EngineTestCase.assertInstanceOf((obj) => obj is FunctionDeclarationStatement
, FunctionDeclarationStatement, nodes[27]); |
| 90 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, IntegerLiter
al, nodes[58]); | 90 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, IntegerLiter
al, nodes[58]); |
| 91 //3 | 91 //3 |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 class BreadthFirstVisitor_BreadthFirstVisitorTest_testIt extends BreadthFirstVis
itor<Object> { | 95 class BreadthFirstVisitor_BreadthFirstVisitorTest_testIt extends BreadthFirstVis
itor<Object> { |
| 96 List<AstNode> nodes; | 96 List<AstNode> nodes; |
| 97 | 97 |
| 98 BreadthFirstVisitor_BreadthFirstVisitorTest_testIt(this.nodes) : super(); | 98 BreadthFirstVisitor_BreadthFirstVisitorTest_testIt(this.nodes) : super(); |
| 99 | 99 |
| 100 @override | 100 @override |
| 101 Object visitNode(AstNode node) { | 101 Object visitNode(AstNode node) { |
| 102 nodes.add(node); | 102 nodes.add(node); |
| 103 return super.visitNode(node); | 103 return super.visitNode(node); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 class ClassDeclarationTest extends ParserTestCase { | 107 class ClassDeclarationTest extends ParserTestCase { |
| 108 void test_getConstructor() { | 108 void test_getConstructor() { |
| 109 List<ConstructorInitializer> initializers = new List<ConstructorInitializer>
(); | 109 List<ConstructorInitializer> initializers = new List<ConstructorInitializer>
(); |
| 110 ConstructorDeclaration defaultConstructor = AstFactory.constructorDeclaratio
n(AstFactory.identifier3("Test"), null, AstFactory.formalParameterList([]), init
ializers); | 110 ConstructorDeclaration defaultConstructor = AstFactory.constructorDeclaratio
n(AstFactory.identifier3("Test"), null, AstFactory.formalParameterList(), initia
lizers); |
| 111 ConstructorDeclaration aConstructor = AstFactory.constructorDeclaration(AstF
actory.identifier3("Test"), "a", AstFactory.formalParameterList([]), initializer
s); | 111 ConstructorDeclaration aConstructor = AstFactory.constructorDeclaration(AstF
actory.identifier3("Test"), "a", AstFactory.formalParameterList(), initializers)
; |
| 112 ConstructorDeclaration bConstructor = AstFactory.constructorDeclaration(AstF
actory.identifier3("Test"), "b", AstFactory.formalParameterList([]), initializer
s); | 112 ConstructorDeclaration bConstructor = AstFactory.constructorDeclaration(AstF
actory.identifier3("Test"), "b", AstFactory.formalParameterList(), initializers)
; |
| 113 ClassDeclaration clazz = AstFactory.classDeclaration(null, "Test", null, nul
l, null, null, [defaultConstructor, aConstructor, bConstructor]); | 113 ClassDeclaration clazz = AstFactory.classDeclaration(null, "Test", null, nul
l, null, null, [defaultConstructor, aConstructor, bConstructor]); |
| 114 expect(clazz.getConstructor(null), same(defaultConstructor)); | 114 expect(clazz.getConstructor(null), same(defaultConstructor)); |
| 115 expect(clazz.getConstructor("a"), same(aConstructor)); | 115 expect(clazz.getConstructor("a"), same(aConstructor)); |
| 116 expect(clazz.getConstructor("b"), same(bConstructor)); | 116 expect(clazz.getConstructor("b"), same(bConstructor)); |
| 117 expect(clazz.getConstructor("noSuchConstructor"), same(null)); | 117 expect(clazz.getConstructor("noSuchConstructor"), same(null)); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void test_getField() { | 120 void test_getField() { |
| 121 VariableDeclaration aVar = AstFactory.variableDeclaration("a"); | 121 VariableDeclaration aVar = AstFactory.variableDeclaration("a"); |
| 122 VariableDeclaration bVar = AstFactory.variableDeclaration("b"); | 122 VariableDeclaration bVar = AstFactory.variableDeclaration("b"); |
| 123 VariableDeclaration cVar = AstFactory.variableDeclaration("c"); | 123 VariableDeclaration cVar = AstFactory.variableDeclaration("c"); |
| 124 ClassDeclaration clazz = AstFactory.classDeclaration(null, "Test", null, nul
l, null, null, [ | 124 ClassDeclaration clazz = AstFactory.classDeclaration(null, "Test", null, nul
l, null, null, [ |
| 125 AstFactory.fieldDeclaration2(false, null, [aVar]), | 125 AstFactory.fieldDeclaration2(false, null, [aVar]), |
| 126 AstFactory.fieldDeclaration2(false, null, [bVar, cVar])]); | 126 AstFactory.fieldDeclaration2(false, null, [bVar, cVar])]); |
| 127 expect(clazz.getField("a"), same(aVar)); | 127 expect(clazz.getField("a"), same(aVar)); |
| 128 expect(clazz.getField("b"), same(bVar)); | 128 expect(clazz.getField("b"), same(bVar)); |
| 129 expect(clazz.getField("c"), same(cVar)); | 129 expect(clazz.getField("c"), same(cVar)); |
| 130 expect(clazz.getField("noSuchField"), same(null)); | 130 expect(clazz.getField("noSuchField"), same(null)); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void test_getMethod() { | 133 void test_getMethod() { |
| 134 MethodDeclaration aMethod = AstFactory.methodDeclaration(null, null, null, n
ull, AstFactory.identifier3("a"), AstFactory.formalParameterList([])); | 134 MethodDeclaration aMethod = AstFactory.methodDeclaration(null, null, null, n
ull, AstFactory.identifier3("a"), AstFactory.formalParameterList()); |
| 135 MethodDeclaration bMethod = AstFactory.methodDeclaration(null, null, null, n
ull, AstFactory.identifier3("b"), AstFactory.formalParameterList([])); | 135 MethodDeclaration bMethod = AstFactory.methodDeclaration(null, null, null, n
ull, AstFactory.identifier3("b"), AstFactory.formalParameterList()); |
| 136 ClassDeclaration clazz = AstFactory.classDeclaration(null, "Test", null, nul
l, null, null, [aMethod, bMethod]); | 136 ClassDeclaration clazz = AstFactory.classDeclaration(null, "Test", null, nul
l, null, null, [aMethod, bMethod]); |
| 137 expect(clazz.getMethod("a"), same(aMethod)); | 137 expect(clazz.getMethod("a"), same(aMethod)); |
| 138 expect(clazz.getMethod("b"), same(bMethod)); | 138 expect(clazz.getMethod("b"), same(bMethod)); |
| 139 expect(clazz.getMethod("noSuchMethod"), same(null)); | 139 expect(clazz.getMethod("noSuchMethod"), same(null)); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void test_isAbstract() { | 142 void test_isAbstract() { |
| 143 expect(AstFactory.classDeclaration(null, "A", null, null, null, null, []).is
Abstract, isFalse); | 143 expect(AstFactory.classDeclaration(null, "A", null, null, null, null).isAbst
ract, isFalse); |
| 144 expect(AstFactory.classDeclaration(Keyword.ABSTRACT, "B", null, null, null,
null, []).isAbstract, isTrue); | 144 expect(AstFactory.classDeclaration(Keyword.ABSTRACT, "B", null, null, null,
null).isAbstract, isTrue); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 class ClassTypeAliasTest extends ParserTestCase { | 148 class ClassTypeAliasTest extends ParserTestCase { |
| 149 void test_isAbstract() { | 149 void test_isAbstract() { |
| 150 expect(AstFactory.classTypeAlias("A", null, null, null, null, null).isAbstra
ct, isFalse); | 150 expect(AstFactory.classTypeAlias("A", null, null, null, null, null).isAbstra
ct, isFalse); |
| 151 expect(AstFactory.classTypeAlias("B", null, Keyword.ABSTRACT, null, null, nu
ll).isAbstract, isTrue); | 151 expect(AstFactory.classTypeAlias("B", null, Keyword.ABSTRACT, null, null, nu
ll).isAbstract, isTrue); |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 | 154 |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value); | 458 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value); |
| 459 expect(value as double, -42.3); | 459 expect(value as double, -42.3); |
| 460 } | 460 } |
| 461 | 461 |
| 462 void test_unary_negated_integer() { | 462 void test_unary_negated_integer() { |
| 463 Object value = _getConstantValue("-42"); | 463 Object value = _getConstantValue("-42"); |
| 464 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); | 464 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); |
| 465 expect(value as int, -42); | 465 expect(value as int, -42); |
| 466 } | 466 } |
| 467 | 467 |
| 468 Object _getConstantValue(String source) => ParserTestCase.parseExpression(sour
ce, []).accept(new ConstantEvaluator()); | 468 Object _getConstantValue(String source) => ParserTestCase.parseExpression(sour
ce).accept(new ConstantEvaluator()); |
| 469 } | 469 } |
| 470 | 470 |
| 471 class IndexExpressionTest extends EngineTestCase { | 471 class IndexExpressionTest extends EngineTestCase { |
| 472 void test_inGetterContext_assignment_compound_left() { | 472 void test_inGetterContext_assignment_compound_left() { |
| 473 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie
r3("a"), AstFactory.identifier3("b")); | 473 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie
r3("a"), AstFactory.identifier3("b")); |
| 474 // a[b] += c | 474 // a[b] += c |
| 475 AstFactory.assignmentExpression(expression, TokenType.PLUS_EQ, AstFactory.id
entifier3("c")); | 475 AstFactory.assignmentExpression(expression, TokenType.PLUS_EQ, AstFactory.id
entifier3("c")); |
| 476 expect(expression.inGetterContext(), isTrue); | 476 expect(expression.inGetterContext(), isTrue); |
| 477 } | 477 } |
| 478 | 478 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 void test_inSetterContext_prefix_plusPlus() { | 549 void test_inSetterContext_prefix_plusPlus() { |
| 550 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie
r3("a"), AstFactory.identifier3("b")); | 550 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie
r3("a"), AstFactory.identifier3("b")); |
| 551 // ++a[b] | 551 // ++a[b] |
| 552 AstFactory.prefixExpression(TokenType.PLUS_PLUS, expression); | 552 AstFactory.prefixExpression(TokenType.PLUS_PLUS, expression); |
| 553 expect(expression.inSetterContext(), isTrue); | 553 expect(expression.inSetterContext(), isTrue); |
| 554 } | 554 } |
| 555 } | 555 } |
| 556 | 556 |
| 557 class NodeListTest extends EngineTestCase { | 557 class NodeListTest extends EngineTestCase { |
| 558 void test_add() { | 558 void test_add() { |
| 559 AstNode parent = AstFactory.argumentList([]); | 559 AstNode parent = AstFactory.argumentList(); |
| 560 AstNode firstNode = AstFactory.booleanLiteral(true); | 560 AstNode firstNode = AstFactory.booleanLiteral(true); |
| 561 AstNode secondNode = AstFactory.booleanLiteral(false); | 561 AstNode secondNode = AstFactory.booleanLiteral(false); |
| 562 NodeList<AstNode> list = new NodeList<AstNode>(parent); | 562 NodeList<AstNode> list = new NodeList<AstNode>(parent); |
| 563 list.insert(0, secondNode); | 563 list.insert(0, secondNode); |
| 564 list.insert(0, firstNode); | 564 list.insert(0, firstNode); |
| 565 expect(list, hasLength(2)); | 565 expect(list, hasLength(2)); |
| 566 expect(list[0], same(firstNode)); | 566 expect(list[0], same(firstNode)); |
| 567 expect(list[1], same(secondNode)); | 567 expect(list[1], same(secondNode)); |
| 568 expect(firstNode.parent, same(parent)); | 568 expect(firstNode.parent, same(parent)); |
| 569 expect(secondNode.parent, same(parent)); | 569 expect(secondNode.parent, same(parent)); |
| 570 AstNode thirdNode = AstFactory.booleanLiteral(false); | 570 AstNode thirdNode = AstFactory.booleanLiteral(false); |
| 571 list.insert(1, thirdNode); | 571 list.insert(1, thirdNode); |
| 572 expect(list, hasLength(3)); | 572 expect(list, hasLength(3)); |
| 573 expect(list[0], same(firstNode)); | 573 expect(list[0], same(firstNode)); |
| 574 expect(list[1], same(thirdNode)); | 574 expect(list[1], same(thirdNode)); |
| 575 expect(list[2], same(secondNode)); | 575 expect(list[2], same(secondNode)); |
| 576 expect(firstNode.parent, same(parent)); | 576 expect(firstNode.parent, same(parent)); |
| 577 expect(secondNode.parent, same(parent)); | 577 expect(secondNode.parent, same(parent)); |
| 578 expect(thirdNode.parent, same(parent)); | 578 expect(thirdNode.parent, same(parent)); |
| 579 } | 579 } |
| 580 | 580 |
| 581 void test_add_negative() { | 581 void test_add_negative() { |
| 582 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); | 582 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); |
| 583 try { | 583 try { |
| 584 list.insert(-1, AstFactory.booleanLiteral(true)); | 584 list.insert(-1, AstFactory.booleanLiteral(true)); |
| 585 fail("Expected IndexOutOfBoundsException"); | 585 fail("Expected IndexOutOfBoundsException"); |
| 586 } on RangeError catch (exception) { | 586 } on RangeError catch (exception) { |
| 587 // Expected | 587 // Expected |
| 588 } | 588 } |
| 589 } | 589 } |
| 590 | 590 |
| 591 void test_add_tooBig() { | 591 void test_add_tooBig() { |
| 592 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); | 592 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); |
| 593 try { | 593 try { |
| 594 list.insert(1, AstFactory.booleanLiteral(true)); | 594 list.insert(1, AstFactory.booleanLiteral(true)); |
| 595 fail("Expected IndexOutOfBoundsException"); | 595 fail("Expected IndexOutOfBoundsException"); |
| 596 } on RangeError catch (exception) { | 596 } on RangeError catch (exception) { |
| 597 // Expected | 597 // Expected |
| 598 } | 598 } |
| 599 } | 599 } |
| 600 | 600 |
| 601 void test_addAll() { | 601 void test_addAll() { |
| 602 AstNode parent = AstFactory.argumentList([]); | 602 AstNode parent = AstFactory.argumentList(); |
| 603 List<AstNode> firstNodes = new List<AstNode>(); | 603 List<AstNode> firstNodes = new List<AstNode>(); |
| 604 AstNode firstNode = AstFactory.booleanLiteral(true); | 604 AstNode firstNode = AstFactory.booleanLiteral(true); |
| 605 AstNode secondNode = AstFactory.booleanLiteral(false); | 605 AstNode secondNode = AstFactory.booleanLiteral(false); |
| 606 firstNodes.add(firstNode); | 606 firstNodes.add(firstNode); |
| 607 firstNodes.add(secondNode); | 607 firstNodes.add(secondNode); |
| 608 NodeList<AstNode> list = new NodeList<AstNode>(parent); | 608 NodeList<AstNode> list = new NodeList<AstNode>(parent); |
| 609 list.addAll(firstNodes); | 609 list.addAll(firstNodes); |
| 610 expect(list, hasLength(2)); | 610 expect(list, hasLength(2)); |
| 611 expect(list[0], same(firstNode)); | 611 expect(list[0], same(firstNode)); |
| 612 expect(list[1], same(secondNode)); | 612 expect(list[1], same(secondNode)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 623 expect(list[1], same(secondNode)); | 623 expect(list[1], same(secondNode)); |
| 624 expect(list[2], same(thirdNode)); | 624 expect(list[2], same(thirdNode)); |
| 625 expect(list[3], same(fourthNode)); | 625 expect(list[3], same(fourthNode)); |
| 626 expect(firstNode.parent, same(parent)); | 626 expect(firstNode.parent, same(parent)); |
| 627 expect(secondNode.parent, same(parent)); | 627 expect(secondNode.parent, same(parent)); |
| 628 expect(thirdNode.parent, same(parent)); | 628 expect(thirdNode.parent, same(parent)); |
| 629 expect(fourthNode.parent, same(parent)); | 629 expect(fourthNode.parent, same(parent)); |
| 630 } | 630 } |
| 631 | 631 |
| 632 void test_create() { | 632 void test_create() { |
| 633 AstNode owner = AstFactory.argumentList([]); | 633 AstNode owner = AstFactory.argumentList(); |
| 634 NodeList<AstNode> list = NodeList.create(owner); | 634 NodeList<AstNode> list = NodeList.create(owner); |
| 635 expect(list, isNotNull); | 635 expect(list, isNotNull); |
| 636 expect(list, hasLength(0)); | 636 expect(list, hasLength(0)); |
| 637 expect(list.owner, same(owner)); | 637 expect(list.owner, same(owner)); |
| 638 } | 638 } |
| 639 | 639 |
| 640 void test_creation() { | 640 void test_creation() { |
| 641 AstNode owner = AstFactory.argumentList([]); | 641 AstNode owner = AstFactory.argumentList(); |
| 642 NodeList<AstNode> list = new NodeList<AstNode>(owner); | 642 NodeList<AstNode> list = new NodeList<AstNode>(owner); |
| 643 expect(list, isNotNull); | 643 expect(list, isNotNull); |
| 644 expect(list, hasLength(0)); | 644 expect(list, hasLength(0)); |
| 645 expect(list.owner, same(owner)); | 645 expect(list.owner, same(owner)); |
| 646 } | 646 } |
| 647 | 647 |
| 648 void test_get_negative() { | 648 void test_get_negative() { |
| 649 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); | 649 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); |
| 650 try { | 650 try { |
| 651 list[-1]; | 651 list[-1]; |
| 652 fail("Expected IndexOutOfBoundsException"); | 652 fail("Expected IndexOutOfBoundsException"); |
| 653 } on RangeError catch (exception) { | 653 } on RangeError catch (exception) { |
| 654 // Expected | 654 // Expected |
| 655 } | 655 } |
| 656 } | 656 } |
| 657 | 657 |
| 658 void test_get_tooBig() { | 658 void test_get_tooBig() { |
| 659 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); | 659 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); |
| 660 try { | 660 try { |
| 661 list[1]; | 661 list[1]; |
| 662 fail("Expected IndexOutOfBoundsException"); | 662 fail("Expected IndexOutOfBoundsException"); |
| 663 } on RangeError catch (exception) { | 663 } on RangeError catch (exception) { |
| 664 // Expected | 664 // Expected |
| 665 } | 665 } |
| 666 } | 666 } |
| 667 | 667 |
| 668 void test_getBeginToken_empty() { | 668 void test_getBeginToken_empty() { |
| 669 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); | 669 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); |
| 670 expect(list.beginToken, isNull); | 670 expect(list.beginToken, isNull); |
| 671 } | 671 } |
| 672 | 672 |
| 673 void test_getBeginToken_nonEmpty() { | 673 void test_getBeginToken_nonEmpty() { |
| 674 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); | 674 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); |
| 675 AstNode node = AstFactory.parenthesizedExpression(AstFactory.booleanLiteral(
true)); | 675 AstNode node = AstFactory.parenthesizedExpression(AstFactory.booleanLiteral(
true)); |
| 676 list.add(node); | 676 list.add(node); |
| 677 expect(list.beginToken, same(node.beginToken)); | 677 expect(list.beginToken, same(node.beginToken)); |
| 678 } | 678 } |
| 679 | 679 |
| 680 void test_getEndToken_empty() { | 680 void test_getEndToken_empty() { |
| 681 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); | 681 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); |
| 682 expect(list.endToken, isNull); | 682 expect(list.endToken, isNull); |
| 683 } | 683 } |
| 684 | 684 |
| 685 void test_getEndToken_nonEmpty() { | 685 void test_getEndToken_nonEmpty() { |
| 686 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); | 686 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); |
| 687 AstNode node = AstFactory.parenthesizedExpression(AstFactory.booleanLiteral(
true)); | 687 AstNode node = AstFactory.parenthesizedExpression(AstFactory.booleanLiteral(
true)); |
| 688 list.add(node); | 688 list.add(node); |
| 689 expect(list.endToken, same(node.endToken)); | 689 expect(list.endToken, same(node.endToken)); |
| 690 } | 690 } |
| 691 | 691 |
| 692 void test_indexOf() { | 692 void test_indexOf() { |
| 693 List<AstNode> nodes = new List<AstNode>(); | 693 List<AstNode> nodes = new List<AstNode>(); |
| 694 AstNode firstNode = AstFactory.booleanLiteral(true); | 694 AstNode firstNode = AstFactory.booleanLiteral(true); |
| 695 AstNode secondNode = AstFactory.booleanLiteral(false); | 695 AstNode secondNode = AstFactory.booleanLiteral(false); |
| 696 AstNode thirdNode = AstFactory.booleanLiteral(true); | 696 AstNode thirdNode = AstFactory.booleanLiteral(true); |
| 697 AstNode fourthNode = AstFactory.booleanLiteral(false); | 697 AstNode fourthNode = AstFactory.booleanLiteral(false); |
| 698 nodes.add(firstNode); | 698 nodes.add(firstNode); |
| 699 nodes.add(secondNode); | 699 nodes.add(secondNode); |
| 700 nodes.add(thirdNode); | 700 nodes.add(thirdNode); |
| 701 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); | 701 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); |
| 702 list.addAll(nodes); | 702 list.addAll(nodes); |
| 703 expect(list, hasLength(3)); | 703 expect(list, hasLength(3)); |
| 704 expect(list.indexOf(firstNode), 0); | 704 expect(list.indexOf(firstNode), 0); |
| 705 expect(list.indexOf(secondNode), 1); | 705 expect(list.indexOf(secondNode), 1); |
| 706 expect(list.indexOf(thirdNode), 2); | 706 expect(list.indexOf(thirdNode), 2); |
| 707 expect(list.indexOf(fourthNode), -1); | 707 expect(list.indexOf(fourthNode), -1); |
| 708 expect(list.indexOf(null), -1); | 708 expect(list.indexOf(null), -1); |
| 709 } | 709 } |
| 710 | 710 |
| 711 void test_remove() { | 711 void test_remove() { |
| 712 List<AstNode> nodes = new List<AstNode>(); | 712 List<AstNode> nodes = new List<AstNode>(); |
| 713 AstNode firstNode = AstFactory.booleanLiteral(true); | 713 AstNode firstNode = AstFactory.booleanLiteral(true); |
| 714 AstNode secondNode = AstFactory.booleanLiteral(false); | 714 AstNode secondNode = AstFactory.booleanLiteral(false); |
| 715 AstNode thirdNode = AstFactory.booleanLiteral(true); | 715 AstNode thirdNode = AstFactory.booleanLiteral(true); |
| 716 nodes.add(firstNode); | 716 nodes.add(firstNode); |
| 717 nodes.add(secondNode); | 717 nodes.add(secondNode); |
| 718 nodes.add(thirdNode); | 718 nodes.add(thirdNode); |
| 719 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); | 719 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); |
| 720 list.addAll(nodes); | 720 list.addAll(nodes); |
| 721 expect(list, hasLength(3)); | 721 expect(list, hasLength(3)); |
| 722 expect(list.removeAt(1), same(secondNode)); | 722 expect(list.removeAt(1), same(secondNode)); |
| 723 expect(list, hasLength(2)); | 723 expect(list, hasLength(2)); |
| 724 expect(list[0], same(firstNode)); | 724 expect(list[0], same(firstNode)); |
| 725 expect(list[1], same(thirdNode)); | 725 expect(list[1], same(thirdNode)); |
| 726 } | 726 } |
| 727 | 727 |
| 728 void test_remove_negative() { | 728 void test_remove_negative() { |
| 729 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); | 729 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); |
| 730 try { | 730 try { |
| 731 list.removeAt(-1); | 731 list.removeAt(-1); |
| 732 fail("Expected IndexOutOfBoundsException"); | 732 fail("Expected IndexOutOfBoundsException"); |
| 733 } on RangeError catch (exception) { | 733 } on RangeError catch (exception) { |
| 734 // Expected | 734 // Expected |
| 735 } | 735 } |
| 736 } | 736 } |
| 737 | 737 |
| 738 void test_remove_tooBig() { | 738 void test_remove_tooBig() { |
| 739 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); | 739 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); |
| 740 try { | 740 try { |
| 741 list.removeAt(1); | 741 list.removeAt(1); |
| 742 fail("Expected IndexOutOfBoundsException"); | 742 fail("Expected IndexOutOfBoundsException"); |
| 743 } on RangeError catch (exception) { | 743 } on RangeError catch (exception) { |
| 744 // Expected | 744 // Expected |
| 745 } | 745 } |
| 746 } | 746 } |
| 747 | 747 |
| 748 void test_set() { | 748 void test_set() { |
| 749 List<AstNode> nodes = new List<AstNode>(); | 749 List<AstNode> nodes = new List<AstNode>(); |
| 750 AstNode firstNode = AstFactory.booleanLiteral(true); | 750 AstNode firstNode = AstFactory.booleanLiteral(true); |
| 751 AstNode secondNode = AstFactory.booleanLiteral(false); | 751 AstNode secondNode = AstFactory.booleanLiteral(false); |
| 752 AstNode thirdNode = AstFactory.booleanLiteral(true); | 752 AstNode thirdNode = AstFactory.booleanLiteral(true); |
| 753 nodes.add(firstNode); | 753 nodes.add(firstNode); |
| 754 nodes.add(secondNode); | 754 nodes.add(secondNode); |
| 755 nodes.add(thirdNode); | 755 nodes.add(thirdNode); |
| 756 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); | 756 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); |
| 757 list.addAll(nodes); | 757 list.addAll(nodes); |
| 758 expect(list, hasLength(3)); | 758 expect(list, hasLength(3)); |
| 759 AstNode fourthNode = AstFactory.integer(0); | 759 AstNode fourthNode = AstFactory.integer(0); |
| 760 expect(javaListSet(list, 1, fourthNode), same(secondNode)); | 760 expect(javaListSet(list, 1, fourthNode), same(secondNode)); |
| 761 expect(list, hasLength(3)); | 761 expect(list, hasLength(3)); |
| 762 expect(list[0], same(firstNode)); | 762 expect(list[0], same(firstNode)); |
| 763 expect(list[1], same(fourthNode)); | 763 expect(list[1], same(fourthNode)); |
| 764 expect(list[2], same(thirdNode)); | 764 expect(list[2], same(thirdNode)); |
| 765 } | 765 } |
| 766 | 766 |
| 767 void test_set_negative() { | 767 void test_set_negative() { |
| 768 AstNode node = AstFactory.booleanLiteral(true); | 768 AstNode node = AstFactory.booleanLiteral(true); |
| 769 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); | 769 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); |
| 770 try { | 770 try { |
| 771 javaListSet(list, -1, node); | 771 javaListSet(list, -1, node); |
| 772 fail("Expected IndexOutOfBoundsException"); | 772 fail("Expected IndexOutOfBoundsException"); |
| 773 } on RangeError catch (exception) { | 773 } on RangeError catch (exception) { |
| 774 // Expected | 774 // Expected |
| 775 } | 775 } |
| 776 } | 776 } |
| 777 | 777 |
| 778 void test_set_tooBig() { | 778 void test_set_tooBig() { |
| 779 AstNode node = AstFactory.booleanLiteral(true); | 779 AstNode node = AstFactory.booleanLiteral(true); |
| 780 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); | 780 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); |
| 781 try { | 781 try { |
| 782 javaListSet(list, 1, node); | 782 javaListSet(list, 1, node); |
| 783 fail("Expected IndexOutOfBoundsException"); | 783 fail("Expected IndexOutOfBoundsException"); |
| 784 } on RangeError catch (exception) { | 784 } on RangeError catch (exception) { |
| 785 // Expected | 785 // Expected |
| 786 } | 786 } |
| 787 } | 787 } |
| 788 } | 788 } |
| 789 | 789 |
| 790 class NodeLocatorTest extends ParserTestCase { | 790 class NodeLocatorTest extends ParserTestCase { |
| 791 void test_range() { | 791 void test_range() { |
| 792 CompilationUnit unit = ParserTestCase.parseCompilationUnit("library myLib;",
[]); | 792 CompilationUnit unit = ParserTestCase.parseCompilationUnit("library myLib;")
; |
| 793 _assertLocate(unit, 4, 10, (node) => node is LibraryDirective, LibraryDirect
ive); | 793 _assertLocate(unit, 4, 10, (node) => node is LibraryDirective, LibraryDirect
ive); |
| 794 } | 794 } |
| 795 | 795 |
| 796 void test_searchWithin_null() { | 796 void test_searchWithin_null() { |
| 797 NodeLocator locator = new NodeLocator.con2(0, 0); | 797 NodeLocator locator = new NodeLocator.con2(0, 0); |
| 798 expect(locator.searchWithin(null), isNull); | 798 expect(locator.searchWithin(null), isNull); |
| 799 } | 799 } |
| 800 | 800 |
| 801 void test_searchWithin_offset() { | 801 void test_searchWithin_offset() { |
| 802 CompilationUnit unit = ParserTestCase.parseCompilationUnit("library myLib;",
[]); | 802 CompilationUnit unit = ParserTestCase.parseCompilationUnit("library myLib;")
; |
| 803 _assertLocate(unit, 10, 10, (node) => node is SimpleIdentifier, SimpleIdenti
fier); | 803 _assertLocate(unit, 10, 10, (node) => node is SimpleIdentifier, SimpleIdenti
fier); |
| 804 } | 804 } |
| 805 | 805 |
| 806 void test_searchWithin_offsetAfterNode() { | 806 void test_searchWithin_offsetAfterNode() { |
| 807 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' | 807 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' |
| 808 class A {} | 808 class A {} |
| 809 class B {}''', []); | 809 class B {}'''); |
| 810 NodeLocator locator = new NodeLocator.con2(1024, 1024); | 810 NodeLocator locator = new NodeLocator.con2(1024, 1024); |
| 811 AstNode node = locator.searchWithin(unit.declarations[0]); | 811 AstNode node = locator.searchWithin(unit.declarations[0]); |
| 812 expect(node, isNull); | 812 expect(node, isNull); |
| 813 } | 813 } |
| 814 | 814 |
| 815 void test_searchWithin_offsetBeforeNode() { | 815 void test_searchWithin_offsetBeforeNode() { |
| 816 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' | 816 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' |
| 817 class A {} | 817 class A {} |
| 818 class B {}''', []); | 818 class B {}'''); |
| 819 NodeLocator locator = new NodeLocator.con2(0, 0); | 819 NodeLocator locator = new NodeLocator.con2(0, 0); |
| 820 AstNode node = locator.searchWithin(unit.declarations[1]); | 820 AstNode node = locator.searchWithin(unit.declarations[1]); |
| 821 expect(node, isNull); | 821 expect(node, isNull); |
| 822 } | 822 } |
| 823 | 823 |
| 824 void _assertLocate(CompilationUnit unit, int start, int end, Predicate<AstNode
> predicate, Type expectedClass) { | 824 void _assertLocate(CompilationUnit unit, int start, int end, Predicate<AstNode
> predicate, Type expectedClass) { |
| 825 NodeLocator locator = new NodeLocator.con2(start, end); | 825 NodeLocator locator = new NodeLocator.con2(start, end); |
| 826 AstNode node = locator.searchWithin(unit); | 826 AstNode node = locator.searchWithin(unit); |
| 827 expect(node, isNotNull); | 827 expect(node, isNotNull); |
| 828 expect(locator.foundNode, same(node)); | 828 expect(locator.foundNode, same(node)); |
| 829 expect(node.offset <= start, isTrue, reason: "Node starts after range"); | 829 expect(node.offset <= start, isTrue, reason: "Node starts after range"); |
| 830 expect(node.offset + node.length > end, isTrue, reason: "Node ends before ra
nge"); | 830 expect(node.offset + node.length > end, isTrue, reason: "Node ends before ra
nge"); |
| 831 EngineTestCase.assertInstanceOf(predicate, expectedClass, node); | 831 EngineTestCase.assertInstanceOf(predicate, expectedClass, node); |
| 832 } | 832 } |
| 833 } | 833 } |
| 834 | 834 |
| 835 class SimpleIdentifierTest extends ParserTestCase { | 835 class SimpleIdentifierTest extends ParserTestCase { |
| 836 void test_inDeclarationContext_catch_exception() { | 836 void test_inDeclarationContext_catch_exception() { |
| 837 SimpleIdentifier identifier = AstFactory.catchClause("e", []).exceptionParam
eter; | 837 SimpleIdentifier identifier = AstFactory.catchClause("e").exceptionParameter
; |
| 838 expect(identifier.inDeclarationContext(), isTrue); | 838 expect(identifier.inDeclarationContext(), isTrue); |
| 839 } | 839 } |
| 840 | 840 |
| 841 void test_inDeclarationContext_catch_stack() { | 841 void test_inDeclarationContext_catch_stack() { |
| 842 SimpleIdentifier identifier = AstFactory.catchClause2("e", "s", []).stackTra
ceParameter; | 842 SimpleIdentifier identifier = AstFactory.catchClause2("e", "s").stackTracePa
rameter; |
| 843 expect(identifier.inDeclarationContext(), isTrue); | 843 expect(identifier.inDeclarationContext(), isTrue); |
| 844 } | 844 } |
| 845 | 845 |
| 846 void test_inDeclarationContext_classDeclaration() { | 846 void test_inDeclarationContext_classDeclaration() { |
| 847 SimpleIdentifier identifier = AstFactory.classDeclaration(null, "C", null, n
ull, null, null, []).name; | 847 SimpleIdentifier identifier = AstFactory.classDeclaration(null, "C", null, n
ull, null, null).name; |
| 848 expect(identifier.inDeclarationContext(), isTrue); | 848 expect(identifier.inDeclarationContext(), isTrue); |
| 849 } | 849 } |
| 850 | 850 |
| 851 void test_inDeclarationContext_classTypeAlias() { | 851 void test_inDeclarationContext_classTypeAlias() { |
| 852 SimpleIdentifier identifier = AstFactory.classTypeAlias("C", null, null, nul
l, null, null).name; | 852 SimpleIdentifier identifier = AstFactory.classTypeAlias("C", null, null, nul
l, null, null).name; |
| 853 expect(identifier.inDeclarationContext(), isTrue); | 853 expect(identifier.inDeclarationContext(), isTrue); |
| 854 } | 854 } |
| 855 | 855 |
| 856 void test_inDeclarationContext_constructorDeclaration() { | 856 void test_inDeclarationContext_constructorDeclaration() { |
| 857 SimpleIdentifier identifier = AstFactory.constructorDeclaration(AstFactory.i
dentifier3("C"), "c", null, null).name; | 857 SimpleIdentifier identifier = AstFactory.constructorDeclaration(AstFactory.i
dentifier3("C"), "c", null, null).name; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 } | 892 } |
| 893 | 893 |
| 894 void test_inDeclarationContext_label_false() { | 894 void test_inDeclarationContext_label_false() { |
| 895 SimpleIdentifier identifier = AstFactory.namedExpression2("l", AstFactory.in
teger(0)).name.label; | 895 SimpleIdentifier identifier = AstFactory.namedExpression2("l", AstFactory.in
teger(0)).name.label; |
| 896 expect(identifier.inDeclarationContext(), isFalse); | 896 expect(identifier.inDeclarationContext(), isFalse); |
| 897 } | 897 } |
| 898 | 898 |
| 899 void test_inDeclarationContext_label_true() { | 899 void test_inDeclarationContext_label_true() { |
| 900 Label label = AstFactory.label2("l"); | 900 Label label = AstFactory.label2("l"); |
| 901 SimpleIdentifier identifier = label.label; | 901 SimpleIdentifier identifier = label.label; |
| 902 AstFactory.labeledStatement(AstFactory.list([label]), AstFactory.emptyStatem
ent()); | 902 AstFactory.labeledStatement([label], AstFactory.emptyStatement()); |
| 903 expect(identifier.inDeclarationContext(), isTrue); | 903 expect(identifier.inDeclarationContext(), isTrue); |
| 904 } | 904 } |
| 905 | 905 |
| 906 void test_inDeclarationContext_methodDeclaration() { | 906 void test_inDeclarationContext_methodDeclaration() { |
| 907 SimpleIdentifier identifier = AstFactory.identifier3("m"); | 907 SimpleIdentifier identifier = AstFactory.identifier3("m"); |
| 908 AstFactory.methodDeclaration2(null, null, null, null, identifier, null, null
); | 908 AstFactory.methodDeclaration2(null, null, null, null, identifier, null, null
); |
| 909 expect(identifier.inDeclarationContext(), isTrue); | 909 expect(identifier.inDeclarationContext(), isTrue); |
| 910 } | 910 } |
| 911 | 911 |
| 912 void test_inDeclarationContext_prefix() { | 912 void test_inDeclarationContext_prefix() { |
| 913 SimpleIdentifier identifier = AstFactory.importDirective3("uri", "pref", [])
.prefix; | 913 SimpleIdentifier identifier = AstFactory.importDirective3("uri", "pref").pre
fix; |
| 914 expect(identifier.inDeclarationContext(), isTrue); | 914 expect(identifier.inDeclarationContext(), isTrue); |
| 915 } | 915 } |
| 916 | 916 |
| 917 void test_inDeclarationContext_simpleFormalParameter() { | 917 void test_inDeclarationContext_simpleFormalParameter() { |
| 918 SimpleIdentifier identifier = AstFactory.simpleFormalParameter3("p").identif
ier; | 918 SimpleIdentifier identifier = AstFactory.simpleFormalParameter3("p").identif
ier; |
| 919 expect(identifier.inDeclarationContext(), isTrue); | 919 expect(identifier.inDeclarationContext(), isTrue); |
| 920 } | 920 } |
| 921 | 921 |
| 922 void test_inDeclarationContext_typeParameter_bound() { | 922 void test_inDeclarationContext_typeParameter_bound() { |
| 923 TypeName bound = AstFactory.typeName4("A", []); | 923 TypeName bound = AstFactory.typeName4("A"); |
| 924 SimpleIdentifier identifier = bound.name as SimpleIdentifier; | 924 SimpleIdentifier identifier = bound.name as SimpleIdentifier; |
| 925 AstFactory.typeParameter2("E", bound); | 925 AstFactory.typeParameter2("E", bound); |
| 926 expect(identifier.inDeclarationContext(), isFalse); | 926 expect(identifier.inDeclarationContext(), isFalse); |
| 927 } | 927 } |
| 928 | 928 |
| 929 void test_inDeclarationContext_typeParameter_name() { | 929 void test_inDeclarationContext_typeParameter_name() { |
| 930 SimpleIdentifier identifier = AstFactory.typeParameter("E").name; | 930 SimpleIdentifier identifier = AstFactory.typeParameter("E").name; |
| 931 expect(identifier.inDeclarationContext(), isTrue); | 931 expect(identifier.inDeclarationContext(), isTrue); |
| 932 } | 932 } |
| 933 | 933 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 948 if (!identifier.inGetterContext()) { | 948 if (!identifier.inGetterContext()) { |
| 949 fail("Expected ${_topMostNode(identifier).toSource()} to be true"); | 949 fail("Expected ${_topMostNode(identifier).toSource()} to be true"); |
| 950 } | 950 } |
| 951 } | 951 } |
| 952 } | 952 } |
| 953 } | 953 } |
| 954 } | 954 } |
| 955 | 955 |
| 956 void test_inGetterContext_forEachLoop() { | 956 void test_inGetterContext_forEachLoop() { |
| 957 SimpleIdentifier identifier = AstFactory.identifier3("a"); | 957 SimpleIdentifier identifier = AstFactory.identifier3("a"); |
| 958 Expression iterator = AstFactory.listLiteral([]); | 958 Expression iterator = AstFactory.listLiteral(); |
| 959 Statement body = AstFactory.block([]); | 959 Statement body = AstFactory.block(); |
| 960 AstFactory.forEachStatement2(identifier, iterator, body); | 960 AstFactory.forEachStatement2(identifier, iterator, body); |
| 961 expect(identifier.inGetterContext(), isFalse); | 961 expect(identifier.inGetterContext(), isFalse); |
| 962 } | 962 } |
| 963 | 963 |
| 964 void test_inReferenceContext() { | 964 void test_inReferenceContext() { |
| 965 SimpleIdentifier identifier = AstFactory.identifier3("id"); | 965 SimpleIdentifier identifier = AstFactory.identifier3("id"); |
| 966 AstFactory.namedExpression(AstFactory.label(identifier), AstFactory.identifi
er3("_")); | 966 AstFactory.namedExpression(AstFactory.label(identifier), AstFactory.identifi
er3("_")); |
| 967 expect(identifier.inGetterContext(), isFalse); | 967 expect(identifier.inGetterContext(), isFalse); |
| 968 expect(identifier.inSetterContext(), isFalse); | 968 expect(identifier.inSetterContext(), isFalse); |
| 969 } | 969 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 980 if (!identifier.inSetterContext()) { | 980 if (!identifier.inSetterContext()) { |
| 981 fail("Expected ${_topMostNode(identifier).toSource()} to be true"); | 981 fail("Expected ${_topMostNode(identifier).toSource()} to be true"); |
| 982 } | 982 } |
| 983 } | 983 } |
| 984 } | 984 } |
| 985 } | 985 } |
| 986 } | 986 } |
| 987 | 987 |
| 988 void test_inSetterContext_forEachLoop() { | 988 void test_inSetterContext_forEachLoop() { |
| 989 SimpleIdentifier identifier = AstFactory.identifier3("a"); | 989 SimpleIdentifier identifier = AstFactory.identifier3("a"); |
| 990 Expression iterator = AstFactory.listLiteral([]); | 990 Expression iterator = AstFactory.listLiteral(); |
| 991 Statement body = AstFactory.block([]); | 991 Statement body = AstFactory.block(); |
| 992 AstFactory.forEachStatement2(identifier, iterator, body); | 992 AstFactory.forEachStatement2(identifier, iterator, body); |
| 993 expect(identifier.inSetterContext(), isTrue); | 993 expect(identifier.inSetterContext(), isTrue); |
| 994 } | 994 } |
| 995 | 995 |
| 996 void test_isQualified_inMethodInvocation_noTarget() { | 996 void test_isQualified_inMethodInvocation_noTarget() { |
| 997 MethodInvocation invocation = AstFactory.methodInvocation2("test", [AstFacto
ry.identifier3("arg0")]); | 997 MethodInvocation invocation = AstFactory.methodInvocation2("test", [AstFacto
ry.identifier3("arg0")]); |
| 998 SimpleIdentifier identifier = invocation.methodName; | 998 SimpleIdentifier identifier = invocation.methodName; |
| 999 expect(identifier.isQualified, isFalse); | 999 expect(identifier.isQualified, isFalse); |
| 1000 } | 1000 } |
| 1001 | 1001 |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 // ''' | 1320 // ''' |
| 1321 { | 1321 { |
| 1322 var a = AstFactory.interpolationString("'''a", "a"); | 1322 var a = AstFactory.interpolationString("'''a", "a"); |
| 1323 var c = AstFactory.interpolationString("ccc'''", "ccc"); | 1323 var c = AstFactory.interpolationString("ccc'''", "ccc"); |
| 1324 StringInterpolation node = AstFactory.string([a, b, c]); | 1324 StringInterpolation node = AstFactory.string([a, b, c]); |
| 1325 expect(node.isSingleQuoted, isTrue); | 1325 expect(node.isSingleQuoted, isTrue); |
| 1326 } | 1326 } |
| 1327 } | 1327 } |
| 1328 | 1328 |
| 1329 void test_isRaw() { | 1329 void test_isRaw() { |
| 1330 StringInterpolation node = AstFactory.string([]); | 1330 StringInterpolation node = AstFactory.string(); |
| 1331 expect(node.isRaw, isFalse); | 1331 expect(node.isRaw, isFalse); |
| 1332 } | 1332 } |
| 1333 } | 1333 } |
| 1334 | 1334 |
| 1335 class ToSourceVisitorTest extends EngineTestCase { | 1335 class ToSourceVisitorTest extends EngineTestCase { |
| 1336 void test_visitAdjacentStrings() { | 1336 void test_visitAdjacentStrings() { |
| 1337 _assertSource("'a' 'b'", AstFactory.adjacentStrings([AstFactory.string2("a")
, AstFactory.string2("b")])); | 1337 _assertSource("'a' 'b'", AstFactory.adjacentStrings([AstFactory.string2("a")
, AstFactory.string2("b")])); |
| 1338 } | 1338 } |
| 1339 | 1339 |
| 1340 void test_visitAnnotation_constant() { | 1340 void test_visitAnnotation_constant() { |
| 1341 _assertSource("@A", AstFactory.annotation(AstFactory.identifier3("A"))); | 1341 _assertSource("@A", AstFactory.annotation(AstFactory.identifier3("A"))); |
| 1342 } | 1342 } |
| 1343 | 1343 |
| 1344 void test_visitAnnotation_constructor() { | 1344 void test_visitAnnotation_constructor() { |
| 1345 _assertSource("@A.c()", AstFactory.annotation2(AstFactory.identifier3("A"),
AstFactory.identifier3("c"), AstFactory.argumentList([]))); | 1345 _assertSource("@A.c()", AstFactory.annotation2(AstFactory.identifier3("A"),
AstFactory.identifier3("c"), AstFactory.argumentList())); |
| 1346 } | 1346 } |
| 1347 | 1347 |
| 1348 void test_visitArgumentList() { | 1348 void test_visitArgumentList() { |
| 1349 _assertSource("(a, b)", AstFactory.argumentList([AstFactory.identifier3("a")
, AstFactory.identifier3("b")])); | 1349 _assertSource("(a, b)", AstFactory.argumentList([AstFactory.identifier3("a")
, AstFactory.identifier3("b")])); |
| 1350 } | 1350 } |
| 1351 | 1351 |
| 1352 void test_visitAsExpression() { | 1352 void test_visitAsExpression() { |
| 1353 _assertSource("e as T", AstFactory.asExpression(AstFactory.identifier3("e"),
AstFactory.typeName4("T", []))); | 1353 _assertSource("e as T", AstFactory.asExpression(AstFactory.identifier3("e"),
AstFactory.typeName4("T"))); |
| 1354 } | 1354 } |
| 1355 | 1355 |
| 1356 void test_visitAssertStatement() { | 1356 void test_visitAssertStatement() { |
| 1357 _assertSource("assert (a);", AstFactory.assertStatement(AstFactory.identifie
r3("a"))); | 1357 _assertSource("assert (a);", AstFactory.assertStatement(AstFactory.identifie
r3("a"))); |
| 1358 } | 1358 } |
| 1359 | 1359 |
| 1360 void test_visitAssignmentExpression() { | 1360 void test_visitAssignmentExpression() { |
| 1361 _assertSource("a = b", AstFactory.assignmentExpression(AstFactory.identifier
3("a"), TokenType.EQ, AstFactory.identifier3("b"))); | 1361 _assertSource("a = b", AstFactory.assignmentExpression(AstFactory.identifier
3("a"), TokenType.EQ, AstFactory.identifier3("b"))); |
| 1362 } | 1362 } |
| 1363 | 1363 |
| 1364 void test_visitAwaitExpression() { | 1364 void test_visitAwaitExpression() { |
| 1365 _assertSource("await e;", AstFactory.awaitExpression(AstFactory.identifier3(
"e"))); | 1365 _assertSource("await e;", AstFactory.awaitExpression(AstFactory.identifier3(
"e"))); |
| 1366 } | 1366 } |
| 1367 | 1367 |
| 1368 void test_visitBinaryExpression() { | 1368 void test_visitBinaryExpression() { |
| 1369 _assertSource("a + b", AstFactory.binaryExpression(AstFactory.identifier3("a
"), TokenType.PLUS, AstFactory.identifier3("b"))); | 1369 _assertSource("a + b", AstFactory.binaryExpression(AstFactory.identifier3("a
"), TokenType.PLUS, AstFactory.identifier3("b"))); |
| 1370 } | 1370 } |
| 1371 | 1371 |
| 1372 void test_visitBlock_empty() { | 1372 void test_visitBlock_empty() { |
| 1373 _assertSource("{}", AstFactory.block([])); | 1373 _assertSource("{}", AstFactory.block()); |
| 1374 } | 1374 } |
| 1375 | 1375 |
| 1376 void test_visitBlock_nonEmpty() { | 1376 void test_visitBlock_nonEmpty() { |
| 1377 _assertSource("{break; break;}", AstFactory.block([AstFactory.breakStatement
(), AstFactory.breakStatement()])); | 1377 _assertSource("{break; break;}", AstFactory.block([AstFactory.breakStatement
(), AstFactory.breakStatement()])); |
| 1378 } | 1378 } |
| 1379 | 1379 |
| 1380 void test_visitBlockFunctionBody_async() { | 1380 void test_visitBlockFunctionBody_async() { |
| 1381 _assertSource("async {}", AstFactory.asyncBlockFunctionBody([])); | 1381 _assertSource("async {}", AstFactory.asyncBlockFunctionBody()); |
| 1382 } | 1382 } |
| 1383 | 1383 |
| 1384 void test_visitBlockFunctionBody_async_star() { | 1384 void test_visitBlockFunctionBody_async_star() { |
| 1385 _assertSource("async* {}", AstFactory.asyncGeneratorBlockFunctionBody([])); | 1385 _assertSource("async* {}", AstFactory.asyncGeneratorBlockFunctionBody()); |
| 1386 } | 1386 } |
| 1387 | 1387 |
| 1388 void test_visitBlockFunctionBody_simple() { | 1388 void test_visitBlockFunctionBody_simple() { |
| 1389 _assertSource("{}", AstFactory.blockFunctionBody2([])); | 1389 _assertSource("{}", AstFactory.blockFunctionBody2()); |
| 1390 } | 1390 } |
| 1391 | 1391 |
| 1392 void test_visitBlockFunctionBody_sync() { | 1392 void test_visitBlockFunctionBody_sync() { |
| 1393 _assertSource("sync {}", AstFactory.syncBlockFunctionBody([])); | 1393 _assertSource("sync {}", AstFactory.syncBlockFunctionBody()); |
| 1394 } | 1394 } |
| 1395 | 1395 |
| 1396 void test_visitBlockFunctionBody_sync_star() { | 1396 void test_visitBlockFunctionBody_sync_star() { |
| 1397 _assertSource("sync* {}", AstFactory.syncGeneratorBlockFunctionBody([])); | 1397 _assertSource("sync* {}", AstFactory.syncGeneratorBlockFunctionBody()); |
| 1398 } | 1398 } |
| 1399 | 1399 |
| 1400 void test_visitBooleanLiteral_false() { | 1400 void test_visitBooleanLiteral_false() { |
| 1401 _assertSource("false", AstFactory.booleanLiteral(false)); | 1401 _assertSource("false", AstFactory.booleanLiteral(false)); |
| 1402 } | 1402 } |
| 1403 | 1403 |
| 1404 void test_visitBooleanLiteral_true() { | 1404 void test_visitBooleanLiteral_true() { |
| 1405 _assertSource("true", AstFactory.booleanLiteral(true)); | 1405 _assertSource("true", AstFactory.booleanLiteral(true)); |
| 1406 } | 1406 } |
| 1407 | 1407 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1420 } | 1420 } |
| 1421 | 1421 |
| 1422 void test_visitCascadeExpression_index() { | 1422 void test_visitCascadeExpression_index() { |
| 1423 _assertSource("a..[0]..[1]", AstFactory.cascadeExpression(AstFactory.identif
ier3("a"), [ | 1423 _assertSource("a..[0]..[1]", AstFactory.cascadeExpression(AstFactory.identif
ier3("a"), [ |
| 1424 AstFactory.cascadedIndexExpression(AstFactory.integer(0)), | 1424 AstFactory.cascadedIndexExpression(AstFactory.integer(0)), |
| 1425 AstFactory.cascadedIndexExpression(AstFactory.integer(1))])); | 1425 AstFactory.cascadedIndexExpression(AstFactory.integer(1))])); |
| 1426 } | 1426 } |
| 1427 | 1427 |
| 1428 void test_visitCascadeExpression_method() { | 1428 void test_visitCascadeExpression_method() { |
| 1429 _assertSource("a..b()..c()", AstFactory.cascadeExpression(AstFactory.identif
ier3("a"), [ | 1429 _assertSource("a..b()..c()", AstFactory.cascadeExpression(AstFactory.identif
ier3("a"), [ |
| 1430 AstFactory.cascadedMethodInvocation("b", []), | 1430 AstFactory.cascadedMethodInvocation("b"), |
| 1431 AstFactory.cascadedMethodInvocation("c", [])])); | 1431 AstFactory.cascadedMethodInvocation("c")])); |
| 1432 } | 1432 } |
| 1433 | 1433 |
| 1434 void test_visitCatchClause_catch_noStack() { | 1434 void test_visitCatchClause_catch_noStack() { |
| 1435 _assertSource("catch (e) {}", AstFactory.catchClause("e", [])); | 1435 _assertSource("catch (e) {}", AstFactory.catchClause("e")); |
| 1436 } | 1436 } |
| 1437 | 1437 |
| 1438 void test_visitCatchClause_catch_stack() { | 1438 void test_visitCatchClause_catch_stack() { |
| 1439 _assertSource("catch (e, s) {}", AstFactory.catchClause2("e", "s", [])); | 1439 _assertSource("catch (e, s) {}", AstFactory.catchClause2("e", "s")); |
| 1440 } | 1440 } |
| 1441 | 1441 |
| 1442 void test_visitCatchClause_on() { | 1442 void test_visitCatchClause_on() { |
| 1443 _assertSource("on E {}", AstFactory.catchClause3(AstFactory.typeName4("E", [
]), [])); | 1443 _assertSource("on E {}", AstFactory.catchClause3(AstFactory.typeName4("E")))
; |
| 1444 } | 1444 } |
| 1445 | 1445 |
| 1446 void test_visitCatchClause_on_catch() { | 1446 void test_visitCatchClause_on_catch() { |
| 1447 _assertSource("on E catch (e) {}", AstFactory.catchClause4(AstFactory.typeNa
me4("E", []), "e", [])); | 1447 _assertSource("on E catch (e) {}", AstFactory.catchClause4(AstFactory.typeNa
me4("E"), "e")); |
| 1448 } | 1448 } |
| 1449 | 1449 |
| 1450 void test_visitClassDeclaration_abstract() { | 1450 void test_visitClassDeclaration_abstract() { |
| 1451 _assertSource("abstract class C {}", AstFactory.classDeclaration(Keyword.ABS
TRACT, "C", null, null, null, null, [])); | 1451 _assertSource("abstract class C {}", AstFactory.classDeclaration(Keyword.ABS
TRACT, "C", null, null, null, null)); |
| 1452 } | 1452 } |
| 1453 | 1453 |
| 1454 void test_visitClassDeclaration_empty() { | 1454 void test_visitClassDeclaration_empty() { |
| 1455 _assertSource("class C {}", AstFactory.classDeclaration(null, "C", null, nul
l, null, null, [])); | 1455 _assertSource("class C {}", AstFactory.classDeclaration(null, "C", null, nul
l, null, null)); |
| 1456 } | 1456 } |
| 1457 | 1457 |
| 1458 void test_visitClassDeclaration_extends() { | 1458 void test_visitClassDeclaration_extends() { |
| 1459 _assertSource("class C extends A {}", AstFactory.classDeclaration(null, "C",
null, AstFactory.extendsClause(AstFactory.typeName4("A", [])), null, null, []))
; | 1459 _assertSource("class C extends A {}", AstFactory.classDeclaration(null, "C",
null, AstFactory.extendsClause(AstFactory.typeName4("A")), null, null)); |
| 1460 } | 1460 } |
| 1461 | 1461 |
| 1462 void test_visitClassDeclaration_extends_implements() { | 1462 void test_visitClassDeclaration_extends_implements() { |
| 1463 _assertSource("class C extends A implements B {}", AstFactory.classDeclarati
on(null, "C", null, AstFactory.extendsClause(AstFactory.typeName4("A", [])), nul
l, AstFactory.implementsClause([AstFactory.typeName4("B", [])]), [])); | 1463 _assertSource("class C extends A implements B {}", AstFactory.classDeclarati
on(null, "C", null, AstFactory.extendsClause(AstFactory.typeName4("A")), null, A
stFactory.implementsClause([AstFactory.typeName4("B")]))); |
| 1464 } | 1464 } |
| 1465 | 1465 |
| 1466 void test_visitClassDeclaration_extends_with() { | 1466 void test_visitClassDeclaration_extends_with() { |
| 1467 _assertSource("class C extends A with M {}", AstFactory.classDeclaration(nul
l, "C", null, AstFactory.extendsClause(AstFactory.typeName4("A", [])), AstFactor
y.withClause([AstFactory.typeName4("M", [])]), null, [])); | 1467 _assertSource("class C extends A with M {}", AstFactory.classDeclaration(nul
l, "C", null, AstFactory.extendsClause(AstFactory.typeName4("A")), AstFactory.wi
thClause([AstFactory.typeName4("M")]), null)); |
| 1468 } | 1468 } |
| 1469 | 1469 |
| 1470 void test_visitClassDeclaration_extends_with_implements() { | 1470 void test_visitClassDeclaration_extends_with_implements() { |
| 1471 _assertSource("class C extends A with M implements B {}", AstFactory.classDe
claration(null, "C", null, AstFactory.extendsClause(AstFactory.typeName4("A", []
)), AstFactory.withClause([AstFactory.typeName4("M", [])]), AstFactory.implement
sClause([AstFactory.typeName4("B", [])]), [])); | 1471 _assertSource("class C extends A with M implements B {}", AstFactory.classDe
claration(null, "C", null, AstFactory.extendsClause(AstFactory.typeName4("A")),
AstFactory.withClause([AstFactory.typeName4("M")]), AstFactory.implementsClause(
[AstFactory.typeName4("B")]))); |
| 1472 } | 1472 } |
| 1473 | 1473 |
| 1474 void test_visitClassDeclaration_implements() { | 1474 void test_visitClassDeclaration_implements() { |
| 1475 _assertSource("class C implements B {}", AstFactory.classDeclaration(null, "
C", null, null, null, AstFactory.implementsClause([AstFactory.typeName4("B", [])
]), [])); | 1475 _assertSource("class C implements B {}", AstFactory.classDeclaration(null, "
C", null, null, null, AstFactory.implementsClause([AstFactory.typeName4("B")])))
; |
| 1476 } | 1476 } |
| 1477 | 1477 |
| 1478 void test_visitClassDeclaration_multipleMember() { | 1478 void test_visitClassDeclaration_multipleMember() { |
| 1479 _assertSource("class C {var a; var b;}", AstFactory.classDeclaration(null, "
C", null, null, null, null, [ | 1479 _assertSource("class C {var a; var b;}", AstFactory.classDeclaration(null, "
C", null, null, null, null, [ |
| 1480 AstFactory.fieldDeclaration2(false, Keyword.VAR, [AstFactory.variableDec
laration("a")]), | 1480 AstFactory.fieldDeclaration2(false, Keyword.VAR, [AstFactory.variableDec
laration("a")]), |
| 1481 AstFactory.fieldDeclaration2(false, Keyword.VAR, [AstFactory.variableDec
laration("b")])])); | 1481 AstFactory.fieldDeclaration2(false, Keyword.VAR, [AstFactory.variableDec
laration("b")])])); |
| 1482 } | 1482 } |
| 1483 | 1483 |
| 1484 void test_visitClassDeclaration_parameters() { | 1484 void test_visitClassDeclaration_parameters() { |
| 1485 _assertSource("class C<E> {}", AstFactory.classDeclaration(null, "C", AstFac
tory.typeParameterList(["E"]), null, null, null, [])); | 1485 _assertSource("class C<E> {}", AstFactory.classDeclaration(null, "C", AstFac
tory.typeParameterList(["E"]), null, null, null)); |
| 1486 } | 1486 } |
| 1487 | 1487 |
| 1488 void test_visitClassDeclaration_parameters_extends() { | 1488 void test_visitClassDeclaration_parameters_extends() { |
| 1489 _assertSource("class C<E> extends A {}", AstFactory.classDeclaration(null, "
C", AstFactory.typeParameterList(["E"]), AstFactory.extendsClause(AstFactory.typ
eName4("A", [])), null, null, [])); | 1489 _assertSource("class C<E> extends A {}", AstFactory.classDeclaration(null, "
C", AstFactory.typeParameterList(["E"]), AstFactory.extendsClause(AstFactory.typ
eName4("A")), null, null)); |
| 1490 } | 1490 } |
| 1491 | 1491 |
| 1492 void test_visitClassDeclaration_parameters_extends_implements() { | 1492 void test_visitClassDeclaration_parameters_extends_implements() { |
| 1493 _assertSource("class C<E> extends A implements B {}", AstFactory.classDeclar
ation(null, "C", AstFactory.typeParameterList(["E"]), AstFactory.extendsClause(A
stFactory.typeName4("A", [])), null, AstFactory.implementsClause([AstFactory.typ
eName4("B", [])]), [])); | 1493 _assertSource("class C<E> extends A implements B {}", AstFactory.classDeclar
ation(null, "C", AstFactory.typeParameterList(["E"]), AstFactory.extendsClause(A
stFactory.typeName4("A")), null, AstFactory.implementsClause([AstFactory.typeNam
e4("B")]))); |
| 1494 } | 1494 } |
| 1495 | 1495 |
| 1496 void test_visitClassDeclaration_parameters_extends_with() { | 1496 void test_visitClassDeclaration_parameters_extends_with() { |
| 1497 _assertSource("class C<E> extends A with M {}", AstFactory.classDeclaration(
null, "C", AstFactory.typeParameterList(["E"]), AstFactory.extendsClause(AstFact
ory.typeName4("A", [])), AstFactory.withClause([AstFactory.typeName4("M", [])]),
null, [])); | 1497 _assertSource("class C<E> extends A with M {}", AstFactory.classDeclaration(
null, "C", AstFactory.typeParameterList(["E"]), AstFactory.extendsClause(AstFact
ory.typeName4("A")), AstFactory.withClause([AstFactory.typeName4("M")]), null)); |
| 1498 } | 1498 } |
| 1499 | 1499 |
| 1500 void test_visitClassDeclaration_parameters_extends_with_implements() { | 1500 void test_visitClassDeclaration_parameters_extends_with_implements() { |
| 1501 _assertSource("class C<E> extends A with M implements B {}", AstFactory.clas
sDeclaration(null, "C", AstFactory.typeParameterList(["E"]), AstFactory.extendsC
lause(AstFactory.typeName4("A", [])), AstFactory.withClause([AstFactory.typeName
4("M", [])]), AstFactory.implementsClause([AstFactory.typeName4("B", [])]), []))
; | 1501 _assertSource("class C<E> extends A with M implements B {}", AstFactory.clas
sDeclaration(null, "C", AstFactory.typeParameterList(["E"]), AstFactory.extendsC
lause(AstFactory.typeName4("A")), AstFactory.withClause([AstFactory.typeName4("M
")]), AstFactory.implementsClause([AstFactory.typeName4("B")]))); |
| 1502 } | 1502 } |
| 1503 | 1503 |
| 1504 void test_visitClassDeclaration_parameters_implements() { | 1504 void test_visitClassDeclaration_parameters_implements() { |
| 1505 _assertSource("class C<E> implements B {}", AstFactory.classDeclaration(null
, "C", AstFactory.typeParameterList(["E"]), null, null, AstFactory.implementsCla
use([AstFactory.typeName4("B", [])]), [])); | 1505 _assertSource("class C<E> implements B {}", AstFactory.classDeclaration(null
, "C", AstFactory.typeParameterList(["E"]), null, null, AstFactory.implementsCla
use([AstFactory.typeName4("B")]))); |
| 1506 } | 1506 } |
| 1507 | 1507 |
| 1508 void test_visitClassDeclaration_singleMember() { | 1508 void test_visitClassDeclaration_singleMember() { |
| 1509 _assertSource("class C {var a;}", AstFactory.classDeclaration(null, "C", nul
l, null, null, null, [AstFactory.fieldDeclaration2(false, Keyword.VAR, [AstFacto
ry.variableDeclaration("a")])])); | 1509 _assertSource("class C {var a;}", AstFactory.classDeclaration(null, "C", nul
l, null, null, null, [AstFactory.fieldDeclaration2(false, Keyword.VAR, [AstFacto
ry.variableDeclaration("a")])])); |
| 1510 } | 1510 } |
| 1511 | 1511 |
| 1512 void test_visitClassDeclaration_withMetadata() { | 1512 void test_visitClassDeclaration_withMetadata() { |
| 1513 ClassDeclaration declaration = AstFactory.classDeclaration(null, "C", null,
null, null, null, []); | 1513 ClassDeclaration declaration = AstFactory.classDeclaration(null, "C", null,
null, null, null); |
| 1514 declaration.metadata = AstFactory.list([AstFactory.annotation(AstFactory.ide
ntifier3("deprecated"))]); | 1514 declaration.metadata = [ |
| 1515 AstFactory.annotation(AstFactory.identifier3("deprecated"))]; |
| 1515 _assertSource("@deprecated class C {}", declaration); | 1516 _assertSource("@deprecated class C {}", declaration); |
| 1516 } | 1517 } |
| 1517 | 1518 |
| 1518 void test_visitClassTypeAlias_abstract() { | 1519 void test_visitClassTypeAlias_abstract() { |
| 1519 _assertSource("abstract class C = S with M1;", AstFactory.classTypeAlias("C"
, null, Keyword.ABSTRACT, AstFactory.typeName4("S", []), AstFactory.withClause([
AstFactory.typeName4("M1", [])]), null)); | 1520 _assertSource("abstract class C = S with M1;", AstFactory.classTypeAlias("C"
, null, Keyword.ABSTRACT, AstFactory.typeName4("S"), AstFactory.withClause([AstF
actory.typeName4("M1")]), null)); |
| 1520 } | 1521 } |
| 1521 | 1522 |
| 1522 void test_visitClassTypeAlias_abstract_implements() { | 1523 void test_visitClassTypeAlias_abstract_implements() { |
| 1523 _assertSource("abstract class C = S with M1 implements I;", AstFactory.class
TypeAlias("C", null, Keyword.ABSTRACT, AstFactory.typeName4("S", []), AstFactory
.withClause([AstFactory.typeName4("M1", [])]), AstFactory.implementsClause([AstF
actory.typeName4("I", [])]))); | 1524 _assertSource("abstract class C = S with M1 implements I;", AstFactory.class
TypeAlias("C", null, Keyword.ABSTRACT, AstFactory.typeName4("S"), AstFactory.wit
hClause([AstFactory.typeName4("M1")]), AstFactory.implementsClause([AstFactory.t
ypeName4("I")]))); |
| 1524 } | 1525 } |
| 1525 | 1526 |
| 1526 void test_visitClassTypeAlias_generic() { | 1527 void test_visitClassTypeAlias_generic() { |
| 1527 _assertSource("class C<E> = S<E> with M1<E>;", AstFactory.classTypeAlias("C"
, AstFactory.typeParameterList(["E"]), null, AstFactory.typeName4("S", [AstFacto
ry.typeName4("E", [])]), AstFactory.withClause([AstFactory.typeName4("M1", [AstF
actory.typeName4("E", [])])]), null)); | 1528 _assertSource("class C<E> = S<E> with M1<E>;", AstFactory.classTypeAlias("C"
, AstFactory.typeParameterList(["E"]), null, AstFactory.typeName4("S", [AstFacto
ry.typeName4("E")]), AstFactory.withClause([AstFactory.typeName4("M1", [AstFacto
ry.typeName4("E")])]), null)); |
| 1528 } | 1529 } |
| 1529 | 1530 |
| 1530 void test_visitClassTypeAlias_implements() { | 1531 void test_visitClassTypeAlias_implements() { |
| 1531 _assertSource("class C = S with M1 implements I;", AstFactory.classTypeAlias
("C", null, null, AstFactory.typeName4("S", []), AstFactory.withClause([AstFacto
ry.typeName4("M1", [])]), AstFactory.implementsClause([AstFactory.typeName4("I",
[])]))); | 1532 _assertSource("class C = S with M1 implements I;", AstFactory.classTypeAlias
("C", null, null, AstFactory.typeName4("S"), AstFactory.withClause([AstFactory.t
ypeName4("M1")]), AstFactory.implementsClause([AstFactory.typeName4("I")]))); |
| 1532 } | 1533 } |
| 1533 | 1534 |
| 1534 void test_visitClassTypeAlias_minimal() { | 1535 void test_visitClassTypeAlias_minimal() { |
| 1535 _assertSource("class C = S with M1;", AstFactory.classTypeAlias("C", null, n
ull, AstFactory.typeName4("S", []), AstFactory.withClause([AstFactory.typeName4(
"M1", [])]), null)); | 1536 _assertSource("class C = S with M1;", AstFactory.classTypeAlias("C", null, n
ull, AstFactory.typeName4("S"), AstFactory.withClause([AstFactory.typeName4("M1"
)]), null)); |
| 1536 } | 1537 } |
| 1537 | 1538 |
| 1538 void test_visitClassTypeAlias_parameters_abstract() { | 1539 void test_visitClassTypeAlias_parameters_abstract() { |
| 1539 _assertSource("abstract class C<E> = S with M1;", AstFactory.classTypeAlias(
"C", AstFactory.typeParameterList(["E"]), Keyword.ABSTRACT, AstFactory.typeName4
("S", []), AstFactory.withClause([AstFactory.typeName4("M1", [])]), null)); | 1540 _assertSource("abstract class C<E> = S with M1;", AstFactory.classTypeAlias(
"C", AstFactory.typeParameterList(["E"]), Keyword.ABSTRACT, AstFactory.typeName4
("S"), AstFactory.withClause([AstFactory.typeName4("M1")]), null)); |
| 1540 } | 1541 } |
| 1541 | 1542 |
| 1542 void test_visitClassTypeAlias_parameters_abstract_implements() { | 1543 void test_visitClassTypeAlias_parameters_abstract_implements() { |
| 1543 _assertSource("abstract class C<E> = S with M1 implements I;", AstFactory.cl
assTypeAlias("C", AstFactory.typeParameterList(["E"]), Keyword.ABSTRACT, AstFact
ory.typeName4("S", []), AstFactory.withClause([AstFactory.typeName4("M1", [])]),
AstFactory.implementsClause([AstFactory.typeName4("I", [])]))); | 1544 _assertSource("abstract class C<E> = S with M1 implements I;", AstFactory.cl
assTypeAlias("C", AstFactory.typeParameterList(["E"]), Keyword.ABSTRACT, AstFact
ory.typeName4("S"), AstFactory.withClause([AstFactory.typeName4("M1")]), AstFact
ory.implementsClause([AstFactory.typeName4("I")]))); |
| 1544 } | 1545 } |
| 1545 | 1546 |
| 1546 void test_visitClassTypeAlias_parameters_implements() { | 1547 void test_visitClassTypeAlias_parameters_implements() { |
| 1547 _assertSource("class C<E> = S with M1 implements I;", AstFactory.classTypeAl
ias("C", AstFactory.typeParameterList(["E"]), null, AstFactory.typeName4("S", []
), AstFactory.withClause([AstFactory.typeName4("M1", [])]), AstFactory.implement
sClause([AstFactory.typeName4("I", [])]))); | 1548 _assertSource("class C<E> = S with M1 implements I;", AstFactory.classTypeAl
ias("C", AstFactory.typeParameterList(["E"]), null, AstFactory.typeName4("S"), A
stFactory.withClause([AstFactory.typeName4("M1")]), AstFactory.implementsClause(
[AstFactory.typeName4("I")]))); |
| 1548 } | 1549 } |
| 1549 | 1550 |
| 1550 void test_visitClassTypeAlias_withMetadata() { | 1551 void test_visitClassTypeAlias_withMetadata() { |
| 1551 ClassTypeAlias declaration = AstFactory.classTypeAlias("C", null, null, AstF
actory.typeName4("S", []), AstFactory.withClause([AstFactory.typeName4("M1", [])
]), null); | 1552 ClassTypeAlias declaration = AstFactory.classTypeAlias("C", null, null, AstF
actory.typeName4("S"), AstFactory.withClause([AstFactory.typeName4("M1")]), null
); |
| 1552 declaration.metadata = AstFactory.list([AstFactory.annotation(AstFactory.ide
ntifier3("deprecated"))]); | 1553 declaration.metadata = [ |
| 1554 AstFactory.annotation(AstFactory.identifier3("deprecated"))]; |
| 1553 _assertSource("@deprecated class C = S with M1;", declaration); | 1555 _assertSource("@deprecated class C = S with M1;", declaration); |
| 1554 } | 1556 } |
| 1555 | 1557 |
| 1556 void test_visitComment() { | 1558 void test_visitComment() { |
| 1557 _assertSource("", Comment.createBlockComment(<Token> [TokenFactory.tokenFrom
String("/* comment */")])); | 1559 _assertSource("", Comment.createBlockComment(<Token> [TokenFactory.tokenFrom
String("/* comment */")])); |
| 1558 } | 1560 } |
| 1559 | 1561 |
| 1560 void test_visitCommentReference() { | 1562 void test_visitCommentReference() { |
| 1561 _assertSource("", new CommentReference(null, AstFactory.identifier3("a"))); | 1563 _assertSource("", new CommentReference(null, AstFactory.identifier3("a"))); |
| 1562 } | 1564 } |
| 1563 | 1565 |
| 1564 void test_visitCompilationUnit_declaration() { | 1566 void test_visitCompilationUnit_declaration() { |
| 1565 _assertSource("var a;", AstFactory.compilationUnit2([AstFactory.topLevelVari
ableDeclaration2(Keyword.VAR, [AstFactory.variableDeclaration("a")])])); | 1567 _assertSource("var a;", AstFactory.compilationUnit2([AstFactory.topLevelVari
ableDeclaration2(Keyword.VAR, [AstFactory.variableDeclaration("a")])])); |
| 1566 } | 1568 } |
| 1567 | 1569 |
| 1568 void test_visitCompilationUnit_directive() { | 1570 void test_visitCompilationUnit_directive() { |
| 1569 _assertSource("library l;", AstFactory.compilationUnit3([AstFactory.libraryD
irective2("l")])); | 1571 _assertSource("library l;", AstFactory.compilationUnit3([AstFactory.libraryD
irective2("l")])); |
| 1570 } | 1572 } |
| 1571 | 1573 |
| 1572 void test_visitCompilationUnit_directive_declaration() { | 1574 void test_visitCompilationUnit_directive_declaration() { |
| 1573 _assertSource("library l; var a;", AstFactory.compilationUnit4(AstFactory.li
st([AstFactory.libraryDirective2("l")]), AstFactory.list([AstFactory.topLevelVar
iableDeclaration2(Keyword.VAR, [AstFactory.variableDeclaration("a")])]))); | 1575 _assertSource("library l; var a;", AstFactory.compilationUnit4( |
| 1576 [AstFactory.libraryDirective2("l")], |
| 1577 [AstFactory.topLevelVariableDeclaration2( |
| 1578 Keyword.VAR, |
| 1579 [AstFactory.variableDeclaration("a")])])); |
| 1574 } | 1580 } |
| 1575 | 1581 |
| 1576 void test_visitCompilationUnit_empty() { | 1582 void test_visitCompilationUnit_empty() { |
| 1577 _assertSource("", AstFactory.compilationUnit()); | 1583 _assertSource("", AstFactory.compilationUnit()); |
| 1578 } | 1584 } |
| 1579 | 1585 |
| 1580 void test_visitCompilationUnit_script() { | 1586 void test_visitCompilationUnit_script() { |
| 1581 _assertSource("!#/bin/dartvm", AstFactory.compilationUnit5("!#/bin/dartvm"))
; | 1587 _assertSource("!#/bin/dartvm", AstFactory.compilationUnit5("!#/bin/dartvm"))
; |
| 1582 } | 1588 } |
| 1583 | 1589 |
| 1584 void test_visitCompilationUnit_script_declaration() { | 1590 void test_visitCompilationUnit_script_declaration() { |
| 1585 _assertSource("!#/bin/dartvm var a;", AstFactory.compilationUnit6("!#/bin/da
rtvm", [AstFactory.topLevelVariableDeclaration2(Keyword.VAR, [AstFactory.variabl
eDeclaration("a")])])); | 1591 _assertSource("!#/bin/dartvm var a;", AstFactory.compilationUnit6("!#/bin/da
rtvm", [AstFactory.topLevelVariableDeclaration2(Keyword.VAR, [AstFactory.variabl
eDeclaration("a")])])); |
| 1586 } | 1592 } |
| 1587 | 1593 |
| 1588 void test_visitCompilationUnit_script_directive() { | 1594 void test_visitCompilationUnit_script_directive() { |
| 1589 _assertSource("!#/bin/dartvm library l;", AstFactory.compilationUnit7("!#/bi
n/dartvm", [AstFactory.libraryDirective2("l")])); | 1595 _assertSource("!#/bin/dartvm library l;", AstFactory.compilationUnit7("!#/bi
n/dartvm", [AstFactory.libraryDirective2("l")])); |
| 1590 } | 1596 } |
| 1591 | 1597 |
| 1592 void test_visitCompilationUnit_script_directives_declarations() { | 1598 void test_visitCompilationUnit_script_directives_declarations() { |
| 1593 _assertSource("!#/bin/dartvm library l; var a;", AstFactory.compilationUnit8
("!#/bin/dartvm", AstFactory.list([AstFactory.libraryDirective2("l")]), AstFacto
ry.list([AstFactory.topLevelVariableDeclaration2(Keyword.VAR, [AstFactory.variab
leDeclaration("a")])]))); | 1599 _assertSource("!#/bin/dartvm library l; var a;", AstFactory.compilationUnit8
( |
| 1600 "!#/bin/dartvm", |
| 1601 [AstFactory.libraryDirective2("l")], |
| 1602 [AstFactory.topLevelVariableDeclaration2( |
| 1603 Keyword.VAR, |
| 1604 [AstFactory.variableDeclaration("a")])])); |
| 1594 } | 1605 } |
| 1595 | 1606 |
| 1596 void test_visitConditionalExpression() { | 1607 void test_visitConditionalExpression() { |
| 1597 _assertSource("a ? b : c", AstFactory.conditionalExpression(AstFactory.ident
ifier3("a"), AstFactory.identifier3("b"), AstFactory.identifier3("c"))); | 1608 _assertSource("a ? b : c", AstFactory.conditionalExpression(AstFactory.ident
ifier3("a"), AstFactory.identifier3("b"), AstFactory.identifier3("c"))); |
| 1598 } | 1609 } |
| 1599 | 1610 |
| 1600 void test_visitConstructorDeclaration_const() { | 1611 void test_visitConstructorDeclaration_const() { |
| 1601 _assertSource("const C() {}", AstFactory.constructorDeclaration2(Keyword.CON
ST, null, AstFactory.identifier3("C"), null, AstFactory.formalParameterList([]),
null, AstFactory.blockFunctionBody2([]))); | 1612 _assertSource("const C() {}", AstFactory.constructorDeclaration2(Keyword.CON
ST, null, AstFactory.identifier3("C"), null, AstFactory.formalParameterList(), n
ull, AstFactory.blockFunctionBody2())); |
| 1602 } | 1613 } |
| 1603 | 1614 |
| 1604 void test_visitConstructorDeclaration_external() { | 1615 void test_visitConstructorDeclaration_external() { |
| 1605 _assertSource("external C();", AstFactory.constructorDeclaration(AstFactory.
identifier3("C"), null, AstFactory.formalParameterList([]), null)); | 1616 _assertSource("external C();", AstFactory.constructorDeclaration(AstFactory.
identifier3("C"), null, AstFactory.formalParameterList(), null)); |
| 1606 } | 1617 } |
| 1607 | 1618 |
| 1608 void test_visitConstructorDeclaration_minimal() { | 1619 void test_visitConstructorDeclaration_minimal() { |
| 1609 _assertSource("C() {}", AstFactory.constructorDeclaration2(null, null, AstFa
ctory.identifier3("C"), null, AstFactory.formalParameterList([]), null, AstFacto
ry.blockFunctionBody2([]))); | 1620 _assertSource("C() {}", AstFactory.constructorDeclaration2(null, null, AstFa
ctory.identifier3("C"), null, AstFactory.formalParameterList(), null, AstFactory
.blockFunctionBody2())); |
| 1610 } | 1621 } |
| 1611 | 1622 |
| 1612 void test_visitConstructorDeclaration_multipleInitializers() { | 1623 void test_visitConstructorDeclaration_multipleInitializers() { |
| 1613 _assertSource("C() : a = b, c = d {}", AstFactory.constructorDeclaration2(nu
ll, null, AstFactory.identifier3("C"), null, AstFactory.formalParameterList([]),
AstFactory.list([ | 1624 _assertSource("C() : a = b, c = d {}", AstFactory.constructorDeclaration2( |
| 1614 AstFactory.constructorFieldInitializer(false, "a", AstFactory.identifier
3("b")), | 1625 null, |
| 1615 AstFactory.constructorFieldInitializer(false, "c", AstFactory.identifier
3("d"))]), AstFactory.blockFunctionBody2([]))); | 1626 null, |
| 1627 AstFactory.identifier3("C"), |
| 1628 null, |
| 1629 AstFactory.formalParameterList(), |
| 1630 [ |
| 1631 AstFactory.constructorFieldInitializer(false, "a", AstFactory.identifi
er3("b")), |
| 1632 AstFactory.constructorFieldInitializer(false, "c", AstFactory.identifi
er3("d"))], |
| 1633 AstFactory.blockFunctionBody2())); |
| 1616 } | 1634 } |
| 1617 | 1635 |
| 1618 void test_visitConstructorDeclaration_multipleParameters() { | 1636 void test_visitConstructorDeclaration_multipleParameters() { |
| 1619 _assertSource("C(var a, var b) {}", AstFactory.constructorDeclaration2(null,
null, AstFactory.identifier3("C"), null, AstFactory.formalParameterList([ | 1637 _assertSource("C(var a, var b) {}", AstFactory.constructorDeclaration2(null,
null, AstFactory.identifier3("C"), null, AstFactory.formalParameterList([ |
| 1620 AstFactory.simpleFormalParameter(Keyword.VAR, "a"), | 1638 AstFactory.simpleFormalParameter(Keyword.VAR, "a"), |
| 1621 AstFactory.simpleFormalParameter(Keyword.VAR, "b")]), null, AstFactory.b
lockFunctionBody2([]))); | 1639 AstFactory.simpleFormalParameter(Keyword.VAR, "b")]), null, AstFactory.b
lockFunctionBody2())); |
| 1622 } | 1640 } |
| 1623 | 1641 |
| 1624 void test_visitConstructorDeclaration_named() { | 1642 void test_visitConstructorDeclaration_named() { |
| 1625 _assertSource("C.m() {}", AstFactory.constructorDeclaration2(null, null, Ast
Factory.identifier3("C"), "m", AstFactory.formalParameterList([]), null, AstFact
ory.blockFunctionBody2([]))); | 1643 _assertSource("C.m() {}", AstFactory.constructorDeclaration2(null, null, Ast
Factory.identifier3("C"), "m", AstFactory.formalParameterList(), null, AstFactor
y.blockFunctionBody2())); |
| 1626 } | 1644 } |
| 1627 | 1645 |
| 1628 void test_visitConstructorDeclaration_singleInitializer() { | 1646 void test_visitConstructorDeclaration_singleInitializer() { |
| 1629 _assertSource("C() : a = b {}", AstFactory.constructorDeclaration2(null, nul
l, AstFactory.identifier3("C"), null, AstFactory.formalParameterList([]), AstFac
tory.list([AstFactory.constructorFieldInitializer(false, "a", AstFactory.identif
ier3("b"))]), AstFactory.blockFunctionBody2([]))); | 1647 _assertSource("C() : a = b {}", AstFactory.constructorDeclaration2( |
| 1648 null, |
| 1649 null, |
| 1650 AstFactory.identifier3("C"), |
| 1651 null, |
| 1652 AstFactory.formalParameterList(), |
| 1653 [AstFactory.constructorFieldInitializer(false, "a", AstFactory.identifie
r3("b"))], |
| 1654 AstFactory.blockFunctionBody2())); |
| 1630 } | 1655 } |
| 1631 | 1656 |
| 1632 void test_visitConstructorDeclaration_withMetadata() { | 1657 void test_visitConstructorDeclaration_withMetadata() { |
| 1633 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2(null
, null, AstFactory.identifier3("C"), null, AstFactory.formalParameterList([]), n
ull, AstFactory.blockFunctionBody2([])); | 1658 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2(null
, null, AstFactory.identifier3("C"), null, AstFactory.formalParameterList(), nul
l, AstFactory.blockFunctionBody2()); |
| 1634 declaration.metadata = AstFactory.list([AstFactory.annotation(AstFactory.ide
ntifier3("deprecated"))]); | 1659 declaration.metadata = [AstFactory.annotation(AstFactory.identifier3("deprec
ated"))]; |
| 1635 _assertSource("@deprecated C() {}", declaration); | 1660 _assertSource("@deprecated C() {}", declaration); |
| 1636 } | 1661 } |
| 1637 | 1662 |
| 1638 void test_visitConstructorFieldInitializer_withoutThis() { | 1663 void test_visitConstructorFieldInitializer_withoutThis() { |
| 1639 _assertSource("a = b", AstFactory.constructorFieldInitializer(false, "a", As
tFactory.identifier3("b"))); | 1664 _assertSource("a = b", AstFactory.constructorFieldInitializer(false, "a", As
tFactory.identifier3("b"))); |
| 1640 } | 1665 } |
| 1641 | 1666 |
| 1642 void test_visitConstructorFieldInitializer_withThis() { | 1667 void test_visitConstructorFieldInitializer_withThis() { |
| 1643 _assertSource("this.a = b", AstFactory.constructorFieldInitializer(true, "a"
, AstFactory.identifier3("b"))); | 1668 _assertSource("this.a = b", AstFactory.constructorFieldInitializer(true, "a"
, AstFactory.identifier3("b"))); |
| 1644 } | 1669 } |
| 1645 | 1670 |
| 1646 void test_visitConstructorName_named_prefix() { | 1671 void test_visitConstructorName_named_prefix() { |
| 1647 _assertSource("p.C.n", AstFactory.constructorName(AstFactory.typeName4("p.C.
n", []), null)); | 1672 _assertSource("p.C.n", AstFactory.constructorName(AstFactory.typeName4("p.C.
n"), null)); |
| 1648 } | 1673 } |
| 1649 | 1674 |
| 1650 void test_visitConstructorName_unnamed_noPrefix() { | 1675 void test_visitConstructorName_unnamed_noPrefix() { |
| 1651 _assertSource("C", AstFactory.constructorName(AstFactory.typeName4("C", []),
null)); | 1676 _assertSource("C", AstFactory.constructorName(AstFactory.typeName4("C"), nul
l)); |
| 1652 } | 1677 } |
| 1653 | 1678 |
| 1654 void test_visitConstructorName_unnamed_prefix() { | 1679 void test_visitConstructorName_unnamed_prefix() { |
| 1655 _assertSource("p.C", AstFactory.constructorName(AstFactory.typeName3(AstFact
ory.identifier5("p", "C"), []), null)); | 1680 _assertSource("p.C", AstFactory.constructorName(AstFactory.typeName3(AstFact
ory.identifier5("p", "C")), null)); |
| 1656 } | 1681 } |
| 1657 | 1682 |
| 1658 void test_visitContinueStatement_label() { | 1683 void test_visitContinueStatement_label() { |
| 1659 _assertSource("continue l;", AstFactory.continueStatement("l")); | 1684 _assertSource("continue l;", AstFactory.continueStatement("l")); |
| 1660 } | 1685 } |
| 1661 | 1686 |
| 1662 void test_visitContinueStatement_noLabel() { | 1687 void test_visitContinueStatement_noLabel() { |
| 1663 _assertSource("continue;", AstFactory.continueStatement()); | 1688 _assertSource("continue;", AstFactory.continueStatement()); |
| 1664 } | 1689 } |
| 1665 | 1690 |
| 1666 void test_visitDefaultFormalParameter_named_noValue() { | 1691 void test_visitDefaultFormalParameter_named_noValue() { |
| 1667 _assertSource("p", AstFactory.namedFormalParameter(AstFactory.simpleFormalPa
rameter3("p"), null)); | 1692 _assertSource("p", AstFactory.namedFormalParameter(AstFactory.simpleFormalPa
rameter3("p"), null)); |
| 1668 } | 1693 } |
| 1669 | 1694 |
| 1670 void test_visitDefaultFormalParameter_named_value() { | 1695 void test_visitDefaultFormalParameter_named_value() { |
| 1671 _assertSource("p : 0", AstFactory.namedFormalParameter(AstFactory.simpleForm
alParameter3("p"), AstFactory.integer(0))); | 1696 _assertSource("p : 0", AstFactory.namedFormalParameter(AstFactory.simpleForm
alParameter3("p"), AstFactory.integer(0))); |
| 1672 } | 1697 } |
| 1673 | 1698 |
| 1674 void test_visitDefaultFormalParameter_positional_noValue() { | 1699 void test_visitDefaultFormalParameter_positional_noValue() { |
| 1675 _assertSource("p", AstFactory.positionalFormalParameter(AstFactory.simpleFor
malParameter3("p"), null)); | 1700 _assertSource("p", AstFactory.positionalFormalParameter(AstFactory.simpleFor
malParameter3("p"), null)); |
| 1676 } | 1701 } |
| 1677 | 1702 |
| 1678 void test_visitDefaultFormalParameter_positional_value() { | 1703 void test_visitDefaultFormalParameter_positional_value() { |
| 1679 _assertSource("p = 0", AstFactory.positionalFormalParameter(AstFactory.simpl
eFormalParameter3("p"), AstFactory.integer(0))); | 1704 _assertSource("p = 0", AstFactory.positionalFormalParameter(AstFactory.simpl
eFormalParameter3("p"), AstFactory.integer(0))); |
| 1680 } | 1705 } |
| 1681 | 1706 |
| 1682 void test_visitDoStatement() { | 1707 void test_visitDoStatement() { |
| 1683 _assertSource("do {} while (c);", AstFactory.doStatement(AstFactory.block([]
), AstFactory.identifier3("c"))); | 1708 _assertSource("do {} while (c);", AstFactory.doStatement(AstFactory.block(),
AstFactory.identifier3("c"))); |
| 1684 } | 1709 } |
| 1685 | 1710 |
| 1686 void test_visitDoubleLiteral() { | 1711 void test_visitDoubleLiteral() { |
| 1687 _assertSource("4.2", AstFactory.doubleLiteral(4.2)); | 1712 _assertSource("4.2", AstFactory.doubleLiteral(4.2)); |
| 1688 } | 1713 } |
| 1689 | 1714 |
| 1690 void test_visitEmptyFunctionBody() { | 1715 void test_visitEmptyFunctionBody() { |
| 1691 _assertSource(";", AstFactory.emptyFunctionBody()); | 1716 _assertSource(";", AstFactory.emptyFunctionBody()); |
| 1692 } | 1717 } |
| 1693 | 1718 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1707 _assertSource("export 'a.dart' show A;", AstFactory.exportDirective2("a.dart
", [AstFactory.showCombinator([AstFactory.identifier3("A")])])); | 1732 _assertSource("export 'a.dart' show A;", AstFactory.exportDirective2("a.dart
", [AstFactory.showCombinator([AstFactory.identifier3("A")])])); |
| 1708 } | 1733 } |
| 1709 | 1734 |
| 1710 void test_visitExportDirective_combinators() { | 1735 void test_visitExportDirective_combinators() { |
| 1711 _assertSource("export 'a.dart' show A hide B;", AstFactory.exportDirective2(
"a.dart", [ | 1736 _assertSource("export 'a.dart' show A hide B;", AstFactory.exportDirective2(
"a.dart", [ |
| 1712 AstFactory.showCombinator([AstFactory.identifier3("A")]), | 1737 AstFactory.showCombinator([AstFactory.identifier3("A")]), |
| 1713 AstFactory.hideCombinator([AstFactory.identifier3("B")])])); | 1738 AstFactory.hideCombinator([AstFactory.identifier3("B")])])); |
| 1714 } | 1739 } |
| 1715 | 1740 |
| 1716 void test_visitExportDirective_minimal() { | 1741 void test_visitExportDirective_minimal() { |
| 1717 _assertSource("export 'a.dart';", AstFactory.exportDirective2("a.dart", []))
; | 1742 _assertSource("export 'a.dart';", AstFactory.exportDirective2("a.dart")); |
| 1718 } | 1743 } |
| 1719 | 1744 |
| 1720 void test_visitExportDirective_withMetadata() { | 1745 void test_visitExportDirective_withMetadata() { |
| 1721 ExportDirective directive = AstFactory.exportDirective2("a.dart", []); | 1746 ExportDirective directive = AstFactory.exportDirective2("a.dart"); |
| 1722 directive.metadata = AstFactory.list([AstFactory.annotation(AstFactory.ident
ifier3("deprecated"))]); | 1747 directive.metadata = [AstFactory.annotation(AstFactory.identifier3("deprecat
ed"))]; |
| 1723 _assertSource("@deprecated export 'a.dart';", directive); | 1748 _assertSource("@deprecated export 'a.dart';", directive); |
| 1724 } | 1749 } |
| 1725 | 1750 |
| 1726 void test_visitExpressionFunctionBody_async() { | 1751 void test_visitExpressionFunctionBody_async() { |
| 1727 _assertSource("async => a;", AstFactory.asyncExpressionFunctionBody(AstFacto
ry.identifier3("a"))); | 1752 _assertSource("async => a;", AstFactory.asyncExpressionFunctionBody(AstFacto
ry.identifier3("a"))); |
| 1728 } | 1753 } |
| 1729 | 1754 |
| 1730 void test_visitExpressionFunctionBody_simple() { | 1755 void test_visitExpressionFunctionBody_simple() { |
| 1731 _assertSource("=> a;", AstFactory.expressionFunctionBody(AstFactory.identifi
er3("a"))); | 1756 _assertSource("=> a;", AstFactory.expressionFunctionBody(AstFactory.identifi
er3("a"))); |
| 1732 } | 1757 } |
| 1733 | 1758 |
| 1734 void test_visitExpressionStatement() { | 1759 void test_visitExpressionStatement() { |
| 1735 _assertSource("a;", AstFactory.expressionStatement(AstFactory.identifier3("a
"))); | 1760 _assertSource("a;", AstFactory.expressionStatement(AstFactory.identifier3("a
"))); |
| 1736 } | 1761 } |
| 1737 | 1762 |
| 1738 void test_visitExtendsClause() { | 1763 void test_visitExtendsClause() { |
| 1739 _assertSource("extends C", AstFactory.extendsClause(AstFactory.typeName4("C"
, []))); | 1764 _assertSource("extends C", AstFactory.extendsClause(AstFactory.typeName4("C"
))); |
| 1740 } | 1765 } |
| 1741 | 1766 |
| 1742 void test_visitFieldDeclaration_instance() { | 1767 void test_visitFieldDeclaration_instance() { |
| 1743 _assertSource("var a;", AstFactory.fieldDeclaration2(false, Keyword.VAR, [As
tFactory.variableDeclaration("a")])); | 1768 _assertSource("var a;", AstFactory.fieldDeclaration2(false, Keyword.VAR, [As
tFactory.variableDeclaration("a")])); |
| 1744 } | 1769 } |
| 1745 | 1770 |
| 1746 void test_visitFieldDeclaration_static() { | 1771 void test_visitFieldDeclaration_static() { |
| 1747 _assertSource("static var a;", AstFactory.fieldDeclaration2(true, Keyword.VA
R, [AstFactory.variableDeclaration("a")])); | 1772 _assertSource("static var a;", AstFactory.fieldDeclaration2(true, Keyword.VA
R, [AstFactory.variableDeclaration("a")])); |
| 1748 } | 1773 } |
| 1749 | 1774 |
| 1750 void test_visitFieldDeclaration_withMetadata() { | 1775 void test_visitFieldDeclaration_withMetadata() { |
| 1751 FieldDeclaration declaration = AstFactory.fieldDeclaration2(false, Keyword.V
AR, [AstFactory.variableDeclaration("a")]); | 1776 FieldDeclaration declaration = AstFactory.fieldDeclaration2(false, Keyword.V
AR, [AstFactory.variableDeclaration("a")]); |
| 1752 declaration.metadata = AstFactory.list([AstFactory.annotation(AstFactory.ide
ntifier3("deprecated"))]); | 1777 declaration.metadata = [AstFactory.annotation(AstFactory.identifier3("deprec
ated"))]; |
| 1753 _assertSource("@deprecated var a;", declaration); | 1778 _assertSource("@deprecated var a;", declaration); |
| 1754 } | 1779 } |
| 1755 | 1780 |
| 1756 void test_visitFieldFormalParameter_functionTyped() { | 1781 void test_visitFieldFormalParameter_functionTyped() { |
| 1757 _assertSource("A this.a(b)", AstFactory.fieldFormalParameter(null, AstFactor
y.typeName4("A", []), "a", AstFactory.formalParameterList([AstFactory.simpleForm
alParameter3("b")]))); | 1782 _assertSource("A this.a(b)", AstFactory.fieldFormalParameter(null, AstFactor
y.typeName4("A"), "a", AstFactory.formalParameterList([AstFactory.simpleFormalPa
rameter3("b")]))); |
| 1758 } | 1783 } |
| 1759 | 1784 |
| 1760 void test_visitFieldFormalParameter_keyword() { | 1785 void test_visitFieldFormalParameter_keyword() { |
| 1761 _assertSource("var this.a", AstFactory.fieldFormalParameter(Keyword.VAR, nul
l, "a")); | 1786 _assertSource("var this.a", AstFactory.fieldFormalParameter(Keyword.VAR, nul
l, "a")); |
| 1762 } | 1787 } |
| 1763 | 1788 |
| 1764 void test_visitFieldFormalParameter_keywordAndType() { | 1789 void test_visitFieldFormalParameter_keywordAndType() { |
| 1765 _assertSource("final A this.a", AstFactory.fieldFormalParameter(Keyword.FINA
L, AstFactory.typeName4("A", []), "a")); | 1790 _assertSource("final A this.a", AstFactory.fieldFormalParameter(Keyword.FINA
L, AstFactory.typeName4("A"), "a")); |
| 1766 } | 1791 } |
| 1767 | 1792 |
| 1768 void test_visitFieldFormalParameter_type() { | 1793 void test_visitFieldFormalParameter_type() { |
| 1769 _assertSource("A this.a", AstFactory.fieldFormalParameter(null, AstFactory.t
ypeName4("A", []), "a")); | 1794 _assertSource("A this.a", AstFactory.fieldFormalParameter(null, AstFactory.t
ypeName4("A"), "a")); |
| 1770 } | 1795 } |
| 1771 | 1796 |
| 1772 void test_visitForEachStatement_declared() { | 1797 void test_visitForEachStatement_declared() { |
| 1773 _assertSource("for (a in b) {}", AstFactory.forEachStatement(AstFactory.decl
aredIdentifier3("a"), AstFactory.identifier3("b"), AstFactory.block([]))); | 1798 _assertSource("for (a in b) {}", AstFactory.forEachStatement(AstFactory.decl
aredIdentifier3("a"), AstFactory.identifier3("b"), AstFactory.block())); |
| 1774 } | 1799 } |
| 1775 | 1800 |
| 1776 void test_visitForEachStatement_variable() { | 1801 void test_visitForEachStatement_variable() { |
| 1777 _assertSource("for (a in b) {}", new ForEachStatement.con2(null, TokenFactor
y.tokenFromKeyword(Keyword.FOR), TokenFactory.tokenFromType(TokenType.OPEN_PAREN
), AstFactory.identifier3("a"), TokenFactory.tokenFromKeyword(Keyword.IN), AstFa
ctory.identifier3("b"), TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), AstFa
ctory.block([]))); | 1802 _assertSource("for (a in b) {}", new ForEachStatement.con2(null, TokenFactor
y.tokenFromKeyword(Keyword.FOR), TokenFactory.tokenFromType(TokenType.OPEN_PAREN
), AstFactory.identifier3("a"), TokenFactory.tokenFromKeyword(Keyword.IN), AstFa
ctory.identifier3("b"), TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), AstFa
ctory.block())); |
| 1778 } | 1803 } |
| 1779 | 1804 |
| 1780 void test_visitForEachStatement_variable_await() { | 1805 void test_visitForEachStatement_variable_await() { |
| 1781 _assertSource("await for (a in b) {}", new ForEachStatement.con2(TokenFactor
y.tokenFromString("await"), TokenFactory.tokenFromKeyword(Keyword.FOR), TokenFac
tory.tokenFromType(TokenType.OPEN_PAREN), AstFactory.identifier3("a"), TokenFact
ory.tokenFromKeyword(Keyword.IN), AstFactory.identifier3("b"), TokenFactory.toke
nFromType(TokenType.CLOSE_PAREN), AstFactory.block([]))); | 1806 _assertSource("await for (a in b) {}", new ForEachStatement.con2(TokenFactor
y.tokenFromString("await"), TokenFactory.tokenFromKeyword(Keyword.FOR), TokenFac
tory.tokenFromType(TokenType.OPEN_PAREN), AstFactory.identifier3("a"), TokenFact
ory.tokenFromKeyword(Keyword.IN), AstFactory.identifier3("b"), TokenFactory.toke
nFromType(TokenType.CLOSE_PAREN), AstFactory.block())); |
| 1782 } | 1807 } |
| 1783 | 1808 |
| 1784 void test_visitFormalParameterList_empty() { | 1809 void test_visitFormalParameterList_empty() { |
| 1785 _assertSource("()", AstFactory.formalParameterList([])); | 1810 _assertSource("()", AstFactory.formalParameterList()); |
| 1786 } | 1811 } |
| 1787 | 1812 |
| 1788 void test_visitFormalParameterList_n() { | 1813 void test_visitFormalParameterList_n() { |
| 1789 _assertSource("({a : 0})", AstFactory.formalParameterList([AstFactory.namedF
ormalParameter(AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0))]))
; | 1814 _assertSource("({a : 0})", AstFactory.formalParameterList([AstFactory.namedF
ormalParameter(AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0))]))
; |
| 1790 } | 1815 } |
| 1791 | 1816 |
| 1792 void test_visitFormalParameterList_nn() { | 1817 void test_visitFormalParameterList_nn() { |
| 1793 _assertSource("({a : 0, b : 1})", AstFactory.formalParameterList([ | 1818 _assertSource("({a : 0, b : 1})", AstFactory.formalParameterList([ |
| 1794 AstFactory.namedFormalParameter(AstFactory.simpleFormalParameter3("a"),
AstFactory.integer(0)), | 1819 AstFactory.namedFormalParameter(AstFactory.simpleFormalParameter3("a"),
AstFactory.integer(0)), |
| 1795 AstFactory.namedFormalParameter(AstFactory.simpleFormalParameter3("b"),
AstFactory.integer(1))])); | 1820 AstFactory.namedFormalParameter(AstFactory.simpleFormalParameter3("b"),
AstFactory.integer(1))])); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1865 | 1890 |
| 1866 void test_visitFormalParameterList_rrpp() { | 1891 void test_visitFormalParameterList_rrpp() { |
| 1867 _assertSource("(a, b, [c = 3, d = 4])", AstFactory.formalParameterList([ | 1892 _assertSource("(a, b, [c = 3, d = 4])", AstFactory.formalParameterList([ |
| 1868 AstFactory.simpleFormalParameter3("a"), | 1893 AstFactory.simpleFormalParameter3("a"), |
| 1869 AstFactory.simpleFormalParameter3("b"), | 1894 AstFactory.simpleFormalParameter3("b"), |
| 1870 AstFactory.positionalFormalParameter(AstFactory.simpleFormalParameter3("
c"), AstFactory.integer(3)), | 1895 AstFactory.positionalFormalParameter(AstFactory.simpleFormalParameter3("
c"), AstFactory.integer(3)), |
| 1871 AstFactory.positionalFormalParameter(AstFactory.simpleFormalParameter3("
d"), AstFactory.integer(4))])); | 1896 AstFactory.positionalFormalParameter(AstFactory.simpleFormalParameter3("
d"), AstFactory.integer(4))])); |
| 1872 } | 1897 } |
| 1873 | 1898 |
| 1874 void test_visitForStatement_c() { | 1899 void test_visitForStatement_c() { |
| 1875 _assertSource("for (; c;) {}", AstFactory.forStatement(null, AstFactory.iden
tifier3("c"), null, AstFactory.block([]))); | 1900 _assertSource("for (; c;) {}", AstFactory.forStatement(null, AstFactory.iden
tifier3("c"), null, AstFactory.block())); |
| 1876 } | 1901 } |
| 1877 | 1902 |
| 1878 void test_visitForStatement_cu() { | 1903 void test_visitForStatement_cu() { |
| 1879 _assertSource("for (; c; u) {}", AstFactory.forStatement(null, AstFactory.id
entifier3("c"), AstFactory.list([AstFactory.identifier3("u")]), AstFactory.block
([]))); | 1904 _assertSource("for (; c; u) {}", AstFactory.forStatement(null, AstFactory.id
entifier3("c"), [AstFactory.identifier3("u")], AstFactory.block())); |
| 1880 } | 1905 } |
| 1881 | 1906 |
| 1882 void test_visitForStatement_e() { | 1907 void test_visitForStatement_e() { |
| 1883 _assertSource("for (e;;) {}", AstFactory.forStatement(AstFactory.identifier3
("e"), null, null, AstFactory.block([]))); | 1908 _assertSource("for (e;;) {}", AstFactory.forStatement(AstFactory.identifier3
("e"), null, null, AstFactory.block())); |
| 1884 } | 1909 } |
| 1885 | 1910 |
| 1886 void test_visitForStatement_ec() { | 1911 void test_visitForStatement_ec() { |
| 1887 _assertSource("for (e; c;) {}", AstFactory.forStatement(AstFactory.identifie
r3("e"), AstFactory.identifier3("c"), null, AstFactory.block([]))); | 1912 _assertSource("for (e; c;) {}", AstFactory.forStatement(AstFactory.identifie
r3("e"), AstFactory.identifier3("c"), null, AstFactory.block())); |
| 1888 } | 1913 } |
| 1889 | 1914 |
| 1890 void test_visitForStatement_ecu() { | 1915 void test_visitForStatement_ecu() { |
| 1891 _assertSource("for (e; c; u) {}", AstFactory.forStatement(AstFactory.identif
ier3("e"), AstFactory.identifier3("c"), AstFactory.list([AstFactory.identifier3(
"u")]), AstFactory.block([]))); | 1916 _assertSource("for (e; c; u) {}", AstFactory.forStatement(AstFactory.identif
ier3("e"), AstFactory.identifier3("c"), [AstFactory.identifier3("u")], AstFactor
y.block())); |
| 1892 } | 1917 } |
| 1893 | 1918 |
| 1894 void test_visitForStatement_eu() { | 1919 void test_visitForStatement_eu() { |
| 1895 _assertSource("for (e;; u) {}", AstFactory.forStatement(AstFactory.identifie
r3("e"), null, AstFactory.list([AstFactory.identifier3("u")]), AstFactory.block(
[]))); | 1920 _assertSource("for (e;; u) {}", AstFactory.forStatement(AstFactory.identifie
r3("e"), null, [AstFactory.identifier3("u")], AstFactory.block())); |
| 1896 } | 1921 } |
| 1897 | 1922 |
| 1898 void test_visitForStatement_i() { | 1923 void test_visitForStatement_i() { |
| 1899 _assertSource("for (var i;;) {}", AstFactory.forStatement2(AstFactory.variab
leDeclarationList2(Keyword.VAR, [AstFactory.variableDeclaration("i")]), null, nu
ll, AstFactory.block([]))); | 1924 _assertSource("for (var i;;) {}", AstFactory.forStatement2(AstFactory.variab
leDeclarationList2(Keyword.VAR, [AstFactory.variableDeclaration("i")]), null, nu
ll, AstFactory.block())); |
| 1900 } | 1925 } |
| 1901 | 1926 |
| 1902 void test_visitForStatement_ic() { | 1927 void test_visitForStatement_ic() { |
| 1903 _assertSource("for (var i; c;) {}", AstFactory.forStatement2(AstFactory.vari
ableDeclarationList2(Keyword.VAR, [AstFactory.variableDeclaration("i")]), AstFac
tory.identifier3("c"), null, AstFactory.block([]))); | 1928 _assertSource("for (var i; c;) {}", AstFactory.forStatement2(AstFactory.vari
ableDeclarationList2(Keyword.VAR, [AstFactory.variableDeclaration("i")]), AstFac
tory.identifier3("c"), null, AstFactory.block())); |
| 1904 } | 1929 } |
| 1905 | 1930 |
| 1906 void test_visitForStatement_icu() { | 1931 void test_visitForStatement_icu() { |
| 1907 _assertSource("for (var i; c; u) {}", AstFactory.forStatement2(AstFactory.va
riableDeclarationList2(Keyword.VAR, [AstFactory.variableDeclaration("i")]), AstF
actory.identifier3("c"), AstFactory.list([AstFactory.identifier3("u")]), AstFact
ory.block([]))); | 1932 _assertSource("for (var i; c; u) {}", AstFactory.forStatement2(AstFactory.va
riableDeclarationList2(Keyword.VAR, [AstFactory.variableDeclaration("i")]), AstF
actory.identifier3("c"), [AstFactory.identifier3("u")], AstFactory.block())); |
| 1908 } | 1933 } |
| 1909 | 1934 |
| 1910 void test_visitForStatement_iu() { | 1935 void test_visitForStatement_iu() { |
| 1911 _assertSource("for (var i;; u) {}", AstFactory.forStatement2(AstFactory.vari
ableDeclarationList2(Keyword.VAR, [AstFactory.variableDeclaration("i")]), null,
AstFactory.list([AstFactory.identifier3("u")]), AstFactory.block([]))); | 1936 _assertSource("for (var i;; u) {}", AstFactory.forStatement2(AstFactory.vari
ableDeclarationList2(Keyword.VAR, [AstFactory.variableDeclaration("i")]), null,
[AstFactory.identifier3("u")], AstFactory.block())); |
| 1912 } | 1937 } |
| 1913 | 1938 |
| 1914 void test_visitForStatement_u() { | 1939 void test_visitForStatement_u() { |
| 1915 _assertSource("for (;; u) {}", AstFactory.forStatement(null, null, AstFactor
y.list([AstFactory.identifier3("u")]), AstFactory.block([]))); | 1940 _assertSource("for (;; u) {}", AstFactory.forStatement(null, null, [AstFacto
ry.identifier3("u")], AstFactory.block())); |
| 1916 } | 1941 } |
| 1917 | 1942 |
| 1918 void test_visitFunctionDeclaration_getter() { | 1943 void test_visitFunctionDeclaration_getter() { |
| 1919 _assertSource("get f() {}", AstFactory.functionDeclaration(null, Keyword.GET
, "f", AstFactory.functionExpression())); | 1944 _assertSource("get f() {}", AstFactory.functionDeclaration(null, Keyword.GET
, "f", AstFactory.functionExpression())); |
| 1920 } | 1945 } |
| 1921 | 1946 |
| 1922 void test_visitFunctionDeclaration_local_blockBody() { | 1947 void test_visitFunctionDeclaration_local_blockBody() { |
| 1923 FunctionDeclaration f = AstFactory.functionDeclaration(null, null, "f", AstF
actory.functionExpression()); | 1948 FunctionDeclaration f = AstFactory.functionDeclaration(null, null, "f", AstF
actory.functionExpression()); |
| 1924 FunctionDeclarationStatement fStatement = new FunctionDeclarationStatement(f
); | 1949 FunctionDeclarationStatement fStatement = new FunctionDeclarationStatement(f
); |
| 1925 _assertSource("main() {f() {} 42;}", AstFactory.functionDeclaration(null, nu
ll, "main", AstFactory.functionExpression2(AstFactory.formalParameterList([]), A
stFactory.blockFunctionBody2([ | 1950 _assertSource("main() {f() {} 42;}", AstFactory.functionDeclaration(null, nu
ll, "main", AstFactory.functionExpression2(AstFactory.formalParameterList(), Ast
Factory.blockFunctionBody2([ |
| 1926 fStatement, | 1951 fStatement, |
| 1927 AstFactory.expressionStatement(AstFactory.integer(42))])))); | 1952 AstFactory.expressionStatement(AstFactory.integer(42))])))); |
| 1928 } | 1953 } |
| 1929 | 1954 |
| 1930 void test_visitFunctionDeclaration_local_expressionBody() { | 1955 void test_visitFunctionDeclaration_local_expressionBody() { |
| 1931 FunctionDeclaration f = AstFactory.functionDeclaration(null, null, "f", AstF
actory.functionExpression2(AstFactory.formalParameterList([]), AstFactory.expres
sionFunctionBody(AstFactory.integer(1)))); | 1956 FunctionDeclaration f = AstFactory.functionDeclaration(null, null, "f", AstF
actory.functionExpression2(AstFactory.formalParameterList(), AstFactory.expressi
onFunctionBody(AstFactory.integer(1)))); |
| 1932 FunctionDeclarationStatement fStatement = new FunctionDeclarationStatement(f
); | 1957 FunctionDeclarationStatement fStatement = new FunctionDeclarationStatement(f
); |
| 1933 _assertSource("main() {f() => 1; 2;}", AstFactory.functionDeclaration(null,
null, "main", AstFactory.functionExpression2(AstFactory.formalParameterList([]),
AstFactory.blockFunctionBody2([ | 1958 _assertSource("main() {f() => 1; 2;}", AstFactory.functionDeclaration(null,
null, "main", AstFactory.functionExpression2(AstFactory.formalParameterList(), A
stFactory.blockFunctionBody2([ |
| 1934 fStatement, | 1959 fStatement, |
| 1935 AstFactory.expressionStatement(AstFactory.integer(2))])))); | 1960 AstFactory.expressionStatement(AstFactory.integer(2))])))); |
| 1936 } | 1961 } |
| 1937 | 1962 |
| 1938 void test_visitFunctionDeclaration_normal() { | 1963 void test_visitFunctionDeclaration_normal() { |
| 1939 _assertSource("f() {}", AstFactory.functionDeclaration(null, null, "f", AstF
actory.functionExpression())); | 1964 _assertSource("f() {}", AstFactory.functionDeclaration(null, null, "f", AstF
actory.functionExpression())); |
| 1940 } | 1965 } |
| 1941 | 1966 |
| 1942 void test_visitFunctionDeclaration_setter() { | 1967 void test_visitFunctionDeclaration_setter() { |
| 1943 _assertSource("set f() {}", AstFactory.functionDeclaration(null, Keyword.SET
, "f", AstFactory.functionExpression())); | 1968 _assertSource("set f() {}", AstFactory.functionDeclaration(null, Keyword.SET
, "f", AstFactory.functionExpression())); |
| 1944 } | 1969 } |
| 1945 | 1970 |
| 1946 void test_visitFunctionDeclaration_withMetadata() { | 1971 void test_visitFunctionDeclaration_withMetadata() { |
| 1947 FunctionDeclaration declaration = AstFactory.functionDeclaration(null, null,
"f", AstFactory.functionExpression()); | 1972 FunctionDeclaration declaration = AstFactory.functionDeclaration(null, null,
"f", AstFactory.functionExpression()); |
| 1948 declaration.metadata = AstFactory.list([AstFactory.annotation(AstFactory.ide
ntifier3("deprecated"))]); | 1973 declaration.metadata = [AstFactory.annotation(AstFactory.identifier3("deprec
ated"))]; |
| 1949 _assertSource("@deprecated f() {}", declaration); | 1974 _assertSource("@deprecated f() {}", declaration); |
| 1950 } | 1975 } |
| 1951 | 1976 |
| 1952 void test_visitFunctionDeclarationStatement() { | 1977 void test_visitFunctionDeclarationStatement() { |
| 1953 _assertSource("f() {}", AstFactory.functionDeclarationStatement(null, null,
"f", AstFactory.functionExpression())); | 1978 _assertSource("f() {}", AstFactory.functionDeclarationStatement(null, null,
"f", AstFactory.functionExpression())); |
| 1954 } | 1979 } |
| 1955 | 1980 |
| 1956 void test_visitFunctionExpression() { | 1981 void test_visitFunctionExpression() { |
| 1957 _assertSource("() {}", AstFactory.functionExpression()); | 1982 _assertSource("() {}", AstFactory.functionExpression()); |
| 1958 } | 1983 } |
| 1959 | 1984 |
| 1960 void test_visitFunctionExpressionInvocation() { | 1985 void test_visitFunctionExpressionInvocation() { |
| 1961 _assertSource("f()", AstFactory.functionExpressionInvocation(AstFactory.iden
tifier3("f"), [])); | 1986 _assertSource("f()", AstFactory.functionExpressionInvocation(AstFactory.iden
tifier3("f"))); |
| 1962 } | 1987 } |
| 1963 | 1988 |
| 1964 void test_visitFunctionTypeAlias_generic() { | 1989 void test_visitFunctionTypeAlias_generic() { |
| 1965 _assertSource("typedef A F<B>();", AstFactory.typeAlias(AstFactory.typeName4
("A", []), "F", AstFactory.typeParameterList(["B"]), AstFactory.formalParameterL
ist([]))); | 1990 _assertSource("typedef A F<B>();", AstFactory.typeAlias(AstFactory.typeName4
("A"), "F", AstFactory.typeParameterList(["B"]), AstFactory.formalParameterList(
))); |
| 1966 } | 1991 } |
| 1967 | 1992 |
| 1968 void test_visitFunctionTypeAlias_nonGeneric() { | 1993 void test_visitFunctionTypeAlias_nonGeneric() { |
| 1969 _assertSource("typedef A F();", AstFactory.typeAlias(AstFactory.typeName4("A
", []), "F", null, AstFactory.formalParameterList([]))); | 1994 _assertSource("typedef A F();", AstFactory.typeAlias(AstFactory.typeName4("A
"), "F", null, AstFactory.formalParameterList())); |
| 1970 } | 1995 } |
| 1971 | 1996 |
| 1972 void test_visitFunctionTypeAlias_withMetadata() { | 1997 void test_visitFunctionTypeAlias_withMetadata() { |
| 1973 FunctionTypeAlias declaration = AstFactory.typeAlias(AstFactory.typeName4("A
", []), "F", null, AstFactory.formalParameterList([])); | 1998 FunctionTypeAlias declaration = AstFactory.typeAlias(AstFactory.typeName4("A
"), "F", null, AstFactory.formalParameterList()); |
| 1974 declaration.metadata = AstFactory.list([AstFactory.annotation(AstFactory.ide
ntifier3("deprecated"))]); | 1999 declaration.metadata = [AstFactory.annotation(AstFactory.identifier3("deprec
ated"))]; |
| 1975 _assertSource("@deprecated typedef A F();", declaration); | 2000 _assertSource("@deprecated typedef A F();", declaration); |
| 1976 } | 2001 } |
| 1977 | 2002 |
| 1978 void test_visitFunctionTypedFormalParameter_noType() { | 2003 void test_visitFunctionTypedFormalParameter_noType() { |
| 1979 _assertSource("f()", AstFactory.functionTypedFormalParameter(null, "f", []))
; | 2004 _assertSource("f()", AstFactory.functionTypedFormalParameter(null, "f")); |
| 1980 } | 2005 } |
| 1981 | 2006 |
| 1982 void test_visitFunctionTypedFormalParameter_type() { | 2007 void test_visitFunctionTypedFormalParameter_type() { |
| 1983 _assertSource("T f()", AstFactory.functionTypedFormalParameter(AstFactory.ty
peName4("T", []), "f", [])); | 2008 _assertSource("T f()", AstFactory.functionTypedFormalParameter(AstFactory.ty
peName4("T"), "f")); |
| 1984 } | 2009 } |
| 1985 | 2010 |
| 1986 void test_visitIfStatement_withElse() { | 2011 void test_visitIfStatement_withElse() { |
| 1987 _assertSource("if (c) {} else {}", AstFactory.ifStatement2(AstFactory.identi
fier3("c"), AstFactory.block([]), AstFactory.block([]))); | 2012 _assertSource("if (c) {} else {}", AstFactory.ifStatement2(AstFactory.identi
fier3("c"), AstFactory.block(), AstFactory.block())); |
| 1988 } | 2013 } |
| 1989 | 2014 |
| 1990 void test_visitIfStatement_withoutElse() { | 2015 void test_visitIfStatement_withoutElse() { |
| 1991 _assertSource("if (c) {}", AstFactory.ifStatement(AstFactory.identifier3("c"
), AstFactory.block([]))); | 2016 _assertSource("if (c) {}", AstFactory.ifStatement(AstFactory.identifier3("c"
), AstFactory.block())); |
| 1992 } | 2017 } |
| 1993 | 2018 |
| 1994 void test_visitImplementsClause_multiple() { | 2019 void test_visitImplementsClause_multiple() { |
| 1995 _assertSource("implements A, B", AstFactory.implementsClause([ | 2020 _assertSource("implements A, B", AstFactory.implementsClause([ |
| 1996 AstFactory.typeName4("A", []), | 2021 AstFactory.typeName4("A"), |
| 1997 AstFactory.typeName4("B", [])])); | 2022 AstFactory.typeName4("B")])); |
| 1998 } | 2023 } |
| 1999 | 2024 |
| 2000 void test_visitImplementsClause_single() { | 2025 void test_visitImplementsClause_single() { |
| 2001 _assertSource("implements A", AstFactory.implementsClause([AstFactory.typeNa
me4("A", [])])); | 2026 _assertSource("implements A", AstFactory.implementsClause([AstFactory.typeNa
me4("A")])); |
| 2002 } | 2027 } |
| 2003 | 2028 |
| 2004 void test_visitImportDirective_combinator() { | 2029 void test_visitImportDirective_combinator() { |
| 2005 _assertSource("import 'a.dart' show A;", AstFactory.importDirective3("a.dart
", null, [AstFactory.showCombinator([AstFactory.identifier3("A")])])); | 2030 _assertSource("import 'a.dart' show A;", AstFactory.importDirective3("a.dart
", null, [AstFactory.showCombinator([AstFactory.identifier3("A")])])); |
| 2006 } | 2031 } |
| 2007 | 2032 |
| 2008 void test_visitImportDirective_combinators() { | 2033 void test_visitImportDirective_combinators() { |
| 2009 _assertSource("import 'a.dart' show A hide B;", AstFactory.importDirective3(
"a.dart", null, [ | 2034 _assertSource("import 'a.dart' show A hide B;", AstFactory.importDirective3(
"a.dart", null, [ |
| 2010 AstFactory.showCombinator([AstFactory.identifier3("A")]), | 2035 AstFactory.showCombinator([AstFactory.identifier3("A")]), |
| 2011 AstFactory.hideCombinator([AstFactory.identifier3("B")])])); | 2036 AstFactory.hideCombinator([AstFactory.identifier3("B")])])); |
| 2012 } | 2037 } |
| 2013 | 2038 |
| 2014 void test_visitImportDirective_deferred() { | 2039 void test_visitImportDirective_deferred() { |
| 2015 _assertSource("import 'a.dart' deferred as p;", AstFactory.importDirective2(
"a.dart", true, "p", [])); | 2040 _assertSource("import 'a.dart' deferred as p;", AstFactory.importDirective2(
"a.dart", true, "p")); |
| 2016 } | 2041 } |
| 2017 | 2042 |
| 2018 void test_visitImportDirective_minimal() { | 2043 void test_visitImportDirective_minimal() { |
| 2019 _assertSource("import 'a.dart';", AstFactory.importDirective3("a.dart", null
, [])); | 2044 _assertSource("import 'a.dart';", AstFactory.importDirective3("a.dart", null
)); |
| 2020 } | 2045 } |
| 2021 | 2046 |
| 2022 void test_visitImportDirective_prefix() { | 2047 void test_visitImportDirective_prefix() { |
| 2023 _assertSource("import 'a.dart' as p;", AstFactory.importDirective3("a.dart",
"p", [])); | 2048 _assertSource("import 'a.dart' as p;", AstFactory.importDirective3("a.dart",
"p")); |
| 2024 } | 2049 } |
| 2025 | 2050 |
| 2026 void test_visitImportDirective_prefix_combinator() { | 2051 void test_visitImportDirective_prefix_combinator() { |
| 2027 _assertSource("import 'a.dart' as p show A;", AstFactory.importDirective3("a
.dart", "p", [AstFactory.showCombinator([AstFactory.identifier3("A")])])); | 2052 _assertSource("import 'a.dart' as p show A;", AstFactory.importDirective3("a
.dart", "p", [AstFactory.showCombinator([AstFactory.identifier3("A")])])); |
| 2028 } | 2053 } |
| 2029 | 2054 |
| 2030 void test_visitImportDirective_prefix_combinators() { | 2055 void test_visitImportDirective_prefix_combinators() { |
| 2031 _assertSource("import 'a.dart' as p show A hide B;", AstFactory.importDirect
ive3("a.dart", "p", [ | 2056 _assertSource("import 'a.dart' as p show A hide B;", AstFactory.importDirect
ive3("a.dart", "p", [ |
| 2032 AstFactory.showCombinator([AstFactory.identifier3("A")]), | 2057 AstFactory.showCombinator([AstFactory.identifier3("A")]), |
| 2033 AstFactory.hideCombinator([AstFactory.identifier3("B")])])); | 2058 AstFactory.hideCombinator([AstFactory.identifier3("B")])])); |
| 2034 } | 2059 } |
| 2035 | 2060 |
| 2036 void test_visitImportDirective_withMetadata() { | 2061 void test_visitImportDirective_withMetadata() { |
| 2037 ImportDirective directive = AstFactory.importDirective3("a.dart", null, []); | 2062 ImportDirective directive = AstFactory.importDirective3("a.dart", null); |
| 2038 directive.metadata = AstFactory.list([AstFactory.annotation(AstFactory.ident
ifier3("deprecated"))]); | 2063 directive.metadata = [AstFactory.annotation(AstFactory.identifier3("deprecat
ed"))]; |
| 2039 _assertSource("@deprecated import 'a.dart';", directive); | 2064 _assertSource("@deprecated import 'a.dart';", directive); |
| 2040 } | 2065 } |
| 2041 | 2066 |
| 2042 void test_visitImportHideCombinator_multiple() { | 2067 void test_visitImportHideCombinator_multiple() { |
| 2043 _assertSource("hide a, b", AstFactory.hideCombinator([AstFactory.identifier3
("a"), AstFactory.identifier3("b")])); | 2068 _assertSource("hide a, b", AstFactory.hideCombinator([AstFactory.identifier3
("a"), AstFactory.identifier3("b")])); |
| 2044 } | 2069 } |
| 2045 | 2070 |
| 2046 void test_visitImportHideCombinator_single() { | 2071 void test_visitImportHideCombinator_single() { |
| 2047 _assertSource("hide a", AstFactory.hideCombinator([AstFactory.identifier3("a
")])); | 2072 _assertSource("hide a", AstFactory.hideCombinator([AstFactory.identifier3("a
")])); |
| 2048 } | 2073 } |
| 2049 | 2074 |
| 2050 void test_visitImportShowCombinator_multiple() { | 2075 void test_visitImportShowCombinator_multiple() { |
| 2051 _assertSource("show a, b", AstFactory.showCombinator([AstFactory.identifier3
("a"), AstFactory.identifier3("b")])); | 2076 _assertSource("show a, b", AstFactory.showCombinator([AstFactory.identifier3
("a"), AstFactory.identifier3("b")])); |
| 2052 } | 2077 } |
| 2053 | 2078 |
| 2054 void test_visitImportShowCombinator_single() { | 2079 void test_visitImportShowCombinator_single() { |
| 2055 _assertSource("show a", AstFactory.showCombinator([AstFactory.identifier3("a
")])); | 2080 _assertSource("show a", AstFactory.showCombinator([AstFactory.identifier3("a
")])); |
| 2056 } | 2081 } |
| 2057 | 2082 |
| 2058 void test_visitIndexExpression() { | 2083 void test_visitIndexExpression() { |
| 2059 _assertSource("a[i]", AstFactory.indexExpression(AstFactory.identifier3("a")
, AstFactory.identifier3("i"))); | 2084 _assertSource("a[i]", AstFactory.indexExpression(AstFactory.identifier3("a")
, AstFactory.identifier3("i"))); |
| 2060 } | 2085 } |
| 2061 | 2086 |
| 2062 void test_visitInstanceCreationExpression_const() { | 2087 void test_visitInstanceCreationExpression_const() { |
| 2063 _assertSource("const C()", AstFactory.instanceCreationExpression2(Keyword.CO
NST, AstFactory.typeName4("C", []), [])); | 2088 _assertSource("const C()", AstFactory.instanceCreationExpression2(Keyword.CO
NST, AstFactory.typeName4("C"))); |
| 2064 } | 2089 } |
| 2065 | 2090 |
| 2066 void test_visitInstanceCreationExpression_named() { | 2091 void test_visitInstanceCreationExpression_named() { |
| 2067 _assertSource("new C.c()", AstFactory.instanceCreationExpression3(Keyword.NE
W, AstFactory.typeName4("C", []), "c", [])); | 2092 _assertSource("new C.c()", AstFactory.instanceCreationExpression3(Keyword.NE
W, AstFactory.typeName4("C"), "c")); |
| 2068 } | 2093 } |
| 2069 | 2094 |
| 2070 void test_visitInstanceCreationExpression_unnamed() { | 2095 void test_visitInstanceCreationExpression_unnamed() { |
| 2071 _assertSource("new C()", AstFactory.instanceCreationExpression2(Keyword.NEW,
AstFactory.typeName4("C", []), [])); | 2096 _assertSource("new C()", AstFactory.instanceCreationExpression2(Keyword.NEW,
AstFactory.typeName4("C"))); |
| 2072 } | 2097 } |
| 2073 | 2098 |
| 2074 void test_visitIntegerLiteral() { | 2099 void test_visitIntegerLiteral() { |
| 2075 _assertSource("42", AstFactory.integer(42)); | 2100 _assertSource("42", AstFactory.integer(42)); |
| 2076 } | 2101 } |
| 2077 | 2102 |
| 2078 void test_visitInterpolationExpression_expression() { | 2103 void test_visitInterpolationExpression_expression() { |
| 2079 _assertSource("\${a}", AstFactory.interpolationExpression(AstFactory.identif
ier3("a"))); | 2104 _assertSource("\${a}", AstFactory.interpolationExpression(AstFactory.identif
ier3("a"))); |
| 2080 } | 2105 } |
| 2081 | 2106 |
| 2082 void test_visitInterpolationExpression_identifier() { | 2107 void test_visitInterpolationExpression_identifier() { |
| 2083 _assertSource("\$a", AstFactory.interpolationExpression2("a")); | 2108 _assertSource("\$a", AstFactory.interpolationExpression2("a")); |
| 2084 } | 2109 } |
| 2085 | 2110 |
| 2086 void test_visitInterpolationString() { | 2111 void test_visitInterpolationString() { |
| 2087 _assertSource("'x", AstFactory.interpolationString("'x", "x")); | 2112 _assertSource("'x", AstFactory.interpolationString("'x", "x")); |
| 2088 } | 2113 } |
| 2089 | 2114 |
| 2090 void test_visitIsExpression_negated() { | 2115 void test_visitIsExpression_negated() { |
| 2091 _assertSource("a is! C", AstFactory.isExpression(AstFactory.identifier3("a")
, true, AstFactory.typeName4("C", []))); | 2116 _assertSource("a is! C", AstFactory.isExpression(AstFactory.identifier3("a")
, true, AstFactory.typeName4("C"))); |
| 2092 } | 2117 } |
| 2093 | 2118 |
| 2094 void test_visitIsExpression_normal() { | 2119 void test_visitIsExpression_normal() { |
| 2095 _assertSource("a is C", AstFactory.isExpression(AstFactory.identifier3("a"),
false, AstFactory.typeName4("C", []))); | 2120 _assertSource("a is C", AstFactory.isExpression(AstFactory.identifier3("a"),
false, AstFactory.typeName4("C"))); |
| 2096 } | 2121 } |
| 2097 | 2122 |
| 2098 void test_visitLabel() { | 2123 void test_visitLabel() { |
| 2099 _assertSource("a:", AstFactory.label2("a")); | 2124 _assertSource("a:", AstFactory.label2("a")); |
| 2100 } | 2125 } |
| 2101 | 2126 |
| 2102 void test_visitLabeledStatement_multiple() { | 2127 void test_visitLabeledStatement_multiple() { |
| 2103 _assertSource("a: b: return;", AstFactory.labeledStatement(AstFactory.list([
AstFactory.label2("a"), AstFactory.label2("b")]), AstFactory.returnStatement()))
; | 2128 _assertSource("a: b: return;", AstFactory.labeledStatement([AstFactory.label
2("a"), AstFactory.label2("b")], AstFactory.returnStatement())); |
| 2104 } | 2129 } |
| 2105 | 2130 |
| 2106 void test_visitLabeledStatement_single() { | 2131 void test_visitLabeledStatement_single() { |
| 2107 _assertSource("a: return;", AstFactory.labeledStatement(AstFactory.list([Ast
Factory.label2("a")]), AstFactory.returnStatement())); | 2132 _assertSource("a: return;", AstFactory.labeledStatement([AstFactory.label2("
a")], AstFactory.returnStatement())); |
| 2108 } | 2133 } |
| 2109 | 2134 |
| 2110 void test_visitLibraryDirective() { | 2135 void test_visitLibraryDirective() { |
| 2111 _assertSource("library l;", AstFactory.libraryDirective2("l")); | 2136 _assertSource("library l;", AstFactory.libraryDirective2("l")); |
| 2112 } | 2137 } |
| 2113 | 2138 |
| 2114 void test_visitLibraryDirective_withMetadata() { | 2139 void test_visitLibraryDirective_withMetadata() { |
| 2115 LibraryDirective directive = AstFactory.libraryDirective2("l"); | 2140 LibraryDirective directive = AstFactory.libraryDirective2("l"); |
| 2116 directive.metadata = AstFactory.list([AstFactory.annotation(AstFactory.ident
ifier3("deprecated"))]); | 2141 directive.metadata = [AstFactory.annotation(AstFactory.identifier3("deprecat
ed"))]; |
| 2117 _assertSource("@deprecated library l;", directive); | 2142 _assertSource("@deprecated library l;", directive); |
| 2118 } | 2143 } |
| 2119 | 2144 |
| 2120 void test_visitLibraryIdentifier_multiple() { | 2145 void test_visitLibraryIdentifier_multiple() { |
| 2121 _assertSource("a.b.c", AstFactory.libraryIdentifier([ | 2146 _assertSource("a.b.c", AstFactory.libraryIdentifier([ |
| 2122 AstFactory.identifier3("a"), | 2147 AstFactory.identifier3("a"), |
| 2123 AstFactory.identifier3("b"), | 2148 AstFactory.identifier3("b"), |
| 2124 AstFactory.identifier3("c")])); | 2149 AstFactory.identifier3("c")])); |
| 2125 } | 2150 } |
| 2126 | 2151 |
| 2127 void test_visitLibraryIdentifier_single() { | 2152 void test_visitLibraryIdentifier_single() { |
| 2128 _assertSource("a", AstFactory.libraryIdentifier([AstFactory.identifier3("a")
])); | 2153 _assertSource("a", AstFactory.libraryIdentifier([AstFactory.identifier3("a")
])); |
| 2129 } | 2154 } |
| 2130 | 2155 |
| 2131 void test_visitListLiteral_const() { | 2156 void test_visitListLiteral_const() { |
| 2132 _assertSource("const []", AstFactory.listLiteral2(Keyword.CONST, null, [])); | 2157 _assertSource("const []", AstFactory.listLiteral2(Keyword.CONST, null)); |
| 2133 } | 2158 } |
| 2134 | 2159 |
| 2135 void test_visitListLiteral_empty() { | 2160 void test_visitListLiteral_empty() { |
| 2136 _assertSource("[]", AstFactory.listLiteral([])); | 2161 _assertSource("[]", AstFactory.listLiteral()); |
| 2137 } | 2162 } |
| 2138 | 2163 |
| 2139 void test_visitListLiteral_nonEmpty() { | 2164 void test_visitListLiteral_nonEmpty() { |
| 2140 _assertSource("[a, b, c]", AstFactory.listLiteral([ | 2165 _assertSource("[a, b, c]", AstFactory.listLiteral([ |
| 2141 AstFactory.identifier3("a"), | 2166 AstFactory.identifier3("a"), |
| 2142 AstFactory.identifier3("b"), | 2167 AstFactory.identifier3("b"), |
| 2143 AstFactory.identifier3("c")])); | 2168 AstFactory.identifier3("c")])); |
| 2144 } | 2169 } |
| 2145 | 2170 |
| 2146 void test_visitMapLiteral_const() { | 2171 void test_visitMapLiteral_const() { |
| 2147 _assertSource("const {}", AstFactory.mapLiteral(Keyword.CONST, null, [])); | 2172 _assertSource("const {}", AstFactory.mapLiteral(Keyword.CONST, null)); |
| 2148 } | 2173 } |
| 2149 | 2174 |
| 2150 void test_visitMapLiteral_empty() { | 2175 void test_visitMapLiteral_empty() { |
| 2151 _assertSource("{}", AstFactory.mapLiteral2([])); | 2176 _assertSource("{}", AstFactory.mapLiteral2()); |
| 2152 } | 2177 } |
| 2153 | 2178 |
| 2154 void test_visitMapLiteral_nonEmpty() { | 2179 void test_visitMapLiteral_nonEmpty() { |
| 2155 _assertSource("{'a' : a, 'b' : b, 'c' : c}", AstFactory.mapLiteral2([ | 2180 _assertSource("{'a' : a, 'b' : b, 'c' : c}", AstFactory.mapLiteral2([ |
| 2156 AstFactory.mapLiteralEntry("a", AstFactory.identifier3("a")), | 2181 AstFactory.mapLiteralEntry("a", AstFactory.identifier3("a")), |
| 2157 AstFactory.mapLiteralEntry("b", AstFactory.identifier3("b")), | 2182 AstFactory.mapLiteralEntry("b", AstFactory.identifier3("b")), |
| 2158 AstFactory.mapLiteralEntry("c", AstFactory.identifier3("c"))])); | 2183 AstFactory.mapLiteralEntry("c", AstFactory.identifier3("c"))])); |
| 2159 } | 2184 } |
| 2160 | 2185 |
| 2161 void test_visitMapLiteralEntry() { | 2186 void test_visitMapLiteralEntry() { |
| 2162 _assertSource("'a' : b", AstFactory.mapLiteralEntry("a", AstFactory.identifi
er3("b"))); | 2187 _assertSource("'a' : b", AstFactory.mapLiteralEntry("a", AstFactory.identifi
er3("b"))); |
| 2163 } | 2188 } |
| 2164 | 2189 |
| 2165 void test_visitMethodDeclaration_external() { | 2190 void test_visitMethodDeclaration_external() { |
| 2166 _assertSource("external m();", AstFactory.methodDeclaration(null, null, null
, null, AstFactory.identifier3("m"), AstFactory.formalParameterList([]))); | 2191 _assertSource("external m();", AstFactory.methodDeclaration(null, null, null
, null, AstFactory.identifier3("m"), AstFactory.formalParameterList())); |
| 2167 } | 2192 } |
| 2168 | 2193 |
| 2169 void test_visitMethodDeclaration_external_returnType() { | 2194 void test_visitMethodDeclaration_external_returnType() { |
| 2170 _assertSource("external T m();", AstFactory.methodDeclaration(null, AstFacto
ry.typeName4("T", []), null, null, AstFactory.identifier3("m"), AstFactory.forma
lParameterList([]))); | 2195 _assertSource("external T m();", AstFactory.methodDeclaration(null, AstFacto
ry.typeName4("T"), null, null, AstFactory.identifier3("m"), AstFactory.formalPar
ameterList())); |
| 2171 } | 2196 } |
| 2172 | 2197 |
| 2173 void test_visitMethodDeclaration_getter() { | 2198 void test_visitMethodDeclaration_getter() { |
| 2174 _assertSource("get m {}", AstFactory.methodDeclaration2(null, null, Keyword.
GET, null, AstFactory.identifier3("m"), null, AstFactory.blockFunctionBody2([]))
); | 2199 _assertSource("get m {}", AstFactory.methodDeclaration2(null, null, Keyword.
GET, null, AstFactory.identifier3("m"), null, AstFactory.blockFunctionBody2())); |
| 2175 } | 2200 } |
| 2176 | 2201 |
| 2177 void test_visitMethodDeclaration_getter_returnType() { | 2202 void test_visitMethodDeclaration_getter_returnType() { |
| 2178 _assertSource("T get m {}", AstFactory.methodDeclaration2(null, AstFactory.t
ypeName4("T", []), Keyword.GET, null, AstFactory.identifier3("m"), null, AstFact
ory.blockFunctionBody2([]))); | 2203 _assertSource("T get m {}", AstFactory.methodDeclaration2(null, AstFactory.t
ypeName4("T"), Keyword.GET, null, AstFactory.identifier3("m"), null, AstFactory.
blockFunctionBody2())); |
| 2179 } | 2204 } |
| 2180 | 2205 |
| 2181 void test_visitMethodDeclaration_getter_seturnType() { | 2206 void test_visitMethodDeclaration_getter_seturnType() { |
| 2182 _assertSource("T set m(var v) {}", AstFactory.methodDeclaration2(null, AstFa
ctory.typeName4("T", []), Keyword.SET, null, AstFactory.identifier3("m"), AstFac
tory.formalParameterList([AstFactory.simpleFormalParameter(Keyword.VAR, "v")]),
AstFactory.blockFunctionBody2([]))); | 2207 _assertSource("T set m(var v) {}", AstFactory.methodDeclaration2(null, AstFa
ctory.typeName4("T"), Keyword.SET, null, AstFactory.identifier3("m"), AstFactory
.formalParameterList([AstFactory.simpleFormalParameter(Keyword.VAR, "v")]), AstF
actory.blockFunctionBody2())); |
| 2183 } | 2208 } |
| 2184 | 2209 |
| 2185 void test_visitMethodDeclaration_minimal() { | 2210 void test_visitMethodDeclaration_minimal() { |
| 2186 _assertSource("m() {}", AstFactory.methodDeclaration2(null, null, null, null
, AstFactory.identifier3("m"), AstFactory.formalParameterList([]), AstFactory.bl
ockFunctionBody2([]))); | 2211 _assertSource("m() {}", AstFactory.methodDeclaration2(null, null, null, null
, AstFactory.identifier3("m"), AstFactory.formalParameterList(), AstFactory.bloc
kFunctionBody2())); |
| 2187 } | 2212 } |
| 2188 | 2213 |
| 2189 void test_visitMethodDeclaration_multipleParameters() { | 2214 void test_visitMethodDeclaration_multipleParameters() { |
| 2190 _assertSource("m(var a, var b) {}", AstFactory.methodDeclaration2(null, null
, null, null, AstFactory.identifier3("m"), AstFactory.formalParameterList([ | 2215 _assertSource("m(var a, var b) {}", AstFactory.methodDeclaration2(null, null
, null, null, AstFactory.identifier3("m"), AstFactory.formalParameterList([ |
| 2191 AstFactory.simpleFormalParameter(Keyword.VAR, "a"), | 2216 AstFactory.simpleFormalParameter(Keyword.VAR, "a"), |
| 2192 AstFactory.simpleFormalParameter(Keyword.VAR, "b")]), AstFactory.blockFu
nctionBody2([]))); | 2217 AstFactory.simpleFormalParameter(Keyword.VAR, "b")]), AstFactory.blockFu
nctionBody2())); |
| 2193 } | 2218 } |
| 2194 | 2219 |
| 2195 void test_visitMethodDeclaration_operator() { | 2220 void test_visitMethodDeclaration_operator() { |
| 2196 _assertSource("operator +() {}", AstFactory.methodDeclaration2(null, null, n
ull, Keyword.OPERATOR, AstFactory.identifier3("+"), AstFactory.formalParameterLi
st([]), AstFactory.blockFunctionBody2([]))); | 2221 _assertSource("operator +() {}", AstFactory.methodDeclaration2(null, null, n
ull, Keyword.OPERATOR, AstFactory.identifier3("+"), AstFactory.formalParameterLi
st(), AstFactory.blockFunctionBody2())); |
| 2197 } | 2222 } |
| 2198 | 2223 |
| 2199 void test_visitMethodDeclaration_operator_returnType() { | 2224 void test_visitMethodDeclaration_operator_returnType() { |
| 2200 _assertSource("T operator +() {}", AstFactory.methodDeclaration2(null, AstFa
ctory.typeName4("T", []), null, Keyword.OPERATOR, AstFactory.identifier3("+"), A
stFactory.formalParameterList([]), AstFactory.blockFunctionBody2([]))); | 2225 _assertSource("T operator +() {}", AstFactory.methodDeclaration2(null, AstFa
ctory.typeName4("T"), null, Keyword.OPERATOR, AstFactory.identifier3("+"), AstFa
ctory.formalParameterList(), AstFactory.blockFunctionBody2())); |
| 2201 } | 2226 } |
| 2202 | 2227 |
| 2203 void test_visitMethodDeclaration_returnType() { | 2228 void test_visitMethodDeclaration_returnType() { |
| 2204 _assertSource("T m() {}", AstFactory.methodDeclaration2(null, AstFactory.typ
eName4("T", []), null, null, AstFactory.identifier3("m"), AstFactory.formalParam
eterList([]), AstFactory.blockFunctionBody2([]))); | 2229 _assertSource("T m() {}", AstFactory.methodDeclaration2(null, AstFactory.typ
eName4("T"), null, null, AstFactory.identifier3("m"), AstFactory.formalParameter
List(), AstFactory.blockFunctionBody2())); |
| 2205 } | 2230 } |
| 2206 | 2231 |
| 2207 void test_visitMethodDeclaration_setter() { | 2232 void test_visitMethodDeclaration_setter() { |
| 2208 _assertSource("set m(var v) {}", AstFactory.methodDeclaration2(null, null, K
eyword.SET, null, AstFactory.identifier3("m"), AstFactory.formalParameterList([A
stFactory.simpleFormalParameter(Keyword.VAR, "v")]), AstFactory.blockFunctionBod
y2([]))); | 2233 _assertSource("set m(var v) {}", AstFactory.methodDeclaration2(null, null, K
eyword.SET, null, AstFactory.identifier3("m"), AstFactory.formalParameterList([A
stFactory.simpleFormalParameter(Keyword.VAR, "v")]), AstFactory.blockFunctionBod
y2())); |
| 2209 } | 2234 } |
| 2210 | 2235 |
| 2211 void test_visitMethodDeclaration_static() { | 2236 void test_visitMethodDeclaration_static() { |
| 2212 _assertSource("static m() {}", AstFactory.methodDeclaration2(Keyword.STATIC,
null, null, null, AstFactory.identifier3("m"), AstFactory.formalParameterList([
]), AstFactory.blockFunctionBody2([]))); | 2237 _assertSource("static m() {}", AstFactory.methodDeclaration2(Keyword.STATIC,
null, null, null, AstFactory.identifier3("m"), AstFactory.formalParameterList()
, AstFactory.blockFunctionBody2())); |
| 2213 } | 2238 } |
| 2214 | 2239 |
| 2215 void test_visitMethodDeclaration_static_returnType() { | 2240 void test_visitMethodDeclaration_static_returnType() { |
| 2216 _assertSource("static T m() {}", AstFactory.methodDeclaration2(Keyword.STATI
C, AstFactory.typeName4("T", []), null, null, AstFactory.identifier3("m"), AstFa
ctory.formalParameterList([]), AstFactory.blockFunctionBody2([]))); | 2241 _assertSource("static T m() {}", AstFactory.methodDeclaration2(Keyword.STATI
C, AstFactory.typeName4("T"), null, null, AstFactory.identifier3("m"), AstFactor
y.formalParameterList(), AstFactory.blockFunctionBody2())); |
| 2217 } | 2242 } |
| 2218 | 2243 |
| 2219 void test_visitMethodDeclaration_withMetadata() { | 2244 void test_visitMethodDeclaration_withMetadata() { |
| 2220 MethodDeclaration declaration = AstFactory.methodDeclaration2(null, null, nu
ll, null, AstFactory.identifier3("m"), AstFactory.formalParameterList([]), AstFa
ctory.blockFunctionBody2([])); | 2245 MethodDeclaration declaration = AstFactory.methodDeclaration2(null, null, nu
ll, null, AstFactory.identifier3("m"), AstFactory.formalParameterList(), AstFact
ory.blockFunctionBody2()); |
| 2221 declaration.metadata = AstFactory.list([AstFactory.annotation(AstFactory.ide
ntifier3("deprecated"))]); | 2246 declaration.metadata = [AstFactory.annotation(AstFactory.identifier3("deprec
ated"))]; |
| 2222 _assertSource("@deprecated m() {}", declaration); | 2247 _assertSource("@deprecated m() {}", declaration); |
| 2223 } | 2248 } |
| 2224 | 2249 |
| 2225 void test_visitMethodInvocation_noTarget() { | 2250 void test_visitMethodInvocation_noTarget() { |
| 2226 _assertSource("m()", AstFactory.methodInvocation2("m", [])); | 2251 _assertSource("m()", AstFactory.methodInvocation2("m")); |
| 2227 } | 2252 } |
| 2228 | 2253 |
| 2229 void test_visitMethodInvocation_target() { | 2254 void test_visitMethodInvocation_target() { |
| 2230 _assertSource("t.m()", AstFactory.methodInvocation(AstFactory.identifier3("t
"), "m", [])); | 2255 _assertSource("t.m()", AstFactory.methodInvocation(AstFactory.identifier3("t
"), "m")); |
| 2231 } | 2256 } |
| 2232 | 2257 |
| 2233 void test_visitNamedExpression() { | 2258 void test_visitNamedExpression() { |
| 2234 _assertSource("a: b", AstFactory.namedExpression2("a", AstFactory.identifier
3("b"))); | 2259 _assertSource("a: b", AstFactory.namedExpression2("a", AstFactory.identifier
3("b"))); |
| 2235 } | 2260 } |
| 2236 | 2261 |
| 2237 void test_visitNamedFormalParameter() { | 2262 void test_visitNamedFormalParameter() { |
| 2238 _assertSource("var a : 0", AstFactory.namedFormalParameter(AstFactory.simple
FormalParameter(Keyword.VAR, "a"), AstFactory.integer(0))); | 2263 _assertSource("var a : 0", AstFactory.namedFormalParameter(AstFactory.simple
FormalParameter(Keyword.VAR, "a"), AstFactory.integer(0))); |
| 2239 } | 2264 } |
| 2240 | 2265 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2253 void test_visitParenthesizedExpression() { | 2278 void test_visitParenthesizedExpression() { |
| 2254 _assertSource("(a)", AstFactory.parenthesizedExpression(AstFactory.identifie
r3("a"))); | 2279 _assertSource("(a)", AstFactory.parenthesizedExpression(AstFactory.identifie
r3("a"))); |
| 2255 } | 2280 } |
| 2256 | 2281 |
| 2257 void test_visitPartDirective() { | 2282 void test_visitPartDirective() { |
| 2258 _assertSource("part 'a.dart';", AstFactory.partDirective2("a.dart")); | 2283 _assertSource("part 'a.dart';", AstFactory.partDirective2("a.dart")); |
| 2259 } | 2284 } |
| 2260 | 2285 |
| 2261 void test_visitPartDirective_withMetadata() { | 2286 void test_visitPartDirective_withMetadata() { |
| 2262 PartDirective directive = AstFactory.partDirective2("a.dart"); | 2287 PartDirective directive = AstFactory.partDirective2("a.dart"); |
| 2263 directive.metadata = AstFactory.list([AstFactory.annotation(AstFactory.ident
ifier3("deprecated"))]); | 2288 directive.metadata = [AstFactory.annotation(AstFactory.identifier3("deprecat
ed"))]; |
| 2264 _assertSource("@deprecated part 'a.dart';", directive); | 2289 _assertSource("@deprecated part 'a.dart';", directive); |
| 2265 } | 2290 } |
| 2266 | 2291 |
| 2267 void test_visitPartOfDirective() { | 2292 void test_visitPartOfDirective() { |
| 2268 _assertSource("part of l;", AstFactory.partOfDirective(AstFactory.libraryIde
ntifier2(["l"]))); | 2293 _assertSource("part of l;", AstFactory.partOfDirective(AstFactory.libraryIde
ntifier2(["l"]))); |
| 2269 } | 2294 } |
| 2270 | 2295 |
| 2271 void test_visitPartOfDirective_withMetadata() { | 2296 void test_visitPartOfDirective_withMetadata() { |
| 2272 PartOfDirective directive = AstFactory.partOfDirective(AstFactory.libraryIde
ntifier2(["l"])); | 2297 PartOfDirective directive = AstFactory.partOfDirective(AstFactory.libraryIde
ntifier2(["l"])); |
| 2273 directive.metadata = AstFactory.list([AstFactory.annotation(AstFactory.ident
ifier3("deprecated"))]); | 2298 directive.metadata = [AstFactory.annotation(AstFactory.identifier3("deprecat
ed"))]; |
| 2274 _assertSource("@deprecated part of l;", directive); | 2299 _assertSource("@deprecated part of l;", directive); |
| 2275 } | 2300 } |
| 2276 | 2301 |
| 2277 void test_visitPositionalFormalParameter() { | 2302 void test_visitPositionalFormalParameter() { |
| 2278 _assertSource("var a = 0", AstFactory.positionalFormalParameter(AstFactory.s
impleFormalParameter(Keyword.VAR, "a"), AstFactory.integer(0))); | 2303 _assertSource("var a = 0", AstFactory.positionalFormalParameter(AstFactory.s
impleFormalParameter(Keyword.VAR, "a"), AstFactory.integer(0))); |
| 2279 } | 2304 } |
| 2280 | 2305 |
| 2281 void test_visitPostfixExpression() { | 2306 void test_visitPostfixExpression() { |
| 2282 _assertSource("a++", AstFactory.postfixExpression(AstFactory.identifier3("a"
), TokenType.PLUS_PLUS)); | 2307 _assertSource("a++", AstFactory.postfixExpression(AstFactory.identifier3("a"
), TokenType.PLUS_PLUS)); |
| 2283 } | 2308 } |
| 2284 | 2309 |
| 2285 void test_visitPrefixedIdentifier() { | 2310 void test_visitPrefixedIdentifier() { |
| 2286 _assertSource("a.b", AstFactory.identifier5("a", "b")); | 2311 _assertSource("a.b", AstFactory.identifier5("a", "b")); |
| 2287 } | 2312 } |
| 2288 | 2313 |
| 2289 void test_visitPrefixExpression() { | 2314 void test_visitPrefixExpression() { |
| 2290 _assertSource("-a", AstFactory.prefixExpression(TokenType.MINUS, AstFactory.
identifier3("a"))); | 2315 _assertSource("-a", AstFactory.prefixExpression(TokenType.MINUS, AstFactory.
identifier3("a"))); |
| 2291 } | 2316 } |
| 2292 | 2317 |
| 2293 void test_visitPropertyAccess() { | 2318 void test_visitPropertyAccess() { |
| 2294 _assertSource("a.b", AstFactory.propertyAccess2(AstFactory.identifier3("a"),
"b")); | 2319 _assertSource("a.b", AstFactory.propertyAccess2(AstFactory.identifier3("a"),
"b")); |
| 2295 } | 2320 } |
| 2296 | 2321 |
| 2297 void test_visitRedirectingConstructorInvocation_named() { | 2322 void test_visitRedirectingConstructorInvocation_named() { |
| 2298 _assertSource("this.c()", AstFactory.redirectingConstructorInvocation2("c",
[])); | 2323 _assertSource("this.c()", AstFactory.redirectingConstructorInvocation2("c"))
; |
| 2299 } | 2324 } |
| 2300 | 2325 |
| 2301 void test_visitRedirectingConstructorInvocation_unnamed() { | 2326 void test_visitRedirectingConstructorInvocation_unnamed() { |
| 2302 _assertSource("this()", AstFactory.redirectingConstructorInvocation([])); | 2327 _assertSource("this()", AstFactory.redirectingConstructorInvocation()); |
| 2303 } | 2328 } |
| 2304 | 2329 |
| 2305 void test_visitRethrowExpression() { | 2330 void test_visitRethrowExpression() { |
| 2306 _assertSource("rethrow", AstFactory.rethrowExpression()); | 2331 _assertSource("rethrow", AstFactory.rethrowExpression()); |
| 2307 } | 2332 } |
| 2308 | 2333 |
| 2309 void test_visitReturnStatement_expression() { | 2334 void test_visitReturnStatement_expression() { |
| 2310 _assertSource("return a;", AstFactory.returnStatement2(AstFactory.identifier
3("a"))); | 2335 _assertSource("return a;", AstFactory.returnStatement2(AstFactory.identifier
3("a"))); |
| 2311 } | 2336 } |
| 2312 | 2337 |
| 2313 void test_visitReturnStatement_noExpression() { | 2338 void test_visitReturnStatement_noExpression() { |
| 2314 _assertSource("return;", AstFactory.returnStatement()); | 2339 _assertSource("return;", AstFactory.returnStatement()); |
| 2315 } | 2340 } |
| 2316 | 2341 |
| 2317 void test_visitScriptTag() { | 2342 void test_visitScriptTag() { |
| 2318 String scriptTag = "!#/bin/dart.exe"; | 2343 String scriptTag = "!#/bin/dart.exe"; |
| 2319 _assertSource(scriptTag, AstFactory.scriptTag(scriptTag)); | 2344 _assertSource(scriptTag, AstFactory.scriptTag(scriptTag)); |
| 2320 } | 2345 } |
| 2321 | 2346 |
| 2322 void test_visitSimpleFormalParameter_keyword() { | 2347 void test_visitSimpleFormalParameter_keyword() { |
| 2323 _assertSource("var a", AstFactory.simpleFormalParameter(Keyword.VAR, "a")); | 2348 _assertSource("var a", AstFactory.simpleFormalParameter(Keyword.VAR, "a")); |
| 2324 } | 2349 } |
| 2325 | 2350 |
| 2326 void test_visitSimpleFormalParameter_keyword_type() { | 2351 void test_visitSimpleFormalParameter_keyword_type() { |
| 2327 _assertSource("final A a", AstFactory.simpleFormalParameter2(Keyword.FINAL,
AstFactory.typeName4("A", []), "a")); | 2352 _assertSource("final A a", AstFactory.simpleFormalParameter2(Keyword.FINAL,
AstFactory.typeName4("A"), "a")); |
| 2328 } | 2353 } |
| 2329 | 2354 |
| 2330 void test_visitSimpleFormalParameter_type() { | 2355 void test_visitSimpleFormalParameter_type() { |
| 2331 _assertSource("A a", AstFactory.simpleFormalParameter4(AstFactory.typeName4(
"A", []), "a")); | 2356 _assertSource("A a", AstFactory.simpleFormalParameter4(AstFactory.typeName4(
"A"), "a")); |
| 2332 } | 2357 } |
| 2333 | 2358 |
| 2334 void test_visitSimpleIdentifier() { | 2359 void test_visitSimpleIdentifier() { |
| 2335 _assertSource("a", AstFactory.identifier3("a")); | 2360 _assertSource("a", AstFactory.identifier3("a")); |
| 2336 } | 2361 } |
| 2337 | 2362 |
| 2338 void test_visitSimpleStringLiteral() { | 2363 void test_visitSimpleStringLiteral() { |
| 2339 _assertSource("'a'", AstFactory.string2("a")); | 2364 _assertSource("'a'", AstFactory.string2("a")); |
| 2340 } | 2365 } |
| 2341 | 2366 |
| 2342 void test_visitStringInterpolation() { | 2367 void test_visitStringInterpolation() { |
| 2343 _assertSource("'a\${e}b'", AstFactory.string([ | 2368 _assertSource("'a\${e}b'", AstFactory.string([ |
| 2344 AstFactory.interpolationString("'a", "a"), | 2369 AstFactory.interpolationString("'a", "a"), |
| 2345 AstFactory.interpolationExpression(AstFactory.identifier3("e")), | 2370 AstFactory.interpolationExpression(AstFactory.identifier3("e")), |
| 2346 AstFactory.interpolationString("b'", "b")])); | 2371 AstFactory.interpolationString("b'", "b")])); |
| 2347 } | 2372 } |
| 2348 | 2373 |
| 2349 void test_visitSuperConstructorInvocation() { | 2374 void test_visitSuperConstructorInvocation() { |
| 2350 _assertSource("super()", AstFactory.superConstructorInvocation([])); | 2375 _assertSource("super()", AstFactory.superConstructorInvocation()); |
| 2351 } | 2376 } |
| 2352 | 2377 |
| 2353 void test_visitSuperConstructorInvocation_named() { | 2378 void test_visitSuperConstructorInvocation_named() { |
| 2354 _assertSource("super.c()", AstFactory.superConstructorInvocation2("c", [])); | 2379 _assertSource("super.c()", AstFactory.superConstructorInvocation2("c")); |
| 2355 } | 2380 } |
| 2356 | 2381 |
| 2357 void test_visitSuperExpression() { | 2382 void test_visitSuperExpression() { |
| 2358 _assertSource("super", AstFactory.superExpression()); | 2383 _assertSource("super", AstFactory.superExpression()); |
| 2359 } | 2384 } |
| 2360 | 2385 |
| 2361 void test_visitSwitchCase_multipleLabels() { | 2386 void test_visitSwitchCase_multipleLabels() { |
| 2362 _assertSource("l1: l2: case a: {}", AstFactory.switchCase2(AstFactory.list([
AstFactory.label2("l1"), AstFactory.label2("l2")]), AstFactory.identifier3("a"),
[AstFactory.block([])])); | 2387 _assertSource("l1: l2: case a: {}", AstFactory.switchCase2([AstFactory.label
2("l1"), AstFactory.label2("l2")], AstFactory.identifier3("a"), [AstFactory.bloc
k()])); |
| 2363 } | 2388 } |
| 2364 | 2389 |
| 2365 void test_visitSwitchCase_multipleStatements() { | 2390 void test_visitSwitchCase_multipleStatements() { |
| 2366 _assertSource("case a: {} {}", AstFactory.switchCase(AstFactory.identifier3(
"a"), [AstFactory.block([]), AstFactory.block([])])); | 2391 _assertSource("case a: {} {}", AstFactory.switchCase(AstFactory.identifier3(
"a"), [AstFactory.block(), AstFactory.block()])); |
| 2367 } | 2392 } |
| 2368 | 2393 |
| 2369 void test_visitSwitchCase_noLabels() { | 2394 void test_visitSwitchCase_noLabels() { |
| 2370 _assertSource("case a: {}", AstFactory.switchCase(AstFactory.identifier3("a"
), [AstFactory.block([])])); | 2395 _assertSource("case a: {}", AstFactory.switchCase(AstFactory.identifier3("a"
), [AstFactory.block()])); |
| 2371 } | 2396 } |
| 2372 | 2397 |
| 2373 void test_visitSwitchCase_singleLabel() { | 2398 void test_visitSwitchCase_singleLabel() { |
| 2374 _assertSource("l1: case a: {}", AstFactory.switchCase2(AstFactory.list([AstF
actory.label2("l1")]), AstFactory.identifier3("a"), [AstFactory.block([])])); | 2399 _assertSource("l1: case a: {}", AstFactory.switchCase2([AstFactory.label2("l
1")], AstFactory.identifier3("a"), [AstFactory.block()])); |
| 2375 } | 2400 } |
| 2376 | 2401 |
| 2377 void test_visitSwitchDefault_multipleLabels() { | 2402 void test_visitSwitchDefault_multipleLabels() { |
| 2378 _assertSource("l1: l2: default: {}", AstFactory.switchDefault(AstFactory.lis
t([AstFactory.label2("l1"), AstFactory.label2("l2")]), [AstFactory.block([])])); | 2403 _assertSource("l1: l2: default: {}", AstFactory.switchDefault([AstFactory.la
bel2("l1"), AstFactory.label2("l2")], [AstFactory.block()])); |
| 2379 } | 2404 } |
| 2380 | 2405 |
| 2381 void test_visitSwitchDefault_multipleStatements() { | 2406 void test_visitSwitchDefault_multipleStatements() { |
| 2382 _assertSource("default: {} {}", AstFactory.switchDefault2([AstFactory.block(
[]), AstFactory.block([])])); | 2407 _assertSource("default: {} {}", AstFactory.switchDefault2([AstFactory.block(
), AstFactory.block()])); |
| 2383 } | 2408 } |
| 2384 | 2409 |
| 2385 void test_visitSwitchDefault_noLabels() { | 2410 void test_visitSwitchDefault_noLabels() { |
| 2386 _assertSource("default: {}", AstFactory.switchDefault2([AstFactory.block([])
])); | 2411 _assertSource("default: {}", AstFactory.switchDefault2([AstFactory.block()])
); |
| 2387 } | 2412 } |
| 2388 | 2413 |
| 2389 void test_visitSwitchDefault_singleLabel() { | 2414 void test_visitSwitchDefault_singleLabel() { |
| 2390 _assertSource("l1: default: {}", AstFactory.switchDefault(AstFactory.list([A
stFactory.label2("l1")]), [AstFactory.block([])])); | 2415 _assertSource("l1: default: {}", AstFactory.switchDefault([AstFactory.label2
("l1")], [AstFactory.block()])); |
| 2391 } | 2416 } |
| 2392 | 2417 |
| 2393 void test_visitSwitchStatement() { | 2418 void test_visitSwitchStatement() { |
| 2394 _assertSource("switch (a) {case 'b': {} default: {}}", AstFactory.switchStat
ement(AstFactory.identifier3("a"), [ | 2419 _assertSource("switch (a) {case 'b': {} default: {}}", AstFactory.switchStat
ement(AstFactory.identifier3("a"), [ |
| 2395 AstFactory.switchCase(AstFactory.string2("b"), [AstFactory.block([])]), | 2420 AstFactory.switchCase(AstFactory.string2("b"), [AstFactory.block()]), |
| 2396 AstFactory.switchDefault2([AstFactory.block([])])])); | 2421 AstFactory.switchDefault2([AstFactory.block()])])); |
| 2397 } | 2422 } |
| 2398 | 2423 |
| 2399 void test_visitSymbolLiteral_multiple() { | 2424 void test_visitSymbolLiteral_multiple() { |
| 2400 _assertSource("#a.b.c", AstFactory.symbolLiteral(["a", "b", "c"])); | 2425 _assertSource("#a.b.c", AstFactory.symbolLiteral(["a", "b", "c"])); |
| 2401 } | 2426 } |
| 2402 | 2427 |
| 2403 void test_visitSymbolLiteral_single() { | 2428 void test_visitSymbolLiteral_single() { |
| 2404 _assertSource("#a", AstFactory.symbolLiteral(["a"])); | 2429 _assertSource("#a", AstFactory.symbolLiteral(["a"])); |
| 2405 } | 2430 } |
| 2406 | 2431 |
| 2407 void test_visitThisExpression() { | 2432 void test_visitThisExpression() { |
| 2408 _assertSource("this", AstFactory.thisExpression()); | 2433 _assertSource("this", AstFactory.thisExpression()); |
| 2409 } | 2434 } |
| 2410 | 2435 |
| 2411 void test_visitThrowStatement() { | 2436 void test_visitThrowStatement() { |
| 2412 _assertSource("throw e", AstFactory.throwExpression2(AstFactory.identifier3(
"e"))); | 2437 _assertSource("throw e", AstFactory.throwExpression2(AstFactory.identifier3(
"e"))); |
| 2413 } | 2438 } |
| 2414 | 2439 |
| 2415 void test_visitTopLevelVariableDeclaration_multiple() { | 2440 void test_visitTopLevelVariableDeclaration_multiple() { |
| 2416 _assertSource("var a;", AstFactory.topLevelVariableDeclaration2(Keyword.VAR,
[AstFactory.variableDeclaration("a")])); | 2441 _assertSource("var a;", AstFactory.topLevelVariableDeclaration2(Keyword.VAR,
[AstFactory.variableDeclaration("a")])); |
| 2417 } | 2442 } |
| 2418 | 2443 |
| 2419 void test_visitTopLevelVariableDeclaration_single() { | 2444 void test_visitTopLevelVariableDeclaration_single() { |
| 2420 _assertSource("var a, b;", AstFactory.topLevelVariableDeclaration2(Keyword.V
AR, [ | 2445 _assertSource("var a, b;", AstFactory.topLevelVariableDeclaration2(Keyword.V
AR, [ |
| 2421 AstFactory.variableDeclaration("a"), | 2446 AstFactory.variableDeclaration("a"), |
| 2422 AstFactory.variableDeclaration("b")])); | 2447 AstFactory.variableDeclaration("b")])); |
| 2423 } | 2448 } |
| 2424 | 2449 |
| 2425 void test_visitTryStatement_catch() { | 2450 void test_visitTryStatement_catch() { |
| 2426 _assertSource("try {} on E {}", AstFactory.tryStatement2(AstFactory.block([]
), [AstFactory.catchClause3(AstFactory.typeName4("E", []), [])])); | 2451 _assertSource("try {} on E {}", AstFactory.tryStatement2(AstFactory.block(),
[AstFactory.catchClause3(AstFactory.typeName4("E"))])); |
| 2427 } | 2452 } |
| 2428 | 2453 |
| 2429 void test_visitTryStatement_catches() { | 2454 void test_visitTryStatement_catches() { |
| 2430 _assertSource("try {} on E {} on F {}", AstFactory.tryStatement2(AstFactory.
block([]), [ | 2455 _assertSource("try {} on E {} on F {}", AstFactory.tryStatement2(AstFactory.
block(), [ |
| 2431 AstFactory.catchClause3(AstFactory.typeName4("E", []), []), | 2456 AstFactory.catchClause3(AstFactory.typeName4("E")), |
| 2432 AstFactory.catchClause3(AstFactory.typeName4("F", []), [])])); | 2457 AstFactory.catchClause3(AstFactory.typeName4("F"))])); |
| 2433 } | 2458 } |
| 2434 | 2459 |
| 2435 void test_visitTryStatement_catchFinally() { | 2460 void test_visitTryStatement_catchFinally() { |
| 2436 _assertSource("try {} on E {} finally {}", AstFactory.tryStatement3(AstFacto
ry.block([]), AstFactory.list([AstFactory.catchClause3(AstFactory.typeName4("E",
[]), [])]), AstFactory.block([]))); | 2461 _assertSource("try {} on E {} finally {}", AstFactory.tryStatement3(AstFacto
ry.block(), [AstFactory.catchClause3(AstFactory.typeName4("E"))], AstFactory.blo
ck())); |
| 2437 } | 2462 } |
| 2438 | 2463 |
| 2439 void test_visitTryStatement_finally() { | 2464 void test_visitTryStatement_finally() { |
| 2440 _assertSource("try {} finally {}", AstFactory.tryStatement(AstFactory.block(
[]), AstFactory.block([]))); | 2465 _assertSource("try {} finally {}", AstFactory.tryStatement(AstFactory.block(
), AstFactory.block())); |
| 2441 } | 2466 } |
| 2442 | 2467 |
| 2443 void test_visitTypeArgumentList_multiple() { | 2468 void test_visitTypeArgumentList_multiple() { |
| 2444 _assertSource("<E, F>", AstFactory.typeArgumentList([ | 2469 _assertSource("<E, F>", AstFactory.typeArgumentList([ |
| 2445 AstFactory.typeName4("E", []), | 2470 AstFactory.typeName4("E"), |
| 2446 AstFactory.typeName4("F", [])])); | 2471 AstFactory.typeName4("F")])); |
| 2447 } | 2472 } |
| 2448 | 2473 |
| 2449 void test_visitTypeArgumentList_single() { | 2474 void test_visitTypeArgumentList_single() { |
| 2450 _assertSource("<E>", AstFactory.typeArgumentList([AstFactory.typeName4("E",
[])])); | 2475 _assertSource("<E>", AstFactory.typeArgumentList([AstFactory.typeName4("E")]
)); |
| 2451 } | 2476 } |
| 2452 | 2477 |
| 2453 void test_visitTypeName_multipleArgs() { | 2478 void test_visitTypeName_multipleArgs() { |
| 2454 _assertSource("C<D, E>", AstFactory.typeName4("C", [ | 2479 _assertSource("C<D, E>", AstFactory.typeName4("C", [ |
| 2455 AstFactory.typeName4("D", []), | 2480 AstFactory.typeName4("D"), |
| 2456 AstFactory.typeName4("E", [])])); | 2481 AstFactory.typeName4("E")])); |
| 2457 } | 2482 } |
| 2458 | 2483 |
| 2459 void test_visitTypeName_nestedArg() { | 2484 void test_visitTypeName_nestedArg() { |
| 2460 _assertSource("C<D<E>>", AstFactory.typeName4("C", [AstFactory.typeName4("D"
, [AstFactory.typeName4("E", [])])])); | 2485 _assertSource("C<D<E>>", AstFactory.typeName4("C", [AstFactory.typeName4("D"
, [AstFactory.typeName4("E")])])); |
| 2461 } | 2486 } |
| 2462 | 2487 |
| 2463 void test_visitTypeName_noArgs() { | 2488 void test_visitTypeName_noArgs() { |
| 2464 _assertSource("C", AstFactory.typeName4("C", [])); | 2489 _assertSource("C", AstFactory.typeName4("C")); |
| 2465 } | 2490 } |
| 2466 | 2491 |
| 2467 void test_visitTypeName_singleArg() { | 2492 void test_visitTypeName_singleArg() { |
| 2468 _assertSource("C<D>", AstFactory.typeName4("C", [AstFactory.typeName4("D", [
])])); | 2493 _assertSource("C<D>", AstFactory.typeName4("C", [AstFactory.typeName4("D")])
); |
| 2469 } | 2494 } |
| 2470 | 2495 |
| 2471 void test_visitTypeParameter_withExtends() { | 2496 void test_visitTypeParameter_withExtends() { |
| 2472 _assertSource("E extends C", AstFactory.typeParameter2("E", AstFactory.typeN
ame4("C", []))); | 2497 _assertSource("E extends C", AstFactory.typeParameter2("E", AstFactory.typeN
ame4("C"))); |
| 2473 } | 2498 } |
| 2474 | 2499 |
| 2475 void test_visitTypeParameter_withMetadata() { | 2500 void test_visitTypeParameter_withMetadata() { |
| 2476 TypeParameter parameter = AstFactory.typeParameter("E"); | 2501 TypeParameter parameter = AstFactory.typeParameter("E"); |
| 2477 parameter.metadata = AstFactory.list([AstFactory.annotation(AstFactory.ident
ifier3("deprecated"))]); | 2502 parameter.metadata = [AstFactory.annotation(AstFactory.identifier3("deprecat
ed"))]; |
| 2478 _assertSource("@deprecated E", parameter); | 2503 _assertSource("@deprecated E", parameter); |
| 2479 } | 2504 } |
| 2480 | 2505 |
| 2481 void test_visitTypeParameter_withoutExtends() { | 2506 void test_visitTypeParameter_withoutExtends() { |
| 2482 _assertSource("E", AstFactory.typeParameter("E")); | 2507 _assertSource("E", AstFactory.typeParameter("E")); |
| 2483 } | 2508 } |
| 2484 | 2509 |
| 2485 void test_visitTypeParameterList_multiple() { | 2510 void test_visitTypeParameterList_multiple() { |
| 2486 _assertSource("<E, F>", AstFactory.typeParameterList(["E", "F"])); | 2511 _assertSource("<E, F>", AstFactory.typeParameterList(["E", "F"])); |
| 2487 } | 2512 } |
| 2488 | 2513 |
| 2489 void test_visitTypeParameterList_single() { | 2514 void test_visitTypeParameterList_single() { |
| 2490 _assertSource("<E>", AstFactory.typeParameterList(["E"])); | 2515 _assertSource("<E>", AstFactory.typeParameterList(["E"])); |
| 2491 } | 2516 } |
| 2492 | 2517 |
| 2493 void test_visitVariableDeclaration_initialized() { | 2518 void test_visitVariableDeclaration_initialized() { |
| 2494 _assertSource("a = b", AstFactory.variableDeclaration2("a", AstFactory.ident
ifier3("b"))); | 2519 _assertSource("a = b", AstFactory.variableDeclaration2("a", AstFactory.ident
ifier3("b"))); |
| 2495 } | 2520 } |
| 2496 | 2521 |
| 2497 void test_visitVariableDeclaration_uninitialized() { | 2522 void test_visitVariableDeclaration_uninitialized() { |
| 2498 _assertSource("a", AstFactory.variableDeclaration("a")); | 2523 _assertSource("a", AstFactory.variableDeclaration("a")); |
| 2499 } | 2524 } |
| 2500 | 2525 |
| 2501 void test_visitVariableDeclaration_withMetadata() { | 2526 void test_visitVariableDeclaration_withMetadata() { |
| 2502 VariableDeclaration declaration = AstFactory.variableDeclaration("a"); | 2527 VariableDeclaration declaration = AstFactory.variableDeclaration("a"); |
| 2503 declaration.metadata = AstFactory.list([AstFactory.annotation(AstFactory.ide
ntifier3("deprecated"))]); | 2528 declaration.metadata = [AstFactory.annotation(AstFactory.identifier3("deprec
ated"))]; |
| 2504 _assertSource("@deprecated a", declaration); | 2529 _assertSource("@deprecated a", declaration); |
| 2505 } | 2530 } |
| 2506 | 2531 |
| 2507 void test_visitVariableDeclarationList_const_type() { | 2532 void test_visitVariableDeclarationList_const_type() { |
| 2508 _assertSource("const C a, b", AstFactory.variableDeclarationList(Keyword.CON
ST, AstFactory.typeName4("C", []), [ | 2533 _assertSource("const C a, b", AstFactory.variableDeclarationList(Keyword.CON
ST, AstFactory.typeName4("C"), [ |
| 2509 AstFactory.variableDeclaration("a"), | 2534 AstFactory.variableDeclaration("a"), |
| 2510 AstFactory.variableDeclaration("b")])); | 2535 AstFactory.variableDeclaration("b")])); |
| 2511 } | 2536 } |
| 2512 | 2537 |
| 2513 void test_visitVariableDeclarationList_final_noType() { | 2538 void test_visitVariableDeclarationList_final_noType() { |
| 2514 _assertSource("final a, b", AstFactory.variableDeclarationList2(Keyword.FINA
L, [ | 2539 _assertSource("final a, b", AstFactory.variableDeclarationList2(Keyword.FINA
L, [ |
| 2515 AstFactory.variableDeclaration("a"), | 2540 AstFactory.variableDeclaration("a"), |
| 2516 AstFactory.variableDeclaration("b")])); | 2541 AstFactory.variableDeclaration("b")])); |
| 2517 } | 2542 } |
| 2518 | 2543 |
| 2519 void test_visitVariableDeclarationList_final_withMetadata() { | 2544 void test_visitVariableDeclarationList_final_withMetadata() { |
| 2520 VariableDeclarationList declarationList = AstFactory.variableDeclarationList
2(Keyword.FINAL, [ | 2545 VariableDeclarationList declarationList = AstFactory.variableDeclarationList
2(Keyword.FINAL, [ |
| 2521 AstFactory.variableDeclaration("a"), | 2546 AstFactory.variableDeclaration("a"), |
| 2522 AstFactory.variableDeclaration("b")]); | 2547 AstFactory.variableDeclaration("b")]); |
| 2523 declarationList.metadata = AstFactory.list([AstFactory.annotation(AstFactory
.identifier3("deprecated"))]); | 2548 declarationList.metadata = [AstFactory.annotation(AstFactory.identifier3("de
precated"))]; |
| 2524 _assertSource("@deprecated final a, b", declarationList); | 2549 _assertSource("@deprecated final a, b", declarationList); |
| 2525 } | 2550 } |
| 2526 | 2551 |
| 2527 void test_visitVariableDeclarationList_type() { | 2552 void test_visitVariableDeclarationList_type() { |
| 2528 _assertSource("C a, b", AstFactory.variableDeclarationList(null, AstFactory.
typeName4("C", []), [ | 2553 _assertSource("C a, b", AstFactory.variableDeclarationList(null, AstFactory.
typeName4("C"), [ |
| 2529 AstFactory.variableDeclaration("a"), | 2554 AstFactory.variableDeclaration("a"), |
| 2530 AstFactory.variableDeclaration("b")])); | 2555 AstFactory.variableDeclaration("b")])); |
| 2531 } | 2556 } |
| 2532 | 2557 |
| 2533 void test_visitVariableDeclarationList_var() { | 2558 void test_visitVariableDeclarationList_var() { |
| 2534 _assertSource("var a, b", AstFactory.variableDeclarationList2(Keyword.VAR, [ | 2559 _assertSource("var a, b", AstFactory.variableDeclarationList2(Keyword.VAR, [ |
| 2535 AstFactory.variableDeclaration("a"), | 2560 AstFactory.variableDeclaration("a"), |
| 2536 AstFactory.variableDeclaration("b")])); | 2561 AstFactory.variableDeclaration("b")])); |
| 2537 } | 2562 } |
| 2538 | 2563 |
| 2539 void test_visitVariableDeclarationStatement() { | 2564 void test_visitVariableDeclarationStatement() { |
| 2540 _assertSource("C c;", AstFactory.variableDeclarationStatement(null, AstFacto
ry.typeName4("C", []), [AstFactory.variableDeclaration("c")])); | 2565 _assertSource("C c;", AstFactory.variableDeclarationStatement(null, AstFacto
ry.typeName4("C"), [AstFactory.variableDeclaration("c")])); |
| 2541 } | 2566 } |
| 2542 | 2567 |
| 2543 void test_visitWhileStatement() { | 2568 void test_visitWhileStatement() { |
| 2544 _assertSource("while (c) {}", AstFactory.whileStatement(AstFactory.identifie
r3("c"), AstFactory.block([]))); | 2569 _assertSource("while (c) {}", AstFactory.whileStatement(AstFactory.identifie
r3("c"), AstFactory.block())); |
| 2545 } | 2570 } |
| 2546 | 2571 |
| 2547 void test_visitWithClause_multiple() { | 2572 void test_visitWithClause_multiple() { |
| 2548 _assertSource("with A, B, C", AstFactory.withClause([ | 2573 _assertSource("with A, B, C", AstFactory.withClause([ |
| 2549 AstFactory.typeName4("A", []), | 2574 AstFactory.typeName4("A"), |
| 2550 AstFactory.typeName4("B", []), | 2575 AstFactory.typeName4("B"), |
| 2551 AstFactory.typeName4("C", [])])); | 2576 AstFactory.typeName4("C")])); |
| 2552 } | 2577 } |
| 2553 | 2578 |
| 2554 void test_visitWithClause_single() { | 2579 void test_visitWithClause_single() { |
| 2555 _assertSource("with A", AstFactory.withClause([AstFactory.typeName4("A", [])
])); | 2580 _assertSource("with A", AstFactory.withClause([AstFactory.typeName4("A")])); |
| 2556 } | 2581 } |
| 2557 | 2582 |
| 2558 void test_visitYieldStatement() { | 2583 void test_visitYieldStatement() { |
| 2559 _assertSource("yield e;", AstFactory.yieldStatement(AstFactory.identifier3("
e"))); | 2584 _assertSource("yield e;", AstFactory.yieldStatement(AstFactory.identifier3("
e"))); |
| 2560 } | 2585 } |
| 2561 | 2586 |
| 2562 void test_visitYieldStatement_each() { | 2587 void test_visitYieldStatement_each() { |
| 2563 _assertSource("yield* e;", AstFactory.yieldEachStatement(AstFactory.identifi
er3("e"))); | 2588 _assertSource("yield* e;", AstFactory.yieldEachStatement(AstFactory.identifi
er3("e"))); |
| 2564 } | 2589 } |
| 2565 | 2590 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2626 runReflectiveTests(BreadthFirstVisitorTest); | 2651 runReflectiveTests(BreadthFirstVisitorTest); |
| 2627 runReflectiveTests(ClassDeclarationTest); | 2652 runReflectiveTests(ClassDeclarationTest); |
| 2628 runReflectiveTests(ClassTypeAliasTest); | 2653 runReflectiveTests(ClassTypeAliasTest); |
| 2629 runReflectiveTests(IndexExpressionTest); | 2654 runReflectiveTests(IndexExpressionTest); |
| 2630 runReflectiveTests(NodeListTest); | 2655 runReflectiveTests(NodeListTest); |
| 2631 runReflectiveTests(SimpleIdentifierTest); | 2656 runReflectiveTests(SimpleIdentifierTest); |
| 2632 runReflectiveTests(SimpleStringLiteralTest); | 2657 runReflectiveTests(SimpleStringLiteralTest); |
| 2633 runReflectiveTests(StringInterpolationTest); | 2658 runReflectiveTests(StringInterpolationTest); |
| 2634 runReflectiveTests(VariableDeclarationTest); | 2659 runReflectiveTests(VariableDeclarationTest); |
| 2635 } | 2660 } |
| OLD | NEW |