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

Side by Side Diff: pkg/analyzer/test/generated/all_the_rest.dart

Issue 712083003: Create fewer unnecessary lists (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.all_the_rest_test; 8 library engine.all_the_rest_test;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 local.toolkitObjects = <AngularElement>[angularElement]; 1847 local.toolkitObjects = <AngularElement>[angularElement];
1848 expect(AngularHtmlUnitResolver.getAngularElement(local), same(angularElement )); 1848 expect(AngularHtmlUnitResolver.getAngularElement(local), same(angularElement ));
1849 } 1849 }
1850 1850
1851 void test_getAngularElement_notAngular() { 1851 void test_getAngularElement_notAngular() {
1852 Element element = ElementFactory.localVariableElement2("name"); 1852 Element element = ElementFactory.localVariableElement2("name");
1853 expect(AngularHtmlUnitResolver.getAngularElement(element), isNull); 1853 expect(AngularHtmlUnitResolver.getAngularElement(element), isNull);
1854 } 1854 }
1855 1855
1856 void test_getAngularElement_notLocal() { 1856 void test_getAngularElement_notLocal() {
1857 Element element = ElementFactory.classElement2("Test", []); 1857 Element element = ElementFactory.classElement2("Test");
1858 expect(AngularHtmlUnitResolver.getAngularElement(element), isNull); 1858 expect(AngularHtmlUnitResolver.getAngularElement(element), isNull);
1859 } 1859 }
1860 1860
1861 /** 1861 /**
1862 * Test that we resolve "ng-click" expression. 1862 * Test that we resolve "ng-click" expression.
1863 */ 1863 */
1864 void test_ngClick() { 1864 void test_ngClick() {
1865 addMyController(); 1865 addMyController();
1866 _resolveIndexNoErrors( 1866 _resolveIndexNoErrors(
1867 AngularTest.createHtmlWithMyController(r"<button ng-click='ctrl.doSometh ing($event)'/>")); 1867 AngularTest.createHtmlWithMyController(r"<button ng-click='ctrl.doSometh ing($event)'/>"));
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 * Assert that the number of errors reported against the given source matches the number of errors 2594 * Assert that the number of errors reported against the given source matches the number of errors
2595 * that are given and that they have the expected error codes. The order in wh ich the errors were 2595 * that are given and that they have the expected error codes. The order in wh ich the errors were
2596 * gathered is ignored. 2596 * gathered is ignored.
2597 * 2597 *
2598 * @param source the source against which the errors should have been reported 2598 * @param source the source against which the errors should have been reported
2599 * @param expectedErrorCodes the error codes of the errors that should have be en reported 2599 * @param expectedErrorCodes the error codes of the errors that should have be en reported
2600 * @throws AnalysisException if the reported errors could not be computed 2600 * @throws AnalysisException if the reported errors could not be computed
2601 * @throws AssertionFailedError if a different number of errors have been repo rted than were 2601 * @throws AssertionFailedError if a different number of errors have been repo rted than were
2602 * expected 2602 * expected
2603 */ 2603 */
2604 void assertErrors(Source source, List<ErrorCode> expectedErrorCodes) { 2604 void assertErrors(Source source, [List<ErrorCode> expectedErrorCodes = ErrorCo de.EMPTY_LIST]) {
2605 GatheringErrorListener errorListener = new GatheringErrorListener(); 2605 GatheringErrorListener errorListener = new GatheringErrorListener();
2606 AnalysisErrorInfo errorsInfo = context.getErrors(source); 2606 AnalysisErrorInfo errorsInfo = context.getErrors(source);
2607 for (AnalysisError error in errorsInfo.errors) { 2607 for (AnalysisError error in errorsInfo.errors) {
2608 errorListener.onError(error); 2608 errorListener.onError(error);
2609 } 2609 }
2610 errorListener.assertErrorsWithCodes(expectedErrorCodes); 2610 errorListener.assertErrorsWithCodes(expectedErrorCodes);
2611 } 2611 }
2612 2612
2613 void assertMainErrors(List<ErrorCode> expectedErrorCodes) { 2613 void assertMainErrors(List<ErrorCode> expectedErrorCodes) {
2614 assertErrors(mainSource, expectedErrorCodes); 2614 assertErrors(mainSource, expectedErrorCodes);
2615 } 2615 }
2616 2616
2617 /** 2617 /**
2618 * Assert that no errors have been reported against the [indexSource]. 2618 * Assert that no errors have been reported against the [indexSource].
2619 */ 2619 */
2620 void assertNoErrors() { 2620 void assertNoErrors() {
2621 assertErrors(indexSource, []); 2621 assertErrors(indexSource);
2622 } 2622 }
2623 2623
2624 void assertNoErrors2(Source source) { 2624 void assertNoErrors2(Source source) {
2625 assertErrors(source, []); 2625 assertErrors(source);
2626 } 2626 }
2627 2627
2628 /** 2628 /**
2629 * Assert that no errors have been reported against the [mainSource]. 2629 * Assert that no errors have been reported against the [mainSource].
2630 */ 2630 */
2631 void assertNoMainErrors() { 2631 void assertNoMainErrors() {
2632 assertErrors(mainSource, []); 2632 assertErrors(mainSource);
2633 } 2633 }
2634 2634
2635 /** 2635 /**
2636 * Checks that [indexHtmlUnit] has [SimpleIdentifier] with given name, resolve d to 2636 * Checks that [indexHtmlUnit] has [SimpleIdentifier] with given name, resolve d to
2637 * not `null` [Element]. 2637 * not `null` [Element].
2638 */ 2638 */
2639 Element assertResolvedIdentifier(String name) { 2639 Element assertResolvedIdentifier(String name) {
2640 SimpleIdentifier identifier = findIdentifier(name); 2640 SimpleIdentifier identifier = findIdentifier(name);
2641 // check Element 2641 // check Element
2642 Element element = identifier.bestElement; 2642 Element element = identifier.bestElement;
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
3463 } 3463 }
3464 3464
3465 ConstructorElement _setupConstructorDeclaration(String name, bool isConst) { 3465 ConstructorElement _setupConstructorDeclaration(String name, bool isConst) {
3466 Keyword constKeyword = isConst ? Keyword.CONST : null; 3466 Keyword constKeyword = isConst ? Keyword.CONST : null;
3467 ConstructorDeclaration constructorDeclaration = 3467 ConstructorDeclaration constructorDeclaration =
3468 AstFactory.constructorDeclaration2( 3468 AstFactory.constructorDeclaration2(
3469 constKeyword, 3469 constKeyword,
3470 null, 3470 null,
3471 null, 3471 null,
3472 name, 3472 name,
3473 AstFactory.formalParameterList([]), 3473 AstFactory.formalParameterList(),
3474 null, 3474 null,
3475 AstFactory.blockFunctionBody2([])); 3475 AstFactory.blockFunctionBody2());
3476 ClassElement classElement = ElementFactory.classElement2(name, []); 3476 ClassElement classElement = ElementFactory.classElement2(name);
3477 ConstructorElement element = 3477 ConstructorElement element =
3478 ElementFactory.constructorElement(classElement, name, isConst, []); 3478 ElementFactory.constructorElement(classElement, name, isConst);
3479 constructorDeclaration.element = element; 3479 constructorDeclaration.element = element;
3480 _node = constructorDeclaration; 3480 _node = constructorDeclaration;
3481 return element; 3481 return element;
3482 } 3482 }
3483 3483
3484 void _setupInstanceCreationExpression(String name, bool isConst) { 3484 void _setupInstanceCreationExpression(String name, bool isConst) {
3485 _node = AstFactory.instanceCreationExpression2( 3485 _node = AstFactory.instanceCreationExpression2(
3486 isConst ? Keyword.CONST : null, 3486 isConst ? Keyword.CONST : null,
3487 AstFactory.typeName3(AstFactory.identifier3(name), []), 3487 AstFactory.typeName3(AstFactory.identifier3(name)));
3488 []);
3489 } 3488 }
3490 3489
3491 VariableElement _setupVariableDeclaration(String name, bool isConst, 3490 VariableElement _setupVariableDeclaration(String name, bool isConst,
3492 bool isInitialized) { 3491 bool isInitialized) {
3493 VariableDeclaration variableDeclaration = isInitialized ? 3492 VariableDeclaration variableDeclaration = isInitialized ?
3494 AstFactory.variableDeclaration2(name, AstFactory.integer(0)) : 3493 AstFactory.variableDeclaration2(name, AstFactory.integer(0)) :
3495 AstFactory.variableDeclaration(name); 3494 AstFactory.variableDeclaration(name);
3496 SimpleIdentifier identifier = variableDeclaration.name; 3495 SimpleIdentifier identifier = variableDeclaration.name;
3497 VariableElement element = ElementFactory.localVariableElement(identifier); 3496 VariableElement element = ElementFactory.localVariableElement(identifier);
3498 identifier.staticElement = element; 3497 identifier.staticElement = element;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
3602 expect(members, hasLength(1)); 3601 expect(members, hasLength(1));
3603 _validate(true, (members[0] as TopLevelVariableDeclaration).variables); 3602 _validate(true, (members[0] as TopLevelVariableDeclaration).variables);
3604 } 3603 }
3605 3604
3606 void test_dependencyOnConstructor() { 3605 void test_dependencyOnConstructor() {
3607 // x depends on "const A()" 3606 // x depends on "const A()"
3608 _assertProperDependencies(r''' 3607 _assertProperDependencies(r'''
3609 class A { 3608 class A {
3610 const A(); 3609 const A();
3611 } 3610 }
3612 const x = const A();''', 3611 const x = const A();''');
3613 []);
3614 } 3612 }
3615 3613
3616 void test_dependencyOnConstructorArgument() { 3614 void test_dependencyOnConstructorArgument() {
3617 // "const A(x)" depends on x 3615 // "const A(x)" depends on x
3618 _assertProperDependencies(r''' 3616 _assertProperDependencies(r'''
3619 class A { 3617 class A {
3620 const A(this.next); 3618 const A(this.next);
3621 final A next; 3619 final A next;
3622 } 3620 }
3623 const A x = const A(null); 3621 const A x = const A(null);
3624 const A y = const A(x);''', 3622 const A y = const A(x);''');
3625 []);
3626 } 3623 }
3627 3624
3628 void test_dependencyOnConstructorArgument_unresolvedConstructor() { 3625 void test_dependencyOnConstructorArgument_unresolvedConstructor() {
3629 // "const A.a(x)" depends on x even if the constructor A.a can't be found. 3626 // "const A.a(x)" depends on x even if the constructor A.a can't be found.
3630 _assertProperDependencies(r''' 3627 _assertProperDependencies(r'''
3631 class A { 3628 class A {
3632 } 3629 }
3633 const int x = 1; 3630 const int x = 1;
3634 const A y = const A.a(x);''', 3631 const A y = const A.a(x);''',
3635 [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR]); 3632 [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR]);
3636 } 3633 }
3637 3634
3638 void test_dependencyOnConstructorInitializer() { 3635 void test_dependencyOnConstructorInitializer() {
3639 // "const A()" depends on x 3636 // "const A()" depends on x
3640 _assertProperDependencies(r''' 3637 _assertProperDependencies(r'''
3641 const int x = 1; 3638 const int x = 1;
3642 class A { 3639 class A {
3643 const A() : v = x; 3640 const A() : v = x;
3644 final int v; 3641 final int v;
3645 }''', 3642 }''');
3646 []);
3647 } 3643 }
3648 3644
3649 void test_dependencyOnExplicitSuperConstructor() { 3645 void test_dependencyOnExplicitSuperConstructor() {
3650 // b depends on B() depends on A() 3646 // b depends on B() depends on A()
3651 _assertProperDependencies(r''' 3647 _assertProperDependencies(r'''
3652 class A { 3648 class A {
3653 const A(this.x); 3649 const A(this.x);
3654 final int x; 3650 final int x;
3655 } 3651 }
3656 class B extends A { 3652 class B extends A {
3657 const B() : super(5); 3653 const B() : super(5);
3658 } 3654 }
3659 const B b = const B();''', 3655 const B b = const B();''');
3660 []);
3661 } 3656 }
3662 3657
3663 void test_dependencyOnExplicitSuperConstructorParameters() { 3658 void test_dependencyOnExplicitSuperConstructorParameters() {
3664 // b depends on B() depends on i 3659 // b depends on B() depends on i
3665 _assertProperDependencies(r''' 3660 _assertProperDependencies(r'''
3666 class A { 3661 class A {
3667 const A(this.x); 3662 const A(this.x);
3668 final int x; 3663 final int x;
3669 } 3664 }
3670 class B extends A { 3665 class B extends A {
3671 const B() : super(i); 3666 const B() : super(i);
3672 } 3667 }
3673 const B b = const B(); 3668 const B b = const B();
3674 const int i = 5;''', 3669 const int i = 5;''');
3675 []);
3676 } 3670 }
3677 3671
3678 void test_dependencyOnFactoryRedirect() { 3672 void test_dependencyOnFactoryRedirect() {
3679 // a depends on A.foo() depends on A.bar() 3673 // a depends on A.foo() depends on A.bar()
3680 _assertProperDependencies(r''' 3674 _assertProperDependencies(r'''
3681 const A a = const A.foo(); 3675 const A a = const A.foo();
3682 class A { 3676 class A {
3683 factory const A.foo() = A.bar; 3677 factory const A.foo() = A.bar;
3684 const A.bar(); 3678 const A.bar();
3685 }''', 3679 }''');
3686 []);
3687 } 3680 }
3688 3681
3689 void test_dependencyOnFactoryRedirectWithTypeParams() { 3682 void test_dependencyOnFactoryRedirectWithTypeParams() {
3690 _assertProperDependencies(r''' 3683 _assertProperDependencies(r'''
3691 class A { 3684 class A {
3692 const factory A(var a) = B<int>; 3685 const factory A(var a) = B<int>;
3693 } 3686 }
3694 3687
3695 class B<T> implements A { 3688 class B<T> implements A {
3696 final T x; 3689 final T x;
3697 const B(this.x); 3690 const B(this.x);
3698 } 3691 }
3699 3692
3700 const A a = const A(10);''', 3693 const A a = const A(10);''');
3701 []);
3702 } 3694 }
3703 3695
3704 void test_dependencyOnImplicitSuperConstructor() { 3696 void test_dependencyOnImplicitSuperConstructor() {
3705 // b depends on B() depends on A() 3697 // b depends on B() depends on A()
3706 _assertProperDependencies(r''' 3698 _assertProperDependencies(r'''
3707 class A { 3699 class A {
3708 const A() : x = 5; 3700 const A() : x = 5;
3709 final int x; 3701 final int x;
3710 } 3702 }
3711 class B extends A { 3703 class B extends A {
3712 const B(); 3704 const B();
3713 } 3705 }
3714 const B b = const B();''', 3706 const B b = const B();''');
3715 []);
3716 } 3707 }
3717 3708
3718 void test_dependencyOnNonFactoryRedirect() { 3709 void test_dependencyOnNonFactoryRedirect() {
3719 // a depends on A.foo() depends on A.bar() 3710 // a depends on A.foo() depends on A.bar()
3720 _assertProperDependencies(r''' 3711 _assertProperDependencies(r'''
3721 const A a = const A.foo(); 3712 const A a = const A.foo();
3722 class A { 3713 class A {
3723 const A.foo() : this.bar(); 3714 const A.foo() : this.bar();
3724 const A.bar(); 3715 const A.bar();
3725 }''', 3716 }''');
3726 []);
3727 } 3717 }
3728 3718
3729 void test_dependencyOnNonFactoryRedirect_arg() { 3719 void test_dependencyOnNonFactoryRedirect_arg() {
3730 // a depends on A.foo() depends on b 3720 // a depends on A.foo() depends on b
3731 _assertProperDependencies(r''' 3721 _assertProperDependencies(r'''
3732 const A a = const A.foo(); 3722 const A a = const A.foo();
3733 const int b = 1; 3723 const int b = 1;
3734 class A { 3724 class A {
3735 const A.foo() : this.bar(b); 3725 const A.foo() : this.bar(b);
3736 const A.bar(x) : y = x; 3726 const A.bar(x) : y = x;
3737 final int y; 3727 final int y;
3738 }''', 3728 }''');
3739 []);
3740 } 3729 }
3741 3730
3742 void test_dependencyOnNonFactoryRedirect_defaultValue() { 3731 void test_dependencyOnNonFactoryRedirect_defaultValue() {
3743 // a depends on A.foo() depends on A.bar() depends on b 3732 // a depends on A.foo() depends on A.bar() depends on b
3744 _assertProperDependencies(r''' 3733 _assertProperDependencies(r'''
3745 const A a = const A.foo(); 3734 const A a = const A.foo();
3746 const int b = 1; 3735 const int b = 1;
3747 class A { 3736 class A {
3748 const A.foo() : this.bar(); 3737 const A.foo() : this.bar();
3749 const A.bar([x = b]) : y = x; 3738 const A.bar([x = b]) : y = x;
3750 final int y; 3739 final int y;
3751 }''', 3740 }''');
3752 []);
3753 } 3741 }
3754 3742
3755 void test_dependencyOnNonFactoryRedirect_toMissing() { 3743 void test_dependencyOnNonFactoryRedirect_toMissing() {
3756 // a depends on A.foo() which depends on nothing, since A.bar() is 3744 // a depends on A.foo() which depends on nothing, since A.bar() is
3757 // missing. 3745 // missing.
3758 _assertProperDependencies(r''' 3746 _assertProperDependencies(r'''
3759 const A a = const A.foo(); 3747 const A a = const A.foo();
3760 class A { 3748 class A {
3761 const A.foo() : this.bar(); 3749 const A.foo() : this.bar();
3762 }''', 3750 }''',
3763 [CompileTimeErrorCode.REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR]); 3751 [CompileTimeErrorCode.REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR]);
3764 } 3752 }
3765 3753
3766 void test_dependencyOnNonFactoryRedirect_toNonConst() { 3754 void test_dependencyOnNonFactoryRedirect_toNonConst() {
3767 // a depends on A.foo() which depends on nothing, since A.bar() is 3755 // a depends on A.foo() which depends on nothing, since A.bar() is
3768 // non-const. 3756 // non-const.
3769 _assertProperDependencies(r''' 3757 _assertProperDependencies(r'''
3770 const A a = const A.foo(); 3758 const A a = const A.foo();
3771 class A { 3759 class A {
3772 const A.foo() : this.bar(); 3760 const A.foo() : this.bar();
3773 A.bar(); 3761 A.bar();
3774 }''', 3762 }''');
3775 []);
3776 } 3763 }
3777 3764
3778 void test_dependencyOnNonFactoryRedirect_unnamed() { 3765 void test_dependencyOnNonFactoryRedirect_unnamed() {
3779 // a depends on A.foo() depends on A() 3766 // a depends on A.foo() depends on A()
3780 _assertProperDependencies(r''' 3767 _assertProperDependencies(r'''
3781 const A a = const A.foo(); 3768 const A a = const A.foo();
3782 class A { 3769 class A {
3783 const A.foo() : this(); 3770 const A.foo() : this();
3784 const A(); 3771 const A();
3785 }''', 3772 }''');
3786 []);
3787 } 3773 }
3788 3774
3789 void test_dependencyOnOptionalParameterDefault() { 3775 void test_dependencyOnOptionalParameterDefault() {
3790 // a depends on A() depends on B() 3776 // a depends on A() depends on B()
3791 _assertProperDependencies(r''' 3777 _assertProperDependencies(r'''
3792 class A { 3778 class A {
3793 const A([x = const B()]) : b = x; 3779 const A([x = const B()]) : b = x;
3794 final B b; 3780 final B b;
3795 } 3781 }
3796 class B { 3782 class B {
3797 const B(); 3783 const B();
3798 } 3784 }
3799 const A a = const A();''', 3785 const A a = const A();''');
3800 []);
3801 } 3786 }
3802 3787
3803 void test_dependencyOnVariable() { 3788 void test_dependencyOnVariable() {
3804 // x depends on y 3789 // x depends on y
3805 _assertProperDependencies(r''' 3790 _assertProperDependencies(r'''
3806 const x = y + 1; 3791 const x = y + 1;
3807 const y = 2;''', 3792 const y = 2;''');
3808 []);
3809 } 3793 }
3810 3794
3811 void test_fromEnvironment_bool_default_false() { 3795 void test_fromEnvironment_bool_default_false() {
3812 expect(_assertValidBool(_check_fromEnvironment_bool(null, "false")), false); 3796 expect(_assertValidBool(_check_fromEnvironment_bool(null, "false")), false);
3813 } 3797 }
3814 3798
3815 void test_fromEnvironment_bool_default_overridden() { 3799 void test_fromEnvironment_bool_default_overridden() {
3816 expect(_assertValidBool(_check_fromEnvironment_bool("false", "true")), false ); 3800 expect(_assertValidBool(_check_fromEnvironment_bool("false", "true")), false );
3817 } 3801 }
3818 3802
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
4342 expect(field.type.name, "int"); 4326 expect(field.type.name, "int");
4343 expect(field.intValue, expectedValue); 4327 expect(field.intValue, expectedValue);
4344 } 4328 }
4345 4329
4346 void _assertNullField(Map<String, DartObjectImpl> fields, String fieldName) { 4330 void _assertNullField(Map<String, DartObjectImpl> fields, String fieldName) {
4347 DartObjectImpl field = fields[fieldName]; 4331 DartObjectImpl field = fields[fieldName];
4348 expect(field.isNull, isTrue); 4332 expect(field.isNull, isTrue);
4349 } 4333 }
4350 4334
4351 void _assertProperDependencies(String sourceText, 4335 void _assertProperDependencies(String sourceText,
4352 List<ErrorCode> expectedErrorCodes) { 4336 [List<ErrorCode> expectedErrorCodes = ErrorCode.EMPTY_LIST]) {
4353 Source source = addSource(sourceText); 4337 Source source = addSource(sourceText);
4354 LibraryElement element = resolve(source); 4338 LibraryElement element = resolve(source);
4355 CompilationUnit unit = 4339 CompilationUnit unit =
4356 analysisContext.resolveCompilationUnit(source, element); 4340 analysisContext.resolveCompilationUnit(source, element);
4357 expect(unit, isNotNull); 4341 expect(unit, isNotNull);
4358 ConstantValueComputer computer = _makeConstantValueComputer(); 4342 ConstantValueComputer computer = _makeConstantValueComputer();
4359 computer.add(unit); 4343 computer.add(unit);
4360 computer.computeValues(); 4344 computer.computeValues();
4361 assertErrors(source, expectedErrorCodes); 4345 assertErrors(source, expectedErrorCodes);
4362 } 4346 }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
4562 GatheringErrorListener errorListener = new GatheringErrorListener(); 4546 GatheringErrorListener errorListener = new GatheringErrorListener();
4563 ErrorReporter errorReporter = 4547 ErrorReporter errorReporter =
4564 new ErrorReporter(errorListener, _dummySource()); 4548 new ErrorReporter(errorListener, _dummySource());
4565 _assertValue( 4549 _assertValue(
4566 0, 4550 0,
4567 expression.accept( 4551 expression.accept(
4568 new ConstantVisitor.con1(new TestTypeProvider(), errorReporter))); 4552 new ConstantVisitor.con1(new TestTypeProvider(), errorReporter)));
4569 errorListener.assertNoErrors(); 4553 errorListener.assertNoErrors();
4570 } 4554 }
4571 4555
4572 void 4556 void test_visitConditionalExpression_instanceCreation_invalidFieldInitializer( ) {
4573 test_visitConditionalExpression_instanceCreation_invalidFieldInitializer() {
4574 TestTypeProvider typeProvider = new TestTypeProvider(); 4557 TestTypeProvider typeProvider = new TestTypeProvider();
4575 LibraryElementImpl libraryElement = ElementFactory.library(null, "lib"); 4558 LibraryElementImpl libraryElement = ElementFactory.library(null, "lib");
4576 String className = "C"; 4559 String className = "C";
4577 ClassElementImpl classElement = ElementFactory.classElement2(className, []); 4560 ClassElementImpl classElement = ElementFactory.classElement2(className);
4578 (libraryElement.definingCompilationUnit as CompilationUnitElementImpl).types = 4561 (libraryElement.definingCompilationUnit as CompilationUnitElementImpl).types =
4579 <ClassElement>[classElement]; 4562 <ClassElement>[classElement];
4580 ConstructorElementImpl constructorElement = 4563 ConstructorElementImpl constructorElement =
4581 ElementFactory.constructorElement( 4564 ElementFactory.constructorElement(
4582 classElement, 4565 classElement,
4583 null, 4566 null,
4584 true, 4567 true,
4585 [typeProvider.intType]); 4568 [typeProvider.intType]);
4586 constructorElement.parameters[0] = 4569 constructorElement.parameters[0] =
4587 new FieldFormalParameterElementImpl(AstFactory.identifier3("x")); 4570 new FieldFormalParameterElementImpl(AstFactory.identifier3("x"));
4588 InstanceCreationExpression expression = 4571 InstanceCreationExpression expression =
4589 AstFactory.instanceCreationExpression2( 4572 AstFactory.instanceCreationExpression2(
4590 Keyword.CONST, 4573 Keyword.CONST,
4591 AstFactory.typeName4(className, []), 4574 AstFactory.typeName4(className),
4592 [AstFactory.integer(0)]); 4575 [AstFactory.integer(0)]);
4593 expression.staticElement = constructorElement; 4576 expression.staticElement = constructorElement;
4594 GatheringErrorListener errorListener = new GatheringErrorListener(); 4577 GatheringErrorListener errorListener = new GatheringErrorListener();
4595 ErrorReporter errorReporter = 4578 ErrorReporter errorReporter =
4596 new ErrorReporter(errorListener, _dummySource()); 4579 new ErrorReporter(errorListener, _dummySource());
4597 expression.accept(new ConstantVisitor.con1(typeProvider, errorReporter)); 4580 expression.accept(new ConstantVisitor.con1(typeProvider, errorReporter));
4598 errorListener.assertErrorsWithCodes( 4581 errorListener.assertErrorsWithCodes(
4599 [CompileTimeErrorCode.INVALID_CONSTANT]); 4582 [CompileTimeErrorCode.INVALID_CONSTANT]);
4600 } 4583 }
4601 4584
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
5012 4995
5013 void test_equalEqual_int_true() { 4996 void test_equalEqual_int_true() {
5014 _assertEqualEqual(_boolValue(true), _intValue(5), _intValue(5)); 4997 _assertEqualEqual(_boolValue(true), _intValue(5), _intValue(5));
5015 } 4998 }
5016 4999
5017 void test_equalEqual_int_unknown() { 5000 void test_equalEqual_int_unknown() {
5018 _assertEqualEqual(_boolValue(null), _intValue(null), _intValue(3)); 5001 _assertEqualEqual(_boolValue(null), _intValue(null), _intValue(3));
5019 } 5002 }
5020 5003
5021 void test_equalEqual_list_empty() { 5004 void test_equalEqual_list_empty() {
5022 _assertEqualEqual(null, _listValue([]), _listValue([])); 5005 _assertEqualEqual(null, _listValue(), _listValue());
5023 } 5006 }
5024 5007
5025 void test_equalEqual_list_false() { 5008 void test_equalEqual_list_false() {
5026 _assertEqualEqual(null, _listValue([]), _listValue([])); 5009 _assertEqualEqual(null, _listValue(), _listValue());
5027 } 5010 }
5028 5011
5029 void test_equalEqual_map_empty() { 5012 void test_equalEqual_map_empty() {
5030 _assertEqualEqual(null, _mapValue([]), _mapValue([])); 5013 _assertEqualEqual(null, _mapValue(), _mapValue());
5031 } 5014 }
5032 5015
5033 void test_equalEqual_map_false() { 5016 void test_equalEqual_map_false() {
5034 _assertEqualEqual(null, _mapValue([]), _mapValue([])); 5017 _assertEqualEqual(null, _mapValue(), _mapValue());
5035 } 5018 }
5036 5019
5037 void test_equalEqual_null() { 5020 void test_equalEqual_null() {
5038 _assertEqualEqual(_boolValue(true), _nullValue(), _nullValue()); 5021 _assertEqualEqual(_boolValue(true), _nullValue(), _nullValue());
5039 } 5022 }
5040 5023
5041 void test_equalEqual_string_false() { 5024 void test_equalEqual_string_false() {
5042 _assertEqualEqual( 5025 _assertEqualEqual(
5043 _boolValue(false), 5026 _boolValue(false),
5044 _stringValue("abc"), 5027 _stringValue("abc"),
(...skipping 17 matching lines...) Expand all
5062 void test_equals_list_false_differentSizes() { 5045 void test_equals_list_false_differentSizes() {
5063 expect(_listValue([_boolValue(true)]) == 5046 expect(_listValue([_boolValue(true)]) ==
5064 _listValue([_boolValue(true), _boolValue(false)]), isFalse); 5047 _listValue([_boolValue(true), _boolValue(false)]), isFalse);
5065 } 5048 }
5066 5049
5067 void test_equals_list_false_sameSize() { 5050 void test_equals_list_false_sameSize() {
5068 expect(_listValue([_boolValue(true)]) == _listValue([_boolValue(false)]), is False); 5051 expect(_listValue([_boolValue(true)]) == _listValue([_boolValue(false)]), is False);
5069 } 5052 }
5070 5053
5071 void test_equals_list_true_empty() { 5054 void test_equals_list_true_empty() {
5072 expect(_listValue([]), _listValue([])); 5055 expect(_listValue(), _listValue());
5073 } 5056 }
5074 5057
5075 void test_equals_list_true_nonEmpty() { 5058 void test_equals_list_true_nonEmpty() {
5076 expect(_listValue([_boolValue(true)]), _listValue([_boolValue(true)])); 5059 expect(_listValue([_boolValue(true)]), _listValue([_boolValue(true)]));
5077 } 5060 }
5078 5061
5079 void test_equals_map_true_empty() { 5062 void test_equals_map_true_empty() {
5080 expect(_mapValue([]), _mapValue([])); 5063 expect(_mapValue(), _mapValue());
5081 } 5064 }
5082 5065
5083 void test_equals_symbol_false() { 5066 void test_equals_symbol_false() {
5084 expect(_symbolValue("a") == _symbolValue("b"), isFalse); 5067 expect(_symbolValue("a") == _symbolValue("b"), isFalse);
5085 } 5068 }
5086 5069
5087 void test_equals_symbol_true() { 5070 void test_equals_symbol_true() {
5088 expect(_symbolValue("a"), _symbolValue("a")); 5071 expect(_symbolValue("a"), _symbolValue("a"));
5089 } 5072 }
5090 5073
(...skipping 21 matching lines...) Expand all
5112 void test_getValue_int_known() { 5095 void test_getValue_int_known() {
5113 int value = 23; 5096 int value = 23;
5114 expect(_intValue(value).value, value); 5097 expect(_intValue(value).value, value);
5115 } 5098 }
5116 5099
5117 void test_getValue_int_unknown() { 5100 void test_getValue_int_unknown() {
5118 expect(_intValue(null).value, isNull); 5101 expect(_intValue(null).value, isNull);
5119 } 5102 }
5120 5103
5121 void test_getValue_list_empty() { 5104 void test_getValue_list_empty() {
5122 Object result = _listValue([]).value; 5105 Object result = _listValue().value;
5123 _assertInstanceOfObjectArray(result); 5106 _assertInstanceOfObjectArray(result);
5124 List<Object> array = result as List<Object>; 5107 List<Object> array = result as List<Object>;
5125 expect(array, hasLength(0)); 5108 expect(array, hasLength(0));
5126 } 5109 }
5127 5110
5128 void test_getValue_list_valid() { 5111 void test_getValue_list_valid() {
5129 Object result = _listValue([_intValue(23)]).value; 5112 Object result = _listValue([_intValue(23)]).value;
5130 _assertInstanceOfObjectArray(result); 5113 _assertInstanceOfObjectArray(result);
5131 List<Object> array = result as List<Object>; 5114 List<Object> array = result as List<Object>;
5132 expect(array, hasLength(1)); 5115 expect(array, hasLength(1));
5133 } 5116 }
5134 5117
5135 void test_getValue_map_empty() { 5118 void test_getValue_map_empty() {
5136 Object result = _mapValue([]).value; 5119 Object result = _mapValue().value;
5137 EngineTestCase.assertInstanceOf((obj) => obj is Map, Map, result); 5120 EngineTestCase.assertInstanceOf((obj) => obj is Map, Map, result);
5138 Map map = result as Map; 5121 Map map = result as Map;
5139 expect(map, hasLength(0)); 5122 expect(map, hasLength(0));
5140 } 5123 }
5141 5124
5142 void test_getValue_map_valid() { 5125 void test_getValue_map_valid() {
5143 Object result = 5126 Object result =
5144 _mapValue([_stringValue("key"), _stringValue("value")]).value; 5127 _mapValue([_stringValue("key"), _stringValue("value")]).value;
5145 EngineTestCase.assertInstanceOf((obj) => obj is Map, Map, result); 5128 EngineTestCase.assertInstanceOf((obj) => obj is Map, Map, result);
5146 Map map = result as Map; 5129 Map map = result as Map;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
5344 5327
5345 void test_hasExactValue_int_known() { 5328 void test_hasExactValue_int_known() {
5346 expect(_intValue(23).hasExactValue, isTrue); 5329 expect(_intValue(23).hasExactValue, isTrue);
5347 } 5330 }
5348 5331
5349 void test_hasExactValue_int_unknown() { 5332 void test_hasExactValue_int_unknown() {
5350 expect(_intValue(null).hasExactValue, isTrue); 5333 expect(_intValue(null).hasExactValue, isTrue);
5351 } 5334 }
5352 5335
5353 void test_hasExactValue_list_empty() { 5336 void test_hasExactValue_list_empty() {
5354 expect(_listValue([]).hasExactValue, isTrue); 5337 expect(_listValue().hasExactValue, isTrue);
5355 } 5338 }
5356 5339
5357 void test_hasExactValue_list_invalid() { 5340 void test_hasExactValue_list_invalid() {
5358 expect(_dynamicValue().hasExactValue, isFalse); 5341 expect(_dynamicValue().hasExactValue, isFalse);
5359 } 5342 }
5360 5343
5361 void test_hasExactValue_list_valid() { 5344 void test_hasExactValue_list_valid() {
5362 expect(_listValue([_intValue(23)]).hasExactValue, isTrue); 5345 expect(_listValue([_intValue(23)]).hasExactValue, isTrue);
5363 } 5346 }
5364 5347
5365 void test_hasExactValue_map_empty() { 5348 void test_hasExactValue_map_empty() {
5366 expect(_mapValue([]).hasExactValue, isTrue); 5349 expect(_mapValue().hasExactValue, isTrue);
5367 } 5350 }
5368 5351
5369 void test_hasExactValue_map_invalidKey() { 5352 void test_hasExactValue_map_invalidKey() {
5370 expect(_mapValue([_dynamicValue(), _stringValue("value")]).hasExactValue, is False); 5353 expect(_mapValue([_dynamicValue(), _stringValue("value")]).hasExactValue, is False);
5371 } 5354 }
5372 5355
5373 void test_hasExactValue_map_invalidValue() { 5356 void test_hasExactValue_map_invalidValue() {
5374 expect(_mapValue([_stringValue("key"), _dynamicValue()]).hasExactValue, isFa lse); 5357 expect(_mapValue([_stringValue("key"), _dynamicValue()]).hasExactValue, isFa lse);
5375 } 5358 }
5376 5359
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
5424 5407
5425 void test_identical_int_true() { 5408 void test_identical_int_true() {
5426 _assertIdentical(_boolValue(true), _intValue(5), _intValue(5)); 5409 _assertIdentical(_boolValue(true), _intValue(5), _intValue(5));
5427 } 5410 }
5428 5411
5429 void test_identical_int_unknown() { 5412 void test_identical_int_unknown() {
5430 _assertIdentical(_boolValue(null), _intValue(null), _intValue(3)); 5413 _assertIdentical(_boolValue(null), _intValue(null), _intValue(3));
5431 } 5414 }
5432 5415
5433 void test_identical_list_empty() { 5416 void test_identical_list_empty() {
5434 _assertIdentical(_boolValue(true), _listValue([]), _listValue([])); 5417 _assertIdentical(_boolValue(true), _listValue(), _listValue());
5435 } 5418 }
5436 5419
5437 void test_identical_list_false() { 5420 void test_identical_list_false() {
5438 _assertIdentical(_boolValue(false), _listValue([]), 5421 _assertIdentical(_boolValue(false), _listValue(),
5439 _listValue([_intValue(3)])); 5422 _listValue([_intValue(3)]));
5440 } 5423 }
5441 5424
5442 void test_identical_map_empty() { 5425 void test_identical_map_empty() {
5443 _assertIdentical(_boolValue(true), _mapValue([]), _mapValue([])); 5426 _assertIdentical(_boolValue(true), _mapValue(), _mapValue());
5444 } 5427 }
5445 5428
5446 void test_identical_map_false() { 5429 void test_identical_map_false() {
5447 _assertIdentical(_boolValue(false), _mapValue([]), 5430 _assertIdentical(_boolValue(false), _mapValue(),
5448 _mapValue([_intValue(1), _intValue(2)])); 5431 _mapValue([_intValue(1), _intValue(2)]));
5449 } 5432 }
5450 5433
5451 void test_identical_null() { 5434 void test_identical_null() {
5452 _assertIdentical(_boolValue(true), _nullValue(), _nullValue()); 5435 _assertIdentical(_boolValue(true), _nullValue(), _nullValue());
5453 } 5436 }
5454 5437
5455 void test_identical_string_false() { 5438 void test_identical_string_false() {
5456 _assertIdentical( 5439 _assertIdentical(
5457 _boolValue(false), 5440 _boolValue(false),
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
5557 5540
5558 void test_isBoolNumStringOrNull_int_known() { 5541 void test_isBoolNumStringOrNull_int_known() {
5559 expect(_intValue(23).isBoolNumStringOrNull, isTrue); 5542 expect(_intValue(23).isBoolNumStringOrNull, isTrue);
5560 } 5543 }
5561 5544
5562 void test_isBoolNumStringOrNull_int_unknown() { 5545 void test_isBoolNumStringOrNull_int_unknown() {
5563 expect(_intValue(null).isBoolNumStringOrNull, isTrue); 5546 expect(_intValue(null).isBoolNumStringOrNull, isTrue);
5564 } 5547 }
5565 5548
5566 void test_isBoolNumStringOrNull_list() { 5549 void test_isBoolNumStringOrNull_list() {
5567 expect(_listValue([]).isBoolNumStringOrNull, isFalse); 5550 expect(_listValue().isBoolNumStringOrNull, isFalse);
5568 } 5551 }
5569 5552
5570 void test_isBoolNumStringOrNull_null() { 5553 void test_isBoolNumStringOrNull_null() {
5571 expect(_nullValue().isBoolNumStringOrNull, isTrue); 5554 expect(_nullValue().isBoolNumStringOrNull, isTrue);
5572 } 5555 }
5573 5556
5574 void test_isBoolNumStringOrNull_num() { 5557 void test_isBoolNumStringOrNull_num() {
5575 expect(_numValue().isBoolNumStringOrNull, isTrue); 5558 expect(_numValue().isBoolNumStringOrNull, isTrue);
5576 } 5559 }
5577 5560
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after
6932 } 6915 }
6933 6916
6934 DartObjectImpl _intValue(int value) { 6917 DartObjectImpl _intValue(int value) {
6935 if (value == null) { 6918 if (value == null) {
6936 return new DartObjectImpl(_typeProvider.intType, IntState.UNKNOWN_VALUE); 6919 return new DartObjectImpl(_typeProvider.intType, IntState.UNKNOWN_VALUE);
6937 } else { 6920 } else {
6938 return new DartObjectImpl(_typeProvider.intType, new IntState(value)); 6921 return new DartObjectImpl(_typeProvider.intType, new IntState(value));
6939 } 6922 }
6940 } 6923 }
6941 6924
6942 DartObjectImpl _listValue(List<DartObjectImpl> elements) { 6925 DartObjectImpl _listValue([List<DartObjectImpl> elements = DartObjectImpl.EMPT Y_LIST]) {
6943 return new DartObjectImpl(_typeProvider.listType, new ListState(elements)); 6926 return new DartObjectImpl(_typeProvider.listType, new ListState(elements));
6944 } 6927 }
6945 6928
6946 DartObjectImpl _mapValue(List<DartObjectImpl> keyElementPairs) { 6929 DartObjectImpl _mapValue([List<DartObjectImpl> keyElementPairs = DartObjectImp l.EMPTY_LIST]) {
6947 Map<DartObjectImpl, DartObjectImpl> map = 6930 Map<DartObjectImpl, DartObjectImpl> map =
6948 new Map<DartObjectImpl, DartObjectImpl>(); 6931 new Map<DartObjectImpl, DartObjectImpl>();
6949 int count = keyElementPairs.length; 6932 int count = keyElementPairs.length;
6950 for (int i = 0; i < count; ) { 6933 for (int i = 0; i < count; ) {
6951 map[keyElementPairs[i++]] = keyElementPairs[i++]; 6934 map[keyElementPairs[i++]] = keyElementPairs[i++];
6952 } 6935 }
6953 return new DartObjectImpl(_typeProvider.mapType, new MapState(map)); 6936 return new DartObjectImpl(_typeProvider.mapType, new MapState(map));
6954 } 6937 }
6955 6938
6956 DartObjectImpl _nullValue() { 6939 DartObjectImpl _nullValue() {
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
7247 } 7230 }
7248 7231
7249 7232
7250 class ElementBuilderTest extends EngineTestCase { 7233 class ElementBuilderTest extends EngineTestCase {
7251 void test_visitCatchClause() { 7234 void test_visitCatchClause() {
7252 ElementHolder holder = new ElementHolder(); 7235 ElementHolder holder = new ElementHolder();
7253 ElementBuilder builder = new ElementBuilder(holder); 7236 ElementBuilder builder = new ElementBuilder(holder);
7254 String exceptionParameterName = "e"; 7237 String exceptionParameterName = "e";
7255 String stackParameterName = "s"; 7238 String stackParameterName = "s";
7256 CatchClause clause = 7239 CatchClause clause =
7257 AstFactory.catchClause2(exceptionParameterName, stackParameterName, []); 7240 AstFactory.catchClause2(exceptionParameterName, stackParameterName);
7258 clause.accept(builder); 7241 clause.accept(builder);
7259 List<LocalVariableElement> variables = holder.localVariables; 7242 List<LocalVariableElement> variables = holder.localVariables;
7260 expect(variables, hasLength(2)); 7243 expect(variables, hasLength(2));
7261 VariableElement exceptionVariable = variables[0]; 7244 VariableElement exceptionVariable = variables[0];
7262 expect(exceptionVariable, isNotNull); 7245 expect(exceptionVariable, isNotNull);
7263 expect(exceptionVariable.name, exceptionParameterName); 7246 expect(exceptionVariable.name, exceptionParameterName);
7264 expect(exceptionVariable.isSynthetic, isFalse); 7247 expect(exceptionVariable.isSynthetic, isFalse);
7265 expect(exceptionVariable.isConst, isFalse); 7248 expect(exceptionVariable.isConst, isFalse);
7266 expect(exceptionVariable.isFinal, isFalse); 7249 expect(exceptionVariable.isFinal, isFalse);
7267 expect(exceptionVariable.initializer, isNull); 7250 expect(exceptionVariable.initializer, isNull);
7268 VariableElement stackVariable = variables[1]; 7251 VariableElement stackVariable = variables[1];
7269 expect(stackVariable, isNotNull); 7252 expect(stackVariable, isNotNull);
7270 expect(stackVariable.name, stackParameterName); 7253 expect(stackVariable.name, stackParameterName);
7271 expect(stackVariable.isSynthetic, isFalse); 7254 expect(stackVariable.isSynthetic, isFalse);
7272 expect(stackVariable.isConst, isFalse); 7255 expect(stackVariable.isConst, isFalse);
7273 expect(stackVariable.isFinal, isFalse); 7256 expect(stackVariable.isFinal, isFalse);
7274 expect(stackVariable.initializer, isNull); 7257 expect(stackVariable.initializer, isNull);
7275 } 7258 }
7276 7259
7277 void test_visitClassDeclaration_abstract() { 7260 void test_visitClassDeclaration_abstract() {
7278 ElementHolder holder = new ElementHolder(); 7261 ElementHolder holder = new ElementHolder();
7279 ElementBuilder builder = new ElementBuilder(holder); 7262 ElementBuilder builder = new ElementBuilder(holder);
7280 String className = "C"; 7263 String className = "C";
7281 ClassDeclaration classDeclaration = AstFactory.classDeclaration( 7264 ClassDeclaration classDeclaration = AstFactory.classDeclaration(
7282 Keyword.ABSTRACT, 7265 Keyword.ABSTRACT,
7283 className, 7266 className,
7284 null, 7267 null,
7285 null, 7268 null,
7286 null, 7269 null,
7287 null, 7270 null);
7288 []);
7289 classDeclaration.accept(builder); 7271 classDeclaration.accept(builder);
7290 List<ClassElement> types = holder.types; 7272 List<ClassElement> types = holder.types;
7291 expect(types, hasLength(1)); 7273 expect(types, hasLength(1));
7292 ClassElement type = types[0]; 7274 ClassElement type = types[0];
7293 expect(type, isNotNull); 7275 expect(type, isNotNull);
7294 expect(type.name, className); 7276 expect(type.name, className);
7295 List<TypeParameterElement> typeParameters = type.typeParameters; 7277 List<TypeParameterElement> typeParameters = type.typeParameters;
7296 expect(typeParameters, hasLength(0)); 7278 expect(typeParameters, hasLength(0));
7297 expect(type.isAbstract, isTrue); 7279 expect(type.isAbstract, isTrue);
7298 expect(type.isSynthetic, isFalse); 7280 expect(type.isSynthetic, isFalse);
7299 } 7281 }
7300 7282
7301 void test_visitClassDeclaration_minimal() { 7283 void test_visitClassDeclaration_minimal() {
7302 ElementHolder holder = new ElementHolder(); 7284 ElementHolder holder = new ElementHolder();
7303 ElementBuilder builder = new ElementBuilder(holder); 7285 ElementBuilder builder = new ElementBuilder(holder);
7304 String className = "C"; 7286 String className = "C";
7305 ClassDeclaration classDeclaration = 7287 ClassDeclaration classDeclaration =
7306 AstFactory.classDeclaration(null, className, null, null, null, null, []) ; 7288 AstFactory.classDeclaration(null, className, null, null, null, null);
7307 classDeclaration.accept(builder); 7289 classDeclaration.accept(builder);
7308 List<ClassElement> types = holder.types; 7290 List<ClassElement> types = holder.types;
7309 expect(types, hasLength(1)); 7291 expect(types, hasLength(1));
7310 ClassElement type = types[0]; 7292 ClassElement type = types[0];
7311 expect(type, isNotNull); 7293 expect(type, isNotNull);
7312 expect(type.name, className); 7294 expect(type.name, className);
7313 List<TypeParameterElement> typeParameters = type.typeParameters; 7295 List<TypeParameterElement> typeParameters = type.typeParameters;
7314 expect(typeParameters, hasLength(0)); 7296 expect(typeParameters, hasLength(0));
7315 expect(type.isAbstract, isFalse); 7297 expect(type.isAbstract, isFalse);
7316 expect(type.isSynthetic, isFalse); 7298 expect(type.isSynthetic, isFalse);
7317 } 7299 }
7318 7300
7319 void test_visitClassDeclaration_parameterized() { 7301 void test_visitClassDeclaration_parameterized() {
7320 ElementHolder holder = new ElementHolder(); 7302 ElementHolder holder = new ElementHolder();
7321 ElementBuilder builder = new ElementBuilder(holder); 7303 ElementBuilder builder = new ElementBuilder(holder);
7322 String className = "C"; 7304 String className = "C";
7323 String firstVariableName = "E"; 7305 String firstVariableName = "E";
7324 String secondVariableName = "F"; 7306 String secondVariableName = "F";
7325 ClassDeclaration classDeclaration = AstFactory.classDeclaration( 7307 ClassDeclaration classDeclaration = AstFactory.classDeclaration(
7326 null, 7308 null,
7327 className, 7309 className,
7328 AstFactory.typeParameterList([firstVariableName, secondVariableName]), 7310 AstFactory.typeParameterList([firstVariableName, secondVariableName]),
7329 null, 7311 null,
7330 null, 7312 null,
7331 null, 7313 null);
7332 []);
7333 classDeclaration.accept(builder); 7314 classDeclaration.accept(builder);
7334 List<ClassElement> types = holder.types; 7315 List<ClassElement> types = holder.types;
7335 expect(types, hasLength(1)); 7316 expect(types, hasLength(1));
7336 ClassElement type = types[0]; 7317 ClassElement type = types[0];
7337 expect(type, isNotNull); 7318 expect(type, isNotNull);
7338 expect(type.name, className); 7319 expect(type.name, className);
7339 List<TypeParameterElement> typeParameters = type.typeParameters; 7320 List<TypeParameterElement> typeParameters = type.typeParameters;
7340 expect(typeParameters, hasLength(2)); 7321 expect(typeParameters, hasLength(2));
7341 expect(typeParameters[0].name, firstVariableName); 7322 expect(typeParameters[0].name, firstVariableName);
7342 expect(typeParameters[1].name, secondVariableName); 7323 expect(typeParameters[1].name, secondVariableName);
(...skipping 19 matching lines...) Expand all
7362 AstFactory.fieldDeclaration2( 7343 AstFactory.fieldDeclaration2(
7363 false, 7344 false,
7364 null, 7345 null,
7365 [AstFactory.variableDeclaration(fieldName)]), 7346 [AstFactory.variableDeclaration(fieldName)]),
7366 AstFactory.methodDeclaration2( 7347 AstFactory.methodDeclaration2(
7367 null, 7348 null,
7368 null, 7349 null,
7369 null, 7350 null,
7370 null, 7351 null,
7371 AstFactory.identifier3(methodName), 7352 AstFactory.identifier3(methodName),
7372 AstFactory.formalParameterList([]), 7353 AstFactory.formalParameterList(),
7373 AstFactory.blockFunctionBody2([]))]); 7354 AstFactory.blockFunctionBody2())]);
7374 classDeclaration.accept(builder); 7355 classDeclaration.accept(builder);
7375 List<ClassElement> types = holder.types; 7356 List<ClassElement> types = holder.types;
7376 expect(types, hasLength(1)); 7357 expect(types, hasLength(1));
7377 ClassElement type = types[0]; 7358 ClassElement type = types[0];
7378 expect(type, isNotNull); 7359 expect(type, isNotNull);
7379 expect(type.name, className); 7360 expect(type.name, className);
7380 expect(type.isAbstract, isFalse); 7361 expect(type.isAbstract, isFalse);
7381 expect(type.isSynthetic, isFalse); 7362 expect(type.isSynthetic, isFalse);
7382 List<TypeParameterElement> typeParameters = type.typeParameters; 7363 List<TypeParameterElement> typeParameters = type.typeParameters;
7383 expect(typeParameters, hasLength(1)); 7364 expect(typeParameters, hasLength(1));
(...skipping 15 matching lines...) Expand all
7399 void test_visitConstructorDeclaration_factory() { 7380 void test_visitConstructorDeclaration_factory() {
7400 ElementHolder holder = new ElementHolder(); 7381 ElementHolder holder = new ElementHolder();
7401 ElementBuilder builder = new ElementBuilder(holder); 7382 ElementBuilder builder = new ElementBuilder(holder);
7402 String className = "A"; 7383 String className = "A";
7403 ConstructorDeclaration constructorDeclaration = 7384 ConstructorDeclaration constructorDeclaration =
7404 AstFactory.constructorDeclaration2( 7385 AstFactory.constructorDeclaration2(
7405 null, 7386 null,
7406 Keyword.FACTORY, 7387 Keyword.FACTORY,
7407 AstFactory.identifier3(className), 7388 AstFactory.identifier3(className),
7408 null, 7389 null,
7409 AstFactory.formalParameterList([]), 7390 AstFactory.formalParameterList(),
7410 null, 7391 null,
7411 AstFactory.blockFunctionBody2([])); 7392 AstFactory.blockFunctionBody2());
7412 constructorDeclaration.accept(builder); 7393 constructorDeclaration.accept(builder);
7413 List<ConstructorElement> constructors = holder.constructors; 7394 List<ConstructorElement> constructors = holder.constructors;
7414 expect(constructors, hasLength(1)); 7395 expect(constructors, hasLength(1));
7415 ConstructorElement constructor = constructors[0]; 7396 ConstructorElement constructor = constructors[0];
7416 expect(constructor, isNotNull); 7397 expect(constructor, isNotNull);
7417 expect(constructor.isFactory, isTrue); 7398 expect(constructor.isFactory, isTrue);
7418 expect(constructor.name, ""); 7399 expect(constructor.name, "");
7419 expect(constructor.functions, hasLength(0)); 7400 expect(constructor.functions, hasLength(0));
7420 expect(constructor.labels, hasLength(0)); 7401 expect(constructor.labels, hasLength(0));
7421 expect(constructor.localVariables, hasLength(0)); 7402 expect(constructor.localVariables, hasLength(0));
7422 expect(constructor.parameters, hasLength(0)); 7403 expect(constructor.parameters, hasLength(0));
7423 } 7404 }
7424 7405
7425 void test_visitConstructorDeclaration_minimal() { 7406 void test_visitConstructorDeclaration_minimal() {
7426 ElementHolder holder = new ElementHolder(); 7407 ElementHolder holder = new ElementHolder();
7427 ElementBuilder builder = new ElementBuilder(holder); 7408 ElementBuilder builder = new ElementBuilder(holder);
7428 String className = "A"; 7409 String className = "A";
7429 ConstructorDeclaration constructorDeclaration = 7410 ConstructorDeclaration constructorDeclaration =
7430 AstFactory.constructorDeclaration2( 7411 AstFactory.constructorDeclaration2(
7431 null, 7412 null,
7432 null, 7413 null,
7433 AstFactory.identifier3(className), 7414 AstFactory.identifier3(className),
7434 null, 7415 null,
7435 AstFactory.formalParameterList([]), 7416 AstFactory.formalParameterList(),
7436 null, 7417 null,
7437 AstFactory.blockFunctionBody2([])); 7418 AstFactory.blockFunctionBody2());
7438 constructorDeclaration.accept(builder); 7419 constructorDeclaration.accept(builder);
7439 List<ConstructorElement> constructors = holder.constructors; 7420 List<ConstructorElement> constructors = holder.constructors;
7440 expect(constructors, hasLength(1)); 7421 expect(constructors, hasLength(1));
7441 ConstructorElement constructor = constructors[0]; 7422 ConstructorElement constructor = constructors[0];
7442 expect(constructor, isNotNull); 7423 expect(constructor, isNotNull);
7443 expect(constructor.isFactory, isFalse); 7424 expect(constructor.isFactory, isFalse);
7444 expect(constructor.name, ""); 7425 expect(constructor.name, "");
7445 expect(constructor.functions, hasLength(0)); 7426 expect(constructor.functions, hasLength(0));
7446 expect(constructor.labels, hasLength(0)); 7427 expect(constructor.labels, hasLength(0));
7447 expect(constructor.localVariables, hasLength(0)); 7428 expect(constructor.localVariables, hasLength(0));
7448 expect(constructor.parameters, hasLength(0)); 7429 expect(constructor.parameters, hasLength(0));
7449 } 7430 }
7450 7431
7451 void test_visitConstructorDeclaration_named() { 7432 void test_visitConstructorDeclaration_named() {
7452 ElementHolder holder = new ElementHolder(); 7433 ElementHolder holder = new ElementHolder();
7453 ElementBuilder builder = new ElementBuilder(holder); 7434 ElementBuilder builder = new ElementBuilder(holder);
7454 String className = "A"; 7435 String className = "A";
7455 String constructorName = "c"; 7436 String constructorName = "c";
7456 ConstructorDeclaration constructorDeclaration = 7437 ConstructorDeclaration constructorDeclaration =
7457 AstFactory.constructorDeclaration2( 7438 AstFactory.constructorDeclaration2(
7458 null, 7439 null,
7459 null, 7440 null,
7460 AstFactory.identifier3(className), 7441 AstFactory.identifier3(className),
7461 constructorName, 7442 constructorName,
7462 AstFactory.formalParameterList([]), 7443 AstFactory.formalParameterList(),
7463 null, 7444 null,
7464 AstFactory.blockFunctionBody2([])); 7445 AstFactory.blockFunctionBody2());
7465 constructorDeclaration.accept(builder); 7446 constructorDeclaration.accept(builder);
7466 List<ConstructorElement> constructors = holder.constructors; 7447 List<ConstructorElement> constructors = holder.constructors;
7467 expect(constructors, hasLength(1)); 7448 expect(constructors, hasLength(1));
7468 ConstructorElement constructor = constructors[0]; 7449 ConstructorElement constructor = constructors[0];
7469 expect(constructor, isNotNull); 7450 expect(constructor, isNotNull);
7470 expect(constructor.isFactory, isFalse); 7451 expect(constructor.isFactory, isFalse);
7471 expect(constructor.name, constructorName); 7452 expect(constructor.name, constructorName);
7472 expect(constructor.functions, hasLength(0)); 7453 expect(constructor.functions, hasLength(0));
7473 expect(constructor.labels, hasLength(0)); 7454 expect(constructor.labels, hasLength(0));
7474 expect(constructor.localVariables, hasLength(0)); 7455 expect(constructor.localVariables, hasLength(0));
7475 expect(constructor.parameters, hasLength(0)); 7456 expect(constructor.parameters, hasLength(0));
7476 expect(constructorDeclaration.name.staticElement, same(constructor)); 7457 expect(constructorDeclaration.name.staticElement, same(constructor));
7477 expect(constructorDeclaration.element, same(constructor)); 7458 expect(constructorDeclaration.element, same(constructor));
7478 } 7459 }
7479 7460
7480 void test_visitConstructorDeclaration_unnamed() { 7461 void test_visitConstructorDeclaration_unnamed() {
7481 ElementHolder holder = new ElementHolder(); 7462 ElementHolder holder = new ElementHolder();
7482 ElementBuilder builder = new ElementBuilder(holder); 7463 ElementBuilder builder = new ElementBuilder(holder);
7483 String className = "A"; 7464 String className = "A";
7484 ConstructorDeclaration constructorDeclaration = 7465 ConstructorDeclaration constructorDeclaration =
7485 AstFactory.constructorDeclaration2( 7466 AstFactory.constructorDeclaration2(
7486 null, 7467 null,
7487 null, 7468 null,
7488 AstFactory.identifier3(className), 7469 AstFactory.identifier3(className),
7489 null, 7470 null,
7490 AstFactory.formalParameterList([]), 7471 AstFactory.formalParameterList(),
7491 null, 7472 null,
7492 AstFactory.blockFunctionBody2([])); 7473 AstFactory.blockFunctionBody2());
7493 constructorDeclaration.accept(builder); 7474 constructorDeclaration.accept(builder);
7494 List<ConstructorElement> constructors = holder.constructors; 7475 List<ConstructorElement> constructors = holder.constructors;
7495 expect(constructors, hasLength(1)); 7476 expect(constructors, hasLength(1));
7496 ConstructorElement constructor = constructors[0]; 7477 ConstructorElement constructor = constructors[0];
7497 expect(constructor, isNotNull); 7478 expect(constructor, isNotNull);
7498 expect(constructor.isFactory, isFalse); 7479 expect(constructor.isFactory, isFalse);
7499 expect(constructor.name, ""); 7480 expect(constructor.name, "");
7500 expect(constructor.functions, hasLength(0)); 7481 expect(constructor.functions, hasLength(0));
7501 expect(constructor.labels, hasLength(0)); 7482 expect(constructor.labels, hasLength(0));
7502 expect(constructor.localVariables, hasLength(0)); 7483 expect(constructor.localVariables, hasLength(0));
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
7609 7590
7610 void test_visitFunctionDeclaration_getter() { 7591 void test_visitFunctionDeclaration_getter() {
7611 ElementHolder holder = new ElementHolder(); 7592 ElementHolder holder = new ElementHolder();
7612 ElementBuilder builder = new ElementBuilder(holder); 7593 ElementBuilder builder = new ElementBuilder(holder);
7613 String functionName = "f"; 7594 String functionName = "f";
7614 FunctionDeclaration declaration = AstFactory.functionDeclaration( 7595 FunctionDeclaration declaration = AstFactory.functionDeclaration(
7615 null, 7596 null,
7616 Keyword.GET, 7597 Keyword.GET,
7617 functionName, 7598 functionName,
7618 AstFactory.functionExpression2( 7599 AstFactory.functionExpression2(
7619 AstFactory.formalParameterList([]), 7600 AstFactory.formalParameterList(),
7620 AstFactory.blockFunctionBody2([]))); 7601 AstFactory.blockFunctionBody2()));
7621 declaration.accept(builder); 7602 declaration.accept(builder);
7622 List<PropertyAccessorElement> accessors = holder.accessors; 7603 List<PropertyAccessorElement> accessors = holder.accessors;
7623 expect(accessors, hasLength(1)); 7604 expect(accessors, hasLength(1));
7624 PropertyAccessorElement accessor = accessors[0]; 7605 PropertyAccessorElement accessor = accessors[0];
7625 expect(accessor, isNotNull); 7606 expect(accessor, isNotNull);
7626 expect(accessor.name, functionName); 7607 expect(accessor.name, functionName);
7627 expect(declaration.element, same(accessor)); 7608 expect(declaration.element, same(accessor));
7628 expect(declaration.functionExpression.element, same(accessor)); 7609 expect(declaration.functionExpression.element, same(accessor));
7629 expect(accessor.isGetter, isTrue); 7610 expect(accessor.isGetter, isTrue);
7630 expect(accessor.isSetter, isFalse); 7611 expect(accessor.isSetter, isFalse);
7631 expect(accessor.isSynthetic, isFalse); 7612 expect(accessor.isSynthetic, isFalse);
7632 PropertyInducingElement variable = accessor.variable; 7613 PropertyInducingElement variable = accessor.variable;
7633 EngineTestCase.assertInstanceOf( 7614 EngineTestCase.assertInstanceOf(
7634 (obj) => obj is TopLevelVariableElement, 7615 (obj) => obj is TopLevelVariableElement,
7635 TopLevelVariableElement, 7616 TopLevelVariableElement,
7636 variable); 7617 variable);
7637 expect(variable.isSynthetic, isTrue); 7618 expect(variable.isSynthetic, isTrue);
7638 } 7619 }
7639 7620
7640 void test_visitFunctionDeclaration_plain() { 7621 void test_visitFunctionDeclaration_plain() {
7641 ElementHolder holder = new ElementHolder(); 7622 ElementHolder holder = new ElementHolder();
7642 ElementBuilder builder = new ElementBuilder(holder); 7623 ElementBuilder builder = new ElementBuilder(holder);
7643 String functionName = "f"; 7624 String functionName = "f";
7644 FunctionDeclaration declaration = AstFactory.functionDeclaration( 7625 FunctionDeclaration declaration = AstFactory.functionDeclaration(
7645 null, 7626 null,
7646 null, 7627 null,
7647 functionName, 7628 functionName,
7648 AstFactory.functionExpression2( 7629 AstFactory.functionExpression2(
7649 AstFactory.formalParameterList([]), 7630 AstFactory.formalParameterList(),
7650 AstFactory.blockFunctionBody2([]))); 7631 AstFactory.blockFunctionBody2()));
7651 declaration.accept(builder); 7632 declaration.accept(builder);
7652 List<FunctionElement> functions = holder.functions; 7633 List<FunctionElement> functions = holder.functions;
7653 expect(functions, hasLength(1)); 7634 expect(functions, hasLength(1));
7654 FunctionElement function = functions[0]; 7635 FunctionElement function = functions[0];
7655 expect(function, isNotNull); 7636 expect(function, isNotNull);
7656 expect(function.name, functionName); 7637 expect(function.name, functionName);
7657 expect(declaration.element, same(function)); 7638 expect(declaration.element, same(function));
7658 expect(declaration.functionExpression.element, same(function)); 7639 expect(declaration.functionExpression.element, same(function));
7659 expect(function.isSynthetic, isFalse); 7640 expect(function.isSynthetic, isFalse);
7660 } 7641 }
7661 7642
7662 void test_visitFunctionDeclaration_setter() { 7643 void test_visitFunctionDeclaration_setter() {
7663 ElementHolder holder = new ElementHolder(); 7644 ElementHolder holder = new ElementHolder();
7664 ElementBuilder builder = new ElementBuilder(holder); 7645 ElementBuilder builder = new ElementBuilder(holder);
7665 String functionName = "f"; 7646 String functionName = "f";
7666 FunctionDeclaration declaration = AstFactory.functionDeclaration( 7647 FunctionDeclaration declaration = AstFactory.functionDeclaration(
7667 null, 7648 null,
7668 Keyword.SET, 7649 Keyword.SET,
7669 functionName, 7650 functionName,
7670 AstFactory.functionExpression2( 7651 AstFactory.functionExpression2(
7671 AstFactory.formalParameterList([]), 7652 AstFactory.formalParameterList(),
7672 AstFactory.blockFunctionBody2([]))); 7653 AstFactory.blockFunctionBody2()));
7673 declaration.accept(builder); 7654 declaration.accept(builder);
7674 List<PropertyAccessorElement> accessors = holder.accessors; 7655 List<PropertyAccessorElement> accessors = holder.accessors;
7675 expect(accessors, hasLength(1)); 7656 expect(accessors, hasLength(1));
7676 PropertyAccessorElement accessor = accessors[0]; 7657 PropertyAccessorElement accessor = accessors[0];
7677 expect(accessor, isNotNull); 7658 expect(accessor, isNotNull);
7678 expect(accessor.name, "$functionName="); 7659 expect(accessor.name, "$functionName=");
7679 expect(declaration.element, same(accessor)); 7660 expect(declaration.element, same(accessor));
7680 expect(declaration.functionExpression.element, same(accessor)); 7661 expect(declaration.functionExpression.element, same(accessor));
7681 expect(accessor.isGetter, isFalse); 7662 expect(accessor.isGetter, isFalse);
7682 expect(accessor.isSetter, isTrue); 7663 expect(accessor.isSetter, isTrue);
7683 expect(accessor.isSynthetic, isFalse); 7664 expect(accessor.isSynthetic, isFalse);
7684 PropertyInducingElement variable = accessor.variable; 7665 PropertyInducingElement variable = accessor.variable;
7685 EngineTestCase.assertInstanceOf( 7666 EngineTestCase.assertInstanceOf(
7686 (obj) => obj is TopLevelVariableElement, 7667 (obj) => obj is TopLevelVariableElement,
7687 TopLevelVariableElement, 7668 TopLevelVariableElement,
7688 variable); 7669 variable);
7689 expect(variable.isSynthetic, isTrue); 7670 expect(variable.isSynthetic, isTrue);
7690 } 7671 }
7691 7672
7692 void test_visitFunctionExpression() { 7673 void test_visitFunctionExpression() {
7693 ElementHolder holder = new ElementHolder(); 7674 ElementHolder holder = new ElementHolder();
7694 ElementBuilder builder = new ElementBuilder(holder); 7675 ElementBuilder builder = new ElementBuilder(holder);
7695 FunctionExpression expression = AstFactory.functionExpression2( 7676 FunctionExpression expression = AstFactory.functionExpression2(
7696 AstFactory.formalParameterList([]), 7677 AstFactory.formalParameterList(),
7697 AstFactory.blockFunctionBody2([])); 7678 AstFactory.blockFunctionBody2());
7698 expression.accept(builder); 7679 expression.accept(builder);
7699 List<FunctionElement> functions = holder.functions; 7680 List<FunctionElement> functions = holder.functions;
7700 expect(functions, hasLength(1)); 7681 expect(functions, hasLength(1));
7701 FunctionElement function = functions[0]; 7682 FunctionElement function = functions[0];
7702 expect(function, isNotNull); 7683 expect(function, isNotNull);
7703 expect(expression.element, same(function)); 7684 expect(expression.element, same(function));
7704 expect(function.isSynthetic, isFalse); 7685 expect(function.isSynthetic, isFalse);
7705 } 7686 }
7706 7687
7707 void test_visitFunctionTypeAlias() { 7688 void test_visitFunctionTypeAlias() {
(...skipping 18 matching lines...) Expand all
7726 TypeParameterElement typeParameter = typeParameters[0]; 7707 TypeParameterElement typeParameter = typeParameters[0];
7727 expect(typeParameter, isNotNull); 7708 expect(typeParameter, isNotNull);
7728 expect(typeParameter.name, parameterName); 7709 expect(typeParameter.name, parameterName);
7729 } 7710 }
7730 7711
7731 void test_visitFunctionTypedFormalParameter() { 7712 void test_visitFunctionTypedFormalParameter() {
7732 ElementHolder holder = new ElementHolder(); 7713 ElementHolder holder = new ElementHolder();
7733 ElementBuilder builder = new ElementBuilder(holder); 7714 ElementBuilder builder = new ElementBuilder(holder);
7734 String parameterName = "p"; 7715 String parameterName = "p";
7735 FunctionTypedFormalParameter formalParameter = 7716 FunctionTypedFormalParameter formalParameter =
7736 AstFactory.functionTypedFormalParameter(null, parameterName, []); 7717 AstFactory.functionTypedFormalParameter(null, parameterName);
7737 _useParameterInMethod(formalParameter, 100, 110); 7718 _useParameterInMethod(formalParameter, 100, 110);
7738 formalParameter.accept(builder); 7719 formalParameter.accept(builder);
7739 List<ParameterElement> parameters = holder.parameters; 7720 List<ParameterElement> parameters = holder.parameters;
7740 expect(parameters, hasLength(1)); 7721 expect(parameters, hasLength(1));
7741 ParameterElement parameter = parameters[0]; 7722 ParameterElement parameter = parameters[0];
7742 expect(parameter, isNotNull); 7723 expect(parameter, isNotNull);
7743 expect(parameter.name, parameterName); 7724 expect(parameter.name, parameterName);
7744 expect(parameter.initializer, isNull); 7725 expect(parameter.initializer, isNull);
7745 expect(parameter.isConst, isFalse); 7726 expect(parameter.isConst, isFalse);
7746 expect(parameter.isFinal, isFalse); 7727 expect(parameter.isFinal, isFalse);
7747 expect(parameter.isSynthetic, isFalse); 7728 expect(parameter.isSynthetic, isFalse);
7748 expect(parameter.parameterKind, ParameterKind.REQUIRED); 7729 expect(parameter.parameterKind, ParameterKind.REQUIRED);
7749 { 7730 {
7750 SourceRange visibleRange = parameter.visibleRange; 7731 SourceRange visibleRange = parameter.visibleRange;
7751 expect(100, visibleRange.offset); 7732 expect(100, visibleRange.offset);
7752 expect(110, visibleRange.end); 7733 expect(110, visibleRange.end);
7753 } 7734 }
7754 } 7735 }
7755 7736
7756 void test_visitLabeledStatement() { 7737 void test_visitLabeledStatement() {
7757 ElementHolder holder = new ElementHolder(); 7738 ElementHolder holder = new ElementHolder();
7758 ElementBuilder builder = new ElementBuilder(holder); 7739 ElementBuilder builder = new ElementBuilder(holder);
7759 String labelName = "l"; 7740 String labelName = "l";
7760 LabeledStatement statement = AstFactory.labeledStatement( 7741 LabeledStatement statement = AstFactory.labeledStatement(
7761 AstFactory.list([AstFactory.label2(labelName)]), 7742 [AstFactory.label2(labelName)],
7762 AstFactory.breakStatement()); 7743 AstFactory.breakStatement());
7763 statement.accept(builder); 7744 statement.accept(builder);
7764 List<LabelElement> labels = holder.labels; 7745 List<LabelElement> labels = holder.labels;
7765 expect(labels, hasLength(1)); 7746 expect(labels, hasLength(1));
7766 LabelElement label = labels[0]; 7747 LabelElement label = labels[0];
7767 expect(label, isNotNull); 7748 expect(label, isNotNull);
7768 expect(label.name, labelName); 7749 expect(label.name, labelName);
7769 expect(label.isSynthetic, isFalse); 7750 expect(label.isSynthetic, isFalse);
7770 } 7751 }
7771 7752
7772 void test_visitMethodDeclaration_abstract() { 7753 void test_visitMethodDeclaration_abstract() {
7773 ElementHolder holder = new ElementHolder(); 7754 ElementHolder holder = new ElementHolder();
7774 ElementBuilder builder = new ElementBuilder(holder); 7755 ElementBuilder builder = new ElementBuilder(holder);
7775 String methodName = "m"; 7756 String methodName = "m";
7776 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 7757 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
7777 null, 7758 null,
7778 null, 7759 null,
7779 null, 7760 null,
7780 null, 7761 null,
7781 AstFactory.identifier3(methodName), 7762 AstFactory.identifier3(methodName),
7782 AstFactory.formalParameterList([]), 7763 AstFactory.formalParameterList(),
7783 AstFactory.emptyFunctionBody()); 7764 AstFactory.emptyFunctionBody());
7784 methodDeclaration.accept(builder); 7765 methodDeclaration.accept(builder);
7785 List<MethodElement> methods = holder.methods; 7766 List<MethodElement> methods = holder.methods;
7786 expect(methods, hasLength(1)); 7767 expect(methods, hasLength(1));
7787 MethodElement method = methods[0]; 7768 MethodElement method = methods[0];
7788 expect(method, isNotNull); 7769 expect(method, isNotNull);
7789 expect(method.name, methodName); 7770 expect(method.name, methodName);
7790 expect(method.functions, hasLength(0)); 7771 expect(method.functions, hasLength(0));
7791 expect(method.labels, hasLength(0)); 7772 expect(method.labels, hasLength(0));
7792 expect(method.localVariables, hasLength(0)); 7773 expect(method.localVariables, hasLength(0));
7793 expect(method.parameters, hasLength(0)); 7774 expect(method.parameters, hasLength(0));
7794 expect(method.isAbstract, isTrue); 7775 expect(method.isAbstract, isTrue);
7795 expect(method.isStatic, isFalse); 7776 expect(method.isStatic, isFalse);
7796 expect(method.isSynthetic, isFalse); 7777 expect(method.isSynthetic, isFalse);
7797 } 7778 }
7798 7779
7799 void test_visitMethodDeclaration_getter() { 7780 void test_visitMethodDeclaration_getter() {
7800 ElementHolder holder = new ElementHolder(); 7781 ElementHolder holder = new ElementHolder();
7801 ElementBuilder builder = new ElementBuilder(holder); 7782 ElementBuilder builder = new ElementBuilder(holder);
7802 String methodName = "m"; 7783 String methodName = "m";
7803 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 7784 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
7804 null, 7785 null,
7805 null, 7786 null,
7806 Keyword.GET, 7787 Keyword.GET,
7807 null, 7788 null,
7808 AstFactory.identifier3(methodName), 7789 AstFactory.identifier3(methodName),
7809 AstFactory.formalParameterList([]), 7790 AstFactory.formalParameterList(),
7810 AstFactory.blockFunctionBody2([])); 7791 AstFactory.blockFunctionBody2());
7811 methodDeclaration.accept(builder); 7792 methodDeclaration.accept(builder);
7812 List<FieldElement> fields = holder.fields; 7793 List<FieldElement> fields = holder.fields;
7813 expect(fields, hasLength(1)); 7794 expect(fields, hasLength(1));
7814 FieldElement field = fields[0]; 7795 FieldElement field = fields[0];
7815 expect(field, isNotNull); 7796 expect(field, isNotNull);
7816 expect(field.name, methodName); 7797 expect(field.name, methodName);
7817 expect(field.isSynthetic, isTrue); 7798 expect(field.isSynthetic, isTrue);
7818 expect(field.setter, isNull); 7799 expect(field.setter, isNull);
7819 PropertyAccessorElement getter = field.getter; 7800 PropertyAccessorElement getter = field.getter;
7820 expect(getter, isNotNull); 7801 expect(getter, isNotNull);
(...skipping 11 matching lines...) Expand all
7832 void test_visitMethodDeclaration_getter_abstract() { 7813 void test_visitMethodDeclaration_getter_abstract() {
7833 ElementHolder holder = new ElementHolder(); 7814 ElementHolder holder = new ElementHolder();
7834 ElementBuilder builder = new ElementBuilder(holder); 7815 ElementBuilder builder = new ElementBuilder(holder);
7835 String methodName = "m"; 7816 String methodName = "m";
7836 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 7817 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
7837 null, 7818 null,
7838 null, 7819 null,
7839 Keyword.GET, 7820 Keyword.GET,
7840 null, 7821 null,
7841 AstFactory.identifier3(methodName), 7822 AstFactory.identifier3(methodName),
7842 AstFactory.formalParameterList([]), 7823 AstFactory.formalParameterList(),
7843 AstFactory.emptyFunctionBody()); 7824 AstFactory.emptyFunctionBody());
7844 methodDeclaration.accept(builder); 7825 methodDeclaration.accept(builder);
7845 List<FieldElement> fields = holder.fields; 7826 List<FieldElement> fields = holder.fields;
7846 expect(fields, hasLength(1)); 7827 expect(fields, hasLength(1));
7847 FieldElement field = fields[0]; 7828 FieldElement field = fields[0];
7848 expect(field, isNotNull); 7829 expect(field, isNotNull);
7849 expect(field.name, methodName); 7830 expect(field.name, methodName);
7850 expect(field.isSynthetic, isTrue); 7831 expect(field.isSynthetic, isTrue);
7851 expect(field.setter, isNull); 7832 expect(field.setter, isNull);
7852 PropertyAccessorElement getter = field.getter; 7833 PropertyAccessorElement getter = field.getter;
(...skipping 12 matching lines...) Expand all
7865 void test_visitMethodDeclaration_getter_external() { 7846 void test_visitMethodDeclaration_getter_external() {
7866 ElementHolder holder = new ElementHolder(); 7847 ElementHolder holder = new ElementHolder();
7867 ElementBuilder builder = new ElementBuilder(holder); 7848 ElementBuilder builder = new ElementBuilder(holder);
7868 String methodName = "m"; 7849 String methodName = "m";
7869 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration( 7850 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration(
7870 null, 7851 null,
7871 null, 7852 null,
7872 Keyword.GET, 7853 Keyword.GET,
7873 null, 7854 null,
7874 AstFactory.identifier3(methodName), 7855 AstFactory.identifier3(methodName),
7875 AstFactory.formalParameterList([])); 7856 AstFactory.formalParameterList());
7876 methodDeclaration.accept(builder); 7857 methodDeclaration.accept(builder);
7877 List<FieldElement> fields = holder.fields; 7858 List<FieldElement> fields = holder.fields;
7878 expect(fields, hasLength(1)); 7859 expect(fields, hasLength(1));
7879 FieldElement field = fields[0]; 7860 FieldElement field = fields[0];
7880 expect(field, isNotNull); 7861 expect(field, isNotNull);
7881 expect(field.name, methodName); 7862 expect(field.name, methodName);
7882 expect(field.isSynthetic, isTrue); 7863 expect(field.isSynthetic, isTrue);
7883 expect(field.setter, isNull); 7864 expect(field.setter, isNull);
7884 PropertyAccessorElement getter = field.getter; 7865 PropertyAccessorElement getter = field.getter;
7885 expect(getter, isNotNull); 7866 expect(getter, isNotNull);
(...skipping 11 matching lines...) Expand all
7897 void test_visitMethodDeclaration_minimal() { 7878 void test_visitMethodDeclaration_minimal() {
7898 ElementHolder holder = new ElementHolder(); 7879 ElementHolder holder = new ElementHolder();
7899 ElementBuilder builder = new ElementBuilder(holder); 7880 ElementBuilder builder = new ElementBuilder(holder);
7900 String methodName = "m"; 7881 String methodName = "m";
7901 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 7882 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
7902 null, 7883 null,
7903 null, 7884 null,
7904 null, 7885 null,
7905 null, 7886 null,
7906 AstFactory.identifier3(methodName), 7887 AstFactory.identifier3(methodName),
7907 AstFactory.formalParameterList([]), 7888 AstFactory.formalParameterList(),
7908 AstFactory.blockFunctionBody2([])); 7889 AstFactory.blockFunctionBody2());
7909 methodDeclaration.accept(builder); 7890 methodDeclaration.accept(builder);
7910 List<MethodElement> methods = holder.methods; 7891 List<MethodElement> methods = holder.methods;
7911 expect(methods, hasLength(1)); 7892 expect(methods, hasLength(1));
7912 MethodElement method = methods[0]; 7893 MethodElement method = methods[0];
7913 expect(method, isNotNull); 7894 expect(method, isNotNull);
7914 expect(method.name, methodName); 7895 expect(method.name, methodName);
7915 expect(method.functions, hasLength(0)); 7896 expect(method.functions, hasLength(0));
7916 expect(method.labels, hasLength(0)); 7897 expect(method.labels, hasLength(0));
7917 expect(method.localVariables, hasLength(0)); 7898 expect(method.localVariables, hasLength(0));
7918 expect(method.parameters, hasLength(0)); 7899 expect(method.parameters, hasLength(0));
7919 expect(method.isAbstract, isFalse); 7900 expect(method.isAbstract, isFalse);
7920 expect(method.isStatic, isFalse); 7901 expect(method.isStatic, isFalse);
7921 expect(method.isSynthetic, isFalse); 7902 expect(method.isSynthetic, isFalse);
7922 } 7903 }
7923 7904
7924 void test_visitMethodDeclaration_operator() { 7905 void test_visitMethodDeclaration_operator() {
7925 ElementHolder holder = new ElementHolder(); 7906 ElementHolder holder = new ElementHolder();
7926 ElementBuilder builder = new ElementBuilder(holder); 7907 ElementBuilder builder = new ElementBuilder(holder);
7927 String methodName = "+"; 7908 String methodName = "+";
7928 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 7909 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
7929 null, 7910 null,
7930 null, 7911 null,
7931 null, 7912 null,
7932 Keyword.OPERATOR, 7913 Keyword.OPERATOR,
7933 AstFactory.identifier3(methodName), 7914 AstFactory.identifier3(methodName),
7934 AstFactory.formalParameterList([AstFactory.simpleFormalParameter3("adden d")]), 7915 AstFactory.formalParameterList([AstFactory.simpleFormalParameter3("adden d")]),
7935 AstFactory.blockFunctionBody2([])); 7916 AstFactory.blockFunctionBody2());
7936 methodDeclaration.accept(builder); 7917 methodDeclaration.accept(builder);
7937 List<MethodElement> methods = holder.methods; 7918 List<MethodElement> methods = holder.methods;
7938 expect(methods, hasLength(1)); 7919 expect(methods, hasLength(1));
7939 MethodElement method = methods[0]; 7920 MethodElement method = methods[0];
7940 expect(method, isNotNull); 7921 expect(method, isNotNull);
7941 expect(method.name, methodName); 7922 expect(method.name, methodName);
7942 expect(method.functions, hasLength(0)); 7923 expect(method.functions, hasLength(0));
7943 expect(method.labels, hasLength(0)); 7924 expect(method.labels, hasLength(0));
7944 expect(method.localVariables, hasLength(0)); 7925 expect(method.localVariables, hasLength(0));
7945 expect(method.parameters, hasLength(1)); 7926 expect(method.parameters, hasLength(1));
7946 expect(method.isAbstract, isFalse); 7927 expect(method.isAbstract, isFalse);
7947 expect(method.isStatic, isFalse); 7928 expect(method.isStatic, isFalse);
7948 expect(method.isSynthetic, isFalse); 7929 expect(method.isSynthetic, isFalse);
7949 } 7930 }
7950 7931
7951 void test_visitMethodDeclaration_setter() { 7932 void test_visitMethodDeclaration_setter() {
7952 ElementHolder holder = new ElementHolder(); 7933 ElementHolder holder = new ElementHolder();
7953 ElementBuilder builder = new ElementBuilder(holder); 7934 ElementBuilder builder = new ElementBuilder(holder);
7954 String methodName = "m"; 7935 String methodName = "m";
7955 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 7936 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
7956 null, 7937 null,
7957 null, 7938 null,
7958 Keyword.SET, 7939 Keyword.SET,
7959 null, 7940 null,
7960 AstFactory.identifier3(methodName), 7941 AstFactory.identifier3(methodName),
7961 AstFactory.formalParameterList([]), 7942 AstFactory.formalParameterList(),
7962 AstFactory.blockFunctionBody2([])); 7943 AstFactory.blockFunctionBody2());
7963 methodDeclaration.accept(builder); 7944 methodDeclaration.accept(builder);
7964 List<FieldElement> fields = holder.fields; 7945 List<FieldElement> fields = holder.fields;
7965 expect(fields, hasLength(1)); 7946 expect(fields, hasLength(1));
7966 FieldElement field = fields[0]; 7947 FieldElement field = fields[0];
7967 expect(field, isNotNull); 7948 expect(field, isNotNull);
7968 expect(field.name, methodName); 7949 expect(field.name, methodName);
7969 expect(field.isSynthetic, isTrue); 7950 expect(field.isSynthetic, isTrue);
7970 expect(field.getter, isNull); 7951 expect(field.getter, isNull);
7971 PropertyAccessorElement setter = field.setter; 7952 PropertyAccessorElement setter = field.setter;
7972 expect(setter, isNotNull); 7953 expect(setter, isNotNull);
(...skipping 12 matching lines...) Expand all
7985 void test_visitMethodDeclaration_setter_abstract() { 7966 void test_visitMethodDeclaration_setter_abstract() {
7986 ElementHolder holder = new ElementHolder(); 7967 ElementHolder holder = new ElementHolder();
7987 ElementBuilder builder = new ElementBuilder(holder); 7968 ElementBuilder builder = new ElementBuilder(holder);
7988 String methodName = "m"; 7969 String methodName = "m";
7989 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 7970 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
7990 null, 7971 null,
7991 null, 7972 null,
7992 Keyword.SET, 7973 Keyword.SET,
7993 null, 7974 null,
7994 AstFactory.identifier3(methodName), 7975 AstFactory.identifier3(methodName),
7995 AstFactory.formalParameterList([]), 7976 AstFactory.formalParameterList(),
7996 AstFactory.emptyFunctionBody()); 7977 AstFactory.emptyFunctionBody());
7997 methodDeclaration.accept(builder); 7978 methodDeclaration.accept(builder);
7998 List<FieldElement> fields = holder.fields; 7979 List<FieldElement> fields = holder.fields;
7999 expect(fields, hasLength(1)); 7980 expect(fields, hasLength(1));
8000 FieldElement field = fields[0]; 7981 FieldElement field = fields[0];
8001 expect(field, isNotNull); 7982 expect(field, isNotNull);
8002 expect(field.name, methodName); 7983 expect(field.name, methodName);
8003 expect(field.isSynthetic, isTrue); 7984 expect(field.isSynthetic, isTrue);
8004 expect(field.getter, isNull); 7985 expect(field.getter, isNull);
8005 PropertyAccessorElement setter = field.setter; 7986 PropertyAccessorElement setter = field.setter;
(...skipping 13 matching lines...) Expand all
8019 void test_visitMethodDeclaration_setter_external() { 8000 void test_visitMethodDeclaration_setter_external() {
8020 ElementHolder holder = new ElementHolder(); 8001 ElementHolder holder = new ElementHolder();
8021 ElementBuilder builder = new ElementBuilder(holder); 8002 ElementBuilder builder = new ElementBuilder(holder);
8022 String methodName = "m"; 8003 String methodName = "m";
8023 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration( 8004 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration(
8024 null, 8005 null,
8025 null, 8006 null,
8026 Keyword.SET, 8007 Keyword.SET,
8027 null, 8008 null,
8028 AstFactory.identifier3(methodName), 8009 AstFactory.identifier3(methodName),
8029 AstFactory.formalParameterList([])); 8010 AstFactory.formalParameterList());
8030 methodDeclaration.accept(builder); 8011 methodDeclaration.accept(builder);
8031 List<FieldElement> fields = holder.fields; 8012 List<FieldElement> fields = holder.fields;
8032 expect(fields, hasLength(1)); 8013 expect(fields, hasLength(1));
8033 FieldElement field = fields[0]; 8014 FieldElement field = fields[0];
8034 expect(field, isNotNull); 8015 expect(field, isNotNull);
8035 expect(field.name, methodName); 8016 expect(field.name, methodName);
8036 expect(field.isSynthetic, isTrue); 8017 expect(field.isSynthetic, isTrue);
8037 expect(field.getter, isNull); 8018 expect(field.getter, isNull);
8038 PropertyAccessorElement setter = field.setter; 8019 PropertyAccessorElement setter = field.setter;
8039 expect(setter, isNotNull); 8020 expect(setter, isNotNull);
(...skipping 12 matching lines...) Expand all
8052 void test_visitMethodDeclaration_static() { 8033 void test_visitMethodDeclaration_static() {
8053 ElementHolder holder = new ElementHolder(); 8034 ElementHolder holder = new ElementHolder();
8054 ElementBuilder builder = new ElementBuilder(holder); 8035 ElementBuilder builder = new ElementBuilder(holder);
8055 String methodName = "m"; 8036 String methodName = "m";
8056 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 8037 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
8057 Keyword.STATIC, 8038 Keyword.STATIC,
8058 null, 8039 null,
8059 null, 8040 null,
8060 null, 8041 null,
8061 AstFactory.identifier3(methodName), 8042 AstFactory.identifier3(methodName),
8062 AstFactory.formalParameterList([]), 8043 AstFactory.formalParameterList(),
8063 AstFactory.blockFunctionBody2([])); 8044 AstFactory.blockFunctionBody2());
8064 methodDeclaration.accept(builder); 8045 methodDeclaration.accept(builder);
8065 List<MethodElement> methods = holder.methods; 8046 List<MethodElement> methods = holder.methods;
8066 expect(methods, hasLength(1)); 8047 expect(methods, hasLength(1));
8067 MethodElement method = methods[0]; 8048 MethodElement method = methods[0];
8068 expect(method, isNotNull); 8049 expect(method, isNotNull);
8069 expect(method.name, methodName); 8050 expect(method.name, methodName);
8070 expect(method.functions, hasLength(0)); 8051 expect(method.functions, hasLength(0));
8071 expect(method.labels, hasLength(0)); 8052 expect(method.labels, hasLength(0));
8072 expect(method.localVariables, hasLength(0)); 8053 expect(method.localVariables, hasLength(0));
8073 expect(method.parameters, hasLength(0)); 8054 expect(method.parameters, hasLength(0));
(...skipping 11 matching lines...) Expand all
8085 String labelName = "l"; 8066 String labelName = "l";
8086 String exceptionParameterName = "e"; 8067 String exceptionParameterName = "e";
8087 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 8068 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
8088 null, 8069 null,
8089 null, 8070 null,
8090 null, 8071 null,
8091 null, 8072 null,
8092 AstFactory.identifier3(methodName), 8073 AstFactory.identifier3(methodName),
8093 AstFactory.formalParameterList( 8074 AstFactory.formalParameterList(
8094 [AstFactory.simpleFormalParameter3(parameterName)]), 8075 [AstFactory.simpleFormalParameter3(parameterName)]),
8095 AstFactory.blockFunctionBody2( 8076 AstFactory.blockFunctionBody2([
8096 [ 8077 AstFactory.variableDeclarationStatement2(
8097 AstFactory.variableDeclarationStatement2( 8078 Keyword.VAR,
8098 Keyword.VAR, 8079 [AstFactory.variableDeclaration(localVariableName)]),
8099 [AstFactory.variableDeclaration(localVariableName)]), 8080 AstFactory.tryStatement2(
8100 AstFactory.tryStatement2( 8081 AstFactory.block([AstFactory.labeledStatement(
8101 AstFactory.block( 8082 [AstFactory.label2(labelName)],
8102 [ 8083 AstFactory.returnStatement())]),
8103 AstFactory.labeledStatement( 8084 [AstFactory.catchClause(exceptionParameterName)])]));
8104 AstFactory.list([AstFactory.label2(labelName)]),
8105 AstFactory.returnStatement())]),
8106 [AstFactory.catchClause(exceptionParameterName, [])])]));
8107 methodDeclaration.accept(builder); 8085 methodDeclaration.accept(builder);
8108 List<MethodElement> methods = holder.methods; 8086 List<MethodElement> methods = holder.methods;
8109 expect(methods, hasLength(1)); 8087 expect(methods, hasLength(1));
8110 MethodElement method = methods[0]; 8088 MethodElement method = methods[0];
8111 expect(method, isNotNull); 8089 expect(method, isNotNull);
8112 expect(method.name, methodName); 8090 expect(method.name, methodName);
8113 expect(method.isAbstract, isFalse); 8091 expect(method.isAbstract, isFalse);
8114 expect(method.isStatic, isFalse); 8092 expect(method.isStatic, isFalse);
8115 expect(method.isSynthetic, isFalse); 8093 expect(method.isSynthetic, isFalse);
8116 List<VariableElement> parameters = method.parameters; 8094 List<VariableElement> parameters = method.parameters;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
8206 8184
8207 void test_visitTypeAlias_withFormalParameters() { 8185 void test_visitTypeAlias_withFormalParameters() {
8208 ElementHolder holder = new ElementHolder(); 8186 ElementHolder holder = new ElementHolder();
8209 ElementBuilder builder = new ElementBuilder(holder); 8187 ElementBuilder builder = new ElementBuilder(holder);
8210 String aliasName = "F"; 8188 String aliasName = "F";
8211 String firstParameterName = "x"; 8189 String firstParameterName = "x";
8212 String secondParameterName = "y"; 8190 String secondParameterName = "y";
8213 TypeAlias typeAlias = AstFactory.typeAlias( 8191 TypeAlias typeAlias = AstFactory.typeAlias(
8214 null, 8192 null,
8215 aliasName, 8193 aliasName,
8216 AstFactory.typeParameterList([]), 8194 AstFactory.typeParameterList(),
8217 AstFactory.formalParameterList( 8195 AstFactory.formalParameterList(
8218 [ 8196 [
8219 AstFactory.simpleFormalParameter3(firstParameterName), 8197 AstFactory.simpleFormalParameter3(firstParameterName),
8220 AstFactory.simpleFormalParameter3(secondParameterName)])); 8198 AstFactory.simpleFormalParameter3(secondParameterName)]));
8221 typeAlias.accept(builder); 8199 typeAlias.accept(builder);
8222 List<FunctionTypeAliasElement> aliases = holder.typeAliases; 8200 List<FunctionTypeAliasElement> aliases = holder.typeAliases;
8223 expect(aliases, hasLength(1)); 8201 expect(aliases, hasLength(1));
8224 FunctionTypeAliasElement alias = aliases[0]; 8202 FunctionTypeAliasElement alias = aliases[0];
8225 expect(alias, isNotNull); 8203 expect(alias, isNotNull);
8226 expect(alias.name, aliasName); 8204 expect(alias.name, aliasName);
(...skipping 11 matching lines...) Expand all
8238 void test_visitTypeAlias_withTypeParameters() { 8216 void test_visitTypeAlias_withTypeParameters() {
8239 ElementHolder holder = new ElementHolder(); 8217 ElementHolder holder = new ElementHolder();
8240 ElementBuilder builder = new ElementBuilder(holder); 8218 ElementBuilder builder = new ElementBuilder(holder);
8241 String aliasName = "F"; 8219 String aliasName = "F";
8242 String firstTypeParameterName = "A"; 8220 String firstTypeParameterName = "A";
8243 String secondTypeParameterName = "B"; 8221 String secondTypeParameterName = "B";
8244 TypeAlias typeAlias = AstFactory.typeAlias( 8222 TypeAlias typeAlias = AstFactory.typeAlias(
8245 null, 8223 null,
8246 aliasName, 8224 aliasName,
8247 AstFactory.typeParameterList([firstTypeParameterName, secondTypeParamete rName]), 8225 AstFactory.typeParameterList([firstTypeParameterName, secondTypeParamete rName]),
8248 AstFactory.formalParameterList([])); 8226 AstFactory.formalParameterList());
8249 typeAlias.accept(builder); 8227 typeAlias.accept(builder);
8250 List<FunctionTypeAliasElement> aliases = holder.typeAliases; 8228 List<FunctionTypeAliasElement> aliases = holder.typeAliases;
8251 expect(aliases, hasLength(1)); 8229 expect(aliases, hasLength(1));
8252 FunctionTypeAliasElement alias = aliases[0]; 8230 FunctionTypeAliasElement alias = aliases[0];
8253 expect(alias, isNotNull); 8231 expect(alias, isNotNull);
8254 expect(alias.name, aliasName); 8232 expect(alias.name, aliasName);
8255 expect(alias.type, isNotNull); 8233 expect(alias.type, isNotNull);
8256 expect(alias.isSynthetic, isFalse); 8234 expect(alias.isSynthetic, isFalse);
8257 List<VariableElement> parameters = alias.parameters; 8235 List<VariableElement> parameters = alias.parameters;
8258 expect(parameters, isNotNull); 8236 expect(parameters, isNotNull);
(...skipping 28 matching lines...) Expand all
8287 String variableName = "v"; 8265 String variableName = "v";
8288 VariableDeclaration variable = 8266 VariableDeclaration variable =
8289 AstFactory.variableDeclaration2(variableName, null); 8267 AstFactory.variableDeclaration2(variableName, null);
8290 Statement statement = 8268 Statement statement =
8291 AstFactory.variableDeclarationStatement2(null, [variable]); 8269 AstFactory.variableDeclarationStatement2(null, [variable]);
8292 ConstructorDeclaration constructor = AstFactory.constructorDeclaration2( 8270 ConstructorDeclaration constructor = AstFactory.constructorDeclaration2(
8293 null, 8271 null,
8294 null, 8272 null,
8295 AstFactory.identifier3("C"), 8273 AstFactory.identifier3("C"),
8296 "C", 8274 "C",
8297 AstFactory.formalParameterList([]), 8275 AstFactory.formalParameterList(),
8298 null, 8276 null,
8299 AstFactory.blockFunctionBody2([statement])); 8277 AstFactory.blockFunctionBody2([statement]));
8300 constructor.accept(builder); 8278 constructor.accept(builder);
8301 List<ConstructorElement> constructors = holder.constructors; 8279 List<ConstructorElement> constructors = holder.constructors;
8302 expect(constructors, hasLength(1)); 8280 expect(constructors, hasLength(1));
8303 List<LocalVariableElement> variableElements = 8281 List<LocalVariableElement> variableElements =
8304 constructors[0].localVariables; 8282 constructors[0].localVariables;
8305 expect(variableElements, hasLength(1)); 8283 expect(variableElements, hasLength(1));
8306 LocalVariableElement variableElement = variableElements[0]; 8284 LocalVariableElement variableElement = variableElements[0];
8307 expect(variableElement.name, variableName); 8285 expect(variableElement.name, variableName);
8308 } 8286 }
8309 8287
8310 void test_visitVariableDeclaration_inMethod() { 8288 void test_visitVariableDeclaration_inMethod() {
8311 ElementHolder holder = new ElementHolder(); 8289 ElementHolder holder = new ElementHolder();
8312 ElementBuilder builder = new ElementBuilder(holder); 8290 ElementBuilder builder = new ElementBuilder(holder);
8313 // 8291 //
8314 // m() {var v;} 8292 // m() {var v;}
8315 // 8293 //
8316 String variableName = "v"; 8294 String variableName = "v";
8317 VariableDeclaration variable = 8295 VariableDeclaration variable =
8318 AstFactory.variableDeclaration2(variableName, null); 8296 AstFactory.variableDeclaration2(variableName, null);
8319 Statement statement = 8297 Statement statement =
8320 AstFactory.variableDeclarationStatement2(null, [variable]); 8298 AstFactory.variableDeclarationStatement2(null, [variable]);
8321 MethodDeclaration constructor = AstFactory.methodDeclaration2( 8299 MethodDeclaration constructor = AstFactory.methodDeclaration2(
8322 null, 8300 null,
8323 null, 8301 null,
8324 null, 8302 null,
8325 null, 8303 null,
8326 AstFactory.identifier3("m"), 8304 AstFactory.identifier3("m"),
8327 AstFactory.formalParameterList([]), 8305 AstFactory.formalParameterList(),
8328 AstFactory.blockFunctionBody2([statement])); 8306 AstFactory.blockFunctionBody2([statement]));
8329 constructor.accept(builder); 8307 constructor.accept(builder);
8330 List<MethodElement> methods = holder.methods; 8308 List<MethodElement> methods = holder.methods;
8331 expect(methods, hasLength(1)); 8309 expect(methods, hasLength(1));
8332 List<LocalVariableElement> variableElements = methods[0].localVariables; 8310 List<LocalVariableElement> variableElements = methods[0].localVariables;
8333 expect(variableElements, hasLength(1)); 8311 expect(variableElements, hasLength(1));
8334 LocalVariableElement variableElement = variableElements[0]; 8312 LocalVariableElement variableElement = variableElements[0];
8335 expect(variableElement.name, variableName); 8313 expect(variableElement.name, variableName);
8336 } 8314 }
8337 8315
8338 void test_visitVariableDeclaration_localNestedInField() { 8316 void test_visitVariableDeclaration_localNestedInField() {
8339 ElementHolder holder = new ElementHolder(); 8317 ElementHolder holder = new ElementHolder();
8340 ElementBuilder builder = new ElementBuilder(holder); 8318 ElementBuilder builder = new ElementBuilder(holder);
8341 // 8319 //
8342 // var f = () {var v;} 8320 // var f = () {var v;}
8343 // 8321 //
8344 String variableName = "v"; 8322 String variableName = "v";
8345 VariableDeclaration variable = 8323 VariableDeclaration variable =
8346 AstFactory.variableDeclaration2(variableName, null); 8324 AstFactory.variableDeclaration2(variableName, null);
8347 Statement statement = 8325 Statement statement =
8348 AstFactory.variableDeclarationStatement2(null, [variable]); 8326 AstFactory.variableDeclarationStatement2(null, [variable]);
8349 Expression initializer = AstFactory.functionExpression2( 8327 Expression initializer = AstFactory.functionExpression2(
8350 AstFactory.formalParameterList([]), 8328 AstFactory.formalParameterList(),
8351 AstFactory.blockFunctionBody2([statement])); 8329 AstFactory.blockFunctionBody2([statement]));
8352 String fieldName = "f"; 8330 String fieldName = "f";
8353 VariableDeclaration field = 8331 VariableDeclaration field =
8354 AstFactory.variableDeclaration2(fieldName, initializer); 8332 AstFactory.variableDeclaration2(fieldName, initializer);
8355 FieldDeclaration fieldDeclaration = 8333 FieldDeclaration fieldDeclaration =
8356 AstFactory.fieldDeclaration2(false, null, [field]); 8334 AstFactory.fieldDeclaration2(false, null, [field]);
8357 fieldDeclaration.accept(builder); 8335 fieldDeclaration.accept(builder);
8358 List<FieldElement> variables = holder.fields; 8336 List<FieldElement> variables = holder.fields;
8359 expect(variables, hasLength(1)); 8337 expect(variables, hasLength(1));
8360 FieldElement fieldElement = variables[0]; 8338 FieldElement fieldElement = variables[0];
(...skipping 28 matching lines...) Expand all
8389 expect(variable.name, variableName); 8367 expect(variable.name, variableName);
8390 expect(variable.isConst, isFalse); 8368 expect(variable.isConst, isFalse);
8391 expect(variable.isFinal, isFalse); 8369 expect(variable.isFinal, isFalse);
8392 expect(variable.isSynthetic, isFalse); 8370 expect(variable.isSynthetic, isFalse);
8393 expect(variable.getter, isNotNull); 8371 expect(variable.getter, isNotNull);
8394 expect(variable.setter, isNotNull); 8372 expect(variable.setter, isNotNull);
8395 } 8373 }
8396 8374
8397 void _useParameterInMethod(FormalParameter formalParameter, int blockOffset, 8375 void _useParameterInMethod(FormalParameter formalParameter, int blockOffset,
8398 int blockEnd) { 8376 int blockEnd) {
8399 Block block = AstFactory.block([]); 8377 Block block = AstFactory.block();
8400 block.leftBracket.offset = blockOffset; 8378 block.leftBracket.offset = blockOffset;
8401 block.rightBracket.offset = blockEnd - 1; 8379 block.rightBracket.offset = blockEnd - 1;
8402 BlockFunctionBody body = AstFactory.blockFunctionBody(block); 8380 BlockFunctionBody body = AstFactory.blockFunctionBody(block);
8403 AstFactory.methodDeclaration2( 8381 AstFactory.methodDeclaration2(
8404 null, 8382 null,
8405 null, 8383 null,
8406 null, 8384 null,
8407 null, 8385 null,
8408 AstFactory.identifier3("main"), 8386 AstFactory.identifier3("main"),
8409 AstFactory.formalParameterList([formalParameter]), 8387 AstFactory.formalParameterList([formalParameter]),
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
8658 } 8636 }
8659 8637
8660 void test_locate_InstanceCreationExpression_type_prefixedIdentifier() { 8638 void test_locate_InstanceCreationExpression_type_prefixedIdentifier() {
8661 // prepare: new pref.A() 8639 // prepare: new pref.A()
8662 SimpleIdentifier identifier = AstFactory.identifier3("A"); 8640 SimpleIdentifier identifier = AstFactory.identifier3("A");
8663 PrefixedIdentifier prefixedIdentifier = 8641 PrefixedIdentifier prefixedIdentifier =
8664 AstFactory.identifier4("pref", identifier); 8642 AstFactory.identifier4("pref", identifier);
8665 InstanceCreationExpression creation = 8643 InstanceCreationExpression creation =
8666 AstFactory.instanceCreationExpression2( 8644 AstFactory.instanceCreationExpression2(
8667 Keyword.NEW, 8645 Keyword.NEW,
8668 AstFactory.typeName3(prefixedIdentifier, []), 8646 AstFactory.typeName3(prefixedIdentifier));
8669 []);
8670 // set ClassElement 8647 // set ClassElement
8671 ClassElement classElement = ElementFactory.classElement2("A", []); 8648 ClassElement classElement = ElementFactory.classElement2("A");
8672 identifier.staticElement = classElement; 8649 identifier.staticElement = classElement;
8673 // set ConstructorElement 8650 // set ConstructorElement
8674 ConstructorElement constructorElement = 8651 ConstructorElement constructorElement =
8675 ElementFactory.constructorElement2(classElement, null, []); 8652 ElementFactory.constructorElement2(classElement, null);
8676 creation.constructorName.staticElement = constructorElement; 8653 creation.constructorName.staticElement = constructorElement;
8677 // verify that "A" is resolved to ConstructorElement 8654 // verify that "A" is resolved to ConstructorElement
8678 Element element = ElementLocator.locate(identifier); 8655 Element element = ElementLocator.locate(identifier);
8679 expect(element, same(classElement)); 8656 expect(element, same(classElement));
8680 } 8657 }
8681 8658
8682 void test_locate_InstanceCreationExpression_type_simpleIdentifier() { 8659 void test_locate_InstanceCreationExpression_type_simpleIdentifier() {
8683 // prepare: new A() 8660 // prepare: new A()
8684 SimpleIdentifier identifier = AstFactory.identifier3("A"); 8661 SimpleIdentifier identifier = AstFactory.identifier3("A");
8685 InstanceCreationExpression creation = 8662 InstanceCreationExpression creation =
8686 AstFactory.instanceCreationExpression2( 8663 AstFactory.instanceCreationExpression2(
8687 Keyword.NEW, 8664 Keyword.NEW,
8688 AstFactory.typeName3(identifier, []), 8665 AstFactory.typeName3(identifier));
8689 []);
8690 // set ClassElement 8666 // set ClassElement
8691 ClassElement classElement = ElementFactory.classElement2("A", []); 8667 ClassElement classElement = ElementFactory.classElement2("A");
8692 identifier.staticElement = classElement; 8668 identifier.staticElement = classElement;
8693 // set ConstructorElement 8669 // set ConstructorElement
8694 ConstructorElement constructorElement = 8670 ConstructorElement constructorElement =
8695 ElementFactory.constructorElement2(classElement, null, []); 8671 ElementFactory.constructorElement2(classElement, null);
8696 creation.constructorName.staticElement = constructorElement; 8672 creation.constructorName.staticElement = constructorElement;
8697 // verify that "A" is resolved to ConstructorElement 8673 // verify that "A" is resolved to ConstructorElement
8698 Element element = ElementLocator.locate(identifier); 8674 Element element = ElementLocator.locate(identifier);
8699 expect(element, same(classElement)); 8675 expect(element, same(classElement));
8700 } 8676 }
8701 8677
8702 void test_locate_LibraryDirective() { 8678 void test_locate_LibraryDirective() {
8703 AstNode id = _findNodeIn("library", "library foo;"); 8679 AstNode id = _findNodeIn("library", "library foo;");
8704 Element element = ElementLocator.locate(id); 8680 Element element = ElementLocator.locate(id);
8705 EngineTestCase.assertInstanceOf( 8681 EngineTestCase.assertInstanceOf(
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
8989 class ErrorReporterTest extends EngineTestCase { 8965 class ErrorReporterTest extends EngineTestCase {
8990 /** 8966 /**
8991 * Create a type with the given name in a compilation unit with the given name . 8967 * Create a type with the given name in a compilation unit with the given name .
8992 * 8968 *
8993 * @param fileName the name of the compilation unit containing the class 8969 * @param fileName the name of the compilation unit containing the class
8994 * @param typeName the name of the type to be created 8970 * @param typeName the name of the type to be created
8995 * @return the type that was created 8971 * @return the type that was created
8996 */ 8972 */
8997 InterfaceType createType(String fileName, String typeName) { 8973 InterfaceType createType(String fileName, String typeName) {
8998 CompilationUnitElementImpl unit = ElementFactory.compilationUnit(fileName); 8974 CompilationUnitElementImpl unit = ElementFactory.compilationUnit(fileName);
8999 ClassElementImpl element = ElementFactory.classElement2(typeName, []); 8975 ClassElementImpl element = ElementFactory.classElement2(typeName);
9000 unit.types = <ClassElement>[element]; 8976 unit.types = <ClassElement>[element];
9001 return element.type; 8977 return element.type;
9002 } 8978 }
9003 8979
9004 void test_creation() { 8980 void test_creation() {
9005 GatheringErrorListener listener = new GatheringErrorListener(); 8981 GatheringErrorListener listener = new GatheringErrorListener();
9006 TestSource source = new TestSource(); 8982 TestSource source = new TestSource();
9007 expect(new ErrorReporter(listener, source), isNotNull); 8983 expect(new ErrorReporter(listener, source), isNotNull);
9008 } 8984 }
9009 8985
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
9549 void test_whileStatement_true_throw() { 9525 void test_whileStatement_true_throw() {
9550 _assertTrue("{ while (true) { throw ''; } }"); 9526 _assertTrue("{ while (true) { throw ''; } }");
9551 } 9527 }
9552 9528
9553 void _assertFalse(String source) { 9529 void _assertFalse(String source) {
9554 _assertHasReturn(false, source); 9530 _assertHasReturn(false, source);
9555 } 9531 }
9556 9532
9557 void _assertHasReturn(bool expectedResult, String source) { 9533 void _assertHasReturn(bool expectedResult, String source) {
9558 ExitDetector detector = new ExitDetector(); 9534 ExitDetector detector = new ExitDetector();
9559 Statement statement = ParserTestCase.parseStatement(source, []); 9535 Statement statement = ParserTestCase.parseStatement(source);
9560 expect(statement.accept(detector), same(expectedResult)); 9536 expect(statement.accept(detector), same(expectedResult));
9561 } 9537 }
9562 9538
9563 void _assertTrue(String source) { 9539 void _assertTrue(String source) {
9564 _assertHasReturn(true, source); 9540 _assertHasReturn(true, source);
9565 } 9541 }
9566 } 9542 }
9567 9543
9568 9544
9569 class ExpressionVisitor_AngularTest_verify extends ExpressionVisitor { 9545 class ExpressionVisitor_AngularTest_verify extends ExpressionVisitor {
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
9837 </body> 9813 </body>
9838 </html>"""); 9814 </html>""");
9839 _validate( 9815 _validate(
9840 htmlUnit, 9816 htmlUnit,
9841 [ 9817 [
9842 _t4( 9818 _t4(
9843 "html", 9819 "html",
9844 [ 9820 [
9845 _t4( 9821 _t4(
9846 "body", 9822 "body",
9847 [_t("script", _a(["type", "'application/dart'"]), script Body, [])])])]); 9823 [_t("script", _a(["type", "'application/dart'"]), script Body)])])]);
9848 } 9824 }
9849 ht.HtmlUnit parse(String contents) { 9825 ht.HtmlUnit parse(String contents) {
9850 // TestSource source = 9826 // TestSource source =
9851 // new TestSource.con1(FileUtilities2.createFile("/test.dart"), contents) ; 9827 // new TestSource.con1(FileUtilities2.createFile("/test.dart"), contents) ;
9852 ht.AbstractScanner scanner = new ht.StringScanner(null, contents); 9828 ht.AbstractScanner scanner = new ht.StringScanner(null, contents);
9853 scanner.passThroughElements = <String>[_TAG_SCRIPT]; 9829 scanner.passThroughElements = <String>[_TAG_SCRIPT];
9854 ht.Token token = scanner.tokenize(); 9830 ht.Token token = scanner.tokenize();
9855 LineInfo lineInfo = new LineInfo(scanner.lineStarts); 9831 LineInfo lineInfo = new LineInfo(scanner.lineStarts);
9856 GatheringErrorListener errorListener = new GatheringErrorListener(); 9832 GatheringErrorListener errorListener = new GatheringErrorListener();
9857 ht.HtmlUnit unit = 9833 ht.HtmlUnit unit =
9858 new ht.HtmlParser(null, errorListener).parse(token, lineInfo); 9834 new ht.HtmlParser(null, errorListener).parse(token, lineInfo);
9859 errorListener.assertNoErrors(); 9835 errorListener.assertNoErrors();
9860 return unit; 9836 return unit;
9861 } 9837 }
9862 void test_parse_attribute() { 9838 void test_parse_attribute() {
9863 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsdf\"></body></html>"); 9839 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsdf\"></body></html>");
9864 _validate( 9840 _validate(
9865 htmlUnit, 9841 htmlUnit,
9866 [_t4("html", [_t("body", _a(["foo", "\"sdfsdf\""]), "", [])])]); 9842 [_t4("html", [_t("body", _a(["foo", "\"sdfsdf\""]), "")])]);
9867 ht.XmlTagNode htmlNode = htmlUnit.tagNodes[0]; 9843 ht.XmlTagNode htmlNode = htmlUnit.tagNodes[0];
9868 ht.XmlTagNode bodyNode = htmlNode.tagNodes[0]; 9844 ht.XmlTagNode bodyNode = htmlNode.tagNodes[0];
9869 expect(bodyNode.attributes[0].text, "sdfsdf"); 9845 expect(bodyNode.attributes[0].text, "sdfsdf");
9870 } 9846 }
9871 void test_parse_attribute_EOF() { 9847 void test_parse_attribute_EOF() {
9872 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsdf\""); 9848 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsdf\"");
9873 _validate( 9849 _validate(
9874 htmlUnit, 9850 htmlUnit,
9875 [_t4("html", [_t("body", _a(["foo", "\"sdfsdf\""]), "", [])])]); 9851 [_t4("html", [_t("body", _a(["foo", "\"sdfsdf\""]), "")])]);
9876 } 9852 }
9877 void test_parse_attribute_EOF_missing_quote() { 9853 void test_parse_attribute_EOF_missing_quote() {
9878 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsd"); 9854 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsd");
9879 _validate( 9855 _validate(
9880 htmlUnit, 9856 htmlUnit,
9881 [_t4("html", [_t("body", _a(["foo", "\"sdfsd"]), "", [])])]); 9857 [_t4("html", [_t("body", _a(["foo", "\"sdfsd"]), "")])]);
9882 ht.XmlTagNode htmlNode = htmlUnit.tagNodes[0]; 9858 ht.XmlTagNode htmlNode = htmlUnit.tagNodes[0];
9883 ht.XmlTagNode bodyNode = htmlNode.tagNodes[0]; 9859 ht.XmlTagNode bodyNode = htmlNode.tagNodes[0];
9884 expect(bodyNode.attributes[0].text, "sdfsd"); 9860 expect(bodyNode.attributes[0].text, "sdfsd");
9885 } 9861 }
9886 void test_parse_attribute_extra_quote() { 9862 void test_parse_attribute_extra_quote() {
9887 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsdf\"\"></body></html>"); 9863 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsdf\"\"></body></html>");
9888 _validate( 9864 _validate(
9889 htmlUnit, 9865 htmlUnit,
9890 [_t4("html", [_t("body", _a(["foo", "\"sdfsdf\""]), "", [])])]); 9866 [_t4("html", [_t("body", _a(["foo", "\"sdfsdf\""]), "")])]);
9891 } 9867 }
9892 void test_parse_attribute_single_quote() { 9868 void test_parse_attribute_single_quote() {
9893 ht.HtmlUnit htmlUnit = parse("<html><body foo='sdfsdf'></body></html>"); 9869 ht.HtmlUnit htmlUnit = parse("<html><body foo='sdfsdf'></body></html>");
9894 _validate( 9870 _validate(
9895 htmlUnit, 9871 htmlUnit,
9896 [_t4("html", [_t("body", _a(["foo", "'sdfsdf'"]), "", [])])]); 9872 [_t4("html", [_t("body", _a(["foo", "'sdfsdf'"]), "")])]);
9897 ht.XmlTagNode htmlNode = htmlUnit.tagNodes[0]; 9873 ht.XmlTagNode htmlNode = htmlUnit.tagNodes[0];
9898 ht.XmlTagNode bodyNode = htmlNode.tagNodes[0]; 9874 ht.XmlTagNode bodyNode = htmlNode.tagNodes[0];
9899 expect(bodyNode.attributes[0].text, "sdfsdf"); 9875 expect(bodyNode.attributes[0].text, "sdfsdf");
9900 } 9876 }
9901 void test_parse_comment_embedded() { 9877 void test_parse_comment_embedded() {
9902 ht.HtmlUnit htmlUnit = parse("<html <!-- comment -->></html>"); 9878 ht.HtmlUnit htmlUnit = parse("<html <!-- comment -->></html>");
9903 _validate(htmlUnit, [_t3("html", "", [])]); 9879 _validate(htmlUnit, [_t3("html", "")]);
9904 } 9880 }
9905 void test_parse_comment_first() { 9881 void test_parse_comment_first() {
9906 ht.HtmlUnit htmlUnit = parse("<!-- comment --><html></html>"); 9882 ht.HtmlUnit htmlUnit = parse("<!-- comment --><html></html>");
9907 _validate(htmlUnit, [_t3("html", "", [])]); 9883 _validate(htmlUnit, [_t3("html", "")]);
9908 } 9884 }
9909 void test_parse_comment_in_content() { 9885 void test_parse_comment_in_content() {
9910 ht.HtmlUnit htmlUnit = parse("<html><!-- comment --></html>"); 9886 ht.HtmlUnit htmlUnit = parse("<html><!-- comment --></html>");
9911 _validate(htmlUnit, [_t3("html", "<!-- comment -->", [])]); 9887 _validate(htmlUnit, [_t3("html", "<!-- comment -->")]);
9912 } 9888 }
9913 void test_parse_content() { 9889 void test_parse_content() {
9914 ht.HtmlUnit htmlUnit = parse("<html>\n<p a=\"b\">blat \n </p>\n</html>"); 9890 ht.HtmlUnit htmlUnit = parse("<html>\n<p a=\"b\">blat \n </p>\n</html>");
9915 // ht.XmlTagNode.getContent() does not include whitespace 9891 // ht.XmlTagNode.getContent() does not include whitespace
9916 // between '<' and '>' at this time 9892 // between '<' and '>' at this time
9917 _validate( 9893 _validate(
9918 htmlUnit, 9894 htmlUnit,
9919 [ 9895 [
9920 _t3( 9896 _t3(
9921 "html", 9897 "html",
9922 "\n<pa=\"b\">blat \n </p>\n", 9898 "\n<pa=\"b\">blat \n </p>\n",
9923 [_t("p", _a(["a", "\"b\""]), "blat \n ", [])])]); 9899 [_t("p", _a(["a", "\"b\""]), "blat \n ")])]);
9924 } 9900 }
9925 void test_parse_content_none() { 9901 void test_parse_content_none() {
9926 ht.HtmlUnit htmlUnit = parse("<html><p/>blat<p/></html>"); 9902 ht.HtmlUnit htmlUnit = parse("<html><p/>blat<p/></html>");
9927 _validate( 9903 _validate(
9928 htmlUnit, 9904 htmlUnit,
9929 [_t3("html", "<p/>blat<p/>", [_t3("p", "", []), _t3("p", "", [])])]); 9905 [_t3("html", "<p/>blat<p/>", [_t3("p", ""), _t3("p", "")])]);
9930 } 9906 }
9931 void test_parse_declaration() { 9907 void test_parse_declaration() {
9932 ht.HtmlUnit htmlUnit = parse("<!DOCTYPE html>\n\n<html><p></p></html>"); 9908 ht.HtmlUnit htmlUnit = parse("<!DOCTYPE html>\n\n<html><p></p></html>");
9933 _validate(htmlUnit, [_t4("html", [_t3("p", "", [])])]); 9909 _validate(htmlUnit, [_t4("html", [_t3("p", "")])]);
9934 } 9910 }
9935 void test_parse_directive() { 9911 void test_parse_directive() {
9936 ht.HtmlUnit htmlUnit = parse("<?xml ?>\n\n<html><p></p></html>"); 9912 ht.HtmlUnit htmlUnit = parse("<?xml ?>\n\n<html><p></p></html>");
9937 _validate(htmlUnit, [_t4("html", [_t3("p", "", [])])]); 9913 _validate(htmlUnit, [_t4("html", [_t3("p", "")])]);
9938 } 9914 }
9939 void test_parse_getAttribute() { 9915 void test_parse_getAttribute() {
9940 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsdf\"></body></html>"); 9916 ht.HtmlUnit htmlUnit = parse("<html><body foo=\"sdfsdf\"></body></html>");
9941 ht.XmlTagNode htmlNode = htmlUnit.tagNodes[0]; 9917 ht.XmlTagNode htmlNode = htmlUnit.tagNodes[0];
9942 ht.XmlTagNode bodyNode = htmlNode.tagNodes[0]; 9918 ht.XmlTagNode bodyNode = htmlNode.tagNodes[0];
9943 expect(bodyNode.getAttribute("foo").text, "sdfsdf"); 9919 expect(bodyNode.getAttribute("foo").text, "sdfsdf");
9944 expect(bodyNode.getAttribute("bar"), null); 9920 expect(bodyNode.getAttribute("bar"), null);
9945 expect(bodyNode.getAttribute(null), null); 9921 expect(bodyNode.getAttribute(null), null);
9946 } 9922 }
9947 void test_parse_getAttributeText() { 9923 void test_parse_getAttributeText() {
(...skipping 10 matching lines...) Expand all
9958 <body> 9934 <body>
9959 <h2>000</h2> 9935 <h2>000</h2>
9960 <div> 9936 <div>
9961 111 9937 111
9962 </div> 9938 </div>
9963 </body> 9939 </body>
9964 </html>'''; 9940 </html>''';
9965 ht.HtmlUnit htmlUnit = parse(code); 9941 ht.HtmlUnit htmlUnit = parse(code);
9966 _validate( 9942 _validate(
9967 htmlUnit, 9943 htmlUnit,
9968 [_t4("html", [_t4("body", [_t3("h2", "000", []), _t4("div", [])])])]); 9944 [_t4("html", [_t4("body", [_t3("h2", "000"), _t4("div")])])]);
9969 } 9945 }
9970 void test_parse_script() { 9946 void test_parse_script() {
9971 ht.HtmlUnit htmlUnit = 9947 ht.HtmlUnit htmlUnit =
9972 parse("<html><script >here is <p> some</script></html>"); 9948 parse("<html><script >here is <p> some</script></html>");
9973 _validate(htmlUnit, [_t4("html", [_t3("script", "here is <p> some", [])])]); 9949 _validate(htmlUnit, [_t4("html", [_t3("script", "here is <p> some")])]);
9974 } 9950 }
9975 void test_parse_self_closing() { 9951 void test_parse_self_closing() {
9976 ht.HtmlUnit htmlUnit = parse("<html>foo<br>bar</html>"); 9952 ht.HtmlUnit htmlUnit = parse("<html>foo<br>bar</html>");
9977 _validate(htmlUnit, [_t3("html", "foo<br>bar", [_t3("br", "", [])])]); 9953 _validate(htmlUnit, [_t3("html", "foo<br>bar", [_t3("br", "")])]);
9978 } 9954 }
9979 void test_parse_self_closing_declaration() { 9955 void test_parse_self_closing_declaration() {
9980 ht.HtmlUnit htmlUnit = parse("<!DOCTYPE html><html>foo</html>"); 9956 ht.HtmlUnit htmlUnit = parse("<!DOCTYPE html><html>foo</html>");
9981 _validate(htmlUnit, [_t3("html", "foo", [])]); 9957 _validate(htmlUnit, [_t3("html", "foo")]);
9982 } 9958 }
9983 XmlValidator_Attributes _a(List<String> keyValuePairs) => 9959 XmlValidator_Attributes _a(List<String> keyValuePairs) =>
9984 new XmlValidator_Attributes(keyValuePairs); 9960 new XmlValidator_Attributes(keyValuePairs);
9985 XmlValidator_Tag _t(String tag, XmlValidator_Attributes attributes, 9961 XmlValidator_Tag _t(String tag, XmlValidator_Attributes attributes,
9986 String content, List<XmlValidator_Tag> children) => 9962 String content, [List<XmlValidator_Tag> children = XmlValidator_Tag.EMPTY_ LIST]) =>
9987 new XmlValidator_Tag(tag, attributes, content, children); 9963 new XmlValidator_Tag(tag, attributes, content, children);
9988 XmlValidator_Tag _t2(String tag, XmlValidator_Attributes attributes, 9964 XmlValidator_Tag _t2(String tag, XmlValidator_Attributes attributes,
9989 List<XmlValidator_Tag> children) => 9965 [List<XmlValidator_Tag> children = XmlValidator_Tag.EMPTY_LIST]) =>
9990 new XmlValidator_Tag(tag, attributes, null, children); 9966 new XmlValidator_Tag(tag, attributes, null, children);
9991 XmlValidator_Tag _t3(String tag, String content, 9967 XmlValidator_Tag _t3(String tag, String content,
9992 List<XmlValidator_Tag> children) => 9968 [List<XmlValidator_Tag> children = XmlValidator_Tag.EMPTY_LIST]) =>
9993 new XmlValidator_Tag(tag, new XmlValidator_Attributes([]), content, childr en); 9969 new XmlValidator_Tag(tag, new XmlValidator_Attributes(), content, children );
9994 XmlValidator_Tag _t4(String tag, List<XmlValidator_Tag> children) => 9970 XmlValidator_Tag _t4(String tag, [List<XmlValidator_Tag> children = XmlValidat or_Tag.EMPTY_LIST]) =>
9995 new XmlValidator_Tag(tag, new XmlValidator_Attributes([]), null, children) ; 9971 new XmlValidator_Tag(tag, new XmlValidator_Attributes(), null, children);
9996 void _validate(ht.HtmlUnit htmlUnit, List<XmlValidator_Tag> expectedTags) { 9972 void _validate(ht.HtmlUnit htmlUnit, List<XmlValidator_Tag> expectedTags) {
9997 XmlValidator validator = new XmlValidator(); 9973 XmlValidator validator = new XmlValidator();
9998 validator.expectTags(expectedTags); 9974 validator.expectTags(expectedTags);
9999 htmlUnit.accept(validator); 9975 htmlUnit.accept(validator);
10000 validator.assertValid(); 9976 validator.assertValid();
10001 } 9977 }
10002 } 9978 }
10003 9979
10004 9980
10005 class HtmlTagInfoBuilderTest extends HtmlParserTest { 9981 class HtmlTagInfoBuilderTest extends HtmlParserTest {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
10041 <html> 10017 <html>
10042 <script type="application/dart">foo=2;</script> 10018 <script type="application/dart">foo=2;</script>
10043 </html>'''); 10019 </html>''');
10044 _validate(element, [_s(_l([_v("foo")]))]); 10020 _validate(element, [_s(_l([_v("foo")]))]);
10045 } 10021 }
10046 void test_embedded_script_no_content() { 10022 void test_embedded_script_no_content() {
10047 HtmlElementImpl element = _build(r''' 10023 HtmlElementImpl element = _build(r'''
10048 <html> 10024 <html>
10049 <script type="application/dart"></script> 10025 <script type="application/dart"></script>
10050 </html>'''); 10026 </html>''');
10051 _validate(element, [_s(_l([]))]); 10027 _validate(element, [_s(_l())]);
10052 } 10028 }
10053 void test_external_script() { 10029 void test_external_script() {
10054 HtmlElementImpl element = _build(r''' 10030 HtmlElementImpl element = _build(r'''
10055 <html> 10031 <html>
10056 <script type="application/dart" src="other.dart"/> 10032 <script type="application/dart" src="other.dart"/>
10057 </html>'''); 10033 </html>''');
10058 _validate(element, [_s2("other.dart")]); 10034 _validate(element, [_s2("other.dart")]);
10059 } 10035 }
10060 void test_external_script_no_source() { 10036 void test_external_script_no_source() {
10061 HtmlElementImpl element = _build(r''' 10037 HtmlElementImpl element = _build(r'''
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
10093 ChangeSet changeSet = new ChangeSet(); 10069 ChangeSet changeSet = new ChangeSet();
10094 changeSet.addedSource(source); 10070 changeSet.addedSource(source);
10095 _context.applyChanges(changeSet); 10071 _context.applyChanges(changeSet);
10096 HtmlUnitBuilder builder = new HtmlUnitBuilder(_context); 10072 HtmlUnitBuilder builder = new HtmlUnitBuilder(_context);
10097 return builder.buildHtmlElement( 10073 return builder.buildHtmlElement(
10098 source, 10074 source,
10099 _context.getModificationStamp(source), 10075 _context.getModificationStamp(source),
10100 _context.parseHtmlUnit(source)); 10076 _context.parseHtmlUnit(source));
10101 } 10077 }
10102 HtmlUnitBuilderTest_ExpectedLibrary 10078 HtmlUnitBuilderTest_ExpectedLibrary
10103 _l(List<HtmlUnitBuilderTest_ExpectedVariable> expectedVariables) => 10079 _l([List<HtmlUnitBuilderTest_ExpectedVariable> expectedVariables = HtmlUni tBuilderTest_ExpectedVariable.EMPTY_LIST]) =>
10104 new HtmlUnitBuilderTest_ExpectedLibrary(this, expectedVariables); 10080 new HtmlUnitBuilderTest_ExpectedLibrary(this, expectedVariables);
10105 _ExpectedScript _s(HtmlUnitBuilderTest_ExpectedLibrary expectedLibrary) => 10081 _ExpectedScript _s(HtmlUnitBuilderTest_ExpectedLibrary expectedLibrary) =>
10106 new _ExpectedScript.con1(expectedLibrary); 10082 new _ExpectedScript.con1(expectedLibrary);
10107 _ExpectedScript _s2(String scriptSourcePath) => 10083 _ExpectedScript _s2(String scriptSourcePath) =>
10108 new _ExpectedScript.con2(scriptSourcePath); 10084 new _ExpectedScript.con2(scriptSourcePath);
10109 HtmlUnitBuilderTest_ExpectedVariable _v(String varName) => 10085 HtmlUnitBuilderTest_ExpectedVariable _v(String varName) =>
10110 new HtmlUnitBuilderTest_ExpectedVariable(varName); 10086 new HtmlUnitBuilderTest_ExpectedVariable(varName);
10111 void _validate(HtmlElementImpl element, 10087 void _validate(HtmlElementImpl element,
10112 List<_ExpectedScript> expectedScripts) { 10088 List<_ExpectedScript> expectedScripts) {
10113 expect(element.context, same(_context)); 10089 expect(element.context, same(_context));
10114 List<HtmlScriptElement> scripts = element.scripts; 10090 List<HtmlScriptElement> scripts = element.scripts;
10115 expect(scripts, isNotNull); 10091 expect(scripts, isNotNull);
10116 expect(scripts, hasLength(expectedScripts.length)); 10092 expect(scripts, hasLength(expectedScripts.length));
10117 for (int scriptIndex = 0; scriptIndex < scripts.length; scriptIndex++) { 10093 for (int scriptIndex = 0; scriptIndex < scripts.length; scriptIndex++) {
10118 expectedScripts[scriptIndex]._validate(scriptIndex, scripts[scriptIndex]); 10094 expectedScripts[scriptIndex]._validate(scriptIndex, scripts[scriptIndex]);
10119 } 10095 }
10120 } 10096 }
10121 } 10097 }
10122 10098
10123 10099
10124 class HtmlUnitBuilderTest_ExpectedLibrary { 10100 class HtmlUnitBuilderTest_ExpectedLibrary {
10125 final HtmlUnitBuilderTest HtmlUnitBuilderTest_this; 10101 final HtmlUnitBuilderTest HtmlUnitBuilderTest_this;
10126 final List<HtmlUnitBuilderTest_ExpectedVariable> _expectedVariables; 10102 final List<HtmlUnitBuilderTest_ExpectedVariable> _expectedVariables;
10127 HtmlUnitBuilderTest_ExpectedLibrary(this.HtmlUnitBuilderTest_this, 10103 HtmlUnitBuilderTest_ExpectedLibrary(this.HtmlUnitBuilderTest_this,
10128 this._expectedVariables); 10104 [this._expectedVariables = HtmlUnitBuilderTest_ExpectedVariable.EMPTY_LIST ]);
10129 void _validate(int scriptIndex, EmbeddedHtmlScriptElementImpl script) { 10105 void _validate(int scriptIndex, EmbeddedHtmlScriptElementImpl script) {
10130 LibraryElement library = script.scriptLibrary; 10106 LibraryElement library = script.scriptLibrary;
10131 expect(library, isNotNull, reason: "script $scriptIndex"); 10107 expect(library, isNotNull, reason: "script $scriptIndex");
10132 expect(script.context, same(HtmlUnitBuilderTest_this._context), reason: "scr ipt $scriptIndex"); 10108 expect(script.context, same(HtmlUnitBuilderTest_this._context), reason: "scr ipt $scriptIndex");
10133 CompilationUnitElement unit = library.definingCompilationUnit; 10109 CompilationUnitElement unit = library.definingCompilationUnit;
10134 expect(unit, isNotNull, reason: "script $scriptIndex"); 10110 expect(unit, isNotNull, reason: "script $scriptIndex");
10135 List<TopLevelVariableElement> variables = unit.topLevelVariables; 10111 List<TopLevelVariableElement> variables = unit.topLevelVariables;
10136 expect(variables, hasLength(_expectedVariables.length)); 10112 expect(variables, hasLength(_expectedVariables.length));
10137 for (int index = 0; index < variables.length; index++) { 10113 for (int index = 0; index < variables.length; index++) {
10138 _expectedVariables[index].validate(scriptIndex, variables[index]); 10114 _expectedVariables[index].validate(scriptIndex, variables[index]);
10139 } 10115 }
10140 expect(library.enclosingElement, same(script), reason: "script $scriptIndex" ); 10116 expect(library.enclosingElement, same(script), reason: "script $scriptIndex" );
10141 } 10117 }
10142 } 10118 }
10143 10119
10144 10120
10145 class HtmlUnitBuilderTest_ExpectedVariable { 10121 class HtmlUnitBuilderTest_ExpectedVariable {
10146 final String _expectedName; 10122 final String _expectedName;
10123 static const List<HtmlUnitBuilderTest_ExpectedVariable> EMPTY_LIST
10124 = const <HtmlUnitBuilderTest_ExpectedVariable>[];
10147 HtmlUnitBuilderTest_ExpectedVariable(this._expectedName); 10125 HtmlUnitBuilderTest_ExpectedVariable(this._expectedName);
10148 void validate(int scriptIndex, TopLevelVariableElement variable) { 10126 void validate(int scriptIndex, TopLevelVariableElement variable) {
10149 expect(variable, isNotNull, reason: "script $scriptIndex"); 10127 expect(variable, isNotNull, reason: "script $scriptIndex");
10150 expect(variable.name, _expectedName, reason: "script $scriptIndex"); 10128 expect(variable.name, _expectedName, reason: "script $scriptIndex");
10151 } 10129 }
10152 } 10130 }
10153 10131
10154 10132
10155 /** 10133 /**
10156 * Instances of the class `HtmlWarningCodeTest` test the generation of HTML warn ing codes. 10134 * Instances of the class `HtmlWarningCodeTest` test the generation of HTML warn ing codes.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
10328 void test_visitSuperConstructorInvocation_nonConst() { 10306 void test_visitSuperConstructorInvocation_nonConst() {
10329 _visitNode(_makeTailSuperConstructorInvocation("A", false, true)); 10307 _visitNode(_makeTailSuperConstructorInvocation("A", false, true));
10330 _assertNoArcs(); 10308 _assertNoArcs();
10331 } 10309 }
10332 void test_visitSuperConstructorInvocation_notInMap() { 10310 void test_visitSuperConstructorInvocation_notInMap() {
10333 _visitNode(_makeTailSuperConstructorInvocation("A", true, false)); 10311 _visitNode(_makeTailSuperConstructorInvocation("A", true, false));
10334 _assertNoArcs(); 10312 _assertNoArcs();
10335 } 10313 }
10336 void test_visitSuperConstructorInvocation_unresolved() { 10314 void test_visitSuperConstructorInvocation_unresolved() {
10337 SuperConstructorInvocation superConstructorInvocation = 10315 SuperConstructorInvocation superConstructorInvocation =
10338 AstFactory.superConstructorInvocation([]); 10316 AstFactory.superConstructorInvocation();
10339 _tail = superConstructorInvocation; 10317 _tail = superConstructorInvocation;
10340 _visitNode(superConstructorInvocation); 10318 _visitNode(superConstructorInvocation);
10341 _assertNoArcs(); 10319 _assertNoArcs();
10342 } 10320 }
10343 void _assertNoArcs() { 10321 void _assertNoArcs() {
10344 Set<AstNode> tails = _referenceGraph.getTails(_head); 10322 Set<AstNode> tails = _referenceGraph.getTails(_head);
10345 expect(tails, hasLength(0)); 10323 expect(tails, hasLength(0));
10346 } 10324 }
10347 void _assertOneArc(AstNode tail) { 10325 void _assertOneArc(AstNode tail) {
10348 Set<AstNode> tails = _referenceGraph.getTails(_head); 10326 Set<AstNode> tails = _referenceGraph.getTails(_head);
10349 expect(tails, hasLength(1)); 10327 expect(tails, hasLength(1));
10350 expect(tails.first, same(tail)); 10328 expect(tails.first, same(tail));
10351 } 10329 }
10352 ReferenceFinder _createReferenceFinder(AstNode source) => 10330 ReferenceFinder _createReferenceFinder(AstNode source) =>
10353 new ReferenceFinder( 10331 new ReferenceFinder(
10354 source, 10332 source,
10355 _referenceGraph, 10333 _referenceGraph,
10356 _variableDeclarationMap, 10334 _variableDeclarationMap,
10357 _constructorDeclarationMap); 10335 _constructorDeclarationMap);
10358 InstanceCreationExpression _makeTailConstructor(String name, 10336 InstanceCreationExpression _makeTailConstructor(String name,
10359 bool isConstDeclaration, bool isConstUsage, bool inMap) { 10337 bool isConstDeclaration, bool isConstUsage, bool inMap) {
10360 List<ConstructorInitializer> initializers = 10338 List<ConstructorInitializer> initializers =
10361 new List<ConstructorInitializer>(); 10339 new List<ConstructorInitializer>();
10362 ConstructorDeclaration constructorDeclaration = 10340 ConstructorDeclaration constructorDeclaration =
10363 AstFactory.constructorDeclaration( 10341 AstFactory.constructorDeclaration(
10364 AstFactory.identifier3(name), 10342 AstFactory.identifier3(name),
10365 null, 10343 null,
10366 AstFactory.formalParameterList([]), 10344 AstFactory.formalParameterList(),
10367 initializers); 10345 initializers);
10368 if (isConstDeclaration) { 10346 if (isConstDeclaration) {
10369 constructorDeclaration.constKeyword = new KeywordToken(Keyword.CONST, 0); 10347 constructorDeclaration.constKeyword = new KeywordToken(Keyword.CONST, 0);
10370 } 10348 }
10371 ClassElementImpl classElement = ElementFactory.classElement2(name, []); 10349 ClassElementImpl classElement = ElementFactory.classElement2(name);
10372 SimpleIdentifier identifier = AstFactory.identifier3(name); 10350 SimpleIdentifier identifier = AstFactory.identifier3(name);
10373 TypeName type = AstFactory.typeName3(identifier, []); 10351 TypeName type = AstFactory.typeName3(identifier);
10374 InstanceCreationExpression instanceCreationExpression = 10352 InstanceCreationExpression instanceCreationExpression =
10375 AstFactory.instanceCreationExpression2( 10353 AstFactory.instanceCreationExpression2(
10376 isConstUsage ? Keyword.CONST : Keyword.NEW, 10354 isConstUsage ? Keyword.CONST : Keyword.NEW,
10377 type, 10355 type);
10378 []);
10379 _tail = instanceCreationExpression; 10356 _tail = instanceCreationExpression;
10380 ConstructorElementImpl constructorElement = 10357 ConstructorElementImpl constructorElement =
10381 ElementFactory.constructorElement(classElement, name, isConstDeclaration , []); 10358 ElementFactory.constructorElement(classElement, name, isConstDeclaration );
10382 if (inMap) { 10359 if (inMap) {
10383 _constructorDeclarationMap[constructorElement] = constructorDeclaration; 10360 _constructorDeclarationMap[constructorElement] = constructorDeclaration;
10384 } 10361 }
10385 instanceCreationExpression.staticElement = constructorElement; 10362 instanceCreationExpression.staticElement = constructorElement;
10386 return instanceCreationExpression; 10363 return instanceCreationExpression;
10387 } 10364 }
10388 SuperConstructorInvocation _makeTailSuperConstructorInvocation(String name, 10365 SuperConstructorInvocation _makeTailSuperConstructorInvocation(String name,
10389 bool isConst, bool inMap) { 10366 bool isConst, bool inMap) {
10390 List<ConstructorInitializer> initializers = 10367 List<ConstructorInitializer> initializers =
10391 new List<ConstructorInitializer>(); 10368 new List<ConstructorInitializer>();
10392 ConstructorDeclaration constructorDeclaration = 10369 ConstructorDeclaration constructorDeclaration =
10393 AstFactory.constructorDeclaration( 10370 AstFactory.constructorDeclaration(
10394 AstFactory.identifier3(name), 10371 AstFactory.identifier3(name),
10395 null, 10372 null,
10396 AstFactory.formalParameterList([]), 10373 AstFactory.formalParameterList(),
10397 initializers); 10374 initializers);
10398 _tail = constructorDeclaration; 10375 _tail = constructorDeclaration;
10399 if (isConst) { 10376 if (isConst) {
10400 constructorDeclaration.constKeyword = new KeywordToken(Keyword.CONST, 0); 10377 constructorDeclaration.constKeyword = new KeywordToken(Keyword.CONST, 0);
10401 } 10378 }
10402 ClassElementImpl classElement = ElementFactory.classElement2(name, []); 10379 ClassElementImpl classElement = ElementFactory.classElement2(name);
10403 SuperConstructorInvocation superConstructorInvocation = 10380 SuperConstructorInvocation superConstructorInvocation =
10404 AstFactory.superConstructorInvocation([]); 10381 AstFactory.superConstructorInvocation();
10405 ConstructorElementImpl constructorElement = 10382 ConstructorElementImpl constructorElement =
10406 ElementFactory.constructorElement(classElement, name, isConst, []); 10383 ElementFactory.constructorElement(classElement, name, isConst);
10407 if (inMap) { 10384 if (inMap) {
10408 _constructorDeclarationMap[constructorElement] = constructorDeclaration; 10385 _constructorDeclarationMap[constructorElement] = constructorDeclaration;
10409 } 10386 }
10410 superConstructorInvocation.staticElement = constructorElement; 10387 superConstructorInvocation.staticElement = constructorElement;
10411 return superConstructorInvocation; 10388 return superConstructorInvocation;
10412 } 10389 }
10413 SimpleIdentifier _makeTailVariable(String name, bool isConst, bool inMap) { 10390 SimpleIdentifier _makeTailVariable(String name, bool isConst, bool inMap) {
10414 VariableDeclaration variableDeclaration = 10391 VariableDeclaration variableDeclaration =
10415 AstFactory.variableDeclaration(name); 10392 AstFactory.variableDeclaration(name);
10416 _tail = variableDeclaration; 10393 _tail = variableDeclaration;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
10588 _assertSource( 10565 _assertSource(
10589 "<script type='application/dart'>f() {}</script>", 10566 "<script type='application/dart'>f() {}</script>",
10590 HtmlFactory.scriptTagWithContent( 10567 HtmlFactory.scriptTagWithContent(
10591 "f() {}", 10568 "f() {}",
10592 [HtmlFactory.attribute("type", "'application/dart'")])); 10569 [HtmlFactory.attribute("type", "'application/dart'")]));
10593 } 10570 }
10594 10571
10595 void fail_visitHtmlScriptTagNode_noAttributes_content() { 10572 void fail_visitHtmlScriptTagNode_noAttributes_content() {
10596 _assertSource( 10573 _assertSource(
10597 "<script>f() {}</script>", 10574 "<script>f() {}</script>",
10598 HtmlFactory.scriptTagWithContent("f() {}", [])); 10575 HtmlFactory.scriptTagWithContent("f() {}"));
10599 } 10576 }
10600 10577
10601 void test_visitHtmlScriptTagNode_attributes_noContent() { 10578 void test_visitHtmlScriptTagNode_attributes_noContent() {
10602 _assertSource( 10579 _assertSource(
10603 "<script type='application/dart'/>", 10580 "<script type='application/dart'/>",
10604 HtmlFactory.scriptTag([HtmlFactory.attribute("type", "'application/dart' ")])); 10581 HtmlFactory.scriptTag([HtmlFactory.attribute("type", "'application/dart' ")]));
10605 } 10582 }
10606 10583
10607 void test_visitHtmlScriptTagNode_noAttributes_noContent() { 10584 void test_visitHtmlScriptTagNode_noAttributes_noContent() {
10608 _assertSource("<script/>", HtmlFactory.scriptTag([])); 10585 _assertSource("<script/>", HtmlFactory.scriptTag());
10609 } 10586 }
10610 10587
10611 void test_visitHtmlUnit_empty() { 10588 void test_visitHtmlUnit_empty() {
10612 _assertSource("", new ht.HtmlUnit(null, new List<ht.XmlTagNode>(), null)); 10589 _assertSource("", new ht.HtmlUnit(null, new List<ht.XmlTagNode>(), null));
10613 } 10590 }
10614 10591
10615 void test_visitHtmlUnit_nonEmpty() { 10592 void test_visitHtmlUnit_nonEmpty() {
10616 _assertSource( 10593 _assertSource(
10617 "<html/>", 10594 "<html/>",
10618 new ht.HtmlUnit(null, [HtmlFactory.tagNode("html", [])], null)); 10595 new ht.HtmlUnit(null, [HtmlFactory.tagNode("html")], null));
10619 } 10596 }
10620 10597
10621 void test_visitXmlAttributeNode() { 10598 void test_visitXmlAttributeNode() {
10622 _assertSource("x=y", HtmlFactory.attribute("x", "y")); 10599 _assertSource("x=y", HtmlFactory.attribute("x", "y"));
10623 } 10600 }
10624 10601
10625 /** 10602 /**
10626 * Assert that a `ToSourceVisitor` will produce the expected source when visit ing the given 10603 * Assert that a `ToSourceVisitor` will produce the expected source when visit ing the given
10627 * node. 10604 * node.
10628 * 10605 *
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
10989 _errors.add( 10966 _errors.add(
10990 "Invalid source end ($nodeEnd) for ${node.runtimeType} inside ${pare nt.runtimeType} ($parentStart)"); 10967 "Invalid source end ($nodeEnd) for ${node.runtimeType} inside ${pare nt.runtimeType} ($parentStart)");
10991 } 10968 }
10992 } 10969 }
10993 } 10970 }
10994 } 10971 }
10995 10972
10996 10973
10997 class XmlValidator_Attributes { 10974 class XmlValidator_Attributes {
10998 final List<String> _keyValuePairs; 10975 final List<String> _keyValuePairs;
10999 XmlValidator_Attributes(this._keyValuePairs); 10976 XmlValidator_Attributes([this._keyValuePairs = StringUtilities.EMPTY_ARRAY]);
11000 } 10977 }
11001 10978
11002 10979
11003 class XmlValidator_Tag { 10980 class XmlValidator_Tag {
11004 final String _tag; 10981 final String _tag;
11005 final XmlValidator_Attributes _attributes; 10982 final XmlValidator_Attributes _attributes;
11006 final String _content; 10983 final String _content;
11007 final List<XmlValidator_Tag> _children; 10984 final List<XmlValidator_Tag> _children;
11008 XmlValidator_Tag(this._tag, this._attributes, this._content, this._children); 10985 static const List<XmlValidator_Tag> EMPTY_LIST = const <XmlValidator_Tag>[];
10986 XmlValidator_Tag(this._tag, this._attributes, this._content, [this._children = EMPTY_LIST]);
11009 } 10987 }
11010 10988
11011 10989
11012 class _AngularTest_findElement extends GeneralizingElementVisitor<Object> { 10990 class _AngularTest_findElement extends GeneralizingElementVisitor<Object> {
11013 final ElementKind kind; 10991 final ElementKind kind;
11014 10992
11015 final String name; 10993 final String name;
11016 10994
11017 Element result; 10995 Element result;
11018 10996
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
11063 Source scriptSource = externalScript.scriptSource; 11041 Source scriptSource = externalScript.scriptSource;
11064 if (_expectedExternalScriptName == null) { 11042 if (_expectedExternalScriptName == null) {
11065 expect(scriptSource, isNull, reason: "script $scriptIndex"); 11043 expect(scriptSource, isNull, reason: "script $scriptIndex");
11066 } else { 11044 } else {
11067 expect(scriptSource, isNotNull, reason: "script $scriptIndex"); 11045 expect(scriptSource, isNotNull, reason: "script $scriptIndex");
11068 String actualExternalScriptName = scriptSource.shortName; 11046 String actualExternalScriptName = scriptSource.shortName;
11069 expect(actualExternalScriptName, _expectedExternalScriptName, reason: "scr ipt $scriptIndex"); 11047 expect(actualExternalScriptName, _expectedExternalScriptName, reason: "scr ipt $scriptIndex");
11070 } 11048 }
11071 } 11049 }
11072 } 11050 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/testing/html_factory.dart ('k') | pkg/analyzer/test/generated/ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698