Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: pkg/analyzer/test/src/dart/ast/utilities_test.dart

Issue 2524903002: Rename AstFactory -> AstTestFactory. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.test.src.dart.ast.utilities_test; 5 library analyzer.test.src.dart.ast.utilities_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/type.dart'; 10 import 'package:analyzer/dart/element/type.dart';
11 import 'package:analyzer/src/dart/ast/utilities.dart'; 11 import 'package:analyzer/src/dart/ast/utilities.dart';
12 import 'package:analyzer/src/dart/element/element.dart'; 12 import 'package:analyzer/src/dart/element/element.dart';
13 import 'package:analyzer/src/generated/java_core.dart'; 13 import 'package:analyzer/src/generated/java_core.dart';
14 import 'package:analyzer/src/generated/java_engine.dart' show Predicate; 14 import 'package:analyzer/src/generated/java_engine.dart' show Predicate;
15 import 'package:analyzer/src/generated/java_engine.dart'; 15 import 'package:analyzer/src/generated/java_engine.dart';
16 import 'package:analyzer/src/generated/testing/ast_factory.dart'; 16 import 'package:analyzer/src/generated/testing/ast_test_factory.dart';
17 import 'package:analyzer/src/generated/testing/element_factory.dart'; 17 import 'package:analyzer/src/generated/testing/element_factory.dart';
18 import 'package:analyzer/src/generated/testing/token_factory.dart'; 18 import 'package:analyzer/src/generated/testing/token_factory.dart';
19 import 'package:test/test.dart'; 19 import 'package:test/test.dart';
20 import 'package:test_reflective_loader/test_reflective_loader.dart'; 20 import 'package:test_reflective_loader/test_reflective_loader.dart';
21 21
22 import '../../../generated/parser_test.dart' show ParserTestCase; 22 import '../../../generated/parser_test.dart' show ParserTestCase;
23 import '../../../generated/test_support.dart'; 23 import '../../../generated/test_support.dart';
24 24
25 main() { 25 main() {
26 defineReflectiveSuite(() { 26 defineReflectiveSuite(() {
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 450
451 AdjacentStrings toNode = createNode(); 451 AdjacentStrings toNode = createNode();
452 ResolutionCopier.copyResolutionData(fromNode, toNode); 452 ResolutionCopier.copyResolutionData(fromNode, toNode);
453 expect(toNode.propagatedType, same(propagatedType)); 453 expect(toNode.propagatedType, same(propagatedType));
454 expect(toNode.staticType, same(staticType)); 454 expect(toNode.staticType, same(staticType));
455 } 455 }
456 456
457 void test_visitAnnotation() { 457 void test_visitAnnotation() {
458 String annotationName = "proxy"; 458 String annotationName = "proxy";
459 Annotation fromNode = 459 Annotation fromNode =
460 AstFactory.annotation(AstFactory.identifier3(annotationName)); 460 AstTestFactory.annotation(AstTestFactory.identifier3(annotationName));
461 Element element = ElementFactory.topLevelVariableElement2(annotationName); 461 Element element = ElementFactory.topLevelVariableElement2(annotationName);
462 fromNode.element = element; 462 fromNode.element = element;
463 Annotation toNode = 463 Annotation toNode =
464 AstFactory.annotation(AstFactory.identifier3(annotationName)); 464 AstTestFactory.annotation(AstTestFactory.identifier3(annotationName));
465 ResolutionCopier.copyResolutionData(fromNode, toNode); 465 ResolutionCopier.copyResolutionData(fromNode, toNode);
466 expect(toNode.element, same(element)); 466 expect(toNode.element, same(element));
467 } 467 }
468 468
469 void test_visitAsExpression() { 469 void test_visitAsExpression() {
470 AsExpression fromNode = AstFactory.asExpression( 470 AsExpression fromNode = AstTestFactory.asExpression(
471 AstFactory.identifier3("x"), AstFactory.typeName4("A")); 471 AstTestFactory.identifier3("x"), AstTestFactory.typeName4("A"));
472 DartType propagatedType = ElementFactory.classElement2("A").type; 472 DartType propagatedType = ElementFactory.classElement2("A").type;
473 fromNode.propagatedType = propagatedType; 473 fromNode.propagatedType = propagatedType;
474 DartType staticType = ElementFactory.classElement2("B").type; 474 DartType staticType = ElementFactory.classElement2("B").type;
475 fromNode.staticType = staticType; 475 fromNode.staticType = staticType;
476 AsExpression toNode = AstFactory.asExpression( 476 AsExpression toNode = AstTestFactory.asExpression(
477 AstFactory.identifier3("x"), AstFactory.typeName4("A")); 477 AstTestFactory.identifier3("x"), AstTestFactory.typeName4("A"));
478 ResolutionCopier.copyResolutionData(fromNode, toNode); 478 ResolutionCopier.copyResolutionData(fromNode, toNode);
479 expect(toNode.propagatedType, same(propagatedType)); 479 expect(toNode.propagatedType, same(propagatedType));
480 expect(toNode.staticType, same(staticType)); 480 expect(toNode.staticType, same(staticType));
481 } 481 }
482 482
483 void test_visitAssignmentExpression() { 483 void test_visitAssignmentExpression() {
484 AssignmentExpression fromNode = AstFactory.assignmentExpression( 484 AssignmentExpression fromNode = AstTestFactory.assignmentExpression(
485 AstFactory.identifier3("a"), 485 AstTestFactory.identifier3("a"),
486 TokenType.PLUS_EQ, 486 TokenType.PLUS_EQ,
487 AstFactory.identifier3("b")); 487 AstTestFactory.identifier3("b"));
488 DartType propagatedType = ElementFactory.classElement2("C").type; 488 DartType propagatedType = ElementFactory.classElement2("C").type;
489 MethodElement propagatedElement = 489 MethodElement propagatedElement =
490 ElementFactory.methodElement("+", propagatedType); 490 ElementFactory.methodElement("+", propagatedType);
491 fromNode.propagatedElement = propagatedElement; 491 fromNode.propagatedElement = propagatedElement;
492 fromNode.propagatedType = propagatedType; 492 fromNode.propagatedType = propagatedType;
493 DartType staticType = ElementFactory.classElement2("C").type; 493 DartType staticType = ElementFactory.classElement2("C").type;
494 MethodElement staticElement = ElementFactory.methodElement("+", staticType); 494 MethodElement staticElement = ElementFactory.methodElement("+", staticType);
495 fromNode.staticElement = staticElement; 495 fromNode.staticElement = staticElement;
496 fromNode.staticType = staticType; 496 fromNode.staticType = staticType;
497 AssignmentExpression toNode = AstFactory.assignmentExpression( 497 AssignmentExpression toNode = AstTestFactory.assignmentExpression(
498 AstFactory.identifier3("a"), 498 AstTestFactory.identifier3("a"),
499 TokenType.PLUS_EQ, 499 TokenType.PLUS_EQ,
500 AstFactory.identifier3("b")); 500 AstTestFactory.identifier3("b"));
501 ResolutionCopier.copyResolutionData(fromNode, toNode); 501 ResolutionCopier.copyResolutionData(fromNode, toNode);
502 expect(toNode.propagatedElement, same(propagatedElement)); 502 expect(toNode.propagatedElement, same(propagatedElement));
503 expect(toNode.propagatedType, same(propagatedType)); 503 expect(toNode.propagatedType, same(propagatedType));
504 expect(toNode.staticElement, same(staticElement)); 504 expect(toNode.staticElement, same(staticElement));
505 expect(toNode.staticType, same(staticType)); 505 expect(toNode.staticType, same(staticType));
506 } 506 }
507 507
508 void test_visitBinaryExpression() { 508 void test_visitBinaryExpression() {
509 BinaryExpression fromNode = AstFactory.binaryExpression( 509 BinaryExpression fromNode = AstTestFactory.binaryExpression(
510 AstFactory.identifier3("a"), 510 AstTestFactory.identifier3("a"),
511 TokenType.PLUS, 511 TokenType.PLUS,
512 AstFactory.identifier3("b")); 512 AstTestFactory.identifier3("b"));
513 DartType propagatedType = ElementFactory.classElement2("C").type; 513 DartType propagatedType = ElementFactory.classElement2("C").type;
514 MethodElement propagatedElement = 514 MethodElement propagatedElement =
515 ElementFactory.methodElement("+", propagatedType); 515 ElementFactory.methodElement("+", propagatedType);
516 fromNode.propagatedElement = propagatedElement; 516 fromNode.propagatedElement = propagatedElement;
517 fromNode.propagatedType = propagatedType; 517 fromNode.propagatedType = propagatedType;
518 DartType staticType = ElementFactory.classElement2("C").type; 518 DartType staticType = ElementFactory.classElement2("C").type;
519 MethodElement staticElement = ElementFactory.methodElement("+", staticType); 519 MethodElement staticElement = ElementFactory.methodElement("+", staticType);
520 fromNode.staticElement = staticElement; 520 fromNode.staticElement = staticElement;
521 fromNode.staticType = staticType; 521 fromNode.staticType = staticType;
522 BinaryExpression toNode = AstFactory.binaryExpression( 522 BinaryExpression toNode = AstTestFactory.binaryExpression(
523 AstFactory.identifier3("a"), 523 AstTestFactory.identifier3("a"),
524 TokenType.PLUS, 524 TokenType.PLUS,
525 AstFactory.identifier3("b")); 525 AstTestFactory.identifier3("b"));
526 ResolutionCopier.copyResolutionData(fromNode, toNode); 526 ResolutionCopier.copyResolutionData(fromNode, toNode);
527 expect(toNode.propagatedElement, same(propagatedElement)); 527 expect(toNode.propagatedElement, same(propagatedElement));
528 expect(toNode.propagatedType, same(propagatedType)); 528 expect(toNode.propagatedType, same(propagatedType));
529 expect(toNode.staticElement, same(staticElement)); 529 expect(toNode.staticElement, same(staticElement));
530 expect(toNode.staticType, same(staticType)); 530 expect(toNode.staticType, same(staticType));
531 } 531 }
532 532
533 void test_visitBooleanLiteral() { 533 void test_visitBooleanLiteral() {
534 BooleanLiteral fromNode = AstFactory.booleanLiteral(true); 534 BooleanLiteral fromNode = AstTestFactory.booleanLiteral(true);
535 DartType propagatedType = ElementFactory.classElement2("C").type; 535 DartType propagatedType = ElementFactory.classElement2("C").type;
536 fromNode.propagatedType = propagatedType; 536 fromNode.propagatedType = propagatedType;
537 DartType staticType = ElementFactory.classElement2("C").type; 537 DartType staticType = ElementFactory.classElement2("C").type;
538 fromNode.staticType = staticType; 538 fromNode.staticType = staticType;
539 BooleanLiteral toNode = AstFactory.booleanLiteral(true); 539 BooleanLiteral toNode = AstTestFactory.booleanLiteral(true);
540 ResolutionCopier.copyResolutionData(fromNode, toNode); 540 ResolutionCopier.copyResolutionData(fromNode, toNode);
541 expect(toNode.propagatedType, same(propagatedType)); 541 expect(toNode.propagatedType, same(propagatedType));
542 expect(toNode.staticType, same(staticType)); 542 expect(toNode.staticType, same(staticType));
543 } 543 }
544 544
545 void test_visitCascadeExpression() { 545 void test_visitCascadeExpression() {
546 CascadeExpression fromNode = AstFactory.cascadeExpression( 546 CascadeExpression fromNode = AstTestFactory.cascadeExpression(
547 AstFactory.identifier3("a"), [AstFactory.identifier3("b")]); 547 AstTestFactory.identifier3("a"), [AstTestFactory.identifier3("b")]);
548 DartType propagatedType = ElementFactory.classElement2("C").type; 548 DartType propagatedType = ElementFactory.classElement2("C").type;
549 fromNode.propagatedType = propagatedType; 549 fromNode.propagatedType = propagatedType;
550 DartType staticType = ElementFactory.classElement2("C").type; 550 DartType staticType = ElementFactory.classElement2("C").type;
551 fromNode.staticType = staticType; 551 fromNode.staticType = staticType;
552 CascadeExpression toNode = AstFactory.cascadeExpression( 552 CascadeExpression toNode = AstTestFactory.cascadeExpression(
553 AstFactory.identifier3("a"), [AstFactory.identifier3("b")]); 553 AstTestFactory.identifier3("a"), [AstTestFactory.identifier3("b")]);
554 ResolutionCopier.copyResolutionData(fromNode, toNode); 554 ResolutionCopier.copyResolutionData(fromNode, toNode);
555 expect(toNode.propagatedType, same(propagatedType)); 555 expect(toNode.propagatedType, same(propagatedType));
556 expect(toNode.staticType, same(staticType)); 556 expect(toNode.staticType, same(staticType));
557 } 557 }
558 558
559 void test_visitCompilationUnit() { 559 void test_visitCompilationUnit() {
560 CompilationUnit fromNode = AstFactory.compilationUnit(); 560 CompilationUnit fromNode = AstTestFactory.compilationUnit();
561 CompilationUnitElement element = 561 CompilationUnitElement element =
562 new CompilationUnitElementImpl("test.dart"); 562 new CompilationUnitElementImpl("test.dart");
563 fromNode.element = element; 563 fromNode.element = element;
564 CompilationUnit toNode = AstFactory.compilationUnit(); 564 CompilationUnit toNode = AstTestFactory.compilationUnit();
565 ResolutionCopier.copyResolutionData(fromNode, toNode); 565 ResolutionCopier.copyResolutionData(fromNode, toNode);
566 expect(toNode.element, same(element)); 566 expect(toNode.element, same(element));
567 } 567 }
568 568
569 void test_visitConditionalExpression() { 569 void test_visitConditionalExpression() {
570 ConditionalExpression fromNode = AstFactory.conditionalExpression( 570 ConditionalExpression fromNode = AstTestFactory.conditionalExpression(
571 AstFactory.identifier3("c"), 571 AstTestFactory.identifier3("c"),
572 AstFactory.identifier3("a"), 572 AstTestFactory.identifier3("a"),
573 AstFactory.identifier3("b")); 573 AstTestFactory.identifier3("b"));
574 DartType propagatedType = ElementFactory.classElement2("C").type; 574 DartType propagatedType = ElementFactory.classElement2("C").type;
575 fromNode.propagatedType = propagatedType; 575 fromNode.propagatedType = propagatedType;
576 DartType staticType = ElementFactory.classElement2("C").type; 576 DartType staticType = ElementFactory.classElement2("C").type;
577 fromNode.staticType = staticType; 577 fromNode.staticType = staticType;
578 ConditionalExpression toNode = AstFactory.conditionalExpression( 578 ConditionalExpression toNode = AstTestFactory.conditionalExpression(
579 AstFactory.identifier3("c"), 579 AstTestFactory.identifier3("c"),
580 AstFactory.identifier3("a"), 580 AstTestFactory.identifier3("a"),
581 AstFactory.identifier3("b")); 581 AstTestFactory.identifier3("b"));
582 ResolutionCopier.copyResolutionData(fromNode, toNode); 582 ResolutionCopier.copyResolutionData(fromNode, toNode);
583 expect(toNode.propagatedType, same(propagatedType)); 583 expect(toNode.propagatedType, same(propagatedType));
584 expect(toNode.staticType, same(staticType)); 584 expect(toNode.staticType, same(staticType));
585 } 585 }
586 586
587 void test_visitConstructorDeclaration() { 587 void test_visitConstructorDeclaration() {
588 String className = "A"; 588 String className = "A";
589 String constructorName = "c"; 589 String constructorName = "c";
590 ConstructorDeclaration fromNode = AstFactory.constructorDeclaration( 590 ConstructorDeclaration fromNode = AstTestFactory.constructorDeclaration(
591 AstFactory.identifier3(className), 591 AstTestFactory.identifier3(className),
592 constructorName, 592 constructorName,
593 AstFactory.formalParameterList(), 593 AstTestFactory.formalParameterList(),
594 null); 594 null);
595 ConstructorElement element = ElementFactory.constructorElement2( 595 ConstructorElement element = ElementFactory.constructorElement2(
596 ElementFactory.classElement2(className), constructorName); 596 ElementFactory.classElement2(className), constructorName);
597 fromNode.element = element; 597 fromNode.element = element;
598 ConstructorDeclaration toNode = AstFactory.constructorDeclaration( 598 ConstructorDeclaration toNode = AstTestFactory.constructorDeclaration(
599 AstFactory.identifier3(className), 599 AstTestFactory.identifier3(className),
600 constructorName, 600 constructorName,
601 AstFactory.formalParameterList(), 601 AstTestFactory.formalParameterList(),
602 null); 602 null);
603 ResolutionCopier.copyResolutionData(fromNode, toNode); 603 ResolutionCopier.copyResolutionData(fromNode, toNode);
604 expect(toNode.element, same(element)); 604 expect(toNode.element, same(element));
605 } 605 }
606 606
607 void test_visitConstructorName() { 607 void test_visitConstructorName() {
608 ConstructorName fromNode = 608 ConstructorName fromNode =
609 AstFactory.constructorName(AstFactory.typeName4("A"), "c"); 609 AstTestFactory.constructorName(AstTestFactory.typeName4("A"), "c");
610 ConstructorElement staticElement = ElementFactory.constructorElement2( 610 ConstructorElement staticElement = ElementFactory.constructorElement2(
611 ElementFactory.classElement2("A"), "c"); 611 ElementFactory.classElement2("A"), "c");
612 fromNode.staticElement = staticElement; 612 fromNode.staticElement = staticElement;
613 ConstructorName toNode = 613 ConstructorName toNode =
614 AstFactory.constructorName(AstFactory.typeName4("A"), "c"); 614 AstTestFactory.constructorName(AstTestFactory.typeName4("A"), "c");
615 ResolutionCopier.copyResolutionData(fromNode, toNode); 615 ResolutionCopier.copyResolutionData(fromNode, toNode);
616 expect(toNode.staticElement, same(staticElement)); 616 expect(toNode.staticElement, same(staticElement));
617 } 617 }
618 618
619 void test_visitDoubleLiteral() { 619 void test_visitDoubleLiteral() {
620 DoubleLiteral fromNode = AstFactory.doubleLiteral(1.0); 620 DoubleLiteral fromNode = AstTestFactory.doubleLiteral(1.0);
621 DartType propagatedType = ElementFactory.classElement2("C").type; 621 DartType propagatedType = ElementFactory.classElement2("C").type;
622 fromNode.propagatedType = propagatedType; 622 fromNode.propagatedType = propagatedType;
623 DartType staticType = ElementFactory.classElement2("C").type; 623 DartType staticType = ElementFactory.classElement2("C").type;
624 fromNode.staticType = staticType; 624 fromNode.staticType = staticType;
625 DoubleLiteral toNode = AstFactory.doubleLiteral(1.0); 625 DoubleLiteral toNode = AstTestFactory.doubleLiteral(1.0);
626 ResolutionCopier.copyResolutionData(fromNode, toNode); 626 ResolutionCopier.copyResolutionData(fromNode, toNode);
627 expect(toNode.propagatedType, same(propagatedType)); 627 expect(toNode.propagatedType, same(propagatedType));
628 expect(toNode.staticType, same(staticType)); 628 expect(toNode.staticType, same(staticType));
629 } 629 }
630 630
631 void test_visitExportDirective() { 631 void test_visitExportDirective() {
632 ExportDirective fromNode = AstFactory.exportDirective2("dart:uri"); 632 ExportDirective fromNode = AstTestFactory.exportDirective2("dart:uri");
633 ExportElement element = new ExportElementImpl(-1); 633 ExportElement element = new ExportElementImpl(-1);
634 fromNode.element = element; 634 fromNode.element = element;
635 ExportDirective toNode = AstFactory.exportDirective2("dart:uri"); 635 ExportDirective toNode = AstTestFactory.exportDirective2("dart:uri");
636 ResolutionCopier.copyResolutionData(fromNode, toNode); 636 ResolutionCopier.copyResolutionData(fromNode, toNode);
637 expect(toNode.element, same(element)); 637 expect(toNode.element, same(element));
638 } 638 }
639 639
640 void test_visitFunctionExpression() { 640 void test_visitFunctionExpression() {
641 FunctionExpression fromNode = AstFactory.functionExpression2( 641 FunctionExpression fromNode = AstTestFactory.functionExpression2(
642 AstFactory.formalParameterList(), AstFactory.emptyFunctionBody()); 642 AstTestFactory.formalParameterList(),
643 AstTestFactory.emptyFunctionBody());
643 MethodElement element = ElementFactory.methodElement( 644 MethodElement element = ElementFactory.methodElement(
644 "m", ElementFactory.classElement2("C").type); 645 "m", ElementFactory.classElement2("C").type);
645 fromNode.element = element; 646 fromNode.element = element;
646 DartType propagatedType = ElementFactory.classElement2("C").type; 647 DartType propagatedType = ElementFactory.classElement2("C").type;
647 fromNode.propagatedType = propagatedType; 648 fromNode.propagatedType = propagatedType;
648 DartType staticType = ElementFactory.classElement2("C").type; 649 DartType staticType = ElementFactory.classElement2("C").type;
649 fromNode.staticType = staticType; 650 fromNode.staticType = staticType;
650 FunctionExpression toNode = AstFactory.functionExpression2( 651 FunctionExpression toNode = AstTestFactory.functionExpression2(
651 AstFactory.formalParameterList(), AstFactory.emptyFunctionBody()); 652 AstTestFactory.formalParameterList(),
653 AstTestFactory.emptyFunctionBody());
652 ResolutionCopier.copyResolutionData(fromNode, toNode); 654 ResolutionCopier.copyResolutionData(fromNode, toNode);
653 expect(toNode.element, same(element)); 655 expect(toNode.element, same(element));
654 expect(toNode.propagatedType, same(propagatedType)); 656 expect(toNode.propagatedType, same(propagatedType));
655 expect(toNode.staticType, same(staticType)); 657 expect(toNode.staticType, same(staticType));
656 } 658 }
657 659
658 void test_visitFunctionExpressionInvocation() { 660 void test_visitFunctionExpressionInvocation() {
659 FunctionExpressionInvocation fromNode = 661 FunctionExpressionInvocation fromNode = AstTestFactory
660 AstFactory.functionExpressionInvocation(AstFactory.identifier3("f")); 662 .functionExpressionInvocation(AstTestFactory.identifier3("f"));
661 MethodElement propagatedElement = ElementFactory.methodElement( 663 MethodElement propagatedElement = ElementFactory.methodElement(
662 "m", ElementFactory.classElement2("C").type); 664 "m", ElementFactory.classElement2("C").type);
663 fromNode.propagatedElement = propagatedElement; 665 fromNode.propagatedElement = propagatedElement;
664 MethodElement staticElement = ElementFactory.methodElement( 666 MethodElement staticElement = ElementFactory.methodElement(
665 "m", ElementFactory.classElement2("C").type); 667 "m", ElementFactory.classElement2("C").type);
666 fromNode.staticElement = staticElement; 668 fromNode.staticElement = staticElement;
667 FunctionExpressionInvocation toNode = 669 FunctionExpressionInvocation toNode = AstTestFactory
668 AstFactory.functionExpressionInvocation(AstFactory.identifier3("f")); 670 .functionExpressionInvocation(AstTestFactory.identifier3("f"));
669 ClassElement elementT = ElementFactory.classElement2('T'); 671 ClassElement elementT = ElementFactory.classElement2('T');
670 fromNode.typeArguments = 672 fromNode.typeArguments = AstTestFactory
671 AstFactory.typeArgumentList(<TypeName>[AstFactory.typeName(elementT)]); 673 .typeArgumentList(<TypeName>[AstTestFactory.typeName(elementT)]);
672 toNode.typeArguments = 674 toNode.typeArguments = AstTestFactory
673 AstFactory.typeArgumentList(<TypeName>[AstFactory.typeName4('T')]); 675 .typeArgumentList(<TypeName>[AstTestFactory.typeName4('T')]);
674 676
675 _copyAndVerifyInvocation(fromNode, toNode); 677 _copyAndVerifyInvocation(fromNode, toNode);
676 678
677 expect(toNode.propagatedElement, same(propagatedElement)); 679 expect(toNode.propagatedElement, same(propagatedElement));
678 expect(toNode.staticElement, same(staticElement)); 680 expect(toNode.staticElement, same(staticElement));
679 } 681 }
680 682
681 void test_visitImportDirective() { 683 void test_visitImportDirective() {
682 ImportDirective fromNode = AstFactory.importDirective3("dart:uri", null); 684 ImportDirective fromNode =
685 AstTestFactory.importDirective3("dart:uri", null);
683 ImportElement element = new ImportElementImpl(0); 686 ImportElement element = new ImportElementImpl(0);
684 fromNode.element = element; 687 fromNode.element = element;
685 ImportDirective toNode = AstFactory.importDirective3("dart:uri", null); 688 ImportDirective toNode = AstTestFactory.importDirective3("dart:uri", null);
686 ResolutionCopier.copyResolutionData(fromNode, toNode); 689 ResolutionCopier.copyResolutionData(fromNode, toNode);
687 expect(toNode.element, same(element)); 690 expect(toNode.element, same(element));
688 } 691 }
689 692
690 void test_visitIndexExpression() { 693 void test_visitIndexExpression() {
691 IndexExpression fromNode = AstFactory.indexExpression( 694 IndexExpression fromNode = AstTestFactory.indexExpression(
692 AstFactory.identifier3("a"), AstFactory.integer(0)); 695 AstTestFactory.identifier3("a"), AstTestFactory.integer(0));
693 MethodElement propagatedElement = ElementFactory.methodElement( 696 MethodElement propagatedElement = ElementFactory.methodElement(
694 "m", ElementFactory.classElement2("C").type); 697 "m", ElementFactory.classElement2("C").type);
695 MethodElement staticElement = ElementFactory.methodElement( 698 MethodElement staticElement = ElementFactory.methodElement(
696 "m", ElementFactory.classElement2("C").type); 699 "m", ElementFactory.classElement2("C").type);
697 AuxiliaryElements auxiliaryElements = 700 AuxiliaryElements auxiliaryElements =
698 new AuxiliaryElements(staticElement, propagatedElement); 701 new AuxiliaryElements(staticElement, propagatedElement);
699 fromNode.auxiliaryElements = auxiliaryElements; 702 fromNode.auxiliaryElements = auxiliaryElements;
700 fromNode.propagatedElement = propagatedElement; 703 fromNode.propagatedElement = propagatedElement;
701 DartType propagatedType = ElementFactory.classElement2("C").type; 704 DartType propagatedType = ElementFactory.classElement2("C").type;
702 fromNode.propagatedType = propagatedType; 705 fromNode.propagatedType = propagatedType;
703 fromNode.staticElement = staticElement; 706 fromNode.staticElement = staticElement;
704 DartType staticType = ElementFactory.classElement2("C").type; 707 DartType staticType = ElementFactory.classElement2("C").type;
705 fromNode.staticType = staticType; 708 fromNode.staticType = staticType;
706 IndexExpression toNode = AstFactory.indexExpression( 709 IndexExpression toNode = AstTestFactory.indexExpression(
707 AstFactory.identifier3("a"), AstFactory.integer(0)); 710 AstTestFactory.identifier3("a"), AstTestFactory.integer(0));
708 ResolutionCopier.copyResolutionData(fromNode, toNode); 711 ResolutionCopier.copyResolutionData(fromNode, toNode);
709 expect(toNode.auxiliaryElements, same(auxiliaryElements)); 712 expect(toNode.auxiliaryElements, same(auxiliaryElements));
710 expect(toNode.propagatedElement, same(propagatedElement)); 713 expect(toNode.propagatedElement, same(propagatedElement));
711 expect(toNode.propagatedType, same(propagatedType)); 714 expect(toNode.propagatedType, same(propagatedType));
712 expect(toNode.staticElement, same(staticElement)); 715 expect(toNode.staticElement, same(staticElement));
713 expect(toNode.staticType, same(staticType)); 716 expect(toNode.staticType, same(staticType));
714 } 717 }
715 718
716 void test_visitInstanceCreationExpression() { 719 void test_visitInstanceCreationExpression() {
717 InstanceCreationExpression fromNode = AstFactory 720 InstanceCreationExpression fromNode =
718 .instanceCreationExpression2(Keyword.NEW, AstFactory.typeName4("C")); 721 AstTestFactory.instanceCreationExpression2(
722 Keyword.NEW, AstTestFactory.typeName4("C"));
719 DartType propagatedType = ElementFactory.classElement2("C").type; 723 DartType propagatedType = ElementFactory.classElement2("C").type;
720 fromNode.propagatedType = propagatedType; 724 fromNode.propagatedType = propagatedType;
721 ConstructorElement staticElement = ElementFactory.constructorElement2( 725 ConstructorElement staticElement = ElementFactory.constructorElement2(
722 ElementFactory.classElement2("C"), null); 726 ElementFactory.classElement2("C"), null);
723 fromNode.staticElement = staticElement; 727 fromNode.staticElement = staticElement;
724 DartType staticType = ElementFactory.classElement2("C").type; 728 DartType staticType = ElementFactory.classElement2("C").type;
725 fromNode.staticType = staticType; 729 fromNode.staticType = staticType;
726 InstanceCreationExpression toNode = AstFactory.instanceCreationExpression2( 730 InstanceCreationExpression toNode =
727 Keyword.NEW, AstFactory.typeName4("C")); 731 AstTestFactory.instanceCreationExpression2(
732 Keyword.NEW, AstTestFactory.typeName4("C"));
728 ResolutionCopier.copyResolutionData(fromNode, toNode); 733 ResolutionCopier.copyResolutionData(fromNode, toNode);
729 expect(toNode.propagatedType, same(propagatedType)); 734 expect(toNode.propagatedType, same(propagatedType));
730 expect(toNode.staticElement, same(staticElement)); 735 expect(toNode.staticElement, same(staticElement));
731 expect(toNode.staticType, same(staticType)); 736 expect(toNode.staticType, same(staticType));
732 } 737 }
733 738
734 void test_visitIntegerLiteral() { 739 void test_visitIntegerLiteral() {
735 IntegerLiteral fromNode = AstFactory.integer(2); 740 IntegerLiteral fromNode = AstTestFactory.integer(2);
736 DartType propagatedType = ElementFactory.classElement2("C").type; 741 DartType propagatedType = ElementFactory.classElement2("C").type;
737 fromNode.propagatedType = propagatedType; 742 fromNode.propagatedType = propagatedType;
738 DartType staticType = ElementFactory.classElement2("C").type; 743 DartType staticType = ElementFactory.classElement2("C").type;
739 fromNode.staticType = staticType; 744 fromNode.staticType = staticType;
740 IntegerLiteral toNode = AstFactory.integer(2); 745 IntegerLiteral toNode = AstTestFactory.integer(2);
741 ResolutionCopier.copyResolutionData(fromNode, toNode); 746 ResolutionCopier.copyResolutionData(fromNode, toNode);
742 expect(toNode.propagatedType, same(propagatedType)); 747 expect(toNode.propagatedType, same(propagatedType));
743 expect(toNode.staticType, same(staticType)); 748 expect(toNode.staticType, same(staticType));
744 } 749 }
745 750
746 void test_visitIsExpression() { 751 void test_visitIsExpression() {
747 IsExpression fromNode = AstFactory.isExpression( 752 IsExpression fromNode = AstTestFactory.isExpression(
748 AstFactory.identifier3("x"), false, AstFactory.typeName4("A")); 753 AstTestFactory.identifier3("x"), false, AstTestFactory.typeName4("A"));
749 DartType propagatedType = ElementFactory.classElement2("C").type; 754 DartType propagatedType = ElementFactory.classElement2("C").type;
750 fromNode.propagatedType = propagatedType; 755 fromNode.propagatedType = propagatedType;
751 DartType staticType = ElementFactory.classElement2("C").type; 756 DartType staticType = ElementFactory.classElement2("C").type;
752 fromNode.staticType = staticType; 757 fromNode.staticType = staticType;
753 IsExpression toNode = AstFactory.isExpression( 758 IsExpression toNode = AstTestFactory.isExpression(
754 AstFactory.identifier3("x"), false, AstFactory.typeName4("A")); 759 AstTestFactory.identifier3("x"), false, AstTestFactory.typeName4("A"));
755 ResolutionCopier.copyResolutionData(fromNode, toNode); 760 ResolutionCopier.copyResolutionData(fromNode, toNode);
756 expect(toNode.propagatedType, same(propagatedType)); 761 expect(toNode.propagatedType, same(propagatedType));
757 expect(toNode.staticType, same(staticType)); 762 expect(toNode.staticType, same(staticType));
758 } 763 }
759 764
760 void test_visitLibraryIdentifier() { 765 void test_visitLibraryIdentifier() {
761 LibraryIdentifier fromNode = 766 LibraryIdentifier fromNode =
762 AstFactory.libraryIdentifier([AstFactory.identifier3("lib")]); 767 AstTestFactory.libraryIdentifier([AstTestFactory.identifier3("lib")]);
763 DartType propagatedType = ElementFactory.classElement2("C").type; 768 DartType propagatedType = ElementFactory.classElement2("C").type;
764 fromNode.propagatedType = propagatedType; 769 fromNode.propagatedType = propagatedType;
765 DartType staticType = ElementFactory.classElement2("C").type; 770 DartType staticType = ElementFactory.classElement2("C").type;
766 fromNode.staticType = staticType; 771 fromNode.staticType = staticType;
767 LibraryIdentifier toNode = 772 LibraryIdentifier toNode =
768 AstFactory.libraryIdentifier([AstFactory.identifier3("lib")]); 773 AstTestFactory.libraryIdentifier([AstTestFactory.identifier3("lib")]);
769 ResolutionCopier.copyResolutionData(fromNode, toNode); 774 ResolutionCopier.copyResolutionData(fromNode, toNode);
770 expect(toNode.propagatedType, same(propagatedType)); 775 expect(toNode.propagatedType, same(propagatedType));
771 expect(toNode.staticType, same(staticType)); 776 expect(toNode.staticType, same(staticType));
772 } 777 }
773 778
774 void test_visitListLiteral() { 779 void test_visitListLiteral() {
775 ListLiteral fromNode = AstFactory.listLiteral(); 780 ListLiteral fromNode = AstTestFactory.listLiteral();
776 DartType propagatedType = ElementFactory.classElement2("C").type; 781 DartType propagatedType = ElementFactory.classElement2("C").type;
777 fromNode.propagatedType = propagatedType; 782 fromNode.propagatedType = propagatedType;
778 DartType staticType = ElementFactory.classElement2("C").type; 783 DartType staticType = ElementFactory.classElement2("C").type;
779 fromNode.staticType = staticType; 784 fromNode.staticType = staticType;
780 ListLiteral toNode = AstFactory.listLiteral(); 785 ListLiteral toNode = AstTestFactory.listLiteral();
781 ResolutionCopier.copyResolutionData(fromNode, toNode); 786 ResolutionCopier.copyResolutionData(fromNode, toNode);
782 expect(toNode.propagatedType, same(propagatedType)); 787 expect(toNode.propagatedType, same(propagatedType));
783 expect(toNode.staticType, same(staticType)); 788 expect(toNode.staticType, same(staticType));
784 } 789 }
785 790
786 void test_visitMapLiteral() { 791 void test_visitMapLiteral() {
787 MapLiteral fromNode = AstFactory.mapLiteral2(); 792 MapLiteral fromNode = AstTestFactory.mapLiteral2();
788 DartType propagatedType = ElementFactory.classElement2("C").type; 793 DartType propagatedType = ElementFactory.classElement2("C").type;
789 fromNode.propagatedType = propagatedType; 794 fromNode.propagatedType = propagatedType;
790 DartType staticType = ElementFactory.classElement2("C").type; 795 DartType staticType = ElementFactory.classElement2("C").type;
791 fromNode.staticType = staticType; 796 fromNode.staticType = staticType;
792 MapLiteral toNode = AstFactory.mapLiteral2(); 797 MapLiteral toNode = AstTestFactory.mapLiteral2();
793 ResolutionCopier.copyResolutionData(fromNode, toNode); 798 ResolutionCopier.copyResolutionData(fromNode, toNode);
794 expect(toNode.propagatedType, same(propagatedType)); 799 expect(toNode.propagatedType, same(propagatedType));
795 expect(toNode.staticType, same(staticType)); 800 expect(toNode.staticType, same(staticType));
796 } 801 }
797 802
798 void test_visitMethodInvocation() { 803 void test_visitMethodInvocation() {
799 MethodInvocation fromNode = AstFactory.methodInvocation2("m"); 804 MethodInvocation fromNode = AstTestFactory.methodInvocation2("m");
800 MethodInvocation toNode = AstFactory.methodInvocation2("m"); 805 MethodInvocation toNode = AstTestFactory.methodInvocation2("m");
801 ClassElement elementT = ElementFactory.classElement2('T'); 806 ClassElement elementT = ElementFactory.classElement2('T');
802 fromNode.typeArguments = 807 fromNode.typeArguments = AstTestFactory
803 AstFactory.typeArgumentList(<TypeName>[AstFactory.typeName(elementT)]); 808 .typeArgumentList(<TypeName>[AstTestFactory.typeName(elementT)]);
804 toNode.typeArguments = 809 toNode.typeArguments = AstTestFactory
805 AstFactory.typeArgumentList(<TypeName>[AstFactory.typeName4('T')]); 810 .typeArgumentList(<TypeName>[AstTestFactory.typeName4('T')]);
806 _copyAndVerifyInvocation(fromNode, toNode); 811 _copyAndVerifyInvocation(fromNode, toNode);
807 } 812 }
808 813
809 void test_visitNamedExpression() { 814 void test_visitNamedExpression() {
810 NamedExpression fromNode = 815 NamedExpression fromNode =
811 AstFactory.namedExpression2("n", AstFactory.integer(0)); 816 AstTestFactory.namedExpression2("n", AstTestFactory.integer(0));
812 DartType propagatedType = ElementFactory.classElement2("C").type; 817 DartType propagatedType = ElementFactory.classElement2("C").type;
813 fromNode.propagatedType = propagatedType; 818 fromNode.propagatedType = propagatedType;
814 DartType staticType = ElementFactory.classElement2("C").type; 819 DartType staticType = ElementFactory.classElement2("C").type;
815 fromNode.staticType = staticType; 820 fromNode.staticType = staticType;
816 NamedExpression toNode = 821 NamedExpression toNode =
817 AstFactory.namedExpression2("n", AstFactory.integer(0)); 822 AstTestFactory.namedExpression2("n", AstTestFactory.integer(0));
818 ResolutionCopier.copyResolutionData(fromNode, toNode); 823 ResolutionCopier.copyResolutionData(fromNode, toNode);
819 expect(toNode.propagatedType, same(propagatedType)); 824 expect(toNode.propagatedType, same(propagatedType));
820 expect(toNode.staticType, same(staticType)); 825 expect(toNode.staticType, same(staticType));
821 } 826 }
822 827
823 void test_visitNullLiteral() { 828 void test_visitNullLiteral() {
824 NullLiteral fromNode = AstFactory.nullLiteral(); 829 NullLiteral fromNode = AstTestFactory.nullLiteral();
825 DartType propagatedType = ElementFactory.classElement2("C").type; 830 DartType propagatedType = ElementFactory.classElement2("C").type;
826 fromNode.propagatedType = propagatedType; 831 fromNode.propagatedType = propagatedType;
827 DartType staticType = ElementFactory.classElement2("C").type; 832 DartType staticType = ElementFactory.classElement2("C").type;
828 fromNode.staticType = staticType; 833 fromNode.staticType = staticType;
829 NullLiteral toNode = AstFactory.nullLiteral(); 834 NullLiteral toNode = AstTestFactory.nullLiteral();
830 ResolutionCopier.copyResolutionData(fromNode, toNode); 835 ResolutionCopier.copyResolutionData(fromNode, toNode);
831 expect(toNode.propagatedType, same(propagatedType)); 836 expect(toNode.propagatedType, same(propagatedType));
832 expect(toNode.staticType, same(staticType)); 837 expect(toNode.staticType, same(staticType));
833 } 838 }
834 839
835 void test_visitParenthesizedExpression() { 840 void test_visitParenthesizedExpression() {
836 ParenthesizedExpression fromNode = 841 ParenthesizedExpression fromNode =
837 AstFactory.parenthesizedExpression(AstFactory.integer(0)); 842 AstTestFactory.parenthesizedExpression(AstTestFactory.integer(0));
838 DartType propagatedType = ElementFactory.classElement2("C").type; 843 DartType propagatedType = ElementFactory.classElement2("C").type;
839 fromNode.propagatedType = propagatedType; 844 fromNode.propagatedType = propagatedType;
840 DartType staticType = ElementFactory.classElement2("C").type; 845 DartType staticType = ElementFactory.classElement2("C").type;
841 fromNode.staticType = staticType; 846 fromNode.staticType = staticType;
842 ParenthesizedExpression toNode = 847 ParenthesizedExpression toNode =
843 AstFactory.parenthesizedExpression(AstFactory.integer(0)); 848 AstTestFactory.parenthesizedExpression(AstTestFactory.integer(0));
844 ResolutionCopier.copyResolutionData(fromNode, toNode); 849 ResolutionCopier.copyResolutionData(fromNode, toNode);
845 expect(toNode.propagatedType, same(propagatedType)); 850 expect(toNode.propagatedType, same(propagatedType));
846 expect(toNode.staticType, same(staticType)); 851 expect(toNode.staticType, same(staticType));
847 } 852 }
848 853
849 void test_visitPartDirective() { 854 void test_visitPartDirective() {
850 PartDirective fromNode = AstFactory.partDirective2("part.dart"); 855 PartDirective fromNode = AstTestFactory.partDirective2("part.dart");
851 LibraryElement element = new LibraryElementImpl.forNode( 856 LibraryElement element = new LibraryElementImpl.forNode(
852 null, AstFactory.libraryIdentifier2(["lib"])); 857 null, AstTestFactory.libraryIdentifier2(["lib"]));
853 fromNode.element = element; 858 fromNode.element = element;
854 PartDirective toNode = AstFactory.partDirective2("part.dart"); 859 PartDirective toNode = AstTestFactory.partDirective2("part.dart");
855 ResolutionCopier.copyResolutionData(fromNode, toNode); 860 ResolutionCopier.copyResolutionData(fromNode, toNode);
856 expect(toNode.element, same(element)); 861 expect(toNode.element, same(element));
857 } 862 }
858 863
859 void test_visitPartOfDirective() { 864 void test_visitPartOfDirective() {
860 PartOfDirective fromNode = 865 PartOfDirective fromNode = AstTestFactory
861 AstFactory.partOfDirective(AstFactory.libraryIdentifier2(["lib"])); 866 .partOfDirective(AstTestFactory.libraryIdentifier2(["lib"]));
862 LibraryElement element = new LibraryElementImpl.forNode( 867 LibraryElement element = new LibraryElementImpl.forNode(
863 null, AstFactory.libraryIdentifier2(["lib"])); 868 null, AstTestFactory.libraryIdentifier2(["lib"]));
864 fromNode.element = element; 869 fromNode.element = element;
865 PartOfDirective toNode = 870 PartOfDirective toNode = AstTestFactory
866 AstFactory.partOfDirective(AstFactory.libraryIdentifier2(["lib"])); 871 .partOfDirective(AstTestFactory.libraryIdentifier2(["lib"]));
867 ResolutionCopier.copyResolutionData(fromNode, toNode); 872 ResolutionCopier.copyResolutionData(fromNode, toNode);
868 expect(toNode.element, same(element)); 873 expect(toNode.element, same(element));
869 } 874 }
870 875
871 void test_visitPostfixExpression() { 876 void test_visitPostfixExpression() {
872 String variableName = "x"; 877 String variableName = "x";
873 PostfixExpression fromNode = AstFactory.postfixExpression( 878 PostfixExpression fromNode = AstTestFactory.postfixExpression(
874 AstFactory.identifier3(variableName), TokenType.PLUS_PLUS); 879 AstTestFactory.identifier3(variableName), TokenType.PLUS_PLUS);
875 MethodElement propagatedElement = ElementFactory.methodElement( 880 MethodElement propagatedElement = ElementFactory.methodElement(
876 "+", ElementFactory.classElement2("C").type); 881 "+", ElementFactory.classElement2("C").type);
877 fromNode.propagatedElement = propagatedElement; 882 fromNode.propagatedElement = propagatedElement;
878 DartType propagatedType = ElementFactory.classElement2("C").type; 883 DartType propagatedType = ElementFactory.classElement2("C").type;
879 fromNode.propagatedType = propagatedType; 884 fromNode.propagatedType = propagatedType;
880 MethodElement staticElement = ElementFactory.methodElement( 885 MethodElement staticElement = ElementFactory.methodElement(
881 "+", ElementFactory.classElement2("C").type); 886 "+", ElementFactory.classElement2("C").type);
882 fromNode.staticElement = staticElement; 887 fromNode.staticElement = staticElement;
883 DartType staticType = ElementFactory.classElement2("C").type; 888 DartType staticType = ElementFactory.classElement2("C").type;
884 fromNode.staticType = staticType; 889 fromNode.staticType = staticType;
885 PostfixExpression toNode = AstFactory.postfixExpression( 890 PostfixExpression toNode = AstTestFactory.postfixExpression(
886 AstFactory.identifier3(variableName), TokenType.PLUS_PLUS); 891 AstTestFactory.identifier3(variableName), TokenType.PLUS_PLUS);
887 ResolutionCopier.copyResolutionData(fromNode, toNode); 892 ResolutionCopier.copyResolutionData(fromNode, toNode);
888 expect(toNode.propagatedElement, same(propagatedElement)); 893 expect(toNode.propagatedElement, same(propagatedElement));
889 expect(toNode.propagatedType, same(propagatedType)); 894 expect(toNode.propagatedType, same(propagatedType));
890 expect(toNode.staticElement, same(staticElement)); 895 expect(toNode.staticElement, same(staticElement));
891 expect(toNode.staticType, same(staticType)); 896 expect(toNode.staticType, same(staticType));
892 } 897 }
893 898
894 void test_visitPrefixedIdentifier() { 899 void test_visitPrefixedIdentifier() {
895 PrefixedIdentifier fromNode = AstFactory.identifier5("p", "f"); 900 PrefixedIdentifier fromNode = AstTestFactory.identifier5("p", "f");
896 DartType propagatedType = ElementFactory.classElement2("C").type; 901 DartType propagatedType = ElementFactory.classElement2("C").type;
897 fromNode.propagatedType = propagatedType; 902 fromNode.propagatedType = propagatedType;
898 DartType staticType = ElementFactory.classElement2("C").type; 903 DartType staticType = ElementFactory.classElement2("C").type;
899 fromNode.staticType = staticType; 904 fromNode.staticType = staticType;
900 PrefixedIdentifier toNode = AstFactory.identifier5("p", "f"); 905 PrefixedIdentifier toNode = AstTestFactory.identifier5("p", "f");
901 ResolutionCopier.copyResolutionData(fromNode, toNode); 906 ResolutionCopier.copyResolutionData(fromNode, toNode);
902 expect(toNode.propagatedType, same(propagatedType)); 907 expect(toNode.propagatedType, same(propagatedType));
903 expect(toNode.staticType, same(staticType)); 908 expect(toNode.staticType, same(staticType));
904 } 909 }
905 910
906 void test_visitPrefixExpression() { 911 void test_visitPrefixExpression() {
907 PrefixExpression fromNode = AstFactory.prefixExpression( 912 PrefixExpression fromNode = AstTestFactory.prefixExpression(
908 TokenType.PLUS_PLUS, AstFactory.identifier3("x")); 913 TokenType.PLUS_PLUS, AstTestFactory.identifier3("x"));
909 MethodElement propagatedElement = ElementFactory.methodElement( 914 MethodElement propagatedElement = ElementFactory.methodElement(
910 "+", ElementFactory.classElement2("C").type); 915 "+", ElementFactory.classElement2("C").type);
911 DartType propagatedType = ElementFactory.classElement2("C").type; 916 DartType propagatedType = ElementFactory.classElement2("C").type;
912 fromNode.propagatedElement = propagatedElement; 917 fromNode.propagatedElement = propagatedElement;
913 fromNode.propagatedType = propagatedType; 918 fromNode.propagatedType = propagatedType;
914 DartType staticType = ElementFactory.classElement2("C").type; 919 DartType staticType = ElementFactory.classElement2("C").type;
915 MethodElement staticElement = ElementFactory.methodElement( 920 MethodElement staticElement = ElementFactory.methodElement(
916 "+", ElementFactory.classElement2("C").type); 921 "+", ElementFactory.classElement2("C").type);
917 fromNode.staticElement = staticElement; 922 fromNode.staticElement = staticElement;
918 fromNode.staticType = staticType; 923 fromNode.staticType = staticType;
919 PrefixExpression toNode = AstFactory.prefixExpression( 924 PrefixExpression toNode = AstTestFactory.prefixExpression(
920 TokenType.PLUS_PLUS, AstFactory.identifier3("x")); 925 TokenType.PLUS_PLUS, AstTestFactory.identifier3("x"));
921 ResolutionCopier.copyResolutionData(fromNode, toNode); 926 ResolutionCopier.copyResolutionData(fromNode, toNode);
922 expect(toNode.propagatedElement, same(propagatedElement)); 927 expect(toNode.propagatedElement, same(propagatedElement));
923 expect(toNode.propagatedType, same(propagatedType)); 928 expect(toNode.propagatedType, same(propagatedType));
924 expect(toNode.staticElement, same(staticElement)); 929 expect(toNode.staticElement, same(staticElement));
925 expect(toNode.staticType, same(staticType)); 930 expect(toNode.staticType, same(staticType));
926 } 931 }
927 932
928 void test_visitPropertyAccess() { 933 void test_visitPropertyAccess() {
929 PropertyAccess fromNode = 934 PropertyAccess fromNode =
930 AstFactory.propertyAccess2(AstFactory.identifier3("x"), "y"); 935 AstTestFactory.propertyAccess2(AstTestFactory.identifier3("x"), "y");
931 DartType propagatedType = ElementFactory.classElement2("C").type; 936 DartType propagatedType = ElementFactory.classElement2("C").type;
932 fromNode.propagatedType = propagatedType; 937 fromNode.propagatedType = propagatedType;
933 DartType staticType = ElementFactory.classElement2("C").type; 938 DartType staticType = ElementFactory.classElement2("C").type;
934 fromNode.staticType = staticType; 939 fromNode.staticType = staticType;
935 PropertyAccess toNode = 940 PropertyAccess toNode =
936 AstFactory.propertyAccess2(AstFactory.identifier3("x"), "y"); 941 AstTestFactory.propertyAccess2(AstTestFactory.identifier3("x"), "y");
937 ResolutionCopier.copyResolutionData(fromNode, toNode); 942 ResolutionCopier.copyResolutionData(fromNode, toNode);
938 expect(toNode.propagatedType, same(propagatedType)); 943 expect(toNode.propagatedType, same(propagatedType));
939 expect(toNode.staticType, same(staticType)); 944 expect(toNode.staticType, same(staticType));
940 } 945 }
941 946
942 void test_visitRedirectingConstructorInvocation() { 947 void test_visitRedirectingConstructorInvocation() {
943 RedirectingConstructorInvocation fromNode = 948 RedirectingConstructorInvocation fromNode =
944 AstFactory.redirectingConstructorInvocation(); 949 AstTestFactory.redirectingConstructorInvocation();
945 ConstructorElement staticElement = ElementFactory.constructorElement2( 950 ConstructorElement staticElement = ElementFactory.constructorElement2(
946 ElementFactory.classElement2("C"), null); 951 ElementFactory.classElement2("C"), null);
947 fromNode.staticElement = staticElement; 952 fromNode.staticElement = staticElement;
948 RedirectingConstructorInvocation toNode = 953 RedirectingConstructorInvocation toNode =
949 AstFactory.redirectingConstructorInvocation(); 954 AstTestFactory.redirectingConstructorInvocation();
950 ResolutionCopier.copyResolutionData(fromNode, toNode); 955 ResolutionCopier.copyResolutionData(fromNode, toNode);
951 expect(toNode.staticElement, same(staticElement)); 956 expect(toNode.staticElement, same(staticElement));
952 } 957 }
953 958
954 void test_visitRethrowExpression() { 959 void test_visitRethrowExpression() {
955 RethrowExpression fromNode = AstFactory.rethrowExpression(); 960 RethrowExpression fromNode = AstTestFactory.rethrowExpression();
956 DartType propagatedType = ElementFactory.classElement2("C").type; 961 DartType propagatedType = ElementFactory.classElement2("C").type;
957 fromNode.propagatedType = propagatedType; 962 fromNode.propagatedType = propagatedType;
958 DartType staticType = ElementFactory.classElement2("C").type; 963 DartType staticType = ElementFactory.classElement2("C").type;
959 fromNode.staticType = staticType; 964 fromNode.staticType = staticType;
960 RethrowExpression toNode = AstFactory.rethrowExpression(); 965 RethrowExpression toNode = AstTestFactory.rethrowExpression();
961 ResolutionCopier.copyResolutionData(fromNode, toNode); 966 ResolutionCopier.copyResolutionData(fromNode, toNode);
962 expect(toNode.propagatedType, same(propagatedType)); 967 expect(toNode.propagatedType, same(propagatedType));
963 expect(toNode.staticType, same(staticType)); 968 expect(toNode.staticType, same(staticType));
964 } 969 }
965 970
966 void test_visitSimpleIdentifier() { 971 void test_visitSimpleIdentifier() {
967 SimpleIdentifier fromNode = AstFactory.identifier3("x"); 972 SimpleIdentifier fromNode = AstTestFactory.identifier3("x");
968 MethodElement propagatedElement = ElementFactory.methodElement( 973 MethodElement propagatedElement = ElementFactory.methodElement(
969 "m", ElementFactory.classElement2("C").type); 974 "m", ElementFactory.classElement2("C").type);
970 MethodElement staticElement = ElementFactory.methodElement( 975 MethodElement staticElement = ElementFactory.methodElement(
971 "m", ElementFactory.classElement2("C").type); 976 "m", ElementFactory.classElement2("C").type);
972 AuxiliaryElements auxiliaryElements = 977 AuxiliaryElements auxiliaryElements =
973 new AuxiliaryElements(staticElement, propagatedElement); 978 new AuxiliaryElements(staticElement, propagatedElement);
974 fromNode.auxiliaryElements = auxiliaryElements; 979 fromNode.auxiliaryElements = auxiliaryElements;
975 fromNode.propagatedElement = propagatedElement; 980 fromNode.propagatedElement = propagatedElement;
976 DartType propagatedType = ElementFactory.classElement2("C").type; 981 DartType propagatedType = ElementFactory.classElement2("C").type;
977 fromNode.propagatedType = propagatedType; 982 fromNode.propagatedType = propagatedType;
978 fromNode.staticElement = staticElement; 983 fromNode.staticElement = staticElement;
979 DartType staticType = ElementFactory.classElement2("C").type; 984 DartType staticType = ElementFactory.classElement2("C").type;
980 fromNode.staticType = staticType; 985 fromNode.staticType = staticType;
981 SimpleIdentifier toNode = AstFactory.identifier3("x"); 986 SimpleIdentifier toNode = AstTestFactory.identifier3("x");
982 ResolutionCopier.copyResolutionData(fromNode, toNode); 987 ResolutionCopier.copyResolutionData(fromNode, toNode);
983 expect(toNode.auxiliaryElements, same(auxiliaryElements)); 988 expect(toNode.auxiliaryElements, same(auxiliaryElements));
984 expect(toNode.propagatedElement, same(propagatedElement)); 989 expect(toNode.propagatedElement, same(propagatedElement));
985 expect(toNode.propagatedType, same(propagatedType)); 990 expect(toNode.propagatedType, same(propagatedType));
986 expect(toNode.staticElement, same(staticElement)); 991 expect(toNode.staticElement, same(staticElement));
987 expect(toNode.staticType, same(staticType)); 992 expect(toNode.staticType, same(staticType));
988 } 993 }
989 994
990 void test_visitSimpleStringLiteral() { 995 void test_visitSimpleStringLiteral() {
991 SimpleStringLiteral fromNode = AstFactory.string2("abc"); 996 SimpleStringLiteral fromNode = AstTestFactory.string2("abc");
992 DartType propagatedType = ElementFactory.classElement2("C").type; 997 DartType propagatedType = ElementFactory.classElement2("C").type;
993 fromNode.propagatedType = propagatedType; 998 fromNode.propagatedType = propagatedType;
994 DartType staticType = ElementFactory.classElement2("C").type; 999 DartType staticType = ElementFactory.classElement2("C").type;
995 fromNode.staticType = staticType; 1000 fromNode.staticType = staticType;
996 SimpleStringLiteral toNode = AstFactory.string2("abc"); 1001 SimpleStringLiteral toNode = AstTestFactory.string2("abc");
997 ResolutionCopier.copyResolutionData(fromNode, toNode); 1002 ResolutionCopier.copyResolutionData(fromNode, toNode);
998 expect(toNode.propagatedType, same(propagatedType)); 1003 expect(toNode.propagatedType, same(propagatedType));
999 expect(toNode.staticType, same(staticType)); 1004 expect(toNode.staticType, same(staticType));
1000 } 1005 }
1001 1006
1002 void test_visitStringInterpolation() { 1007 void test_visitStringInterpolation() {
1003 StringInterpolation fromNode = 1008 StringInterpolation fromNode =
1004 AstFactory.string([AstFactory.interpolationString("a", "'a'")]); 1009 AstTestFactory.string([AstTestFactory.interpolationString("a", "'a'")]);
1005 DartType propagatedType = ElementFactory.classElement2("C").type; 1010 DartType propagatedType = ElementFactory.classElement2("C").type;
1006 fromNode.propagatedType = propagatedType; 1011 fromNode.propagatedType = propagatedType;
1007 DartType staticType = ElementFactory.classElement2("C").type; 1012 DartType staticType = ElementFactory.classElement2("C").type;
1008 fromNode.staticType = staticType; 1013 fromNode.staticType = staticType;
1009 StringInterpolation toNode = 1014 StringInterpolation toNode =
1010 AstFactory.string([AstFactory.interpolationString("a", "'a'")]); 1015 AstTestFactory.string([AstTestFactory.interpolationString("a", "'a'")]);
1011 ResolutionCopier.copyResolutionData(fromNode, toNode); 1016 ResolutionCopier.copyResolutionData(fromNode, toNode);
1012 expect(toNode.propagatedType, same(propagatedType)); 1017 expect(toNode.propagatedType, same(propagatedType));
1013 expect(toNode.staticType, same(staticType)); 1018 expect(toNode.staticType, same(staticType));
1014 } 1019 }
1015 1020
1016 void test_visitSuperConstructorInvocation() { 1021 void test_visitSuperConstructorInvocation() {
1017 SuperConstructorInvocation fromNode = 1022 SuperConstructorInvocation fromNode =
1018 AstFactory.superConstructorInvocation(); 1023 AstTestFactory.superConstructorInvocation();
1019 ConstructorElement staticElement = ElementFactory.constructorElement2( 1024 ConstructorElement staticElement = ElementFactory.constructorElement2(
1020 ElementFactory.classElement2("C"), null); 1025 ElementFactory.classElement2("C"), null);
1021 fromNode.staticElement = staticElement; 1026 fromNode.staticElement = staticElement;
1022 SuperConstructorInvocation toNode = AstFactory.superConstructorInvocation(); 1027 SuperConstructorInvocation toNode =
1028 AstTestFactory.superConstructorInvocation();
1023 ResolutionCopier.copyResolutionData(fromNode, toNode); 1029 ResolutionCopier.copyResolutionData(fromNode, toNode);
1024 expect(toNode.staticElement, same(staticElement)); 1030 expect(toNode.staticElement, same(staticElement));
1025 } 1031 }
1026 1032
1027 void test_visitSuperExpression() { 1033 void test_visitSuperExpression() {
1028 SuperExpression fromNode = AstFactory.superExpression(); 1034 SuperExpression fromNode = AstTestFactory.superExpression();
1029 DartType propagatedType = ElementFactory.classElement2("C").type; 1035 DartType propagatedType = ElementFactory.classElement2("C").type;
1030 fromNode.propagatedType = propagatedType; 1036 fromNode.propagatedType = propagatedType;
1031 DartType staticType = ElementFactory.classElement2("C").type; 1037 DartType staticType = ElementFactory.classElement2("C").type;
1032 fromNode.staticType = staticType; 1038 fromNode.staticType = staticType;
1033 SuperExpression toNode = AstFactory.superExpression(); 1039 SuperExpression toNode = AstTestFactory.superExpression();
1034 ResolutionCopier.copyResolutionData(fromNode, toNode); 1040 ResolutionCopier.copyResolutionData(fromNode, toNode);
1035 expect(toNode.propagatedType, same(propagatedType)); 1041 expect(toNode.propagatedType, same(propagatedType));
1036 expect(toNode.staticType, same(staticType)); 1042 expect(toNode.staticType, same(staticType));
1037 } 1043 }
1038 1044
1039 void test_visitSymbolLiteral() { 1045 void test_visitSymbolLiteral() {
1040 SymbolLiteral fromNode = AstFactory.symbolLiteral(["s"]); 1046 SymbolLiteral fromNode = AstTestFactory.symbolLiteral(["s"]);
1041 DartType propagatedType = ElementFactory.classElement2("C").type; 1047 DartType propagatedType = ElementFactory.classElement2("C").type;
1042 fromNode.propagatedType = propagatedType; 1048 fromNode.propagatedType = propagatedType;
1043 DartType staticType = ElementFactory.classElement2("C").type; 1049 DartType staticType = ElementFactory.classElement2("C").type;
1044 fromNode.staticType = staticType; 1050 fromNode.staticType = staticType;
1045 SymbolLiteral toNode = AstFactory.symbolLiteral(["s"]); 1051 SymbolLiteral toNode = AstTestFactory.symbolLiteral(["s"]);
1046 ResolutionCopier.copyResolutionData(fromNode, toNode); 1052 ResolutionCopier.copyResolutionData(fromNode, toNode);
1047 expect(toNode.propagatedType, same(propagatedType)); 1053 expect(toNode.propagatedType, same(propagatedType));
1048 expect(toNode.staticType, same(staticType)); 1054 expect(toNode.staticType, same(staticType));
1049 } 1055 }
1050 1056
1051 void test_visitThisExpression() { 1057 void test_visitThisExpression() {
1052 ThisExpression fromNode = AstFactory.thisExpression(); 1058 ThisExpression fromNode = AstTestFactory.thisExpression();
1053 DartType propagatedType = ElementFactory.classElement2("C").type; 1059 DartType propagatedType = ElementFactory.classElement2("C").type;
1054 fromNode.propagatedType = propagatedType; 1060 fromNode.propagatedType = propagatedType;
1055 DartType staticType = ElementFactory.classElement2("C").type; 1061 DartType staticType = ElementFactory.classElement2("C").type;
1056 fromNode.staticType = staticType; 1062 fromNode.staticType = staticType;
1057 ThisExpression toNode = AstFactory.thisExpression(); 1063 ThisExpression toNode = AstTestFactory.thisExpression();
1058 ResolutionCopier.copyResolutionData(fromNode, toNode); 1064 ResolutionCopier.copyResolutionData(fromNode, toNode);
1059 expect(toNode.propagatedType, same(propagatedType)); 1065 expect(toNode.propagatedType, same(propagatedType));
1060 expect(toNode.staticType, same(staticType)); 1066 expect(toNode.staticType, same(staticType));
1061 } 1067 }
1062 1068
1063 void test_visitThrowExpression() { 1069 void test_visitThrowExpression() {
1064 ThrowExpression fromNode = AstFactory.throwExpression(); 1070 ThrowExpression fromNode = AstTestFactory.throwExpression();
1065 DartType propagatedType = ElementFactory.classElement2("C").type; 1071 DartType propagatedType = ElementFactory.classElement2("C").type;
1066 fromNode.propagatedType = propagatedType; 1072 fromNode.propagatedType = propagatedType;
1067 DartType staticType = ElementFactory.classElement2("C").type; 1073 DartType staticType = ElementFactory.classElement2("C").type;
1068 fromNode.staticType = staticType; 1074 fromNode.staticType = staticType;
1069 ThrowExpression toNode = AstFactory.throwExpression(); 1075 ThrowExpression toNode = AstTestFactory.throwExpression();
1070 ResolutionCopier.copyResolutionData(fromNode, toNode); 1076 ResolutionCopier.copyResolutionData(fromNode, toNode);
1071 expect(toNode.propagatedType, same(propagatedType)); 1077 expect(toNode.propagatedType, same(propagatedType));
1072 expect(toNode.staticType, same(staticType)); 1078 expect(toNode.staticType, same(staticType));
1073 } 1079 }
1074 1080
1075 void test_visitTypeName() { 1081 void test_visitTypeName() {
1076 TypeName fromNode = AstFactory.typeName4("C"); 1082 TypeName fromNode = AstTestFactory.typeName4("C");
1077 DartType type = ElementFactory.classElement2("C").type; 1083 DartType type = ElementFactory.classElement2("C").type;
1078 fromNode.type = type; 1084 fromNode.type = type;
1079 TypeName toNode = AstFactory.typeName4("C"); 1085 TypeName toNode = AstTestFactory.typeName4("C");
1080 ResolutionCopier.copyResolutionData(fromNode, toNode); 1086 ResolutionCopier.copyResolutionData(fromNode, toNode);
1081 expect(toNode.type, same(type)); 1087 expect(toNode.type, same(type));
1082 } 1088 }
1083 1089
1084 void _copyAndVerifyInvocation( 1090 void _copyAndVerifyInvocation(
1085 InvocationExpression fromNode, InvocationExpression toNode) { 1091 InvocationExpression fromNode, InvocationExpression toNode) {
1086 DartType propagatedType = ElementFactory.classElement2("C").type; 1092 DartType propagatedType = ElementFactory.classElement2("C").type;
1087 fromNode.propagatedType = propagatedType; 1093 fromNode.propagatedType = propagatedType;
1088 DartType staticType = ElementFactory.classElement2("C").type; 1094 DartType staticType = ElementFactory.classElement2("C").type;
1089 fromNode.staticType = staticType; 1095 fromNode.staticType = staticType;
(...skipping 18 matching lines...) Expand all
1108 } 1114 }
1109 } 1115 }
1110 } 1116 }
1111 } 1117 }
1112 1118
1113 @reflectiveTest 1119 @reflectiveTest
1114 class ToSourceVisitor2Test extends EngineTestCase { 1120 class ToSourceVisitor2Test extends EngineTestCase {
1115 void test_visitAdjacentStrings() { 1121 void test_visitAdjacentStrings() {
1116 _assertSource( 1122 _assertSource(
1117 "'a' 'b'", 1123 "'a' 'b'",
1118 AstFactory.adjacentStrings( 1124 AstTestFactory.adjacentStrings(
1119 [AstFactory.string2("a"), AstFactory.string2("b")])); 1125 [AstTestFactory.string2("a"), AstTestFactory.string2("b")]));
1120 } 1126 }
1121 1127
1122 void test_visitAnnotation_constant() { 1128 void test_visitAnnotation_constant() {
1123 _assertSource("@A", AstFactory.annotation(AstFactory.identifier3("A"))); 1129 _assertSource(
1130 "@A", AstTestFactory.annotation(AstTestFactory.identifier3("A")));
1124 } 1131 }
1125 1132
1126 void test_visitAnnotation_constructor() { 1133 void test_visitAnnotation_constructor() {
1127 _assertSource( 1134 _assertSource(
1128 "@A.c()", 1135 "@A.c()",
1129 AstFactory.annotation2(AstFactory.identifier3("A"), 1136 AstTestFactory.annotation2(AstTestFactory.identifier3("A"),
1130 AstFactory.identifier3("c"), AstFactory.argumentList())); 1137 AstTestFactory.identifier3("c"), AstTestFactory.argumentList()));
1131 } 1138 }
1132 1139
1133 void test_visitArgumentList() { 1140 void test_visitArgumentList() {
1134 _assertSource( 1141 _assertSource(
1135 "(a, b)", 1142 "(a, b)",
1136 AstFactory.argumentList( 1143 AstTestFactory.argumentList([
1137 [AstFactory.identifier3("a"), AstFactory.identifier3("b")])); 1144 AstTestFactory.identifier3("a"),
1145 AstTestFactory.identifier3("b")
1146 ]));
1138 } 1147 }
1139 1148
1140 void test_visitAsExpression() { 1149 void test_visitAsExpression() {
1141 _assertSource( 1150 _assertSource(
1142 "e as T", 1151 "e as T",
1143 AstFactory.asExpression( 1152 AstTestFactory.asExpression(
1144 AstFactory.identifier3("e"), AstFactory.typeName4("T"))); 1153 AstTestFactory.identifier3("e"), AstTestFactory.typeName4("T")));
1145 } 1154 }
1146 1155
1147 void test_visitAssertStatement() { 1156 void test_visitAssertStatement() {
1148 _assertSource( 1157 _assertSource("assert (a);",
1149 "assert (a);", AstFactory.assertStatement(AstFactory.identifier3("a"))); 1158 AstTestFactory.assertStatement(AstTestFactory.identifier3("a")));
1150 } 1159 }
1151 1160
1152 void test_visitAssertStatement_withMessage() { 1161 void test_visitAssertStatement_withMessage() {
1153 _assertSource( 1162 _assertSource(
1154 "assert (a, b);", 1163 "assert (a, b);",
1155 AstFactory.assertStatement( 1164 AstTestFactory.assertStatement(
1156 AstFactory.identifier3("a"), AstFactory.identifier3('b'))); 1165 AstTestFactory.identifier3("a"), AstTestFactory.identifier3('b')));
1157 } 1166 }
1158 1167
1159 void test_visitAssignmentExpression() { 1168 void test_visitAssignmentExpression() {
1160 _assertSource( 1169 _assertSource(
1161 "a = b", 1170 "a = b",
1162 AstFactory.assignmentExpression(AstFactory.identifier3("a"), 1171 AstTestFactory.assignmentExpression(AstTestFactory.identifier3("a"),
1163 TokenType.EQ, AstFactory.identifier3("b"))); 1172 TokenType.EQ, AstTestFactory.identifier3("b")));
1164 } 1173 }
1165 1174
1166 void test_visitAwaitExpression() { 1175 void test_visitAwaitExpression() {
1167 _assertSource( 1176 _assertSource("await e",
1168 "await e", AstFactory.awaitExpression(AstFactory.identifier3("e"))); 1177 AstTestFactory.awaitExpression(AstTestFactory.identifier3("e")));
1169 } 1178 }
1170 1179
1171 void test_visitBinaryExpression() { 1180 void test_visitBinaryExpression() {
1172 _assertSource( 1181 _assertSource(
1173 "a + b", 1182 "a + b",
1174 AstFactory.binaryExpression(AstFactory.identifier3("a"), TokenType.PLUS, 1183 AstTestFactory.binaryExpression(AstTestFactory.identifier3("a"),
1175 AstFactory.identifier3("b"))); 1184 TokenType.PLUS, AstTestFactory.identifier3("b")));
1176 } 1185 }
1177 1186
1178 void test_visitBlock_empty() { 1187 void test_visitBlock_empty() {
1179 _assertSource("{}", AstFactory.block()); 1188 _assertSource("{}", AstTestFactory.block());
1180 } 1189 }
1181 1190
1182 void test_visitBlock_nonEmpty() { 1191 void test_visitBlock_nonEmpty() {
1183 _assertSource( 1192 _assertSource(
1184 "{break; break;}", 1193 "{break; break;}",
1185 AstFactory 1194 AstTestFactory.block([
1186 .block([AstFactory.breakStatement(), AstFactory.breakStatement()])); 1195 AstTestFactory.breakStatement(),
1196 AstTestFactory.breakStatement()
1197 ]));
1187 } 1198 }
1188 1199
1189 void test_visitBlockFunctionBody_async() { 1200 void test_visitBlockFunctionBody_async() {
1190 _assertSource("async {}", AstFactory.asyncBlockFunctionBody()); 1201 _assertSource("async {}", AstTestFactory.asyncBlockFunctionBody());
1191 } 1202 }
1192 1203
1193 void test_visitBlockFunctionBody_async_star() { 1204 void test_visitBlockFunctionBody_async_star() {
1194 _assertSource("async* {}", AstFactory.asyncGeneratorBlockFunctionBody()); 1205 _assertSource(
1206 "async* {}", AstTestFactory.asyncGeneratorBlockFunctionBody());
1195 } 1207 }
1196 1208
1197 void test_visitBlockFunctionBody_simple() { 1209 void test_visitBlockFunctionBody_simple() {
1198 _assertSource("{}", AstFactory.blockFunctionBody2()); 1210 _assertSource("{}", AstTestFactory.blockFunctionBody2());
1199 } 1211 }
1200 1212
1201 void test_visitBlockFunctionBody_sync() { 1213 void test_visitBlockFunctionBody_sync() {
1202 _assertSource("sync {}", AstFactory.syncBlockFunctionBody()); 1214 _assertSource("sync {}", AstTestFactory.syncBlockFunctionBody());
1203 } 1215 }
1204 1216
1205 void test_visitBlockFunctionBody_sync_star() { 1217 void test_visitBlockFunctionBody_sync_star() {
1206 _assertSource("sync* {}", AstFactory.syncGeneratorBlockFunctionBody()); 1218 _assertSource("sync* {}", AstTestFactory.syncGeneratorBlockFunctionBody());
1207 } 1219 }
1208 1220
1209 void test_visitBooleanLiteral_false() { 1221 void test_visitBooleanLiteral_false() {
1210 _assertSource("false", AstFactory.booleanLiteral(false)); 1222 _assertSource("false", AstTestFactory.booleanLiteral(false));
1211 } 1223 }
1212 1224
1213 void test_visitBooleanLiteral_true() { 1225 void test_visitBooleanLiteral_true() {
1214 _assertSource("true", AstFactory.booleanLiteral(true)); 1226 _assertSource("true", AstTestFactory.booleanLiteral(true));
1215 } 1227 }
1216 1228
1217 void test_visitBreakStatement_label() { 1229 void test_visitBreakStatement_label() {
1218 _assertSource("break l;", AstFactory.breakStatement2("l")); 1230 _assertSource("break l;", AstTestFactory.breakStatement2("l"));
1219 } 1231 }
1220 1232
1221 void test_visitBreakStatement_noLabel() { 1233 void test_visitBreakStatement_noLabel() {
1222 _assertSource("break;", AstFactory.breakStatement()); 1234 _assertSource("break;", AstTestFactory.breakStatement());
1223 } 1235 }
1224 1236
1225 void test_visitCascadeExpression_field() { 1237 void test_visitCascadeExpression_field() {
1226 _assertSource( 1238 _assertSource(
1227 "a..b..c", 1239 "a..b..c",
1228 AstFactory.cascadeExpression(AstFactory.identifier3("a"), [ 1240 AstTestFactory.cascadeExpression(AstTestFactory.identifier3("a"), [
1229 AstFactory.cascadedPropertyAccess("b"), 1241 AstTestFactory.cascadedPropertyAccess("b"),
1230 AstFactory.cascadedPropertyAccess("c") 1242 AstTestFactory.cascadedPropertyAccess("c")
1231 ])); 1243 ]));
1232 } 1244 }
1233 1245
1234 void test_visitCascadeExpression_index() { 1246 void test_visitCascadeExpression_index() {
1235 _assertSource( 1247 _assertSource(
1236 "a..[0]..[1]", 1248 "a..[0]..[1]",
1237 AstFactory.cascadeExpression(AstFactory.identifier3("a"), [ 1249 AstTestFactory.cascadeExpression(AstTestFactory.identifier3("a"), [
1238 AstFactory.cascadedIndexExpression(AstFactory.integer(0)), 1250 AstTestFactory.cascadedIndexExpression(AstTestFactory.integer(0)),
1239 AstFactory.cascadedIndexExpression(AstFactory.integer(1)) 1251 AstTestFactory.cascadedIndexExpression(AstTestFactory.integer(1))
1240 ])); 1252 ]));
1241 } 1253 }
1242 1254
1243 void test_visitCascadeExpression_method() { 1255 void test_visitCascadeExpression_method() {
1244 _assertSource( 1256 _assertSource(
1245 "a..b()..c()", 1257 "a..b()..c()",
1246 AstFactory.cascadeExpression(AstFactory.identifier3("a"), [ 1258 AstTestFactory.cascadeExpression(AstTestFactory.identifier3("a"), [
1247 AstFactory.cascadedMethodInvocation("b"), 1259 AstTestFactory.cascadedMethodInvocation("b"),
1248 AstFactory.cascadedMethodInvocation("c") 1260 AstTestFactory.cascadedMethodInvocation("c")
1249 ])); 1261 ]));
1250 } 1262 }
1251 1263
1252 void test_visitCatchClause_catch_noStack() { 1264 void test_visitCatchClause_catch_noStack() {
1253 _assertSource("catch (e) {}", AstFactory.catchClause("e")); 1265 _assertSource("catch (e) {}", AstTestFactory.catchClause("e"));
1254 } 1266 }
1255 1267
1256 void test_visitCatchClause_catch_stack() { 1268 void test_visitCatchClause_catch_stack() {
1257 _assertSource("catch (e, s) {}", AstFactory.catchClause2("e", "s")); 1269 _assertSource("catch (e, s) {}", AstTestFactory.catchClause2("e", "s"));
1258 } 1270 }
1259 1271
1260 void test_visitCatchClause_on() { 1272 void test_visitCatchClause_on() {
1261 _assertSource( 1273 _assertSource(
1262 "on E {}", AstFactory.catchClause3(AstFactory.typeName4("E"))); 1274 "on E {}", AstTestFactory.catchClause3(AstTestFactory.typeName4("E")));
1263 } 1275 }
1264 1276
1265 void test_visitCatchClause_on_catch() { 1277 void test_visitCatchClause_on_catch() {
1266 _assertSource("on E catch (e) {}", 1278 _assertSource("on E catch (e) {}",
1267 AstFactory.catchClause4(AstFactory.typeName4("E"), "e")); 1279 AstTestFactory.catchClause4(AstTestFactory.typeName4("E"), "e"));
1268 } 1280 }
1269 1281
1270 void test_visitClassDeclaration_abstract() { 1282 void test_visitClassDeclaration_abstract() {
1271 _assertSource( 1283 _assertSource(
1272 "abstract class C {}", 1284 "abstract class C {}",
1273 AstFactory.classDeclaration( 1285 AstTestFactory.classDeclaration(
1274 Keyword.ABSTRACT, "C", null, null, null, null)); 1286 Keyword.ABSTRACT, "C", null, null, null, null));
1275 } 1287 }
1276 1288
1277 void test_visitClassDeclaration_empty() { 1289 void test_visitClassDeclaration_empty() {
1278 _assertSource("class C {}", 1290 _assertSource("class C {}",
1279 AstFactory.classDeclaration(null, "C", null, null, null, null)); 1291 AstTestFactory.classDeclaration(null, "C", null, null, null, null));
1280 } 1292 }
1281 1293
1282 void test_visitClassDeclaration_extends() { 1294 void test_visitClassDeclaration_extends() {
1283 _assertSource( 1295 _assertSource(
1284 "class C extends A {}", 1296 "class C extends A {}",
1285 AstFactory.classDeclaration(null, "C", null, 1297 AstTestFactory.classDeclaration(
1286 AstFactory.extendsClause(AstFactory.typeName4("A")), null, null)); 1298 null,
1299 "C",
1300 null,
1301 AstTestFactory.extendsClause(AstTestFactory.typeName4("A")),
1302 null,
1303 null));
1287 } 1304 }
1288 1305
1289 void test_visitClassDeclaration_extends_implements() { 1306 void test_visitClassDeclaration_extends_implements() {
1290 _assertSource( 1307 _assertSource(
1291 "class C extends A implements B {}", 1308 "class C extends A implements B {}",
1292 AstFactory.classDeclaration( 1309 AstTestFactory.classDeclaration(
1293 null, 1310 null,
1294 "C", 1311 "C",
1295 null, 1312 null,
1296 AstFactory.extendsClause(AstFactory.typeName4("A")), 1313 AstTestFactory.extendsClause(AstTestFactory.typeName4("A")),
1297 null, 1314 null,
1298 AstFactory.implementsClause([AstFactory.typeName4("B")]))); 1315 AstTestFactory.implementsClause([AstTestFactory.typeName4("B")])));
1299 } 1316 }
1300 1317
1301 void test_visitClassDeclaration_extends_with() { 1318 void test_visitClassDeclaration_extends_with() {
1302 _assertSource( 1319 _assertSource(
1303 "class C extends A with M {}", 1320 "class C extends A with M {}",
1304 AstFactory.classDeclaration( 1321 AstTestFactory.classDeclaration(
1305 null, 1322 null,
1306 "C", 1323 "C",
1307 null, 1324 null,
1308 AstFactory.extendsClause(AstFactory.typeName4("A")), 1325 AstTestFactory.extendsClause(AstTestFactory.typeName4("A")),
1309 AstFactory.withClause([AstFactory.typeName4("M")]), 1326 AstTestFactory.withClause([AstTestFactory.typeName4("M")]),
1310 null)); 1327 null));
1311 } 1328 }
1312 1329
1313 void test_visitClassDeclaration_extends_with_implements() { 1330 void test_visitClassDeclaration_extends_with_implements() {
1314 _assertSource( 1331 _assertSource(
1315 "class C extends A with M implements B {}", 1332 "class C extends A with M implements B {}",
1316 AstFactory.classDeclaration( 1333 AstTestFactory.classDeclaration(
1317 null, 1334 null,
1318 "C", 1335 "C",
1319 null, 1336 null,
1320 AstFactory.extendsClause(AstFactory.typeName4("A")), 1337 AstTestFactory.extendsClause(AstTestFactory.typeName4("A")),
1321 AstFactory.withClause([AstFactory.typeName4("M")]), 1338 AstTestFactory.withClause([AstTestFactory.typeName4("M")]),
1322 AstFactory.implementsClause([AstFactory.typeName4("B")]))); 1339 AstTestFactory.implementsClause([AstTestFactory.typeName4("B")])));
1323 } 1340 }
1324 1341
1325 void test_visitClassDeclaration_implements() { 1342 void test_visitClassDeclaration_implements() {
1326 _assertSource( 1343 _assertSource(
1327 "class C implements B {}", 1344 "class C implements B {}",
1328 AstFactory.classDeclaration(null, "C", null, null, null, 1345 AstTestFactory.classDeclaration(null, "C", null, null, null,
1329 AstFactory.implementsClause([AstFactory.typeName4("B")]))); 1346 AstTestFactory.implementsClause([AstTestFactory.typeName4("B")])));
1330 } 1347 }
1331 1348
1332 void test_visitClassDeclaration_multipleMember() { 1349 void test_visitClassDeclaration_multipleMember() {
1333 _assertSource( 1350 _assertSource(
1334 "class C {var a; var b;}", 1351 "class C {var a; var b;}",
1335 AstFactory.classDeclaration(null, "C", null, null, null, null, [ 1352 AstTestFactory.classDeclaration(null, "C", null, null, null, null, [
1336 AstFactory.fieldDeclaration2( 1353 AstTestFactory.fieldDeclaration2(
1337 false, Keyword.VAR, [AstFactory.variableDeclaration("a")]), 1354 false, Keyword.VAR, [AstTestFactory.variableDeclaration("a")]),
1338 AstFactory.fieldDeclaration2( 1355 AstTestFactory.fieldDeclaration2(
1339 false, Keyword.VAR, [AstFactory.variableDeclaration("b")]) 1356 false, Keyword.VAR, [AstTestFactory.variableDeclaration("b")])
1340 ])); 1357 ]));
1341 } 1358 }
1342 1359
1343 void test_visitClassDeclaration_parameters() { 1360 void test_visitClassDeclaration_parameters() {
1344 _assertSource( 1361 _assertSource(
1345 "class C<E> {}", 1362 "class C<E> {}",
1346 AstFactory.classDeclaration( 1363 AstTestFactory.classDeclaration(null, "C",
1347 null, "C", AstFactory.typeParameterList(["E"]), null, null, null)); 1364 AstTestFactory.typeParameterList(["E"]), null, null, null));
1348 } 1365 }
1349 1366
1350 void test_visitClassDeclaration_parameters_extends() { 1367 void test_visitClassDeclaration_parameters_extends() {
1351 _assertSource( 1368 _assertSource(
1352 "class C<E> extends A {}", 1369 "class C<E> extends A {}",
1353 AstFactory.classDeclaration( 1370 AstTestFactory.classDeclaration(
1354 null, 1371 null,
1355 "C", 1372 "C",
1356 AstFactory.typeParameterList(["E"]), 1373 AstTestFactory.typeParameterList(["E"]),
1357 AstFactory.extendsClause(AstFactory.typeName4("A")), 1374 AstTestFactory.extendsClause(AstTestFactory.typeName4("A")),
1358 null, 1375 null,
1359 null)); 1376 null));
1360 } 1377 }
1361 1378
1362 void test_visitClassDeclaration_parameters_extends_implements() { 1379 void test_visitClassDeclaration_parameters_extends_implements() {
1363 _assertSource( 1380 _assertSource(
1364 "class C<E> extends A implements B {}", 1381 "class C<E> extends A implements B {}",
1365 AstFactory.classDeclaration( 1382 AstTestFactory.classDeclaration(
1366 null, 1383 null,
1367 "C", 1384 "C",
1368 AstFactory.typeParameterList(["E"]), 1385 AstTestFactory.typeParameterList(["E"]),
1369 AstFactory.extendsClause(AstFactory.typeName4("A")), 1386 AstTestFactory.extendsClause(AstTestFactory.typeName4("A")),
1370 null, 1387 null,
1371 AstFactory.implementsClause([AstFactory.typeName4("B")]))); 1388 AstTestFactory.implementsClause([AstTestFactory.typeName4("B")])));
1372 } 1389 }
1373 1390
1374 void test_visitClassDeclaration_parameters_extends_with() { 1391 void test_visitClassDeclaration_parameters_extends_with() {
1375 _assertSource( 1392 _assertSource(
1376 "class C<E> extends A with M {}", 1393 "class C<E> extends A with M {}",
1377 AstFactory.classDeclaration( 1394 AstTestFactory.classDeclaration(
1378 null, 1395 null,
1379 "C", 1396 "C",
1380 AstFactory.typeParameterList(["E"]), 1397 AstTestFactory.typeParameterList(["E"]),
1381 AstFactory.extendsClause(AstFactory.typeName4("A")), 1398 AstTestFactory.extendsClause(AstTestFactory.typeName4("A")),
1382 AstFactory.withClause([AstFactory.typeName4("M")]), 1399 AstTestFactory.withClause([AstTestFactory.typeName4("M")]),
1383 null)); 1400 null));
1384 } 1401 }
1385 1402
1386 void test_visitClassDeclaration_parameters_extends_with_implements() { 1403 void test_visitClassDeclaration_parameters_extends_with_implements() {
1387 _assertSource( 1404 _assertSource(
1388 "class C<E> extends A with M implements B {}", 1405 "class C<E> extends A with M implements B {}",
1389 AstFactory.classDeclaration( 1406 AstTestFactory.classDeclaration(
1390 null, 1407 null,
1391 "C", 1408 "C",
1392 AstFactory.typeParameterList(["E"]), 1409 AstTestFactory.typeParameterList(["E"]),
1393 AstFactory.extendsClause(AstFactory.typeName4("A")), 1410 AstTestFactory.extendsClause(AstTestFactory.typeName4("A")),
1394 AstFactory.withClause([AstFactory.typeName4("M")]), 1411 AstTestFactory.withClause([AstTestFactory.typeName4("M")]),
1395 AstFactory.implementsClause([AstFactory.typeName4("B")]))); 1412 AstTestFactory.implementsClause([AstTestFactory.typeName4("B")])));
1396 } 1413 }
1397 1414
1398 void test_visitClassDeclaration_parameters_implements() { 1415 void test_visitClassDeclaration_parameters_implements() {
1399 _assertSource( 1416 _assertSource(
1400 "class C<E> implements B {}", 1417 "class C<E> implements B {}",
1401 AstFactory.classDeclaration( 1418 AstTestFactory.classDeclaration(
1402 null, 1419 null,
1403 "C", 1420 "C",
1404 AstFactory.typeParameterList(["E"]), 1421 AstTestFactory.typeParameterList(["E"]),
1405 null, 1422 null,
1406 null, 1423 null,
1407 AstFactory.implementsClause([AstFactory.typeName4("B")]))); 1424 AstTestFactory.implementsClause([AstTestFactory.typeName4("B")])));
1408 } 1425 }
1409 1426
1410 void test_visitClassDeclaration_singleMember() { 1427 void test_visitClassDeclaration_singleMember() {
1411 _assertSource( 1428 _assertSource(
1412 "class C {var a;}", 1429 "class C {var a;}",
1413 AstFactory.classDeclaration(null, "C", null, null, null, null, [ 1430 AstTestFactory.classDeclaration(null, "C", null, null, null, null, [
1414 AstFactory.fieldDeclaration2( 1431 AstTestFactory.fieldDeclaration2(
1415 false, Keyword.VAR, [AstFactory.variableDeclaration("a")]) 1432 false, Keyword.VAR, [AstTestFactory.variableDeclaration("a")])
1416 ])); 1433 ]));
1417 } 1434 }
1418 1435
1419 void test_visitClassDeclaration_withMetadata() { 1436 void test_visitClassDeclaration_withMetadata() {
1420 ClassDeclaration declaration = 1437 ClassDeclaration declaration =
1421 AstFactory.classDeclaration(null, "C", null, null, null, null); 1438 AstTestFactory.classDeclaration(null, "C", null, null, null, null);
1422 declaration.metadata 1439 declaration.metadata.add(
1423 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 1440 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
1424 _assertSource("@deprecated class C {}", declaration); 1441 _assertSource("@deprecated class C {}", declaration);
1425 } 1442 }
1426 1443
1427 void test_visitClassTypeAlias_abstract() { 1444 void test_visitClassTypeAlias_abstract() {
1428 _assertSource( 1445 _assertSource(
1429 "abstract class C = S with M1;", 1446 "abstract class C = S with M1;",
1430 AstFactory.classTypeAlias( 1447 AstTestFactory.classTypeAlias(
1431 "C", 1448 "C",
1432 null, 1449 null,
1433 Keyword.ABSTRACT, 1450 Keyword.ABSTRACT,
1434 AstFactory.typeName4("S"), 1451 AstTestFactory.typeName4("S"),
1435 AstFactory.withClause([AstFactory.typeName4("M1")]), 1452 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]),
1436 null)); 1453 null));
1437 } 1454 }
1438 1455
1439 void test_visitClassTypeAlias_abstract_implements() { 1456 void test_visitClassTypeAlias_abstract_implements() {
1440 _assertSource( 1457 _assertSource(
1441 "abstract class C = S with M1 implements I;", 1458 "abstract class C = S with M1 implements I;",
1442 AstFactory.classTypeAlias( 1459 AstTestFactory.classTypeAlias(
1443 "C", 1460 "C",
1444 null, 1461 null,
1445 Keyword.ABSTRACT, 1462 Keyword.ABSTRACT,
1446 AstFactory.typeName4("S"), 1463 AstTestFactory.typeName4("S"),
1447 AstFactory.withClause([AstFactory.typeName4("M1")]), 1464 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]),
1448 AstFactory.implementsClause([AstFactory.typeName4("I")]))); 1465 AstTestFactory.implementsClause([AstTestFactory.typeName4("I")])));
1449 } 1466 }
1450 1467
1451 void test_visitClassTypeAlias_generic() { 1468 void test_visitClassTypeAlias_generic() {
1452 _assertSource( 1469 _assertSource(
1453 "class C<E> = S<E> with M1<E>;", 1470 "class C<E> = S<E> with M1<E>;",
1454 AstFactory.classTypeAlias( 1471 AstTestFactory.classTypeAlias(
1455 "C", 1472 "C",
1456 AstFactory.typeParameterList(["E"]), 1473 AstTestFactory.typeParameterList(["E"]),
1457 null, 1474 null,
1458 AstFactory.typeName4("S", [AstFactory.typeName4("E")]), 1475 AstTestFactory.typeName4("S", [AstTestFactory.typeName4("E")]),
1459 AstFactory.withClause([ 1476 AstTestFactory.withClause([
1460 AstFactory.typeName4("M1", [AstFactory.typeName4("E")]) 1477 AstTestFactory.typeName4("M1", [AstTestFactory.typeName4("E")])
1461 ]), 1478 ]),
1462 null)); 1479 null));
1463 } 1480 }
1464 1481
1465 void test_visitClassTypeAlias_implements() { 1482 void test_visitClassTypeAlias_implements() {
1466 _assertSource( 1483 _assertSource(
1467 "class C = S with M1 implements I;", 1484 "class C = S with M1 implements I;",
1468 AstFactory.classTypeAlias( 1485 AstTestFactory.classTypeAlias(
1469 "C", 1486 "C",
1470 null, 1487 null,
1471 null, 1488 null,
1472 AstFactory.typeName4("S"), 1489 AstTestFactory.typeName4("S"),
1473 AstFactory.withClause([AstFactory.typeName4("M1")]), 1490 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]),
1474 AstFactory.implementsClause([AstFactory.typeName4("I")]))); 1491 AstTestFactory.implementsClause([AstTestFactory.typeName4("I")])));
1475 } 1492 }
1476 1493
1477 void test_visitClassTypeAlias_minimal() { 1494 void test_visitClassTypeAlias_minimal() {
1478 _assertSource( 1495 _assertSource(
1479 "class C = S with M1;", 1496 "class C = S with M1;",
1480 AstFactory.classTypeAlias("C", null, null, AstFactory.typeName4("S"), 1497 AstTestFactory.classTypeAlias(
1481 AstFactory.withClause([AstFactory.typeName4("M1")]), null)); 1498 "C",
1499 null,
1500 null,
1501 AstTestFactory.typeName4("S"),
1502 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]),
1503 null));
1482 } 1504 }
1483 1505
1484 void test_visitClassTypeAlias_parameters_abstract() { 1506 void test_visitClassTypeAlias_parameters_abstract() {
1485 _assertSource( 1507 _assertSource(
1486 "abstract class C<E> = S with M1;", 1508 "abstract class C<E> = S with M1;",
1487 AstFactory.classTypeAlias( 1509 AstTestFactory.classTypeAlias(
1488 "C", 1510 "C",
1489 AstFactory.typeParameterList(["E"]), 1511 AstTestFactory.typeParameterList(["E"]),
1490 Keyword.ABSTRACT, 1512 Keyword.ABSTRACT,
1491 AstFactory.typeName4("S"), 1513 AstTestFactory.typeName4("S"),
1492 AstFactory.withClause([AstFactory.typeName4("M1")]), 1514 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]),
1493 null)); 1515 null));
1494 } 1516 }
1495 1517
1496 void test_visitClassTypeAlias_parameters_abstract_implements() { 1518 void test_visitClassTypeAlias_parameters_abstract_implements() {
1497 _assertSource( 1519 _assertSource(
1498 "abstract class C<E> = S with M1 implements I;", 1520 "abstract class C<E> = S with M1 implements I;",
1499 AstFactory.classTypeAlias( 1521 AstTestFactory.classTypeAlias(
1500 "C", 1522 "C",
1501 AstFactory.typeParameterList(["E"]), 1523 AstTestFactory.typeParameterList(["E"]),
1502 Keyword.ABSTRACT, 1524 Keyword.ABSTRACT,
1503 AstFactory.typeName4("S"), 1525 AstTestFactory.typeName4("S"),
1504 AstFactory.withClause([AstFactory.typeName4("M1")]), 1526 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]),
1505 AstFactory.implementsClause([AstFactory.typeName4("I")]))); 1527 AstTestFactory.implementsClause([AstTestFactory.typeName4("I")])));
1506 } 1528 }
1507 1529
1508 void test_visitClassTypeAlias_parameters_implements() { 1530 void test_visitClassTypeAlias_parameters_implements() {
1509 _assertSource( 1531 _assertSource(
1510 "class C<E> = S with M1 implements I;", 1532 "class C<E> = S with M1 implements I;",
1511 AstFactory.classTypeAlias( 1533 AstTestFactory.classTypeAlias(
1512 "C", 1534 "C",
1513 AstFactory.typeParameterList(["E"]), 1535 AstTestFactory.typeParameterList(["E"]),
1514 null, 1536 null,
1515 AstFactory.typeName4("S"), 1537 AstTestFactory.typeName4("S"),
1516 AstFactory.withClause([AstFactory.typeName4("M1")]), 1538 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]),
1517 AstFactory.implementsClause([AstFactory.typeName4("I")]))); 1539 AstTestFactory.implementsClause([AstTestFactory.typeName4("I")])));
1518 } 1540 }
1519 1541
1520 void test_visitClassTypeAlias_withMetadata() { 1542 void test_visitClassTypeAlias_withMetadata() {
1521 ClassTypeAlias declaration = AstFactory.classTypeAlias( 1543 ClassTypeAlias declaration = AstTestFactory.classTypeAlias(
1522 "C", 1544 "C",
1523 null, 1545 null,
1524 null, 1546 null,
1525 AstFactory.typeName4("S"), 1547 AstTestFactory.typeName4("S"),
1526 AstFactory.withClause([AstFactory.typeName4("M1")]), 1548 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]),
1527 null); 1549 null);
1528 declaration.metadata 1550 declaration.metadata.add(
1529 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 1551 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
1530 _assertSource("@deprecated class C = S with M1;", declaration); 1552 _assertSource("@deprecated class C = S with M1;", declaration);
1531 } 1553 }
1532 1554
1533 void test_visitComment() { 1555 void test_visitComment() {
1534 _assertSource( 1556 _assertSource(
1535 "", 1557 "",
1536 Comment.createBlockComment( 1558 Comment.createBlockComment(
1537 <Token>[TokenFactory.tokenFromString("/* comment */")])); 1559 <Token>[TokenFactory.tokenFromString("/* comment */")]));
1538 } 1560 }
1539 1561
1540 void test_visitCommentReference() { 1562 void test_visitCommentReference() {
1541 _assertSource("", new CommentReference(null, AstFactory.identifier3("a"))); 1563 _assertSource(
1564 "", new CommentReference(null, AstTestFactory.identifier3("a")));
1542 } 1565 }
1543 1566
1544 void test_visitCompilationUnit_declaration() { 1567 void test_visitCompilationUnit_declaration() {
1545 _assertSource( 1568 _assertSource(
1546 "var a;", 1569 "var a;",
1547 AstFactory.compilationUnit2([ 1570 AstTestFactory.compilationUnit2([
1548 AstFactory.topLevelVariableDeclaration2( 1571 AstTestFactory.topLevelVariableDeclaration2(
1549 Keyword.VAR, [AstFactory.variableDeclaration("a")]) 1572 Keyword.VAR, [AstTestFactory.variableDeclaration("a")])
1550 ])); 1573 ]));
1551 } 1574 }
1552 1575
1553 void test_visitCompilationUnit_directive() { 1576 void test_visitCompilationUnit_directive() {
1554 _assertSource("library l;", 1577 _assertSource(
1555 AstFactory.compilationUnit3([AstFactory.libraryDirective2("l")])); 1578 "library l;",
1579 AstTestFactory
1580 .compilationUnit3([AstTestFactory.libraryDirective2("l")]));
1556 } 1581 }
1557 1582
1558 void test_visitCompilationUnit_directive_declaration() { 1583 void test_visitCompilationUnit_directive_declaration() {
1559 _assertSource( 1584 _assertSource(
1560 "library l; var a;", 1585 "library l; var a;",
1561 AstFactory.compilationUnit4([ 1586 AstTestFactory.compilationUnit4([
1562 AstFactory.libraryDirective2("l") 1587 AstTestFactory.libraryDirective2("l")
1563 ], [ 1588 ], [
1564 AstFactory.topLevelVariableDeclaration2( 1589 AstTestFactory.topLevelVariableDeclaration2(
1565 Keyword.VAR, [AstFactory.variableDeclaration("a")]) 1590 Keyword.VAR, [AstTestFactory.variableDeclaration("a")])
1566 ])); 1591 ]));
1567 } 1592 }
1568 1593
1569 void test_visitCompilationUnit_empty() { 1594 void test_visitCompilationUnit_empty() {
1570 _assertSource("", AstFactory.compilationUnit()); 1595 _assertSource("", AstTestFactory.compilationUnit());
1571 } 1596 }
1572 1597
1573 void test_visitCompilationUnit_script() { 1598 void test_visitCompilationUnit_script() {
1574 _assertSource( 1599 _assertSource(
1575 "!#/bin/dartvm", AstFactory.compilationUnit5("!#/bin/dartvm")); 1600 "!#/bin/dartvm", AstTestFactory.compilationUnit5("!#/bin/dartvm"));
1576 } 1601 }
1577 1602
1578 void test_visitCompilationUnit_script_declaration() { 1603 void test_visitCompilationUnit_script_declaration() {
1579 _assertSource( 1604 _assertSource(
1580 "!#/bin/dartvm var a;", 1605 "!#/bin/dartvm var a;",
1581 AstFactory.compilationUnit6("!#/bin/dartvm", [ 1606 AstTestFactory.compilationUnit6("!#/bin/dartvm", [
1582 AstFactory.topLevelVariableDeclaration2( 1607 AstTestFactory.topLevelVariableDeclaration2(
1583 Keyword.VAR, [AstFactory.variableDeclaration("a")]) 1608 Keyword.VAR, [AstTestFactory.variableDeclaration("a")])
1584 ])); 1609 ]));
1585 } 1610 }
1586 1611
1587 void test_visitCompilationUnit_script_directive() { 1612 void test_visitCompilationUnit_script_directive() {
1588 _assertSource( 1613 _assertSource(
1589 "!#/bin/dartvm library l;", 1614 "!#/bin/dartvm library l;",
1590 AstFactory.compilationUnit7( 1615 AstTestFactory.compilationUnit7(
1591 "!#/bin/dartvm", [AstFactory.libraryDirective2("l")])); 1616 "!#/bin/dartvm", [AstTestFactory.libraryDirective2("l")]));
1592 } 1617 }
1593 1618
1594 void test_visitCompilationUnit_script_directives_declarations() { 1619 void test_visitCompilationUnit_script_directives_declarations() {
1595 _assertSource( 1620 _assertSource(
1596 "!#/bin/dartvm library l; var a;", 1621 "!#/bin/dartvm library l; var a;",
1597 AstFactory.compilationUnit8("!#/bin/dartvm", [ 1622 AstTestFactory.compilationUnit8("!#/bin/dartvm", [
1598 AstFactory.libraryDirective2("l") 1623 AstTestFactory.libraryDirective2("l")
1599 ], [ 1624 ], [
1600 AstFactory.topLevelVariableDeclaration2( 1625 AstTestFactory.topLevelVariableDeclaration2(
1601 Keyword.VAR, [AstFactory.variableDeclaration("a")]) 1626 Keyword.VAR, [AstTestFactory.variableDeclaration("a")])
1602 ])); 1627 ]));
1603 } 1628 }
1604 1629
1605 void test_visitConditionalExpression() { 1630 void test_visitConditionalExpression() {
1606 _assertSource( 1631 _assertSource(
1607 "a ? b : c", 1632 "a ? b : c",
1608 AstFactory.conditionalExpression(AstFactory.identifier3("a"), 1633 AstTestFactory.conditionalExpression(AstTestFactory.identifier3("a"),
1609 AstFactory.identifier3("b"), AstFactory.identifier3("c"))); 1634 AstTestFactory.identifier3("b"), AstTestFactory.identifier3("c")));
1610 } 1635 }
1611 1636
1612 void test_visitConstructorDeclaration_const() { 1637 void test_visitConstructorDeclaration_const() {
1613 _assertSource( 1638 _assertSource(
1614 "const C() {}", 1639 "const C() {}",
1615 AstFactory.constructorDeclaration2( 1640 AstTestFactory.constructorDeclaration2(
1616 Keyword.CONST, 1641 Keyword.CONST,
1617 null, 1642 null,
1618 AstFactory.identifier3("C"), 1643 AstTestFactory.identifier3("C"),
1619 null, 1644 null,
1620 AstFactory.formalParameterList(), 1645 AstTestFactory.formalParameterList(),
1621 null, 1646 null,
1622 AstFactory.blockFunctionBody2())); 1647 AstTestFactory.blockFunctionBody2()));
1623 } 1648 }
1624 1649
1625 void test_visitConstructorDeclaration_external() { 1650 void test_visitConstructorDeclaration_external() {
1626 _assertSource( 1651 _assertSource(
1627 "external C();", 1652 "external C();",
1628 AstFactory.constructorDeclaration(AstFactory.identifier3("C"), null, 1653 AstTestFactory.constructorDeclaration(AstTestFactory.identifier3("C"),
1629 AstFactory.formalParameterList(), null)); 1654 null, AstTestFactory.formalParameterList(), null));
1630 } 1655 }
1631 1656
1632 void test_visitConstructorDeclaration_minimal() { 1657 void test_visitConstructorDeclaration_minimal() {
1633 _assertSource( 1658 _assertSource(
1634 "C() {}", 1659 "C() {}",
1635 AstFactory.constructorDeclaration2( 1660 AstTestFactory.constructorDeclaration2(
1636 null, 1661 null,
1637 null, 1662 null,
1638 AstFactory.identifier3("C"), 1663 AstTestFactory.identifier3("C"),
1639 null, 1664 null,
1640 AstFactory.formalParameterList(), 1665 AstTestFactory.formalParameterList(),
1641 null, 1666 null,
1642 AstFactory.blockFunctionBody2())); 1667 AstTestFactory.blockFunctionBody2()));
1643 } 1668 }
1644 1669
1645 void test_visitConstructorDeclaration_multipleInitializers() { 1670 void test_visitConstructorDeclaration_multipleInitializers() {
1646 _assertSource( 1671 _assertSource(
1647 "C() : a = b, c = d {}", 1672 "C() : a = b, c = d {}",
1648 AstFactory.constructorDeclaration2( 1673 AstTestFactory.constructorDeclaration2(
1649 null, 1674 null,
1650 null, 1675 null,
1651 AstFactory.identifier3("C"), 1676 AstTestFactory.identifier3("C"),
1652 null, 1677 null,
1653 AstFactory.formalParameterList(), 1678 AstTestFactory.formalParameterList(),
1654 [ 1679 [
1655 AstFactory.constructorFieldInitializer( 1680 AstTestFactory.constructorFieldInitializer(
1656 false, "a", AstFactory.identifier3("b")), 1681 false, "a", AstTestFactory.identifier3("b")),
1657 AstFactory.constructorFieldInitializer( 1682 AstTestFactory.constructorFieldInitializer(
1658 false, "c", AstFactory.identifier3("d")) 1683 false, "c", AstTestFactory.identifier3("d"))
1659 ], 1684 ],
1660 AstFactory.blockFunctionBody2())); 1685 AstTestFactory.blockFunctionBody2()));
1661 } 1686 }
1662 1687
1663 void test_visitConstructorDeclaration_multipleParameters() { 1688 void test_visitConstructorDeclaration_multipleParameters() {
1664 _assertSource( 1689 _assertSource(
1665 "C(var a, var b) {}", 1690 "C(var a, var b) {}",
1666 AstFactory.constructorDeclaration2( 1691 AstTestFactory.constructorDeclaration2(
1667 null, 1692 null,
1668 null, 1693 null,
1669 AstFactory.identifier3("C"), 1694 AstTestFactory.identifier3("C"),
1670 null, 1695 null,
1671 AstFactory.formalParameterList([ 1696 AstTestFactory.formalParameterList([
1672 AstFactory.simpleFormalParameter(Keyword.VAR, "a"), 1697 AstTestFactory.simpleFormalParameter(Keyword.VAR, "a"),
1673 AstFactory.simpleFormalParameter(Keyword.VAR, "b") 1698 AstTestFactory.simpleFormalParameter(Keyword.VAR, "b")
1674 ]), 1699 ]),
1675 null, 1700 null,
1676 AstFactory.blockFunctionBody2())); 1701 AstTestFactory.blockFunctionBody2()));
1677 } 1702 }
1678 1703
1679 void test_visitConstructorDeclaration_named() { 1704 void test_visitConstructorDeclaration_named() {
1680 _assertSource( 1705 _assertSource(
1681 "C.m() {}", 1706 "C.m() {}",
1682 AstFactory.constructorDeclaration2( 1707 AstTestFactory.constructorDeclaration2(
1683 null, 1708 null,
1684 null, 1709 null,
1685 AstFactory.identifier3("C"), 1710 AstTestFactory.identifier3("C"),
1686 "m", 1711 "m",
1687 AstFactory.formalParameterList(), 1712 AstTestFactory.formalParameterList(),
1688 null, 1713 null,
1689 AstFactory.blockFunctionBody2())); 1714 AstTestFactory.blockFunctionBody2()));
1690 } 1715 }
1691 1716
1692 void test_visitConstructorDeclaration_singleInitializer() { 1717 void test_visitConstructorDeclaration_singleInitializer() {
1693 _assertSource( 1718 _assertSource(
1694 "C() : a = b {}", 1719 "C() : a = b {}",
1695 AstFactory.constructorDeclaration2( 1720 AstTestFactory.constructorDeclaration2(
1696 null, 1721 null,
1697 null, 1722 null,
1698 AstFactory.identifier3("C"), 1723 AstTestFactory.identifier3("C"),
1699 null, 1724 null,
1700 AstFactory.formalParameterList(), 1725 AstTestFactory.formalParameterList(),
1701 [ 1726 [
1702 AstFactory.constructorFieldInitializer( 1727 AstTestFactory.constructorFieldInitializer(
1703 false, "a", AstFactory.identifier3("b")) 1728 false, "a", AstTestFactory.identifier3("b"))
1704 ], 1729 ],
1705 AstFactory.blockFunctionBody2())); 1730 AstTestFactory.blockFunctionBody2()));
1706 } 1731 }
1707 1732
1708 void test_visitConstructorDeclaration_withMetadata() { 1733 void test_visitConstructorDeclaration_withMetadata() {
1709 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( 1734 ConstructorDeclaration declaration = AstTestFactory.constructorDeclaration2(
1710 null, 1735 null,
1711 null, 1736 null,
1712 AstFactory.identifier3("C"), 1737 AstTestFactory.identifier3("C"),
1713 null, 1738 null,
1714 AstFactory.formalParameterList(), 1739 AstTestFactory.formalParameterList(),
1715 null, 1740 null,
1716 AstFactory.blockFunctionBody2()); 1741 AstTestFactory.blockFunctionBody2());
1717 declaration.metadata 1742 declaration.metadata.add(
1718 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 1743 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
1719 _assertSource("@deprecated C() {}", declaration); 1744 _assertSource("@deprecated C() {}", declaration);
1720 } 1745 }
1721 1746
1722 void test_visitConstructorFieldInitializer_withoutThis() { 1747 void test_visitConstructorFieldInitializer_withoutThis() {
1723 _assertSource( 1748 _assertSource(
1724 "a = b", 1749 "a = b",
1725 AstFactory.constructorFieldInitializer( 1750 AstTestFactory.constructorFieldInitializer(
1726 false, "a", AstFactory.identifier3("b"))); 1751 false, "a", AstTestFactory.identifier3("b")));
1727 } 1752 }
1728 1753
1729 void test_visitConstructorFieldInitializer_withThis() { 1754 void test_visitConstructorFieldInitializer_withThis() {
1730 _assertSource( 1755 _assertSource(
1731 "this.a = b", 1756 "this.a = b",
1732 AstFactory.constructorFieldInitializer( 1757 AstTestFactory.constructorFieldInitializer(
1733 true, "a", AstFactory.identifier3("b"))); 1758 true, "a", AstTestFactory.identifier3("b")));
1734 } 1759 }
1735 1760
1736 void test_visitConstructorName_named_prefix() { 1761 void test_visitConstructorName_named_prefix() {
1737 _assertSource("p.C.n", 1762 _assertSource(
1738 AstFactory.constructorName(AstFactory.typeName4("p.C.n"), null)); 1763 "p.C.n",
1764 AstTestFactory.constructorName(
1765 AstTestFactory.typeName4("p.C.n"), null));
1739 } 1766 }
1740 1767
1741 void test_visitConstructorName_unnamed_noPrefix() { 1768 void test_visitConstructorName_unnamed_noPrefix() {
1742 _assertSource( 1769 _assertSource("C",
1743 "C", AstFactory.constructorName(AstFactory.typeName4("C"), null)); 1770 AstTestFactory.constructorName(AstTestFactory.typeName4("C"), null));
1744 } 1771 }
1745 1772
1746 void test_visitConstructorName_unnamed_prefix() { 1773 void test_visitConstructorName_unnamed_prefix() {
1747 _assertSource( 1774 _assertSource(
1748 "p.C", 1775 "p.C",
1749 AstFactory.constructorName( 1776 AstTestFactory.constructorName(
1750 AstFactory.typeName3(AstFactory.identifier5("p", "C")), null)); 1777 AstTestFactory.typeName3(AstTestFactory.identifier5("p", "C")),
1778 null));
1751 } 1779 }
1752 1780
1753 void test_visitContinueStatement_label() { 1781 void test_visitContinueStatement_label() {
1754 _assertSource("continue l;", AstFactory.continueStatement("l")); 1782 _assertSource("continue l;", AstTestFactory.continueStatement("l"));
1755 } 1783 }
1756 1784
1757 void test_visitContinueStatement_noLabel() { 1785 void test_visitContinueStatement_noLabel() {
1758 _assertSource("continue;", AstFactory.continueStatement()); 1786 _assertSource("continue;", AstTestFactory.continueStatement());
1759 } 1787 }
1760 1788
1761 void test_visitDefaultFormalParameter_annotation() { 1789 void test_visitDefaultFormalParameter_annotation() {
1762 DefaultFormalParameter parameter = AstFactory.positionalFormalParameter( 1790 DefaultFormalParameter parameter = AstTestFactory.positionalFormalParameter(
1763 AstFactory.simpleFormalParameter3("p"), AstFactory.integer(0)); 1791 AstTestFactory.simpleFormalParameter3("p"), AstTestFactory.integer(0));
1764 parameter.metadata.add(AstFactory.annotation(AstFactory.identifier3("A"))); 1792 parameter.metadata
1793 .add(AstTestFactory.annotation(AstTestFactory.identifier3("A")));
1765 _assertSource('@A p = 0', parameter); 1794 _assertSource('@A p = 0', parameter);
1766 } 1795 }
1767 1796
1768 void test_visitDefaultFormalParameter_named_noValue() { 1797 void test_visitDefaultFormalParameter_named_noValue() {
1769 _assertSource( 1798 _assertSource(
1770 "p", 1799 "p",
1771 AstFactory.namedFormalParameter( 1800 AstTestFactory.namedFormalParameter(
1772 AstFactory.simpleFormalParameter3("p"), null)); 1801 AstTestFactory.simpleFormalParameter3("p"), null));
1773 } 1802 }
1774 1803
1775 void test_visitDefaultFormalParameter_named_value() { 1804 void test_visitDefaultFormalParameter_named_value() {
1776 _assertSource( 1805 _assertSource(
1777 "p : 0", 1806 "p : 0",
1778 AstFactory.namedFormalParameter( 1807 AstTestFactory.namedFormalParameter(
1779 AstFactory.simpleFormalParameter3("p"), AstFactory.integer(0))); 1808 AstTestFactory.simpleFormalParameter3("p"),
1809 AstTestFactory.integer(0)));
1780 } 1810 }
1781 1811
1782 void test_visitDefaultFormalParameter_positional_noValue() { 1812 void test_visitDefaultFormalParameter_positional_noValue() {
1783 _assertSource( 1813 _assertSource(
1784 "p", 1814 "p",
1785 AstFactory.positionalFormalParameter( 1815 AstTestFactory.positionalFormalParameter(
1786 AstFactory.simpleFormalParameter3("p"), null)); 1816 AstTestFactory.simpleFormalParameter3("p"), null));
1787 } 1817 }
1788 1818
1789 void test_visitDefaultFormalParameter_positional_value() { 1819 void test_visitDefaultFormalParameter_positional_value() {
1790 _assertSource( 1820 _assertSource(
1791 "p = 0", 1821 "p = 0",
1792 AstFactory.positionalFormalParameter( 1822 AstTestFactory.positionalFormalParameter(
1793 AstFactory.simpleFormalParameter3("p"), AstFactory.integer(0))); 1823 AstTestFactory.simpleFormalParameter3("p"),
1824 AstTestFactory.integer(0)));
1794 } 1825 }
1795 1826
1796 void test_visitDoStatement() { 1827 void test_visitDoStatement() {
1797 _assertSource( 1828 _assertSource(
1798 "do {} while (c);", 1829 "do {} while (c);",
1799 AstFactory.doStatement( 1830 AstTestFactory.doStatement(
1800 AstFactory.block(), AstFactory.identifier3("c"))); 1831 AstTestFactory.block(), AstTestFactory.identifier3("c")));
1801 } 1832 }
1802 1833
1803 void test_visitDoubleLiteral() { 1834 void test_visitDoubleLiteral() {
1804 _assertSource("4.2", AstFactory.doubleLiteral(4.2)); 1835 _assertSource("4.2", AstTestFactory.doubleLiteral(4.2));
1805 } 1836 }
1806 1837
1807 void test_visitEmptyFunctionBody() { 1838 void test_visitEmptyFunctionBody() {
1808 _assertSource(";", AstFactory.emptyFunctionBody()); 1839 _assertSource(";", AstTestFactory.emptyFunctionBody());
1809 } 1840 }
1810 1841
1811 void test_visitEmptyStatement() { 1842 void test_visitEmptyStatement() {
1812 _assertSource(";", AstFactory.emptyStatement()); 1843 _assertSource(";", AstTestFactory.emptyStatement());
1813 } 1844 }
1814 1845
1815 void test_visitEnumDeclaration_multiple() { 1846 void test_visitEnumDeclaration_multiple() {
1816 _assertSource( 1847 _assertSource("enum E {ONE, TWO}",
1817 "enum E {ONE, TWO}", AstFactory.enumDeclaration2("E", ["ONE", "TWO"])); 1848 AstTestFactory.enumDeclaration2("E", ["ONE", "TWO"]));
1818 } 1849 }
1819 1850
1820 void test_visitEnumDeclaration_single() { 1851 void test_visitEnumDeclaration_single() {
1821 _assertSource("enum E {ONE}", AstFactory.enumDeclaration2("E", ["ONE"])); 1852 _assertSource(
1853 "enum E {ONE}", AstTestFactory.enumDeclaration2("E", ["ONE"]));
1822 } 1854 }
1823 1855
1824 void test_visitExportDirective_combinator() { 1856 void test_visitExportDirective_combinator() {
1825 _assertSource( 1857 _assertSource(
1826 "export 'a.dart' show A;", 1858 "export 'a.dart' show A;",
1827 AstFactory.exportDirective2("a.dart", [ 1859 AstTestFactory.exportDirective2("a.dart", [
1828 AstFactory.showCombinator([AstFactory.identifier3("A")]) 1860 AstTestFactory.showCombinator([AstTestFactory.identifier3("A")])
1829 ])); 1861 ]));
1830 } 1862 }
1831 1863
1832 void test_visitExportDirective_combinators() { 1864 void test_visitExportDirective_combinators() {
1833 _assertSource( 1865 _assertSource(
1834 "export 'a.dart' show A hide B;", 1866 "export 'a.dart' show A hide B;",
1835 AstFactory.exportDirective2("a.dart", [ 1867 AstTestFactory.exportDirective2("a.dart", [
1836 AstFactory.showCombinator([AstFactory.identifier3("A")]), 1868 AstTestFactory.showCombinator([AstTestFactory.identifier3("A")]),
1837 AstFactory.hideCombinator([AstFactory.identifier3("B")]) 1869 AstTestFactory.hideCombinator([AstTestFactory.identifier3("B")])
1838 ])); 1870 ]));
1839 } 1871 }
1840 1872
1841 void test_visitExportDirective_minimal() { 1873 void test_visitExportDirective_minimal() {
1842 _assertSource("export 'a.dart';", AstFactory.exportDirective2("a.dart")); 1874 _assertSource(
1875 "export 'a.dart';", AstTestFactory.exportDirective2("a.dart"));
1843 } 1876 }
1844 1877
1845 void test_visitExportDirective_withMetadata() { 1878 void test_visitExportDirective_withMetadata() {
1846 ExportDirective directive = AstFactory.exportDirective2("a.dart"); 1879 ExportDirective directive = AstTestFactory.exportDirective2("a.dart");
1847 directive.metadata 1880 directive.metadata.add(
1848 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 1881 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
1849 _assertSource("@deprecated export 'a.dart';", directive); 1882 _assertSource("@deprecated export 'a.dart';", directive);
1850 } 1883 }
1851 1884
1852 void test_visitExpressionFunctionBody_async() { 1885 void test_visitExpressionFunctionBody_async() {
1853 _assertSource("async => a;", 1886 _assertSource(
1854 AstFactory.asyncExpressionFunctionBody(AstFactory.identifier3("a"))); 1887 "async => a;",
1888 AstTestFactory
1889 .asyncExpressionFunctionBody(AstTestFactory.identifier3("a")));
1855 } 1890 }
1856 1891
1857 void test_visitExpressionFunctionBody_simple() { 1892 void test_visitExpressionFunctionBody_simple() {
1858 _assertSource("=> a;", 1893 _assertSource("=> a;",
1859 AstFactory.expressionFunctionBody(AstFactory.identifier3("a"))); 1894 AstTestFactory.expressionFunctionBody(AstTestFactory.identifier3("a")));
1860 } 1895 }
1861 1896
1862 void test_visitExpressionStatement() { 1897 void test_visitExpressionStatement() {
1863 _assertSource( 1898 _assertSource("a;",
1864 "a;", AstFactory.expressionStatement(AstFactory.identifier3("a"))); 1899 AstTestFactory.expressionStatement(AstTestFactory.identifier3("a")));
1865 } 1900 }
1866 1901
1867 void test_visitExtendsClause() { 1902 void test_visitExtendsClause() {
1868 _assertSource( 1903 _assertSource("extends C",
1869 "extends C", AstFactory.extendsClause(AstFactory.typeName4("C"))); 1904 AstTestFactory.extendsClause(AstTestFactory.typeName4("C")));
1870 } 1905 }
1871 1906
1872 void test_visitFieldDeclaration_instance() { 1907 void test_visitFieldDeclaration_instance() {
1873 _assertSource( 1908 _assertSource(
1874 "var a;", 1909 "var a;",
1875 AstFactory.fieldDeclaration2( 1910 AstTestFactory.fieldDeclaration2(
1876 false, Keyword.VAR, [AstFactory.variableDeclaration("a")])); 1911 false, Keyword.VAR, [AstTestFactory.variableDeclaration("a")]));
1877 } 1912 }
1878 1913
1879 void test_visitFieldDeclaration_static() { 1914 void test_visitFieldDeclaration_static() {
1880 _assertSource( 1915 _assertSource(
1881 "static var a;", 1916 "static var a;",
1882 AstFactory.fieldDeclaration2( 1917 AstTestFactory.fieldDeclaration2(
1883 true, Keyword.VAR, [AstFactory.variableDeclaration("a")])); 1918 true, Keyword.VAR, [AstTestFactory.variableDeclaration("a")]));
1884 } 1919 }
1885 1920
1886 void test_visitFieldDeclaration_withMetadata() { 1921 void test_visitFieldDeclaration_withMetadata() {
1887 FieldDeclaration declaration = AstFactory.fieldDeclaration2( 1922 FieldDeclaration declaration = AstTestFactory.fieldDeclaration2(
1888 false, Keyword.VAR, [AstFactory.variableDeclaration("a")]); 1923 false, Keyword.VAR, [AstTestFactory.variableDeclaration("a")]);
1889 declaration.metadata 1924 declaration.metadata.add(
1890 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 1925 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
1891 _assertSource("@deprecated var a;", declaration); 1926 _assertSource("@deprecated var a;", declaration);
1892 } 1927 }
1893 1928
1894 void test_visitFieldFormalParameter_annotation() { 1929 void test_visitFieldFormalParameter_annotation() {
1895 FieldFormalParameter parameter = AstFactory.fieldFormalParameter2('f'); 1930 FieldFormalParameter parameter = AstTestFactory.fieldFormalParameter2('f');
1896 parameter.metadata.add(AstFactory.annotation(AstFactory.identifier3("A"))); 1931 parameter.metadata
1932 .add(AstTestFactory.annotation(AstTestFactory.identifier3("A")));
1897 _assertSource('@A this.f', parameter); 1933 _assertSource('@A this.f', parameter);
1898 } 1934 }
1899 1935
1900 void test_visitFieldFormalParameter_functionTyped() { 1936 void test_visitFieldFormalParameter_functionTyped() {
1901 _assertSource( 1937 _assertSource(
1902 "A this.a(b)", 1938 "A this.a(b)",
1903 AstFactory.fieldFormalParameter( 1939 AstTestFactory.fieldFormalParameter(
1904 null, 1940 null,
1905 AstFactory.typeName4("A"), 1941 AstTestFactory.typeName4("A"),
1906 "a", 1942 "a",
1907 AstFactory.formalParameterList( 1943 AstTestFactory.formalParameterList(
1908 [AstFactory.simpleFormalParameter3("b")]))); 1944 [AstTestFactory.simpleFormalParameter3("b")])));
1909 } 1945 }
1910 1946
1911 void test_visitFieldFormalParameter_functionTyped_typeParameters() { 1947 void test_visitFieldFormalParameter_functionTyped_typeParameters() {
1912 _assertSource( 1948 _assertSource(
1913 "A this.a<E, F>(b)", 1949 "A this.a<E, F>(b)",
1914 new FieldFormalParameter( 1950 new FieldFormalParameter(
1915 null, 1951 null,
1916 null, 1952 null,
1917 null, 1953 null,
1918 AstFactory.typeName4('A'), 1954 AstTestFactory.typeName4('A'),
1919 TokenFactory.tokenFromKeyword(Keyword.THIS), 1955 TokenFactory.tokenFromKeyword(Keyword.THIS),
1920 TokenFactory.tokenFromType(TokenType.PERIOD), 1956 TokenFactory.tokenFromType(TokenType.PERIOD),
1921 AstFactory.identifier3('a'), 1957 AstTestFactory.identifier3('a'),
1922 AstFactory.typeParameterList(['E', 'F']), 1958 AstTestFactory.typeParameterList(['E', 'F']),
1923 AstFactory.formalParameterList( 1959 AstTestFactory.formalParameterList(
1924 [AstFactory.simpleFormalParameter3("b")]))); 1960 [AstTestFactory.simpleFormalParameter3("b")])));
1925 } 1961 }
1926 1962
1927 void test_visitFieldFormalParameter_keyword() { 1963 void test_visitFieldFormalParameter_keyword() {
1928 _assertSource( 1964 _assertSource("var this.a",
1929 "var this.a", AstFactory.fieldFormalParameter(Keyword.VAR, null, "a")); 1965 AstTestFactory.fieldFormalParameter(Keyword.VAR, null, "a"));
1930 } 1966 }
1931 1967
1932 void test_visitFieldFormalParameter_keywordAndType() { 1968 void test_visitFieldFormalParameter_keywordAndType() {
1933 _assertSource( 1969 _assertSource(
1934 "final A this.a", 1970 "final A this.a",
1935 AstFactory.fieldFormalParameter( 1971 AstTestFactory.fieldFormalParameter(
1936 Keyword.FINAL, AstFactory.typeName4("A"), "a")); 1972 Keyword.FINAL, AstTestFactory.typeName4("A"), "a"));
1937 } 1973 }
1938 1974
1939 void test_visitFieldFormalParameter_type() { 1975 void test_visitFieldFormalParameter_type() {
1940 _assertSource("A this.a", 1976 _assertSource(
1941 AstFactory.fieldFormalParameter(null, AstFactory.typeName4("A"), "a")); 1977 "A this.a",
1978 AstTestFactory.fieldFormalParameter(
1979 null, AstTestFactory.typeName4("A"), "a"));
1942 } 1980 }
1943 1981
1944 void test_visitForEachStatement_declared() { 1982 void test_visitForEachStatement_declared() {
1945 _assertSource( 1983 _assertSource(
1946 "for (var a in b) {}", 1984 "for (var a in b) {}",
1947 AstFactory.forEachStatement(AstFactory.declaredIdentifier3("a"), 1985 AstTestFactory.forEachStatement(AstTestFactory.declaredIdentifier3("a"),
1948 AstFactory.identifier3("b"), AstFactory.block())); 1986 AstTestFactory.identifier3("b"), AstTestFactory.block()));
1949 } 1987 }
1950 1988
1951 void test_visitForEachStatement_variable() { 1989 void test_visitForEachStatement_variable() {
1952 _assertSource( 1990 _assertSource(
1953 "for (a in b) {}", 1991 "for (a in b) {}",
1954 new ForEachStatement.withReference( 1992 new ForEachStatement.withReference(
1955 null, 1993 null,
1956 TokenFactory.tokenFromKeyword(Keyword.FOR), 1994 TokenFactory.tokenFromKeyword(Keyword.FOR),
1957 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), 1995 TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
1958 AstFactory.identifier3("a"), 1996 AstTestFactory.identifier3("a"),
1959 TokenFactory.tokenFromKeyword(Keyword.IN), 1997 TokenFactory.tokenFromKeyword(Keyword.IN),
1960 AstFactory.identifier3("b"), 1998 AstTestFactory.identifier3("b"),
1961 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), 1999 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN),
1962 AstFactory.block())); 2000 AstTestFactory.block()));
1963 } 2001 }
1964 2002
1965 void test_visitForEachStatement_variable_await() { 2003 void test_visitForEachStatement_variable_await() {
1966 _assertSource( 2004 _assertSource(
1967 "await for (a in b) {}", 2005 "await for (a in b) {}",
1968 new ForEachStatement.withReference( 2006 new ForEachStatement.withReference(
1969 TokenFactory.tokenFromString("await"), 2007 TokenFactory.tokenFromString("await"),
1970 TokenFactory.tokenFromKeyword(Keyword.FOR), 2008 TokenFactory.tokenFromKeyword(Keyword.FOR),
1971 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), 2009 TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
1972 AstFactory.identifier3("a"), 2010 AstTestFactory.identifier3("a"),
1973 TokenFactory.tokenFromKeyword(Keyword.IN), 2011 TokenFactory.tokenFromKeyword(Keyword.IN),
1974 AstFactory.identifier3("b"), 2012 AstTestFactory.identifier3("b"),
1975 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), 2013 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN),
1976 AstFactory.block())); 2014 AstTestFactory.block()));
1977 } 2015 }
1978 2016
1979 void test_visitFormalParameterList_empty() { 2017 void test_visitFormalParameterList_empty() {
1980 _assertSource("()", AstFactory.formalParameterList()); 2018 _assertSource("()", AstTestFactory.formalParameterList());
1981 } 2019 }
1982 2020
1983 void test_visitFormalParameterList_n() { 2021 void test_visitFormalParameterList_n() {
1984 _assertSource( 2022 _assertSource(
1985 "({a : 0})", 2023 "({a : 0})",
1986 AstFactory.formalParameterList([ 2024 AstTestFactory.formalParameterList([
1987 AstFactory.namedFormalParameter( 2025 AstTestFactory.namedFormalParameter(
1988 AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0)) 2026 AstTestFactory.simpleFormalParameter3("a"),
2027 AstTestFactory.integer(0))
1989 ])); 2028 ]));
1990 } 2029 }
1991 2030
1992 void test_visitFormalParameterList_nn() { 2031 void test_visitFormalParameterList_nn() {
1993 _assertSource( 2032 _assertSource(
1994 "({a : 0, b : 1})", 2033 "({a : 0, b : 1})",
1995 AstFactory.formalParameterList([ 2034 AstTestFactory.formalParameterList([
1996 AstFactory.namedFormalParameter( 2035 AstTestFactory.namedFormalParameter(
1997 AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0)), 2036 AstTestFactory.simpleFormalParameter3("a"),
1998 AstFactory.namedFormalParameter( 2037 AstTestFactory.integer(0)),
1999 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)) 2038 AstTestFactory.namedFormalParameter(
2039 AstTestFactory.simpleFormalParameter3("b"),
2040 AstTestFactory.integer(1))
2000 ])); 2041 ]));
2001 } 2042 }
2002 2043
2003 void test_visitFormalParameterList_p() { 2044 void test_visitFormalParameterList_p() {
2004 _assertSource( 2045 _assertSource(
2005 "([a = 0])", 2046 "([a = 0])",
2006 AstFactory.formalParameterList([ 2047 AstTestFactory.formalParameterList([
2007 AstFactory.positionalFormalParameter( 2048 AstTestFactory.positionalFormalParameter(
2008 AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0)) 2049 AstTestFactory.simpleFormalParameter3("a"),
2050 AstTestFactory.integer(0))
2009 ])); 2051 ]));
2010 } 2052 }
2011 2053
2012 void test_visitFormalParameterList_pp() { 2054 void test_visitFormalParameterList_pp() {
2013 _assertSource( 2055 _assertSource(
2014 "([a = 0, b = 1])", 2056 "([a = 0, b = 1])",
2015 AstFactory.formalParameterList([ 2057 AstTestFactory.formalParameterList([
2016 AstFactory.positionalFormalParameter( 2058 AstTestFactory.positionalFormalParameter(
2017 AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0)), 2059 AstTestFactory.simpleFormalParameter3("a"),
2018 AstFactory.positionalFormalParameter( 2060 AstTestFactory.integer(0)),
2019 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)) 2061 AstTestFactory.positionalFormalParameter(
2062 AstTestFactory.simpleFormalParameter3("b"),
2063 AstTestFactory.integer(1))
2020 ])); 2064 ]));
2021 } 2065 }
2022 2066
2023 void test_visitFormalParameterList_r() { 2067 void test_visitFormalParameterList_r() {
2024 _assertSource( 2068 _assertSource(
2025 "(a)", 2069 "(a)",
2026 AstFactory 2070 AstTestFactory
2027 .formalParameterList([AstFactory.simpleFormalParameter3("a")])); 2071 .formalParameterList([AstTestFactory.simpleFormalParameter3("a")]));
2028 } 2072 }
2029 2073
2030 void test_visitFormalParameterList_rn() { 2074 void test_visitFormalParameterList_rn() {
2031 _assertSource( 2075 _assertSource(
2032 "(a, {b : 1})", 2076 "(a, {b : 1})",
2033 AstFactory.formalParameterList([ 2077 AstTestFactory.formalParameterList([
2034 AstFactory.simpleFormalParameter3("a"), 2078 AstTestFactory.simpleFormalParameter3("a"),
2035 AstFactory.namedFormalParameter( 2079 AstTestFactory.namedFormalParameter(
2036 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)) 2080 AstTestFactory.simpleFormalParameter3("b"),
2081 AstTestFactory.integer(1))
2037 ])); 2082 ]));
2038 } 2083 }
2039 2084
2040 void test_visitFormalParameterList_rnn() { 2085 void test_visitFormalParameterList_rnn() {
2041 _assertSource( 2086 _assertSource(
2042 "(a, {b : 1, c : 2})", 2087 "(a, {b : 1, c : 2})",
2043 AstFactory.formalParameterList([ 2088 AstTestFactory.formalParameterList([
2044 AstFactory.simpleFormalParameter3("a"), 2089 AstTestFactory.simpleFormalParameter3("a"),
2045 AstFactory.namedFormalParameter( 2090 AstTestFactory.namedFormalParameter(
2046 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)), 2091 AstTestFactory.simpleFormalParameter3("b"),
2047 AstFactory.namedFormalParameter( 2092 AstTestFactory.integer(1)),
2048 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(2)) 2093 AstTestFactory.namedFormalParameter(
2094 AstTestFactory.simpleFormalParameter3("c"),
2095 AstTestFactory.integer(2))
2049 ])); 2096 ]));
2050 } 2097 }
2051 2098
2052 void test_visitFormalParameterList_rp() { 2099 void test_visitFormalParameterList_rp() {
2053 _assertSource( 2100 _assertSource(
2054 "(a, [b = 1])", 2101 "(a, [b = 1])",
2055 AstFactory.formalParameterList([ 2102 AstTestFactory.formalParameterList([
2056 AstFactory.simpleFormalParameter3("a"), 2103 AstTestFactory.simpleFormalParameter3("a"),
2057 AstFactory.positionalFormalParameter( 2104 AstTestFactory.positionalFormalParameter(
2058 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)) 2105 AstTestFactory.simpleFormalParameter3("b"),
2106 AstTestFactory.integer(1))
2059 ])); 2107 ]));
2060 } 2108 }
2061 2109
2062 void test_visitFormalParameterList_rpp() { 2110 void test_visitFormalParameterList_rpp() {
2063 _assertSource( 2111 _assertSource(
2064 "(a, [b = 1, c = 2])", 2112 "(a, [b = 1, c = 2])",
2065 AstFactory.formalParameterList([ 2113 AstTestFactory.formalParameterList([
2066 AstFactory.simpleFormalParameter3("a"), 2114 AstTestFactory.simpleFormalParameter3("a"),
2067 AstFactory.positionalFormalParameter( 2115 AstTestFactory.positionalFormalParameter(
2068 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)), 2116 AstTestFactory.simpleFormalParameter3("b"),
2069 AstFactory.positionalFormalParameter( 2117 AstTestFactory.integer(1)),
2070 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(2)) 2118 AstTestFactory.positionalFormalParameter(
2119 AstTestFactory.simpleFormalParameter3("c"),
2120 AstTestFactory.integer(2))
2071 ])); 2121 ]));
2072 } 2122 }
2073 2123
2074 void test_visitFormalParameterList_rr() { 2124 void test_visitFormalParameterList_rr() {
2075 _assertSource( 2125 _assertSource(
2076 "(a, b)", 2126 "(a, b)",
2077 AstFactory.formalParameterList([ 2127 AstTestFactory.formalParameterList([
2078 AstFactory.simpleFormalParameter3("a"), 2128 AstTestFactory.simpleFormalParameter3("a"),
2079 AstFactory.simpleFormalParameter3("b") 2129 AstTestFactory.simpleFormalParameter3("b")
2080 ])); 2130 ]));
2081 } 2131 }
2082 2132
2083 void test_visitFormalParameterList_rrn() { 2133 void test_visitFormalParameterList_rrn() {
2084 _assertSource( 2134 _assertSource(
2085 "(a, b, {c : 3})", 2135 "(a, b, {c : 3})",
2086 AstFactory.formalParameterList([ 2136 AstTestFactory.formalParameterList([
2087 AstFactory.simpleFormalParameter3("a"), 2137 AstTestFactory.simpleFormalParameter3("a"),
2088 AstFactory.simpleFormalParameter3("b"), 2138 AstTestFactory.simpleFormalParameter3("b"),
2089 AstFactory.namedFormalParameter( 2139 AstTestFactory.namedFormalParameter(
2090 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3)) 2140 AstTestFactory.simpleFormalParameter3("c"),
2141 AstTestFactory.integer(3))
2091 ])); 2142 ]));
2092 } 2143 }
2093 2144
2094 void test_visitFormalParameterList_rrnn() { 2145 void test_visitFormalParameterList_rrnn() {
2095 _assertSource( 2146 _assertSource(
2096 "(a, b, {c : 3, d : 4})", 2147 "(a, b, {c : 3, d : 4})",
2097 AstFactory.formalParameterList([ 2148 AstTestFactory.formalParameterList([
2098 AstFactory.simpleFormalParameter3("a"), 2149 AstTestFactory.simpleFormalParameter3("a"),
2099 AstFactory.simpleFormalParameter3("b"), 2150 AstTestFactory.simpleFormalParameter3("b"),
2100 AstFactory.namedFormalParameter( 2151 AstTestFactory.namedFormalParameter(
2101 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3)), 2152 AstTestFactory.simpleFormalParameter3("c"),
2102 AstFactory.namedFormalParameter( 2153 AstTestFactory.integer(3)),
2103 AstFactory.simpleFormalParameter3("d"), AstFactory.integer(4)) 2154 AstTestFactory.namedFormalParameter(
2155 AstTestFactory.simpleFormalParameter3("d"),
2156 AstTestFactory.integer(4))
2104 ])); 2157 ]));
2105 } 2158 }
2106 2159
2107 void test_visitFormalParameterList_rrp() { 2160 void test_visitFormalParameterList_rrp() {
2108 _assertSource( 2161 _assertSource(
2109 "(a, b, [c = 3])", 2162 "(a, b, [c = 3])",
2110 AstFactory.formalParameterList([ 2163 AstTestFactory.formalParameterList([
2111 AstFactory.simpleFormalParameter3("a"), 2164 AstTestFactory.simpleFormalParameter3("a"),
2112 AstFactory.simpleFormalParameter3("b"), 2165 AstTestFactory.simpleFormalParameter3("b"),
2113 AstFactory.positionalFormalParameter( 2166 AstTestFactory.positionalFormalParameter(
2114 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3)) 2167 AstTestFactory.simpleFormalParameter3("c"),
2168 AstTestFactory.integer(3))
2115 ])); 2169 ]));
2116 } 2170 }
2117 2171
2118 void test_visitFormalParameterList_rrpp() { 2172 void test_visitFormalParameterList_rrpp() {
2119 _assertSource( 2173 _assertSource(
2120 "(a, b, [c = 3, d = 4])", 2174 "(a, b, [c = 3, d = 4])",
2121 AstFactory.formalParameterList([ 2175 AstTestFactory.formalParameterList([
2122 AstFactory.simpleFormalParameter3("a"), 2176 AstTestFactory.simpleFormalParameter3("a"),
2123 AstFactory.simpleFormalParameter3("b"), 2177 AstTestFactory.simpleFormalParameter3("b"),
2124 AstFactory.positionalFormalParameter( 2178 AstTestFactory.positionalFormalParameter(
2125 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3)), 2179 AstTestFactory.simpleFormalParameter3("c"),
2126 AstFactory.positionalFormalParameter( 2180 AstTestFactory.integer(3)),
2127 AstFactory.simpleFormalParameter3("d"), AstFactory.integer(4)) 2181 AstTestFactory.positionalFormalParameter(
2182 AstTestFactory.simpleFormalParameter3("d"),
2183 AstTestFactory.integer(4))
2128 ])); 2184 ]));
2129 } 2185 }
2130 2186
2131 void test_visitForStatement_c() { 2187 void test_visitForStatement_c() {
2132 _assertSource( 2188 _assertSource(
2133 "for (; c;) {}", 2189 "for (; c;) {}",
2134 AstFactory.forStatement( 2190 AstTestFactory.forStatement(null, AstTestFactory.identifier3("c"), null,
2135 null, AstFactory.identifier3("c"), null, AstFactory.block())); 2191 AstTestFactory.block()));
2136 } 2192 }
2137 2193
2138 void test_visitForStatement_cu() { 2194 void test_visitForStatement_cu() {
2139 _assertSource( 2195 _assertSource(
2140 "for (; c; u) {}", 2196 "for (; c; u) {}",
2141 AstFactory.forStatement(null, AstFactory.identifier3("c"), 2197 AstTestFactory.forStatement(null, AstTestFactory.identifier3("c"),
2142 [AstFactory.identifier3("u")], AstFactory.block())); 2198 [AstTestFactory.identifier3("u")], AstTestFactory.block()));
2143 } 2199 }
2144 2200
2145 void test_visitForStatement_e() { 2201 void test_visitForStatement_e() {
2146 _assertSource( 2202 _assertSource(
2147 "for (e;;) {}", 2203 "for (e;;) {}",
2148 AstFactory.forStatement( 2204 AstTestFactory.forStatement(AstTestFactory.identifier3("e"), null, null,
2149 AstFactory.identifier3("e"), null, null, AstFactory.block())); 2205 AstTestFactory.block()));
2150 } 2206 }
2151 2207
2152 void test_visitForStatement_ec() { 2208 void test_visitForStatement_ec() {
2153 _assertSource( 2209 _assertSource(
2154 "for (e; c;) {}", 2210 "for (e; c;) {}",
2155 AstFactory.forStatement(AstFactory.identifier3("e"), 2211 AstTestFactory.forStatement(AstTestFactory.identifier3("e"),
2156 AstFactory.identifier3("c"), null, AstFactory.block())); 2212 AstTestFactory.identifier3("c"), null, AstTestFactory.block()));
2157 } 2213 }
2158 2214
2159 void test_visitForStatement_ecu() { 2215 void test_visitForStatement_ecu() {
2160 _assertSource( 2216 _assertSource(
2161 "for (e; c; u) {}", 2217 "for (e; c; u) {}",
2162 AstFactory.forStatement( 2218 AstTestFactory.forStatement(
2163 AstFactory.identifier3("e"), 2219 AstTestFactory.identifier3("e"),
2164 AstFactory.identifier3("c"), 2220 AstTestFactory.identifier3("c"),
2165 [AstFactory.identifier3("u")], 2221 [AstTestFactory.identifier3("u")],
2166 AstFactory.block())); 2222 AstTestFactory.block()));
2167 } 2223 }
2168 2224
2169 void test_visitForStatement_eu() { 2225 void test_visitForStatement_eu() {
2170 _assertSource( 2226 _assertSource(
2171 "for (e;; u) {}", 2227 "for (e;; u) {}",
2172 AstFactory.forStatement(AstFactory.identifier3("e"), null, 2228 AstTestFactory.forStatement(AstTestFactory.identifier3("e"), null,
2173 [AstFactory.identifier3("u")], AstFactory.block())); 2229 [AstTestFactory.identifier3("u")], AstTestFactory.block()));
2174 } 2230 }
2175 2231
2176 void test_visitForStatement_i() { 2232 void test_visitForStatement_i() {
2177 _assertSource( 2233 _assertSource(
2178 "for (var i;;) {}", 2234 "for (var i;;) {}",
2179 AstFactory.forStatement2( 2235 AstTestFactory.forStatement2(
2180 AstFactory.variableDeclarationList2( 2236 AstTestFactory.variableDeclarationList2(
2181 Keyword.VAR, [AstFactory.variableDeclaration("i")]), 2237 Keyword.VAR, [AstTestFactory.variableDeclaration("i")]),
2182 null, 2238 null,
2183 null, 2239 null,
2184 AstFactory.block())); 2240 AstTestFactory.block()));
2185 } 2241 }
2186 2242
2187 void test_visitForStatement_ic() { 2243 void test_visitForStatement_ic() {
2188 _assertSource( 2244 _assertSource(
2189 "for (var i; c;) {}", 2245 "for (var i; c;) {}",
2190 AstFactory.forStatement2( 2246 AstTestFactory.forStatement2(
2191 AstFactory.variableDeclarationList2( 2247 AstTestFactory.variableDeclarationList2(
2192 Keyword.VAR, [AstFactory.variableDeclaration("i")]), 2248 Keyword.VAR, [AstTestFactory.variableDeclaration("i")]),
2193 AstFactory.identifier3("c"), 2249 AstTestFactory.identifier3("c"),
2194 null, 2250 null,
2195 AstFactory.block())); 2251 AstTestFactory.block()));
2196 } 2252 }
2197 2253
2198 void test_visitForStatement_icu() { 2254 void test_visitForStatement_icu() {
2199 _assertSource( 2255 _assertSource(
2200 "for (var i; c; u) {}", 2256 "for (var i; c; u) {}",
2201 AstFactory.forStatement2( 2257 AstTestFactory.forStatement2(
2202 AstFactory.variableDeclarationList2( 2258 AstTestFactory.variableDeclarationList2(
2203 Keyword.VAR, [AstFactory.variableDeclaration("i")]), 2259 Keyword.VAR, [AstTestFactory.variableDeclaration("i")]),
2204 AstFactory.identifier3("c"), 2260 AstTestFactory.identifier3("c"),
2205 [AstFactory.identifier3("u")], 2261 [AstTestFactory.identifier3("u")],
2206 AstFactory.block())); 2262 AstTestFactory.block()));
2207 } 2263 }
2208 2264
2209 void test_visitForStatement_iu() { 2265 void test_visitForStatement_iu() {
2210 _assertSource( 2266 _assertSource(
2211 "for (var i;; u) {}", 2267 "for (var i;; u) {}",
2212 AstFactory.forStatement2( 2268 AstTestFactory.forStatement2(
2213 AstFactory.variableDeclarationList2( 2269 AstTestFactory.variableDeclarationList2(
2214 Keyword.VAR, [AstFactory.variableDeclaration("i")]), 2270 Keyword.VAR, [AstTestFactory.variableDeclaration("i")]),
2215 null, 2271 null,
2216 [AstFactory.identifier3("u")], 2272 [AstTestFactory.identifier3("u")],
2217 AstFactory.block())); 2273 AstTestFactory.block()));
2218 } 2274 }
2219 2275
2220 void test_visitForStatement_u() { 2276 void test_visitForStatement_u() {
2221 _assertSource( 2277 _assertSource(
2222 "for (;; u) {}", 2278 "for (;; u) {}",
2223 AstFactory.forStatement( 2279 AstTestFactory.forStatement(null, null,
2224 null, null, [AstFactory.identifier3("u")], AstFactory.block())); 2280 [AstTestFactory.identifier3("u")], AstTestFactory.block()));
2225 } 2281 }
2226 2282
2227 void test_visitFunctionDeclaration_external() { 2283 void test_visitFunctionDeclaration_external() {
2228 FunctionDeclaration functionDeclaration = AstFactory.functionDeclaration( 2284 FunctionDeclaration functionDeclaration =
2229 null, 2285 AstTestFactory.functionDeclaration(
2230 null, 2286 null,
2231 "f", 2287 null,
2232 AstFactory.functionExpression2( 2288 "f",
2233 AstFactory.formalParameterList(), AstFactory.emptyFunctionBody())); 2289 AstTestFactory.functionExpression2(
2290 AstTestFactory.formalParameterList(),
2291 AstTestFactory.emptyFunctionBody()));
2234 functionDeclaration.externalKeyword = 2292 functionDeclaration.externalKeyword =
2235 TokenFactory.tokenFromKeyword(Keyword.EXTERNAL); 2293 TokenFactory.tokenFromKeyword(Keyword.EXTERNAL);
2236 _assertSource("external f();", functionDeclaration); 2294 _assertSource("external f();", functionDeclaration);
2237 } 2295 }
2238 2296
2239 void test_visitFunctionDeclaration_getter() { 2297 void test_visitFunctionDeclaration_getter() {
2240 _assertSource( 2298 _assertSource(
2241 "get f() {}", 2299 "get f() {}",
2242 AstFactory.functionDeclaration( 2300 AstTestFactory.functionDeclaration(
2243 null, Keyword.GET, "f", AstFactory.functionExpression())); 2301 null, Keyword.GET, "f", AstTestFactory.functionExpression()));
2244 } 2302 }
2245 2303
2246 void test_visitFunctionDeclaration_local_blockBody() { 2304 void test_visitFunctionDeclaration_local_blockBody() {
2247 FunctionDeclaration f = AstFactory.functionDeclaration( 2305 FunctionDeclaration f = AstTestFactory.functionDeclaration(
2248 null, null, "f", AstFactory.functionExpression()); 2306 null, null, "f", AstTestFactory.functionExpression());
2249 FunctionDeclarationStatement fStatement = 2307 FunctionDeclarationStatement fStatement =
2250 new FunctionDeclarationStatement(f); 2308 new FunctionDeclarationStatement(f);
2251 _assertSource( 2309 _assertSource(
2252 "main() {f() {} 42;}", 2310 "main() {f() {} 42;}",
2253 AstFactory.functionDeclaration( 2311 AstTestFactory.functionDeclaration(
2254 null, 2312 null,
2255 null, 2313 null,
2256 "main", 2314 "main",
2257 AstFactory.functionExpression2( 2315 AstTestFactory.functionExpression2(
2258 AstFactory.formalParameterList(), 2316 AstTestFactory.formalParameterList(),
2259 AstFactory.blockFunctionBody2([ 2317 AstTestFactory.blockFunctionBody2([
2260 fStatement, 2318 fStatement,
2261 AstFactory.expressionStatement(AstFactory.integer(42)) 2319 AstTestFactory.expressionStatement(AstTestFactory.integer(42))
2262 ])))); 2320 ]))));
2263 } 2321 }
2264 2322
2265 void test_visitFunctionDeclaration_local_expressionBody() { 2323 void test_visitFunctionDeclaration_local_expressionBody() {
2266 FunctionDeclaration f = AstFactory.functionDeclaration( 2324 FunctionDeclaration f = AstTestFactory.functionDeclaration(
2267 null, 2325 null,
2268 null, 2326 null,
2269 "f", 2327 "f",
2270 AstFactory.functionExpression2(AstFactory.formalParameterList(), 2328 AstTestFactory.functionExpression2(AstTestFactory.formalParameterList(),
2271 AstFactory.expressionFunctionBody(AstFactory.integer(1)))); 2329 AstTestFactory.expressionFunctionBody(AstTestFactory.integer(1))));
2272 FunctionDeclarationStatement fStatement = 2330 FunctionDeclarationStatement fStatement =
2273 new FunctionDeclarationStatement(f); 2331 new FunctionDeclarationStatement(f);
2274 _assertSource( 2332 _assertSource(
2275 "main() {f() => 1; 2;}", 2333 "main() {f() => 1; 2;}",
2276 AstFactory.functionDeclaration( 2334 AstTestFactory.functionDeclaration(
2277 null, 2335 null,
2278 null, 2336 null,
2279 "main", 2337 "main",
2280 AstFactory.functionExpression2( 2338 AstTestFactory.functionExpression2(
2281 AstFactory.formalParameterList(), 2339 AstTestFactory.formalParameterList(),
2282 AstFactory.blockFunctionBody2([ 2340 AstTestFactory.blockFunctionBody2([
2283 fStatement, 2341 fStatement,
2284 AstFactory.expressionStatement(AstFactory.integer(2)) 2342 AstTestFactory.expressionStatement(AstTestFactory.integer(2))
2285 ])))); 2343 ]))));
2286 } 2344 }
2287 2345
2288 void test_visitFunctionDeclaration_normal() { 2346 void test_visitFunctionDeclaration_normal() {
2289 _assertSource( 2347 _assertSource(
2290 "f() {}", 2348 "f() {}",
2291 AstFactory.functionDeclaration( 2349 AstTestFactory.functionDeclaration(
2292 null, null, "f", AstFactory.functionExpression())); 2350 null, null, "f", AstTestFactory.functionExpression()));
2293 } 2351 }
2294 2352
2295 void test_visitFunctionDeclaration_setter() { 2353 void test_visitFunctionDeclaration_setter() {
2296 _assertSource( 2354 _assertSource(
2297 "set f() {}", 2355 "set f() {}",
2298 AstFactory.functionDeclaration( 2356 AstTestFactory.functionDeclaration(
2299 null, Keyword.SET, "f", AstFactory.functionExpression())); 2357 null, Keyword.SET, "f", AstTestFactory.functionExpression()));
2300 } 2358 }
2301 2359
2302 void test_visitFunctionDeclaration_typeParameters() { 2360 void test_visitFunctionDeclaration_typeParameters() {
2303 _assertSource( 2361 _assertSource(
2304 "f<E>() {}", 2362 "f<E>() {}",
2305 AstFactory.functionDeclaration( 2363 AstTestFactory.functionDeclaration(
2306 null, 2364 null,
2307 null, 2365 null,
2308 "f", 2366 "f",
2309 AstFactory.functionExpression3( 2367 AstTestFactory.functionExpression3(
2310 AstFactory.typeParameterList(['E']), 2368 AstTestFactory.typeParameterList(['E']),
2311 AstFactory.formalParameterList(), 2369 AstTestFactory.formalParameterList(),
2312 AstFactory.blockFunctionBody2()))); 2370 AstTestFactory.blockFunctionBody2())));
2313 } 2371 }
2314 2372
2315 void test_visitFunctionDeclaration_withMetadata() { 2373 void test_visitFunctionDeclaration_withMetadata() {
2316 FunctionDeclaration declaration = AstFactory.functionDeclaration( 2374 FunctionDeclaration declaration = AstTestFactory.functionDeclaration(
2317 null, null, "f", AstFactory.functionExpression()); 2375 null, null, "f", AstTestFactory.functionExpression());
2318 declaration.metadata 2376 declaration.metadata.add(
2319 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 2377 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
2320 _assertSource("@deprecated f() {}", declaration); 2378 _assertSource("@deprecated f() {}", declaration);
2321 } 2379 }
2322 2380
2323 void test_visitFunctionDeclarationStatement() { 2381 void test_visitFunctionDeclarationStatement() {
2324 _assertSource( 2382 _assertSource(
2325 "f() {}", 2383 "f() {}",
2326 AstFactory.functionDeclarationStatement( 2384 AstTestFactory.functionDeclarationStatement(
2327 null, null, "f", AstFactory.functionExpression())); 2385 null, null, "f", AstTestFactory.functionExpression()));
2328 } 2386 }
2329 2387
2330 void test_visitFunctionExpression() { 2388 void test_visitFunctionExpression() {
2331 _assertSource("() {}", AstFactory.functionExpression()); 2389 _assertSource("() {}", AstTestFactory.functionExpression());
2332 } 2390 }
2333 2391
2334 void test_visitFunctionExpression_typeParameters() { 2392 void test_visitFunctionExpression_typeParameters() {
2335 _assertSource( 2393 _assertSource(
2336 "<E>() {}", 2394 "<E>() {}",
2337 AstFactory.functionExpression3(AstFactory.typeParameterList(['E']), 2395 AstTestFactory.functionExpression3(
2338 AstFactory.formalParameterList(), AstFactory.blockFunctionBody2())); 2396 AstTestFactory.typeParameterList(['E']),
2397 AstTestFactory.formalParameterList(),
2398 AstTestFactory.blockFunctionBody2()));
2339 } 2399 }
2340 2400
2341 void test_visitFunctionExpressionInvocation_minimal() { 2401 void test_visitFunctionExpressionInvocation_minimal() {
2342 _assertSource("f()", 2402 _assertSource(
2343 AstFactory.functionExpressionInvocation(AstFactory.identifier3("f"))); 2403 "f()",
2404 AstTestFactory
2405 .functionExpressionInvocation(AstTestFactory.identifier3("f")));
2344 } 2406 }
2345 2407
2346 void test_visitFunctionExpressionInvocation_typeArguments() { 2408 void test_visitFunctionExpressionInvocation_typeArguments() {
2347 _assertSource( 2409 _assertSource(
2348 "f<A>()", 2410 "f<A>()",
2349 AstFactory.functionExpressionInvocation2(AstFactory.identifier3("f"), 2411 AstTestFactory.functionExpressionInvocation2(
2350 AstFactory.typeArgumentList([AstFactory.typeName4('A')]))); 2412 AstTestFactory.identifier3("f"),
2413 AstTestFactory.typeArgumentList([AstTestFactory.typeName4('A')])));
2351 } 2414 }
2352 2415
2353 void test_visitFunctionTypeAlias_generic() { 2416 void test_visitFunctionTypeAlias_generic() {
2354 _assertSource( 2417 _assertSource(
2355 "typedef A F<B>();", 2418 "typedef A F<B>();",
2356 AstFactory.typeAlias( 2419 AstTestFactory.typeAlias(
2357 AstFactory.typeName4("A"), 2420 AstTestFactory.typeName4("A"),
2358 "F", 2421 "F",
2359 AstFactory.typeParameterList(["B"]), 2422 AstTestFactory.typeParameterList(["B"]),
2360 AstFactory.formalParameterList())); 2423 AstTestFactory.formalParameterList()));
2361 } 2424 }
2362 2425
2363 void test_visitFunctionTypeAlias_nonGeneric() { 2426 void test_visitFunctionTypeAlias_nonGeneric() {
2364 _assertSource( 2427 _assertSource(
2365 "typedef A F();", 2428 "typedef A F();",
2366 AstFactory.typeAlias(AstFactory.typeName4("A"), "F", null, 2429 AstTestFactory.typeAlias(AstTestFactory.typeName4("A"), "F", null,
2367 AstFactory.formalParameterList())); 2430 AstTestFactory.formalParameterList()));
2368 } 2431 }
2369 2432
2370 void test_visitFunctionTypeAlias_withMetadata() { 2433 void test_visitFunctionTypeAlias_withMetadata() {
2371 FunctionTypeAlias declaration = AstFactory.typeAlias( 2434 FunctionTypeAlias declaration = AstTestFactory.typeAlias(
2372 AstFactory.typeName4("A"), "F", null, AstFactory.formalParameterList()); 2435 AstTestFactory.typeName4("A"),
2373 declaration.metadata 2436 "F",
2374 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 2437 null,
2438 AstTestFactory.formalParameterList());
2439 declaration.metadata.add(
2440 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
2375 _assertSource("@deprecated typedef A F();", declaration); 2441 _assertSource("@deprecated typedef A F();", declaration);
2376 } 2442 }
2377 2443
2378 void test_visitFunctionTypedFormalParameter_annotation() { 2444 void test_visitFunctionTypedFormalParameter_annotation() {
2379 FunctionTypedFormalParameter parameter = 2445 FunctionTypedFormalParameter parameter =
2380 AstFactory.functionTypedFormalParameter(null, "f"); 2446 AstTestFactory.functionTypedFormalParameter(null, "f");
2381 parameter.metadata.add(AstFactory.annotation(AstFactory.identifier3("A"))); 2447 parameter.metadata
2448 .add(AstTestFactory.annotation(AstTestFactory.identifier3("A")));
2382 _assertSource('@A f()', parameter); 2449 _assertSource('@A f()', parameter);
2383 } 2450 }
2384 2451
2385 void test_visitFunctionTypedFormalParameter_noType() { 2452 void test_visitFunctionTypedFormalParameter_noType() {
2386 _assertSource("f()", AstFactory.functionTypedFormalParameter(null, "f")); 2453 _assertSource(
2454 "f()", AstTestFactory.functionTypedFormalParameter(null, "f"));
2387 } 2455 }
2388 2456
2389 void test_visitFunctionTypedFormalParameter_type() { 2457 void test_visitFunctionTypedFormalParameter_type() {
2390 _assertSource( 2458 _assertSource(
2391 "T f()", 2459 "T f()",
2392 AstFactory.functionTypedFormalParameter( 2460 AstTestFactory.functionTypedFormalParameter(
2393 AstFactory.typeName4("T"), "f")); 2461 AstTestFactory.typeName4("T"), "f"));
2394 } 2462 }
2395 2463
2396 void test_visitFunctionTypedFormalParameter_typeParameters() { 2464 void test_visitFunctionTypedFormalParameter_typeParameters() {
2397 _assertSource( 2465 _assertSource(
2398 "T f<E>()", 2466 "T f<E>()",
2399 new FunctionTypedFormalParameter( 2467 new FunctionTypedFormalParameter(
2400 null, 2468 null,
2401 null, 2469 null,
2402 AstFactory.typeName4("T"), 2470 AstTestFactory.typeName4("T"),
2403 AstFactory.identifier3('f'), 2471 AstTestFactory.identifier3('f'),
2404 AstFactory.typeParameterList(['E']), 2472 AstTestFactory.typeParameterList(['E']),
2405 AstFactory.formalParameterList([]))); 2473 AstTestFactory.formalParameterList([])));
2406 } 2474 }
2407 2475
2408 void test_visitIfStatement_withElse() { 2476 void test_visitIfStatement_withElse() {
2409 _assertSource( 2477 _assertSource(
2410 "if (c) {} else {}", 2478 "if (c) {} else {}",
2411 AstFactory.ifStatement2(AstFactory.identifier3("c"), AstFactory.block(), 2479 AstTestFactory.ifStatement2(AstTestFactory.identifier3("c"),
2412 AstFactory.block())); 2480 AstTestFactory.block(), AstTestFactory.block()));
2413 } 2481 }
2414 2482
2415 void test_visitIfStatement_withoutElse() { 2483 void test_visitIfStatement_withoutElse() {
2416 _assertSource( 2484 _assertSource(
2417 "if (c) {}", 2485 "if (c) {}",
2418 AstFactory.ifStatement( 2486 AstTestFactory.ifStatement(
2419 AstFactory.identifier3("c"), AstFactory.block())); 2487 AstTestFactory.identifier3("c"), AstTestFactory.block()));
2420 } 2488 }
2421 2489
2422 void test_visitImplementsClause_multiple() { 2490 void test_visitImplementsClause_multiple() {
2423 _assertSource( 2491 _assertSource(
2424 "implements A, B", 2492 "implements A, B",
2425 AstFactory.implementsClause( 2493 AstTestFactory.implementsClause(
2426 [AstFactory.typeName4("A"), AstFactory.typeName4("B")])); 2494 [AstTestFactory.typeName4("A"), AstTestFactory.typeName4("B")]));
2427 } 2495 }
2428 2496
2429 void test_visitImplementsClause_single() { 2497 void test_visitImplementsClause_single() {
2430 _assertSource("implements A", 2498 _assertSource("implements A",
2431 AstFactory.implementsClause([AstFactory.typeName4("A")])); 2499 AstTestFactory.implementsClause([AstTestFactory.typeName4("A")]));
2432 } 2500 }
2433 2501
2434 void test_visitImportDirective_combinator() { 2502 void test_visitImportDirective_combinator() {
2435 _assertSource( 2503 _assertSource(
2436 "import 'a.dart' show A;", 2504 "import 'a.dart' show A;",
2437 AstFactory.importDirective3("a.dart", null, [ 2505 AstTestFactory.importDirective3("a.dart", null, [
2438 AstFactory.showCombinator([AstFactory.identifier3("A")]) 2506 AstTestFactory.showCombinator([AstTestFactory.identifier3("A")])
2439 ])); 2507 ]));
2440 } 2508 }
2441 2509
2442 void test_visitImportDirective_combinators() { 2510 void test_visitImportDirective_combinators() {
2443 _assertSource( 2511 _assertSource(
2444 "import 'a.dart' show A hide B;", 2512 "import 'a.dart' show A hide B;",
2445 AstFactory.importDirective3("a.dart", null, [ 2513 AstTestFactory.importDirective3("a.dart", null, [
2446 AstFactory.showCombinator([AstFactory.identifier3("A")]), 2514 AstTestFactory.showCombinator([AstTestFactory.identifier3("A")]),
2447 AstFactory.hideCombinator([AstFactory.identifier3("B")]) 2515 AstTestFactory.hideCombinator([AstTestFactory.identifier3("B")])
2448 ])); 2516 ]));
2449 } 2517 }
2450 2518
2451 void test_visitImportDirective_deferred() { 2519 void test_visitImportDirective_deferred() {
2452 _assertSource("import 'a.dart' deferred as p;", 2520 _assertSource("import 'a.dart' deferred as p;",
2453 AstFactory.importDirective2("a.dart", true, "p")); 2521 AstTestFactory.importDirective2("a.dart", true, "p"));
2454 } 2522 }
2455 2523
2456 void test_visitImportDirective_minimal() { 2524 void test_visitImportDirective_minimal() {
2457 _assertSource( 2525 _assertSource(
2458 "import 'a.dart';", AstFactory.importDirective3("a.dart", null)); 2526 "import 'a.dart';", AstTestFactory.importDirective3("a.dart", null));
2459 } 2527 }
2460 2528
2461 void test_visitImportDirective_prefix() { 2529 void test_visitImportDirective_prefix() {
2462 _assertSource( 2530 _assertSource("import 'a.dart' as p;",
2463 "import 'a.dart' as p;", AstFactory.importDirective3("a.dart", "p")); 2531 AstTestFactory.importDirective3("a.dart", "p"));
2464 } 2532 }
2465 2533
2466 void test_visitImportDirective_prefix_combinator() { 2534 void test_visitImportDirective_prefix_combinator() {
2467 _assertSource( 2535 _assertSource(
2468 "import 'a.dart' as p show A;", 2536 "import 'a.dart' as p show A;",
2469 AstFactory.importDirective3("a.dart", "p", [ 2537 AstTestFactory.importDirective3("a.dart", "p", [
2470 AstFactory.showCombinator([AstFactory.identifier3("A")]) 2538 AstTestFactory.showCombinator([AstTestFactory.identifier3("A")])
2471 ])); 2539 ]));
2472 } 2540 }
2473 2541
2474 void test_visitImportDirective_prefix_combinators() { 2542 void test_visitImportDirective_prefix_combinators() {
2475 _assertSource( 2543 _assertSource(
2476 "import 'a.dart' as p show A hide B;", 2544 "import 'a.dart' as p show A hide B;",
2477 AstFactory.importDirective3("a.dart", "p", [ 2545 AstTestFactory.importDirective3("a.dart", "p", [
2478 AstFactory.showCombinator([AstFactory.identifier3("A")]), 2546 AstTestFactory.showCombinator([AstTestFactory.identifier3("A")]),
2479 AstFactory.hideCombinator([AstFactory.identifier3("B")]) 2547 AstTestFactory.hideCombinator([AstTestFactory.identifier3("B")])
2480 ])); 2548 ]));
2481 } 2549 }
2482 2550
2483 void test_visitImportDirective_withMetadata() { 2551 void test_visitImportDirective_withMetadata() {
2484 ImportDirective directive = AstFactory.importDirective3("a.dart", null); 2552 ImportDirective directive = AstTestFactory.importDirective3("a.dart", null);
2485 directive.metadata 2553 directive.metadata.add(
2486 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 2554 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
2487 _assertSource("@deprecated import 'a.dart';", directive); 2555 _assertSource("@deprecated import 'a.dart';", directive);
2488 } 2556 }
2489 2557
2490 void test_visitImportHideCombinator_multiple() { 2558 void test_visitImportHideCombinator_multiple() {
2491 _assertSource( 2559 _assertSource(
2492 "hide a, b", 2560 "hide a, b",
2493 AstFactory.hideCombinator( 2561 AstTestFactory.hideCombinator([
2494 [AstFactory.identifier3("a"), AstFactory.identifier3("b")])); 2562 AstTestFactory.identifier3("a"),
2563 AstTestFactory.identifier3("b")
2564 ]));
2495 } 2565 }
2496 2566
2497 void test_visitImportHideCombinator_single() { 2567 void test_visitImportHideCombinator_single() {
2498 _assertSource( 2568 _assertSource("hide a",
2499 "hide a", AstFactory.hideCombinator([AstFactory.identifier3("a")])); 2569 AstTestFactory.hideCombinator([AstTestFactory.identifier3("a")]));
2500 } 2570 }
2501 2571
2502 void test_visitImportShowCombinator_multiple() { 2572 void test_visitImportShowCombinator_multiple() {
2503 _assertSource( 2573 _assertSource(
2504 "show a, b", 2574 "show a, b",
2505 AstFactory.showCombinator( 2575 AstTestFactory.showCombinator([
2506 [AstFactory.identifier3("a"), AstFactory.identifier3("b")])); 2576 AstTestFactory.identifier3("a"),
2577 AstTestFactory.identifier3("b")
2578 ]));
2507 } 2579 }
2508 2580
2509 void test_visitImportShowCombinator_single() { 2581 void test_visitImportShowCombinator_single() {
2510 _assertSource( 2582 _assertSource("show a",
2511 "show a", AstFactory.showCombinator([AstFactory.identifier3("a")])); 2583 AstTestFactory.showCombinator([AstTestFactory.identifier3("a")]));
2512 } 2584 }
2513 2585
2514 void test_visitIndexExpression() { 2586 void test_visitIndexExpression() {
2515 _assertSource( 2587 _assertSource(
2516 "a[i]", 2588 "a[i]",
2517 AstFactory.indexExpression( 2589 AstTestFactory.indexExpression(
2518 AstFactory.identifier3("a"), AstFactory.identifier3("i"))); 2590 AstTestFactory.identifier3("a"), AstTestFactory.identifier3("i")));
2519 } 2591 }
2520 2592
2521 void test_visitInstanceCreationExpression_const() { 2593 void test_visitInstanceCreationExpression_const() {
2522 _assertSource( 2594 _assertSource(
2523 "const C()", 2595 "const C()",
2524 AstFactory.instanceCreationExpression2( 2596 AstTestFactory.instanceCreationExpression2(
2525 Keyword.CONST, AstFactory.typeName4("C"))); 2597 Keyword.CONST, AstTestFactory.typeName4("C")));
2526 } 2598 }
2527 2599
2528 void test_visitInstanceCreationExpression_named() { 2600 void test_visitInstanceCreationExpression_named() {
2529 _assertSource( 2601 _assertSource(
2530 "new C.c()", 2602 "new C.c()",
2531 AstFactory.instanceCreationExpression3( 2603 AstTestFactory.instanceCreationExpression3(
2532 Keyword.NEW, AstFactory.typeName4("C"), "c")); 2604 Keyword.NEW, AstTestFactory.typeName4("C"), "c"));
2533 } 2605 }
2534 2606
2535 void test_visitInstanceCreationExpression_unnamed() { 2607 void test_visitInstanceCreationExpression_unnamed() {
2536 _assertSource( 2608 _assertSource(
2537 "new C()", 2609 "new C()",
2538 AstFactory.instanceCreationExpression2( 2610 AstTestFactory.instanceCreationExpression2(
2539 Keyword.NEW, AstFactory.typeName4("C"))); 2611 Keyword.NEW, AstTestFactory.typeName4("C")));
2540 } 2612 }
2541 2613
2542 void test_visitIntegerLiteral() { 2614 void test_visitIntegerLiteral() {
2543 _assertSource("42", AstFactory.integer(42)); 2615 _assertSource("42", AstTestFactory.integer(42));
2544 } 2616 }
2545 2617
2546 void test_visitInterpolationExpression_expression() { 2618 void test_visitInterpolationExpression_expression() {
2547 _assertSource("\${a}", 2619 _assertSource(
2548 AstFactory.interpolationExpression(AstFactory.identifier3("a"))); 2620 "\${a}",
2621 AstTestFactory
2622 .interpolationExpression(AstTestFactory.identifier3("a")));
2549 } 2623 }
2550 2624
2551 void test_visitInterpolationExpression_identifier() { 2625 void test_visitInterpolationExpression_identifier() {
2552 _assertSource("\$a", AstFactory.interpolationExpression2("a")); 2626 _assertSource("\$a", AstTestFactory.interpolationExpression2("a"));
2553 } 2627 }
2554 2628
2555 void test_visitInterpolationString() { 2629 void test_visitInterpolationString() {
2556 _assertSource("'x", AstFactory.interpolationString("'x", "x")); 2630 _assertSource("'x", AstTestFactory.interpolationString("'x", "x"));
2557 } 2631 }
2558 2632
2559 void test_visitIsExpression_negated() { 2633 void test_visitIsExpression_negated() {
2560 _assertSource( 2634 _assertSource(
2561 "a is! C", 2635 "a is! C",
2562 AstFactory.isExpression( 2636 AstTestFactory.isExpression(AstTestFactory.identifier3("a"), true,
2563 AstFactory.identifier3("a"), true, AstFactory.typeName4("C"))); 2637 AstTestFactory.typeName4("C")));
2564 } 2638 }
2565 2639
2566 void test_visitIsExpression_normal() { 2640 void test_visitIsExpression_normal() {
2567 _assertSource( 2641 _assertSource(
2568 "a is C", 2642 "a is C",
2569 AstFactory.isExpression( 2643 AstTestFactory.isExpression(AstTestFactory.identifier3("a"), false,
2570 AstFactory.identifier3("a"), false, AstFactory.typeName4("C"))); 2644 AstTestFactory.typeName4("C")));
2571 } 2645 }
2572 2646
2573 void test_visitLabel() { 2647 void test_visitLabel() {
2574 _assertSource("a:", AstFactory.label2("a")); 2648 _assertSource("a:", AstTestFactory.label2("a"));
2575 } 2649 }
2576 2650
2577 void test_visitLabeledStatement_multiple() { 2651 void test_visitLabeledStatement_multiple() {
2578 _assertSource( 2652 _assertSource(
2579 "a: b: return;", 2653 "a: b: return;",
2580 AstFactory.labeledStatement( 2654 AstTestFactory.labeledStatement(
2581 [AstFactory.label2("a"), AstFactory.label2("b")], 2655 [AstTestFactory.label2("a"), AstTestFactory.label2("b")],
2582 AstFactory.returnStatement())); 2656 AstTestFactory.returnStatement()));
2583 } 2657 }
2584 2658
2585 void test_visitLabeledStatement_single() { 2659 void test_visitLabeledStatement_single() {
2586 _assertSource( 2660 _assertSource(
2587 "a: return;", 2661 "a: return;",
2588 AstFactory.labeledStatement( 2662 AstTestFactory.labeledStatement(
2589 [AstFactory.label2("a")], AstFactory.returnStatement())); 2663 [AstTestFactory.label2("a")], AstTestFactory.returnStatement()));
2590 } 2664 }
2591 2665
2592 void test_visitLibraryDirective() { 2666 void test_visitLibraryDirective() {
2593 _assertSource("library l;", AstFactory.libraryDirective2("l")); 2667 _assertSource("library l;", AstTestFactory.libraryDirective2("l"));
2594 } 2668 }
2595 2669
2596 void test_visitLibraryDirective_withMetadata() { 2670 void test_visitLibraryDirective_withMetadata() {
2597 LibraryDirective directive = AstFactory.libraryDirective2("l"); 2671 LibraryDirective directive = AstTestFactory.libraryDirective2("l");
2598 directive.metadata 2672 directive.metadata.add(
2599 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 2673 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
2600 _assertSource("@deprecated library l;", directive); 2674 _assertSource("@deprecated library l;", directive);
2601 } 2675 }
2602 2676
2603 void test_visitLibraryIdentifier_multiple() { 2677 void test_visitLibraryIdentifier_multiple() {
2604 _assertSource( 2678 _assertSource(
2605 "a.b.c", 2679 "a.b.c",
2606 AstFactory.libraryIdentifier([ 2680 AstTestFactory.libraryIdentifier([
2607 AstFactory.identifier3("a"), 2681 AstTestFactory.identifier3("a"),
2608 AstFactory.identifier3("b"), 2682 AstTestFactory.identifier3("b"),
2609 AstFactory.identifier3("c") 2683 AstTestFactory.identifier3("c")
2610 ])); 2684 ]));
2611 } 2685 }
2612 2686
2613 void test_visitLibraryIdentifier_single() { 2687 void test_visitLibraryIdentifier_single() {
2614 _assertSource( 2688 _assertSource("a",
2615 "a", AstFactory.libraryIdentifier([AstFactory.identifier3("a")])); 2689 AstTestFactory.libraryIdentifier([AstTestFactory.identifier3("a")]));
2616 } 2690 }
2617 2691
2618 void test_visitListLiteral_const() { 2692 void test_visitListLiteral_const() {
2619 _assertSource("const []", AstFactory.listLiteral2(Keyword.CONST, null)); 2693 _assertSource("const []", AstTestFactory.listLiteral2(Keyword.CONST, null));
2620 } 2694 }
2621 2695
2622 void test_visitListLiteral_empty() { 2696 void test_visitListLiteral_empty() {
2623 _assertSource("[]", AstFactory.listLiteral()); 2697 _assertSource("[]", AstTestFactory.listLiteral());
2624 } 2698 }
2625 2699
2626 void test_visitListLiteral_nonEmpty() { 2700 void test_visitListLiteral_nonEmpty() {
2627 _assertSource( 2701 _assertSource(
2628 "[a, b, c]", 2702 "[a, b, c]",
2629 AstFactory.listLiteral([ 2703 AstTestFactory.listLiteral([
2630 AstFactory.identifier3("a"), 2704 AstTestFactory.identifier3("a"),
2631 AstFactory.identifier3("b"), 2705 AstTestFactory.identifier3("b"),
2632 AstFactory.identifier3("c") 2706 AstTestFactory.identifier3("c")
2633 ])); 2707 ]));
2634 } 2708 }
2635 2709
2636 void test_visitMapLiteral_const() { 2710 void test_visitMapLiteral_const() {
2637 _assertSource("const {}", AstFactory.mapLiteral(Keyword.CONST, null)); 2711 _assertSource("const {}", AstTestFactory.mapLiteral(Keyword.CONST, null));
2638 } 2712 }
2639 2713
2640 void test_visitMapLiteral_empty() { 2714 void test_visitMapLiteral_empty() {
2641 _assertSource("{}", AstFactory.mapLiteral2()); 2715 _assertSource("{}", AstTestFactory.mapLiteral2());
2642 } 2716 }
2643 2717
2644 void test_visitMapLiteral_nonEmpty() { 2718 void test_visitMapLiteral_nonEmpty() {
2645 _assertSource( 2719 _assertSource(
2646 "{'a' : a, 'b' : b, 'c' : c}", 2720 "{'a' : a, 'b' : b, 'c' : c}",
2647 AstFactory.mapLiteral2([ 2721 AstTestFactory.mapLiteral2([
2648 AstFactory.mapLiteralEntry("a", AstFactory.identifier3("a")), 2722 AstTestFactory.mapLiteralEntry("a", AstTestFactory.identifier3("a")),
2649 AstFactory.mapLiteralEntry("b", AstFactory.identifier3("b")), 2723 AstTestFactory.mapLiteralEntry("b", AstTestFactory.identifier3("b")),
2650 AstFactory.mapLiteralEntry("c", AstFactory.identifier3("c")) 2724 AstTestFactory.mapLiteralEntry("c", AstTestFactory.identifier3("c"))
2651 ])); 2725 ]));
2652 } 2726 }
2653 2727
2654 void test_visitMapLiteralEntry() { 2728 void test_visitMapLiteralEntry() {
2655 _assertSource("'a' : b", 2729 _assertSource("'a' : b",
2656 AstFactory.mapLiteralEntry("a", AstFactory.identifier3("b"))); 2730 AstTestFactory.mapLiteralEntry("a", AstTestFactory.identifier3("b")));
2657 } 2731 }
2658 2732
2659 void test_visitMethodDeclaration_external() { 2733 void test_visitMethodDeclaration_external() {
2660 _assertSource( 2734 _assertSource(
2661 "external m();", 2735 "external m();",
2662 AstFactory.methodDeclaration(null, null, null, null, 2736 AstTestFactory.methodDeclaration(
2663 AstFactory.identifier3("m"), AstFactory.formalParameterList())); 2737 null,
2738 null,
2739 null,
2740 null,
2741 AstTestFactory.identifier3("m"),
2742 AstTestFactory.formalParameterList()));
2664 } 2743 }
2665 2744
2666 void test_visitMethodDeclaration_external_returnType() { 2745 void test_visitMethodDeclaration_external_returnType() {
2667 _assertSource( 2746 _assertSource(
2668 "external T m();", 2747 "external T m();",
2669 AstFactory.methodDeclaration( 2748 AstTestFactory.methodDeclaration(
2670 null, 2749 null,
2671 AstFactory.typeName4("T"), 2750 AstTestFactory.typeName4("T"),
2672 null, 2751 null,
2673 null, 2752 null,
2674 AstFactory.identifier3("m"), 2753 AstTestFactory.identifier3("m"),
2675 AstFactory.formalParameterList())); 2754 AstTestFactory.formalParameterList()));
2676 } 2755 }
2677 2756
2678 void test_visitMethodDeclaration_getter() { 2757 void test_visitMethodDeclaration_getter() {
2679 _assertSource( 2758 _assertSource(
2680 "get m {}", 2759 "get m {}",
2681 AstFactory.methodDeclaration2( 2760 AstTestFactory.methodDeclaration2(
2682 null, 2761 null,
2683 null, 2762 null,
2684 Keyword.GET, 2763 Keyword.GET,
2685 null, 2764 null,
2686 AstFactory.identifier3("m"), 2765 AstTestFactory.identifier3("m"),
2687 null, 2766 null,
2688 AstFactory.blockFunctionBody2())); 2767 AstTestFactory.blockFunctionBody2()));
2689 } 2768 }
2690 2769
2691 void test_visitMethodDeclaration_getter_returnType() { 2770 void test_visitMethodDeclaration_getter_returnType() {
2692 _assertSource( 2771 _assertSource(
2693 "T get m {}", 2772 "T get m {}",
2694 AstFactory.methodDeclaration2( 2773 AstTestFactory.methodDeclaration2(
2695 null, 2774 null,
2696 AstFactory.typeName4("T"), 2775 AstTestFactory.typeName4("T"),
2697 Keyword.GET, 2776 Keyword.GET,
2698 null, 2777 null,
2699 AstFactory.identifier3("m"), 2778 AstTestFactory.identifier3("m"),
2700 null, 2779 null,
2701 AstFactory.blockFunctionBody2())); 2780 AstTestFactory.blockFunctionBody2()));
2702 } 2781 }
2703 2782
2704 void test_visitMethodDeclaration_getter_seturnType() { 2783 void test_visitMethodDeclaration_getter_seturnType() {
2705 _assertSource( 2784 _assertSource(
2706 "T set m(var v) {}", 2785 "T set m(var v) {}",
2707 AstFactory.methodDeclaration2( 2786 AstTestFactory.methodDeclaration2(
2708 null, 2787 null,
2709 AstFactory.typeName4("T"), 2788 AstTestFactory.typeName4("T"),
2710 Keyword.SET, 2789 Keyword.SET,
2711 null, 2790 null,
2712 AstFactory.identifier3("m"), 2791 AstTestFactory.identifier3("m"),
2713 AstFactory.formalParameterList( 2792 AstTestFactory.formalParameterList(
2714 [AstFactory.simpleFormalParameter(Keyword.VAR, "v")]), 2793 [AstTestFactory.simpleFormalParameter(Keyword.VAR, "v")]),
2715 AstFactory.blockFunctionBody2())); 2794 AstTestFactory.blockFunctionBody2()));
2716 } 2795 }
2717 2796
2718 void test_visitMethodDeclaration_minimal() { 2797 void test_visitMethodDeclaration_minimal() {
2719 _assertSource( 2798 _assertSource(
2720 "m() {}", 2799 "m() {}",
2721 AstFactory.methodDeclaration2( 2800 AstTestFactory.methodDeclaration2(
2722 null, 2801 null,
2723 null, 2802 null,
2724 null, 2803 null,
2725 null, 2804 null,
2726 AstFactory.identifier3("m"), 2805 AstTestFactory.identifier3("m"),
2727 AstFactory.formalParameterList(), 2806 AstTestFactory.formalParameterList(),
2728 AstFactory.blockFunctionBody2())); 2807 AstTestFactory.blockFunctionBody2()));
2729 } 2808 }
2730 2809
2731 void test_visitMethodDeclaration_multipleParameters() { 2810 void test_visitMethodDeclaration_multipleParameters() {
2732 _assertSource( 2811 _assertSource(
2733 "m(var a, var b) {}", 2812 "m(var a, var b) {}",
2734 AstFactory.methodDeclaration2( 2813 AstTestFactory.methodDeclaration2(
2735 null, 2814 null,
2736 null, 2815 null,
2737 null, 2816 null,
2738 null, 2817 null,
2739 AstFactory.identifier3("m"), 2818 AstTestFactory.identifier3("m"),
2740 AstFactory.formalParameterList([ 2819 AstTestFactory.formalParameterList([
2741 AstFactory.simpleFormalParameter(Keyword.VAR, "a"), 2820 AstTestFactory.simpleFormalParameter(Keyword.VAR, "a"),
2742 AstFactory.simpleFormalParameter(Keyword.VAR, "b") 2821 AstTestFactory.simpleFormalParameter(Keyword.VAR, "b")
2743 ]), 2822 ]),
2744 AstFactory.blockFunctionBody2())); 2823 AstTestFactory.blockFunctionBody2()));
2745 } 2824 }
2746 2825
2747 void test_visitMethodDeclaration_operator() { 2826 void test_visitMethodDeclaration_operator() {
2748 _assertSource( 2827 _assertSource(
2749 "operator +() {}", 2828 "operator +() {}",
2750 AstFactory.methodDeclaration2( 2829 AstTestFactory.methodDeclaration2(
2751 null, 2830 null,
2752 null, 2831 null,
2753 null, 2832 null,
2754 Keyword.OPERATOR, 2833 Keyword.OPERATOR,
2755 AstFactory.identifier3("+"), 2834 AstTestFactory.identifier3("+"),
2756 AstFactory.formalParameterList(), 2835 AstTestFactory.formalParameterList(),
2757 AstFactory.blockFunctionBody2())); 2836 AstTestFactory.blockFunctionBody2()));
2758 } 2837 }
2759 2838
2760 void test_visitMethodDeclaration_operator_returnType() { 2839 void test_visitMethodDeclaration_operator_returnType() {
2761 _assertSource( 2840 _assertSource(
2762 "T operator +() {}", 2841 "T operator +() {}",
2763 AstFactory.methodDeclaration2( 2842 AstTestFactory.methodDeclaration2(
2764 null, 2843 null,
2765 AstFactory.typeName4("T"), 2844 AstTestFactory.typeName4("T"),
2766 null, 2845 null,
2767 Keyword.OPERATOR, 2846 Keyword.OPERATOR,
2768 AstFactory.identifier3("+"), 2847 AstTestFactory.identifier3("+"),
2769 AstFactory.formalParameterList(), 2848 AstTestFactory.formalParameterList(),
2770 AstFactory.blockFunctionBody2())); 2849 AstTestFactory.blockFunctionBody2()));
2771 } 2850 }
2772 2851
2773 void test_visitMethodDeclaration_returnType() { 2852 void test_visitMethodDeclaration_returnType() {
2774 _assertSource( 2853 _assertSource(
2775 "T m() {}", 2854 "T m() {}",
2776 AstFactory.methodDeclaration2( 2855 AstTestFactory.methodDeclaration2(
2777 null, 2856 null,
2778 AstFactory.typeName4("T"), 2857 AstTestFactory.typeName4("T"),
2779 null, 2858 null,
2780 null, 2859 null,
2781 AstFactory.identifier3("m"), 2860 AstTestFactory.identifier3("m"),
2782 AstFactory.formalParameterList(), 2861 AstTestFactory.formalParameterList(),
2783 AstFactory.blockFunctionBody2())); 2862 AstTestFactory.blockFunctionBody2()));
2784 } 2863 }
2785 2864
2786 void test_visitMethodDeclaration_setter() { 2865 void test_visitMethodDeclaration_setter() {
2787 _assertSource( 2866 _assertSource(
2788 "set m(var v) {}", 2867 "set m(var v) {}",
2789 AstFactory.methodDeclaration2( 2868 AstTestFactory.methodDeclaration2(
2790 null, 2869 null,
2791 null, 2870 null,
2792 Keyword.SET, 2871 Keyword.SET,
2793 null, 2872 null,
2794 AstFactory.identifier3("m"), 2873 AstTestFactory.identifier3("m"),
2795 AstFactory.formalParameterList( 2874 AstTestFactory.formalParameterList(
2796 [AstFactory.simpleFormalParameter(Keyword.VAR, "v")]), 2875 [AstTestFactory.simpleFormalParameter(Keyword.VAR, "v")]),
2797 AstFactory.blockFunctionBody2())); 2876 AstTestFactory.blockFunctionBody2()));
2798 } 2877 }
2799 2878
2800 void test_visitMethodDeclaration_static() { 2879 void test_visitMethodDeclaration_static() {
2801 _assertSource( 2880 _assertSource(
2802 "static m() {}", 2881 "static m() {}",
2803 AstFactory.methodDeclaration2( 2882 AstTestFactory.methodDeclaration2(
2804 Keyword.STATIC, 2883 Keyword.STATIC,
2805 null, 2884 null,
2806 null, 2885 null,
2807 null, 2886 null,
2808 AstFactory.identifier3("m"), 2887 AstTestFactory.identifier3("m"),
2809 AstFactory.formalParameterList(), 2888 AstTestFactory.formalParameterList(),
2810 AstFactory.blockFunctionBody2())); 2889 AstTestFactory.blockFunctionBody2()));
2811 } 2890 }
2812 2891
2813 void test_visitMethodDeclaration_static_returnType() { 2892 void test_visitMethodDeclaration_static_returnType() {
2814 _assertSource( 2893 _assertSource(
2815 "static T m() {}", 2894 "static T m() {}",
2816 AstFactory.methodDeclaration2( 2895 AstTestFactory.methodDeclaration2(
2817 Keyword.STATIC, 2896 Keyword.STATIC,
2818 AstFactory.typeName4("T"), 2897 AstTestFactory.typeName4("T"),
2819 null, 2898 null,
2820 null, 2899 null,
2821 AstFactory.identifier3("m"), 2900 AstTestFactory.identifier3("m"),
2822 AstFactory.formalParameterList(), 2901 AstTestFactory.formalParameterList(),
2823 AstFactory.blockFunctionBody2())); 2902 AstTestFactory.blockFunctionBody2()));
2824 } 2903 }
2825 2904
2826 void test_visitMethodDeclaration_typeParameters() { 2905 void test_visitMethodDeclaration_typeParameters() {
2827 _assertSource( 2906 _assertSource(
2828 "m<E>() {}", 2907 "m<E>() {}",
2829 AstFactory.methodDeclaration3( 2908 AstTestFactory.methodDeclaration3(
2830 null, 2909 null,
2831 null, 2910 null,
2832 null, 2911 null,
2833 null, 2912 null,
2834 AstFactory.identifier3("m"), 2913 AstTestFactory.identifier3("m"),
2835 AstFactory.typeParameterList(['E']), 2914 AstTestFactory.typeParameterList(['E']),
2836 AstFactory.formalParameterList(), 2915 AstTestFactory.formalParameterList(),
2837 AstFactory.blockFunctionBody2())); 2916 AstTestFactory.blockFunctionBody2()));
2838 } 2917 }
2839 2918
2840 void test_visitMethodDeclaration_withMetadata() { 2919 void test_visitMethodDeclaration_withMetadata() {
2841 MethodDeclaration declaration = AstFactory.methodDeclaration2( 2920 MethodDeclaration declaration = AstTestFactory.methodDeclaration2(
2842 null, 2921 null,
2843 null, 2922 null,
2844 null, 2923 null,
2845 null, 2924 null,
2846 AstFactory.identifier3("m"), 2925 AstTestFactory.identifier3("m"),
2847 AstFactory.formalParameterList(), 2926 AstTestFactory.formalParameterList(),
2848 AstFactory.blockFunctionBody2()); 2927 AstTestFactory.blockFunctionBody2());
2849 declaration.metadata 2928 declaration.metadata.add(
2850 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 2929 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
2851 _assertSource("@deprecated m() {}", declaration); 2930 _assertSource("@deprecated m() {}", declaration);
2852 } 2931 }
2853 2932
2854 void test_visitMethodInvocation_conditional() { 2933 void test_visitMethodInvocation_conditional() {
2855 _assertSource( 2934 _assertSource(
2856 "t?.m()", 2935 "t?.m()",
2857 AstFactory.methodInvocation( 2936 AstTestFactory.methodInvocation(AstTestFactory.identifier3("t"), "m",
2858 AstFactory.identifier3("t"), "m", null, TokenType.QUESTION_PERIOD)); 2937 null, TokenType.QUESTION_PERIOD));
2859 } 2938 }
2860 2939
2861 void test_visitMethodInvocation_noTarget() { 2940 void test_visitMethodInvocation_noTarget() {
2862 _assertSource("m()", AstFactory.methodInvocation2("m")); 2941 _assertSource("m()", AstTestFactory.methodInvocation2("m"));
2863 } 2942 }
2864 2943
2865 void test_visitMethodInvocation_target() { 2944 void test_visitMethodInvocation_target() {
2866 _assertSource( 2945 _assertSource("t.m()",
2867 "t.m()", AstFactory.methodInvocation(AstFactory.identifier3("t"), "m")); 2946 AstTestFactory.methodInvocation(AstTestFactory.identifier3("t"), "m"));
2868 } 2947 }
2869 2948
2870 void test_visitMethodInvocation_typeArguments() { 2949 void test_visitMethodInvocation_typeArguments() {
2871 _assertSource( 2950 _assertSource(
2872 "m<A>()", 2951 "m<A>()",
2873 AstFactory.methodInvocation3(null, "m", 2952 AstTestFactory.methodInvocation3(null, "m",
2874 AstFactory.typeArgumentList([AstFactory.typeName4('A')]))); 2953 AstTestFactory.typeArgumentList([AstTestFactory.typeName4('A')])));
2875 } 2954 }
2876 2955
2877 void test_visitNamedExpression() { 2956 void test_visitNamedExpression() {
2878 _assertSource( 2957 _assertSource("a: b",
2879 "a: b", AstFactory.namedExpression2("a", AstFactory.identifier3("b"))); 2958 AstTestFactory.namedExpression2("a", AstTestFactory.identifier3("b")));
2880 } 2959 }
2881 2960
2882 void test_visitNamedFormalParameter() { 2961 void test_visitNamedFormalParameter() {
2883 _assertSource( 2962 _assertSource(
2884 "var a : 0", 2963 "var a : 0",
2885 AstFactory.namedFormalParameter( 2964 AstTestFactory.namedFormalParameter(
2886 AstFactory.simpleFormalParameter(Keyword.VAR, "a"), 2965 AstTestFactory.simpleFormalParameter(Keyword.VAR, "a"),
2887 AstFactory.integer(0))); 2966 AstTestFactory.integer(0)));
2888 } 2967 }
2889 2968
2890 void test_visitNativeClause() { 2969 void test_visitNativeClause() {
2891 _assertSource("native 'code'", AstFactory.nativeClause("code")); 2970 _assertSource("native 'code'", AstTestFactory.nativeClause("code"));
2892 } 2971 }
2893 2972
2894 void test_visitNativeFunctionBody() { 2973 void test_visitNativeFunctionBody() {
2895 _assertSource("native 'str';", AstFactory.nativeFunctionBody("str")); 2974 _assertSource("native 'str';", AstTestFactory.nativeFunctionBody("str"));
2896 } 2975 }
2897 2976
2898 void test_visitNullLiteral() { 2977 void test_visitNullLiteral() {
2899 _assertSource("null", AstFactory.nullLiteral()); 2978 _assertSource("null", AstTestFactory.nullLiteral());
2900 } 2979 }
2901 2980
2902 void test_visitParenthesizedExpression() { 2981 void test_visitParenthesizedExpression() {
2903 _assertSource( 2982 _assertSource(
2904 "(a)", AstFactory.parenthesizedExpression(AstFactory.identifier3("a"))); 2983 "(a)",
2984 AstTestFactory
2985 .parenthesizedExpression(AstTestFactory.identifier3("a")));
2905 } 2986 }
2906 2987
2907 void test_visitPartDirective() { 2988 void test_visitPartDirective() {
2908 _assertSource("part 'a.dart';", AstFactory.partDirective2("a.dart")); 2989 _assertSource("part 'a.dart';", AstTestFactory.partDirective2("a.dart"));
2909 } 2990 }
2910 2991
2911 void test_visitPartDirective_withMetadata() { 2992 void test_visitPartDirective_withMetadata() {
2912 PartDirective directive = AstFactory.partDirective2("a.dart"); 2993 PartDirective directive = AstTestFactory.partDirective2("a.dart");
2913 directive.metadata 2994 directive.metadata.add(
2914 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 2995 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
2915 _assertSource("@deprecated part 'a.dart';", directive); 2996 _assertSource("@deprecated part 'a.dart';", directive);
2916 } 2997 }
2917 2998
2918 void test_visitPartOfDirective() { 2999 void test_visitPartOfDirective() {
2919 _assertSource("part of l;", 3000 _assertSource(
2920 AstFactory.partOfDirective(AstFactory.libraryIdentifier2(["l"]))); 3001 "part of l;",
3002 AstTestFactory
3003 .partOfDirective(AstTestFactory.libraryIdentifier2(["l"])));
2921 } 3004 }
2922 3005
2923 void test_visitPartOfDirective_withMetadata() { 3006 void test_visitPartOfDirective_withMetadata() {
2924 PartOfDirective directive = 3007 PartOfDirective directive = AstTestFactory
2925 AstFactory.partOfDirective(AstFactory.libraryIdentifier2(["l"])); 3008 .partOfDirective(AstTestFactory.libraryIdentifier2(["l"]));
2926 directive.metadata 3009 directive.metadata.add(
2927 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 3010 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
2928 _assertSource("@deprecated part of l;", directive); 3011 _assertSource("@deprecated part of l;", directive);
2929 } 3012 }
2930 3013
2931 void test_visitPositionalFormalParameter() { 3014 void test_visitPositionalFormalParameter() {
2932 _assertSource( 3015 _assertSource(
2933 "var a = 0", 3016 "var a = 0",
2934 AstFactory.positionalFormalParameter( 3017 AstTestFactory.positionalFormalParameter(
2935 AstFactory.simpleFormalParameter(Keyword.VAR, "a"), 3018 AstTestFactory.simpleFormalParameter(Keyword.VAR, "a"),
2936 AstFactory.integer(0))); 3019 AstTestFactory.integer(0)));
2937 } 3020 }
2938 3021
2939 void test_visitPostfixExpression() { 3022 void test_visitPostfixExpression() {
2940 _assertSource( 3023 _assertSource(
2941 "a++", 3024 "a++",
2942 AstFactory.postfixExpression( 3025 AstTestFactory.postfixExpression(
2943 AstFactory.identifier3("a"), TokenType.PLUS_PLUS)); 3026 AstTestFactory.identifier3("a"), TokenType.PLUS_PLUS));
2944 } 3027 }
2945 3028
2946 void test_visitPrefixedIdentifier() { 3029 void test_visitPrefixedIdentifier() {
2947 _assertSource("a.b", AstFactory.identifier5("a", "b")); 3030 _assertSource("a.b", AstTestFactory.identifier5("a", "b"));
2948 } 3031 }
2949 3032
2950 void test_visitPrefixExpression() { 3033 void test_visitPrefixExpression() {
2951 _assertSource( 3034 _assertSource(
2952 "-a", 3035 "-a",
2953 AstFactory.prefixExpression( 3036 AstTestFactory.prefixExpression(
2954 TokenType.MINUS, AstFactory.identifier3("a"))); 3037 TokenType.MINUS, AstTestFactory.identifier3("a")));
2955 } 3038 }
2956 3039
2957 void test_visitPropertyAccess() { 3040 void test_visitPropertyAccess() {
2958 _assertSource( 3041 _assertSource("a.b",
2959 "a.b", AstFactory.propertyAccess2(AstFactory.identifier3("a"), "b")); 3042 AstTestFactory.propertyAccess2(AstTestFactory.identifier3("a"), "b"));
2960 } 3043 }
2961 3044
2962 void test_visitPropertyAccess_conditional() { 3045 void test_visitPropertyAccess_conditional() {
2963 _assertSource( 3046 _assertSource(
2964 "a?.b", 3047 "a?.b",
2965 AstFactory.propertyAccess2( 3048 AstTestFactory.propertyAccess2(
2966 AstFactory.identifier3("a"), "b", TokenType.QUESTION_PERIOD)); 3049 AstTestFactory.identifier3("a"), "b", TokenType.QUESTION_PERIOD));
2967 } 3050 }
2968 3051
2969 void test_visitRedirectingConstructorInvocation_named() { 3052 void test_visitRedirectingConstructorInvocation_named() {
2970 _assertSource( 3053 _assertSource(
2971 "this.c()", AstFactory.redirectingConstructorInvocation2("c")); 3054 "this.c()", AstTestFactory.redirectingConstructorInvocation2("c"));
2972 } 3055 }
2973 3056
2974 void test_visitRedirectingConstructorInvocation_unnamed() { 3057 void test_visitRedirectingConstructorInvocation_unnamed() {
2975 _assertSource("this()", AstFactory.redirectingConstructorInvocation()); 3058 _assertSource("this()", AstTestFactory.redirectingConstructorInvocation());
2976 } 3059 }
2977 3060
2978 void test_visitRethrowExpression() { 3061 void test_visitRethrowExpression() {
2979 _assertSource("rethrow", AstFactory.rethrowExpression()); 3062 _assertSource("rethrow", AstTestFactory.rethrowExpression());
2980 } 3063 }
2981 3064
2982 void test_visitReturnStatement_expression() { 3065 void test_visitReturnStatement_expression() {
2983 _assertSource( 3066 _assertSource("return a;",
2984 "return a;", AstFactory.returnStatement2(AstFactory.identifier3("a"))); 3067 AstTestFactory.returnStatement2(AstTestFactory.identifier3("a")));
2985 } 3068 }
2986 3069
2987 void test_visitReturnStatement_noExpression() { 3070 void test_visitReturnStatement_noExpression() {
2988 _assertSource("return;", AstFactory.returnStatement()); 3071 _assertSource("return;", AstTestFactory.returnStatement());
2989 } 3072 }
2990 3073
2991 void test_visitScriptTag() { 3074 void test_visitScriptTag() {
2992 String scriptTag = "!#/bin/dart.exe"; 3075 String scriptTag = "!#/bin/dart.exe";
2993 _assertSource(scriptTag, AstFactory.scriptTag(scriptTag)); 3076 _assertSource(scriptTag, AstTestFactory.scriptTag(scriptTag));
2994 } 3077 }
2995 3078
2996 void test_visitSimpleFormalParameter_annotation() { 3079 void test_visitSimpleFormalParameter_annotation() {
2997 SimpleFormalParameter parameter = AstFactory.simpleFormalParameter3('x'); 3080 SimpleFormalParameter parameter =
2998 parameter.metadata.add(AstFactory.annotation(AstFactory.identifier3("A"))); 3081 AstTestFactory.simpleFormalParameter3('x');
3082 parameter.metadata
3083 .add(AstTestFactory.annotation(AstTestFactory.identifier3("A")));
2999 _assertSource('@A x', parameter); 3084 _assertSource('@A x', parameter);
3000 } 3085 }
3001 3086
3002 void test_visitSimpleFormalParameter_keyword() { 3087 void test_visitSimpleFormalParameter_keyword() {
3003 _assertSource("var a", AstFactory.simpleFormalParameter(Keyword.VAR, "a")); 3088 _assertSource(
3089 "var a", AstTestFactory.simpleFormalParameter(Keyword.VAR, "a"));
3004 } 3090 }
3005 3091
3006 void test_visitSimpleFormalParameter_keyword_type() { 3092 void test_visitSimpleFormalParameter_keyword_type() {
3007 _assertSource( 3093 _assertSource(
3008 "final A a", 3094 "final A a",
3009 AstFactory.simpleFormalParameter2( 3095 AstTestFactory.simpleFormalParameter2(
3010 Keyword.FINAL, AstFactory.typeName4("A"), "a")); 3096 Keyword.FINAL, AstTestFactory.typeName4("A"), "a"));
3011 } 3097 }
3012 3098
3013 void test_visitSimpleFormalParameter_type() { 3099 void test_visitSimpleFormalParameter_type() {
3014 _assertSource("A a", 3100 _assertSource(
3015 AstFactory.simpleFormalParameter4(AstFactory.typeName4("A"), "a")); 3101 "A a",
3102 AstTestFactory.simpleFormalParameter4(
3103 AstTestFactory.typeName4("A"), "a"));
3016 } 3104 }
3017 3105
3018 void test_visitSimpleIdentifier() { 3106 void test_visitSimpleIdentifier() {
3019 _assertSource("a", AstFactory.identifier3("a")); 3107 _assertSource("a", AstTestFactory.identifier3("a"));
3020 } 3108 }
3021 3109
3022 void test_visitSimpleStringLiteral() { 3110 void test_visitSimpleStringLiteral() {
3023 _assertSource("'a'", AstFactory.string2("a")); 3111 _assertSource("'a'", AstTestFactory.string2("a"));
3024 } 3112 }
3025 3113
3026 void test_visitStringInterpolation() { 3114 void test_visitStringInterpolation() {
3027 _assertSource( 3115 _assertSource(
3028 "'a\${e}b'", 3116 "'a\${e}b'",
3029 AstFactory.string([ 3117 AstTestFactory.string([
3030 AstFactory.interpolationString("'a", "a"), 3118 AstTestFactory.interpolationString("'a", "a"),
3031 AstFactory.interpolationExpression(AstFactory.identifier3("e")), 3119 AstTestFactory
3032 AstFactory.interpolationString("b'", "b") 3120 .interpolationExpression(AstTestFactory.identifier3("e")),
3121 AstTestFactory.interpolationString("b'", "b")
3033 ])); 3122 ]));
3034 } 3123 }
3035 3124
3036 void test_visitSuperConstructorInvocation() { 3125 void test_visitSuperConstructorInvocation() {
3037 _assertSource("super()", AstFactory.superConstructorInvocation()); 3126 _assertSource("super()", AstTestFactory.superConstructorInvocation());
3038 } 3127 }
3039 3128
3040 void test_visitSuperConstructorInvocation_named() { 3129 void test_visitSuperConstructorInvocation_named() {
3041 _assertSource("super.c()", AstFactory.superConstructorInvocation2("c")); 3130 _assertSource("super.c()", AstTestFactory.superConstructorInvocation2("c"));
3042 } 3131 }
3043 3132
3044 void test_visitSuperExpression() { 3133 void test_visitSuperExpression() {
3045 _assertSource("super", AstFactory.superExpression()); 3134 _assertSource("super", AstTestFactory.superExpression());
3046 } 3135 }
3047 3136
3048 void test_visitSwitchCase_multipleLabels() { 3137 void test_visitSwitchCase_multipleLabels() {
3049 _assertSource( 3138 _assertSource(
3050 "l1: l2: case a: {}", 3139 "l1: l2: case a: {}",
3051 AstFactory.switchCase2( 3140 AstTestFactory.switchCase2(
3052 [AstFactory.label2("l1"), AstFactory.label2("l2")], 3141 [AstTestFactory.label2("l1"), AstTestFactory.label2("l2")],
3053 AstFactory.identifier3("a"), 3142 AstTestFactory.identifier3("a"),
3054 [AstFactory.block()])); 3143 [AstTestFactory.block()]));
3055 } 3144 }
3056 3145
3057 void test_visitSwitchCase_multipleStatements() { 3146 void test_visitSwitchCase_multipleStatements() {
3058 _assertSource( 3147 _assertSource(
3059 "case a: {} {}", 3148 "case a: {} {}",
3060 AstFactory.switchCase(AstFactory.identifier3("a"), 3149 AstTestFactory.switchCase(AstTestFactory.identifier3("a"),
3061 [AstFactory.block(), AstFactory.block()])); 3150 [AstTestFactory.block(), AstTestFactory.block()]));
3062 } 3151 }
3063 3152
3064 void test_visitSwitchCase_noLabels() { 3153 void test_visitSwitchCase_noLabels() {
3065 _assertSource( 3154 _assertSource(
3066 "case a: {}", 3155 "case a: {}",
3067 AstFactory 3156 AstTestFactory.switchCase(
3068 .switchCase(AstFactory.identifier3("a"), [AstFactory.block()])); 3157 AstTestFactory.identifier3("a"), [AstTestFactory.block()]));
3069 } 3158 }
3070 3159
3071 void test_visitSwitchCase_singleLabel() { 3160 void test_visitSwitchCase_singleLabel() {
3072 _assertSource( 3161 _assertSource(
3073 "l1: case a: {}", 3162 "l1: case a: {}",
3074 AstFactory.switchCase2([AstFactory.label2("l1")], 3163 AstTestFactory.switchCase2([AstTestFactory.label2("l1")],
3075 AstFactory.identifier3("a"), [AstFactory.block()])); 3164 AstTestFactory.identifier3("a"), [AstTestFactory.block()]));
3076 } 3165 }
3077 3166
3078 void test_visitSwitchDefault_multipleLabels() { 3167 void test_visitSwitchDefault_multipleLabels() {
3079 _assertSource( 3168 _assertSource(
3080 "l1: l2: default: {}", 3169 "l1: l2: default: {}",
3081 AstFactory.switchDefault( 3170 AstTestFactory.switchDefault(
3082 [AstFactory.label2("l1"), AstFactory.label2("l2")], 3171 [AstTestFactory.label2("l1"), AstTestFactory.label2("l2")],
3083 [AstFactory.block()])); 3172 [AstTestFactory.block()]));
3084 } 3173 }
3085 3174
3086 void test_visitSwitchDefault_multipleStatements() { 3175 void test_visitSwitchDefault_multipleStatements() {
3087 _assertSource("default: {} {}", 3176 _assertSource(
3088 AstFactory.switchDefault2([AstFactory.block(), AstFactory.block()])); 3177 "default: {} {}",
3178 AstTestFactory
3179 .switchDefault2([AstTestFactory.block(), AstTestFactory.block()]));
3089 } 3180 }
3090 3181
3091 void test_visitSwitchDefault_noLabels() { 3182 void test_visitSwitchDefault_noLabels() {
3092 _assertSource( 3183 _assertSource(
3093 "default: {}", AstFactory.switchDefault2([AstFactory.block()])); 3184 "default: {}", AstTestFactory.switchDefault2([AstTestFactory.block()]));
3094 } 3185 }
3095 3186
3096 void test_visitSwitchDefault_singleLabel() { 3187 void test_visitSwitchDefault_singleLabel() {
3097 _assertSource( 3188 _assertSource(
3098 "l1: default: {}", 3189 "l1: default: {}",
3099 AstFactory 3190 AstTestFactory.switchDefault(
3100 .switchDefault([AstFactory.label2("l1")], [AstFactory.block()])); 3191 [AstTestFactory.label2("l1")], [AstTestFactory.block()]));
3101 } 3192 }
3102 3193
3103 void test_visitSwitchStatement() { 3194 void test_visitSwitchStatement() {
3104 _assertSource( 3195 _assertSource(
3105 "switch (a) {case 'b': {} default: {}}", 3196 "switch (a) {case 'b': {} default: {}}",
3106 AstFactory.switchStatement(AstFactory.identifier3("a"), [ 3197 AstTestFactory.switchStatement(AstTestFactory.identifier3("a"), [
3107 AstFactory.switchCase(AstFactory.string2("b"), [AstFactory.block()]), 3198 AstTestFactory.switchCase(
3108 AstFactory.switchDefault2([AstFactory.block()]) 3199 AstTestFactory.string2("b"), [AstTestFactory.block()]),
3200 AstTestFactory.switchDefault2([AstTestFactory.block()])
3109 ])); 3201 ]));
3110 } 3202 }
3111 3203
3112 void test_visitSymbolLiteral_multiple() { 3204 void test_visitSymbolLiteral_multiple() {
3113 _assertSource("#a.b.c", AstFactory.symbolLiteral(["a", "b", "c"])); 3205 _assertSource("#a.b.c", AstTestFactory.symbolLiteral(["a", "b", "c"]));
3114 } 3206 }
3115 3207
3116 void test_visitSymbolLiteral_single() { 3208 void test_visitSymbolLiteral_single() {
3117 _assertSource("#a", AstFactory.symbolLiteral(["a"])); 3209 _assertSource("#a", AstTestFactory.symbolLiteral(["a"]));
3118 } 3210 }
3119 3211
3120 void test_visitThisExpression() { 3212 void test_visitThisExpression() {
3121 _assertSource("this", AstFactory.thisExpression()); 3213 _assertSource("this", AstTestFactory.thisExpression());
3122 } 3214 }
3123 3215
3124 void test_visitThrowStatement() { 3216 void test_visitThrowStatement() {
3125 _assertSource( 3217 _assertSource("throw e",
3126 "throw e", AstFactory.throwExpression2(AstFactory.identifier3("e"))); 3218 AstTestFactory.throwExpression2(AstTestFactory.identifier3("e")));
3127 } 3219 }
3128 3220
3129 void test_visitTopLevelVariableDeclaration_multiple() { 3221 void test_visitTopLevelVariableDeclaration_multiple() {
3130 _assertSource( 3222 _assertSource(
3131 "var a;", 3223 "var a;",
3132 AstFactory.topLevelVariableDeclaration2( 3224 AstTestFactory.topLevelVariableDeclaration2(
3133 Keyword.VAR, [AstFactory.variableDeclaration("a")])); 3225 Keyword.VAR, [AstTestFactory.variableDeclaration("a")]));
3134 } 3226 }
3135 3227
3136 void test_visitTopLevelVariableDeclaration_single() { 3228 void test_visitTopLevelVariableDeclaration_single() {
3137 _assertSource( 3229 _assertSource(
3138 "var a, b;", 3230 "var a, b;",
3139 AstFactory.topLevelVariableDeclaration2(Keyword.VAR, [ 3231 AstTestFactory.topLevelVariableDeclaration2(Keyword.VAR, [
3140 AstFactory.variableDeclaration("a"), 3232 AstTestFactory.variableDeclaration("a"),
3141 AstFactory.variableDeclaration("b") 3233 AstTestFactory.variableDeclaration("b")
3142 ])); 3234 ]));
3143 } 3235 }
3144 3236
3145 void test_visitTryStatement_catch() { 3237 void test_visitTryStatement_catch() {
3146 _assertSource( 3238 _assertSource(
3147 "try {} on E {}", 3239 "try {} on E {}",
3148 AstFactory.tryStatement2(AstFactory.block(), 3240 AstTestFactory.tryStatement2(AstTestFactory.block(),
3149 [AstFactory.catchClause3(AstFactory.typeName4("E"))])); 3241 [AstTestFactory.catchClause3(AstTestFactory.typeName4("E"))]));
3150 } 3242 }
3151 3243
3152 void test_visitTryStatement_catches() { 3244 void test_visitTryStatement_catches() {
3153 _assertSource( 3245 _assertSource(
3154 "try {} on E {} on F {}", 3246 "try {} on E {} on F {}",
3155 AstFactory.tryStatement2(AstFactory.block(), [ 3247 AstTestFactory.tryStatement2(AstTestFactory.block(), [
3156 AstFactory.catchClause3(AstFactory.typeName4("E")), 3248 AstTestFactory.catchClause3(AstTestFactory.typeName4("E")),
3157 AstFactory.catchClause3(AstFactory.typeName4("F")) 3249 AstTestFactory.catchClause3(AstTestFactory.typeName4("F"))
3158 ])); 3250 ]));
3159 } 3251 }
3160 3252
3161 void test_visitTryStatement_catchFinally() { 3253 void test_visitTryStatement_catchFinally() {
3162 _assertSource( 3254 _assertSource(
3163 "try {} on E {} finally {}", 3255 "try {} on E {} finally {}",
3164 AstFactory.tryStatement3( 3256 AstTestFactory.tryStatement3(
3165 AstFactory.block(), 3257 AstTestFactory.block(),
3166 [AstFactory.catchClause3(AstFactory.typeName4("E"))], 3258 [AstTestFactory.catchClause3(AstTestFactory.typeName4("E"))],
3167 AstFactory.block())); 3259 AstTestFactory.block()));
3168 } 3260 }
3169 3261
3170 void test_visitTryStatement_finally() { 3262 void test_visitTryStatement_finally() {
3171 _assertSource("try {} finally {}", 3263 _assertSource(
3172 AstFactory.tryStatement(AstFactory.block(), AstFactory.block())); 3264 "try {} finally {}",
3265 AstTestFactory.tryStatement(
3266 AstTestFactory.block(), AstTestFactory.block()));
3173 } 3267 }
3174 3268
3175 void test_visitTypeArgumentList_multiple() { 3269 void test_visitTypeArgumentList_multiple() {
3176 _assertSource( 3270 _assertSource(
3177 "<E, F>", 3271 "<E, F>",
3178 AstFactory.typeArgumentList( 3272 AstTestFactory.typeArgumentList(
3179 [AstFactory.typeName4("E"), AstFactory.typeName4("F")])); 3273 [AstTestFactory.typeName4("E"), AstTestFactory.typeName4("F")]));
3180 } 3274 }
3181 3275
3182 void test_visitTypeArgumentList_single() { 3276 void test_visitTypeArgumentList_single() {
3183 _assertSource( 3277 _assertSource("<E>",
3184 "<E>", AstFactory.typeArgumentList([AstFactory.typeName4("E")])); 3278 AstTestFactory.typeArgumentList([AstTestFactory.typeName4("E")]));
3185 } 3279 }
3186 3280
3187 void test_visitTypeName_multipleArgs() { 3281 void test_visitTypeName_multipleArgs() {
3188 _assertSource( 3282 _assertSource(
3189 "C<D, E>", 3283 "C<D, E>",
3190 AstFactory.typeName4( 3284 AstTestFactory.typeName4("C",
3191 "C", [AstFactory.typeName4("D"), AstFactory.typeName4("E")])); 3285 [AstTestFactory.typeName4("D"), AstTestFactory.typeName4("E")]));
3192 } 3286 }
3193 3287
3194 void test_visitTypeName_nestedArg() { 3288 void test_visitTypeName_nestedArg() {
3195 _assertSource( 3289 _assertSource(
3196 "C<D<E>>", 3290 "C<D<E>>",
3197 AstFactory.typeName4("C", [ 3291 AstTestFactory.typeName4("C", [
3198 AstFactory.typeName4("D", [AstFactory.typeName4("E")]) 3292 AstTestFactory.typeName4("D", [AstTestFactory.typeName4("E")])
3199 ])); 3293 ]));
3200 } 3294 }
3201 3295
3202 void test_visitTypeName_noArgs() { 3296 void test_visitTypeName_noArgs() {
3203 _assertSource("C", AstFactory.typeName4("C")); 3297 _assertSource("C", AstTestFactory.typeName4("C"));
3204 } 3298 }
3205 3299
3206 void test_visitTypeName_singleArg() { 3300 void test_visitTypeName_singleArg() {
3207 _assertSource( 3301 _assertSource(
3208 "C<D>", AstFactory.typeName4("C", [AstFactory.typeName4("D")])); 3302 "C<D>", AstTestFactory.typeName4("C", [AstTestFactory.typeName4("D")]));
3209 } 3303 }
3210 3304
3211 void test_visitTypeParameter_withExtends() { 3305 void test_visitTypeParameter_withExtends() {
3212 _assertSource("E extends C", 3306 _assertSource("E extends C",
3213 AstFactory.typeParameter2("E", AstFactory.typeName4("C"))); 3307 AstTestFactory.typeParameter2("E", AstTestFactory.typeName4("C")));
3214 } 3308 }
3215 3309
3216 void test_visitTypeParameter_withMetadata() { 3310 void test_visitTypeParameter_withMetadata() {
3217 TypeParameter parameter = AstFactory.typeParameter("E"); 3311 TypeParameter parameter = AstTestFactory.typeParameter("E");
3218 parameter.metadata 3312 parameter.metadata.add(
3219 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 3313 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
3220 _assertSource("@deprecated E", parameter); 3314 _assertSource("@deprecated E", parameter);
3221 } 3315 }
3222 3316
3223 void test_visitTypeParameter_withoutExtends() { 3317 void test_visitTypeParameter_withoutExtends() {
3224 _assertSource("E", AstFactory.typeParameter("E")); 3318 _assertSource("E", AstTestFactory.typeParameter("E"));
3225 } 3319 }
3226 3320
3227 void test_visitTypeParameterList_multiple() { 3321 void test_visitTypeParameterList_multiple() {
3228 _assertSource("<E, F>", AstFactory.typeParameterList(["E", "F"])); 3322 _assertSource("<E, F>", AstTestFactory.typeParameterList(["E", "F"]));
3229 } 3323 }
3230 3324
3231 void test_visitTypeParameterList_single() { 3325 void test_visitTypeParameterList_single() {
3232 _assertSource("<E>", AstFactory.typeParameterList(["E"])); 3326 _assertSource("<E>", AstTestFactory.typeParameterList(["E"]));
3233 } 3327 }
3234 3328
3235 void test_visitVariableDeclaration_initialized() { 3329 void test_visitVariableDeclaration_initialized() {
3236 _assertSource("a = b", 3330 _assertSource(
3237 AstFactory.variableDeclaration2("a", AstFactory.identifier3("b"))); 3331 "a = b",
3332 AstTestFactory.variableDeclaration2(
3333 "a", AstTestFactory.identifier3("b")));
3238 } 3334 }
3239 3335
3240 void test_visitVariableDeclaration_uninitialized() { 3336 void test_visitVariableDeclaration_uninitialized() {
3241 _assertSource("a", AstFactory.variableDeclaration("a")); 3337 _assertSource("a", AstTestFactory.variableDeclaration("a"));
3242 } 3338 }
3243 3339
3244 void test_visitVariableDeclaration_withMetadata() { 3340 void test_visitVariableDeclaration_withMetadata() {
3245 VariableDeclaration declaration = AstFactory.variableDeclaration("a"); 3341 VariableDeclaration declaration = AstTestFactory.variableDeclaration("a");
3246 declaration.metadata 3342 declaration.metadata.add(
3247 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 3343 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
3248 _assertSource("@deprecated a", declaration); 3344 _assertSource("@deprecated a", declaration);
3249 } 3345 }
3250 3346
3251 void test_visitVariableDeclarationList_const_type() { 3347 void test_visitVariableDeclarationList_const_type() {
3252 _assertSource( 3348 _assertSource(
3253 "const C a, b", 3349 "const C a, b",
3254 AstFactory.variableDeclarationList( 3350 AstTestFactory.variableDeclarationList(
3255 Keyword.CONST, AstFactory.typeName4("C"), [ 3351 Keyword.CONST, AstTestFactory.typeName4("C"), [
3256 AstFactory.variableDeclaration("a"), 3352 AstTestFactory.variableDeclaration("a"),
3257 AstFactory.variableDeclaration("b") 3353 AstTestFactory.variableDeclaration("b")
3258 ])); 3354 ]));
3259 } 3355 }
3260 3356
3261 void test_visitVariableDeclarationList_final_noType() { 3357 void test_visitVariableDeclarationList_final_noType() {
3262 _assertSource( 3358 _assertSource(
3263 "final a, b", 3359 "final a, b",
3264 AstFactory.variableDeclarationList2(Keyword.FINAL, [ 3360 AstTestFactory.variableDeclarationList2(Keyword.FINAL, [
3265 AstFactory.variableDeclaration("a"), 3361 AstTestFactory.variableDeclaration("a"),
3266 AstFactory.variableDeclaration("b") 3362 AstTestFactory.variableDeclaration("b")
3267 ])); 3363 ]));
3268 } 3364 }
3269 3365
3270 void test_visitVariableDeclarationList_final_withMetadata() { 3366 void test_visitVariableDeclarationList_final_withMetadata() {
3271 VariableDeclarationList declarationList = AstFactory 3367 VariableDeclarationList declarationList = AstTestFactory
3272 .variableDeclarationList2(Keyword.FINAL, [ 3368 .variableDeclarationList2(Keyword.FINAL, [
3273 AstFactory.variableDeclaration("a"), 3369 AstTestFactory.variableDeclaration("a"),
3274 AstFactory.variableDeclaration("b") 3370 AstTestFactory.variableDeclaration("b")
3275 ]); 3371 ]);
3276 declarationList.metadata 3372 declarationList.metadata.add(
3277 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 3373 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
3278 _assertSource("@deprecated final a, b", declarationList); 3374 _assertSource("@deprecated final a, b", declarationList);
3279 } 3375 }
3280 3376
3281 void test_visitVariableDeclarationList_type() { 3377 void test_visitVariableDeclarationList_type() {
3282 _assertSource( 3378 _assertSource(
3283 "C a, b", 3379 "C a, b",
3284 AstFactory.variableDeclarationList(null, AstFactory.typeName4("C"), [ 3380 AstTestFactory.variableDeclarationList(
3285 AstFactory.variableDeclaration("a"), 3381 null, AstTestFactory.typeName4("C"), [
3286 AstFactory.variableDeclaration("b") 3382 AstTestFactory.variableDeclaration("a"),
3383 AstTestFactory.variableDeclaration("b")
3287 ])); 3384 ]));
3288 } 3385 }
3289 3386
3290 void test_visitVariableDeclarationList_var() { 3387 void test_visitVariableDeclarationList_var() {
3291 _assertSource( 3388 _assertSource(
3292 "var a, b", 3389 "var a, b",
3293 AstFactory.variableDeclarationList2(Keyword.VAR, [ 3390 AstTestFactory.variableDeclarationList2(Keyword.VAR, [
3294 AstFactory.variableDeclaration("a"), 3391 AstTestFactory.variableDeclaration("a"),
3295 AstFactory.variableDeclaration("b") 3392 AstTestFactory.variableDeclaration("b")
3296 ])); 3393 ]));
3297 } 3394 }
3298 3395
3299 void test_visitVariableDeclarationStatement() { 3396 void test_visitVariableDeclarationStatement() {
3300 _assertSource( 3397 _assertSource(
3301 "C c;", 3398 "C c;",
3302 AstFactory.variableDeclarationStatement(null, AstFactory.typeName4("C"), 3399 AstTestFactory.variableDeclarationStatement(
3303 [AstFactory.variableDeclaration("c")])); 3400 null,
3401 AstTestFactory.typeName4("C"),
3402 [AstTestFactory.variableDeclaration("c")]));
3304 } 3403 }
3305 3404
3306 void test_visitWhileStatement() { 3405 void test_visitWhileStatement() {
3307 _assertSource( 3406 _assertSource(
3308 "while (c) {}", 3407 "while (c) {}",
3309 AstFactory.whileStatement( 3408 AstTestFactory.whileStatement(
3310 AstFactory.identifier3("c"), AstFactory.block())); 3409 AstTestFactory.identifier3("c"), AstTestFactory.block()));
3311 } 3410 }
3312 3411
3313 void test_visitWithClause_multiple() { 3412 void test_visitWithClause_multiple() {
3314 _assertSource( 3413 _assertSource(
3315 "with A, B, C", 3414 "with A, B, C",
3316 AstFactory.withClause([ 3415 AstTestFactory.withClause([
3317 AstFactory.typeName4("A"), 3416 AstTestFactory.typeName4("A"),
3318 AstFactory.typeName4("B"), 3417 AstTestFactory.typeName4("B"),
3319 AstFactory.typeName4("C") 3418 AstTestFactory.typeName4("C")
3320 ])); 3419 ]));
3321 } 3420 }
3322 3421
3323 void test_visitWithClause_single() { 3422 void test_visitWithClause_single() {
3324 _assertSource("with A", AstFactory.withClause([AstFactory.typeName4("A")])); 3423 _assertSource(
3424 "with A", AstTestFactory.withClause([AstTestFactory.typeName4("A")]));
3325 } 3425 }
3326 3426
3327 void test_visitYieldStatement() { 3427 void test_visitYieldStatement() {
3328 _assertSource( 3428 _assertSource("yield e;",
3329 "yield e;", AstFactory.yieldStatement(AstFactory.identifier3("e"))); 3429 AstTestFactory.yieldStatement(AstTestFactory.identifier3("e")));
3330 } 3430 }
3331 3431
3332 void test_visitYieldStatement_each() { 3432 void test_visitYieldStatement_each() {
3333 _assertSource("yield* e;", 3433 _assertSource("yield* e;",
3334 AstFactory.yieldEachStatement(AstFactory.identifier3("e"))); 3434 AstTestFactory.yieldEachStatement(AstTestFactory.identifier3("e")));
3335 } 3435 }
3336 3436
3337 /** 3437 /**
3338 * Assert that a `ToSourceVisitor2` will produce the [expectedSource] when 3438 * Assert that a `ToSourceVisitor2` will produce the [expectedSource] when
3339 * visiting the given [node]. 3439 * visiting the given [node].
3340 */ 3440 */
3341 void _assertSource(String expectedSource, AstNode node) { 3441 void _assertSource(String expectedSource, AstNode node) {
3342 StringBuffer buffer = new StringBuffer(); 3442 StringBuffer buffer = new StringBuffer();
3343 node.accept(new ToSourceVisitor2(buffer)); 3443 node.accept(new ToSourceVisitor2(buffer));
3344 expect(buffer.toString(), expectedSource); 3444 expect(buffer.toString(), expectedSource);
3345 } 3445 }
3346 } 3446 }
3347 3447
3348 @deprecated 3448 @deprecated
3349 @reflectiveTest 3449 @reflectiveTest
3350 class ToSourceVisitorTest extends EngineTestCase { 3450 class ToSourceVisitorTest extends EngineTestCase {
3351 void test_visitAdjacentStrings() { 3451 void test_visitAdjacentStrings() {
3352 _assertSource( 3452 _assertSource(
3353 "'a' 'b'", 3453 "'a' 'b'",
3354 AstFactory.adjacentStrings( 3454 AstTestFactory.adjacentStrings(
3355 [AstFactory.string2("a"), AstFactory.string2("b")])); 3455 [AstTestFactory.string2("a"), AstTestFactory.string2("b")]));
3356 } 3456 }
3357 3457
3358 void test_visitAnnotation_constant() { 3458 void test_visitAnnotation_constant() {
3359 _assertSource("@A", AstFactory.annotation(AstFactory.identifier3("A"))); 3459 _assertSource(
3460 "@A", AstTestFactory.annotation(AstTestFactory.identifier3("A")));
3360 } 3461 }
3361 3462
3362 void test_visitAnnotation_constructor() { 3463 void test_visitAnnotation_constructor() {
3363 _assertSource( 3464 _assertSource(
3364 "@A.c()", 3465 "@A.c()",
3365 AstFactory.annotation2(AstFactory.identifier3("A"), 3466 AstTestFactory.annotation2(AstTestFactory.identifier3("A"),
3366 AstFactory.identifier3("c"), AstFactory.argumentList())); 3467 AstTestFactory.identifier3("c"), AstTestFactory.argumentList()));
3367 } 3468 }
3368 3469
3369 void test_visitArgumentList() { 3470 void test_visitArgumentList() {
3370 _assertSource( 3471 _assertSource(
3371 "(a, b)", 3472 "(a, b)",
3372 AstFactory.argumentList( 3473 AstTestFactory.argumentList([
3373 [AstFactory.identifier3("a"), AstFactory.identifier3("b")])); 3474 AstTestFactory.identifier3("a"),
3475 AstTestFactory.identifier3("b")
3476 ]));
3374 } 3477 }
3375 3478
3376 void test_visitAsExpression() { 3479 void test_visitAsExpression() {
3377 _assertSource( 3480 _assertSource(
3378 "e as T", 3481 "e as T",
3379 AstFactory.asExpression( 3482 AstTestFactory.asExpression(
3380 AstFactory.identifier3("e"), AstFactory.typeName4("T"))); 3483 AstTestFactory.identifier3("e"), AstTestFactory.typeName4("T")));
3381 } 3484 }
3382 3485
3383 void test_visitAssertStatement() { 3486 void test_visitAssertStatement() {
3384 _assertSource( 3487 _assertSource("assert (a);",
3385 "assert (a);", AstFactory.assertStatement(AstFactory.identifier3("a"))); 3488 AstTestFactory.assertStatement(AstTestFactory.identifier3("a")));
3386 } 3489 }
3387 3490
3388 void test_visitAssertStatement_withMessage() { 3491 void test_visitAssertStatement_withMessage() {
3389 _assertSource( 3492 _assertSource(
3390 "assert (a, b);", 3493 "assert (a, b);",
3391 AstFactory.assertStatement( 3494 AstTestFactory.assertStatement(
3392 AstFactory.identifier3("a"), AstFactory.identifier3('b'))); 3495 AstTestFactory.identifier3("a"), AstTestFactory.identifier3('b')));
3393 } 3496 }
3394 3497
3395 void test_visitAssignmentExpression() { 3498 void test_visitAssignmentExpression() {
3396 _assertSource( 3499 _assertSource(
3397 "a = b", 3500 "a = b",
3398 AstFactory.assignmentExpression(AstFactory.identifier3("a"), 3501 AstTestFactory.assignmentExpression(AstTestFactory.identifier3("a"),
3399 TokenType.EQ, AstFactory.identifier3("b"))); 3502 TokenType.EQ, AstTestFactory.identifier3("b")));
3400 } 3503 }
3401 3504
3402 void test_visitAwaitExpression() { 3505 void test_visitAwaitExpression() {
3403 _assertSource( 3506 _assertSource("await e",
3404 "await e", AstFactory.awaitExpression(AstFactory.identifier3("e"))); 3507 AstTestFactory.awaitExpression(AstTestFactory.identifier3("e")));
3405 } 3508 }
3406 3509
3407 void test_visitBinaryExpression() { 3510 void test_visitBinaryExpression() {
3408 _assertSource( 3511 _assertSource(
3409 "a + b", 3512 "a + b",
3410 AstFactory.binaryExpression(AstFactory.identifier3("a"), TokenType.PLUS, 3513 AstTestFactory.binaryExpression(AstTestFactory.identifier3("a"),
3411 AstFactory.identifier3("b"))); 3514 TokenType.PLUS, AstTestFactory.identifier3("b")));
3412 } 3515 }
3413 3516
3414 void test_visitBlock_empty() { 3517 void test_visitBlock_empty() {
3415 _assertSource("{}", AstFactory.block()); 3518 _assertSource("{}", AstTestFactory.block());
3416 } 3519 }
3417 3520
3418 void test_visitBlock_nonEmpty() { 3521 void test_visitBlock_nonEmpty() {
3419 _assertSource( 3522 _assertSource(
3420 "{break; break;}", 3523 "{break; break;}",
3421 AstFactory 3524 AstTestFactory.block([
3422 .block([AstFactory.breakStatement(), AstFactory.breakStatement()])); 3525 AstTestFactory.breakStatement(),
3526 AstTestFactory.breakStatement()
3527 ]));
3423 } 3528 }
3424 3529
3425 void test_visitBlockFunctionBody_async() { 3530 void test_visitBlockFunctionBody_async() {
3426 _assertSource("async {}", AstFactory.asyncBlockFunctionBody()); 3531 _assertSource("async {}", AstTestFactory.asyncBlockFunctionBody());
3427 } 3532 }
3428 3533
3429 void test_visitBlockFunctionBody_async_star() { 3534 void test_visitBlockFunctionBody_async_star() {
3430 _assertSource("async* {}", AstFactory.asyncGeneratorBlockFunctionBody()); 3535 _assertSource(
3536 "async* {}", AstTestFactory.asyncGeneratorBlockFunctionBody());
3431 } 3537 }
3432 3538
3433 void test_visitBlockFunctionBody_simple() { 3539 void test_visitBlockFunctionBody_simple() {
3434 _assertSource("{}", AstFactory.blockFunctionBody2()); 3540 _assertSource("{}", AstTestFactory.blockFunctionBody2());
3435 } 3541 }
3436 3542
3437 void test_visitBlockFunctionBody_sync() { 3543 void test_visitBlockFunctionBody_sync() {
3438 _assertSource("sync {}", AstFactory.syncBlockFunctionBody()); 3544 _assertSource("sync {}", AstTestFactory.syncBlockFunctionBody());
3439 } 3545 }
3440 3546
3441 void test_visitBlockFunctionBody_sync_star() { 3547 void test_visitBlockFunctionBody_sync_star() {
3442 _assertSource("sync* {}", AstFactory.syncGeneratorBlockFunctionBody()); 3548 _assertSource("sync* {}", AstTestFactory.syncGeneratorBlockFunctionBody());
3443 } 3549 }
3444 3550
3445 void test_visitBooleanLiteral_false() { 3551 void test_visitBooleanLiteral_false() {
3446 _assertSource("false", AstFactory.booleanLiteral(false)); 3552 _assertSource("false", AstTestFactory.booleanLiteral(false));
3447 } 3553 }
3448 3554
3449 void test_visitBooleanLiteral_true() { 3555 void test_visitBooleanLiteral_true() {
3450 _assertSource("true", AstFactory.booleanLiteral(true)); 3556 _assertSource("true", AstTestFactory.booleanLiteral(true));
3451 } 3557 }
3452 3558
3453 void test_visitBreakStatement_label() { 3559 void test_visitBreakStatement_label() {
3454 _assertSource("break l;", AstFactory.breakStatement2("l")); 3560 _assertSource("break l;", AstTestFactory.breakStatement2("l"));
3455 } 3561 }
3456 3562
3457 void test_visitBreakStatement_noLabel() { 3563 void test_visitBreakStatement_noLabel() {
3458 _assertSource("break;", AstFactory.breakStatement()); 3564 _assertSource("break;", AstTestFactory.breakStatement());
3459 } 3565 }
3460 3566
3461 void test_visitCascadeExpression_field() { 3567 void test_visitCascadeExpression_field() {
3462 _assertSource( 3568 _assertSource(
3463 "a..b..c", 3569 "a..b..c",
3464 AstFactory.cascadeExpression(AstFactory.identifier3("a"), [ 3570 AstTestFactory.cascadeExpression(AstTestFactory.identifier3("a"), [
3465 AstFactory.cascadedPropertyAccess("b"), 3571 AstTestFactory.cascadedPropertyAccess("b"),
3466 AstFactory.cascadedPropertyAccess("c") 3572 AstTestFactory.cascadedPropertyAccess("c")
3467 ])); 3573 ]));
3468 } 3574 }
3469 3575
3470 void test_visitCascadeExpression_index() { 3576 void test_visitCascadeExpression_index() {
3471 _assertSource( 3577 _assertSource(
3472 "a..[0]..[1]", 3578 "a..[0]..[1]",
3473 AstFactory.cascadeExpression(AstFactory.identifier3("a"), [ 3579 AstTestFactory.cascadeExpression(AstTestFactory.identifier3("a"), [
3474 AstFactory.cascadedIndexExpression(AstFactory.integer(0)), 3580 AstTestFactory.cascadedIndexExpression(AstTestFactory.integer(0)),
3475 AstFactory.cascadedIndexExpression(AstFactory.integer(1)) 3581 AstTestFactory.cascadedIndexExpression(AstTestFactory.integer(1))
3476 ])); 3582 ]));
3477 } 3583 }
3478 3584
3479 void test_visitCascadeExpression_method() { 3585 void test_visitCascadeExpression_method() {
3480 _assertSource( 3586 _assertSource(
3481 "a..b()..c()", 3587 "a..b()..c()",
3482 AstFactory.cascadeExpression(AstFactory.identifier3("a"), [ 3588 AstTestFactory.cascadeExpression(AstTestFactory.identifier3("a"), [
3483 AstFactory.cascadedMethodInvocation("b"), 3589 AstTestFactory.cascadedMethodInvocation("b"),
3484 AstFactory.cascadedMethodInvocation("c") 3590 AstTestFactory.cascadedMethodInvocation("c")
3485 ])); 3591 ]));
3486 } 3592 }
3487 3593
3488 void test_visitCatchClause_catch_noStack() { 3594 void test_visitCatchClause_catch_noStack() {
3489 _assertSource("catch (e) {}", AstFactory.catchClause("e")); 3595 _assertSource("catch (e) {}", AstTestFactory.catchClause("e"));
3490 } 3596 }
3491 3597
3492 void test_visitCatchClause_catch_stack() { 3598 void test_visitCatchClause_catch_stack() {
3493 _assertSource("catch (e, s) {}", AstFactory.catchClause2("e", "s")); 3599 _assertSource("catch (e, s) {}", AstTestFactory.catchClause2("e", "s"));
3494 } 3600 }
3495 3601
3496 void test_visitCatchClause_on() { 3602 void test_visitCatchClause_on() {
3497 _assertSource( 3603 _assertSource(
3498 "on E {}", AstFactory.catchClause3(AstFactory.typeName4("E"))); 3604 "on E {}", AstTestFactory.catchClause3(AstTestFactory.typeName4("E")));
3499 } 3605 }
3500 3606
3501 void test_visitCatchClause_on_catch() { 3607 void test_visitCatchClause_on_catch() {
3502 _assertSource("on E catch (e) {}", 3608 _assertSource("on E catch (e) {}",
3503 AstFactory.catchClause4(AstFactory.typeName4("E"), "e")); 3609 AstTestFactory.catchClause4(AstTestFactory.typeName4("E"), "e"));
3504 } 3610 }
3505 3611
3506 void test_visitClassDeclaration_abstract() { 3612 void test_visitClassDeclaration_abstract() {
3507 _assertSource( 3613 _assertSource(
3508 "abstract class C {}", 3614 "abstract class C {}",
3509 AstFactory.classDeclaration( 3615 AstTestFactory.classDeclaration(
3510 Keyword.ABSTRACT, "C", null, null, null, null)); 3616 Keyword.ABSTRACT, "C", null, null, null, null));
3511 } 3617 }
3512 3618
3513 void test_visitClassDeclaration_empty() { 3619 void test_visitClassDeclaration_empty() {
3514 _assertSource("class C {}", 3620 _assertSource("class C {}",
3515 AstFactory.classDeclaration(null, "C", null, null, null, null)); 3621 AstTestFactory.classDeclaration(null, "C", null, null, null, null));
3516 } 3622 }
3517 3623
3518 void test_visitClassDeclaration_extends() { 3624 void test_visitClassDeclaration_extends() {
3519 _assertSource( 3625 _assertSource(
3520 "class C extends A {}", 3626 "class C extends A {}",
3521 AstFactory.classDeclaration(null, "C", null, 3627 AstTestFactory.classDeclaration(
3522 AstFactory.extendsClause(AstFactory.typeName4("A")), null, null)); 3628 null,
3629 "C",
3630 null,
3631 AstTestFactory.extendsClause(AstTestFactory.typeName4("A")),
3632 null,
3633 null));
3523 } 3634 }
3524 3635
3525 void test_visitClassDeclaration_extends_implements() { 3636 void test_visitClassDeclaration_extends_implements() {
3526 _assertSource( 3637 _assertSource(
3527 "class C extends A implements B {}", 3638 "class C extends A implements B {}",
3528 AstFactory.classDeclaration( 3639 AstTestFactory.classDeclaration(
3529 null, 3640 null,
3530 "C", 3641 "C",
3531 null, 3642 null,
3532 AstFactory.extendsClause(AstFactory.typeName4("A")), 3643 AstTestFactory.extendsClause(AstTestFactory.typeName4("A")),
3533 null, 3644 null,
3534 AstFactory.implementsClause([AstFactory.typeName4("B")]))); 3645 AstTestFactory.implementsClause([AstTestFactory.typeName4("B")])));
3535 } 3646 }
3536 3647
3537 void test_visitClassDeclaration_extends_with() { 3648 void test_visitClassDeclaration_extends_with() {
3538 _assertSource( 3649 _assertSource(
3539 "class C extends A with M {}", 3650 "class C extends A with M {}",
3540 AstFactory.classDeclaration( 3651 AstTestFactory.classDeclaration(
3541 null, 3652 null,
3542 "C", 3653 "C",
3543 null, 3654 null,
3544 AstFactory.extendsClause(AstFactory.typeName4("A")), 3655 AstTestFactory.extendsClause(AstTestFactory.typeName4("A")),
3545 AstFactory.withClause([AstFactory.typeName4("M")]), 3656 AstTestFactory.withClause([AstTestFactory.typeName4("M")]),
3546 null)); 3657 null));
3547 } 3658 }
3548 3659
3549 void test_visitClassDeclaration_extends_with_implements() { 3660 void test_visitClassDeclaration_extends_with_implements() {
3550 _assertSource( 3661 _assertSource(
3551 "class C extends A with M implements B {}", 3662 "class C extends A with M implements B {}",
3552 AstFactory.classDeclaration( 3663 AstTestFactory.classDeclaration(
3553 null, 3664 null,
3554 "C", 3665 "C",
3555 null, 3666 null,
3556 AstFactory.extendsClause(AstFactory.typeName4("A")), 3667 AstTestFactory.extendsClause(AstTestFactory.typeName4("A")),
3557 AstFactory.withClause([AstFactory.typeName4("M")]), 3668 AstTestFactory.withClause([AstTestFactory.typeName4("M")]),
3558 AstFactory.implementsClause([AstFactory.typeName4("B")]))); 3669 AstTestFactory.implementsClause([AstTestFactory.typeName4("B")])));
3559 } 3670 }
3560 3671
3561 void test_visitClassDeclaration_implements() { 3672 void test_visitClassDeclaration_implements() {
3562 _assertSource( 3673 _assertSource(
3563 "class C implements B {}", 3674 "class C implements B {}",
3564 AstFactory.classDeclaration(null, "C", null, null, null, 3675 AstTestFactory.classDeclaration(null, "C", null, null, null,
3565 AstFactory.implementsClause([AstFactory.typeName4("B")]))); 3676 AstTestFactory.implementsClause([AstTestFactory.typeName4("B")])));
3566 } 3677 }
3567 3678
3568 void test_visitClassDeclaration_multipleMember() { 3679 void test_visitClassDeclaration_multipleMember() {
3569 _assertSource( 3680 _assertSource(
3570 "class C {var a; var b;}", 3681 "class C {var a; var b;}",
3571 AstFactory.classDeclaration(null, "C", null, null, null, null, [ 3682 AstTestFactory.classDeclaration(null, "C", null, null, null, null, [
3572 AstFactory.fieldDeclaration2( 3683 AstTestFactory.fieldDeclaration2(
3573 false, Keyword.VAR, [AstFactory.variableDeclaration("a")]), 3684 false, Keyword.VAR, [AstTestFactory.variableDeclaration("a")]),
3574 AstFactory.fieldDeclaration2( 3685 AstTestFactory.fieldDeclaration2(
3575 false, Keyword.VAR, [AstFactory.variableDeclaration("b")]) 3686 false, Keyword.VAR, [AstTestFactory.variableDeclaration("b")])
3576 ])); 3687 ]));
3577 } 3688 }
3578 3689
3579 void test_visitClassDeclaration_parameters() { 3690 void test_visitClassDeclaration_parameters() {
3580 _assertSource( 3691 _assertSource(
3581 "class C<E> {}", 3692 "class C<E> {}",
3582 AstFactory.classDeclaration( 3693 AstTestFactory.classDeclaration(null, "C",
3583 null, "C", AstFactory.typeParameterList(["E"]), null, null, null)); 3694 AstTestFactory.typeParameterList(["E"]), null, null, null));
3584 } 3695 }
3585 3696
3586 void test_visitClassDeclaration_parameters_extends() { 3697 void test_visitClassDeclaration_parameters_extends() {
3587 _assertSource( 3698 _assertSource(
3588 "class C<E> extends A {}", 3699 "class C<E> extends A {}",
3589 AstFactory.classDeclaration( 3700 AstTestFactory.classDeclaration(
3590 null, 3701 null,
3591 "C", 3702 "C",
3592 AstFactory.typeParameterList(["E"]), 3703 AstTestFactory.typeParameterList(["E"]),
3593 AstFactory.extendsClause(AstFactory.typeName4("A")), 3704 AstTestFactory.extendsClause(AstTestFactory.typeName4("A")),
3594 null, 3705 null,
3595 null)); 3706 null));
3596 } 3707 }
3597 3708
3598 void test_visitClassDeclaration_parameters_extends_implements() { 3709 void test_visitClassDeclaration_parameters_extends_implements() {
3599 _assertSource( 3710 _assertSource(
3600 "class C<E> extends A implements B {}", 3711 "class C<E> extends A implements B {}",
3601 AstFactory.classDeclaration( 3712 AstTestFactory.classDeclaration(
3602 null, 3713 null,
3603 "C", 3714 "C",
3604 AstFactory.typeParameterList(["E"]), 3715 AstTestFactory.typeParameterList(["E"]),
3605 AstFactory.extendsClause(AstFactory.typeName4("A")), 3716 AstTestFactory.extendsClause(AstTestFactory.typeName4("A")),
3606 null, 3717 null,
3607 AstFactory.implementsClause([AstFactory.typeName4("B")]))); 3718 AstTestFactory.implementsClause([AstTestFactory.typeName4("B")])));
3608 } 3719 }
3609 3720
3610 void test_visitClassDeclaration_parameters_extends_with() { 3721 void test_visitClassDeclaration_parameters_extends_with() {
3611 _assertSource( 3722 _assertSource(
3612 "class C<E> extends A with M {}", 3723 "class C<E> extends A with M {}",
3613 AstFactory.classDeclaration( 3724 AstTestFactory.classDeclaration(
3614 null, 3725 null,
3615 "C", 3726 "C",
3616 AstFactory.typeParameterList(["E"]), 3727 AstTestFactory.typeParameterList(["E"]),
3617 AstFactory.extendsClause(AstFactory.typeName4("A")), 3728 AstTestFactory.extendsClause(AstTestFactory.typeName4("A")),
3618 AstFactory.withClause([AstFactory.typeName4("M")]), 3729 AstTestFactory.withClause([AstTestFactory.typeName4("M")]),
3619 null)); 3730 null));
3620 } 3731 }
3621 3732
3622 void test_visitClassDeclaration_parameters_extends_with_implements() { 3733 void test_visitClassDeclaration_parameters_extends_with_implements() {
3623 _assertSource( 3734 _assertSource(
3624 "class C<E> extends A with M implements B {}", 3735 "class C<E> extends A with M implements B {}",
3625 AstFactory.classDeclaration( 3736 AstTestFactory.classDeclaration(
3626 null, 3737 null,
3627 "C", 3738 "C",
3628 AstFactory.typeParameterList(["E"]), 3739 AstTestFactory.typeParameterList(["E"]),
3629 AstFactory.extendsClause(AstFactory.typeName4("A")), 3740 AstTestFactory.extendsClause(AstTestFactory.typeName4("A")),
3630 AstFactory.withClause([AstFactory.typeName4("M")]), 3741 AstTestFactory.withClause([AstTestFactory.typeName4("M")]),
3631 AstFactory.implementsClause([AstFactory.typeName4("B")]))); 3742 AstTestFactory.implementsClause([AstTestFactory.typeName4("B")])));
3632 } 3743 }
3633 3744
3634 void test_visitClassDeclaration_parameters_implements() { 3745 void test_visitClassDeclaration_parameters_implements() {
3635 _assertSource( 3746 _assertSource(
3636 "class C<E> implements B {}", 3747 "class C<E> implements B {}",
3637 AstFactory.classDeclaration( 3748 AstTestFactory.classDeclaration(
3638 null, 3749 null,
3639 "C", 3750 "C",
3640 AstFactory.typeParameterList(["E"]), 3751 AstTestFactory.typeParameterList(["E"]),
3641 null, 3752 null,
3642 null, 3753 null,
3643 AstFactory.implementsClause([AstFactory.typeName4("B")]))); 3754 AstTestFactory.implementsClause([AstTestFactory.typeName4("B")])));
3644 } 3755 }
3645 3756
3646 void test_visitClassDeclaration_singleMember() { 3757 void test_visitClassDeclaration_singleMember() {
3647 _assertSource( 3758 _assertSource(
3648 "class C {var a;}", 3759 "class C {var a;}",
3649 AstFactory.classDeclaration(null, "C", null, null, null, null, [ 3760 AstTestFactory.classDeclaration(null, "C", null, null, null, null, [
3650 AstFactory.fieldDeclaration2( 3761 AstTestFactory.fieldDeclaration2(
3651 false, Keyword.VAR, [AstFactory.variableDeclaration("a")]) 3762 false, Keyword.VAR, [AstTestFactory.variableDeclaration("a")])
3652 ])); 3763 ]));
3653 } 3764 }
3654 3765
3655 void test_visitClassDeclaration_withMetadata() { 3766 void test_visitClassDeclaration_withMetadata() {
3656 ClassDeclaration declaration = 3767 ClassDeclaration declaration =
3657 AstFactory.classDeclaration(null, "C", null, null, null, null); 3768 AstTestFactory.classDeclaration(null, "C", null, null, null, null);
3658 declaration.metadata 3769 declaration.metadata.add(
3659 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 3770 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
3660 _assertSource("@deprecated class C {}", declaration); 3771 _assertSource("@deprecated class C {}", declaration);
3661 } 3772 }
3662 3773
3663 void test_visitClassTypeAlias_abstract() { 3774 void test_visitClassTypeAlias_abstract() {
3664 _assertSource( 3775 _assertSource(
3665 "abstract class C = S with M1;", 3776 "abstract class C = S with M1;",
3666 AstFactory.classTypeAlias( 3777 AstTestFactory.classTypeAlias(
3667 "C", 3778 "C",
3668 null, 3779 null,
3669 Keyword.ABSTRACT, 3780 Keyword.ABSTRACT,
3670 AstFactory.typeName4("S"), 3781 AstTestFactory.typeName4("S"),
3671 AstFactory.withClause([AstFactory.typeName4("M1")]), 3782 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]),
3672 null)); 3783 null));
3673 } 3784 }
3674 3785
3675 void test_visitClassTypeAlias_abstract_implements() { 3786 void test_visitClassTypeAlias_abstract_implements() {
3676 _assertSource( 3787 _assertSource(
3677 "abstract class C = S with M1 implements I;", 3788 "abstract class C = S with M1 implements I;",
3678 AstFactory.classTypeAlias( 3789 AstTestFactory.classTypeAlias(
3679 "C", 3790 "C",
3680 null, 3791 null,
3681 Keyword.ABSTRACT, 3792 Keyword.ABSTRACT,
3682 AstFactory.typeName4("S"), 3793 AstTestFactory.typeName4("S"),
3683 AstFactory.withClause([AstFactory.typeName4("M1")]), 3794 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]),
3684 AstFactory.implementsClause([AstFactory.typeName4("I")]))); 3795 AstTestFactory.implementsClause([AstTestFactory.typeName4("I")])));
3685 } 3796 }
3686 3797
3687 void test_visitClassTypeAlias_generic() { 3798 void test_visitClassTypeAlias_generic() {
3688 _assertSource( 3799 _assertSource(
3689 "class C<E> = S<E> with M1<E>;", 3800 "class C<E> = S<E> with M1<E>;",
3690 AstFactory.classTypeAlias( 3801 AstTestFactory.classTypeAlias(
3691 "C", 3802 "C",
3692 AstFactory.typeParameterList(["E"]), 3803 AstTestFactory.typeParameterList(["E"]),
3693 null, 3804 null,
3694 AstFactory.typeName4("S", [AstFactory.typeName4("E")]), 3805 AstTestFactory.typeName4("S", [AstTestFactory.typeName4("E")]),
3695 AstFactory.withClause([ 3806 AstTestFactory.withClause([
3696 AstFactory.typeName4("M1", [AstFactory.typeName4("E")]) 3807 AstTestFactory.typeName4("M1", [AstTestFactory.typeName4("E")])
3697 ]), 3808 ]),
3698 null)); 3809 null));
3699 } 3810 }
3700 3811
3701 void test_visitClassTypeAlias_implements() { 3812 void test_visitClassTypeAlias_implements() {
3702 _assertSource( 3813 _assertSource(
3703 "class C = S with M1 implements I;", 3814 "class C = S with M1 implements I;",
3704 AstFactory.classTypeAlias( 3815 AstTestFactory.classTypeAlias(
3705 "C", 3816 "C",
3706 null, 3817 null,
3707 null, 3818 null,
3708 AstFactory.typeName4("S"), 3819 AstTestFactory.typeName4("S"),
3709 AstFactory.withClause([AstFactory.typeName4("M1")]), 3820 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]),
3710 AstFactory.implementsClause([AstFactory.typeName4("I")]))); 3821 AstTestFactory.implementsClause([AstTestFactory.typeName4("I")])));
3711 } 3822 }
3712 3823
3713 void test_visitClassTypeAlias_minimal() { 3824 void test_visitClassTypeAlias_minimal() {
3714 _assertSource( 3825 _assertSource(
3715 "class C = S with M1;", 3826 "class C = S with M1;",
3716 AstFactory.classTypeAlias("C", null, null, AstFactory.typeName4("S"), 3827 AstTestFactory.classTypeAlias(
3717 AstFactory.withClause([AstFactory.typeName4("M1")]), null)); 3828 "C",
3829 null,
3830 null,
3831 AstTestFactory.typeName4("S"),
3832 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]),
3833 null));
3718 } 3834 }
3719 3835
3720 void test_visitClassTypeAlias_parameters_abstract() { 3836 void test_visitClassTypeAlias_parameters_abstract() {
3721 _assertSource( 3837 _assertSource(
3722 "abstract class C<E> = S with M1;", 3838 "abstract class C<E> = S with M1;",
3723 AstFactory.classTypeAlias( 3839 AstTestFactory.classTypeAlias(
3724 "C", 3840 "C",
3725 AstFactory.typeParameterList(["E"]), 3841 AstTestFactory.typeParameterList(["E"]),
3726 Keyword.ABSTRACT, 3842 Keyword.ABSTRACT,
3727 AstFactory.typeName4("S"), 3843 AstTestFactory.typeName4("S"),
3728 AstFactory.withClause([AstFactory.typeName4("M1")]), 3844 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]),
3729 null)); 3845 null));
3730 } 3846 }
3731 3847
3732 void test_visitClassTypeAlias_parameters_abstract_implements() { 3848 void test_visitClassTypeAlias_parameters_abstract_implements() {
3733 _assertSource( 3849 _assertSource(
3734 "abstract class C<E> = S with M1 implements I;", 3850 "abstract class C<E> = S with M1 implements I;",
3735 AstFactory.classTypeAlias( 3851 AstTestFactory.classTypeAlias(
3736 "C", 3852 "C",
3737 AstFactory.typeParameterList(["E"]), 3853 AstTestFactory.typeParameterList(["E"]),
3738 Keyword.ABSTRACT, 3854 Keyword.ABSTRACT,
3739 AstFactory.typeName4("S"), 3855 AstTestFactory.typeName4("S"),
3740 AstFactory.withClause([AstFactory.typeName4("M1")]), 3856 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]),
3741 AstFactory.implementsClause([AstFactory.typeName4("I")]))); 3857 AstTestFactory.implementsClause([AstTestFactory.typeName4("I")])));
3742 } 3858 }
3743 3859
3744 void test_visitClassTypeAlias_parameters_implements() { 3860 void test_visitClassTypeAlias_parameters_implements() {
3745 _assertSource( 3861 _assertSource(
3746 "class C<E> = S with M1 implements I;", 3862 "class C<E> = S with M1 implements I;",
3747 AstFactory.classTypeAlias( 3863 AstTestFactory.classTypeAlias(
3748 "C", 3864 "C",
3749 AstFactory.typeParameterList(["E"]), 3865 AstTestFactory.typeParameterList(["E"]),
3750 null, 3866 null,
3751 AstFactory.typeName4("S"), 3867 AstTestFactory.typeName4("S"),
3752 AstFactory.withClause([AstFactory.typeName4("M1")]), 3868 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]),
3753 AstFactory.implementsClause([AstFactory.typeName4("I")]))); 3869 AstTestFactory.implementsClause([AstTestFactory.typeName4("I")])));
3754 } 3870 }
3755 3871
3756 void test_visitClassTypeAlias_withMetadata() { 3872 void test_visitClassTypeAlias_withMetadata() {
3757 ClassTypeAlias declaration = AstFactory.classTypeAlias( 3873 ClassTypeAlias declaration = AstTestFactory.classTypeAlias(
3758 "C", 3874 "C",
3759 null, 3875 null,
3760 null, 3876 null,
3761 AstFactory.typeName4("S"), 3877 AstTestFactory.typeName4("S"),
3762 AstFactory.withClause([AstFactory.typeName4("M1")]), 3878 AstTestFactory.withClause([AstTestFactory.typeName4("M1")]),
3763 null); 3879 null);
3764 declaration.metadata 3880 declaration.metadata.add(
3765 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 3881 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
3766 _assertSource("@deprecated class C = S with M1;", declaration); 3882 _assertSource("@deprecated class C = S with M1;", declaration);
3767 } 3883 }
3768 3884
3769 void test_visitComment() { 3885 void test_visitComment() {
3770 _assertSource( 3886 _assertSource(
3771 "", 3887 "",
3772 Comment.createBlockComment( 3888 Comment.createBlockComment(
3773 <Token>[TokenFactory.tokenFromString("/* comment */")])); 3889 <Token>[TokenFactory.tokenFromString("/* comment */")]));
3774 } 3890 }
3775 3891
3776 void test_visitCommentReference() { 3892 void test_visitCommentReference() {
3777 _assertSource("", new CommentReference(null, AstFactory.identifier3("a"))); 3893 _assertSource(
3894 "", new CommentReference(null, AstTestFactory.identifier3("a")));
3778 } 3895 }
3779 3896
3780 void test_visitCompilationUnit_declaration() { 3897 void test_visitCompilationUnit_declaration() {
3781 _assertSource( 3898 _assertSource(
3782 "var a;", 3899 "var a;",
3783 AstFactory.compilationUnit2([ 3900 AstTestFactory.compilationUnit2([
3784 AstFactory.topLevelVariableDeclaration2( 3901 AstTestFactory.topLevelVariableDeclaration2(
3785 Keyword.VAR, [AstFactory.variableDeclaration("a")]) 3902 Keyword.VAR, [AstTestFactory.variableDeclaration("a")])
3786 ])); 3903 ]));
3787 } 3904 }
3788 3905
3789 void test_visitCompilationUnit_directive() { 3906 void test_visitCompilationUnit_directive() {
3790 _assertSource("library l;", 3907 _assertSource(
3791 AstFactory.compilationUnit3([AstFactory.libraryDirective2("l")])); 3908 "library l;",
3909 AstTestFactory
3910 .compilationUnit3([AstTestFactory.libraryDirective2("l")]));
3792 } 3911 }
3793 3912
3794 void test_visitCompilationUnit_directive_declaration() { 3913 void test_visitCompilationUnit_directive_declaration() {
3795 _assertSource( 3914 _assertSource(
3796 "library l; var a;", 3915 "library l; var a;",
3797 AstFactory.compilationUnit4([ 3916 AstTestFactory.compilationUnit4([
3798 AstFactory.libraryDirective2("l") 3917 AstTestFactory.libraryDirective2("l")
3799 ], [ 3918 ], [
3800 AstFactory.topLevelVariableDeclaration2( 3919 AstTestFactory.topLevelVariableDeclaration2(
3801 Keyword.VAR, [AstFactory.variableDeclaration("a")]) 3920 Keyword.VAR, [AstTestFactory.variableDeclaration("a")])
3802 ])); 3921 ]));
3803 } 3922 }
3804 3923
3805 void test_visitCompilationUnit_empty() { 3924 void test_visitCompilationUnit_empty() {
3806 _assertSource("", AstFactory.compilationUnit()); 3925 _assertSource("", AstTestFactory.compilationUnit());
3807 } 3926 }
3808 3927
3809 void test_visitCompilationUnit_script() { 3928 void test_visitCompilationUnit_script() {
3810 _assertSource( 3929 _assertSource(
3811 "!#/bin/dartvm", AstFactory.compilationUnit5("!#/bin/dartvm")); 3930 "!#/bin/dartvm", AstTestFactory.compilationUnit5("!#/bin/dartvm"));
3812 } 3931 }
3813 3932
3814 void test_visitCompilationUnit_script_declaration() { 3933 void test_visitCompilationUnit_script_declaration() {
3815 _assertSource( 3934 _assertSource(
3816 "!#/bin/dartvm var a;", 3935 "!#/bin/dartvm var a;",
3817 AstFactory.compilationUnit6("!#/bin/dartvm", [ 3936 AstTestFactory.compilationUnit6("!#/bin/dartvm", [
3818 AstFactory.topLevelVariableDeclaration2( 3937 AstTestFactory.topLevelVariableDeclaration2(
3819 Keyword.VAR, [AstFactory.variableDeclaration("a")]) 3938 Keyword.VAR, [AstTestFactory.variableDeclaration("a")])
3820 ])); 3939 ]));
3821 } 3940 }
3822 3941
3823 void test_visitCompilationUnit_script_directive() { 3942 void test_visitCompilationUnit_script_directive() {
3824 _assertSource( 3943 _assertSource(
3825 "!#/bin/dartvm library l;", 3944 "!#/bin/dartvm library l;",
3826 AstFactory.compilationUnit7( 3945 AstTestFactory.compilationUnit7(
3827 "!#/bin/dartvm", [AstFactory.libraryDirective2("l")])); 3946 "!#/bin/dartvm", [AstTestFactory.libraryDirective2("l")]));
3828 } 3947 }
3829 3948
3830 void test_visitCompilationUnit_script_directives_declarations() { 3949 void test_visitCompilationUnit_script_directives_declarations() {
3831 _assertSource( 3950 _assertSource(
3832 "!#/bin/dartvm library l; var a;", 3951 "!#/bin/dartvm library l; var a;",
3833 AstFactory.compilationUnit8("!#/bin/dartvm", [ 3952 AstTestFactory.compilationUnit8("!#/bin/dartvm", [
3834 AstFactory.libraryDirective2("l") 3953 AstTestFactory.libraryDirective2("l")
3835 ], [ 3954 ], [
3836 AstFactory.topLevelVariableDeclaration2( 3955 AstTestFactory.topLevelVariableDeclaration2(
3837 Keyword.VAR, [AstFactory.variableDeclaration("a")]) 3956 Keyword.VAR, [AstTestFactory.variableDeclaration("a")])
3838 ])); 3957 ]));
3839 } 3958 }
3840 3959
3841 void test_visitConditionalExpression() { 3960 void test_visitConditionalExpression() {
3842 _assertSource( 3961 _assertSource(
3843 "a ? b : c", 3962 "a ? b : c",
3844 AstFactory.conditionalExpression(AstFactory.identifier3("a"), 3963 AstTestFactory.conditionalExpression(AstTestFactory.identifier3("a"),
3845 AstFactory.identifier3("b"), AstFactory.identifier3("c"))); 3964 AstTestFactory.identifier3("b"), AstTestFactory.identifier3("c")));
3846 } 3965 }
3847 3966
3848 void test_visitConstructorDeclaration_const() { 3967 void test_visitConstructorDeclaration_const() {
3849 _assertSource( 3968 _assertSource(
3850 "const C() {}", 3969 "const C() {}",
3851 AstFactory.constructorDeclaration2( 3970 AstTestFactory.constructorDeclaration2(
3852 Keyword.CONST, 3971 Keyword.CONST,
3853 null, 3972 null,
3854 AstFactory.identifier3("C"), 3973 AstTestFactory.identifier3("C"),
3855 null, 3974 null,
3856 AstFactory.formalParameterList(), 3975 AstTestFactory.formalParameterList(),
3857 null, 3976 null,
3858 AstFactory.blockFunctionBody2())); 3977 AstTestFactory.blockFunctionBody2()));
3859 } 3978 }
3860 3979
3861 void test_visitConstructorDeclaration_external() { 3980 void test_visitConstructorDeclaration_external() {
3862 _assertSource( 3981 _assertSource(
3863 "external C();", 3982 "external C();",
3864 AstFactory.constructorDeclaration(AstFactory.identifier3("C"), null, 3983 AstTestFactory.constructorDeclaration(AstTestFactory.identifier3("C"),
3865 AstFactory.formalParameterList(), null)); 3984 null, AstTestFactory.formalParameterList(), null));
3866 } 3985 }
3867 3986
3868 void test_visitConstructorDeclaration_minimal() { 3987 void test_visitConstructorDeclaration_minimal() {
3869 _assertSource( 3988 _assertSource(
3870 "C() {}", 3989 "C() {}",
3871 AstFactory.constructorDeclaration2( 3990 AstTestFactory.constructorDeclaration2(
3872 null, 3991 null,
3873 null, 3992 null,
3874 AstFactory.identifier3("C"), 3993 AstTestFactory.identifier3("C"),
3875 null, 3994 null,
3876 AstFactory.formalParameterList(), 3995 AstTestFactory.formalParameterList(),
3877 null, 3996 null,
3878 AstFactory.blockFunctionBody2())); 3997 AstTestFactory.blockFunctionBody2()));
3879 } 3998 }
3880 3999
3881 void test_visitConstructorDeclaration_multipleInitializers() { 4000 void test_visitConstructorDeclaration_multipleInitializers() {
3882 _assertSource( 4001 _assertSource(
3883 "C() : a = b, c = d {}", 4002 "C() : a = b, c = d {}",
3884 AstFactory.constructorDeclaration2( 4003 AstTestFactory.constructorDeclaration2(
3885 null, 4004 null,
3886 null, 4005 null,
3887 AstFactory.identifier3("C"), 4006 AstTestFactory.identifier3("C"),
3888 null, 4007 null,
3889 AstFactory.formalParameterList(), 4008 AstTestFactory.formalParameterList(),
3890 [ 4009 [
3891 AstFactory.constructorFieldInitializer( 4010 AstTestFactory.constructorFieldInitializer(
3892 false, "a", AstFactory.identifier3("b")), 4011 false, "a", AstTestFactory.identifier3("b")),
3893 AstFactory.constructorFieldInitializer( 4012 AstTestFactory.constructorFieldInitializer(
3894 false, "c", AstFactory.identifier3("d")) 4013 false, "c", AstTestFactory.identifier3("d"))
3895 ], 4014 ],
3896 AstFactory.blockFunctionBody2())); 4015 AstTestFactory.blockFunctionBody2()));
3897 } 4016 }
3898 4017
3899 void test_visitConstructorDeclaration_multipleParameters() { 4018 void test_visitConstructorDeclaration_multipleParameters() {
3900 _assertSource( 4019 _assertSource(
3901 "C(var a, var b) {}", 4020 "C(var a, var b) {}",
3902 AstFactory.constructorDeclaration2( 4021 AstTestFactory.constructorDeclaration2(
3903 null, 4022 null,
3904 null, 4023 null,
3905 AstFactory.identifier3("C"), 4024 AstTestFactory.identifier3("C"),
3906 null, 4025 null,
3907 AstFactory.formalParameterList([ 4026 AstTestFactory.formalParameterList([
3908 AstFactory.simpleFormalParameter(Keyword.VAR, "a"), 4027 AstTestFactory.simpleFormalParameter(Keyword.VAR, "a"),
3909 AstFactory.simpleFormalParameter(Keyword.VAR, "b") 4028 AstTestFactory.simpleFormalParameter(Keyword.VAR, "b")
3910 ]), 4029 ]),
3911 null, 4030 null,
3912 AstFactory.blockFunctionBody2())); 4031 AstTestFactory.blockFunctionBody2()));
3913 } 4032 }
3914 4033
3915 void test_visitConstructorDeclaration_named() { 4034 void test_visitConstructorDeclaration_named() {
3916 _assertSource( 4035 _assertSource(
3917 "C.m() {}", 4036 "C.m() {}",
3918 AstFactory.constructorDeclaration2( 4037 AstTestFactory.constructorDeclaration2(
3919 null, 4038 null,
3920 null, 4039 null,
3921 AstFactory.identifier3("C"), 4040 AstTestFactory.identifier3("C"),
3922 "m", 4041 "m",
3923 AstFactory.formalParameterList(), 4042 AstTestFactory.formalParameterList(),
3924 null, 4043 null,
3925 AstFactory.blockFunctionBody2())); 4044 AstTestFactory.blockFunctionBody2()));
3926 } 4045 }
3927 4046
3928 void test_visitConstructorDeclaration_singleInitializer() { 4047 void test_visitConstructorDeclaration_singleInitializer() {
3929 _assertSource( 4048 _assertSource(
3930 "C() : a = b {}", 4049 "C() : a = b {}",
3931 AstFactory.constructorDeclaration2( 4050 AstTestFactory.constructorDeclaration2(
3932 null, 4051 null,
3933 null, 4052 null,
3934 AstFactory.identifier3("C"), 4053 AstTestFactory.identifier3("C"),
3935 null, 4054 null,
3936 AstFactory.formalParameterList(), 4055 AstTestFactory.formalParameterList(),
3937 [ 4056 [
3938 AstFactory.constructorFieldInitializer( 4057 AstTestFactory.constructorFieldInitializer(
3939 false, "a", AstFactory.identifier3("b")) 4058 false, "a", AstTestFactory.identifier3("b"))
3940 ], 4059 ],
3941 AstFactory.blockFunctionBody2())); 4060 AstTestFactory.blockFunctionBody2()));
3942 } 4061 }
3943 4062
3944 void test_visitConstructorDeclaration_withMetadata() { 4063 void test_visitConstructorDeclaration_withMetadata() {
3945 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( 4064 ConstructorDeclaration declaration = AstTestFactory.constructorDeclaration2(
3946 null, 4065 null,
3947 null, 4066 null,
3948 AstFactory.identifier3("C"), 4067 AstTestFactory.identifier3("C"),
3949 null, 4068 null,
3950 AstFactory.formalParameterList(), 4069 AstTestFactory.formalParameterList(),
3951 null, 4070 null,
3952 AstFactory.blockFunctionBody2()); 4071 AstTestFactory.blockFunctionBody2());
3953 declaration.metadata 4072 declaration.metadata.add(
3954 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 4073 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
3955 _assertSource("@deprecated C() {}", declaration); 4074 _assertSource("@deprecated C() {}", declaration);
3956 } 4075 }
3957 4076
3958 void test_visitConstructorFieldInitializer_withoutThis() { 4077 void test_visitConstructorFieldInitializer_withoutThis() {
3959 _assertSource( 4078 _assertSource(
3960 "a = b", 4079 "a = b",
3961 AstFactory.constructorFieldInitializer( 4080 AstTestFactory.constructorFieldInitializer(
3962 false, "a", AstFactory.identifier3("b"))); 4081 false, "a", AstTestFactory.identifier3("b")));
3963 } 4082 }
3964 4083
3965 void test_visitConstructorFieldInitializer_withThis() { 4084 void test_visitConstructorFieldInitializer_withThis() {
3966 _assertSource( 4085 _assertSource(
3967 "this.a = b", 4086 "this.a = b",
3968 AstFactory.constructorFieldInitializer( 4087 AstTestFactory.constructorFieldInitializer(
3969 true, "a", AstFactory.identifier3("b"))); 4088 true, "a", AstTestFactory.identifier3("b")));
3970 } 4089 }
3971 4090
3972 void test_visitConstructorName_named_prefix() { 4091 void test_visitConstructorName_named_prefix() {
3973 _assertSource("p.C.n", 4092 _assertSource(
3974 AstFactory.constructorName(AstFactory.typeName4("p.C.n"), null)); 4093 "p.C.n",
4094 AstTestFactory.constructorName(
4095 AstTestFactory.typeName4("p.C.n"), null));
3975 } 4096 }
3976 4097
3977 void test_visitConstructorName_unnamed_noPrefix() { 4098 void test_visitConstructorName_unnamed_noPrefix() {
3978 _assertSource( 4099 _assertSource("C",
3979 "C", AstFactory.constructorName(AstFactory.typeName4("C"), null)); 4100 AstTestFactory.constructorName(AstTestFactory.typeName4("C"), null));
3980 } 4101 }
3981 4102
3982 void test_visitConstructorName_unnamed_prefix() { 4103 void test_visitConstructorName_unnamed_prefix() {
3983 _assertSource( 4104 _assertSource(
3984 "p.C", 4105 "p.C",
3985 AstFactory.constructorName( 4106 AstTestFactory.constructorName(
3986 AstFactory.typeName3(AstFactory.identifier5("p", "C")), null)); 4107 AstTestFactory.typeName3(AstTestFactory.identifier5("p", "C")),
4108 null));
3987 } 4109 }
3988 4110
3989 void test_visitContinueStatement_label() { 4111 void test_visitContinueStatement_label() {
3990 _assertSource("continue l;", AstFactory.continueStatement("l")); 4112 _assertSource("continue l;", AstTestFactory.continueStatement("l"));
3991 } 4113 }
3992 4114
3993 void test_visitContinueStatement_noLabel() { 4115 void test_visitContinueStatement_noLabel() {
3994 _assertSource("continue;", AstFactory.continueStatement()); 4116 _assertSource("continue;", AstTestFactory.continueStatement());
3995 } 4117 }
3996 4118
3997 void test_visitDefaultFormalParameter_annotation() { 4119 void test_visitDefaultFormalParameter_annotation() {
3998 DefaultFormalParameter parameter = AstFactory.positionalFormalParameter( 4120 DefaultFormalParameter parameter = AstTestFactory.positionalFormalParameter(
3999 AstFactory.simpleFormalParameter3("p"), AstFactory.integer(0)); 4121 AstTestFactory.simpleFormalParameter3("p"), AstTestFactory.integer(0));
4000 parameter.metadata.add(AstFactory.annotation(AstFactory.identifier3("A"))); 4122 parameter.metadata
4123 .add(AstTestFactory.annotation(AstTestFactory.identifier3("A")));
4001 _assertSource('@A p = 0', parameter); 4124 _assertSource('@A p = 0', parameter);
4002 } 4125 }
4003 4126
4004 void test_visitDefaultFormalParameter_named_noValue() { 4127 void test_visitDefaultFormalParameter_named_noValue() {
4005 _assertSource( 4128 _assertSource(
4006 "p", 4129 "p",
4007 AstFactory.namedFormalParameter( 4130 AstTestFactory.namedFormalParameter(
4008 AstFactory.simpleFormalParameter3("p"), null)); 4131 AstTestFactory.simpleFormalParameter3("p"), null));
4009 } 4132 }
4010 4133
4011 void test_visitDefaultFormalParameter_named_value() { 4134 void test_visitDefaultFormalParameter_named_value() {
4012 _assertSource( 4135 _assertSource(
4013 "p : 0", 4136 "p : 0",
4014 AstFactory.namedFormalParameter( 4137 AstTestFactory.namedFormalParameter(
4015 AstFactory.simpleFormalParameter3("p"), AstFactory.integer(0))); 4138 AstTestFactory.simpleFormalParameter3("p"),
4139 AstTestFactory.integer(0)));
4016 } 4140 }
4017 4141
4018 void test_visitDefaultFormalParameter_positional_noValue() { 4142 void test_visitDefaultFormalParameter_positional_noValue() {
4019 _assertSource( 4143 _assertSource(
4020 "p", 4144 "p",
4021 AstFactory.positionalFormalParameter( 4145 AstTestFactory.positionalFormalParameter(
4022 AstFactory.simpleFormalParameter3("p"), null)); 4146 AstTestFactory.simpleFormalParameter3("p"), null));
4023 } 4147 }
4024 4148
4025 void test_visitDefaultFormalParameter_positional_value() { 4149 void test_visitDefaultFormalParameter_positional_value() {
4026 _assertSource( 4150 _assertSource(
4027 "p = 0", 4151 "p = 0",
4028 AstFactory.positionalFormalParameter( 4152 AstTestFactory.positionalFormalParameter(
4029 AstFactory.simpleFormalParameter3("p"), AstFactory.integer(0))); 4153 AstTestFactory.simpleFormalParameter3("p"),
4154 AstTestFactory.integer(0)));
4030 } 4155 }
4031 4156
4032 void test_visitDoStatement() { 4157 void test_visitDoStatement() {
4033 _assertSource( 4158 _assertSource(
4034 "do {} while (c);", 4159 "do {} while (c);",
4035 AstFactory.doStatement( 4160 AstTestFactory.doStatement(
4036 AstFactory.block(), AstFactory.identifier3("c"))); 4161 AstTestFactory.block(), AstTestFactory.identifier3("c")));
4037 } 4162 }
4038 4163
4039 void test_visitDoubleLiteral() { 4164 void test_visitDoubleLiteral() {
4040 _assertSource("4.2", AstFactory.doubleLiteral(4.2)); 4165 _assertSource("4.2", AstTestFactory.doubleLiteral(4.2));
4041 } 4166 }
4042 4167
4043 void test_visitEmptyFunctionBody() { 4168 void test_visitEmptyFunctionBody() {
4044 _assertSource(";", AstFactory.emptyFunctionBody()); 4169 _assertSource(";", AstTestFactory.emptyFunctionBody());
4045 } 4170 }
4046 4171
4047 void test_visitEmptyStatement() { 4172 void test_visitEmptyStatement() {
4048 _assertSource(";", AstFactory.emptyStatement()); 4173 _assertSource(";", AstTestFactory.emptyStatement());
4049 } 4174 }
4050 4175
4051 void test_visitEnumDeclaration_multiple() { 4176 void test_visitEnumDeclaration_multiple() {
4052 _assertSource( 4177 _assertSource("enum E {ONE, TWO}",
4053 "enum E {ONE, TWO}", AstFactory.enumDeclaration2("E", ["ONE", "TWO"])); 4178 AstTestFactory.enumDeclaration2("E", ["ONE", "TWO"]));
4054 } 4179 }
4055 4180
4056 void test_visitEnumDeclaration_single() { 4181 void test_visitEnumDeclaration_single() {
4057 _assertSource("enum E {ONE}", AstFactory.enumDeclaration2("E", ["ONE"])); 4182 _assertSource(
4183 "enum E {ONE}", AstTestFactory.enumDeclaration2("E", ["ONE"]));
4058 } 4184 }
4059 4185
4060 void test_visitExportDirective_combinator() { 4186 void test_visitExportDirective_combinator() {
4061 _assertSource( 4187 _assertSource(
4062 "export 'a.dart' show A;", 4188 "export 'a.dart' show A;",
4063 AstFactory.exportDirective2("a.dart", [ 4189 AstTestFactory.exportDirective2("a.dart", [
4064 AstFactory.showCombinator([AstFactory.identifier3("A")]) 4190 AstTestFactory.showCombinator([AstTestFactory.identifier3("A")])
4065 ])); 4191 ]));
4066 } 4192 }
4067 4193
4068 void test_visitExportDirective_combinators() { 4194 void test_visitExportDirective_combinators() {
4069 _assertSource( 4195 _assertSource(
4070 "export 'a.dart' show A hide B;", 4196 "export 'a.dart' show A hide B;",
4071 AstFactory.exportDirective2("a.dart", [ 4197 AstTestFactory.exportDirective2("a.dart", [
4072 AstFactory.showCombinator([AstFactory.identifier3("A")]), 4198 AstTestFactory.showCombinator([AstTestFactory.identifier3("A")]),
4073 AstFactory.hideCombinator([AstFactory.identifier3("B")]) 4199 AstTestFactory.hideCombinator([AstTestFactory.identifier3("B")])
4074 ])); 4200 ]));
4075 } 4201 }
4076 4202
4077 void test_visitExportDirective_minimal() { 4203 void test_visitExportDirective_minimal() {
4078 _assertSource("export 'a.dart';", AstFactory.exportDirective2("a.dart")); 4204 _assertSource(
4205 "export 'a.dart';", AstTestFactory.exportDirective2("a.dart"));
4079 } 4206 }
4080 4207
4081 void test_visitExportDirective_withMetadata() { 4208 void test_visitExportDirective_withMetadata() {
4082 ExportDirective directive = AstFactory.exportDirective2("a.dart"); 4209 ExportDirective directive = AstTestFactory.exportDirective2("a.dart");
4083 directive.metadata 4210 directive.metadata.add(
4084 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 4211 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
4085 _assertSource("@deprecated export 'a.dart';", directive); 4212 _assertSource("@deprecated export 'a.dart';", directive);
4086 } 4213 }
4087 4214
4088 void test_visitExpressionFunctionBody_async() { 4215 void test_visitExpressionFunctionBody_async() {
4089 _assertSource("async => a;", 4216 _assertSource(
4090 AstFactory.asyncExpressionFunctionBody(AstFactory.identifier3("a"))); 4217 "async => a;",
4218 AstTestFactory
4219 .asyncExpressionFunctionBody(AstTestFactory.identifier3("a")));
4091 } 4220 }
4092 4221
4093 void test_visitExpressionFunctionBody_simple() { 4222 void test_visitExpressionFunctionBody_simple() {
4094 _assertSource("=> a;", 4223 _assertSource("=> a;",
4095 AstFactory.expressionFunctionBody(AstFactory.identifier3("a"))); 4224 AstTestFactory.expressionFunctionBody(AstTestFactory.identifier3("a")));
4096 } 4225 }
4097 4226
4098 void test_visitExpressionStatement() { 4227 void test_visitExpressionStatement() {
4099 _assertSource( 4228 _assertSource("a;",
4100 "a;", AstFactory.expressionStatement(AstFactory.identifier3("a"))); 4229 AstTestFactory.expressionStatement(AstTestFactory.identifier3("a")));
4101 } 4230 }
4102 4231
4103 void test_visitExtendsClause() { 4232 void test_visitExtendsClause() {
4104 _assertSource( 4233 _assertSource("extends C",
4105 "extends C", AstFactory.extendsClause(AstFactory.typeName4("C"))); 4234 AstTestFactory.extendsClause(AstTestFactory.typeName4("C")));
4106 } 4235 }
4107 4236
4108 void test_visitFieldDeclaration_instance() { 4237 void test_visitFieldDeclaration_instance() {
4109 _assertSource( 4238 _assertSource(
4110 "var a;", 4239 "var a;",
4111 AstFactory.fieldDeclaration2( 4240 AstTestFactory.fieldDeclaration2(
4112 false, Keyword.VAR, [AstFactory.variableDeclaration("a")])); 4241 false, Keyword.VAR, [AstTestFactory.variableDeclaration("a")]));
4113 } 4242 }
4114 4243
4115 void test_visitFieldDeclaration_static() { 4244 void test_visitFieldDeclaration_static() {
4116 _assertSource( 4245 _assertSource(
4117 "static var a;", 4246 "static var a;",
4118 AstFactory.fieldDeclaration2( 4247 AstTestFactory.fieldDeclaration2(
4119 true, Keyword.VAR, [AstFactory.variableDeclaration("a")])); 4248 true, Keyword.VAR, [AstTestFactory.variableDeclaration("a")]));
4120 } 4249 }
4121 4250
4122 void test_visitFieldDeclaration_withMetadata() { 4251 void test_visitFieldDeclaration_withMetadata() {
4123 FieldDeclaration declaration = AstFactory.fieldDeclaration2( 4252 FieldDeclaration declaration = AstTestFactory.fieldDeclaration2(
4124 false, Keyword.VAR, [AstFactory.variableDeclaration("a")]); 4253 false, Keyword.VAR, [AstTestFactory.variableDeclaration("a")]);
4125 declaration.metadata 4254 declaration.metadata.add(
4126 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 4255 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
4127 _assertSource("@deprecated var a;", declaration); 4256 _assertSource("@deprecated var a;", declaration);
4128 } 4257 }
4129 4258
4130 void test_visitFieldFormalParameter_annotation() { 4259 void test_visitFieldFormalParameter_annotation() {
4131 FieldFormalParameter parameter = AstFactory.fieldFormalParameter2('f'); 4260 FieldFormalParameter parameter = AstTestFactory.fieldFormalParameter2('f');
4132 parameter.metadata.add(AstFactory.annotation(AstFactory.identifier3("A"))); 4261 parameter.metadata
4262 .add(AstTestFactory.annotation(AstTestFactory.identifier3("A")));
4133 _assertSource('@A this.f', parameter); 4263 _assertSource('@A this.f', parameter);
4134 } 4264 }
4135 4265
4136 void test_visitFieldFormalParameter_functionTyped() { 4266 void test_visitFieldFormalParameter_functionTyped() {
4137 _assertSource( 4267 _assertSource(
4138 "A this.a(b)", 4268 "A this.a(b)",
4139 AstFactory.fieldFormalParameter( 4269 AstTestFactory.fieldFormalParameter(
4140 null, 4270 null,
4141 AstFactory.typeName4("A"), 4271 AstTestFactory.typeName4("A"),
4142 "a", 4272 "a",
4143 AstFactory.formalParameterList( 4273 AstTestFactory.formalParameterList(
4144 [AstFactory.simpleFormalParameter3("b")]))); 4274 [AstTestFactory.simpleFormalParameter3("b")])));
4145 } 4275 }
4146 4276
4147 void test_visitFieldFormalParameter_functionTyped_typeParameters() { 4277 void test_visitFieldFormalParameter_functionTyped_typeParameters() {
4148 _assertSource( 4278 _assertSource(
4149 "A this.a<E, F>(b)", 4279 "A this.a<E, F>(b)",
4150 new FieldFormalParameter( 4280 new FieldFormalParameter(
4151 null, 4281 null,
4152 null, 4282 null,
4153 null, 4283 null,
4154 AstFactory.typeName4('A'), 4284 AstTestFactory.typeName4('A'),
4155 TokenFactory.tokenFromKeyword(Keyword.THIS), 4285 TokenFactory.tokenFromKeyword(Keyword.THIS),
4156 TokenFactory.tokenFromType(TokenType.PERIOD), 4286 TokenFactory.tokenFromType(TokenType.PERIOD),
4157 AstFactory.identifier3('a'), 4287 AstTestFactory.identifier3('a'),
4158 AstFactory.typeParameterList(['E', 'F']), 4288 AstTestFactory.typeParameterList(['E', 'F']),
4159 AstFactory.formalParameterList( 4289 AstTestFactory.formalParameterList(
4160 [AstFactory.simpleFormalParameter3("b")]))); 4290 [AstTestFactory.simpleFormalParameter3("b")])));
4161 } 4291 }
4162 4292
4163 void test_visitFieldFormalParameter_keyword() { 4293 void test_visitFieldFormalParameter_keyword() {
4164 _assertSource( 4294 _assertSource("var this.a",
4165 "var this.a", AstFactory.fieldFormalParameter(Keyword.VAR, null, "a")); 4295 AstTestFactory.fieldFormalParameter(Keyword.VAR, null, "a"));
4166 } 4296 }
4167 4297
4168 void test_visitFieldFormalParameter_keywordAndType() { 4298 void test_visitFieldFormalParameter_keywordAndType() {
4169 _assertSource( 4299 _assertSource(
4170 "final A this.a", 4300 "final A this.a",
4171 AstFactory.fieldFormalParameter( 4301 AstTestFactory.fieldFormalParameter(
4172 Keyword.FINAL, AstFactory.typeName4("A"), "a")); 4302 Keyword.FINAL, AstTestFactory.typeName4("A"), "a"));
4173 } 4303 }
4174 4304
4175 void test_visitFieldFormalParameter_type() { 4305 void test_visitFieldFormalParameter_type() {
4176 _assertSource("A this.a", 4306 _assertSource(
4177 AstFactory.fieldFormalParameter(null, AstFactory.typeName4("A"), "a")); 4307 "A this.a",
4308 AstTestFactory.fieldFormalParameter(
4309 null, AstTestFactory.typeName4("A"), "a"));
4178 } 4310 }
4179 4311
4180 void test_visitForEachStatement_declared() { 4312 void test_visitForEachStatement_declared() {
4181 _assertSource( 4313 _assertSource(
4182 "for (var a in b) {}", 4314 "for (var a in b) {}",
4183 AstFactory.forEachStatement(AstFactory.declaredIdentifier3("a"), 4315 AstTestFactory.forEachStatement(AstTestFactory.declaredIdentifier3("a"),
4184 AstFactory.identifier3("b"), AstFactory.block())); 4316 AstTestFactory.identifier3("b"), AstTestFactory.block()));
4185 } 4317 }
4186 4318
4187 void test_visitForEachStatement_variable() { 4319 void test_visitForEachStatement_variable() {
4188 _assertSource( 4320 _assertSource(
4189 "for (a in b) {}", 4321 "for (a in b) {}",
4190 new ForEachStatement.withReference( 4322 new ForEachStatement.withReference(
4191 null, 4323 null,
4192 TokenFactory.tokenFromKeyword(Keyword.FOR), 4324 TokenFactory.tokenFromKeyword(Keyword.FOR),
4193 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), 4325 TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
4194 AstFactory.identifier3("a"), 4326 AstTestFactory.identifier3("a"),
4195 TokenFactory.tokenFromKeyword(Keyword.IN), 4327 TokenFactory.tokenFromKeyword(Keyword.IN),
4196 AstFactory.identifier3("b"), 4328 AstTestFactory.identifier3("b"),
4197 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), 4329 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN),
4198 AstFactory.block())); 4330 AstTestFactory.block()));
4199 } 4331 }
4200 4332
4201 void test_visitForEachStatement_variable_await() { 4333 void test_visitForEachStatement_variable_await() {
4202 _assertSource( 4334 _assertSource(
4203 "await for (a in b) {}", 4335 "await for (a in b) {}",
4204 new ForEachStatement.withReference( 4336 new ForEachStatement.withReference(
4205 TokenFactory.tokenFromString("await"), 4337 TokenFactory.tokenFromString("await"),
4206 TokenFactory.tokenFromKeyword(Keyword.FOR), 4338 TokenFactory.tokenFromKeyword(Keyword.FOR),
4207 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), 4339 TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
4208 AstFactory.identifier3("a"), 4340 AstTestFactory.identifier3("a"),
4209 TokenFactory.tokenFromKeyword(Keyword.IN), 4341 TokenFactory.tokenFromKeyword(Keyword.IN),
4210 AstFactory.identifier3("b"), 4342 AstTestFactory.identifier3("b"),
4211 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), 4343 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN),
4212 AstFactory.block())); 4344 AstTestFactory.block()));
4213 } 4345 }
4214 4346
4215 void test_visitFormalParameterList_empty() { 4347 void test_visitFormalParameterList_empty() {
4216 _assertSource("()", AstFactory.formalParameterList()); 4348 _assertSource("()", AstTestFactory.formalParameterList());
4217 } 4349 }
4218 4350
4219 void test_visitFormalParameterList_n() { 4351 void test_visitFormalParameterList_n() {
4220 _assertSource( 4352 _assertSource(
4221 "({a : 0})", 4353 "({a : 0})",
4222 AstFactory.formalParameterList([ 4354 AstTestFactory.formalParameterList([
4223 AstFactory.namedFormalParameter( 4355 AstTestFactory.namedFormalParameter(
4224 AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0)) 4356 AstTestFactory.simpleFormalParameter3("a"),
4357 AstTestFactory.integer(0))
4225 ])); 4358 ]));
4226 } 4359 }
4227 4360
4228 void test_visitFormalParameterList_nn() { 4361 void test_visitFormalParameterList_nn() {
4229 _assertSource( 4362 _assertSource(
4230 "({a : 0, b : 1})", 4363 "({a : 0, b : 1})",
4231 AstFactory.formalParameterList([ 4364 AstTestFactory.formalParameterList([
4232 AstFactory.namedFormalParameter( 4365 AstTestFactory.namedFormalParameter(
4233 AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0)), 4366 AstTestFactory.simpleFormalParameter3("a"),
4234 AstFactory.namedFormalParameter( 4367 AstTestFactory.integer(0)),
4235 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)) 4368 AstTestFactory.namedFormalParameter(
4369 AstTestFactory.simpleFormalParameter3("b"),
4370 AstTestFactory.integer(1))
4236 ])); 4371 ]));
4237 } 4372 }
4238 4373
4239 void test_visitFormalParameterList_p() { 4374 void test_visitFormalParameterList_p() {
4240 _assertSource( 4375 _assertSource(
4241 "([a = 0])", 4376 "([a = 0])",
4242 AstFactory.formalParameterList([ 4377 AstTestFactory.formalParameterList([
4243 AstFactory.positionalFormalParameter( 4378 AstTestFactory.positionalFormalParameter(
4244 AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0)) 4379 AstTestFactory.simpleFormalParameter3("a"),
4380 AstTestFactory.integer(0))
4245 ])); 4381 ]));
4246 } 4382 }
4247 4383
4248 void test_visitFormalParameterList_pp() { 4384 void test_visitFormalParameterList_pp() {
4249 _assertSource( 4385 _assertSource(
4250 "([a = 0, b = 1])", 4386 "([a = 0, b = 1])",
4251 AstFactory.formalParameterList([ 4387 AstTestFactory.formalParameterList([
4252 AstFactory.positionalFormalParameter( 4388 AstTestFactory.positionalFormalParameter(
4253 AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0)), 4389 AstTestFactory.simpleFormalParameter3("a"),
4254 AstFactory.positionalFormalParameter( 4390 AstTestFactory.integer(0)),
4255 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)) 4391 AstTestFactory.positionalFormalParameter(
4392 AstTestFactory.simpleFormalParameter3("b"),
4393 AstTestFactory.integer(1))
4256 ])); 4394 ]));
4257 } 4395 }
4258 4396
4259 void test_visitFormalParameterList_r() { 4397 void test_visitFormalParameterList_r() {
4260 _assertSource( 4398 _assertSource(
4261 "(a)", 4399 "(a)",
4262 AstFactory 4400 AstTestFactory
4263 .formalParameterList([AstFactory.simpleFormalParameter3("a")])); 4401 .formalParameterList([AstTestFactory.simpleFormalParameter3("a")]));
4264 } 4402 }
4265 4403
4266 void test_visitFormalParameterList_rn() { 4404 void test_visitFormalParameterList_rn() {
4267 _assertSource( 4405 _assertSource(
4268 "(a, {b : 1})", 4406 "(a, {b : 1})",
4269 AstFactory.formalParameterList([ 4407 AstTestFactory.formalParameterList([
4270 AstFactory.simpleFormalParameter3("a"), 4408 AstTestFactory.simpleFormalParameter3("a"),
4271 AstFactory.namedFormalParameter( 4409 AstTestFactory.namedFormalParameter(
4272 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)) 4410 AstTestFactory.simpleFormalParameter3("b"),
4411 AstTestFactory.integer(1))
4273 ])); 4412 ]));
4274 } 4413 }
4275 4414
4276 void test_visitFormalParameterList_rnn() { 4415 void test_visitFormalParameterList_rnn() {
4277 _assertSource( 4416 _assertSource(
4278 "(a, {b : 1, c : 2})", 4417 "(a, {b : 1, c : 2})",
4279 AstFactory.formalParameterList([ 4418 AstTestFactory.formalParameterList([
4280 AstFactory.simpleFormalParameter3("a"), 4419 AstTestFactory.simpleFormalParameter3("a"),
4281 AstFactory.namedFormalParameter( 4420 AstTestFactory.namedFormalParameter(
4282 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)), 4421 AstTestFactory.simpleFormalParameter3("b"),
4283 AstFactory.namedFormalParameter( 4422 AstTestFactory.integer(1)),
4284 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(2)) 4423 AstTestFactory.namedFormalParameter(
4424 AstTestFactory.simpleFormalParameter3("c"),
4425 AstTestFactory.integer(2))
4285 ])); 4426 ]));
4286 } 4427 }
4287 4428
4288 void test_visitFormalParameterList_rp() { 4429 void test_visitFormalParameterList_rp() {
4289 _assertSource( 4430 _assertSource(
4290 "(a, [b = 1])", 4431 "(a, [b = 1])",
4291 AstFactory.formalParameterList([ 4432 AstTestFactory.formalParameterList([
4292 AstFactory.simpleFormalParameter3("a"), 4433 AstTestFactory.simpleFormalParameter3("a"),
4293 AstFactory.positionalFormalParameter( 4434 AstTestFactory.positionalFormalParameter(
4294 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)) 4435 AstTestFactory.simpleFormalParameter3("b"),
4436 AstTestFactory.integer(1))
4295 ])); 4437 ]));
4296 } 4438 }
4297 4439
4298 void test_visitFormalParameterList_rpp() { 4440 void test_visitFormalParameterList_rpp() {
4299 _assertSource( 4441 _assertSource(
4300 "(a, [b = 1, c = 2])", 4442 "(a, [b = 1, c = 2])",
4301 AstFactory.formalParameterList([ 4443 AstTestFactory.formalParameterList([
4302 AstFactory.simpleFormalParameter3("a"), 4444 AstTestFactory.simpleFormalParameter3("a"),
4303 AstFactory.positionalFormalParameter( 4445 AstTestFactory.positionalFormalParameter(
4304 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)), 4446 AstTestFactory.simpleFormalParameter3("b"),
4305 AstFactory.positionalFormalParameter( 4447 AstTestFactory.integer(1)),
4306 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(2)) 4448 AstTestFactory.positionalFormalParameter(
4449 AstTestFactory.simpleFormalParameter3("c"),
4450 AstTestFactory.integer(2))
4307 ])); 4451 ]));
4308 } 4452 }
4309 4453
4310 void test_visitFormalParameterList_rr() { 4454 void test_visitFormalParameterList_rr() {
4311 _assertSource( 4455 _assertSource(
4312 "(a, b)", 4456 "(a, b)",
4313 AstFactory.formalParameterList([ 4457 AstTestFactory.formalParameterList([
4314 AstFactory.simpleFormalParameter3("a"), 4458 AstTestFactory.simpleFormalParameter3("a"),
4315 AstFactory.simpleFormalParameter3("b") 4459 AstTestFactory.simpleFormalParameter3("b")
4316 ])); 4460 ]));
4317 } 4461 }
4318 4462
4319 void test_visitFormalParameterList_rrn() { 4463 void test_visitFormalParameterList_rrn() {
4320 _assertSource( 4464 _assertSource(
4321 "(a, b, {c : 3})", 4465 "(a, b, {c : 3})",
4322 AstFactory.formalParameterList([ 4466 AstTestFactory.formalParameterList([
4323 AstFactory.simpleFormalParameter3("a"), 4467 AstTestFactory.simpleFormalParameter3("a"),
4324 AstFactory.simpleFormalParameter3("b"), 4468 AstTestFactory.simpleFormalParameter3("b"),
4325 AstFactory.namedFormalParameter( 4469 AstTestFactory.namedFormalParameter(
4326 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3)) 4470 AstTestFactory.simpleFormalParameter3("c"),
4471 AstTestFactory.integer(3))
4327 ])); 4472 ]));
4328 } 4473 }
4329 4474
4330 void test_visitFormalParameterList_rrnn() { 4475 void test_visitFormalParameterList_rrnn() {
4331 _assertSource( 4476 _assertSource(
4332 "(a, b, {c : 3, d : 4})", 4477 "(a, b, {c : 3, d : 4})",
4333 AstFactory.formalParameterList([ 4478 AstTestFactory.formalParameterList([
4334 AstFactory.simpleFormalParameter3("a"), 4479 AstTestFactory.simpleFormalParameter3("a"),
4335 AstFactory.simpleFormalParameter3("b"), 4480 AstTestFactory.simpleFormalParameter3("b"),
4336 AstFactory.namedFormalParameter( 4481 AstTestFactory.namedFormalParameter(
4337 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3)), 4482 AstTestFactory.simpleFormalParameter3("c"),
4338 AstFactory.namedFormalParameter( 4483 AstTestFactory.integer(3)),
4339 AstFactory.simpleFormalParameter3("d"), AstFactory.integer(4)) 4484 AstTestFactory.namedFormalParameter(
4485 AstTestFactory.simpleFormalParameter3("d"),
4486 AstTestFactory.integer(4))
4340 ])); 4487 ]));
4341 } 4488 }
4342 4489
4343 void test_visitFormalParameterList_rrp() { 4490 void test_visitFormalParameterList_rrp() {
4344 _assertSource( 4491 _assertSource(
4345 "(a, b, [c = 3])", 4492 "(a, b, [c = 3])",
4346 AstFactory.formalParameterList([ 4493 AstTestFactory.formalParameterList([
4347 AstFactory.simpleFormalParameter3("a"), 4494 AstTestFactory.simpleFormalParameter3("a"),
4348 AstFactory.simpleFormalParameter3("b"), 4495 AstTestFactory.simpleFormalParameter3("b"),
4349 AstFactory.positionalFormalParameter( 4496 AstTestFactory.positionalFormalParameter(
4350 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3)) 4497 AstTestFactory.simpleFormalParameter3("c"),
4498 AstTestFactory.integer(3))
4351 ])); 4499 ]));
4352 } 4500 }
4353 4501
4354 void test_visitFormalParameterList_rrpp() { 4502 void test_visitFormalParameterList_rrpp() {
4355 _assertSource( 4503 _assertSource(
4356 "(a, b, [c = 3, d = 4])", 4504 "(a, b, [c = 3, d = 4])",
4357 AstFactory.formalParameterList([ 4505 AstTestFactory.formalParameterList([
4358 AstFactory.simpleFormalParameter3("a"), 4506 AstTestFactory.simpleFormalParameter3("a"),
4359 AstFactory.simpleFormalParameter3("b"), 4507 AstTestFactory.simpleFormalParameter3("b"),
4360 AstFactory.positionalFormalParameter( 4508 AstTestFactory.positionalFormalParameter(
4361 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3)), 4509 AstTestFactory.simpleFormalParameter3("c"),
4362 AstFactory.positionalFormalParameter( 4510 AstTestFactory.integer(3)),
4363 AstFactory.simpleFormalParameter3("d"), AstFactory.integer(4)) 4511 AstTestFactory.positionalFormalParameter(
4512 AstTestFactory.simpleFormalParameter3("d"),
4513 AstTestFactory.integer(4))
4364 ])); 4514 ]));
4365 } 4515 }
4366 4516
4367 void test_visitForStatement_c() { 4517 void test_visitForStatement_c() {
4368 _assertSource( 4518 _assertSource(
4369 "for (; c;) {}", 4519 "for (; c;) {}",
4370 AstFactory.forStatement( 4520 AstTestFactory.forStatement(null, AstTestFactory.identifier3("c"), null,
4371 null, AstFactory.identifier3("c"), null, AstFactory.block())); 4521 AstTestFactory.block()));
4372 } 4522 }
4373 4523
4374 void test_visitForStatement_cu() { 4524 void test_visitForStatement_cu() {
4375 _assertSource( 4525 _assertSource(
4376 "for (; c; u) {}", 4526 "for (; c; u) {}",
4377 AstFactory.forStatement(null, AstFactory.identifier3("c"), 4527 AstTestFactory.forStatement(null, AstTestFactory.identifier3("c"),
4378 [AstFactory.identifier3("u")], AstFactory.block())); 4528 [AstTestFactory.identifier3("u")], AstTestFactory.block()));
4379 } 4529 }
4380 4530
4381 void test_visitForStatement_e() { 4531 void test_visitForStatement_e() {
4382 _assertSource( 4532 _assertSource(
4383 "for (e;;) {}", 4533 "for (e;;) {}",
4384 AstFactory.forStatement( 4534 AstTestFactory.forStatement(AstTestFactory.identifier3("e"), null, null,
4385 AstFactory.identifier3("e"), null, null, AstFactory.block())); 4535 AstTestFactory.block()));
4386 } 4536 }
4387 4537
4388 void test_visitForStatement_ec() { 4538 void test_visitForStatement_ec() {
4389 _assertSource( 4539 _assertSource(
4390 "for (e; c;) {}", 4540 "for (e; c;) {}",
4391 AstFactory.forStatement(AstFactory.identifier3("e"), 4541 AstTestFactory.forStatement(AstTestFactory.identifier3("e"),
4392 AstFactory.identifier3("c"), null, AstFactory.block())); 4542 AstTestFactory.identifier3("c"), null, AstTestFactory.block()));
4393 } 4543 }
4394 4544
4395 void test_visitForStatement_ecu() { 4545 void test_visitForStatement_ecu() {
4396 _assertSource( 4546 _assertSource(
4397 "for (e; c; u) {}", 4547 "for (e; c; u) {}",
4398 AstFactory.forStatement( 4548 AstTestFactory.forStatement(
4399 AstFactory.identifier3("e"), 4549 AstTestFactory.identifier3("e"),
4400 AstFactory.identifier3("c"), 4550 AstTestFactory.identifier3("c"),
4401 [AstFactory.identifier3("u")], 4551 [AstTestFactory.identifier3("u")],
4402 AstFactory.block())); 4552 AstTestFactory.block()));
4403 } 4553 }
4404 4554
4405 void test_visitForStatement_eu() { 4555 void test_visitForStatement_eu() {
4406 _assertSource( 4556 _assertSource(
4407 "for (e;; u) {}", 4557 "for (e;; u) {}",
4408 AstFactory.forStatement(AstFactory.identifier3("e"), null, 4558 AstTestFactory.forStatement(AstTestFactory.identifier3("e"), null,
4409 [AstFactory.identifier3("u")], AstFactory.block())); 4559 [AstTestFactory.identifier3("u")], AstTestFactory.block()));
4410 } 4560 }
4411 4561
4412 void test_visitForStatement_i() { 4562 void test_visitForStatement_i() {
4413 _assertSource( 4563 _assertSource(
4414 "for (var i;;) {}", 4564 "for (var i;;) {}",
4415 AstFactory.forStatement2( 4565 AstTestFactory.forStatement2(
4416 AstFactory.variableDeclarationList2( 4566 AstTestFactory.variableDeclarationList2(
4417 Keyword.VAR, [AstFactory.variableDeclaration("i")]), 4567 Keyword.VAR, [AstTestFactory.variableDeclaration("i")]),
4418 null, 4568 null,
4419 null, 4569 null,
4420 AstFactory.block())); 4570 AstTestFactory.block()));
4421 } 4571 }
4422 4572
4423 void test_visitForStatement_ic() { 4573 void test_visitForStatement_ic() {
4424 _assertSource( 4574 _assertSource(
4425 "for (var i; c;) {}", 4575 "for (var i; c;) {}",
4426 AstFactory.forStatement2( 4576 AstTestFactory.forStatement2(
4427 AstFactory.variableDeclarationList2( 4577 AstTestFactory.variableDeclarationList2(
4428 Keyword.VAR, [AstFactory.variableDeclaration("i")]), 4578 Keyword.VAR, [AstTestFactory.variableDeclaration("i")]),
4429 AstFactory.identifier3("c"), 4579 AstTestFactory.identifier3("c"),
4430 null, 4580 null,
4431 AstFactory.block())); 4581 AstTestFactory.block()));
4432 } 4582 }
4433 4583
4434 void test_visitForStatement_icu() { 4584 void test_visitForStatement_icu() {
4435 _assertSource( 4585 _assertSource(
4436 "for (var i; c; u) {}", 4586 "for (var i; c; u) {}",
4437 AstFactory.forStatement2( 4587 AstTestFactory.forStatement2(
4438 AstFactory.variableDeclarationList2( 4588 AstTestFactory.variableDeclarationList2(
4439 Keyword.VAR, [AstFactory.variableDeclaration("i")]), 4589 Keyword.VAR, [AstTestFactory.variableDeclaration("i")]),
4440 AstFactory.identifier3("c"), 4590 AstTestFactory.identifier3("c"),
4441 [AstFactory.identifier3("u")], 4591 [AstTestFactory.identifier3("u")],
4442 AstFactory.block())); 4592 AstTestFactory.block()));
4443 } 4593 }
4444 4594
4445 void test_visitForStatement_iu() { 4595 void test_visitForStatement_iu() {
4446 _assertSource( 4596 _assertSource(
4447 "for (var i;; u) {}", 4597 "for (var i;; u) {}",
4448 AstFactory.forStatement2( 4598 AstTestFactory.forStatement2(
4449 AstFactory.variableDeclarationList2( 4599 AstTestFactory.variableDeclarationList2(
4450 Keyword.VAR, [AstFactory.variableDeclaration("i")]), 4600 Keyword.VAR, [AstTestFactory.variableDeclaration("i")]),
4451 null, 4601 null,
4452 [AstFactory.identifier3("u")], 4602 [AstTestFactory.identifier3("u")],
4453 AstFactory.block())); 4603 AstTestFactory.block()));
4454 } 4604 }
4455 4605
4456 void test_visitForStatement_u() { 4606 void test_visitForStatement_u() {
4457 _assertSource( 4607 _assertSource(
4458 "for (;; u) {}", 4608 "for (;; u) {}",
4459 AstFactory.forStatement( 4609 AstTestFactory.forStatement(null, null,
4460 null, null, [AstFactory.identifier3("u")], AstFactory.block())); 4610 [AstTestFactory.identifier3("u")], AstTestFactory.block()));
4461 } 4611 }
4462 4612
4463 void test_visitFunctionDeclaration_external() { 4613 void test_visitFunctionDeclaration_external() {
4464 FunctionDeclaration functionDeclaration = AstFactory.functionDeclaration( 4614 FunctionDeclaration functionDeclaration =
4465 null, 4615 AstTestFactory.functionDeclaration(
4466 null, 4616 null,
4467 "f", 4617 null,
4468 AstFactory.functionExpression2( 4618 "f",
4469 AstFactory.formalParameterList(), AstFactory.emptyFunctionBody())); 4619 AstTestFactory.functionExpression2(
4620 AstTestFactory.formalParameterList(),
4621 AstTestFactory.emptyFunctionBody()));
4470 functionDeclaration.externalKeyword = 4622 functionDeclaration.externalKeyword =
4471 TokenFactory.tokenFromKeyword(Keyword.EXTERNAL); 4623 TokenFactory.tokenFromKeyword(Keyword.EXTERNAL);
4472 _assertSource("external f();", functionDeclaration); 4624 _assertSource("external f();", functionDeclaration);
4473 } 4625 }
4474 4626
4475 void test_visitFunctionDeclaration_getter() { 4627 void test_visitFunctionDeclaration_getter() {
4476 _assertSource( 4628 _assertSource(
4477 "get f() {}", 4629 "get f() {}",
4478 AstFactory.functionDeclaration( 4630 AstTestFactory.functionDeclaration(
4479 null, Keyword.GET, "f", AstFactory.functionExpression())); 4631 null, Keyword.GET, "f", AstTestFactory.functionExpression()));
4480 } 4632 }
4481 4633
4482 void test_visitFunctionDeclaration_local_blockBody() { 4634 void test_visitFunctionDeclaration_local_blockBody() {
4483 FunctionDeclaration f = AstFactory.functionDeclaration( 4635 FunctionDeclaration f = AstTestFactory.functionDeclaration(
4484 null, null, "f", AstFactory.functionExpression()); 4636 null, null, "f", AstTestFactory.functionExpression());
4485 FunctionDeclarationStatement fStatement = 4637 FunctionDeclarationStatement fStatement =
4486 new FunctionDeclarationStatement(f); 4638 new FunctionDeclarationStatement(f);
4487 _assertSource( 4639 _assertSource(
4488 "main() {f() {} 42;}", 4640 "main() {f() {} 42;}",
4489 AstFactory.functionDeclaration( 4641 AstTestFactory.functionDeclaration(
4490 null, 4642 null,
4491 null, 4643 null,
4492 "main", 4644 "main",
4493 AstFactory.functionExpression2( 4645 AstTestFactory.functionExpression2(
4494 AstFactory.formalParameterList(), 4646 AstTestFactory.formalParameterList(),
4495 AstFactory.blockFunctionBody2([ 4647 AstTestFactory.blockFunctionBody2([
4496 fStatement, 4648 fStatement,
4497 AstFactory.expressionStatement(AstFactory.integer(42)) 4649 AstTestFactory.expressionStatement(AstTestFactory.integer(42))
4498 ])))); 4650 ]))));
4499 } 4651 }
4500 4652
4501 void test_visitFunctionDeclaration_local_expressionBody() { 4653 void test_visitFunctionDeclaration_local_expressionBody() {
4502 FunctionDeclaration f = AstFactory.functionDeclaration( 4654 FunctionDeclaration f = AstTestFactory.functionDeclaration(
4503 null, 4655 null,
4504 null, 4656 null,
4505 "f", 4657 "f",
4506 AstFactory.functionExpression2(AstFactory.formalParameterList(), 4658 AstTestFactory.functionExpression2(AstTestFactory.formalParameterList(),
4507 AstFactory.expressionFunctionBody(AstFactory.integer(1)))); 4659 AstTestFactory.expressionFunctionBody(AstTestFactory.integer(1))));
4508 FunctionDeclarationStatement fStatement = 4660 FunctionDeclarationStatement fStatement =
4509 new FunctionDeclarationStatement(f); 4661 new FunctionDeclarationStatement(f);
4510 _assertSource( 4662 _assertSource(
4511 "main() {f() => 1; 2;}", 4663 "main() {f() => 1; 2;}",
4512 AstFactory.functionDeclaration( 4664 AstTestFactory.functionDeclaration(
4513 null, 4665 null,
4514 null, 4666 null,
4515 "main", 4667 "main",
4516 AstFactory.functionExpression2( 4668 AstTestFactory.functionExpression2(
4517 AstFactory.formalParameterList(), 4669 AstTestFactory.formalParameterList(),
4518 AstFactory.blockFunctionBody2([ 4670 AstTestFactory.blockFunctionBody2([
4519 fStatement, 4671 fStatement,
4520 AstFactory.expressionStatement(AstFactory.integer(2)) 4672 AstTestFactory.expressionStatement(AstTestFactory.integer(2))
4521 ])))); 4673 ]))));
4522 } 4674 }
4523 4675
4524 void test_visitFunctionDeclaration_normal() { 4676 void test_visitFunctionDeclaration_normal() {
4525 _assertSource( 4677 _assertSource(
4526 "f() {}", 4678 "f() {}",
4527 AstFactory.functionDeclaration( 4679 AstTestFactory.functionDeclaration(
4528 null, null, "f", AstFactory.functionExpression())); 4680 null, null, "f", AstTestFactory.functionExpression()));
4529 } 4681 }
4530 4682
4531 void test_visitFunctionDeclaration_setter() { 4683 void test_visitFunctionDeclaration_setter() {
4532 _assertSource( 4684 _assertSource(
4533 "set f() {}", 4685 "set f() {}",
4534 AstFactory.functionDeclaration( 4686 AstTestFactory.functionDeclaration(
4535 null, Keyword.SET, "f", AstFactory.functionExpression())); 4687 null, Keyword.SET, "f", AstTestFactory.functionExpression()));
4536 } 4688 }
4537 4689
4538 void test_visitFunctionDeclaration_typeParameters() { 4690 void test_visitFunctionDeclaration_typeParameters() {
4539 _assertSource( 4691 _assertSource(
4540 "f<E>() {}", 4692 "f<E>() {}",
4541 AstFactory.functionDeclaration( 4693 AstTestFactory.functionDeclaration(
4542 null, 4694 null,
4543 null, 4695 null,
4544 "f", 4696 "f",
4545 AstFactory.functionExpression3( 4697 AstTestFactory.functionExpression3(
4546 AstFactory.typeParameterList(['E']), 4698 AstTestFactory.typeParameterList(['E']),
4547 AstFactory.formalParameterList(), 4699 AstTestFactory.formalParameterList(),
4548 AstFactory.blockFunctionBody2()))); 4700 AstTestFactory.blockFunctionBody2())));
4549 } 4701 }
4550 4702
4551 void test_visitFunctionDeclaration_withMetadata() { 4703 void test_visitFunctionDeclaration_withMetadata() {
4552 FunctionDeclaration declaration = AstFactory.functionDeclaration( 4704 FunctionDeclaration declaration = AstTestFactory.functionDeclaration(
4553 null, null, "f", AstFactory.functionExpression()); 4705 null, null, "f", AstTestFactory.functionExpression());
4554 declaration.metadata 4706 declaration.metadata.add(
4555 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 4707 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
4556 _assertSource("@deprecated f() {}", declaration); 4708 _assertSource("@deprecated f() {}", declaration);
4557 } 4709 }
4558 4710
4559 void test_visitFunctionDeclarationStatement() { 4711 void test_visitFunctionDeclarationStatement() {
4560 _assertSource( 4712 _assertSource(
4561 "f() {}", 4713 "f() {}",
4562 AstFactory.functionDeclarationStatement( 4714 AstTestFactory.functionDeclarationStatement(
4563 null, null, "f", AstFactory.functionExpression())); 4715 null, null, "f", AstTestFactory.functionExpression()));
4564 } 4716 }
4565 4717
4566 void test_visitFunctionExpression() { 4718 void test_visitFunctionExpression() {
4567 _assertSource("() {}", AstFactory.functionExpression()); 4719 _assertSource("() {}", AstTestFactory.functionExpression());
4568 } 4720 }
4569 4721
4570 void test_visitFunctionExpression_typeParameters() { 4722 void test_visitFunctionExpression_typeParameters() {
4571 _assertSource( 4723 _assertSource(
4572 "<E>() {}", 4724 "<E>() {}",
4573 AstFactory.functionExpression3(AstFactory.typeParameterList(['E']), 4725 AstTestFactory.functionExpression3(
4574 AstFactory.formalParameterList(), AstFactory.blockFunctionBody2())); 4726 AstTestFactory.typeParameterList(['E']),
4727 AstTestFactory.formalParameterList(),
4728 AstTestFactory.blockFunctionBody2()));
4575 } 4729 }
4576 4730
4577 void test_visitFunctionExpressionInvocation_minimal() { 4731 void test_visitFunctionExpressionInvocation_minimal() {
4578 _assertSource("f()", 4732 _assertSource(
4579 AstFactory.functionExpressionInvocation(AstFactory.identifier3("f"))); 4733 "f()",
4734 AstTestFactory
4735 .functionExpressionInvocation(AstTestFactory.identifier3("f")));
4580 } 4736 }
4581 4737
4582 void test_visitFunctionExpressionInvocation_typeArguments() { 4738 void test_visitFunctionExpressionInvocation_typeArguments() {
4583 _assertSource( 4739 _assertSource(
4584 "f<A>()", 4740 "f<A>()",
4585 AstFactory.functionExpressionInvocation2(AstFactory.identifier3("f"), 4741 AstTestFactory.functionExpressionInvocation2(
4586 AstFactory.typeArgumentList([AstFactory.typeName4('A')]))); 4742 AstTestFactory.identifier3("f"),
4743 AstTestFactory.typeArgumentList([AstTestFactory.typeName4('A')])));
4587 } 4744 }
4588 4745
4589 void test_visitFunctionTypeAlias_generic() { 4746 void test_visitFunctionTypeAlias_generic() {
4590 _assertSource( 4747 _assertSource(
4591 "typedef A F<B>();", 4748 "typedef A F<B>();",
4592 AstFactory.typeAlias( 4749 AstTestFactory.typeAlias(
4593 AstFactory.typeName4("A"), 4750 AstTestFactory.typeName4("A"),
4594 "F", 4751 "F",
4595 AstFactory.typeParameterList(["B"]), 4752 AstTestFactory.typeParameterList(["B"]),
4596 AstFactory.formalParameterList())); 4753 AstTestFactory.formalParameterList()));
4597 } 4754 }
4598 4755
4599 void test_visitFunctionTypeAlias_nonGeneric() { 4756 void test_visitFunctionTypeAlias_nonGeneric() {
4600 _assertSource( 4757 _assertSource(
4601 "typedef A F();", 4758 "typedef A F();",
4602 AstFactory.typeAlias(AstFactory.typeName4("A"), "F", null, 4759 AstTestFactory.typeAlias(AstTestFactory.typeName4("A"), "F", null,
4603 AstFactory.formalParameterList())); 4760 AstTestFactory.formalParameterList()));
4604 } 4761 }
4605 4762
4606 void test_visitFunctionTypeAlias_withMetadata() { 4763 void test_visitFunctionTypeAlias_withMetadata() {
4607 FunctionTypeAlias declaration = AstFactory.typeAlias( 4764 FunctionTypeAlias declaration = AstTestFactory.typeAlias(
4608 AstFactory.typeName4("A"), "F", null, AstFactory.formalParameterList()); 4765 AstTestFactory.typeName4("A"),
4609 declaration.metadata 4766 "F",
4610 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 4767 null,
4768 AstTestFactory.formalParameterList());
4769 declaration.metadata.add(
4770 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
4611 _assertSource("@deprecated typedef A F();", declaration); 4771 _assertSource("@deprecated typedef A F();", declaration);
4612 } 4772 }
4613 4773
4614 void test_visitFunctionTypedFormalParameter_annotation() { 4774 void test_visitFunctionTypedFormalParameter_annotation() {
4615 FunctionTypedFormalParameter parameter = 4775 FunctionTypedFormalParameter parameter =
4616 AstFactory.functionTypedFormalParameter(null, "f"); 4776 AstTestFactory.functionTypedFormalParameter(null, "f");
4617 parameter.metadata.add(AstFactory.annotation(AstFactory.identifier3("A"))); 4777 parameter.metadata
4778 .add(AstTestFactory.annotation(AstTestFactory.identifier3("A")));
4618 _assertSource('@A f()', parameter); 4779 _assertSource('@A f()', parameter);
4619 } 4780 }
4620 4781
4621 void test_visitFunctionTypedFormalParameter_noType() { 4782 void test_visitFunctionTypedFormalParameter_noType() {
4622 _assertSource("f()", AstFactory.functionTypedFormalParameter(null, "f")); 4783 _assertSource(
4784 "f()", AstTestFactory.functionTypedFormalParameter(null, "f"));
4623 } 4785 }
4624 4786
4625 void test_visitFunctionTypedFormalParameter_type() { 4787 void test_visitFunctionTypedFormalParameter_type() {
4626 _assertSource( 4788 _assertSource(
4627 "T f()", 4789 "T f()",
4628 AstFactory.functionTypedFormalParameter( 4790 AstTestFactory.functionTypedFormalParameter(
4629 AstFactory.typeName4("T"), "f")); 4791 AstTestFactory.typeName4("T"), "f"));
4630 } 4792 }
4631 4793
4632 void test_visitFunctionTypedFormalParameter_typeParameters() { 4794 void test_visitFunctionTypedFormalParameter_typeParameters() {
4633 _assertSource( 4795 _assertSource(
4634 "T f<E>()", 4796 "T f<E>()",
4635 new FunctionTypedFormalParameter( 4797 new FunctionTypedFormalParameter(
4636 null, 4798 null,
4637 null, 4799 null,
4638 AstFactory.typeName4("T"), 4800 AstTestFactory.typeName4("T"),
4639 AstFactory.identifier3('f'), 4801 AstTestFactory.identifier3('f'),
4640 AstFactory.typeParameterList(['E']), 4802 AstTestFactory.typeParameterList(['E']),
4641 AstFactory.formalParameterList([]))); 4803 AstTestFactory.formalParameterList([])));
4642 } 4804 }
4643 4805
4644 void test_visitIfStatement_withElse() { 4806 void test_visitIfStatement_withElse() {
4645 _assertSource( 4807 _assertSource(
4646 "if (c) {} else {}", 4808 "if (c) {} else {}",
4647 AstFactory.ifStatement2(AstFactory.identifier3("c"), AstFactory.block(), 4809 AstTestFactory.ifStatement2(AstTestFactory.identifier3("c"),
4648 AstFactory.block())); 4810 AstTestFactory.block(), AstTestFactory.block()));
4649 } 4811 }
4650 4812
4651 void test_visitIfStatement_withoutElse() { 4813 void test_visitIfStatement_withoutElse() {
4652 _assertSource( 4814 _assertSource(
4653 "if (c) {}", 4815 "if (c) {}",
4654 AstFactory.ifStatement( 4816 AstTestFactory.ifStatement(
4655 AstFactory.identifier3("c"), AstFactory.block())); 4817 AstTestFactory.identifier3("c"), AstTestFactory.block()));
4656 } 4818 }
4657 4819
4658 void test_visitImplementsClause_multiple() { 4820 void test_visitImplementsClause_multiple() {
4659 _assertSource( 4821 _assertSource(
4660 "implements A, B", 4822 "implements A, B",
4661 AstFactory.implementsClause( 4823 AstTestFactory.implementsClause(
4662 [AstFactory.typeName4("A"), AstFactory.typeName4("B")])); 4824 [AstTestFactory.typeName4("A"), AstTestFactory.typeName4("B")]));
4663 } 4825 }
4664 4826
4665 void test_visitImplementsClause_single() { 4827 void test_visitImplementsClause_single() {
4666 _assertSource("implements A", 4828 _assertSource("implements A",
4667 AstFactory.implementsClause([AstFactory.typeName4("A")])); 4829 AstTestFactory.implementsClause([AstTestFactory.typeName4("A")]));
4668 } 4830 }
4669 4831
4670 void test_visitImportDirective_combinator() { 4832 void test_visitImportDirective_combinator() {
4671 _assertSource( 4833 _assertSource(
4672 "import 'a.dart' show A;", 4834 "import 'a.dart' show A;",
4673 AstFactory.importDirective3("a.dart", null, [ 4835 AstTestFactory.importDirective3("a.dart", null, [
4674 AstFactory.showCombinator([AstFactory.identifier3("A")]) 4836 AstTestFactory.showCombinator([AstTestFactory.identifier3("A")])
4675 ])); 4837 ]));
4676 } 4838 }
4677 4839
4678 void test_visitImportDirective_combinators() { 4840 void test_visitImportDirective_combinators() {
4679 _assertSource( 4841 _assertSource(
4680 "import 'a.dart' show A hide B;", 4842 "import 'a.dart' show A hide B;",
4681 AstFactory.importDirective3("a.dart", null, [ 4843 AstTestFactory.importDirective3("a.dart", null, [
4682 AstFactory.showCombinator([AstFactory.identifier3("A")]), 4844 AstTestFactory.showCombinator([AstTestFactory.identifier3("A")]),
4683 AstFactory.hideCombinator([AstFactory.identifier3("B")]) 4845 AstTestFactory.hideCombinator([AstTestFactory.identifier3("B")])
4684 ])); 4846 ]));
4685 } 4847 }
4686 4848
4687 void test_visitImportDirective_deferred() { 4849 void test_visitImportDirective_deferred() {
4688 _assertSource("import 'a.dart' deferred as p;", 4850 _assertSource("import 'a.dart' deferred as p;",
4689 AstFactory.importDirective2("a.dart", true, "p")); 4851 AstTestFactory.importDirective2("a.dart", true, "p"));
4690 } 4852 }
4691 4853
4692 void test_visitImportDirective_minimal() { 4854 void test_visitImportDirective_minimal() {
4693 _assertSource( 4855 _assertSource(
4694 "import 'a.dart';", AstFactory.importDirective3("a.dart", null)); 4856 "import 'a.dart';", AstTestFactory.importDirective3("a.dart", null));
4695 } 4857 }
4696 4858
4697 void test_visitImportDirective_prefix() { 4859 void test_visitImportDirective_prefix() {
4698 _assertSource( 4860 _assertSource("import 'a.dart' as p;",
4699 "import 'a.dart' as p;", AstFactory.importDirective3("a.dart", "p")); 4861 AstTestFactory.importDirective3("a.dart", "p"));
4700 } 4862 }
4701 4863
4702 void test_visitImportDirective_prefix_combinator() { 4864 void test_visitImportDirective_prefix_combinator() {
4703 _assertSource( 4865 _assertSource(
4704 "import 'a.dart' as p show A;", 4866 "import 'a.dart' as p show A;",
4705 AstFactory.importDirective3("a.dart", "p", [ 4867 AstTestFactory.importDirective3("a.dart", "p", [
4706 AstFactory.showCombinator([AstFactory.identifier3("A")]) 4868 AstTestFactory.showCombinator([AstTestFactory.identifier3("A")])
4707 ])); 4869 ]));
4708 } 4870 }
4709 4871
4710 void test_visitImportDirective_prefix_combinators() { 4872 void test_visitImportDirective_prefix_combinators() {
4711 _assertSource( 4873 _assertSource(
4712 "import 'a.dart' as p show A hide B;", 4874 "import 'a.dart' as p show A hide B;",
4713 AstFactory.importDirective3("a.dart", "p", [ 4875 AstTestFactory.importDirective3("a.dart", "p", [
4714 AstFactory.showCombinator([AstFactory.identifier3("A")]), 4876 AstTestFactory.showCombinator([AstTestFactory.identifier3("A")]),
4715 AstFactory.hideCombinator([AstFactory.identifier3("B")]) 4877 AstTestFactory.hideCombinator([AstTestFactory.identifier3("B")])
4716 ])); 4878 ]));
4717 } 4879 }
4718 4880
4719 void test_visitImportDirective_withMetadata() { 4881 void test_visitImportDirective_withMetadata() {
4720 ImportDirective directive = AstFactory.importDirective3("a.dart", null); 4882 ImportDirective directive = AstTestFactory.importDirective3("a.dart", null);
4721 directive.metadata 4883 directive.metadata.add(
4722 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 4884 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
4723 _assertSource("@deprecated import 'a.dart';", directive); 4885 _assertSource("@deprecated import 'a.dart';", directive);
4724 } 4886 }
4725 4887
4726 void test_visitImportHideCombinator_multiple() { 4888 void test_visitImportHideCombinator_multiple() {
4727 _assertSource( 4889 _assertSource(
4728 "hide a, b", 4890 "hide a, b",
4729 AstFactory.hideCombinator( 4891 AstTestFactory.hideCombinator([
4730 [AstFactory.identifier3("a"), AstFactory.identifier3("b")])); 4892 AstTestFactory.identifier3("a"),
4893 AstTestFactory.identifier3("b")
4894 ]));
4731 } 4895 }
4732 4896
4733 void test_visitImportHideCombinator_single() { 4897 void test_visitImportHideCombinator_single() {
4734 _assertSource( 4898 _assertSource("hide a",
4735 "hide a", AstFactory.hideCombinator([AstFactory.identifier3("a")])); 4899 AstTestFactory.hideCombinator([AstTestFactory.identifier3("a")]));
4736 } 4900 }
4737 4901
4738 void test_visitImportShowCombinator_multiple() { 4902 void test_visitImportShowCombinator_multiple() {
4739 _assertSource( 4903 _assertSource(
4740 "show a, b", 4904 "show a, b",
4741 AstFactory.showCombinator( 4905 AstTestFactory.showCombinator([
4742 [AstFactory.identifier3("a"), AstFactory.identifier3("b")])); 4906 AstTestFactory.identifier3("a"),
4907 AstTestFactory.identifier3("b")
4908 ]));
4743 } 4909 }
4744 4910
4745 void test_visitImportShowCombinator_single() { 4911 void test_visitImportShowCombinator_single() {
4746 _assertSource( 4912 _assertSource("show a",
4747 "show a", AstFactory.showCombinator([AstFactory.identifier3("a")])); 4913 AstTestFactory.showCombinator([AstTestFactory.identifier3("a")]));
4748 } 4914 }
4749 4915
4750 void test_visitIndexExpression() { 4916 void test_visitIndexExpression() {
4751 _assertSource( 4917 _assertSource(
4752 "a[i]", 4918 "a[i]",
4753 AstFactory.indexExpression( 4919 AstTestFactory.indexExpression(
4754 AstFactory.identifier3("a"), AstFactory.identifier3("i"))); 4920 AstTestFactory.identifier3("a"), AstTestFactory.identifier3("i")));
4755 } 4921 }
4756 4922
4757 void test_visitInstanceCreationExpression_const() { 4923 void test_visitInstanceCreationExpression_const() {
4758 _assertSource( 4924 _assertSource(
4759 "const C()", 4925 "const C()",
4760 AstFactory.instanceCreationExpression2( 4926 AstTestFactory.instanceCreationExpression2(
4761 Keyword.CONST, AstFactory.typeName4("C"))); 4927 Keyword.CONST, AstTestFactory.typeName4("C")));
4762 } 4928 }
4763 4929
4764 void test_visitInstanceCreationExpression_named() { 4930 void test_visitInstanceCreationExpression_named() {
4765 _assertSource( 4931 _assertSource(
4766 "new C.c()", 4932 "new C.c()",
4767 AstFactory.instanceCreationExpression3( 4933 AstTestFactory.instanceCreationExpression3(
4768 Keyword.NEW, AstFactory.typeName4("C"), "c")); 4934 Keyword.NEW, AstTestFactory.typeName4("C"), "c"));
4769 } 4935 }
4770 4936
4771 void test_visitInstanceCreationExpression_unnamed() { 4937 void test_visitInstanceCreationExpression_unnamed() {
4772 _assertSource( 4938 _assertSource(
4773 "new C()", 4939 "new C()",
4774 AstFactory.instanceCreationExpression2( 4940 AstTestFactory.instanceCreationExpression2(
4775 Keyword.NEW, AstFactory.typeName4("C"))); 4941 Keyword.NEW, AstTestFactory.typeName4("C")));
4776 } 4942 }
4777 4943
4778 void test_visitIntegerLiteral() { 4944 void test_visitIntegerLiteral() {
4779 _assertSource("42", AstFactory.integer(42)); 4945 _assertSource("42", AstTestFactory.integer(42));
4780 } 4946 }
4781 4947
4782 void test_visitInterpolationExpression_expression() { 4948 void test_visitInterpolationExpression_expression() {
4783 _assertSource("\${a}", 4949 _assertSource(
4784 AstFactory.interpolationExpression(AstFactory.identifier3("a"))); 4950 "\${a}",
4951 AstTestFactory
4952 .interpolationExpression(AstTestFactory.identifier3("a")));
4785 } 4953 }
4786 4954
4787 void test_visitInterpolationExpression_identifier() { 4955 void test_visitInterpolationExpression_identifier() {
4788 _assertSource("\$a", AstFactory.interpolationExpression2("a")); 4956 _assertSource("\$a", AstTestFactory.interpolationExpression2("a"));
4789 } 4957 }
4790 4958
4791 void test_visitInterpolationString() { 4959 void test_visitInterpolationString() {
4792 _assertSource("'x", AstFactory.interpolationString("'x", "x")); 4960 _assertSource("'x", AstTestFactory.interpolationString("'x", "x"));
4793 } 4961 }
4794 4962
4795 void test_visitIsExpression_negated() { 4963 void test_visitIsExpression_negated() {
4796 _assertSource( 4964 _assertSource(
4797 "a is! C", 4965 "a is! C",
4798 AstFactory.isExpression( 4966 AstTestFactory.isExpression(AstTestFactory.identifier3("a"), true,
4799 AstFactory.identifier3("a"), true, AstFactory.typeName4("C"))); 4967 AstTestFactory.typeName4("C")));
4800 } 4968 }
4801 4969
4802 void test_visitIsExpression_normal() { 4970 void test_visitIsExpression_normal() {
4803 _assertSource( 4971 _assertSource(
4804 "a is C", 4972 "a is C",
4805 AstFactory.isExpression( 4973 AstTestFactory.isExpression(AstTestFactory.identifier3("a"), false,
4806 AstFactory.identifier3("a"), false, AstFactory.typeName4("C"))); 4974 AstTestFactory.typeName4("C")));
4807 } 4975 }
4808 4976
4809 void test_visitLabel() { 4977 void test_visitLabel() {
4810 _assertSource("a:", AstFactory.label2("a")); 4978 _assertSource("a:", AstTestFactory.label2("a"));
4811 } 4979 }
4812 4980
4813 void test_visitLabeledStatement_multiple() { 4981 void test_visitLabeledStatement_multiple() {
4814 _assertSource( 4982 _assertSource(
4815 "a: b: return;", 4983 "a: b: return;",
4816 AstFactory.labeledStatement( 4984 AstTestFactory.labeledStatement(
4817 [AstFactory.label2("a"), AstFactory.label2("b")], 4985 [AstTestFactory.label2("a"), AstTestFactory.label2("b")],
4818 AstFactory.returnStatement())); 4986 AstTestFactory.returnStatement()));
4819 } 4987 }
4820 4988
4821 void test_visitLabeledStatement_single() { 4989 void test_visitLabeledStatement_single() {
4822 _assertSource( 4990 _assertSource(
4823 "a: return;", 4991 "a: return;",
4824 AstFactory.labeledStatement( 4992 AstTestFactory.labeledStatement(
4825 [AstFactory.label2("a")], AstFactory.returnStatement())); 4993 [AstTestFactory.label2("a")], AstTestFactory.returnStatement()));
4826 } 4994 }
4827 4995
4828 void test_visitLibraryDirective() { 4996 void test_visitLibraryDirective() {
4829 _assertSource("library l;", AstFactory.libraryDirective2("l")); 4997 _assertSource("library l;", AstTestFactory.libraryDirective2("l"));
4830 } 4998 }
4831 4999
4832 void test_visitLibraryDirective_withMetadata() { 5000 void test_visitLibraryDirective_withMetadata() {
4833 LibraryDirective directive = AstFactory.libraryDirective2("l"); 5001 LibraryDirective directive = AstTestFactory.libraryDirective2("l");
4834 directive.metadata 5002 directive.metadata.add(
4835 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 5003 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
4836 _assertSource("@deprecated library l;", directive); 5004 _assertSource("@deprecated library l;", directive);
4837 } 5005 }
4838 5006
4839 void test_visitLibraryIdentifier_multiple() { 5007 void test_visitLibraryIdentifier_multiple() {
4840 _assertSource( 5008 _assertSource(
4841 "a.b.c", 5009 "a.b.c",
4842 AstFactory.libraryIdentifier([ 5010 AstTestFactory.libraryIdentifier([
4843 AstFactory.identifier3("a"), 5011 AstTestFactory.identifier3("a"),
4844 AstFactory.identifier3("b"), 5012 AstTestFactory.identifier3("b"),
4845 AstFactory.identifier3("c") 5013 AstTestFactory.identifier3("c")
4846 ])); 5014 ]));
4847 } 5015 }
4848 5016
4849 void test_visitLibraryIdentifier_single() { 5017 void test_visitLibraryIdentifier_single() {
4850 _assertSource( 5018 _assertSource("a",
4851 "a", AstFactory.libraryIdentifier([AstFactory.identifier3("a")])); 5019 AstTestFactory.libraryIdentifier([AstTestFactory.identifier3("a")]));
4852 } 5020 }
4853 5021
4854 void test_visitListLiteral_const() { 5022 void test_visitListLiteral_const() {
4855 _assertSource("const []", AstFactory.listLiteral2(Keyword.CONST, null)); 5023 _assertSource("const []", AstTestFactory.listLiteral2(Keyword.CONST, null));
4856 } 5024 }
4857 5025
4858 void test_visitListLiteral_empty() { 5026 void test_visitListLiteral_empty() {
4859 _assertSource("[]", AstFactory.listLiteral()); 5027 _assertSource("[]", AstTestFactory.listLiteral());
4860 } 5028 }
4861 5029
4862 void test_visitListLiteral_nonEmpty() { 5030 void test_visitListLiteral_nonEmpty() {
4863 _assertSource( 5031 _assertSource(
4864 "[a, b, c]", 5032 "[a, b, c]",
4865 AstFactory.listLiteral([ 5033 AstTestFactory.listLiteral([
4866 AstFactory.identifier3("a"), 5034 AstTestFactory.identifier3("a"),
4867 AstFactory.identifier3("b"), 5035 AstTestFactory.identifier3("b"),
4868 AstFactory.identifier3("c") 5036 AstTestFactory.identifier3("c")
4869 ])); 5037 ]));
4870 } 5038 }
4871 5039
4872 void test_visitMapLiteral_const() { 5040 void test_visitMapLiteral_const() {
4873 _assertSource("const {}", AstFactory.mapLiteral(Keyword.CONST, null)); 5041 _assertSource("const {}", AstTestFactory.mapLiteral(Keyword.CONST, null));
4874 } 5042 }
4875 5043
4876 void test_visitMapLiteral_empty() { 5044 void test_visitMapLiteral_empty() {
4877 _assertSource("{}", AstFactory.mapLiteral2()); 5045 _assertSource("{}", AstTestFactory.mapLiteral2());
4878 } 5046 }
4879 5047
4880 void test_visitMapLiteral_nonEmpty() { 5048 void test_visitMapLiteral_nonEmpty() {
4881 _assertSource( 5049 _assertSource(
4882 "{'a' : a, 'b' : b, 'c' : c}", 5050 "{'a' : a, 'b' : b, 'c' : c}",
4883 AstFactory.mapLiteral2([ 5051 AstTestFactory.mapLiteral2([
4884 AstFactory.mapLiteralEntry("a", AstFactory.identifier3("a")), 5052 AstTestFactory.mapLiteralEntry("a", AstTestFactory.identifier3("a")),
4885 AstFactory.mapLiteralEntry("b", AstFactory.identifier3("b")), 5053 AstTestFactory.mapLiteralEntry("b", AstTestFactory.identifier3("b")),
4886 AstFactory.mapLiteralEntry("c", AstFactory.identifier3("c")) 5054 AstTestFactory.mapLiteralEntry("c", AstTestFactory.identifier3("c"))
4887 ])); 5055 ]));
4888 } 5056 }
4889 5057
4890 void test_visitMapLiteralEntry() { 5058 void test_visitMapLiteralEntry() {
4891 _assertSource("'a' : b", 5059 _assertSource("'a' : b",
4892 AstFactory.mapLiteralEntry("a", AstFactory.identifier3("b"))); 5060 AstTestFactory.mapLiteralEntry("a", AstTestFactory.identifier3("b")));
4893 } 5061 }
4894 5062
4895 void test_visitMethodDeclaration_external() { 5063 void test_visitMethodDeclaration_external() {
4896 _assertSource( 5064 _assertSource(
4897 "external m();", 5065 "external m();",
4898 AstFactory.methodDeclaration(null, null, null, null, 5066 AstTestFactory.methodDeclaration(
4899 AstFactory.identifier3("m"), AstFactory.formalParameterList())); 5067 null,
5068 null,
5069 null,
5070 null,
5071 AstTestFactory.identifier3("m"),
5072 AstTestFactory.formalParameterList()));
4900 } 5073 }
4901 5074
4902 void test_visitMethodDeclaration_external_returnType() { 5075 void test_visitMethodDeclaration_external_returnType() {
4903 _assertSource( 5076 _assertSource(
4904 "external T m();", 5077 "external T m();",
4905 AstFactory.methodDeclaration( 5078 AstTestFactory.methodDeclaration(
4906 null, 5079 null,
4907 AstFactory.typeName4("T"), 5080 AstTestFactory.typeName4("T"),
4908 null, 5081 null,
4909 null, 5082 null,
4910 AstFactory.identifier3("m"), 5083 AstTestFactory.identifier3("m"),
4911 AstFactory.formalParameterList())); 5084 AstTestFactory.formalParameterList()));
4912 } 5085 }
4913 5086
4914 void test_visitMethodDeclaration_getter() { 5087 void test_visitMethodDeclaration_getter() {
4915 _assertSource( 5088 _assertSource(
4916 "get m {}", 5089 "get m {}",
4917 AstFactory.methodDeclaration2( 5090 AstTestFactory.methodDeclaration2(
4918 null, 5091 null,
4919 null, 5092 null,
4920 Keyword.GET, 5093 Keyword.GET,
4921 null, 5094 null,
4922 AstFactory.identifier3("m"), 5095 AstTestFactory.identifier3("m"),
4923 null, 5096 null,
4924 AstFactory.blockFunctionBody2())); 5097 AstTestFactory.blockFunctionBody2()));
4925 } 5098 }
4926 5099
4927 void test_visitMethodDeclaration_getter_returnType() { 5100 void test_visitMethodDeclaration_getter_returnType() {
4928 _assertSource( 5101 _assertSource(
4929 "T get m {}", 5102 "T get m {}",
4930 AstFactory.methodDeclaration2( 5103 AstTestFactory.methodDeclaration2(
4931 null, 5104 null,
4932 AstFactory.typeName4("T"), 5105 AstTestFactory.typeName4("T"),
4933 Keyword.GET, 5106 Keyword.GET,
4934 null, 5107 null,
4935 AstFactory.identifier3("m"), 5108 AstTestFactory.identifier3("m"),
4936 null, 5109 null,
4937 AstFactory.blockFunctionBody2())); 5110 AstTestFactory.blockFunctionBody2()));
4938 } 5111 }
4939 5112
4940 void test_visitMethodDeclaration_getter_seturnType() { 5113 void test_visitMethodDeclaration_getter_seturnType() {
4941 _assertSource( 5114 _assertSource(
4942 "T set m(var v) {}", 5115 "T set m(var v) {}",
4943 AstFactory.methodDeclaration2( 5116 AstTestFactory.methodDeclaration2(
4944 null, 5117 null,
4945 AstFactory.typeName4("T"), 5118 AstTestFactory.typeName4("T"),
4946 Keyword.SET, 5119 Keyword.SET,
4947 null, 5120 null,
4948 AstFactory.identifier3("m"), 5121 AstTestFactory.identifier3("m"),
4949 AstFactory.formalParameterList( 5122 AstTestFactory.formalParameterList(
4950 [AstFactory.simpleFormalParameter(Keyword.VAR, "v")]), 5123 [AstTestFactory.simpleFormalParameter(Keyword.VAR, "v")]),
4951 AstFactory.blockFunctionBody2())); 5124 AstTestFactory.blockFunctionBody2()));
4952 } 5125 }
4953 5126
4954 void test_visitMethodDeclaration_minimal() { 5127 void test_visitMethodDeclaration_minimal() {
4955 _assertSource( 5128 _assertSource(
4956 "m() {}", 5129 "m() {}",
4957 AstFactory.methodDeclaration2( 5130 AstTestFactory.methodDeclaration2(
4958 null, 5131 null,
4959 null, 5132 null,
4960 null, 5133 null,
4961 null, 5134 null,
4962 AstFactory.identifier3("m"), 5135 AstTestFactory.identifier3("m"),
4963 AstFactory.formalParameterList(), 5136 AstTestFactory.formalParameterList(),
4964 AstFactory.blockFunctionBody2())); 5137 AstTestFactory.blockFunctionBody2()));
4965 } 5138 }
4966 5139
4967 void test_visitMethodDeclaration_multipleParameters() { 5140 void test_visitMethodDeclaration_multipleParameters() {
4968 _assertSource( 5141 _assertSource(
4969 "m(var a, var b) {}", 5142 "m(var a, var b) {}",
4970 AstFactory.methodDeclaration2( 5143 AstTestFactory.methodDeclaration2(
4971 null, 5144 null,
4972 null, 5145 null,
4973 null, 5146 null,
4974 null, 5147 null,
4975 AstFactory.identifier3("m"), 5148 AstTestFactory.identifier3("m"),
4976 AstFactory.formalParameterList([ 5149 AstTestFactory.formalParameterList([
4977 AstFactory.simpleFormalParameter(Keyword.VAR, "a"), 5150 AstTestFactory.simpleFormalParameter(Keyword.VAR, "a"),
4978 AstFactory.simpleFormalParameter(Keyword.VAR, "b") 5151 AstTestFactory.simpleFormalParameter(Keyword.VAR, "b")
4979 ]), 5152 ]),
4980 AstFactory.blockFunctionBody2())); 5153 AstTestFactory.blockFunctionBody2()));
4981 } 5154 }
4982 5155
4983 void test_visitMethodDeclaration_operator() { 5156 void test_visitMethodDeclaration_operator() {
4984 _assertSource( 5157 _assertSource(
4985 "operator +() {}", 5158 "operator +() {}",
4986 AstFactory.methodDeclaration2( 5159 AstTestFactory.methodDeclaration2(
4987 null, 5160 null,
4988 null, 5161 null,
4989 null, 5162 null,
4990 Keyword.OPERATOR, 5163 Keyword.OPERATOR,
4991 AstFactory.identifier3("+"), 5164 AstTestFactory.identifier3("+"),
4992 AstFactory.formalParameterList(), 5165 AstTestFactory.formalParameterList(),
4993 AstFactory.blockFunctionBody2())); 5166 AstTestFactory.blockFunctionBody2()));
4994 } 5167 }
4995 5168
4996 void test_visitMethodDeclaration_operator_returnType() { 5169 void test_visitMethodDeclaration_operator_returnType() {
4997 _assertSource( 5170 _assertSource(
4998 "T operator +() {}", 5171 "T operator +() {}",
4999 AstFactory.methodDeclaration2( 5172 AstTestFactory.methodDeclaration2(
5000 null, 5173 null,
5001 AstFactory.typeName4("T"), 5174 AstTestFactory.typeName4("T"),
5002 null, 5175 null,
5003 Keyword.OPERATOR, 5176 Keyword.OPERATOR,
5004 AstFactory.identifier3("+"), 5177 AstTestFactory.identifier3("+"),
5005 AstFactory.formalParameterList(), 5178 AstTestFactory.formalParameterList(),
5006 AstFactory.blockFunctionBody2())); 5179 AstTestFactory.blockFunctionBody2()));
5007 } 5180 }
5008 5181
5009 void test_visitMethodDeclaration_returnType() { 5182 void test_visitMethodDeclaration_returnType() {
5010 _assertSource( 5183 _assertSource(
5011 "T m() {}", 5184 "T m() {}",
5012 AstFactory.methodDeclaration2( 5185 AstTestFactory.methodDeclaration2(
5013 null, 5186 null,
5014 AstFactory.typeName4("T"), 5187 AstTestFactory.typeName4("T"),
5015 null, 5188 null,
5016 null, 5189 null,
5017 AstFactory.identifier3("m"), 5190 AstTestFactory.identifier3("m"),
5018 AstFactory.formalParameterList(), 5191 AstTestFactory.formalParameterList(),
5019 AstFactory.blockFunctionBody2())); 5192 AstTestFactory.blockFunctionBody2()));
5020 } 5193 }
5021 5194
5022 void test_visitMethodDeclaration_setter() { 5195 void test_visitMethodDeclaration_setter() {
5023 _assertSource( 5196 _assertSource(
5024 "set m(var v) {}", 5197 "set m(var v) {}",
5025 AstFactory.methodDeclaration2( 5198 AstTestFactory.methodDeclaration2(
5026 null, 5199 null,
5027 null, 5200 null,
5028 Keyword.SET, 5201 Keyword.SET,
5029 null, 5202 null,
5030 AstFactory.identifier3("m"), 5203 AstTestFactory.identifier3("m"),
5031 AstFactory.formalParameterList( 5204 AstTestFactory.formalParameterList(
5032 [AstFactory.simpleFormalParameter(Keyword.VAR, "v")]), 5205 [AstTestFactory.simpleFormalParameter(Keyword.VAR, "v")]),
5033 AstFactory.blockFunctionBody2())); 5206 AstTestFactory.blockFunctionBody2()));
5034 } 5207 }
5035 5208
5036 void test_visitMethodDeclaration_static() { 5209 void test_visitMethodDeclaration_static() {
5037 _assertSource( 5210 _assertSource(
5038 "static m() {}", 5211 "static m() {}",
5039 AstFactory.methodDeclaration2( 5212 AstTestFactory.methodDeclaration2(
5040 Keyword.STATIC, 5213 Keyword.STATIC,
5041 null, 5214 null,
5042 null, 5215 null,
5043 null, 5216 null,
5044 AstFactory.identifier3("m"), 5217 AstTestFactory.identifier3("m"),
5045 AstFactory.formalParameterList(), 5218 AstTestFactory.formalParameterList(),
5046 AstFactory.blockFunctionBody2())); 5219 AstTestFactory.blockFunctionBody2()));
5047 } 5220 }
5048 5221
5049 void test_visitMethodDeclaration_static_returnType() { 5222 void test_visitMethodDeclaration_static_returnType() {
5050 _assertSource( 5223 _assertSource(
5051 "static T m() {}", 5224 "static T m() {}",
5052 AstFactory.methodDeclaration2( 5225 AstTestFactory.methodDeclaration2(
5053 Keyword.STATIC, 5226 Keyword.STATIC,
5054 AstFactory.typeName4("T"), 5227 AstTestFactory.typeName4("T"),
5055 null, 5228 null,
5056 null, 5229 null,
5057 AstFactory.identifier3("m"), 5230 AstTestFactory.identifier3("m"),
5058 AstFactory.formalParameterList(), 5231 AstTestFactory.formalParameterList(),
5059 AstFactory.blockFunctionBody2())); 5232 AstTestFactory.blockFunctionBody2()));
5060 } 5233 }
5061 5234
5062 void test_visitMethodDeclaration_typeParameters() { 5235 void test_visitMethodDeclaration_typeParameters() {
5063 _assertSource( 5236 _assertSource(
5064 "m<E>() {}", 5237 "m<E>() {}",
5065 AstFactory.methodDeclaration3( 5238 AstTestFactory.methodDeclaration3(
5066 null, 5239 null,
5067 null, 5240 null,
5068 null, 5241 null,
5069 null, 5242 null,
5070 AstFactory.identifier3("m"), 5243 AstTestFactory.identifier3("m"),
5071 AstFactory.typeParameterList(['E']), 5244 AstTestFactory.typeParameterList(['E']),
5072 AstFactory.formalParameterList(), 5245 AstTestFactory.formalParameterList(),
5073 AstFactory.blockFunctionBody2())); 5246 AstTestFactory.blockFunctionBody2()));
5074 } 5247 }
5075 5248
5076 void test_visitMethodDeclaration_withMetadata() { 5249 void test_visitMethodDeclaration_withMetadata() {
5077 MethodDeclaration declaration = AstFactory.methodDeclaration2( 5250 MethodDeclaration declaration = AstTestFactory.methodDeclaration2(
5078 null, 5251 null,
5079 null, 5252 null,
5080 null, 5253 null,
5081 null, 5254 null,
5082 AstFactory.identifier3("m"), 5255 AstTestFactory.identifier3("m"),
5083 AstFactory.formalParameterList(), 5256 AstTestFactory.formalParameterList(),
5084 AstFactory.blockFunctionBody2()); 5257 AstTestFactory.blockFunctionBody2());
5085 declaration.metadata 5258 declaration.metadata.add(
5086 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 5259 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
5087 _assertSource("@deprecated m() {}", declaration); 5260 _assertSource("@deprecated m() {}", declaration);
5088 } 5261 }
5089 5262
5090 void test_visitMethodInvocation_conditional() { 5263 void test_visitMethodInvocation_conditional() {
5091 _assertSource( 5264 _assertSource(
5092 "t?.m()", 5265 "t?.m()",
5093 AstFactory.methodInvocation( 5266 AstTestFactory.methodInvocation(AstTestFactory.identifier3("t"), "m",
5094 AstFactory.identifier3("t"), "m", null, TokenType.QUESTION_PERIOD)); 5267 null, TokenType.QUESTION_PERIOD));
5095 } 5268 }
5096 5269
5097 void test_visitMethodInvocation_noTarget() { 5270 void test_visitMethodInvocation_noTarget() {
5098 _assertSource("m()", AstFactory.methodInvocation2("m")); 5271 _assertSource("m()", AstTestFactory.methodInvocation2("m"));
5099 } 5272 }
5100 5273
5101 void test_visitMethodInvocation_target() { 5274 void test_visitMethodInvocation_target() {
5102 _assertSource( 5275 _assertSource("t.m()",
5103 "t.m()", AstFactory.methodInvocation(AstFactory.identifier3("t"), "m")); 5276 AstTestFactory.methodInvocation(AstTestFactory.identifier3("t"), "m"));
5104 } 5277 }
5105 5278
5106 void test_visitMethodInvocation_typeArguments() { 5279 void test_visitMethodInvocation_typeArguments() {
5107 _assertSource( 5280 _assertSource(
5108 "m<A>()", 5281 "m<A>()",
5109 AstFactory.methodInvocation3(null, "m", 5282 AstTestFactory.methodInvocation3(null, "m",
5110 AstFactory.typeArgumentList([AstFactory.typeName4('A')]))); 5283 AstTestFactory.typeArgumentList([AstTestFactory.typeName4('A')])));
5111 } 5284 }
5112 5285
5113 void test_visitNamedExpression() { 5286 void test_visitNamedExpression() {
5114 _assertSource( 5287 _assertSource("a: b",
5115 "a: b", AstFactory.namedExpression2("a", AstFactory.identifier3("b"))); 5288 AstTestFactory.namedExpression2("a", AstTestFactory.identifier3("b")));
5116 } 5289 }
5117 5290
5118 void test_visitNamedFormalParameter() { 5291 void test_visitNamedFormalParameter() {
5119 _assertSource( 5292 _assertSource(
5120 "var a : 0", 5293 "var a : 0",
5121 AstFactory.namedFormalParameter( 5294 AstTestFactory.namedFormalParameter(
5122 AstFactory.simpleFormalParameter(Keyword.VAR, "a"), 5295 AstTestFactory.simpleFormalParameter(Keyword.VAR, "a"),
5123 AstFactory.integer(0))); 5296 AstTestFactory.integer(0)));
5124 } 5297 }
5125 5298
5126 void test_visitNativeClause() { 5299 void test_visitNativeClause() {
5127 _assertSource("native 'code'", AstFactory.nativeClause("code")); 5300 _assertSource("native 'code'", AstTestFactory.nativeClause("code"));
5128 } 5301 }
5129 5302
5130 void test_visitNativeFunctionBody() { 5303 void test_visitNativeFunctionBody() {
5131 _assertSource("native 'str';", AstFactory.nativeFunctionBody("str")); 5304 _assertSource("native 'str';", AstTestFactory.nativeFunctionBody("str"));
5132 } 5305 }
5133 5306
5134 void test_visitNullLiteral() { 5307 void test_visitNullLiteral() {
5135 _assertSource("null", AstFactory.nullLiteral()); 5308 _assertSource("null", AstTestFactory.nullLiteral());
5136 } 5309 }
5137 5310
5138 void test_visitParenthesizedExpression() { 5311 void test_visitParenthesizedExpression() {
5139 _assertSource( 5312 _assertSource(
5140 "(a)", AstFactory.parenthesizedExpression(AstFactory.identifier3("a"))); 5313 "(a)",
5314 AstTestFactory
5315 .parenthesizedExpression(AstTestFactory.identifier3("a")));
5141 } 5316 }
5142 5317
5143 void test_visitPartDirective() { 5318 void test_visitPartDirective() {
5144 _assertSource("part 'a.dart';", AstFactory.partDirective2("a.dart")); 5319 _assertSource("part 'a.dart';", AstTestFactory.partDirective2("a.dart"));
5145 } 5320 }
5146 5321
5147 void test_visitPartDirective_withMetadata() { 5322 void test_visitPartDirective_withMetadata() {
5148 PartDirective directive = AstFactory.partDirective2("a.dart"); 5323 PartDirective directive = AstTestFactory.partDirective2("a.dart");
5149 directive.metadata 5324 directive.metadata.add(
5150 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 5325 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
5151 _assertSource("@deprecated part 'a.dart';", directive); 5326 _assertSource("@deprecated part 'a.dart';", directive);
5152 } 5327 }
5153 5328
5154 void test_visitPartOfDirective() { 5329 void test_visitPartOfDirective() {
5155 _assertSource("part of l;", 5330 _assertSource(
5156 AstFactory.partOfDirective(AstFactory.libraryIdentifier2(["l"]))); 5331 "part of l;",
5332 AstTestFactory
5333 .partOfDirective(AstTestFactory.libraryIdentifier2(["l"])));
5157 } 5334 }
5158 5335
5159 void test_visitPartOfDirective_withMetadata() { 5336 void test_visitPartOfDirective_withMetadata() {
5160 PartOfDirective directive = 5337 PartOfDirective directive = AstTestFactory
5161 AstFactory.partOfDirective(AstFactory.libraryIdentifier2(["l"])); 5338 .partOfDirective(AstTestFactory.libraryIdentifier2(["l"]));
5162 directive.metadata 5339 directive.metadata.add(
5163 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 5340 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
5164 _assertSource("@deprecated part of l;", directive); 5341 _assertSource("@deprecated part of l;", directive);
5165 } 5342 }
5166 5343
5167 void test_visitPositionalFormalParameter() { 5344 void test_visitPositionalFormalParameter() {
5168 _assertSource( 5345 _assertSource(
5169 "var a = 0", 5346 "var a = 0",
5170 AstFactory.positionalFormalParameter( 5347 AstTestFactory.positionalFormalParameter(
5171 AstFactory.simpleFormalParameter(Keyword.VAR, "a"), 5348 AstTestFactory.simpleFormalParameter(Keyword.VAR, "a"),
5172 AstFactory.integer(0))); 5349 AstTestFactory.integer(0)));
5173 } 5350 }
5174 5351
5175 void test_visitPostfixExpression() { 5352 void test_visitPostfixExpression() {
5176 _assertSource( 5353 _assertSource(
5177 "a++", 5354 "a++",
5178 AstFactory.postfixExpression( 5355 AstTestFactory.postfixExpression(
5179 AstFactory.identifier3("a"), TokenType.PLUS_PLUS)); 5356 AstTestFactory.identifier3("a"), TokenType.PLUS_PLUS));
5180 } 5357 }
5181 5358
5182 void test_visitPrefixedIdentifier() { 5359 void test_visitPrefixedIdentifier() {
5183 _assertSource("a.b", AstFactory.identifier5("a", "b")); 5360 _assertSource("a.b", AstTestFactory.identifier5("a", "b"));
5184 } 5361 }
5185 5362
5186 void test_visitPrefixExpression() { 5363 void test_visitPrefixExpression() {
5187 _assertSource( 5364 _assertSource(
5188 "-a", 5365 "-a",
5189 AstFactory.prefixExpression( 5366 AstTestFactory.prefixExpression(
5190 TokenType.MINUS, AstFactory.identifier3("a"))); 5367 TokenType.MINUS, AstTestFactory.identifier3("a")));
5191 } 5368 }
5192 5369
5193 void test_visitPropertyAccess() { 5370 void test_visitPropertyAccess() {
5194 _assertSource( 5371 _assertSource("a.b",
5195 "a.b", AstFactory.propertyAccess2(AstFactory.identifier3("a"), "b")); 5372 AstTestFactory.propertyAccess2(AstTestFactory.identifier3("a"), "b"));
5196 } 5373 }
5197 5374
5198 void test_visitPropertyAccess_conditional() { 5375 void test_visitPropertyAccess_conditional() {
5199 _assertSource( 5376 _assertSource(
5200 "a?.b", 5377 "a?.b",
5201 AstFactory.propertyAccess2( 5378 AstTestFactory.propertyAccess2(
5202 AstFactory.identifier3("a"), "b", TokenType.QUESTION_PERIOD)); 5379 AstTestFactory.identifier3("a"), "b", TokenType.QUESTION_PERIOD));
5203 } 5380 }
5204 5381
5205 void test_visitRedirectingConstructorInvocation_named() { 5382 void test_visitRedirectingConstructorInvocation_named() {
5206 _assertSource( 5383 _assertSource(
5207 "this.c()", AstFactory.redirectingConstructorInvocation2("c")); 5384 "this.c()", AstTestFactory.redirectingConstructorInvocation2("c"));
5208 } 5385 }
5209 5386
5210 void test_visitRedirectingConstructorInvocation_unnamed() { 5387 void test_visitRedirectingConstructorInvocation_unnamed() {
5211 _assertSource("this()", AstFactory.redirectingConstructorInvocation()); 5388 _assertSource("this()", AstTestFactory.redirectingConstructorInvocation());
5212 } 5389 }
5213 5390
5214 void test_visitRethrowExpression() { 5391 void test_visitRethrowExpression() {
5215 _assertSource("rethrow", AstFactory.rethrowExpression()); 5392 _assertSource("rethrow", AstTestFactory.rethrowExpression());
5216 } 5393 }
5217 5394
5218 void test_visitReturnStatement_expression() { 5395 void test_visitReturnStatement_expression() {
5219 _assertSource( 5396 _assertSource("return a;",
5220 "return a;", AstFactory.returnStatement2(AstFactory.identifier3("a"))); 5397 AstTestFactory.returnStatement2(AstTestFactory.identifier3("a")));
5221 } 5398 }
5222 5399
5223 void test_visitReturnStatement_noExpression() { 5400 void test_visitReturnStatement_noExpression() {
5224 _assertSource("return;", AstFactory.returnStatement()); 5401 _assertSource("return;", AstTestFactory.returnStatement());
5225 } 5402 }
5226 5403
5227 void test_visitScriptTag() { 5404 void test_visitScriptTag() {
5228 String scriptTag = "!#/bin/dart.exe"; 5405 String scriptTag = "!#/bin/dart.exe";
5229 _assertSource(scriptTag, AstFactory.scriptTag(scriptTag)); 5406 _assertSource(scriptTag, AstTestFactory.scriptTag(scriptTag));
5230 } 5407 }
5231 5408
5232 void test_visitSimpleFormalParameter_annotation() { 5409 void test_visitSimpleFormalParameter_annotation() {
5233 SimpleFormalParameter parameter = AstFactory.simpleFormalParameter3('x'); 5410 SimpleFormalParameter parameter =
5234 parameter.metadata.add(AstFactory.annotation(AstFactory.identifier3("A"))); 5411 AstTestFactory.simpleFormalParameter3('x');
5412 parameter.metadata
5413 .add(AstTestFactory.annotation(AstTestFactory.identifier3("A")));
5235 _assertSource('@A x', parameter); 5414 _assertSource('@A x', parameter);
5236 } 5415 }
5237 5416
5238 void test_visitSimpleFormalParameter_keyword() { 5417 void test_visitSimpleFormalParameter_keyword() {
5239 _assertSource("var a", AstFactory.simpleFormalParameter(Keyword.VAR, "a")); 5418 _assertSource(
5419 "var a", AstTestFactory.simpleFormalParameter(Keyword.VAR, "a"));
5240 } 5420 }
5241 5421
5242 void test_visitSimpleFormalParameter_keyword_type() { 5422 void test_visitSimpleFormalParameter_keyword_type() {
5243 _assertSource( 5423 _assertSource(
5244 "final A a", 5424 "final A a",
5245 AstFactory.simpleFormalParameter2( 5425 AstTestFactory.simpleFormalParameter2(
5246 Keyword.FINAL, AstFactory.typeName4("A"), "a")); 5426 Keyword.FINAL, AstTestFactory.typeName4("A"), "a"));
5247 } 5427 }
5248 5428
5249 void test_visitSimpleFormalParameter_type() { 5429 void test_visitSimpleFormalParameter_type() {
5250 _assertSource("A a", 5430 _assertSource(
5251 AstFactory.simpleFormalParameter4(AstFactory.typeName4("A"), "a")); 5431 "A a",
5432 AstTestFactory.simpleFormalParameter4(
5433 AstTestFactory.typeName4("A"), "a"));
5252 } 5434 }
5253 5435
5254 void test_visitSimpleIdentifier() { 5436 void test_visitSimpleIdentifier() {
5255 _assertSource("a", AstFactory.identifier3("a")); 5437 _assertSource("a", AstTestFactory.identifier3("a"));
5256 } 5438 }
5257 5439
5258 void test_visitSimpleStringLiteral() { 5440 void test_visitSimpleStringLiteral() {
5259 _assertSource("'a'", AstFactory.string2("a")); 5441 _assertSource("'a'", AstTestFactory.string2("a"));
5260 } 5442 }
5261 5443
5262 void test_visitStringInterpolation() { 5444 void test_visitStringInterpolation() {
5263 _assertSource( 5445 _assertSource(
5264 "'a\${e}b'", 5446 "'a\${e}b'",
5265 AstFactory.string([ 5447 AstTestFactory.string([
5266 AstFactory.interpolationString("'a", "a"), 5448 AstTestFactory.interpolationString("'a", "a"),
5267 AstFactory.interpolationExpression(AstFactory.identifier3("e")), 5449 AstTestFactory
5268 AstFactory.interpolationString("b'", "b") 5450 .interpolationExpression(AstTestFactory.identifier3("e")),
5451 AstTestFactory.interpolationString("b'", "b")
5269 ])); 5452 ]));
5270 } 5453 }
5271 5454
5272 void test_visitSuperConstructorInvocation() { 5455 void test_visitSuperConstructorInvocation() {
5273 _assertSource("super()", AstFactory.superConstructorInvocation()); 5456 _assertSource("super()", AstTestFactory.superConstructorInvocation());
5274 } 5457 }
5275 5458
5276 void test_visitSuperConstructorInvocation_named() { 5459 void test_visitSuperConstructorInvocation_named() {
5277 _assertSource("super.c()", AstFactory.superConstructorInvocation2("c")); 5460 _assertSource("super.c()", AstTestFactory.superConstructorInvocation2("c"));
5278 } 5461 }
5279 5462
5280 void test_visitSuperExpression() { 5463 void test_visitSuperExpression() {
5281 _assertSource("super", AstFactory.superExpression()); 5464 _assertSource("super", AstTestFactory.superExpression());
5282 } 5465 }
5283 5466
5284 void test_visitSwitchCase_multipleLabels() { 5467 void test_visitSwitchCase_multipleLabels() {
5285 _assertSource( 5468 _assertSource(
5286 "l1: l2: case a: {}", 5469 "l1: l2: case a: {}",
5287 AstFactory.switchCase2( 5470 AstTestFactory.switchCase2(
5288 [AstFactory.label2("l1"), AstFactory.label2("l2")], 5471 [AstTestFactory.label2("l1"), AstTestFactory.label2("l2")],
5289 AstFactory.identifier3("a"), 5472 AstTestFactory.identifier3("a"),
5290 [AstFactory.block()])); 5473 [AstTestFactory.block()]));
5291 } 5474 }
5292 5475
5293 void test_visitSwitchCase_multipleStatements() { 5476 void test_visitSwitchCase_multipleStatements() {
5294 _assertSource( 5477 _assertSource(
5295 "case a: {} {}", 5478 "case a: {} {}",
5296 AstFactory.switchCase(AstFactory.identifier3("a"), 5479 AstTestFactory.switchCase(AstTestFactory.identifier3("a"),
5297 [AstFactory.block(), AstFactory.block()])); 5480 [AstTestFactory.block(), AstTestFactory.block()]));
5298 } 5481 }
5299 5482
5300 void test_visitSwitchCase_noLabels() { 5483 void test_visitSwitchCase_noLabels() {
5301 _assertSource( 5484 _assertSource(
5302 "case a: {}", 5485 "case a: {}",
5303 AstFactory 5486 AstTestFactory.switchCase(
5304 .switchCase(AstFactory.identifier3("a"), [AstFactory.block()])); 5487 AstTestFactory.identifier3("a"), [AstTestFactory.block()]));
5305 } 5488 }
5306 5489
5307 void test_visitSwitchCase_singleLabel() { 5490 void test_visitSwitchCase_singleLabel() {
5308 _assertSource( 5491 _assertSource(
5309 "l1: case a: {}", 5492 "l1: case a: {}",
5310 AstFactory.switchCase2([AstFactory.label2("l1")], 5493 AstTestFactory.switchCase2([AstTestFactory.label2("l1")],
5311 AstFactory.identifier3("a"), [AstFactory.block()])); 5494 AstTestFactory.identifier3("a"), [AstTestFactory.block()]));
5312 } 5495 }
5313 5496
5314 void test_visitSwitchDefault_multipleLabels() { 5497 void test_visitSwitchDefault_multipleLabels() {
5315 _assertSource( 5498 _assertSource(
5316 "l1: l2: default: {}", 5499 "l1: l2: default: {}",
5317 AstFactory.switchDefault( 5500 AstTestFactory.switchDefault(
5318 [AstFactory.label2("l1"), AstFactory.label2("l2")], 5501 [AstTestFactory.label2("l1"), AstTestFactory.label2("l2")],
5319 [AstFactory.block()])); 5502 [AstTestFactory.block()]));
5320 } 5503 }
5321 5504
5322 void test_visitSwitchDefault_multipleStatements() { 5505 void test_visitSwitchDefault_multipleStatements() {
5323 _assertSource("default: {} {}", 5506 _assertSource(
5324 AstFactory.switchDefault2([AstFactory.block(), AstFactory.block()])); 5507 "default: {} {}",
5508 AstTestFactory
5509 .switchDefault2([AstTestFactory.block(), AstTestFactory.block()]));
5325 } 5510 }
5326 5511
5327 void test_visitSwitchDefault_noLabels() { 5512 void test_visitSwitchDefault_noLabels() {
5328 _assertSource( 5513 _assertSource(
5329 "default: {}", AstFactory.switchDefault2([AstFactory.block()])); 5514 "default: {}", AstTestFactory.switchDefault2([AstTestFactory.block()]));
5330 } 5515 }
5331 5516
5332 void test_visitSwitchDefault_singleLabel() { 5517 void test_visitSwitchDefault_singleLabel() {
5333 _assertSource( 5518 _assertSource(
5334 "l1: default: {}", 5519 "l1: default: {}",
5335 AstFactory 5520 AstTestFactory.switchDefault(
5336 .switchDefault([AstFactory.label2("l1")], [AstFactory.block()])); 5521 [AstTestFactory.label2("l1")], [AstTestFactory.block()]));
5337 } 5522 }
5338 5523
5339 void test_visitSwitchStatement() { 5524 void test_visitSwitchStatement() {
5340 _assertSource( 5525 _assertSource(
5341 "switch (a) {case 'b': {} default: {}}", 5526 "switch (a) {case 'b': {} default: {}}",
5342 AstFactory.switchStatement(AstFactory.identifier3("a"), [ 5527 AstTestFactory.switchStatement(AstTestFactory.identifier3("a"), [
5343 AstFactory.switchCase(AstFactory.string2("b"), [AstFactory.block()]), 5528 AstTestFactory.switchCase(
5344 AstFactory.switchDefault2([AstFactory.block()]) 5529 AstTestFactory.string2("b"), [AstTestFactory.block()]),
5530 AstTestFactory.switchDefault2([AstTestFactory.block()])
5345 ])); 5531 ]));
5346 } 5532 }
5347 5533
5348 void test_visitSymbolLiteral_multiple() { 5534 void test_visitSymbolLiteral_multiple() {
5349 _assertSource("#a.b.c", AstFactory.symbolLiteral(["a", "b", "c"])); 5535 _assertSource("#a.b.c", AstTestFactory.symbolLiteral(["a", "b", "c"]));
5350 } 5536 }
5351 5537
5352 void test_visitSymbolLiteral_single() { 5538 void test_visitSymbolLiteral_single() {
5353 _assertSource("#a", AstFactory.symbolLiteral(["a"])); 5539 _assertSource("#a", AstTestFactory.symbolLiteral(["a"]));
5354 } 5540 }
5355 5541
5356 void test_visitThisExpression() { 5542 void test_visitThisExpression() {
5357 _assertSource("this", AstFactory.thisExpression()); 5543 _assertSource("this", AstTestFactory.thisExpression());
5358 } 5544 }
5359 5545
5360 void test_visitThrowStatement() { 5546 void test_visitThrowStatement() {
5361 _assertSource( 5547 _assertSource("throw e",
5362 "throw e", AstFactory.throwExpression2(AstFactory.identifier3("e"))); 5548 AstTestFactory.throwExpression2(AstTestFactory.identifier3("e")));
5363 } 5549 }
5364 5550
5365 void test_visitTopLevelVariableDeclaration_multiple() { 5551 void test_visitTopLevelVariableDeclaration_multiple() {
5366 _assertSource( 5552 _assertSource(
5367 "var a;", 5553 "var a;",
5368 AstFactory.topLevelVariableDeclaration2( 5554 AstTestFactory.topLevelVariableDeclaration2(
5369 Keyword.VAR, [AstFactory.variableDeclaration("a")])); 5555 Keyword.VAR, [AstTestFactory.variableDeclaration("a")]));
5370 } 5556 }
5371 5557
5372 void test_visitTopLevelVariableDeclaration_single() { 5558 void test_visitTopLevelVariableDeclaration_single() {
5373 _assertSource( 5559 _assertSource(
5374 "var a, b;", 5560 "var a, b;",
5375 AstFactory.topLevelVariableDeclaration2(Keyword.VAR, [ 5561 AstTestFactory.topLevelVariableDeclaration2(Keyword.VAR, [
5376 AstFactory.variableDeclaration("a"), 5562 AstTestFactory.variableDeclaration("a"),
5377 AstFactory.variableDeclaration("b") 5563 AstTestFactory.variableDeclaration("b")
5378 ])); 5564 ]));
5379 } 5565 }
5380 5566
5381 void test_visitTryStatement_catch() { 5567 void test_visitTryStatement_catch() {
5382 _assertSource( 5568 _assertSource(
5383 "try {} on E {}", 5569 "try {} on E {}",
5384 AstFactory.tryStatement2(AstFactory.block(), 5570 AstTestFactory.tryStatement2(AstTestFactory.block(),
5385 [AstFactory.catchClause3(AstFactory.typeName4("E"))])); 5571 [AstTestFactory.catchClause3(AstTestFactory.typeName4("E"))]));
5386 } 5572 }
5387 5573
5388 void test_visitTryStatement_catches() { 5574 void test_visitTryStatement_catches() {
5389 _assertSource( 5575 _assertSource(
5390 "try {} on E {} on F {}", 5576 "try {} on E {} on F {}",
5391 AstFactory.tryStatement2(AstFactory.block(), [ 5577 AstTestFactory.tryStatement2(AstTestFactory.block(), [
5392 AstFactory.catchClause3(AstFactory.typeName4("E")), 5578 AstTestFactory.catchClause3(AstTestFactory.typeName4("E")),
5393 AstFactory.catchClause3(AstFactory.typeName4("F")) 5579 AstTestFactory.catchClause3(AstTestFactory.typeName4("F"))
5394 ])); 5580 ]));
5395 } 5581 }
5396 5582
5397 void test_visitTryStatement_catchFinally() { 5583 void test_visitTryStatement_catchFinally() {
5398 _assertSource( 5584 _assertSource(
5399 "try {} on E {} finally {}", 5585 "try {} on E {} finally {}",
5400 AstFactory.tryStatement3( 5586 AstTestFactory.tryStatement3(
5401 AstFactory.block(), 5587 AstTestFactory.block(),
5402 [AstFactory.catchClause3(AstFactory.typeName4("E"))], 5588 [AstTestFactory.catchClause3(AstTestFactory.typeName4("E"))],
5403 AstFactory.block())); 5589 AstTestFactory.block()));
5404 } 5590 }
5405 5591
5406 void test_visitTryStatement_finally() { 5592 void test_visitTryStatement_finally() {
5407 _assertSource("try {} finally {}", 5593 _assertSource(
5408 AstFactory.tryStatement(AstFactory.block(), AstFactory.block())); 5594 "try {} finally {}",
5595 AstTestFactory.tryStatement(
5596 AstTestFactory.block(), AstTestFactory.block()));
5409 } 5597 }
5410 5598
5411 void test_visitTypeArgumentList_multiple() { 5599 void test_visitTypeArgumentList_multiple() {
5412 _assertSource( 5600 _assertSource(
5413 "<E, F>", 5601 "<E, F>",
5414 AstFactory.typeArgumentList( 5602 AstTestFactory.typeArgumentList(
5415 [AstFactory.typeName4("E"), AstFactory.typeName4("F")])); 5603 [AstTestFactory.typeName4("E"), AstTestFactory.typeName4("F")]));
5416 } 5604 }
5417 5605
5418 void test_visitTypeArgumentList_single() { 5606 void test_visitTypeArgumentList_single() {
5419 _assertSource( 5607 _assertSource("<E>",
5420 "<E>", AstFactory.typeArgumentList([AstFactory.typeName4("E")])); 5608 AstTestFactory.typeArgumentList([AstTestFactory.typeName4("E")]));
5421 } 5609 }
5422 5610
5423 void test_visitTypeName_multipleArgs() { 5611 void test_visitTypeName_multipleArgs() {
5424 _assertSource( 5612 _assertSource(
5425 "C<D, E>", 5613 "C<D, E>",
5426 AstFactory.typeName4( 5614 AstTestFactory.typeName4("C",
5427 "C", [AstFactory.typeName4("D"), AstFactory.typeName4("E")])); 5615 [AstTestFactory.typeName4("D"), AstTestFactory.typeName4("E")]));
5428 } 5616 }
5429 5617
5430 void test_visitTypeName_nestedArg() { 5618 void test_visitTypeName_nestedArg() {
5431 _assertSource( 5619 _assertSource(
5432 "C<D<E>>", 5620 "C<D<E>>",
5433 AstFactory.typeName4("C", [ 5621 AstTestFactory.typeName4("C", [
5434 AstFactory.typeName4("D", [AstFactory.typeName4("E")]) 5622 AstTestFactory.typeName4("D", [AstTestFactory.typeName4("E")])
5435 ])); 5623 ]));
5436 } 5624 }
5437 5625
5438 void test_visitTypeName_noArgs() { 5626 void test_visitTypeName_noArgs() {
5439 _assertSource("C", AstFactory.typeName4("C")); 5627 _assertSource("C", AstTestFactory.typeName4("C"));
5440 } 5628 }
5441 5629
5442 void test_visitTypeName_singleArg() { 5630 void test_visitTypeName_singleArg() {
5443 _assertSource( 5631 _assertSource(
5444 "C<D>", AstFactory.typeName4("C", [AstFactory.typeName4("D")])); 5632 "C<D>", AstTestFactory.typeName4("C", [AstTestFactory.typeName4("D")]));
5445 } 5633 }
5446 5634
5447 void test_visitTypeParameter_withExtends() { 5635 void test_visitTypeParameter_withExtends() {
5448 _assertSource("E extends C", 5636 _assertSource("E extends C",
5449 AstFactory.typeParameter2("E", AstFactory.typeName4("C"))); 5637 AstTestFactory.typeParameter2("E", AstTestFactory.typeName4("C")));
5450 } 5638 }
5451 5639
5452 void test_visitTypeParameter_withMetadata() { 5640 void test_visitTypeParameter_withMetadata() {
5453 TypeParameter parameter = AstFactory.typeParameter("E"); 5641 TypeParameter parameter = AstTestFactory.typeParameter("E");
5454 parameter.metadata 5642 parameter.metadata.add(
5455 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 5643 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
5456 _assertSource("@deprecated E", parameter); 5644 _assertSource("@deprecated E", parameter);
5457 } 5645 }
5458 5646
5459 void test_visitTypeParameter_withoutExtends() { 5647 void test_visitTypeParameter_withoutExtends() {
5460 _assertSource("E", AstFactory.typeParameter("E")); 5648 _assertSource("E", AstTestFactory.typeParameter("E"));
5461 } 5649 }
5462 5650
5463 void test_visitTypeParameterList_multiple() { 5651 void test_visitTypeParameterList_multiple() {
5464 _assertSource("<E, F>", AstFactory.typeParameterList(["E", "F"])); 5652 _assertSource("<E, F>", AstTestFactory.typeParameterList(["E", "F"]));
5465 } 5653 }
5466 5654
5467 void test_visitTypeParameterList_single() { 5655 void test_visitTypeParameterList_single() {
5468 _assertSource("<E>", AstFactory.typeParameterList(["E"])); 5656 _assertSource("<E>", AstTestFactory.typeParameterList(["E"]));
5469 } 5657 }
5470 5658
5471 void test_visitVariableDeclaration_initialized() { 5659 void test_visitVariableDeclaration_initialized() {
5472 _assertSource("a = b", 5660 _assertSource(
5473 AstFactory.variableDeclaration2("a", AstFactory.identifier3("b"))); 5661 "a = b",
5662 AstTestFactory.variableDeclaration2(
5663 "a", AstTestFactory.identifier3("b")));
5474 } 5664 }
5475 5665
5476 void test_visitVariableDeclaration_uninitialized() { 5666 void test_visitVariableDeclaration_uninitialized() {
5477 _assertSource("a", AstFactory.variableDeclaration("a")); 5667 _assertSource("a", AstTestFactory.variableDeclaration("a"));
5478 } 5668 }
5479 5669
5480 void test_visitVariableDeclaration_withMetadata() { 5670 void test_visitVariableDeclaration_withMetadata() {
5481 VariableDeclaration declaration = AstFactory.variableDeclaration("a"); 5671 VariableDeclaration declaration = AstTestFactory.variableDeclaration("a");
5482 declaration.metadata 5672 declaration.metadata.add(
5483 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 5673 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
5484 _assertSource("@deprecated a", declaration); 5674 _assertSource("@deprecated a", declaration);
5485 } 5675 }
5486 5676
5487 void test_visitVariableDeclarationList_const_type() { 5677 void test_visitVariableDeclarationList_const_type() {
5488 _assertSource( 5678 _assertSource(
5489 "const C a, b", 5679 "const C a, b",
5490 AstFactory.variableDeclarationList( 5680 AstTestFactory.variableDeclarationList(
5491 Keyword.CONST, AstFactory.typeName4("C"), [ 5681 Keyword.CONST, AstTestFactory.typeName4("C"), [
5492 AstFactory.variableDeclaration("a"), 5682 AstTestFactory.variableDeclaration("a"),
5493 AstFactory.variableDeclaration("b") 5683 AstTestFactory.variableDeclaration("b")
5494 ])); 5684 ]));
5495 } 5685 }
5496 5686
5497 void test_visitVariableDeclarationList_final_noType() { 5687 void test_visitVariableDeclarationList_final_noType() {
5498 _assertSource( 5688 _assertSource(
5499 "final a, b", 5689 "final a, b",
5500 AstFactory.variableDeclarationList2(Keyword.FINAL, [ 5690 AstTestFactory.variableDeclarationList2(Keyword.FINAL, [
5501 AstFactory.variableDeclaration("a"), 5691 AstTestFactory.variableDeclaration("a"),
5502 AstFactory.variableDeclaration("b") 5692 AstTestFactory.variableDeclaration("b")
5503 ])); 5693 ]));
5504 } 5694 }
5505 5695
5506 void test_visitVariableDeclarationList_final_withMetadata() { 5696 void test_visitVariableDeclarationList_final_withMetadata() {
5507 VariableDeclarationList declarationList = AstFactory 5697 VariableDeclarationList declarationList = AstTestFactory
5508 .variableDeclarationList2(Keyword.FINAL, [ 5698 .variableDeclarationList2(Keyword.FINAL, [
5509 AstFactory.variableDeclaration("a"), 5699 AstTestFactory.variableDeclaration("a"),
5510 AstFactory.variableDeclaration("b") 5700 AstTestFactory.variableDeclaration("b")
5511 ]); 5701 ]);
5512 declarationList.metadata 5702 declarationList.metadata.add(
5513 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 5703 AstTestFactory.annotation(AstTestFactory.identifier3("deprecated")));
5514 _assertSource("@deprecated final a, b", declarationList); 5704 _assertSource("@deprecated final a, b", declarationList);
5515 } 5705 }
5516 5706
5517 void test_visitVariableDeclarationList_type() { 5707 void test_visitVariableDeclarationList_type() {
5518 _assertSource( 5708 _assertSource(
5519 "C a, b", 5709 "C a, b",
5520 AstFactory.variableDeclarationList(null, AstFactory.typeName4("C"), [ 5710 AstTestFactory.variableDeclarationList(
5521 AstFactory.variableDeclaration("a"), 5711 null, AstTestFactory.typeName4("C"), [
5522 AstFactory.variableDeclaration("b") 5712 AstTestFactory.variableDeclaration("a"),
5713 AstTestFactory.variableDeclaration("b")
5523 ])); 5714 ]));
5524 } 5715 }
5525 5716
5526 void test_visitVariableDeclarationList_var() { 5717 void test_visitVariableDeclarationList_var() {
5527 _assertSource( 5718 _assertSource(
5528 "var a, b", 5719 "var a, b",
5529 AstFactory.variableDeclarationList2(Keyword.VAR, [ 5720 AstTestFactory.variableDeclarationList2(Keyword.VAR, [
5530 AstFactory.variableDeclaration("a"), 5721 AstTestFactory.variableDeclaration("a"),
5531 AstFactory.variableDeclaration("b") 5722 AstTestFactory.variableDeclaration("b")
5532 ])); 5723 ]));
5533 } 5724 }
5534 5725
5535 void test_visitVariableDeclarationStatement() { 5726 void test_visitVariableDeclarationStatement() {
5536 _assertSource( 5727 _assertSource(
5537 "C c;", 5728 "C c;",
5538 AstFactory.variableDeclarationStatement(null, AstFactory.typeName4("C"), 5729 AstTestFactory.variableDeclarationStatement(
5539 [AstFactory.variableDeclaration("c")])); 5730 null,
5731 AstTestFactory.typeName4("C"),
5732 [AstTestFactory.variableDeclaration("c")]));
5540 } 5733 }
5541 5734
5542 void test_visitWhileStatement() { 5735 void test_visitWhileStatement() {
5543 _assertSource( 5736 _assertSource(
5544 "while (c) {}", 5737 "while (c) {}",
5545 AstFactory.whileStatement( 5738 AstTestFactory.whileStatement(
5546 AstFactory.identifier3("c"), AstFactory.block())); 5739 AstTestFactory.identifier3("c"), AstTestFactory.block()));
5547 } 5740 }
5548 5741
5549 void test_visitWithClause_multiple() { 5742 void test_visitWithClause_multiple() {
5550 _assertSource( 5743 _assertSource(
5551 "with A, B, C", 5744 "with A, B, C",
5552 AstFactory.withClause([ 5745 AstTestFactory.withClause([
5553 AstFactory.typeName4("A"), 5746 AstTestFactory.typeName4("A"),
5554 AstFactory.typeName4("B"), 5747 AstTestFactory.typeName4("B"),
5555 AstFactory.typeName4("C") 5748 AstTestFactory.typeName4("C")
5556 ])); 5749 ]));
5557 } 5750 }
5558 5751
5559 void test_visitWithClause_single() { 5752 void test_visitWithClause_single() {
5560 _assertSource("with A", AstFactory.withClause([AstFactory.typeName4("A")])); 5753 _assertSource(
5754 "with A", AstTestFactory.withClause([AstTestFactory.typeName4("A")]));
5561 } 5755 }
5562 5756
5563 void test_visitYieldStatement() { 5757 void test_visitYieldStatement() {
5564 _assertSource( 5758 _assertSource("yield e;",
5565 "yield e;", AstFactory.yieldStatement(AstFactory.identifier3("e"))); 5759 AstTestFactory.yieldStatement(AstTestFactory.identifier3("e")));
5566 } 5760 }
5567 5761
5568 void test_visitYieldStatement_each() { 5762 void test_visitYieldStatement_each() {
5569 _assertSource("yield* e;", 5763 _assertSource("yield* e;",
5570 AstFactory.yieldEachStatement(AstFactory.identifier3("e"))); 5764 AstTestFactory.yieldEachStatement(AstTestFactory.identifier3("e")));
5571 } 5765 }
5572 5766
5573 /** 5767 /**
5574 * Assert that a `ToSourceVisitor` will produce the [expectedSource] when 5768 * Assert that a `ToSourceVisitor` will produce the [expectedSource] when
5575 * visiting the given [node]. 5769 * visiting the given [node].
5576 */ 5770 */
5577 void _assertSource(String expectedSource, AstNode node) { 5771 void _assertSource(String expectedSource, AstNode node) {
5578 PrintStringWriter writer = new PrintStringWriter(); 5772 PrintStringWriter writer = new PrintStringWriter();
5579 node.accept(new ToSourceVisitor(writer)); 5773 node.accept(new ToSourceVisitor(writer));
5580 expect(writer.toString(), expectedSource); 5774 expect(writer.toString(), expectedSource);
5581 } 5775 }
5582 } 5776 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/utilities_test.dart ('k') | pkg/analyzer/test/src/dart/constant/evaluation_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698