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

Side by Side Diff: pkg/analyzer_experimental/test/generated/resolver_test.dart

Issue 12604020: analyzer_experimental checkpoint and AnalysisContext example. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Don't mark Source as 'changed'. Created 7 years, 9 months 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 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 3
4 library engine.resolver_test; 4 library engine.resolver_test;
5 5
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'package:analyzer_experimental/src/generated/java_core.dart'; 7 import 'package:analyzer_experimental/src/generated/java_core.dart';
8 import 'package:analyzer_experimental/src/generated/java_engine.dart'; 8 import 'package:analyzer_experimental/src/generated/java_engine.dart';
9 import 'package:analyzer_experimental/src/generated/java_junit.dart'; 9 import 'package:analyzer_experimental/src/generated/java_junit.dart';
10 import 'package:analyzer_experimental/src/generated/source_io.dart'; 10 import 'package:analyzer_experimental/src/generated/source_io.dart';
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 JUnitTestCase.assertSame(elementD.type, interfaces4[0]); 570 JUnitTestCase.assertSame(elementD.type, interfaces4[0]);
571 _listener.assertNoErrors(); 571 _listener.assertNoErrors();
572 } 572 }
573 void test_visitSimpleFormalParameter_noType() { 573 void test_visitSimpleFormalParameter_noType() {
574 FormalParameter node = ASTFactory.simpleFormalParameter3("p"); 574 FormalParameter node = ASTFactory.simpleFormalParameter3("p");
575 node.identifier.element = new ParameterElementImpl(ASTFactory.identifier2("p ")); 575 node.identifier.element = new ParameterElementImpl(ASTFactory.identifier2("p "));
576 JUnitTestCase.assertSame(_typeProvider.dynamicType, resolve5(node, [])); 576 JUnitTestCase.assertSame(_typeProvider.dynamicType, resolve5(node, []));
577 _listener.assertNoErrors(); 577 _listener.assertNoErrors();
578 } 578 }
579 void test_visitSimpleFormalParameter_type() { 579 void test_visitSimpleFormalParameter_type() {
580 InterfaceType intType8 = _typeProvider.intType; 580 InterfaceType intType9 = _typeProvider.intType;
581 ClassElement intElement = intType8.element; 581 ClassElement intElement = intType9.element;
582 FormalParameter node = ASTFactory.simpleFormalParameter4(ASTFactory.typeName (intElement, []), "p"); 582 FormalParameter node = ASTFactory.simpleFormalParameter4(ASTFactory.typeName (intElement, []), "p");
583 SimpleIdentifier identifier18 = node.identifier; 583 SimpleIdentifier identifier18 = node.identifier;
584 ParameterElementImpl element = new ParameterElementImpl(identifier18); 584 ParameterElementImpl element = new ParameterElementImpl(identifier18);
585 identifier18.element = element; 585 identifier18.element = element;
586 JUnitTestCase.assertSame(intType8, resolve5(node, [intElement])); 586 JUnitTestCase.assertSame(intType9, resolve5(node, [intElement]));
587 _listener.assertNoErrors(); 587 _listener.assertNoErrors();
588 } 588 }
589 void test_visitTypeName_noParameters_noArguments() { 589 void test_visitTypeName_noParameters_noArguments() {
590 ClassElement classA = ElementFactory.classElement2("A", []); 590 ClassElement classA = ElementFactory.classElement2("A", []);
591 TypeName typeName5 = ASTFactory.typeName(classA, []); 591 TypeName typeName5 = ASTFactory.typeName(classA, []);
592 typeName5.type = null; 592 typeName5.type = null;
593 resolveNode(typeName5, [classA]); 593 resolveNode(typeName5, [classA]);
594 JUnitTestCase.assertSame(classA.type, typeName5.type); 594 JUnitTestCase.assertSame(classA.type, typeName5.type);
595 _listener.assertNoErrors(); 595 _listener.assertNoErrors();
596 } 596 }
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 resolve(source, []); 914 resolve(source, []);
915 assertErrors([CompileTimeErrorCode.AMBIGUOUS_IMPORT]); 915 assertErrors([CompileTimeErrorCode.AMBIGUOUS_IMPORT]);
916 verify([source]); 916 verify([source]);
917 } 917 }
918 void fail_compileTimeConstantRaisesException() { 918 void fail_compileTimeConstantRaisesException() {
919 Source source = addSource("/test.dart", EngineTestCase.createSource([])); 919 Source source = addSource("/test.dart", EngineTestCase.createSource([]));
920 resolve(source, []); 920 resolve(source, []);
921 assertErrors([CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES_EXCEPTION]); 921 assertErrors([CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES_EXCEPTION]);
922 verify([source]); 922 verify([source]);
923 } 923 }
924 void fail_constEvalThrowsException() {
925 Source source = addSource("/test.dart", EngineTestCase.createSource(["class C {", " const C() { throw null; }", "}", "f() { return const C(); }"]));
926 resolve(source, []);
927 assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
928 verify([source]);
929 }
930 void fail_constWithNonConstantArgument() { 924 void fail_constWithNonConstantArgument() {
931 Source source = addSource("/test.dart", EngineTestCase.createSource(["class T {", " T(a) {};", "}", "f(p) { return const T(p); }"])); 925 Source source = addSource("/test.dart", EngineTestCase.createSource(["class T {", " T(a) {};", "}", "f(p) { return const T(p); }"]));
932 resolve(source, []); 926 resolve(source, []);
933 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT]); 927 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT]);
934 verify([source]); 928 verify([source]);
935 } 929 }
936 void fail_constWithNonType() { 930 void fail_constWithNonType() {
937 Source source = addSource("/test.dart", EngineTestCase.createSource(["int A; ", "f() {", " return const A();", "}"])); 931 Source source = addSource("/test.dart", EngineTestCase.createSource(["int A; ", "f() {", " return const A();", "}"]));
938 resolve(source, []); 932 resolve(source, []);
939 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_TYPE]); 933 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_TYPE]);
940 verify([source]); 934 verify([source]);
941 } 935 }
942 void fail_constWithTypeParameters() { 936 void fail_constWithTypeParameters() {
943 Source source = addSource("/test.dart", EngineTestCase.createSource([])); 937 Source source = addSource("/test.dart", EngineTestCase.createSource([]));
944 resolve(source, []); 938 resolve(source, []);
945 assertErrors([CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS]); 939 assertErrors([CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS]);
946 verify([source]); 940 verify([source]);
947 } 941 }
948 void fail_constWithUndefinedConstructor() { 942 void fail_constWithUndefinedConstructor() {
949 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " A(x) {}", "}", "f() {", " return const A(0);", "}"])); 943 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " A(x) {}", "}", "f() {", " return const A(0);", "}"]));
950 resolve(source, []); 944 resolve(source, []);
951 assertErrors([CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR]); 945 assertErrors([CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR]);
952 verify([source]); 946 verify([source]);
953 } 947 }
954 void fail_defaultValueInFunctionTypeAlias() {
955 Source source = addSource("/test.dart", EngineTestCase.createSource(["typede f F([x = 0]);"]));
956 resolve(source, []);
957 assertErrors([CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS]);
958 verify([source]);
959 }
960 void fail_duplicateDefinition() { 948 void fail_duplicateDefinition() {
961 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " int m = 0;", " m(a) {}", "}"])); 949 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " int m = 0;", " m(a) {}", "}"]));
962 resolve(source, []); 950 resolve(source, []);
963 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]); 951 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]);
964 verify([source]); 952 verify([source]);
965 } 953 }
966 void fail_duplicateMemberName() { 954 void fail_duplicateMemberName() {
967 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x = 0;", " int x() {}", "}"])); 955 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x = 0;", " int x() {}", "}"]));
968 resolve(source, []); 956 resolve(source, []);
969 assertErrors([CompileTimeErrorCode.DUPLICATE_MEMBER_NAME]); 957 assertErrors([CompileTimeErrorCode.DUPLICATE_MEMBER_NAME]);
(...skipping 11 matching lines...) Expand all
981 assertErrors([CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT]); 969 assertErrors([CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT]);
982 verify([source]); 970 verify([source]);
983 } 971 }
984 void fail_exportOfNonLibrary() { 972 void fail_exportOfNonLibrary() {
985 Source source = addSource("/test.dart", EngineTestCase.createSource(["librar y L;", "export 'lib1.dart';"])); 973 Source source = addSource("/test.dart", EngineTestCase.createSource(["librar y L;", "export 'lib1.dart';"]));
986 addSource("/lib1.dart", EngineTestCase.createSource(["part of lib;"])); 974 addSource("/lib1.dart", EngineTestCase.createSource(["part of lib;"]));
987 resolve(source, []); 975 resolve(source, []);
988 assertErrors([CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY]); 976 assertErrors([CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY]);
989 verify([source]); 977 verify([source]);
990 } 978 }
991 void fail_extendsOrImplementsDisallowedClass_extends_bool() {
992 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends bool {}"]));
993 resolve(source, []);
994 assertErrors([CompileTimeErrorCode.EXTENDS_OR_IMPLEMENTS_DISALLOWED_CLASS]);
995 verify([source]);
996 }
997 void fail_extendsOrImplementsDisallowedClass_extends_double() {
998 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends double {}"]));
999 resolve(source, []);
1000 assertErrors([CompileTimeErrorCode.EXTENDS_OR_IMPLEMENTS_DISALLOWED_CLASS]);
1001 verify([source]);
1002 }
1003 void fail_extendsOrImplementsDisallowedClass_extends_int() {
1004 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends int {}"]));
1005 resolve(source, []);
1006 assertErrors([CompileTimeErrorCode.EXTENDS_OR_IMPLEMENTS_DISALLOWED_CLASS]);
1007 verify([source]);
1008 }
1009 void fail_extendsOrImplementsDisallowedClass_extends_null() { 979 void fail_extendsOrImplementsDisallowedClass_extends_null() {
1010 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends Null {}"])); 980 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends Null {}"]));
1011 resolve(source, []); 981 resolve(source, []);
1012 assertErrors([CompileTimeErrorCode.EXTENDS_OR_IMPLEMENTS_DISALLOWED_CLASS]); 982 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
1013 verify([source]);
1014 }
1015 void fail_extendsOrImplementsDisallowedClass_extends_num() {
1016 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends num {}"]));
1017 resolve(source, []);
1018 assertErrors([CompileTimeErrorCode.EXTENDS_OR_IMPLEMENTS_DISALLOWED_CLASS]);
1019 verify([source]);
1020 }
1021 void fail_extendsOrImplementsDisallowedClass_extends_String() {
1022 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends String {}"]));
1023 resolve(source, []);
1024 assertErrors([CompileTimeErrorCode.EXTENDS_OR_IMPLEMENTS_DISALLOWED_CLASS]);
1025 verify([source]);
1026 }
1027 void fail_extendsOrImplementsDisallowedClass_implements_bool() {
1028 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements bool {}"]));
1029 resolve(source, []);
1030 assertErrors([CompileTimeErrorCode.EXTENDS_OR_IMPLEMENTS_DISALLOWED_CLASS]);
1031 verify([source]);
1032 }
1033 void fail_extendsOrImplementsDisallowedClass_implements_double() {
1034 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements double {}"]));
1035 resolve(source, []);
1036 assertErrors([CompileTimeErrorCode.EXTENDS_OR_IMPLEMENTS_DISALLOWED_CLASS]);
1037 verify([source]);
1038 }
1039 void fail_extendsOrImplementsDisallowedClass_implements_int() {
1040 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements int {}"]));
1041 resolve(source, []);
1042 assertErrors([CompileTimeErrorCode.EXTENDS_OR_IMPLEMENTS_DISALLOWED_CLASS]);
1043 verify([source]); 983 verify([source]);
1044 } 984 }
1045 void fail_extendsOrImplementsDisallowedClass_implements_null() { 985 void fail_extendsOrImplementsDisallowedClass_implements_null() {
1046 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements Null {}"])); 986 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements Null {}"]));
1047 resolve(source, []); 987 resolve(source, []);
1048 assertErrors([CompileTimeErrorCode.EXTENDS_OR_IMPLEMENTS_DISALLOWED_CLASS]); 988 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
1049 verify([source]);
1050 }
1051 void fail_extendsOrImplementsDisallowedClass_implements_num() {
1052 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements num {}"]));
1053 resolve(source, []);
1054 assertErrors([CompileTimeErrorCode.EXTENDS_OR_IMPLEMENTS_DISALLOWED_CLASS]);
1055 verify([source]);
1056 }
1057 void fail_extendsOrImplementsDisallowedClass_implements_String() {
1058 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements String {}"]));
1059 resolve(source, []);
1060 assertErrors([CompileTimeErrorCode.EXTENDS_OR_IMPLEMENTS_DISALLOWED_CLASS]);
1061 verify([source]); 989 verify([source]);
1062 } 990 }
1063 void fail_fieldInitializedByMultipleInitializers() { 991 void fail_fieldInitializedByMultipleInitializers() {
1064 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " A() : x = 0, x = 1 {}", "}"])); 992 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " A() : x = 0, x = 1 {}", "}"]));
1065 resolve(source, []); 993 resolve(source, []);
1066 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZER S]); 994 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZER S]);
1067 verify([source]); 995 verify([source]);
1068 } 996 }
1069 void fail_fieldInitializedInInitializerAndDeclaration() { 997 void fail_fieldInitializedInInitializerAndDeclaration() {
1070 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final int x = 0;", " A() : x = 1 {}", "}"])); 998 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final int x = 0;", " A() : x = 1 {}", "}"]));
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 resolve(source, []); 1573 resolve(source, []);
1646 assertErrors([CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD]) ; 1574 assertErrors([CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD]) ;
1647 verify([source]); 1575 verify([source]);
1648 } 1576 }
1649 void test_constConstructorWithNonFinalField() { 1577 void test_constConstructorWithNonFinalField() {
1650 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " const A() {}", "}"])); 1578 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " const A() {}", "}"]));
1651 resolve(source, []); 1579 resolve(source, []);
1652 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]); 1580 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]);
1653 verify([source]); 1581 verify([source]);
1654 } 1582 }
1583 void test_constEvalThrowsException() {
1584 Source source = addSource("/test.dart", EngineTestCase.createSource(["class C {", " const C() { throw null; }", "}", "f() { return const C(); }"]));
1585 resolve(source, []);
1586 assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
1587 verify([source]);
1588 }
1655 void test_constFormalParameter_fieldFormalParameter() { 1589 void test_constFormalParameter_fieldFormalParameter() {
1656 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " var x;", " A(const this.x) {}", "}"])); 1590 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " var x;", " A(const this.x) {}", "}"]));
1657 resolve(source, []); 1591 resolve(source, []);
1658 assertErrors([CompileTimeErrorCode.CONST_FORMAL_PARAMETER]); 1592 assertErrors([CompileTimeErrorCode.CONST_FORMAL_PARAMETER]);
1659 verify([source]); 1593 verify([source]);
1660 } 1594 }
1661 void test_constFormalParameter_simpleFormalParameter() { 1595 void test_constFormalParameter_simpleFormalParameter() {
1662 Source source = addSource("/test.dart", EngineTestCase.createSource(["f(cons t x) {}"])); 1596 Source source = addSource("/test.dart", EngineTestCase.createSource(["f(cons t x) {}"]));
1663 resolve(source, []); 1597 resolve(source, []);
1664 assertErrors([CompileTimeErrorCode.CONST_FORMAL_PARAMETER]); 1598 assertErrors([CompileTimeErrorCode.CONST_FORMAL_PARAMETER]);
(...skipping 10 matching lines...) Expand all
1675 resolve(source, []); 1609 resolve(source, []);
1676 assertErrors([CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]); 1610 assertErrors([CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]);
1677 verify([source]); 1611 verify([source]);
1678 } 1612 }
1679 void test_constWithNonConst() { 1613 void test_constWithNonConst() {
1680 Source source = addSource("/test.dart", EngineTestCase.createSource(["class T {", " T(a, b, {c, d}) {}", "}", "f() { return const T(0, 1, c: 2, d: 3); }"]) ); 1614 Source source = addSource("/test.dart", EngineTestCase.createSource(["class T {", " T(a, b, {c, d}) {}", "}", "f() { return const T(0, 1, c: 2, d: 3); }"]) );
1681 resolve(source, []); 1615 resolve(source, []);
1682 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONST]); 1616 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONST]);
1683 verify([source]); 1617 verify([source]);
1684 } 1618 }
1619 void test_defaultValueInFunctionTypeAlias() {
1620 Source source = addSource("/test.dart", EngineTestCase.createSource(["typede f F([x = 0]);"]));
1621 resolve(source, []);
1622 assertErrors([CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS]);
1623 verify([source]);
1624 }
1685 void test_duplicateMemberError() { 1625 void test_duplicateMemberError() {
1686 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([" library lib;", "", "part 'a.dart';", "part 'b.dart';"])); 1626 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([" library lib;", "", "part 'a.dart';", "part 'b.dart';"]));
1687 Source sourceA = addSource("/a.dart", EngineTestCase.createSource(["part of lib;", "", "class A {}"])); 1627 Source sourceA = addSource("/a.dart", EngineTestCase.createSource(["part of lib;", "", "class A {}"]));
1688 Source sourceB = addSource("/b.dart", EngineTestCase.createSource(["part of lib;", "", "class A {}"])); 1628 Source sourceB = addSource("/b.dart", EngineTestCase.createSource(["part of lib;", "", "class A {}"]));
1689 resolve(librarySource, [sourceA, sourceB]); 1629 resolve(librarySource, [sourceA, sourceB]);
1690 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]); 1630 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]);
1691 verify([librarySource, sourceA, sourceB]); 1631 verify([librarySource, sourceA, sourceB]);
1692 } 1632 }
1693 void test_extendsNonClass() { 1633 void test_extendsNonClass() {
1694 Source source = addSource("/test.dart", EngineTestCase.createSource(["int A; ", "class B extends A {}"])); 1634 Source source = addSource("/test.dart", EngineTestCase.createSource(["int A; ", "class B extends A {}"]));
1695 resolve(source, []); 1635 resolve(source, []);
1696 assertErrors([CompileTimeErrorCode.EXTENDS_NON_CLASS]); 1636 assertErrors([CompileTimeErrorCode.EXTENDS_NON_CLASS]);
1697 verify([source]); 1637 verify([source]);
1698 } 1638 }
1639 void test_extendsOrImplementsDisallowedClass_extends_bool() {
1640 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends bool {}"]));
1641 resolve(source, []);
1642 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
1643 verify([source]);
1644 }
1645 void test_extendsOrImplementsDisallowedClass_extends_double() {
1646 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends double {}"]));
1647 resolve(source, []);
1648 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
1649 verify([source]);
1650 }
1651 void test_extendsOrImplementsDisallowedClass_extends_int() {
1652 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends int {}"]));
1653 resolve(source, []);
1654 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
1655 verify([source]);
1656 }
1657 void test_extendsOrImplementsDisallowedClass_extends_num() {
1658 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends num {}"]));
1659 resolve(source, []);
1660 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
1661 verify([source]);
1662 }
1663 void test_extendsOrImplementsDisallowedClass_extends_String() {
1664 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends String {}"]));
1665 resolve(source, []);
1666 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
1667 verify([source]);
1668 }
1669 void test_extendsOrImplementsDisallowedClass_implements_bool() {
1670 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements bool {}"]));
1671 resolve(source, []);
1672 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
1673 verify([source]);
1674 }
1675 void test_extendsOrImplementsDisallowedClass_implements_double() {
1676 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements double {}"]));
1677 resolve(source, []);
1678 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
1679 verify([source]);
1680 }
1681 void test_extendsOrImplementsDisallowedClass_implements_int() {
1682 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements int {}"]));
1683 resolve(source, []);
1684 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
1685 verify([source]);
1686 }
1687 void test_extendsOrImplementsDisallowedClass_implements_num() {
1688 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements num {}"]));
1689 resolve(source, []);
1690 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
1691 verify([source]);
1692 }
1693 void test_extendsOrImplementsDisallowedClass_implements_String() {
1694 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements String {}"]));
1695 resolve(source, []);
1696 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
1697 verify([source]);
1698 }
1699 void test_implementsNonClass() { 1699 void test_implementsNonClass() {
1700 Source source = addSource("/test.dart", EngineTestCase.createSource(["int A; ", "class B implements A {}"])); 1700 Source source = addSource("/test.dart", EngineTestCase.createSource(["int A; ", "class B implements A {}"]));
1701 resolve(source, []); 1701 resolve(source, []);
1702 assertErrors([CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]); 1702 assertErrors([CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]);
1703 verify([source]); 1703 verify([source]);
1704 } 1704 }
1705 void test_labelInOuterScope() { 1705 void test_labelInOuterScope() {
1706 Source source = addSource("/test.dart", EngineTestCase.createSource(["class int {}", "", "class A {", " void m(int i) {", " l: while (i > 0) {", " void f() {", " break l;", " };", " }", " }", "}"])); 1706 Source source = addSource("/test.dart", EngineTestCase.createSource(["class int {}", "", "class A {", " void m(int i) {", " l: while (i > 0) {", " void f() {", " break l;", " };", " }", " }", "}"]));
1707 resolve(source, []); 1707 resolve(source, []);
1708 assertErrors([CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE, ResolverErrorCode.C ANNOT_BE_RESOLVED]); 1708 assertErrors([CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE, ResolverErrorCode.C ANNOT_BE_RESOLVED]);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 runJUnitTest(__test, __test.test_conflictingConstructorNameAndMember_fie ld); 1790 runJUnitTest(__test, __test.test_conflictingConstructorNameAndMember_fie ld);
1791 }); 1791 });
1792 _ut.test('test_conflictingConstructorNameAndMember_method', () { 1792 _ut.test('test_conflictingConstructorNameAndMember_method', () {
1793 final __test = new CompileTimeErrorCodeTest(); 1793 final __test = new CompileTimeErrorCodeTest();
1794 runJUnitTest(__test, __test.test_conflictingConstructorNameAndMember_met hod); 1794 runJUnitTest(__test, __test.test_conflictingConstructorNameAndMember_met hod);
1795 }); 1795 });
1796 _ut.test('test_constConstructorWithNonFinalField', () { 1796 _ut.test('test_constConstructorWithNonFinalField', () {
1797 final __test = new CompileTimeErrorCodeTest(); 1797 final __test = new CompileTimeErrorCodeTest();
1798 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField); 1798 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField);
1799 }); 1799 });
1800 _ut.test('test_constEvalThrowsException', () {
1801 final __test = new CompileTimeErrorCodeTest();
1802 runJUnitTest(__test, __test.test_constEvalThrowsException);
1803 });
1800 _ut.test('test_constFormalParameter_fieldFormalParameter', () { 1804 _ut.test('test_constFormalParameter_fieldFormalParameter', () {
1801 final __test = new CompileTimeErrorCodeTest(); 1805 final __test = new CompileTimeErrorCodeTest();
1802 runJUnitTest(__test, __test.test_constFormalParameter_fieldFormalParamet er); 1806 runJUnitTest(__test, __test.test_constFormalParameter_fieldFormalParamet er);
1803 }); 1807 });
1804 _ut.test('test_constFormalParameter_simpleFormalParameter', () { 1808 _ut.test('test_constFormalParameter_simpleFormalParameter', () {
1805 final __test = new CompileTimeErrorCodeTest(); 1809 final __test = new CompileTimeErrorCodeTest();
1806 runJUnitTest(__test, __test.test_constFormalParameter_simpleFormalParame ter); 1810 runJUnitTest(__test, __test.test_constFormalParameter_simpleFormalParame ter);
1807 }); 1811 });
1808 _ut.test('test_constInitializedWithNonConstValue', () { 1812 _ut.test('test_constInitializedWithNonConstValue', () {
1809 final __test = new CompileTimeErrorCodeTest(); 1813 final __test = new CompileTimeErrorCodeTest();
1810 runJUnitTest(__test, __test.test_constInitializedWithNonConstValue); 1814 runJUnitTest(__test, __test.test_constInitializedWithNonConstValue);
1811 }); 1815 });
1812 _ut.test('test_constWithInvalidTypeParameters', () { 1816 _ut.test('test_constWithInvalidTypeParameters', () {
1813 final __test = new CompileTimeErrorCodeTest(); 1817 final __test = new CompileTimeErrorCodeTest();
1814 runJUnitTest(__test, __test.test_constWithInvalidTypeParameters); 1818 runJUnitTest(__test, __test.test_constWithInvalidTypeParameters);
1815 }); 1819 });
1816 _ut.test('test_constWithNonConst', () { 1820 _ut.test('test_constWithNonConst', () {
1817 final __test = new CompileTimeErrorCodeTest(); 1821 final __test = new CompileTimeErrorCodeTest();
1818 runJUnitTest(__test, __test.test_constWithNonConst); 1822 runJUnitTest(__test, __test.test_constWithNonConst);
1819 }); 1823 });
1824 _ut.test('test_defaultValueInFunctionTypeAlias', () {
1825 final __test = new CompileTimeErrorCodeTest();
1826 runJUnitTest(__test, __test.test_defaultValueInFunctionTypeAlias);
1827 });
1820 _ut.test('test_duplicateMemberError', () { 1828 _ut.test('test_duplicateMemberError', () {
1821 final __test = new CompileTimeErrorCodeTest(); 1829 final __test = new CompileTimeErrorCodeTest();
1822 runJUnitTest(__test, __test.test_duplicateMemberError); 1830 runJUnitTest(__test, __test.test_duplicateMemberError);
1823 }); 1831 });
1824 _ut.test('test_extendsNonClass', () { 1832 _ut.test('test_extendsNonClass', () {
1825 final __test = new CompileTimeErrorCodeTest(); 1833 final __test = new CompileTimeErrorCodeTest();
1826 runJUnitTest(__test, __test.test_extendsNonClass); 1834 runJUnitTest(__test, __test.test_extendsNonClass);
1827 }); 1835 });
1836 _ut.test('test_extendsOrImplementsDisallowedClass_extends_String', () {
1837 final __test = new CompileTimeErrorCodeTest();
1838 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_exte nds_String);
1839 });
1840 _ut.test('test_extendsOrImplementsDisallowedClass_extends_bool', () {
1841 final __test = new CompileTimeErrorCodeTest();
1842 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_exte nds_bool);
1843 });
1844 _ut.test('test_extendsOrImplementsDisallowedClass_extends_double', () {
1845 final __test = new CompileTimeErrorCodeTest();
1846 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_exte nds_double);
1847 });
1848 _ut.test('test_extendsOrImplementsDisallowedClass_extends_int', () {
1849 final __test = new CompileTimeErrorCodeTest();
1850 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_exte nds_int);
1851 });
1852 _ut.test('test_extendsOrImplementsDisallowedClass_extends_num', () {
1853 final __test = new CompileTimeErrorCodeTest();
1854 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_exte nds_num);
1855 });
1856 _ut.test('test_extendsOrImplementsDisallowedClass_implements_String', () {
1857 final __test = new CompileTimeErrorCodeTest();
1858 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_impl ements_String);
1859 });
1860 _ut.test('test_extendsOrImplementsDisallowedClass_implements_bool', () {
1861 final __test = new CompileTimeErrorCodeTest();
1862 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_impl ements_bool);
1863 });
1864 _ut.test('test_extendsOrImplementsDisallowedClass_implements_double', () {
1865 final __test = new CompileTimeErrorCodeTest();
1866 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_impl ements_double);
1867 });
1868 _ut.test('test_extendsOrImplementsDisallowedClass_implements_int', () {
1869 final __test = new CompileTimeErrorCodeTest();
1870 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_impl ements_int);
1871 });
1872 _ut.test('test_extendsOrImplementsDisallowedClass_implements_num', () {
1873 final __test = new CompileTimeErrorCodeTest();
1874 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_impl ements_num);
1875 });
1828 _ut.test('test_implementsNonClass', () { 1876 _ut.test('test_implementsNonClass', () {
1829 final __test = new CompileTimeErrorCodeTest(); 1877 final __test = new CompileTimeErrorCodeTest();
1830 runJUnitTest(__test, __test.test_implementsNonClass); 1878 runJUnitTest(__test, __test.test_implementsNonClass);
1831 }); 1879 });
1832 _ut.test('test_labelInOuterScope', () { 1880 _ut.test('test_labelInOuterScope', () {
1833 final __test = new CompileTimeErrorCodeTest(); 1881 final __test = new CompileTimeErrorCodeTest();
1834 runJUnitTest(__test, __test.test_labelInOuterScope); 1882 runJUnitTest(__test, __test.test_labelInOuterScope);
1835 }); 1883 });
1836 _ut.test('test_labelUndefined_break', () { 1884 _ut.test('test_labelUndefined_break', () {
1837 final __test = new CompileTimeErrorCodeTest(); 1885 final __test = new CompileTimeErrorCodeTest();
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after
3307 List<ASTNode> _unresolvedNodes = new List<ASTNode>(); 3355 List<ASTNode> _unresolvedNodes = new List<ASTNode>();
3308 /** 3356 /**
3309 * A list containing all of the AST nodes that were resolved to an element of the wrong type. 3357 * A list containing all of the AST nodes that were resolved to an element of the wrong type.
3310 */ 3358 */
3311 List<ASTNode> _wrongTypedNodes = new List<ASTNode>(); 3359 List<ASTNode> _wrongTypedNodes = new List<ASTNode>();
3312 /** 3360 /**
3313 * Initialize a newly created verifier to verify that all of the nodes in the visited AST 3361 * Initialize a newly created verifier to verify that all of the nodes in the visited AST
3314 * structures that are expected to have been resolved have an element associat ed with them. 3362 * structures that are expected to have been resolved have an element associat ed with them.
3315 */ 3363 */
3316 ResolutionVerifier() { 3364 ResolutionVerifier() {
3317 _jtd_constructor_317_impl(); 3365 _jtd_constructor_319_impl();
3318 } 3366 }
3319 _jtd_constructor_317_impl() { 3367 _jtd_constructor_319_impl() {
3320 _jtd_constructor_318_impl(null); 3368 _jtd_constructor_320_impl(null);
3321 } 3369 }
3322 /** 3370 /**
3323 * Initialize a newly created verifier to verify that all of the identifiers i n the visited AST 3371 * Initialize a newly created verifier to verify that all of the identifiers i n the visited AST
3324 * structures that are expected to have been resolved have an element associat ed with them. Nodes 3372 * structures that are expected to have been resolved have an element associat ed with them. Nodes
3325 * in the set of known exceptions are not expected to have been resolved, even if they normally 3373 * in the set of known exceptions are not expected to have been resolved, even if they normally
3326 * would have been expected to have been resolved. 3374 * would have been expected to have been resolved.
3327 * @param knownExceptions a set containing nodes that are known to not be reso lvable and should 3375 * @param knownExceptions a set containing nodes that are known to not be reso lvable and should
3328 * therefore not cause the test to fail 3376 * therefore not cause the test to fail
3329 */ 3377 */
3330 ResolutionVerifier.con1(Set<ASTNode> knownExceptions2) { 3378 ResolutionVerifier.con1(Set<ASTNode> knownExceptions2) {
3331 _jtd_constructor_318_impl(knownExceptions2); 3379 _jtd_constructor_320_impl(knownExceptions2);
3332 } 3380 }
3333 _jtd_constructor_318_impl(Set<ASTNode> knownExceptions2) { 3381 _jtd_constructor_320_impl(Set<ASTNode> knownExceptions2) {
3334 this._knownExceptions = knownExceptions2; 3382 this._knownExceptions = knownExceptions2;
3335 } 3383 }
3336 /** 3384 /**
3337 * Assert that all of the visited identifiers were resolved. 3385 * Assert that all of the visited identifiers were resolved.
3338 */ 3386 */
3339 void assertResolved() { 3387 void assertResolved() {
3340 if (!_unresolvedNodes.isEmpty || !_wrongTypedNodes.isEmpty) { 3388 if (!_unresolvedNodes.isEmpty || !_wrongTypedNodes.isEmpty) {
3341 PrintStringWriter writer = new PrintStringWriter(); 3389 PrintStringWriter writer = new PrintStringWriter();
3342 if (!_unresolvedNodes.isEmpty) { 3390 if (!_unresolvedNodes.isEmpty) {
3343 writer.print("Failed to resolve "); 3391 writer.print("Failed to resolve ");
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
3519 */ 3567 */
3520 StaticTypeAnalyzer _analyzer; 3568 StaticTypeAnalyzer _analyzer;
3521 /** 3569 /**
3522 * The type provider used to access the types. 3570 * The type provider used to access the types.
3523 */ 3571 */
3524 TestTypeProvider _typeProvider; 3572 TestTypeProvider _typeProvider;
3525 void fail_visitFunctionExpressionInvocation() { 3573 void fail_visitFunctionExpressionInvocation() {
3526 JUnitTestCase.fail("Not yet tested"); 3574 JUnitTestCase.fail("Not yet tested");
3527 _listener.assertNoErrors(); 3575 _listener.assertNoErrors();
3528 } 3576 }
3529 void fail_visitIndexExpression_typeParameters() {
3530 InterfaceType intType6 = _typeProvider.intType;
3531 InterfaceType listType2 = _typeProvider.listType;
3532 MethodElement methodElement = getMethod(listType2, "[]");
3533 SimpleIdentifier identifier = ASTFactory.identifier2("list");
3534 identifier.staticType = listType2.substitute5(<Type2> [intType6]);
3535 IndexExpression indexExpression2 = ASTFactory.indexExpression(identifier, AS TFactory.integer(0));
3536 indexExpression2.element = methodElement;
3537 JUnitTestCase.assertSame(intType6, analyze(indexExpression2));
3538 _listener.assertNoErrors();
3539 }
3540 void fail_visitMethodInvocation() { 3577 void fail_visitMethodInvocation() {
3541 JUnitTestCase.fail("Not yet tested"); 3578 JUnitTestCase.fail("Not yet tested");
3542 _listener.assertNoErrors(); 3579 _listener.assertNoErrors();
3543 } 3580 }
3544 void fail_visitSimpleIdentifier() { 3581 void fail_visitSimpleIdentifier() {
3545 JUnitTestCase.fail("Not yet tested"); 3582 JUnitTestCase.fail("Not yet tested");
3546 _listener.assertNoErrors(); 3583 _listener.assertNoErrors();
3547 } 3584 }
3548 void setUp() { 3585 void setUp() {
3549 _listener = new GatheringErrorListener(); 3586 _listener = new GatheringErrorListener();
(...skipping 20 matching lines...) Expand all
3570 } 3607 }
3571 void test_visitAssignmentExpression_compound() { 3608 void test_visitAssignmentExpression_compound() {
3572 InterfaceType numType6 = _typeProvider.numType; 3609 InterfaceType numType6 = _typeProvider.numType;
3573 SimpleIdentifier identifier = resolvedVariable(_typeProvider.intType, "i"); 3610 SimpleIdentifier identifier = resolvedVariable(_typeProvider.intType, "i");
3574 AssignmentExpression node = ASTFactory.assignmentExpression(identifier, Toke nType.PLUS_EQ, resolvedInteger(1)); 3611 AssignmentExpression node = ASTFactory.assignmentExpression(identifier, Toke nType.PLUS_EQ, resolvedInteger(1));
3575 node.element = getMethod(numType6, "+"); 3612 node.element = getMethod(numType6, "+");
3576 JUnitTestCase.assertSame(numType6, analyze(node)); 3613 JUnitTestCase.assertSame(numType6, analyze(node));
3577 _listener.assertNoErrors(); 3614 _listener.assertNoErrors();
3578 } 3615 }
3579 void test_visitAssignmentExpression_simple() { 3616 void test_visitAssignmentExpression_simple() {
3580 InterfaceType intType7 = _typeProvider.intType; 3617 InterfaceType intType6 = _typeProvider.intType;
3581 Expression node = ASTFactory.assignmentExpression(resolvedVariable(intType7, "i"), TokenType.EQ, resolvedInteger(0)); 3618 Expression node = ASTFactory.assignmentExpression(resolvedVariable(intType6, "i"), TokenType.EQ, resolvedInteger(0));
3582 JUnitTestCase.assertSame(intType7, analyze(node)); 3619 JUnitTestCase.assertSame(intType6, analyze(node));
3583 _listener.assertNoErrors(); 3620 _listener.assertNoErrors();
3584 } 3621 }
3585 void test_visitBinaryExpression_equals() { 3622 void test_visitBinaryExpression_equals() {
3586 Expression node = ASTFactory.binaryExpression(resolvedInteger(2), TokenType. EQ_EQ, resolvedInteger(3)); 3623 Expression node = ASTFactory.binaryExpression(resolvedInteger(2), TokenType. EQ_EQ, resolvedInteger(3));
3587 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); 3624 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
3588 _listener.assertNoErrors(); 3625 _listener.assertNoErrors();
3589 } 3626 }
3590 void test_visitBinaryExpression_logicalAnd() { 3627 void test_visitBinaryExpression_logicalAnd() {
3591 Expression node = ASTFactory.binaryExpression(ASTFactory.booleanLiteral(fals e), TokenType.AMPERSAND_AMPERSAND, ASTFactory.booleanLiteral(true)); 3628 Expression node = ASTFactory.binaryExpression(ASTFactory.booleanLiteral(fals e), TokenType.AMPERSAND_AMPERSAND, ASTFactory.booleanLiteral(true));
3592 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); 3629 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
3760 Type2 dynamicType12 = _typeProvider.dynamicType; 3797 Type2 dynamicType12 = _typeProvider.dynamicType;
3761 FormalParameter p = ASTFactory.positionalFormalParameter(ASTFactory.simpleFo rmalParameter3("p"), resolvedInteger(0)); 3798 FormalParameter p = ASTFactory.positionalFormalParameter(ASTFactory.simpleFo rmalParameter3("p"), resolvedInteger(0));
3762 setType(p, dynamicType12); 3799 setType(p, dynamicType12);
3763 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); 3800 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0)));
3764 analyze3(p); 3801 analyze3(p);
3765 Type2 resultType = analyze(node); 3802 Type2 resultType = analyze(node);
3766 assertFunctionType(_typeProvider.intType, null, <Type2> [dynamicType12], nul l, resultType); 3803 assertFunctionType(_typeProvider.intType, null, <Type2> [dynamicType12], nul l, resultType);
3767 _listener.assertNoErrors(); 3804 _listener.assertNoErrors();
3768 } 3805 }
3769 void test_visitIndexExpression_getter() { 3806 void test_visitIndexExpression_getter() {
3807 InterfaceType listType2 = _typeProvider.listType;
3808 SimpleIdentifier identifier = resolvedVariable(listType2, "a");
3809 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege r(2));
3810 node.element = listType2.element.methods[0];
3811 JUnitTestCase.assertSame(listType2.typeArguments[0], analyze(node));
3812 _listener.assertNoErrors();
3813 }
3814 void test_visitIndexExpression_setter() {
3770 InterfaceType listType3 = _typeProvider.listType; 3815 InterfaceType listType3 = _typeProvider.listType;
3771 SimpleIdentifier identifier = resolvedVariable(listType3, "a"); 3816 SimpleIdentifier identifier = resolvedVariable(listType3, "a");
3772 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege r(2)); 3817 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege r(2));
3773 node.element = listType3.element.methods[0]; 3818 node.element = listType3.element.methods[1];
3819 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0));
3774 JUnitTestCase.assertSame(listType3.typeArguments[0], analyze(node)); 3820 JUnitTestCase.assertSame(listType3.typeArguments[0], analyze(node));
3775 _listener.assertNoErrors(); 3821 _listener.assertNoErrors();
3776 } 3822 }
3777 void test_visitIndexExpression_setter() { 3823 void test_visitIndexExpression_typeParameters() {
3824 InterfaceType intType7 = _typeProvider.intType;
3778 InterfaceType listType4 = _typeProvider.listType; 3825 InterfaceType listType4 = _typeProvider.listType;
3779 SimpleIdentifier identifier = resolvedVariable(listType4, "a"); 3826 MethodElement methodElement = getMethod(listType4, "[]");
3780 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege r(2)); 3827 SimpleIdentifier identifier = ASTFactory.identifier2("list");
3781 node.element = listType4.element.methods[1]; 3828 identifier.staticType = listType4.substitute5(<Type2> [intType7]);
3782 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0)); 3829 IndexExpression indexExpression2 = ASTFactory.indexExpression(identifier, AS TFactory.integer(0));
3783 JUnitTestCase.assertSame(listType4.typeArguments[0], analyze(node)); 3830 indexExpression2.element = methodElement;
3831 JUnitTestCase.assertSame(intType7, analyze(indexExpression2));
3832 _listener.assertNoErrors();
3833 }
3834 void test_visitIndexExpression_typeParameters_inSetterContext() {
3835 InterfaceType intType8 = _typeProvider.intType;
3836 InterfaceType listType5 = _typeProvider.listType;
3837 MethodElement methodElement = getMethod(listType5, "[]=");
3838 SimpleIdentifier identifier = ASTFactory.identifier2("list");
3839 identifier.staticType = listType5.substitute5(<Type2> [intType8]);
3840 IndexExpression indexExpression3 = ASTFactory.indexExpression(identifier, AS TFactory.integer(0));
3841 indexExpression3.element = methodElement;
3842 ASTFactory.assignmentExpression(indexExpression3, TokenType.EQ, ASTFactory.i nteger(0));
3843 JUnitTestCase.assertSame(intType8, analyze(indexExpression3));
3784 _listener.assertNoErrors(); 3844 _listener.assertNoErrors();
3785 } 3845 }
3786 void test_visitInstanceCreationExpression_named() { 3846 void test_visitInstanceCreationExpression_named() {
3787 ClassElement classElement = ElementFactory.classElement2("C", []); 3847 ClassElement classElement = ElementFactory.classElement2("C", []);
3788 String constructorName = "m"; 3848 String constructorName = "m";
3789 ConstructorElementImpl constructor = ElementFactory.constructorElement(const ructorName); 3849 ConstructorElementImpl constructor = ElementFactory.constructorElement(const ructorName);
3790 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); 3850 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor);
3791 constructorType.returnType = classElement.type; 3851 constructorType.returnType = classElement.type;
3792 constructor.type = constructorType; 3852 constructor.type = constructorType;
3793 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, ASTFactory.typeName(classElement, []), [ASTFactory.identifier2(constructorNam e)]); 3853 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, ASTFactory.typeName(classElement, []), [ASTFactory.identifier2(constructorNam e)]);
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
4119 return literal; 4179 return literal;
4120 } 4180 }
4121 /** 4181 /**
4122 * Create a function expression that has an element associated with it, where the element has an 4182 * Create a function expression that has an element associated with it, where the element has an
4123 * incomplete type associated with it (just like the one{@link ElementBuilder# visitFunctionExpression(FunctionExpression)} would have built if we had 4183 * incomplete type associated with it (just like the one{@link ElementBuilder# visitFunctionExpression(FunctionExpression)} would have built if we had
4124 * run it). 4184 * run it).
4125 * @param parameters the parameters to the function 4185 * @param parameters the parameters to the function
4126 * @param body the body of the function 4186 * @param body the body of the function
4127 * @return a resolved function expression 4187 * @return a resolved function expression
4128 */ 4188 */
4129 FunctionExpression resolvedFunctionExpression(FormalParameterList parameters15 , FunctionBody body) { 4189 FunctionExpression resolvedFunctionExpression(FormalParameterList parameters16 , FunctionBody body) {
4130 for (FormalParameter parameter in parameters15.parameters) { 4190 for (FormalParameter parameter in parameters16.parameters) {
4131 ParameterElementImpl element = new ParameterElementImpl(parameter.identifi er); 4191 ParameterElementImpl element = new ParameterElementImpl(parameter.identifi er);
4132 element.parameterKind = parameter.kind; 4192 element.parameterKind = parameter.kind;
4133 element.type = _typeProvider.dynamicType; 4193 element.type = _typeProvider.dynamicType;
4134 parameter.identifier.element = element; 4194 parameter.identifier.element = element;
4135 } 4195 }
4136 FunctionExpression node = ASTFactory.functionExpression2(parameters15, body) ; 4196 FunctionExpression node = ASTFactory.functionExpression2(parameters16, body) ;
4137 FunctionElementImpl element = new FunctionElementImpl.con1(null); 4197 FunctionElementImpl element = new FunctionElementImpl.con1(null);
4138 element.type = new FunctionTypeImpl.con1(element); 4198 element.type = new FunctionTypeImpl.con1(element);
4139 node.element = element; 4199 node.element = element;
4140 return node; 4200 return node;
4141 } 4201 }
4142 /** 4202 /**
4143 * Return an integer literal that has been resolved to the correct type. 4203 * Return an integer literal that has been resolved to the correct type.
4144 * @param value the value of the literal 4204 * @param value the value of the literal
4145 * @return an integer literal that has been resolved to the correct type 4205 * @return an integer literal that has been resolved to the correct type
4146 */ 4206 */
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
4294 runJUnitTest(__test, __test.test_visitFunctionExpression_positional_expr ession); 4354 runJUnitTest(__test, __test.test_visitFunctionExpression_positional_expr ession);
4295 }); 4355 });
4296 _ut.test('test_visitIndexExpression_getter', () { 4356 _ut.test('test_visitIndexExpression_getter', () {
4297 final __test = new StaticTypeAnalyzerTest(); 4357 final __test = new StaticTypeAnalyzerTest();
4298 runJUnitTest(__test, __test.test_visitIndexExpression_getter); 4358 runJUnitTest(__test, __test.test_visitIndexExpression_getter);
4299 }); 4359 });
4300 _ut.test('test_visitIndexExpression_setter', () { 4360 _ut.test('test_visitIndexExpression_setter', () {
4301 final __test = new StaticTypeAnalyzerTest(); 4361 final __test = new StaticTypeAnalyzerTest();
4302 runJUnitTest(__test, __test.test_visitIndexExpression_setter); 4362 runJUnitTest(__test, __test.test_visitIndexExpression_setter);
4303 }); 4363 });
4364 _ut.test('test_visitIndexExpression_typeParameters', () {
4365 final __test = new StaticTypeAnalyzerTest();
4366 runJUnitTest(__test, __test.test_visitIndexExpression_typeParameters);
4367 });
4368 _ut.test('test_visitIndexExpression_typeParameters_inSetterContext', () {
4369 final __test = new StaticTypeAnalyzerTest();
4370 runJUnitTest(__test, __test.test_visitIndexExpression_typeParameters_inS etterContext);
4371 });
4304 _ut.test('test_visitInstanceCreationExpression_named', () { 4372 _ut.test('test_visitInstanceCreationExpression_named', () {
4305 final __test = new StaticTypeAnalyzerTest(); 4373 final __test = new StaticTypeAnalyzerTest();
4306 runJUnitTest(__test, __test.test_visitInstanceCreationExpression_named); 4374 runJUnitTest(__test, __test.test_visitInstanceCreationExpression_named);
4307 }); 4375 });
4308 _ut.test('test_visitInstanceCreationExpression_typeParameters', () { 4376 _ut.test('test_visitInstanceCreationExpression_typeParameters', () {
4309 final __test = new StaticTypeAnalyzerTest(); 4377 final __test = new StaticTypeAnalyzerTest();
4310 runJUnitTest(__test, __test.test_visitInstanceCreationExpression_typePar ameters); 4378 runJUnitTest(__test, __test.test_visitInstanceCreationExpression_typePar ameters);
4311 }); 4379 });
4312 _ut.test('test_visitInstanceCreationExpression_unnamed', () { 4380 _ut.test('test_visitInstanceCreationExpression_unnamed', () {
4313 final __test = new StaticTypeAnalyzerTest(); 4381 final __test = new StaticTypeAnalyzerTest();
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
4795 resolve(source, []); 4863 resolve(source, []);
4796 assertNoErrors(); 4864 assertNoErrors();
4797 verify([source]); 4865 verify([source]);
4798 } 4866 }
4799 void test_constConstructorWithNonFinalField_syntheticField() { 4867 void test_constConstructorWithNonFinalField_syntheticField() {
4800 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " const A();", " set x(value) {}", " get x {return 0;}", "}"])); 4868 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " const A();", " set x(value) {}", " get x {return 0;}", "}"]));
4801 resolve(source, []); 4869 resolve(source, []);
4802 assertNoErrors(); 4870 assertNoErrors();
4803 verify([source]); 4871 verify([source]);
4804 } 4872 }
4873 void test_defaultValueInFunctionTypeAlias() {
4874 Source source = addSource("/test.dart", EngineTestCase.createSource(["typede f F([x]);"]));
4875 resolve(source, []);
4876 assertErrors([]);
4877 verify([source]);
4878 }
4805 void test_duplicateDefinition_getter() { 4879 void test_duplicateDefinition_getter() {
4806 Source source = addSource("/test.dart", EngineTestCase.createSource(["bool g et a => true;"])); 4880 Source source = addSource("/test.dart", EngineTestCase.createSource(["bool g et a => true;"]));
4807 resolve(source, []); 4881 resolve(source, []);
4808 assertNoErrors(); 4882 assertNoErrors();
4809 verify([source]); 4883 verify([source]);
4810 } 4884 }
4811 void test_empty() { 4885 void test_empty() {
4812 Source source = addSource("/test.dart", ""); 4886 Source source = addSource("/test.dart", "");
4813 resolve(source, []); 4887 resolve(source, []);
4814 assertNoErrors(); 4888 assertNoErrors();
(...skipping 16 matching lines...) Expand all
4831 resolve(source, []); 4905 resolve(source, []);
4832 assertNoErrors(); 4906 assertNoErrors();
4833 verify([source]); 4907 verify([source]);
4834 } 4908 }
4835 void test_getterAndSetterWithDifferentTypes() { 4909 void test_getterAndSetterWithDifferentTypes() {
4836 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int get f => 0;", " void set f(String s) {}", "}", "g (A a) {", " a.f = a.f.toString();", "}"])); 4910 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int get f => 0;", " void set f(String s) {}", "}", "g (A a) {", " a.f = a.f.toString();", "}"]));
4837 resolve(source, []); 4911 resolve(source, []);
4838 assertNoErrors(); 4912 assertNoErrors();
4839 verify([source]); 4913 verify([source]);
4840 } 4914 }
4915 void test_indexExpression_typeParameters() {
4916 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " List<int> a;", " a[0];", " List<List<int>> b;", " b[0][0];", " List<Lis t<List<int>>> c;", " c[0][0][0];", "}"]));
4917 resolve(source, []);
4918 assertNoErrors();
4919 verify([source]);
4920 }
4921 void test_indexExpression_typeParameters_invalidAssignmentWarning() {
4922 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " List<List<int>> b;", " b[0][0] = 'hi';", "}"]));
4923 resolve(source, []);
4924 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]);
4925 verify([source]);
4926 }
4841 void test_invalidAssignment() { 4927 void test_invalidAssignment() {
4842 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " var x;", " var y;", " x = y;", "}"])); 4928 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " var x;", " var y;", " x = y;", "}"]));
4843 resolve(source, []); 4929 resolve(source, []);
4844 assertNoErrors(); 4930 assertNoErrors();
4845 verify([source]); 4931 verify([source]);
4846 } 4932 }
4847 void test_invalidAssignment_toDynamic() { 4933 void test_invalidAssignment_toDynamic() {
4848 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " var g;", " g = () => 0;", "}"])); 4934 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " var g;", " g = () => 0;", "}"]));
4849 resolve(source, []); 4935 resolve(source, []);
4850 assertNoErrors(); 4936 assertNoErrors();
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
5031 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_const ); 5117 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_const );
5032 }); 5118 });
5033 _ut.test('test_constConstructorWithNonFinalField_final', () { 5119 _ut.test('test_constConstructorWithNonFinalField_final', () {
5034 final __test = new SimpleResolverTest(); 5120 final __test = new SimpleResolverTest();
5035 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_final ); 5121 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_final );
5036 }); 5122 });
5037 _ut.test('test_constConstructorWithNonFinalField_syntheticField', () { 5123 _ut.test('test_constConstructorWithNonFinalField_syntheticField', () {
5038 final __test = new SimpleResolverTest(); 5124 final __test = new SimpleResolverTest();
5039 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_synth eticField); 5125 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_synth eticField);
5040 }); 5126 });
5127 _ut.test('test_defaultValueInFunctionTypeAlias', () {
5128 final __test = new SimpleResolverTest();
5129 runJUnitTest(__test, __test.test_defaultValueInFunctionTypeAlias);
5130 });
5041 _ut.test('test_duplicateDefinition_getter', () { 5131 _ut.test('test_duplicateDefinition_getter', () {
5042 final __test = new SimpleResolverTest(); 5132 final __test = new SimpleResolverTest();
5043 runJUnitTest(__test, __test.test_duplicateDefinition_getter); 5133 runJUnitTest(__test, __test.test_duplicateDefinition_getter);
5044 }); 5134 });
5045 _ut.test('test_empty', () { 5135 _ut.test('test_empty', () {
5046 final __test = new SimpleResolverTest(); 5136 final __test = new SimpleResolverTest();
5047 runJUnitTest(__test, __test.test_empty); 5137 runJUnitTest(__test, __test.test_empty);
5048 }); 5138 });
5049 _ut.test('test_forEachLoops_nonConflicting', () { 5139 _ut.test('test_forEachLoops_nonConflicting', () {
5050 final __test = new SimpleResolverTest(); 5140 final __test = new SimpleResolverTest();
5051 runJUnitTest(__test, __test.test_forEachLoops_nonConflicting); 5141 runJUnitTest(__test, __test.test_forEachLoops_nonConflicting);
5052 }); 5142 });
5053 _ut.test('test_forLoops_nonConflicting', () { 5143 _ut.test('test_forLoops_nonConflicting', () {
5054 final __test = new SimpleResolverTest(); 5144 final __test = new SimpleResolverTest();
5055 runJUnitTest(__test, __test.test_forLoops_nonConflicting); 5145 runJUnitTest(__test, __test.test_forLoops_nonConflicting);
5056 }); 5146 });
5057 _ut.test('test_functionTypeAlias', () { 5147 _ut.test('test_functionTypeAlias', () {
5058 final __test = new SimpleResolverTest(); 5148 final __test = new SimpleResolverTest();
5059 runJUnitTest(__test, __test.test_functionTypeAlias); 5149 runJUnitTest(__test, __test.test_functionTypeAlias);
5060 }); 5150 });
5061 _ut.test('test_getterAndSetterWithDifferentTypes', () { 5151 _ut.test('test_getterAndSetterWithDifferentTypes', () {
5062 final __test = new SimpleResolverTest(); 5152 final __test = new SimpleResolverTest();
5063 runJUnitTest(__test, __test.test_getterAndSetterWithDifferentTypes); 5153 runJUnitTest(__test, __test.test_getterAndSetterWithDifferentTypes);
5064 }); 5154 });
5155 _ut.test('test_indexExpression_typeParameters', () {
5156 final __test = new SimpleResolverTest();
5157 runJUnitTest(__test, __test.test_indexExpression_typeParameters);
5158 });
5159 _ut.test('test_indexExpression_typeParameters_invalidAssignmentWarning', ( ) {
5160 final __test = new SimpleResolverTest();
5161 runJUnitTest(__test, __test.test_indexExpression_typeParameters_invalidA ssignmentWarning);
5162 });
5065 _ut.test('test_invalidAssignment', () { 5163 _ut.test('test_invalidAssignment', () {
5066 final __test = new SimpleResolverTest(); 5164 final __test = new SimpleResolverTest();
5067 runJUnitTest(__test, __test.test_invalidAssignment); 5165 runJUnitTest(__test, __test.test_invalidAssignment);
5068 }); 5166 });
5069 _ut.test('test_invalidAssignment_toDynamic', () { 5167 _ut.test('test_invalidAssignment_toDynamic', () {
5070 final __test = new SimpleResolverTest(); 5168 final __test = new SimpleResolverTest();
5071 runJUnitTest(__test, __test.test_invalidAssignment_toDynamic); 5169 runJUnitTest(__test, __test.test_invalidAssignment_toDynamic);
5072 }); 5170 });
5073 _ut.test('test_invocationOfNonFunction_dynamic', () { 5171 _ut.test('test_invocationOfNonFunction_dynamic', () {
5074 final __test = new SimpleResolverTest(); 5172 final __test = new SimpleResolverTest();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
5143 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_const); 5241 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_const);
5144 }); 5242 });
5145 _ut.test('test_typeArgumentNotMatchingBounds_new', () { 5243 _ut.test('test_typeArgumentNotMatchingBounds_new', () {
5146 final __test = new SimpleResolverTest(); 5244 final __test = new SimpleResolverTest();
5147 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new); 5245 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new);
5148 }); 5246 });
5149 }); 5247 });
5150 } 5248 }
5151 } 5249 }
5152 main() { 5250 main() {
5153 // ElementResolverTest.dartSuite(); 5251 ElementResolverTest.dartSuite();
5154 // LibraryElementBuilderTest.dartSuite(); 5252 LibraryElementBuilderTest.dartSuite();
5155 // LibraryTest.dartSuite(); 5253 LibraryTest.dartSuite();
5156 // StaticTypeAnalyzerTest.dartSuite(); 5254 StaticTypeAnalyzerTest.dartSuite();
5157 // TypeProviderImplTest.dartSuite(); 5255 TypeProviderImplTest.dartSuite();
5158 // TypeResolverVisitorTest.dartSuite(); 5256 TypeResolverVisitorTest.dartSuite();
5159 // EnclosedScopeTest.dartSuite(); 5257 EnclosedScopeTest.dartSuite();
5160 // LibraryImportScopeTest.dartSuite(); 5258 LibraryImportScopeTest.dartSuite();
5161 // LibraryScopeTest.dartSuite(); 5259 LibraryScopeTest.dartSuite();
5162 // ScopeTest.dartSuite(); 5260 ScopeTest.dartSuite();
5163 // CompileTimeErrorCodeTest.dartSuite(); 5261 CompileTimeErrorCodeTest.dartSuite();
5164 // ErrorResolverTest.dartSuite(); 5262 ErrorResolverTest.dartSuite();
5165 // SimpleResolverTest.dartSuite(); 5263 SimpleResolverTest.dartSuite();
5166 // StaticTypeWarningCodeTest.dartSuite(); 5264 StaticTypeWarningCodeTest.dartSuite();
5167 // StaticWarningCodeTest.dartSuite(); 5265 StaticWarningCodeTest.dartSuite();
5168 } 5266 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698