OLD | NEW |
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 library engine.resolver_test; | 3 library engine.resolver_test; |
4 import 'dart:collection'; | 4 import 'dart:collection'; |
5 import 'package:analyzer_experimental/src/generated/java_core.dart'; | 5 import 'package:analyzer_experimental/src/generated/java_core.dart'; |
6 import 'package:analyzer_experimental/src/generated/java_engine.dart'; | 6 import 'package:analyzer_experimental/src/generated/java_engine.dart'; |
7 import 'package:analyzer_experimental/src/generated/java_junit.dart'; | 7 import 'package:analyzer_experimental/src/generated/java_junit.dart'; |
8 import 'package:analyzer_experimental/src/generated/source_io.dart'; | 8 import 'package:analyzer_experimental/src/generated/source_io.dart'; |
9 import 'package:analyzer_experimental/src/generated/error.dart'; | 9 import 'package:analyzer_experimental/src/generated/error.dart'; |
10 import 'package:analyzer_experimental/src/generated/scanner.dart'; | 10 import 'package:analyzer_experimental/src/generated/scanner.dart'; |
(...skipping 12 matching lines...) Expand all Loading... |
23 class TypePropagationTest extends ResolverTestCase { | 23 class TypePropagationTest extends ResolverTestCase { |
24 void test_as() { | 24 void test_as() { |
25 Source source = addSource(EngineTestCase.createSource(["class A {", " bool
get g => true;", "}", "A f(var p) {", " if ((p as A).g) {", " return p;", "
} else {", " return null;", " }", "}"])); | 25 Source source = addSource(EngineTestCase.createSource(["class A {", " bool
get g => true;", "}", "A f(var p) {", " if ((p as A).g) {", " return p;", "
} else {", " return null;", " }", "}"])); |
26 LibraryElement library = resolve(source); | 26 LibraryElement library = resolve(source); |
27 assertNoErrors(); | 27 assertNoErrors(); |
28 verify([source]); | 28 verify([source]); |
29 CompilationUnit unit = resolveCompilationUnit(source, library); | 29 CompilationUnit unit = resolveCompilationUnit(source, library); |
30 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 30 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
31 InterfaceType typeA = classA.element.type; | 31 InterfaceType typeA = classA.element.type; |
32 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 32 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
33 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 33 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
34 IfStatement ifStatement = body2.block.statements[0] as IfStatement; | 34 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
35 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; | 35 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; |
36 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 36 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
37 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 37 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
38 } | 38 } |
39 void test_assert() { | 39 void test_assert() { |
40 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " assert (p is A);", " return p;", "}"])); | 40 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " assert (p is A);", " return p;", "}"])); |
41 LibraryElement library = resolve(source); | 41 LibraryElement library = resolve(source); |
42 assertNoErrors(); | 42 assertNoErrors(); |
43 verify([source]); | 43 verify([source]); |
44 CompilationUnit unit = resolveCompilationUnit(source, library); | 44 CompilationUnit unit = resolveCompilationUnit(source, library); |
45 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 45 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
46 InterfaceType typeA = classA.element.type; | 46 InterfaceType typeA = classA.element.type; |
47 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 47 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
48 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 48 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
49 ReturnStatement statement = body2.block.statements[1] as ReturnStatement; | 49 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
50 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 50 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
51 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 51 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
52 } | 52 } |
53 void test_assignment() { | 53 void test_assignment() { |
54 Source source = addSource(EngineTestCase.createSource(["f() {", " var v;",
" v = 0;", " return v;", "}"])); | 54 Source source = addSource(EngineTestCase.createSource(["f() {", " var v;",
" v = 0;", " return v;", "}"])); |
55 LibraryElement library = resolve(source); | 55 LibraryElement library = resolve(source); |
56 assertNoErrors(); | 56 assertNoErrors(); |
57 verify([source]); | 57 verify([source]); |
58 CompilationUnit unit = resolveCompilationUnit(source, library); | 58 CompilationUnit unit = resolveCompilationUnit(source, library); |
59 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 59 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
60 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 60 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
61 ReturnStatement statement = body2.block.statements[2] as ReturnStatement; | 61 ReturnStatement statement = body.block.statements[2] as ReturnStatement; |
62 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 62 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
63 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType); | 63 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType); |
64 } | 64 } |
65 void test_assignment_afterInitializer() { | 65 void test_assignment_afterInitializer() { |
66 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0
;", " v = 1.0;", " return v;", "}"])); | 66 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0
;", " v = 1.0;", " return v;", "}"])); |
67 LibraryElement library = resolve(source); | 67 LibraryElement library = resolve(source); |
68 assertNoErrors(); | 68 assertNoErrors(); |
69 verify([source]); | 69 verify([source]); |
70 CompilationUnit unit = resolveCompilationUnit(source, library); | 70 CompilationUnit unit = resolveCompilationUnit(source, library); |
71 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 71 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
72 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 72 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
73 ReturnStatement statement = body2.block.statements[2] as ReturnStatement; | 73 ReturnStatement statement = body.block.statements[2] as ReturnStatement; |
74 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 74 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
75 JUnitTestCase.assertSame(typeProvider.doubleType, variableName.propagatedTyp
e); | 75 JUnitTestCase.assertSame(typeProvider.doubleType, variableName.propagatedTyp
e); |
76 } | 76 } |
77 void test_forEach() { | 77 void test_forEach() { |
78 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(Li
st<A> p) {", " for (var e in p) {", " return e;", " }", "}"])); | 78 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(Li
st<A> p) {", " for (var e in p) {", " return e;", " }", "}"])); |
79 LibraryElement library = resolve(source); | 79 LibraryElement library = resolve(source); |
80 assertNoErrors(); | 80 assertNoErrors(); |
81 verify([source]); | 81 verify([source]); |
82 CompilationUnit unit = resolveCompilationUnit(source, library); | 82 CompilationUnit unit = resolveCompilationUnit(source, library); |
83 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 83 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
84 InterfaceType typeA = classA.element.type; | 84 InterfaceType typeA = classA.element.type; |
85 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 85 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
86 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 86 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
87 ForEachStatement forStatement = body2.block.statements[0] as ForEachStatemen
t; | 87 ForEachStatement forStatement = body.block.statements[0] as ForEachStatement
; |
88 ReturnStatement statement = ((forStatement.body as Block)).statements[0] as
ReturnStatement; | 88 ReturnStatement statement = ((forStatement.body as Block)).statements[0] as
ReturnStatement; |
89 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 89 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
90 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 90 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
91 } | 91 } |
92 void test_initializer() { | 92 void test_initializer() { |
93 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0
;", " return v;", "}"])); | 93 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0
;", " return v;", "}"])); |
94 LibraryElement library = resolve(source); | 94 LibraryElement library = resolve(source); |
95 assertNoErrors(); | 95 assertNoErrors(); |
96 verify([source]); | 96 verify([source]); |
97 CompilationUnit unit = resolveCompilationUnit(source, library); | 97 CompilationUnit unit = resolveCompilationUnit(source, library); |
98 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 98 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
99 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 99 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
100 ReturnStatement statement = body2.block.statements[1] as ReturnStatement; | 100 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
101 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 101 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
102 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType); | 102 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType); |
103 } | 103 } |
104 void test_initializer_dereference() { | 104 void test_initializer_dereference() { |
105 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = '
String';", " v.", "}"])); | 105 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = '
String';", " v.", "}"])); |
106 LibraryElement library = resolve(source); | 106 LibraryElement library = resolve(source); |
107 CompilationUnit unit = resolveCompilationUnit(source, library); | 107 CompilationUnit unit = resolveCompilationUnit(source, library); |
108 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 108 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
109 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 109 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
110 ExpressionStatement statement = body2.block.statements[1] as ExpressionState
ment; | 110 ExpressionStatement statement = body.block.statements[1] as ExpressionStatem
ent; |
111 PrefixedIdentifier invocation = statement.expression as PrefixedIdentifier; | 111 PrefixedIdentifier invocation = statement.expression as PrefixedIdentifier; |
112 SimpleIdentifier variableName = invocation.prefix; | 112 SimpleIdentifier variableName = invocation.prefix; |
113 JUnitTestCase.assertSame(typeProvider.stringType, variableName.propagatedTyp
e); | 113 JUnitTestCase.assertSame(typeProvider.stringType, variableName.propagatedTyp
e); |
114 } | 114 } |
115 void test_is_conditional() { | 115 void test_is_conditional() { |
116 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " return (p is A) ? p : null;", "}"])); | 116 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " return (p is A) ? p : null;", "}"])); |
117 LibraryElement library = resolve(source); | 117 LibraryElement library = resolve(source); |
118 assertNoErrors(); | 118 assertNoErrors(); |
119 verify([source]); | 119 verify([source]); |
120 CompilationUnit unit = resolveCompilationUnit(source, library); | 120 CompilationUnit unit = resolveCompilationUnit(source, library); |
121 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 121 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
122 InterfaceType typeA = classA.element.type; | 122 InterfaceType typeA = classA.element.type; |
123 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 123 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
124 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 124 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
125 ReturnStatement statement = body2.block.statements[0] as ReturnStatement; | 125 ReturnStatement statement = body.block.statements[0] as ReturnStatement; |
126 ConditionalExpression conditional = statement.expression as ConditionalExpre
ssion; | 126 ConditionalExpression conditional = statement.expression as ConditionalExpre
ssion; |
127 SimpleIdentifier variableName = conditional.thenExpression as SimpleIdentifi
er; | 127 SimpleIdentifier variableName = conditional.thenExpression as SimpleIdentifi
er; |
128 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 128 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
129 } | 129 } |
130 void test_is_if() { | 130 void test_is_if() { |
131 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " if (p is A) {", " return p;", " } else {", " return null;", "
}", "}"])); | 131 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " if (p is A) {", " return p;", " } else {", " return null;", "
}", "}"])); |
132 LibraryElement library = resolve(source); | 132 LibraryElement library = resolve(source); |
133 assertNoErrors(); | 133 assertNoErrors(); |
134 verify([source]); | 134 verify([source]); |
135 CompilationUnit unit = resolveCompilationUnit(source, library); | 135 CompilationUnit unit = resolveCompilationUnit(source, library); |
136 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 136 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
137 InterfaceType typeA = classA.element.type; | 137 InterfaceType typeA = classA.element.type; |
138 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 138 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
139 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 139 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
140 IfStatement ifStatement = body2.block.statements[0] as IfStatement; | 140 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
141 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; | 141 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; |
142 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 142 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
143 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 143 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
144 } | 144 } |
145 void test_is_if_lessSpecific() { | 145 void test_is_if_lessSpecific() { |
146 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(A
p) {", " if (p is Object) {", " return p;", " } else {", " return null;"
, " }", "}"])); | 146 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(A
p) {", " if (p is Object) {", " return p;", " } else {", " return null;"
, " }", "}"])); |
147 LibraryElement library = resolve(source); | 147 LibraryElement library = resolve(source); |
148 assertNoErrors(); | 148 assertNoErrors(); |
149 verify([source]); | 149 verify([source]); |
150 CompilationUnit unit = resolveCompilationUnit(source, library); | 150 CompilationUnit unit = resolveCompilationUnit(source, library); |
151 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 151 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
152 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 152 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
153 IfStatement ifStatement = body2.block.statements[0] as IfStatement; | 153 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
154 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; | 154 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; |
155 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 155 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
156 JUnitTestCase.assertSame(null, variableName.propagatedType); | 156 JUnitTestCase.assertSame(null, variableName.propagatedType); |
157 } | 157 } |
158 void test_is_if_logicalAnd() { | 158 void test_is_if_logicalAnd() { |
159 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " if (p is A && p != null) {", " return p;", " } else {", " ret
urn null;", " }", "}"])); | 159 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " if (p is A && p != null) {", " return p;", " } else {", " ret
urn null;", " }", "}"])); |
160 LibraryElement library = resolve(source); | 160 LibraryElement library = resolve(source); |
161 assertNoErrors(); | 161 assertNoErrors(); |
162 verify([source]); | 162 verify([source]); |
163 CompilationUnit unit = resolveCompilationUnit(source, library); | 163 CompilationUnit unit = resolveCompilationUnit(source, library); |
164 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 164 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
165 InterfaceType typeA = classA.element.type; | 165 InterfaceType typeA = classA.element.type; |
166 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 166 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
167 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 167 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
168 IfStatement ifStatement = body2.block.statements[0] as IfStatement; | 168 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
169 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; | 169 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; |
170 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 170 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
171 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 171 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
172 } | 172 } |
173 void test_is_postConditional() { | 173 void test_is_postConditional() { |
174 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " A a = (p is A) ? p : throw null;", " return p;", "}"])); | 174 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " A a = (p is A) ? p : throw null;", " return p;", "}"])); |
175 LibraryElement library = resolve(source); | 175 LibraryElement library = resolve(source); |
176 assertNoErrors(); | 176 assertNoErrors(); |
177 verify([source]); | 177 verify([source]); |
178 CompilationUnit unit = resolveCompilationUnit(source, library); | 178 CompilationUnit unit = resolveCompilationUnit(source, library); |
179 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 179 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
180 InterfaceType typeA = classA.element.type; | 180 InterfaceType typeA = classA.element.type; |
181 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 181 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
182 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 182 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
183 ReturnStatement statement = body2.block.statements[1] as ReturnStatement; | 183 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
184 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 184 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
185 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 185 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
186 } | 186 } |
187 void test_is_postIf() { | 187 void test_is_postIf() { |
188 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " if (p is A) {", " A a = p;", " } else {", " return null;", "
}", " return p;", "}"])); | 188 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " if (p is A) {", " A a = p;", " } else {", " return null;", "
}", " return p;", "}"])); |
189 LibraryElement library = resolve(source); | 189 LibraryElement library = resolve(source); |
190 assertNoErrors(); | 190 assertNoErrors(); |
191 verify([source]); | 191 verify([source]); |
192 CompilationUnit unit = resolveCompilationUnit(source, library); | 192 CompilationUnit unit = resolveCompilationUnit(source, library); |
193 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 193 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
194 InterfaceType typeA = classA.element.type; | 194 InterfaceType typeA = classA.element.type; |
195 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 195 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
196 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 196 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
197 ReturnStatement statement = body2.block.statements[1] as ReturnStatement; | 197 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
198 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 198 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
199 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 199 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
200 } | 200 } |
201 void test_is_subclass() { | 201 void test_is_subclass() { |
202 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B extends A {", " B m() => this;", "}", "A f(A p) {", " if (p is B) {", " r
eturn p.m();", " }", "}"])); | 202 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B extends A {", " B m() => this;", "}", "A f(A p) {", " if (p is B) {", " r
eturn p.m();", " }", "}"])); |
203 LibraryElement library = resolve(source); | 203 LibraryElement library = resolve(source); |
204 assertNoErrors(); | 204 assertNoErrors(); |
205 verify([source]); | 205 verify([source]); |
206 CompilationUnit unit = resolveCompilationUnit(source, library); | 206 CompilationUnit unit = resolveCompilationUnit(source, library); |
207 FunctionDeclaration function = unit.declarations[2] as FunctionDeclaration; | 207 FunctionDeclaration function = unit.declarations[2] as FunctionDeclaration; |
208 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 208 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
209 IfStatement ifStatement = body2.block.statements[0] as IfStatement; | 209 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
210 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; | 210 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; |
211 MethodInvocation invocation = statement.expression as MethodInvocation; | 211 MethodInvocation invocation = statement.expression as MethodInvocation; |
212 JUnitTestCase.assertNotNull(invocation.methodName.element); | 212 JUnitTestCase.assertNotNull(invocation.methodName.element); |
213 } | 213 } |
214 void test_is_while() { | 214 void test_is_while() { |
215 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " while (p is A) {", " return p;", " }", "}"])); | 215 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " while (p is A) {", " return p;", " }", "}"])); |
216 LibraryElement library = resolve(source); | 216 LibraryElement library = resolve(source); |
217 assertNoErrors(); | 217 assertNoErrors(); |
218 verify([source]); | 218 verify([source]); |
219 CompilationUnit unit = resolveCompilationUnit(source, library); | 219 CompilationUnit unit = resolveCompilationUnit(source, library); |
220 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 220 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
221 InterfaceType typeA = classA.element.type; | 221 InterfaceType typeA = classA.element.type; |
222 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 222 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
223 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 223 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
224 WhileStatement whileStatement = body2.block.statements[0] as WhileStatement; | 224 WhileStatement whileStatement = body.block.statements[0] as WhileStatement; |
225 ReturnStatement statement = ((whileStatement.body as Block)).statements[0] a
s ReturnStatement; | 225 ReturnStatement statement = ((whileStatement.body as Block)).statements[0] a
s ReturnStatement; |
226 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 226 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
227 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 227 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
228 } | 228 } |
229 void test_isNot_conditional() { | 229 void test_isNot_conditional() { |
230 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " return (p is! A) ? null : p;", "}"])); | 230 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " return (p is! A) ? null : p;", "}"])); |
231 LibraryElement library = resolve(source); | 231 LibraryElement library = resolve(source); |
232 assertNoErrors(); | 232 assertNoErrors(); |
233 verify([source]); | 233 verify([source]); |
234 CompilationUnit unit = resolveCompilationUnit(source, library); | 234 CompilationUnit unit = resolveCompilationUnit(source, library); |
235 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 235 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
236 InterfaceType typeA = classA.element.type; | 236 InterfaceType typeA = classA.element.type; |
237 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 237 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
238 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 238 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
239 ReturnStatement statement = body2.block.statements[0] as ReturnStatement; | 239 ReturnStatement statement = body.block.statements[0] as ReturnStatement; |
240 ConditionalExpression conditional = statement.expression as ConditionalExpre
ssion; | 240 ConditionalExpression conditional = statement.expression as ConditionalExpre
ssion; |
241 SimpleIdentifier variableName = conditional.elseExpression as SimpleIdentifi
er; | 241 SimpleIdentifier variableName = conditional.elseExpression as SimpleIdentifi
er; |
242 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 242 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
243 } | 243 } |
244 void test_isNot_if() { | 244 void test_isNot_if() { |
245 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " if (p is! A) {", " return null;", " } else {", " return p;",
" }", "}"])); | 245 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " if (p is! A) {", " return null;", " } else {", " return p;",
" }", "}"])); |
246 LibraryElement library = resolve(source); | 246 LibraryElement library = resolve(source); |
247 assertNoErrors(); | 247 assertNoErrors(); |
248 verify([source]); | 248 verify([source]); |
249 CompilationUnit unit = resolveCompilationUnit(source, library); | 249 CompilationUnit unit = resolveCompilationUnit(source, library); |
250 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 250 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
251 InterfaceType typeA = classA.element.type; | 251 InterfaceType typeA = classA.element.type; |
252 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 252 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
253 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 253 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
254 IfStatement ifStatement = body2.block.statements[0] as IfStatement; | 254 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
255 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement
s[0] as ReturnStatement; | 255 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement
s[0] as ReturnStatement; |
256 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 256 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
257 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 257 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
258 } | 258 } |
259 void test_isNot_if_logicalOr() { | 259 void test_isNot_if_logicalOr() { |
260 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " if (p is! A || null == p) {", " return null;", " } else {", "
return p;", " }", "}"])); | 260 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " if (p is! A || null == p) {", " return null;", " } else {", "
return p;", " }", "}"])); |
261 LibraryElement library = resolve(source); | 261 LibraryElement library = resolve(source); |
262 assertNoErrors(); | 262 assertNoErrors(); |
263 verify([source]); | 263 verify([source]); |
264 CompilationUnit unit = resolveCompilationUnit(source, library); | 264 CompilationUnit unit = resolveCompilationUnit(source, library); |
265 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 265 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
266 InterfaceType typeA = classA.element.type; | 266 InterfaceType typeA = classA.element.type; |
267 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 267 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
268 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 268 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
269 IfStatement ifStatement = body2.block.statements[0] as IfStatement; | 269 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
270 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement
s[0] as ReturnStatement; | 270 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement
s[0] as ReturnStatement; |
271 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 271 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
272 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 272 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
273 } | 273 } |
274 void test_isNot_postConditional() { | 274 void test_isNot_postConditional() { |
275 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " A a = (p is! A) ? throw null : p;", " return p;", "}"])); | 275 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " A a = (p is! A) ? throw null : p;", " return p;", "}"])); |
276 LibraryElement library = resolve(source); | 276 LibraryElement library = resolve(source); |
277 assertNoErrors(); | 277 assertNoErrors(); |
278 verify([source]); | 278 verify([source]); |
279 CompilationUnit unit = resolveCompilationUnit(source, library); | 279 CompilationUnit unit = resolveCompilationUnit(source, library); |
280 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 280 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
281 InterfaceType typeA = classA.element.type; | 281 InterfaceType typeA = classA.element.type; |
282 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 282 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
283 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 283 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
284 ReturnStatement statement = body2.block.statements[1] as ReturnStatement; | 284 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
285 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 285 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
286 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 286 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
287 } | 287 } |
288 void test_isNot_postIf() { | 288 void test_isNot_postIf() { |
289 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " if (p is! A) {", " return null;", " }", " return p;", "}"])); | 289 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va
r p) {", " if (p is! A) {", " return null;", " }", " return p;", "}"])); |
290 LibraryElement library = resolve(source); | 290 LibraryElement library = resolve(source); |
291 assertNoErrors(); | 291 assertNoErrors(); |
292 verify([source]); | 292 verify([source]); |
293 CompilationUnit unit = resolveCompilationUnit(source, library); | 293 CompilationUnit unit = resolveCompilationUnit(source, library); |
294 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 294 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
295 InterfaceType typeA = classA.element.type; | 295 InterfaceType typeA = classA.element.type; |
296 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 296 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
297 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 297 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
298 ReturnStatement statement = body2.block.statements[1] as ReturnStatement; | 298 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
299 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 299 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
300 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 300 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
301 } | 301 } |
302 void test_listLiteral_different() { | 302 void test_listLiteral_different() { |
303 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = [
0, '1', 2];", " return v[2];", "}"])); | 303 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = [
0, '1', 2];", " return v[2];", "}"])); |
304 LibraryElement library = resolve(source); | 304 LibraryElement library = resolve(source); |
305 assertNoErrors(); | 305 assertNoErrors(); |
306 verify([source]); | 306 verify([source]); |
307 CompilationUnit unit = resolveCompilationUnit(source, library); | 307 CompilationUnit unit = resolveCompilationUnit(source, library); |
308 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 308 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
309 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 309 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
310 ReturnStatement statement = body2.block.statements[1] as ReturnStatement; | 310 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
311 IndexExpression indexExpression = statement.expression as IndexExpression; | 311 IndexExpression indexExpression = statement.expression as IndexExpression; |
312 JUnitTestCase.assertNull(indexExpression.propagatedType); | 312 JUnitTestCase.assertNull(indexExpression.propagatedType); |
313 } | 313 } |
314 void test_listLiteral_same() { | 314 void test_listLiteral_same() { |
315 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = [
0, 1, 2];", " return v[2];", "}"])); | 315 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = [
0, 1, 2];", " return v[2];", "}"])); |
316 LibraryElement library = resolve(source); | 316 LibraryElement library = resolve(source); |
317 assertNoErrors(); | 317 assertNoErrors(); |
318 verify([source]); | 318 verify([source]); |
319 CompilationUnit unit = resolveCompilationUnit(source, library); | 319 CompilationUnit unit = resolveCompilationUnit(source, library); |
320 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 320 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
321 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 321 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
322 ReturnStatement statement = body2.block.statements[1] as ReturnStatement; | 322 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
323 IndexExpression indexExpression = statement.expression as IndexExpression; | 323 IndexExpression indexExpression = statement.expression as IndexExpression; |
324 JUnitTestCase.assertSame(typeProvider.intType, indexExpression.propagatedTyp
e); | 324 JUnitTestCase.assertSame(typeProvider.intType, indexExpression.propagatedTyp
e); |
325 } | 325 } |
326 void test_mapLiteral_different() { | 326 void test_mapLiteral_different() { |
327 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = {
'0' : 0, 1 : '1', '2' : 2};", " return v;", "}"])); | 327 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = {
'0' : 0, 1 : '1', '2' : 2};", " return v;", "}"])); |
328 LibraryElement library = resolve(source); | 328 LibraryElement library = resolve(source); |
329 assertNoErrors(); | 329 assertNoErrors(); |
330 verify([source]); | 330 verify([source]); |
331 CompilationUnit unit = resolveCompilationUnit(source, library); | 331 CompilationUnit unit = resolveCompilationUnit(source, library); |
332 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 332 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
333 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 333 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
334 ReturnStatement statement = body2.block.statements[1] as ReturnStatement; | 334 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
335 SimpleIdentifier identifier = statement.expression as SimpleIdentifier; | 335 SimpleIdentifier identifier = statement.expression as SimpleIdentifier; |
336 InterfaceType propagatedType2 = identifier.propagatedType as InterfaceType; | 336 InterfaceType propagatedType = identifier.propagatedType as InterfaceType; |
337 JUnitTestCase.assertSame(typeProvider.mapType.element, propagatedType2.eleme
nt); | 337 JUnitTestCase.assertSame(typeProvider.mapType.element, propagatedType.elemen
t); |
338 List<Type2> typeArguments2 = propagatedType2.typeArguments; | 338 List<Type2> typeArguments = propagatedType.typeArguments; |
339 EngineTestCase.assertLength(2, typeArguments2); | 339 EngineTestCase.assertLength(2, typeArguments); |
340 JUnitTestCase.assertSame(typeProvider.dynamicType, typeArguments2[0]); | 340 JUnitTestCase.assertSame(typeProvider.dynamicType, typeArguments[0]); |
341 JUnitTestCase.assertSame(typeProvider.dynamicType, typeArguments2[1]); | 341 JUnitTestCase.assertSame(typeProvider.dynamicType, typeArguments[1]); |
342 } | 342 } |
343 void test_mapLiteral_same() { | 343 void test_mapLiteral_same() { |
344 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = {
'a' : 0, 'b' : 1, 'c' : 2};", " return v;", "}"])); | 344 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = {
'a' : 0, 'b' : 1, 'c' : 2};", " return v;", "}"])); |
345 LibraryElement library = resolve(source); | 345 LibraryElement library = resolve(source); |
346 assertNoErrors(); | 346 assertNoErrors(); |
347 verify([source]); | 347 verify([source]); |
348 CompilationUnit unit = resolveCompilationUnit(source, library); | 348 CompilationUnit unit = resolveCompilationUnit(source, library); |
349 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 349 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
350 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB
ody; | 350 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
351 ReturnStatement statement = body2.block.statements[1] as ReturnStatement; | 351 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
352 SimpleIdentifier identifier = statement.expression as SimpleIdentifier; | 352 SimpleIdentifier identifier = statement.expression as SimpleIdentifier; |
353 InterfaceType propagatedType2 = identifier.propagatedType as InterfaceType; | 353 InterfaceType propagatedType = identifier.propagatedType as InterfaceType; |
354 JUnitTestCase.assertSame(typeProvider.mapType.element, propagatedType2.eleme
nt); | 354 JUnitTestCase.assertSame(typeProvider.mapType.element, propagatedType.elemen
t); |
355 List<Type2> typeArguments2 = propagatedType2.typeArguments; | 355 List<Type2> typeArguments = propagatedType.typeArguments; |
356 EngineTestCase.assertLength(2, typeArguments2); | 356 EngineTestCase.assertLength(2, typeArguments); |
357 JUnitTestCase.assertSame(typeProvider.stringType, typeArguments2[0]); | 357 JUnitTestCase.assertSame(typeProvider.stringType, typeArguments[0]); |
358 JUnitTestCase.assertSame(typeProvider.intType, typeArguments2[1]); | 358 JUnitTestCase.assertSame(typeProvider.intType, typeArguments[1]); |
359 } | 359 } |
360 void test_query() { | 360 void test_query() { |
361 Source source = addSource(EngineTestCase.createSource(["import 'dart:html';"
, "", "main() {", " var v1 = query('a');", " var v2 = query('A');", " var v3
= query('body:active');", " var v4 = query('button[foo=\"bar\"]');", " var v5
= query('div.class');", " var v6 = query('input#id');", " var v7 = query('sele
ct#id');", " // invocation of method", " var m1 = document.query('div');", " /
/ unsupported currently", " var b1 = query('noSuchTag');", " var b2 = query('D
ART_EDITOR_NO_SUCH_TYPE');", " var b3 = query('body div');", " return [v1, v2,
v3, v4, v5, v6, v7, m1, b1, b2, b3];", "}"])); | 361 Source source = addSource(EngineTestCase.createSource(["import 'dart:html';"
, "", "main() {", " var v1 = query('a');", " var v2 = query('A');", " var v3
= query('body:active');", " var v4 = query('button[foo=\"bar\"]');", " var v5
= query('div.class');", " var v6 = query('input#id');", " var v7 = query('sele
ct#id');", " // invocation of method", " var m1 = document.query('div');", " /
/ unsupported currently", " var b1 = query('noSuchTag');", " var b2 = query('D
ART_EDITOR_NO_SUCH_TYPE');", " var b3 = query('body div');", " return [v1, v2,
v3, v4, v5, v6, v7, m1, b1, b2, b3];", "}"])); |
362 LibraryElement library = resolve(source); | 362 LibraryElement library = resolve(source); |
363 assertNoErrors(); | 363 assertNoErrors(); |
364 verify([source]); | 364 verify([source]); |
365 CompilationUnit unit = resolveCompilationUnit(source, library); | 365 CompilationUnit unit = resolveCompilationUnit(source, library); |
366 FunctionDeclaration main = unit.declarations[0] as FunctionDeclaration; | 366 FunctionDeclaration main = unit.declarations[0] as FunctionDeclaration; |
367 BlockFunctionBody body2 = main.functionExpression.body as BlockFunctionBody; | 367 BlockFunctionBody body = main.functionExpression.body as BlockFunctionBody; |
368 ReturnStatement statement = body2.block.statements[11] as ReturnStatement; | 368 ReturnStatement statement = body.block.statements[11] as ReturnStatement; |
369 NodeList<Expression> elements2 = ((statement.expression as ListLiteral)).ele
ments; | 369 NodeList<Expression> elements = ((statement.expression as ListLiteral)).elem
ents; |
370 JUnitTestCase.assertEquals("AnchorElement", elements2[0].propagatedType.name
); | 370 JUnitTestCase.assertEquals("AnchorElement", elements[0].propagatedType.name)
; |
371 JUnitTestCase.assertEquals("AnchorElement", elements2[1].propagatedType.name
); | 371 JUnitTestCase.assertEquals("AnchorElement", elements[1].propagatedType.name)
; |
372 JUnitTestCase.assertEquals("BodyElement", elements2[2].propagatedType.name); | 372 JUnitTestCase.assertEquals("BodyElement", elements[2].propagatedType.name); |
373 JUnitTestCase.assertEquals("ButtonElement", elements2[3].propagatedType.name
); | 373 JUnitTestCase.assertEquals("ButtonElement", elements[3].propagatedType.name)
; |
374 JUnitTestCase.assertEquals("DivElement", elements2[4].propagatedType.name); | 374 JUnitTestCase.assertEquals("DivElement", elements[4].propagatedType.name); |
375 JUnitTestCase.assertEquals("InputElement", elements2[5].propagatedType.name)
; | 375 JUnitTestCase.assertEquals("InputElement", elements[5].propagatedType.name); |
376 JUnitTestCase.assertEquals("SelectElement", elements2[6].propagatedType.name
); | 376 JUnitTestCase.assertEquals("SelectElement", elements[6].propagatedType.name)
; |
377 JUnitTestCase.assertEquals("DivElement", elements2[7].propagatedType.name); | 377 JUnitTestCase.assertEquals("DivElement", elements[7].propagatedType.name); |
378 JUnitTestCase.assertEquals("Element", elements2[8].propagatedType.name); | 378 JUnitTestCase.assertEquals("Element", elements[8].propagatedType.name); |
379 JUnitTestCase.assertEquals("Element", elements2[9].propagatedType.name); | 379 JUnitTestCase.assertEquals("Element", elements[9].propagatedType.name); |
380 JUnitTestCase.assertEquals("Element", elements2[10].propagatedType.name); | 380 JUnitTestCase.assertEquals("Element", elements[10].propagatedType.name); |
381 } | 381 } |
382 static dartSuite() { | 382 static dartSuite() { |
383 _ut.group('TypePropagationTest', () { | 383 _ut.group('TypePropagationTest', () { |
384 _ut.test('test_as', () { | 384 _ut.test('test_as', () { |
385 final __test = new TypePropagationTest(); | 385 final __test = new TypePropagationTest(); |
386 runJUnitTest(__test, __test.test_as); | 386 runJUnitTest(__test, __test.test_as); |
387 }); | 387 }); |
388 _ut.test('test_assert', () { | 388 _ut.test('test_assert', () { |
389 final __test = new TypePropagationTest(); | 389 final __test = new TypePropagationTest(); |
390 runJUnitTest(__test, __test.test_assert); | 390 runJUnitTest(__test, __test.test_assert); |
(...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2292 void setUp() { | 2292 void setUp() { |
2293 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]); | 2293 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]); |
2294 _analysisContext = new AnalysisContextImpl(); | 2294 _analysisContext = new AnalysisContextImpl(); |
2295 _analysisContext.sourceFactory = _sourceFactory; | 2295 _analysisContext.sourceFactory = _sourceFactory; |
2296 _errorListener = new GatheringErrorListener(); | 2296 _errorListener = new GatheringErrorListener(); |
2297 _library5 = library("/lib.dart"); | 2297 _library5 = library("/lib.dart"); |
2298 } | 2298 } |
2299 void test_addExport() { | 2299 void test_addExport() { |
2300 Library exportLibrary = library("/exported.dart"); | 2300 Library exportLibrary = library("/exported.dart"); |
2301 _library5.addExport(ASTFactory.exportDirective2("exported.dart", []), export
Library); | 2301 _library5.addExport(ASTFactory.exportDirective2("exported.dart", []), export
Library); |
2302 List<Library> exports2 = _library5.exports; | 2302 List<Library> exports = _library5.exports; |
2303 EngineTestCase.assertLength(1, exports2); | 2303 EngineTestCase.assertLength(1, exports); |
2304 JUnitTestCase.assertSame(exportLibrary, exports2[0]); | 2304 JUnitTestCase.assertSame(exportLibrary, exports[0]); |
2305 _errorListener.assertNoErrors(); | 2305 _errorListener.assertNoErrors(); |
2306 } | 2306 } |
2307 void test_addImport() { | 2307 void test_addImport() { |
2308 Library importLibrary = library("/imported.dart"); | 2308 Library importLibrary = library("/imported.dart"); |
2309 _library5.addImport(ASTFactory.importDirective2("imported.dart", null, []),
importLibrary); | 2309 _library5.addImport(ASTFactory.importDirective2("imported.dart", null, []),
importLibrary); |
2310 List<Library> imports2 = _library5.imports; | 2310 List<Library> imports = _library5.imports; |
2311 EngineTestCase.assertLength(1, imports2); | 2311 EngineTestCase.assertLength(1, imports); |
2312 JUnitTestCase.assertSame(importLibrary, imports2[0]); | 2312 JUnitTestCase.assertSame(importLibrary, imports[0]); |
2313 _errorListener.assertNoErrors(); | 2313 _errorListener.assertNoErrors(); |
2314 } | 2314 } |
2315 void test_getExplicitlyImportsCore() { | 2315 void test_getExplicitlyImportsCore() { |
2316 JUnitTestCase.assertFalse(_library5.explicitlyImportsCore); | 2316 JUnitTestCase.assertFalse(_library5.explicitlyImportsCore); |
2317 _errorListener.assertNoErrors(); | 2317 _errorListener.assertNoErrors(); |
2318 } | 2318 } |
2319 void test_getExport() { | 2319 void test_getExport() { |
2320 ExportDirective directive = ASTFactory.exportDirective2("exported.dart", [])
; | 2320 ExportDirective directive = ASTFactory.exportDirective2("exported.dart", [])
; |
2321 Library exportLibrary = library("/exported.dart"); | 2321 Library exportLibrary = library("/exported.dart"); |
2322 _library5.addExport(directive, exportLibrary); | 2322 _library5.addExport(directive, exportLibrary); |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2872 Source librarySource = new FileBasedSource.con1(factory.contentCache, FileUt
ilities2.createFile("/lib.dart")); | 2872 Source librarySource = new FileBasedSource.con1(factory.contentCache, FileUt
ilities2.createFile("/lib.dart")); |
2873 _library = new Library(context, _listener, librarySource); | 2873 _library = new Library(context, _listener, librarySource); |
2874 LibraryElementImpl element = new LibraryElementImpl(context, ASTFactory.libr
aryIdentifier2(["lib"])); | 2874 LibraryElementImpl element = new LibraryElementImpl(context, ASTFactory.libr
aryIdentifier2(["lib"])); |
2875 element.definingCompilationUnit = new CompilationUnitElementImpl("lib.dart")
; | 2875 element.definingCompilationUnit = new CompilationUnitElementImpl("lib.dart")
; |
2876 _library.libraryElement = element; | 2876 _library.libraryElement = element; |
2877 _typeProvider = new TestTypeProvider(); | 2877 _typeProvider = new TestTypeProvider(); |
2878 _visitor = new TypeResolverVisitor.con1(_library, librarySource, _typeProvid
er); | 2878 _visitor = new TypeResolverVisitor.con1(_library, librarySource, _typeProvid
er); |
2879 } | 2879 } |
2880 void test_visitCatchClause_exception() { | 2880 void test_visitCatchClause_exception() { |
2881 CatchClause clause = ASTFactory.catchClause("e", []); | 2881 CatchClause clause = ASTFactory.catchClause("e", []); |
2882 SimpleIdentifier exceptionParameter2 = clause.exceptionParameter; | 2882 SimpleIdentifier exceptionParameter = clause.exceptionParameter; |
2883 exceptionParameter2.element = new LocalVariableElementImpl(exceptionParamete
r2); | 2883 exceptionParameter.element = new LocalVariableElementImpl(exceptionParameter
); |
2884 resolve(clause, _typeProvider.objectType, null, []); | 2884 resolve(clause, _typeProvider.objectType, null, []); |
2885 _listener.assertNoErrors(); | 2885 _listener.assertNoErrors(); |
2886 } | 2886 } |
2887 void test_visitCatchClause_exception_stackTrace() { | 2887 void test_visitCatchClause_exception_stackTrace() { |
2888 CatchClause clause = ASTFactory.catchClause2("e", "s", []); | 2888 CatchClause clause = ASTFactory.catchClause2("e", "s", []); |
2889 SimpleIdentifier exceptionParameter2 = clause.exceptionParameter; | 2889 SimpleIdentifier exceptionParameter = clause.exceptionParameter; |
2890 exceptionParameter2.element = new LocalVariableElementImpl(exceptionParamete
r2); | 2890 exceptionParameter.element = new LocalVariableElementImpl(exceptionParameter
); |
2891 SimpleIdentifier stackTraceParameter2 = clause.stackTraceParameter; | 2891 SimpleIdentifier stackTraceParameter = clause.stackTraceParameter; |
2892 stackTraceParameter2.element = new LocalVariableElementImpl(stackTraceParame
ter2); | 2892 stackTraceParameter.element = new LocalVariableElementImpl(stackTraceParamet
er); |
2893 resolve(clause, _typeProvider.objectType, _typeProvider.stackTraceType, []); | 2893 resolve(clause, _typeProvider.objectType, _typeProvider.stackTraceType, []); |
2894 _listener.assertNoErrors(); | 2894 _listener.assertNoErrors(); |
2895 } | 2895 } |
2896 void test_visitCatchClause_on_exception() { | 2896 void test_visitCatchClause_on_exception() { |
2897 ClassElement exceptionElement = ElementFactory.classElement2("E", []); | 2897 ClassElement exceptionElement = ElementFactory.classElement2("E", []); |
2898 TypeName exceptionType = ASTFactory.typeName(exceptionElement, []); | 2898 TypeName exceptionType = ASTFactory.typeName(exceptionElement, []); |
2899 CatchClause clause = ASTFactory.catchClause4(exceptionType, "e", []); | 2899 CatchClause clause = ASTFactory.catchClause4(exceptionType, "e", []); |
2900 SimpleIdentifier exceptionParameter2 = clause.exceptionParameter; | 2900 SimpleIdentifier exceptionParameter = clause.exceptionParameter; |
2901 exceptionParameter2.element = new LocalVariableElementImpl(exceptionParamete
r2); | 2901 exceptionParameter.element = new LocalVariableElementImpl(exceptionParameter
); |
2902 resolve(clause, exceptionElement.type, null, [exceptionElement]); | 2902 resolve(clause, exceptionElement.type, null, [exceptionElement]); |
2903 _listener.assertNoErrors(); | 2903 _listener.assertNoErrors(); |
2904 } | 2904 } |
2905 void test_visitCatchClause_on_exception_stackTrace() { | 2905 void test_visitCatchClause_on_exception_stackTrace() { |
2906 ClassElement exceptionElement = ElementFactory.classElement2("E", []); | 2906 ClassElement exceptionElement = ElementFactory.classElement2("E", []); |
2907 TypeName exceptionType = ASTFactory.typeName(exceptionElement, []); | 2907 TypeName exceptionType = ASTFactory.typeName(exceptionElement, []); |
2908 ((exceptionType.name as SimpleIdentifier)).element = exceptionElement; | 2908 ((exceptionType.name as SimpleIdentifier)).element = exceptionElement; |
2909 CatchClause clause = ASTFactory.catchClause5(exceptionType, "e", "s", []); | 2909 CatchClause clause = ASTFactory.catchClause5(exceptionType, "e", "s", []); |
2910 SimpleIdentifier exceptionParameter2 = clause.exceptionParameter; | 2910 SimpleIdentifier exceptionParameter = clause.exceptionParameter; |
2911 exceptionParameter2.element = new LocalVariableElementImpl(exceptionParamete
r2); | 2911 exceptionParameter.element = new LocalVariableElementImpl(exceptionParameter
); |
2912 SimpleIdentifier stackTraceParameter2 = clause.stackTraceParameter; | 2912 SimpleIdentifier stackTraceParameter = clause.stackTraceParameter; |
2913 stackTraceParameter2.element = new LocalVariableElementImpl(stackTraceParame
ter2); | 2913 stackTraceParameter.element = new LocalVariableElementImpl(stackTraceParamet
er); |
2914 resolve(clause, exceptionElement.type, _typeProvider.stackTraceType, [except
ionElement]); | 2914 resolve(clause, exceptionElement.type, _typeProvider.stackTraceType, [except
ionElement]); |
2915 _listener.assertNoErrors(); | 2915 _listener.assertNoErrors(); |
2916 } | 2916 } |
2917 void test_visitClassDeclaration() { | 2917 void test_visitClassDeclaration() { |
2918 ClassElement elementA = ElementFactory.classElement2("A", []); | 2918 ClassElement elementA = ElementFactory.classElement2("A", []); |
2919 ClassElement elementB = ElementFactory.classElement2("B", []); | 2919 ClassElement elementB = ElementFactory.classElement2("B", []); |
2920 ClassElement elementC = ElementFactory.classElement2("C", []); | 2920 ClassElement elementC = ElementFactory.classElement2("C", []); |
2921 ClassElement elementD = ElementFactory.classElement2("D", []); | 2921 ClassElement elementD = ElementFactory.classElement2("D", []); |
2922 ExtendsClause extendsClause2 = ASTFactory.extendsClause(ASTFactory.typeName(
elementB, [])); | 2922 ExtendsClause extendsClause = ASTFactory.extendsClause(ASTFactory.typeName(e
lementB, [])); |
2923 WithClause withClause2 = ASTFactory.withClause([ASTFactory.typeName(elementC
, [])]); | 2923 WithClause withClause = ASTFactory.withClause([ASTFactory.typeName(elementC,
[])]); |
2924 ImplementsClause implementsClause2 = ASTFactory.implementsClause([ASTFactory
.typeName(elementD, [])]); | 2924 ImplementsClause implementsClause = ASTFactory.implementsClause([ASTFactory.
typeName(elementD, [])]); |
2925 ClassDeclaration declaration = ASTFactory.classDeclaration(null, "A", null,
extendsClause2, withClause2, implementsClause2, []); | 2925 ClassDeclaration declaration = ASTFactory.classDeclaration(null, "A", null,
extendsClause, withClause, implementsClause, []); |
2926 declaration.name.element = elementA; | 2926 declaration.name.element = elementA; |
2927 resolveNode(declaration, [elementA, elementB, elementC, elementD]); | 2927 resolveNode(declaration, [elementA, elementB, elementC, elementD]); |
2928 JUnitTestCase.assertSame(elementB.type, elementA.supertype); | 2928 JUnitTestCase.assertSame(elementB.type, elementA.supertype); |
2929 List<InterfaceType> mixins2 = elementA.mixins; | 2929 List<InterfaceType> mixins = elementA.mixins; |
2930 EngineTestCase.assertLength(1, mixins2); | 2930 EngineTestCase.assertLength(1, mixins); |
2931 JUnitTestCase.assertSame(elementC.type, mixins2[0]); | 2931 JUnitTestCase.assertSame(elementC.type, mixins[0]); |
2932 List<InterfaceType> interfaces2 = elementA.interfaces; | 2932 List<InterfaceType> interfaces = elementA.interfaces; |
2933 EngineTestCase.assertLength(1, interfaces2); | 2933 EngineTestCase.assertLength(1, interfaces); |
2934 JUnitTestCase.assertSame(elementD.type, interfaces2[0]); | 2934 JUnitTestCase.assertSame(elementD.type, interfaces[0]); |
2935 _listener.assertNoErrors(); | 2935 _listener.assertNoErrors(); |
2936 } | 2936 } |
2937 void test_visitClassTypeAlias() { | 2937 void test_visitClassTypeAlias() { |
2938 ClassElement elementA = ElementFactory.classElement2("A", []); | 2938 ClassElement elementA = ElementFactory.classElement2("A", []); |
2939 ClassElement elementB = ElementFactory.classElement2("B", []); | 2939 ClassElement elementB = ElementFactory.classElement2("B", []); |
2940 ClassElement elementC = ElementFactory.classElement2("C", []); | 2940 ClassElement elementC = ElementFactory.classElement2("C", []); |
2941 ClassElement elementD = ElementFactory.classElement2("D", []); | 2941 ClassElement elementD = ElementFactory.classElement2("D", []); |
2942 WithClause withClause2 = ASTFactory.withClause([ASTFactory.typeName(elementC
, [])]); | 2942 WithClause withClause = ASTFactory.withClause([ASTFactory.typeName(elementC,
[])]); |
2943 ImplementsClause implementsClause2 = ASTFactory.implementsClause([ASTFactory
.typeName(elementD, [])]); | 2943 ImplementsClause implementsClause = ASTFactory.implementsClause([ASTFactory.
typeName(elementD, [])]); |
2944 ClassTypeAlias alias = ASTFactory.classTypeAlias("A", null, null, ASTFactory
.typeName(elementB, []), withClause2, implementsClause2); | 2944 ClassTypeAlias alias = ASTFactory.classTypeAlias("A", null, null, ASTFactory
.typeName(elementB, []), withClause, implementsClause); |
2945 alias.name.element = elementA; | 2945 alias.name.element = elementA; |
2946 resolveNode(alias, [elementA, elementB, elementC, elementD]); | 2946 resolveNode(alias, [elementA, elementB, elementC, elementD]); |
2947 JUnitTestCase.assertSame(elementB.type, elementA.supertype); | 2947 JUnitTestCase.assertSame(elementB.type, elementA.supertype); |
2948 List<InterfaceType> mixins2 = elementA.mixins; | 2948 List<InterfaceType> mixins = elementA.mixins; |
2949 EngineTestCase.assertLength(1, mixins2); | 2949 EngineTestCase.assertLength(1, mixins); |
2950 JUnitTestCase.assertSame(elementC.type, mixins2[0]); | 2950 JUnitTestCase.assertSame(elementC.type, mixins[0]); |
2951 List<InterfaceType> interfaces2 = elementA.interfaces; | 2951 List<InterfaceType> interfaces = elementA.interfaces; |
2952 EngineTestCase.assertLength(1, interfaces2); | 2952 EngineTestCase.assertLength(1, interfaces); |
2953 JUnitTestCase.assertSame(elementD.type, interfaces2[0]); | 2953 JUnitTestCase.assertSame(elementD.type, interfaces[0]); |
2954 _listener.assertNoErrors(); | 2954 _listener.assertNoErrors(); |
2955 } | 2955 } |
2956 void test_visitSimpleFormalParameter_noType() { | 2956 void test_visitSimpleFormalParameter_noType() { |
2957 FormalParameter node = ASTFactory.simpleFormalParameter3("p"); | 2957 FormalParameter node = ASTFactory.simpleFormalParameter3("p"); |
2958 node.identifier.element = new ParameterElementImpl(ASTFactory.identifier3("p
")); | 2958 node.identifier.element = new ParameterElementImpl(ASTFactory.identifier3("p
")); |
2959 JUnitTestCase.assertSame(_typeProvider.dynamicType, resolve6(node, [])); | 2959 JUnitTestCase.assertSame(_typeProvider.dynamicType, resolve6(node, [])); |
2960 _listener.assertNoErrors(); | 2960 _listener.assertNoErrors(); |
2961 } | 2961 } |
2962 void test_visitSimpleFormalParameter_type() { | 2962 void test_visitSimpleFormalParameter_type() { |
2963 InterfaceType intType2 = _typeProvider.intType; | 2963 InterfaceType intType = _typeProvider.intType; |
2964 ClassElement intElement = intType2.element; | 2964 ClassElement intElement = intType.element; |
2965 FormalParameter node = ASTFactory.simpleFormalParameter4(ASTFactory.typeName
(intElement, []), "p"); | 2965 FormalParameter node = ASTFactory.simpleFormalParameter4(ASTFactory.typeName
(intElement, []), "p"); |
2966 SimpleIdentifier identifier2 = node.identifier; | 2966 SimpleIdentifier identifier = node.identifier; |
2967 ParameterElementImpl element = new ParameterElementImpl(identifier2); | 2967 ParameterElementImpl element = new ParameterElementImpl(identifier); |
2968 identifier2.element = element; | 2968 identifier.element = element; |
2969 JUnitTestCase.assertSame(intType2, resolve6(node, [intElement])); | 2969 JUnitTestCase.assertSame(intType, resolve6(node, [intElement])); |
2970 _listener.assertNoErrors(); | 2970 _listener.assertNoErrors(); |
2971 } | 2971 } |
2972 void test_visitTypeName_noParameters_noArguments() { | 2972 void test_visitTypeName_noParameters_noArguments() { |
2973 ClassElement classA = ElementFactory.classElement2("A", []); | 2973 ClassElement classA = ElementFactory.classElement2("A", []); |
2974 TypeName typeName2 = ASTFactory.typeName(classA, []); | 2974 TypeName typeName = ASTFactory.typeName(classA, []); |
2975 typeName2.type = null; | 2975 typeName.type = null; |
2976 resolveNode(typeName2, [classA]); | 2976 resolveNode(typeName, [classA]); |
2977 JUnitTestCase.assertSame(classA.type, typeName2.type); | 2977 JUnitTestCase.assertSame(classA.type, typeName.type); |
2978 _listener.assertNoErrors(); | 2978 _listener.assertNoErrors(); |
2979 } | 2979 } |
2980 void test_visitTypeName_parameters_arguments() { | 2980 void test_visitTypeName_parameters_arguments() { |
2981 ClassElement classA = ElementFactory.classElement2("A", ["E"]); | 2981 ClassElement classA = ElementFactory.classElement2("A", ["E"]); |
2982 ClassElement classB = ElementFactory.classElement2("B", []); | 2982 ClassElement classB = ElementFactory.classElement2("B", []); |
2983 TypeName typeName2 = ASTFactory.typeName(classA, [ASTFactory.typeName(classB
, [])]); | 2983 TypeName typeName = ASTFactory.typeName(classA, [ASTFactory.typeName(classB,
[])]); |
2984 typeName2.type = null; | 2984 typeName.type = null; |
2985 resolveNode(typeName2, [classA, classB]); | 2985 resolveNode(typeName, [classA, classB]); |
2986 InterfaceType resultType = typeName2.type as InterfaceType; | 2986 InterfaceType resultType = typeName.type as InterfaceType; |
2987 JUnitTestCase.assertSame(classA, resultType.element); | 2987 JUnitTestCase.assertSame(classA, resultType.element); |
2988 List<Type2> resultArguments = resultType.typeArguments; | 2988 List<Type2> resultArguments = resultType.typeArguments; |
2989 EngineTestCase.assertLength(1, resultArguments); | 2989 EngineTestCase.assertLength(1, resultArguments); |
2990 JUnitTestCase.assertSame(classB.type, resultArguments[0]); | 2990 JUnitTestCase.assertSame(classB.type, resultArguments[0]); |
2991 _listener.assertNoErrors(); | 2991 _listener.assertNoErrors(); |
2992 } | 2992 } |
2993 void test_visitTypeName_parameters_noArguments() { | 2993 void test_visitTypeName_parameters_noArguments() { |
2994 ClassElement classA = ElementFactory.classElement2("A", ["E"]); | 2994 ClassElement classA = ElementFactory.classElement2("A", ["E"]); |
2995 TypeName typeName2 = ASTFactory.typeName(classA, []); | 2995 TypeName typeName = ASTFactory.typeName(classA, []); |
2996 typeName2.type = null; | 2996 typeName.type = null; |
2997 resolveNode(typeName2, [classA]); | 2997 resolveNode(typeName, [classA]); |
2998 InterfaceType resultType = typeName2.type as InterfaceType; | 2998 InterfaceType resultType = typeName.type as InterfaceType; |
2999 JUnitTestCase.assertSame(classA, resultType.element); | 2999 JUnitTestCase.assertSame(classA, resultType.element); |
3000 List<Type2> resultArguments = resultType.typeArguments; | 3000 List<Type2> resultArguments = resultType.typeArguments; |
3001 EngineTestCase.assertLength(1, resultArguments); | 3001 EngineTestCase.assertLength(1, resultArguments); |
3002 JUnitTestCase.assertSame(DynamicTypeImpl.instance, resultArguments[0]); | 3002 JUnitTestCase.assertSame(DynamicTypeImpl.instance, resultArguments[0]); |
3003 _listener.assertNoErrors(); | 3003 _listener.assertNoErrors(); |
3004 } | 3004 } |
3005 void test_visitTypeName_void() { | 3005 void test_visitTypeName_void() { |
3006 ClassElement classA = ElementFactory.classElement2("A", []); | 3006 ClassElement classA = ElementFactory.classElement2("A", []); |
3007 TypeName typeName = ASTFactory.typeName4("void", []); | 3007 TypeName typeName = ASTFactory.typeName4("void", []); |
3008 resolveNode(typeName, [classA]); | 3008 resolveNode(typeName, [classA]); |
3009 JUnitTestCase.assertSame(VoidTypeImpl.instance, typeName.type); | 3009 JUnitTestCase.assertSame(VoidTypeImpl.instance, typeName.type); |
3010 _listener.assertNoErrors(); | 3010 _listener.assertNoErrors(); |
3011 } | 3011 } |
3012 | 3012 |
3013 /** | 3013 /** |
3014 * Analyze the given catch clause and assert that the types of the parameters
have been set to the | 3014 * Analyze the given catch clause and assert that the types of the parameters
have been set to the |
3015 * given types. The types can be null if the catch clause does not have the co
rresponding | 3015 * given types. The types can be null if the catch clause does not have the co
rresponding |
3016 * parameter. | 3016 * parameter. |
3017 * @param node the catch clause to be analyzed | 3017 * @param node the catch clause to be analyzed |
3018 * @param exceptionType the expected type of the exception parameter | 3018 * @param exceptionType the expected type of the exception parameter |
3019 * @param stackTraceType the expected type of the stack trace parameter | 3019 * @param stackTraceType the expected type of the stack trace parameter |
3020 * @param definedElements the elements that are to be defined in the scope in
which the element is | 3020 * @param definedElements the elements that are to be defined in the scope in
which the element is |
3021 * being resolved | 3021 * being resolved |
3022 */ | 3022 */ |
3023 void resolve(CatchClause node, InterfaceType exceptionType, InterfaceType stac
kTraceType, List<Element> definedElements) { | 3023 void resolve(CatchClause node, InterfaceType exceptionType, InterfaceType stac
kTraceType, List<Element> definedElements) { |
3024 resolveNode(node, definedElements); | 3024 resolveNode(node, definedElements); |
3025 SimpleIdentifier exceptionParameter2 = node.exceptionParameter; | 3025 SimpleIdentifier exceptionParameter = node.exceptionParameter; |
3026 if (exceptionParameter2 != null) { | 3026 if (exceptionParameter != null) { |
3027 JUnitTestCase.assertSame(exceptionType, exceptionParameter2.staticType); | 3027 JUnitTestCase.assertSame(exceptionType, exceptionParameter.staticType); |
3028 } | 3028 } |
3029 SimpleIdentifier stackTraceParameter2 = node.stackTraceParameter; | 3029 SimpleIdentifier stackTraceParameter = node.stackTraceParameter; |
3030 if (stackTraceParameter2 != null) { | 3030 if (stackTraceParameter != null) { |
3031 JUnitTestCase.assertSame(stackTraceType, stackTraceParameter2.staticType); | 3031 JUnitTestCase.assertSame(stackTraceType, stackTraceParameter.staticType); |
3032 } | 3032 } |
3033 } | 3033 } |
3034 | 3034 |
3035 /** | 3035 /** |
3036 * Return the type associated with the given parameter after the static type a
nalyzer has computed | 3036 * Return the type associated with the given parameter after the static type a
nalyzer has computed |
3037 * a type for it. | 3037 * a type for it. |
3038 * @param node the parameter with which the type is associated | 3038 * @param node the parameter with which the type is associated |
3039 * @param definedElements the elements that are to be defined in the scope in
which the element is | 3039 * @param definedElements the elements that are to be defined in the scope in
which the element is |
3040 * being resolved | 3040 * being resolved |
3041 * @return the type associated with the parameter | 3041 * @return the type associated with the parameter |
(...skipping 3355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6397 Object visitImportDirective(ImportDirective node) => null; | 6397 Object visitImportDirective(ImportDirective node) => null; |
6398 Object visitLabel(Label node) => null; | 6398 Object visitLabel(Label node) => null; |
6399 Object visitLibraryIdentifier(LibraryIdentifier node) => null; | 6399 Object visitLibraryIdentifier(LibraryIdentifier node) => null; |
6400 Object visitPrefixedIdentifier(PrefixedIdentifier node) { | 6400 Object visitPrefixedIdentifier(PrefixedIdentifier node) { |
6401 if (node.staticType == null && identical(node.prefix.staticType, DynamicType
Impl.instance)) { | 6401 if (node.staticType == null && identical(node.prefix.staticType, DynamicType
Impl.instance)) { |
6402 return null; | 6402 return null; |
6403 } | 6403 } |
6404 return super.visitPrefixedIdentifier(node); | 6404 return super.visitPrefixedIdentifier(node); |
6405 } | 6405 } |
6406 Object visitSimpleIdentifier(SimpleIdentifier node) { | 6406 Object visitSimpleIdentifier(SimpleIdentifier node) { |
6407 ASTNode parent2 = node.parent; | 6407 ASTNode parent = node.parent; |
6408 if (parent2 is MethodInvocation && identical(node, ((parent2 as MethodInvoca
tion)).methodName)) { | 6408 if (parent is MethodInvocation && identical(node, ((parent as MethodInvocati
on)).methodName)) { |
6409 return null; | 6409 return null; |
6410 } else if (parent2 is RedirectingConstructorInvocation && identical(node, ((
parent2 as RedirectingConstructorInvocation)).constructorName)) { | 6410 } else if (parent is RedirectingConstructorInvocation && identical(node, ((p
arent as RedirectingConstructorInvocation)).constructorName)) { |
6411 return null; | 6411 return null; |
6412 } else if (parent2 is SuperConstructorInvocation && identical(node, ((parent
2 as SuperConstructorInvocation)).constructorName)) { | 6412 } else if (parent is SuperConstructorInvocation && identical(node, ((parent
as SuperConstructorInvocation)).constructorName)) { |
6413 return null; | 6413 return null; |
6414 } else if (parent2 is ConstructorName && identical(node, ((parent2 as Constr
uctorName)).name)) { | 6414 } else if (parent is ConstructorName && identical(node, ((parent as Construc
torName)).name)) { |
6415 return null; | 6415 return null; |
6416 } else if (parent2 is ConstructorFieldInitializer && identical(node, ((paren
t2 as ConstructorFieldInitializer)).fieldName)) { | 6416 } else if (parent is ConstructorFieldInitializer && identical(node, ((parent
as ConstructorFieldInitializer)).fieldName)) { |
6417 return null; | 6417 return null; |
6418 } else if (node.element is PrefixElement) { | 6418 } else if (node.element is PrefixElement) { |
6419 return null; | 6419 return null; |
6420 } | 6420 } |
6421 return super.visitSimpleIdentifier(node); | 6421 return super.visitSimpleIdentifier(node); |
6422 } | 6422 } |
6423 Object visitTypeName(TypeName node) { | 6423 Object visitTypeName(TypeName node) { |
6424 if (node.type == null) { | 6424 if (node.type == null) { |
6425 _unresolvedTypes.add(node); | 6425 _unresolvedTypes.add(node); |
6426 } else { | 6426 } else { |
6427 _resolvedTypeCount++; | 6427 _resolvedTypeCount++; |
6428 } | 6428 } |
6429 return null; | 6429 return null; |
6430 } | 6430 } |
6431 String getFileName(ASTNode node) { | 6431 String getFileName(ASTNode node) { |
6432 if (node != null) { | 6432 if (node != null) { |
6433 ASTNode root2 = node.root; | 6433 ASTNode root = node.root; |
6434 if (root2 is CompilationUnit) { | 6434 if (root is CompilationUnit) { |
6435 CompilationUnit rootCU = (root2 as CompilationUnit); | 6435 CompilationUnit rootCU = (root as CompilationUnit); |
6436 if (rootCU.element != null) { | 6436 if (rootCU.element != null) { |
6437 return rootCU.element.source.fullName; | 6437 return rootCU.element.source.fullName; |
6438 } else { | 6438 } else { |
6439 return "<unknown file- CompilationUnit.getElement() returned null>"; | 6439 return "<unknown file- CompilationUnit.getElement() returned null>"; |
6440 } | 6440 } |
6441 } else { | 6441 } else { |
6442 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni
t>"; | 6442 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni
t>"; |
6443 } | 6443 } |
6444 } | 6444 } |
6445 return "<unknown file- ASTNode is null>"; | 6445 return "<unknown file- ASTNode is null>"; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6627 void fail_visitRedirectingConstructorInvocation() { | 6627 void fail_visitRedirectingConstructorInvocation() { |
6628 JUnitTestCase.fail("Not yet tested"); | 6628 JUnitTestCase.fail("Not yet tested"); |
6629 _listener.assertNoErrors(); | 6629 _listener.assertNoErrors(); |
6630 } | 6630 } |
6631 void setUp() { | 6631 void setUp() { |
6632 _listener = new GatheringErrorListener(); | 6632 _listener = new GatheringErrorListener(); |
6633 _typeProvider = new TestTypeProvider(); | 6633 _typeProvider = new TestTypeProvider(); |
6634 _resolver = createResolver(); | 6634 _resolver = createResolver(); |
6635 } | 6635 } |
6636 void test_lookUpMethodInInterfaces() { | 6636 void test_lookUpMethodInInterfaces() { |
6637 InterfaceType intType2 = _typeProvider.intType; | 6637 InterfaceType intType = _typeProvider.intType; |
6638 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 6638 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
6639 MethodElement operator = ElementFactory.methodElement("[]", intType2, [intTy
pe2]); | 6639 MethodElement operator = ElementFactory.methodElement("[]", intType, [intTyp
e]); |
6640 classA.methods = <MethodElement> [operator]; | 6640 classA.methods = <MethodElement> [operator]; |
6641 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 6641 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
6642 classB.interfaces = <InterfaceType> [classA.type]; | 6642 classB.interfaces = <InterfaceType> [classA.type]; |
6643 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 6643 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
6644 classC.mixins = <InterfaceType> [classB.type]; | 6644 classC.mixins = <InterfaceType> [classB.type]; |
6645 ClassElementImpl classD = ElementFactory.classElement("D", classC.type, []); | 6645 ClassElementImpl classD = ElementFactory.classElement("D", classC.type, []); |
6646 SimpleIdentifier array = ASTFactory.identifier3("a"); | 6646 SimpleIdentifier array = ASTFactory.identifier3("a"); |
6647 array.staticType = classD.type; | 6647 array.staticType = classD.type; |
6648 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id
entifier3("i")); | 6648 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id
entifier3("i")); |
6649 JUnitTestCase.assertSame(operator, resolve5(expression, [])); | 6649 JUnitTestCase.assertSame(operator, resolve5(expression, [])); |
6650 _listener.assertNoErrors(); | 6650 _listener.assertNoErrors(); |
6651 } | 6651 } |
6652 void test_visitAssignmentExpression_compound() { | 6652 void test_visitAssignmentExpression_compound() { |
6653 InterfaceType intType2 = _typeProvider.intType; | 6653 InterfaceType intType = _typeProvider.intType; |
6654 SimpleIdentifier leftHandSide = ASTFactory.identifier3("a"); | 6654 SimpleIdentifier leftHandSide = ASTFactory.identifier3("a"); |
6655 leftHandSide.staticType = intType2; | 6655 leftHandSide.staticType = intType; |
6656 AssignmentExpression assignment = ASTFactory.assignmentExpression(leftHandSi
de, TokenType.PLUS_EQ, ASTFactory.integer(1)); | 6656 AssignmentExpression assignment = ASTFactory.assignmentExpression(leftHandSi
de, TokenType.PLUS_EQ, ASTFactory.integer(1)); |
6657 resolveNode(assignment, []); | 6657 resolveNode(assignment, []); |
6658 JUnitTestCase.assertSame(getMethod(_typeProvider.numType, "+"), assignment.e
lement); | 6658 JUnitTestCase.assertSame(getMethod(_typeProvider.numType, "+"), assignment.e
lement); |
6659 _listener.assertNoErrors(); | 6659 _listener.assertNoErrors(); |
6660 } | 6660 } |
6661 void test_visitAssignmentExpression_simple() { | 6661 void test_visitAssignmentExpression_simple() { |
6662 AssignmentExpression expression = ASTFactory.assignmentExpression(ASTFactory
.identifier3("x"), TokenType.EQ, ASTFactory.integer(0)); | 6662 AssignmentExpression expression = ASTFactory.assignmentExpression(ASTFactory
.identifier3("x"), TokenType.EQ, ASTFactory.integer(0)); |
6663 resolveNode(expression, []); | 6663 resolveNode(expression, []); |
6664 JUnitTestCase.assertNull(expression.element); | 6664 JUnitTestCase.assertNull(expression.element); |
6665 _listener.assertNoErrors(); | 6665 _listener.assertNoErrors(); |
6666 } | 6666 } |
6667 void test_visitBinaryExpression() { | 6667 void test_visitBinaryExpression() { |
6668 InterfaceType numType2 = _typeProvider.numType; | 6668 InterfaceType numType = _typeProvider.numType; |
6669 SimpleIdentifier left = ASTFactory.identifier3("i"); | 6669 SimpleIdentifier left = ASTFactory.identifier3("i"); |
6670 left.staticType = numType2; | 6670 left.staticType = numType; |
6671 BinaryExpression expression = ASTFactory.binaryExpression(left, TokenType.PL
US, ASTFactory.identifier3("j")); | 6671 BinaryExpression expression = ASTFactory.binaryExpression(left, TokenType.PL
US, ASTFactory.identifier3("j")); |
6672 resolveNode(expression, []); | 6672 resolveNode(expression, []); |
6673 JUnitTestCase.assertEquals(getMethod(numType2, "+"), expression.element); | 6673 JUnitTestCase.assertEquals(getMethod(numType, "+"), expression.element); |
6674 _listener.assertNoErrors(); | 6674 _listener.assertNoErrors(); |
6675 } | 6675 } |
6676 void test_visitBreakStatement_withLabel() { | 6676 void test_visitBreakStatement_withLabel() { |
6677 String label = "loop"; | 6677 String label = "loop"; |
6678 LabelElementImpl labelElement = new LabelElementImpl(ASTFactory.identifier3(
label), false, false); | 6678 LabelElementImpl labelElement = new LabelElementImpl(ASTFactory.identifier3(
label), false, false); |
6679 BreakStatement statement = ASTFactory.breakStatement2(label); | 6679 BreakStatement statement = ASTFactory.breakStatement2(label); |
6680 JUnitTestCase.assertSame(labelElement, resolve(statement, labelElement)); | 6680 JUnitTestCase.assertSame(labelElement, resolve(statement, labelElement)); |
6681 _listener.assertNoErrors(); | 6681 _listener.assertNoErrors(); |
6682 } | 6682 } |
6683 void test_visitBreakStatement_withoutLabel() { | 6683 void test_visitBreakStatement_withoutLabel() { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6717 resolveStatement(statement, null); | 6717 resolveStatement(statement, null); |
6718 _listener.assertNoErrors(); | 6718 _listener.assertNoErrors(); |
6719 } | 6719 } |
6720 void test_visitExportDirective_noCombinators() { | 6720 void test_visitExportDirective_noCombinators() { |
6721 ExportDirective directive = ASTFactory.exportDirective2(null, []); | 6721 ExportDirective directive = ASTFactory.exportDirective2(null, []); |
6722 directive.element = ElementFactory.exportFor(ElementFactory.library(_definin
gLibrary.context, "lib"), []); | 6722 directive.element = ElementFactory.exportFor(ElementFactory.library(_definin
gLibrary.context, "lib"), []); |
6723 resolveNode(directive, []); | 6723 resolveNode(directive, []); |
6724 _listener.assertNoErrors(); | 6724 _listener.assertNoErrors(); |
6725 } | 6725 } |
6726 void test_visitFieldFormalParameter() { | 6726 void test_visitFieldFormalParameter() { |
6727 InterfaceType intType2 = _typeProvider.intType; | 6727 InterfaceType intType = _typeProvider.intType; |
6728 String fieldName = "f"; | 6728 String fieldName = "f"; |
6729 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 6729 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
6730 classA.fields = <FieldElement> [ElementFactory.fieldElement(fieldName, false
, false, false, intType2)]; | 6730 classA.fields = <FieldElement> [ElementFactory.fieldElement(fieldName, false
, false, false, intType)]; |
6731 FieldFormalParameter parameter = ASTFactory.fieldFormalParameter2(fieldName)
; | 6731 FieldFormalParameter parameter = ASTFactory.fieldFormalParameter2(fieldName)
; |
6732 parameter.identifier.element = ElementFactory.fieldFormalParameter(parameter
.identifier); | 6732 parameter.identifier.element = ElementFactory.fieldFormalParameter(parameter
.identifier); |
6733 resolveInClass(parameter, classA); | 6733 resolveInClass(parameter, classA); |
6734 JUnitTestCase.assertSame(intType2, parameter.element.type); | 6734 JUnitTestCase.assertSame(intType, parameter.element.type); |
6735 } | 6735 } |
6736 void test_visitImportDirective_noCombinators_noPrefix() { | 6736 void test_visitImportDirective_noCombinators_noPrefix() { |
6737 ImportDirective directive = ASTFactory.importDirective2(null, null, []); | 6737 ImportDirective directive = ASTFactory.importDirective2(null, null, []); |
6738 directive.element = ElementFactory.importFor(ElementFactory.library(_definin
gLibrary.context, "lib"), null, []); | 6738 directive.element = ElementFactory.importFor(ElementFactory.library(_definin
gLibrary.context, "lib"), null, []); |
6739 resolveNode(directive, []); | 6739 resolveNode(directive, []); |
6740 _listener.assertNoErrors(); | 6740 _listener.assertNoErrors(); |
6741 } | 6741 } |
6742 void test_visitImportDirective_noCombinators_prefix() { | 6742 void test_visitImportDirective_noCombinators_prefix() { |
6743 String prefixName = "p"; | 6743 String prefixName = "p"; |
6744 ImportElement importElement = ElementFactory.importFor(ElementFactory.librar
y(_definingLibrary.context, "lib"), ElementFactory.prefix(prefixName), []); | 6744 ImportElement importElement = ElementFactory.importFor(ElementFactory.librar
y(_definingLibrary.context, "lib"), ElementFactory.prefix(prefixName), []); |
6745 _definingLibrary.imports = <ImportElement> [importElement]; | 6745 _definingLibrary.imports = <ImportElement> [importElement]; |
6746 ImportDirective directive = ASTFactory.importDirective2(null, prefixName, []
); | 6746 ImportDirective directive = ASTFactory.importDirective2(null, prefixName, []
); |
6747 directive.element = importElement; | 6747 directive.element = importElement; |
6748 resolveNode(directive, []); | 6748 resolveNode(directive, []); |
6749 _listener.assertNoErrors(); | 6749 _listener.assertNoErrors(); |
6750 } | 6750 } |
6751 void test_visitIndexExpression_get() { | 6751 void test_visitIndexExpression_get() { |
6752 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 6752 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
6753 InterfaceType intType2 = _typeProvider.intType; | 6753 InterfaceType intType = _typeProvider.intType; |
6754 MethodElement getter = ElementFactory.methodElement("[]", intType2, [intType
2]); | 6754 MethodElement getter = ElementFactory.methodElement("[]", intType, [intType]
); |
6755 classA.methods = <MethodElement> [getter]; | 6755 classA.methods = <MethodElement> [getter]; |
6756 SimpleIdentifier array = ASTFactory.identifier3("a"); | 6756 SimpleIdentifier array = ASTFactory.identifier3("a"); |
6757 array.staticType = classA.type; | 6757 array.staticType = classA.type; |
6758 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id
entifier3("i")); | 6758 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id
entifier3("i")); |
6759 JUnitTestCase.assertSame(getter, resolve5(expression, [])); | 6759 JUnitTestCase.assertSame(getter, resolve5(expression, [])); |
6760 _listener.assertNoErrors(); | 6760 _listener.assertNoErrors(); |
6761 } | 6761 } |
6762 void test_visitIndexExpression_set() { | 6762 void test_visitIndexExpression_set() { |
6763 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 6763 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
6764 InterfaceType intType2 = _typeProvider.intType; | 6764 InterfaceType intType = _typeProvider.intType; |
6765 MethodElement setter = ElementFactory.methodElement("[]=", intType2, [intTyp
e2]); | 6765 MethodElement setter = ElementFactory.methodElement("[]=", intType, [intType
]); |
6766 classA.methods = <MethodElement> [setter]; | 6766 classA.methods = <MethodElement> [setter]; |
6767 SimpleIdentifier array = ASTFactory.identifier3("a"); | 6767 SimpleIdentifier array = ASTFactory.identifier3("a"); |
6768 array.staticType = classA.type; | 6768 array.staticType = classA.type; |
6769 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id
entifier3("i")); | 6769 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id
entifier3("i")); |
6770 ASTFactory.assignmentExpression(expression, TokenType.EQ, ASTFactory.integer
(0)); | 6770 ASTFactory.assignmentExpression(expression, TokenType.EQ, ASTFactory.integer
(0)); |
6771 JUnitTestCase.assertSame(setter, resolve5(expression, [])); | 6771 JUnitTestCase.assertSame(setter, resolve5(expression, [])); |
6772 _listener.assertNoErrors(); | 6772 _listener.assertNoErrors(); |
6773 } | 6773 } |
6774 void test_visitInstanceCreationExpression_named() { | 6774 void test_visitInstanceCreationExpression_named() { |
6775 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 6775 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
(...skipping 29 matching lines...) Expand all Loading... |
6805 classA.constructors = <ConstructorElement> [constructor]; | 6805 classA.constructors = <ConstructorElement> [constructor]; |
6806 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA
, []), constructorName); | 6806 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA
, []), constructorName); |
6807 name.element = constructor; | 6807 name.element = constructor; |
6808 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression(
Keyword.NEW, name, [ASTFactory.namedExpression2(parameterName, ASTFactory.intege
r(0))]); | 6808 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression(
Keyword.NEW, name, [ASTFactory.namedExpression2(parameterName, ASTFactory.intege
r(0))]); |
6809 resolveNode(creation, []); | 6809 resolveNode(creation, []); |
6810 JUnitTestCase.assertSame(constructor, creation.element); | 6810 JUnitTestCase.assertSame(constructor, creation.element); |
6811 JUnitTestCase.assertSame(parameter, ((creation.argumentList.arguments[0] as
NamedExpression)).name.label.element); | 6811 JUnitTestCase.assertSame(parameter, ((creation.argumentList.arguments[0] as
NamedExpression)).name.label.element); |
6812 _listener.assertNoErrors(); | 6812 _listener.assertNoErrors(); |
6813 } | 6813 } |
6814 void test_visitMethodInvocation() { | 6814 void test_visitMethodInvocation() { |
6815 InterfaceType numType2 = _typeProvider.numType; | 6815 InterfaceType numType = _typeProvider.numType; |
6816 SimpleIdentifier left = ASTFactory.identifier3("i"); | 6816 SimpleIdentifier left = ASTFactory.identifier3("i"); |
6817 left.staticType = numType2; | 6817 left.staticType = numType; |
6818 String methodName = "abs"; | 6818 String methodName = "abs"; |
6819 MethodInvocation invocation = ASTFactory.methodInvocation(left, methodName,
[]); | 6819 MethodInvocation invocation = ASTFactory.methodInvocation(left, methodName,
[]); |
6820 resolveNode(invocation, []); | 6820 resolveNode(invocation, []); |
6821 JUnitTestCase.assertSame(getMethod(numType2, methodName), invocation.methodN
ame.element); | 6821 JUnitTestCase.assertSame(getMethod(numType, methodName), invocation.methodNa
me.element); |
6822 _listener.assertNoErrors(); | 6822 _listener.assertNoErrors(); |
6823 } | 6823 } |
6824 void test_visitMethodInvocation_namedParameter() { | 6824 void test_visitMethodInvocation_namedParameter() { |
6825 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 6825 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
6826 String methodName = "m"; | 6826 String methodName = "m"; |
6827 String parameterName = "p"; | 6827 String parameterName = "p"; |
6828 MethodElementImpl method = ElementFactory.methodElement(methodName, null, []
); | 6828 MethodElementImpl method = ElementFactory.methodElement(methodName, null, []
); |
6829 ParameterElement parameter = ElementFactory.namedParameter(parameterName); | 6829 ParameterElement parameter = ElementFactory.namedParameter(parameterName); |
6830 method.parameters = <ParameterElement> [parameter]; | 6830 method.parameters = <ParameterElement> [parameter]; |
6831 classA.methods = <MethodElement> [method]; | 6831 classA.methods = <MethodElement> [method]; |
6832 SimpleIdentifier left = ASTFactory.identifier3("i"); | 6832 SimpleIdentifier left = ASTFactory.identifier3("i"); |
6833 left.staticType = classA.type; | 6833 left.staticType = classA.type; |
6834 MethodInvocation invocation = ASTFactory.methodInvocation(left, methodName,
[ASTFactory.namedExpression2(parameterName, ASTFactory.integer(0))]); | 6834 MethodInvocation invocation = ASTFactory.methodInvocation(left, methodName,
[ASTFactory.namedExpression2(parameterName, ASTFactory.integer(0))]); |
6835 resolveNode(invocation, []); | 6835 resolveNode(invocation, []); |
6836 JUnitTestCase.assertSame(method, invocation.methodName.element); | 6836 JUnitTestCase.assertSame(method, invocation.methodName.element); |
6837 JUnitTestCase.assertSame(parameter, ((invocation.argumentList.arguments[0] a
s NamedExpression)).name.label.element); | 6837 JUnitTestCase.assertSame(parameter, ((invocation.argumentList.arguments[0] a
s NamedExpression)).name.label.element); |
6838 _listener.assertNoErrors(); | 6838 _listener.assertNoErrors(); |
6839 } | 6839 } |
6840 void test_visitPostfixExpression() { | 6840 void test_visitPostfixExpression() { |
6841 InterfaceType numType2 = _typeProvider.numType; | 6841 InterfaceType numType = _typeProvider.numType; |
6842 SimpleIdentifier operand = ASTFactory.identifier3("i"); | 6842 SimpleIdentifier operand = ASTFactory.identifier3("i"); |
6843 operand.staticType = numType2; | 6843 operand.staticType = numType; |
6844 PostfixExpression expression = ASTFactory.postfixExpression(operand, TokenTy
pe.PLUS_PLUS); | 6844 PostfixExpression expression = ASTFactory.postfixExpression(operand, TokenTy
pe.PLUS_PLUS); |
6845 resolveNode(expression, []); | 6845 resolveNode(expression, []); |
6846 JUnitTestCase.assertEquals(getMethod(numType2, "+"), expression.element); | 6846 JUnitTestCase.assertEquals(getMethod(numType, "+"), expression.element); |
6847 _listener.assertNoErrors(); | 6847 _listener.assertNoErrors(); |
6848 } | 6848 } |
6849 void test_visitPrefixedIdentifier_dynamic() { | 6849 void test_visitPrefixedIdentifier_dynamic() { |
6850 Type2 dynamicType2 = _typeProvider.dynamicType; | 6850 Type2 dynamicType = _typeProvider.dynamicType; |
6851 SimpleIdentifier target = ASTFactory.identifier3("a"); | 6851 SimpleIdentifier target = ASTFactory.identifier3("a"); |
6852 VariableElementImpl variable = ElementFactory.localVariableElement(target); | 6852 VariableElementImpl variable = ElementFactory.localVariableElement(target); |
6853 variable.type = dynamicType2; | 6853 variable.type = dynamicType; |
6854 target.element = variable; | 6854 target.element = variable; |
6855 target.staticType = dynamicType2; | 6855 target.staticType = dynamicType; |
6856 PrefixedIdentifier identifier2 = ASTFactory.identifier(target, ASTFactory.id
entifier3("b")); | 6856 PrefixedIdentifier identifier = ASTFactory.identifier(target, ASTFactory.ide
ntifier3("b")); |
6857 resolveNode(identifier2, []); | 6857 resolveNode(identifier, []); |
6858 JUnitTestCase.assertNull(identifier2.element); | 6858 JUnitTestCase.assertNull(identifier.element); |
6859 JUnitTestCase.assertNull(identifier2.identifier.element); | 6859 JUnitTestCase.assertNull(identifier.identifier.element); |
6860 _listener.assertNoErrors(); | 6860 _listener.assertNoErrors(); |
6861 } | 6861 } |
6862 void test_visitPrefixedIdentifier_nonDynamic() { | 6862 void test_visitPrefixedIdentifier_nonDynamic() { |
6863 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 6863 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
6864 String getterName = "b"; | 6864 String getterName = "b"; |
6865 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa
lse, _typeProvider.intType); | 6865 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa
lse, _typeProvider.intType); |
6866 classA.accessors = <PropertyAccessorElement> [getter]; | 6866 classA.accessors = <PropertyAccessorElement> [getter]; |
6867 SimpleIdentifier target = ASTFactory.identifier3("a"); | 6867 SimpleIdentifier target = ASTFactory.identifier3("a"); |
6868 VariableElementImpl variable = ElementFactory.localVariableElement(target); | 6868 VariableElementImpl variable = ElementFactory.localVariableElement(target); |
6869 variable.type = classA.type; | 6869 variable.type = classA.type; |
6870 target.element = variable; | 6870 target.element = variable; |
6871 target.staticType = classA.type; | 6871 target.staticType = classA.type; |
6872 PrefixedIdentifier identifier2 = ASTFactory.identifier(target, ASTFactory.id
entifier3(getterName)); | 6872 PrefixedIdentifier identifier = ASTFactory.identifier(target, ASTFactory.ide
ntifier3(getterName)); |
6873 resolveNode(identifier2, []); | 6873 resolveNode(identifier, []); |
6874 JUnitTestCase.assertSame(getter, identifier2.element); | 6874 JUnitTestCase.assertSame(getter, identifier.element); |
6875 JUnitTestCase.assertSame(getter, identifier2.identifier.element); | 6875 JUnitTestCase.assertSame(getter, identifier.identifier.element); |
6876 _listener.assertNoErrors(); | 6876 _listener.assertNoErrors(); |
6877 } | 6877 } |
6878 void test_visitPrefixExpression() { | 6878 void test_visitPrefixExpression() { |
6879 InterfaceType numType2 = _typeProvider.numType; | 6879 InterfaceType numType = _typeProvider.numType; |
6880 SimpleIdentifier operand = ASTFactory.identifier3("i"); | 6880 SimpleIdentifier operand = ASTFactory.identifier3("i"); |
6881 operand.staticType = numType2; | 6881 operand.staticType = numType; |
6882 PrefixExpression expression = ASTFactory.prefixExpression(TokenType.PLUS_PLU
S, operand); | 6882 PrefixExpression expression = ASTFactory.prefixExpression(TokenType.PLUS_PLU
S, operand); |
6883 resolveNode(expression, []); | 6883 resolveNode(expression, []); |
6884 JUnitTestCase.assertEquals(getMethod(numType2, "+"), expression.element); | 6884 JUnitTestCase.assertEquals(getMethod(numType, "+"), expression.element); |
6885 _listener.assertNoErrors(); | 6885 _listener.assertNoErrors(); |
6886 } | 6886 } |
6887 void test_visitPropertyAccess_getter_identifier() { | 6887 void test_visitPropertyAccess_getter_identifier() { |
6888 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 6888 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
6889 String getterName = "b"; | 6889 String getterName = "b"; |
6890 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa
lse, _typeProvider.intType); | 6890 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa
lse, _typeProvider.intType); |
6891 classA.accessors = <PropertyAccessorElement> [getter]; | 6891 classA.accessors = <PropertyAccessorElement> [getter]; |
6892 SimpleIdentifier target = ASTFactory.identifier3("a"); | 6892 SimpleIdentifier target = ASTFactory.identifier3("a"); |
6893 target.staticType = classA.type; | 6893 target.staticType = classA.type; |
6894 PropertyAccess access = ASTFactory.propertyAccess2(target, getterName); | 6894 PropertyAccess access = ASTFactory.propertyAccess2(target, getterName); |
(...skipping 21 matching lines...) Expand all Loading... |
6916 classA.accessors = <PropertyAccessorElement> [setter]; | 6916 classA.accessors = <PropertyAccessorElement> [setter]; |
6917 ThisExpression target = ASTFactory.thisExpression(); | 6917 ThisExpression target = ASTFactory.thisExpression(); |
6918 target.staticType = classA.type; | 6918 target.staticType = classA.type; |
6919 PropertyAccess access = ASTFactory.propertyAccess2(target, setterName); | 6919 PropertyAccess access = ASTFactory.propertyAccess2(target, setterName); |
6920 ASTFactory.assignmentExpression(access, TokenType.EQ, ASTFactory.integer(0))
; | 6920 ASTFactory.assignmentExpression(access, TokenType.EQ, ASTFactory.integer(0))
; |
6921 resolveNode(access, []); | 6921 resolveNode(access, []); |
6922 JUnitTestCase.assertSame(setter, access.propertyName.element); | 6922 JUnitTestCase.assertSame(setter, access.propertyName.element); |
6923 _listener.assertNoErrors(); | 6923 _listener.assertNoErrors(); |
6924 } | 6924 } |
6925 void test_visitSimpleIdentifier_classScope() { | 6925 void test_visitSimpleIdentifier_classScope() { |
6926 InterfaceType doubleType2 = _typeProvider.doubleType; | 6926 InterfaceType doubleType = _typeProvider.doubleType; |
6927 String fieldName = "NAN"; | 6927 String fieldName = "NAN"; |
6928 SimpleIdentifier node = ASTFactory.identifier3(fieldName); | 6928 SimpleIdentifier node = ASTFactory.identifier3(fieldName); |
6929 resolveInClass(node, doubleType2.element); | 6929 resolveInClass(node, doubleType.element); |
6930 JUnitTestCase.assertEquals(getGetter(doubleType2, fieldName), node.element); | 6930 JUnitTestCase.assertEquals(getGetter(doubleType, fieldName), node.element); |
6931 _listener.assertNoErrors(); | 6931 _listener.assertNoErrors(); |
6932 } | 6932 } |
6933 void test_visitSimpleIdentifier_lexicalScope() { | 6933 void test_visitSimpleIdentifier_lexicalScope() { |
6934 SimpleIdentifier node = ASTFactory.identifier3("i"); | 6934 SimpleIdentifier node = ASTFactory.identifier3("i"); |
6935 VariableElementImpl element = ElementFactory.localVariableElement(node); | 6935 VariableElementImpl element = ElementFactory.localVariableElement(node); |
6936 JUnitTestCase.assertSame(element, resolve4(node, [element])); | 6936 JUnitTestCase.assertSame(element, resolve4(node, [element])); |
6937 _listener.assertNoErrors(); | 6937 _listener.assertNoErrors(); |
6938 } | 6938 } |
6939 void test_visitSimpleIdentifier_lexicalScope_field_setter() { | 6939 void test_visitSimpleIdentifier_lexicalScope_field_setter() { |
6940 InterfaceType intType2 = _typeProvider.intType; | 6940 InterfaceType intType = _typeProvider.intType; |
6941 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 6941 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
6942 String fieldName = "a"; | 6942 String fieldName = "a"; |
6943 FieldElement field = ElementFactory.fieldElement(fieldName, false, false, fa
lse, intType2); | 6943 FieldElement field = ElementFactory.fieldElement(fieldName, false, false, fa
lse, intType); |
6944 classA.fields = <FieldElement> [field]; | 6944 classA.fields = <FieldElement> [field]; |
6945 classA.accessors = <PropertyAccessorElement> [field.getter, field.setter]; | 6945 classA.accessors = <PropertyAccessorElement> [field.getter, field.setter]; |
6946 SimpleIdentifier node = ASTFactory.identifier3(fieldName); | 6946 SimpleIdentifier node = ASTFactory.identifier3(fieldName); |
6947 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0)); | 6947 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0)); |
6948 resolveInClass(node, classA); | 6948 resolveInClass(node, classA); |
6949 Element element2 = node.element; | 6949 Element element = node.element; |
6950 EngineTestCase.assertInstanceOf(PropertyAccessorElement, element2); | 6950 EngineTestCase.assertInstanceOf(PropertyAccessorElement, element); |
6951 JUnitTestCase.assertTrue(((element2 as PropertyAccessorElement)).isSetter())
; | 6951 JUnitTestCase.assertTrue(((element as PropertyAccessorElement)).isSetter()); |
6952 _listener.assertNoErrors(); | 6952 _listener.assertNoErrors(); |
6953 } | 6953 } |
6954 void test_visitSuperConstructorInvocation() { | 6954 void test_visitSuperConstructorInvocation() { |
6955 ClassElementImpl superclass = ElementFactory.classElement2("A", []); | 6955 ClassElementImpl superclass = ElementFactory.classElement2("A", []); |
6956 ConstructorElementImpl superConstructor = ElementFactory.constructorElement(
superclass, null); | 6956 ConstructorElementImpl superConstructor = ElementFactory.constructorElement(
superclass, null); |
6957 superclass.constructors = <ConstructorElement> [superConstructor]; | 6957 superclass.constructors = <ConstructorElement> [superConstructor]; |
6958 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type
, []); | 6958 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type
, []); |
6959 ConstructorElementImpl subConstructor = ElementFactory.constructorElement(su
bclass, null); | 6959 ConstructorElementImpl subConstructor = ElementFactory.constructorElement(su
bclass, null); |
6960 subclass.constructors = <ConstructorElement> [subConstructor]; | 6960 subclass.constructors = <ConstructorElement> [subConstructor]; |
6961 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio
n([]); | 6961 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio
n([]); |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7294 manager.exitScope(); | 7294 manager.exitScope(); |
7295 try { | 7295 try { |
7296 manager.exitScope(); | 7296 manager.exitScope(); |
7297 JUnitTestCase.fail("Expected IllegalStateException"); | 7297 JUnitTestCase.fail("Expected IllegalStateException"); |
7298 } on IllegalStateException catch (exception) { | 7298 } on IllegalStateException catch (exception) { |
7299 } | 7299 } |
7300 } | 7300 } |
7301 void test_getType_enclosedOverride() { | 7301 void test_getType_enclosedOverride() { |
7302 TypeOverrideManager manager = new TypeOverrideManager(); | 7302 TypeOverrideManager manager = new TypeOverrideManager(); |
7303 LocalVariableElementImpl element = ElementFactory.localVariableElement2("v")
; | 7303 LocalVariableElementImpl element = ElementFactory.localVariableElement2("v")
; |
7304 InterfaceType type2 = ElementFactory.classElement2("C", []).type; | 7304 InterfaceType type = ElementFactory.classElement2("C", []).type; |
7305 manager.enterScope(); | 7305 manager.enterScope(); |
7306 manager.setType(element, type2); | 7306 manager.setType(element, type); |
7307 manager.enterScope(); | 7307 manager.enterScope(); |
7308 JUnitTestCase.assertSame(type2, manager.getType(element)); | 7308 JUnitTestCase.assertSame(type, manager.getType(element)); |
7309 } | 7309 } |
7310 void test_getType_immediateOverride() { | 7310 void test_getType_immediateOverride() { |
7311 TypeOverrideManager manager = new TypeOverrideManager(); | 7311 TypeOverrideManager manager = new TypeOverrideManager(); |
7312 LocalVariableElementImpl element = ElementFactory.localVariableElement2("v")
; | 7312 LocalVariableElementImpl element = ElementFactory.localVariableElement2("v")
; |
7313 InterfaceType type2 = ElementFactory.classElement2("C", []).type; | 7313 InterfaceType type = ElementFactory.classElement2("C", []).type; |
7314 manager.enterScope(); | 7314 manager.enterScope(); |
7315 manager.setType(element, type2); | 7315 manager.setType(element, type); |
7316 JUnitTestCase.assertSame(type2, manager.getType(element)); | 7316 JUnitTestCase.assertSame(type, manager.getType(element)); |
7317 } | 7317 } |
7318 void test_getType_noOverride() { | 7318 void test_getType_noOverride() { |
7319 TypeOverrideManager manager = new TypeOverrideManager(); | 7319 TypeOverrideManager manager = new TypeOverrideManager(); |
7320 manager.enterScope(); | 7320 manager.enterScope(); |
7321 JUnitTestCase.assertNull(manager.getType(ElementFactory.localVariableElement
2("v"))); | 7321 JUnitTestCase.assertNull(manager.getType(ElementFactory.localVariableElement
2("v"))); |
7322 } | 7322 } |
7323 void test_getType_noScope() { | 7323 void test_getType_noScope() { |
7324 TypeOverrideManager manager = new TypeOverrideManager(); | 7324 TypeOverrideManager manager = new TypeOverrideManager(); |
7325 JUnitTestCase.assertNull(manager.getType(ElementFactory.localVariableElement
2("v"))); | 7325 JUnitTestCase.assertNull(manager.getType(ElementFactory.localVariableElement
2("v"))); |
7326 } | 7326 } |
(...skipping 1645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8972 * for testing purposes. | 8972 * for testing purposes. |
8973 */ | 8973 */ |
8974 class AnalysisContextFactory { | 8974 class AnalysisContextFactory { |
8975 | 8975 |
8976 /** | 8976 /** |
8977 * Create an analysis context that has a fake core library already resolved. | 8977 * Create an analysis context that has a fake core library already resolved. |
8978 * @return the analysis context that was created | 8978 * @return the analysis context that was created |
8979 */ | 8979 */ |
8980 static AnalysisContextImpl contextWithCore() { | 8980 static AnalysisContextImpl contextWithCore() { |
8981 AnalysisContextImpl sdkContext = DirectoryBasedDartSdk.defaultSdk.context as
AnalysisContextImpl; | 8981 AnalysisContextImpl sdkContext = DirectoryBasedDartSdk.defaultSdk.context as
AnalysisContextImpl; |
8982 SourceFactory sourceFactory2 = sdkContext.sourceFactory; | 8982 SourceFactory sourceFactory = sdkContext.sourceFactory; |
8983 TestTypeProvider provider = new TestTypeProvider(); | 8983 TestTypeProvider provider = new TestTypeProvider(); |
8984 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d
art"); | 8984 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d
art"); |
8985 Source coreSource = sourceFactory2.forUri(DartSdk.DART_CORE); | 8985 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); |
8986 sdkContext.setContents(coreSource, ""); | 8986 sdkContext.setContents(coreSource, ""); |
8987 coreUnit.source = coreSource; | 8987 coreUnit.source = coreSource; |
8988 coreUnit.types = <ClassElement> [provider.boolType.element, provider.doubleT
ype.element, provider.functionType.element, provider.intType.element, provider.l
istType.element, provider.mapType.element, provider.numType.element, provider.ob
jectType.element, provider.stackTraceType.element, provider.stringType.element,
provider.typeType.element]; | 8988 coreUnit.types = <ClassElement> [provider.boolType.element, provider.doubleT
ype.element, provider.functionType.element, provider.intType.element, provider.l
istType.element, provider.mapType.element, provider.numType.element, provider.ob
jectType.element, provider.stackTraceType.element, provider.stringType.element,
provider.typeType.element]; |
8989 LibraryElementImpl coreLibrary = new LibraryElementImpl(sdkContext, ASTFacto
ry.libraryIdentifier2(["dart", "core"])); | 8989 LibraryElementImpl coreLibrary = new LibraryElementImpl(sdkContext, ASTFacto
ry.libraryIdentifier2(["dart", "core"])); |
8990 coreLibrary.definingCompilationUnit = coreUnit; | 8990 coreLibrary.definingCompilationUnit = coreUnit; |
8991 CompilationUnitElementImpl htmlUnit = new CompilationUnitElementImpl("html_d
artium.dart"); | 8991 CompilationUnitElementImpl htmlUnit = new CompilationUnitElementImpl("html_d
artium.dart"); |
8992 Source htmlSource = sourceFactory2.forUri(DartSdk.DART_HTML); | 8992 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); |
8993 sdkContext.setContents(htmlSource, ""); | 8993 sdkContext.setContents(htmlSource, ""); |
8994 htmlUnit.source = htmlSource; | 8994 htmlUnit.source = htmlSource; |
8995 ClassElementImpl elementElement = ElementFactory.classElement2("Element", []
); | 8995 ClassElementImpl elementElement = ElementFactory.classElement2("Element", []
); |
8996 InterfaceType elementType = elementElement.type; | 8996 InterfaceType elementType = elementElement.type; |
8997 ClassElementImpl documentElement = ElementFactory.classElement("Document", e
lementType, []); | 8997 ClassElementImpl documentElement = ElementFactory.classElement("Document", e
lementType, []); |
8998 ClassElementImpl htmlDocumentElement = ElementFactory.classElement("HtmlDocu
ment", documentElement.type, []); | 8998 ClassElementImpl htmlDocumentElement = ElementFactory.classElement("HtmlDocu
ment", documentElement.type, []); |
8999 htmlDocumentElement.methods = <MethodElement> [ElementFactory.methodElement(
"query", elementType, <Type2> [provider.stringType])]; | 8999 htmlDocumentElement.methods = <MethodElement> [ElementFactory.methodElement(
"query", elementType, <Type2> [provider.stringType])]; |
9000 htmlUnit.types = <ClassElement> [ElementFactory.classElement("AnchorElement"
, elementType, []), ElementFactory.classElement("BodyElement", elementType, []),
ElementFactory.classElement("ButtonElement", elementType, []), ElementFactory.c
lassElement("DivElement", elementType, []), documentElement, elementElement, htm
lDocumentElement, ElementFactory.classElement("InputElement", elementType, []),
ElementFactory.classElement("SelectElement", elementType, [])]; | 9000 htmlUnit.types = <ClassElement> [ElementFactory.classElement("AnchorElement"
, elementType, []), ElementFactory.classElement("BodyElement", elementType, []),
ElementFactory.classElement("ButtonElement", elementType, []), ElementFactory.c
lassElement("DivElement", elementType, []), documentElement, elementElement, htm
lDocumentElement, ElementFactory.classElement("InputElement", elementType, []),
ElementFactory.classElement("SelectElement", elementType, [])]; |
9001 htmlUnit.functions = <FunctionElement> [ElementFactory.functionElement3("que
ry", elementElement, <ClassElement> [provider.stringType.element], ClassElementI
mpl.EMPTY_ARRAY)]; | 9001 htmlUnit.functions = <FunctionElement> [ElementFactory.functionElement3("que
ry", elementElement, <ClassElement> [provider.stringType.element], ClassElementI
mpl.EMPTY_ARRAY)]; |
9002 TopLevelVariableElementImpl document = ElementFactory.topLevelVariableElemen
t3("document", true, htmlDocumentElement.type); | 9002 TopLevelVariableElementImpl document = ElementFactory.topLevelVariableElemen
t3("document", true, htmlDocumentElement.type); |
9003 htmlUnit.topLevelVariables = <TopLevelVariableElement> [document]; | 9003 htmlUnit.topLevelVariables = <TopLevelVariableElement> [document]; |
9004 htmlUnit.accessors = <PropertyAccessorElement> [document.getter]; | 9004 htmlUnit.accessors = <PropertyAccessorElement> [document.getter]; |
9005 LibraryElementImpl htmlLibrary = new LibraryElementImpl(sdkContext, ASTFacto
ry.libraryIdentifier2(["dart", "dom", "html"])); | 9005 LibraryElementImpl htmlLibrary = new LibraryElementImpl(sdkContext, ASTFacto
ry.libraryIdentifier2(["dart", "dom", "html"])); |
9006 htmlLibrary.definingCompilationUnit = htmlUnit; | 9006 htmlLibrary.definingCompilationUnit = htmlUnit; |
9007 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>(); | 9007 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>(); |
9008 elementMap[coreSource] = coreLibrary; | 9008 elementMap[coreSource] = coreLibrary; |
9009 elementMap[htmlSource] = htmlLibrary; | 9009 elementMap[htmlSource] = htmlLibrary; |
9010 sdkContext.recordLibraryElements(elementMap); | 9010 sdkContext.recordLibraryElements(elementMap); |
9011 AnalysisContextImpl context = new DelegatingAnalysisContextImpl(); | 9011 AnalysisContextImpl context = new DelegatingAnalysisContextImpl(); |
9012 sourceFactory2 = new SourceFactory.con2([new DartUriResolver(sdkContext.sour
ceFactory.dartSdk), new FileUriResolver()]); | 9012 sourceFactory = new SourceFactory.con2([new DartUriResolver(sdkContext.sourc
eFactory.dartSdk), new FileUriResolver()]); |
9013 context.sourceFactory = sourceFactory2; | 9013 context.sourceFactory = sourceFactory; |
9014 return context; | 9014 return context; |
9015 } | 9015 } |
9016 } | 9016 } |
9017 class LibraryImportScopeTest extends ResolverTestCase { | 9017 class LibraryImportScopeTest extends ResolverTestCase { |
9018 void test_conflictingImports() { | 9018 void test_conflictingImports() { |
9019 AnalysisContext context = new AnalysisContextImpl(); | 9019 AnalysisContext context = new AnalysisContextImpl(); |
9020 String typeNameA = "A"; | 9020 String typeNameA = "A"; |
9021 String typeNameB = "B"; | 9021 String typeNameB = "B"; |
9022 String typeNameC = "C"; | 9022 String typeNameC = "C"; |
9023 ClassElement typeA = ElementFactory.classElement2(typeNameA, []); | 9023 ClassElement typeA = ElementFactory.classElement2(typeNameA, []); |
(...skipping 11 matching lines...) Expand all Loading... |
9035 { | 9035 { |
9036 GatheringErrorListener errorListener = new GatheringErrorListener(); | 9036 GatheringErrorListener errorListener = new GatheringErrorListener(); |
9037 Scope scope = new LibraryImportScope(importingLibrary, errorListener); | 9037 Scope scope = new LibraryImportScope(importingLibrary, errorListener); |
9038 JUnitTestCase.assertEquals(typeA, scope.lookup(ASTFactory.identifier3(type
NameA), importingLibrary)); | 9038 JUnitTestCase.assertEquals(typeA, scope.lookup(ASTFactory.identifier3(type
NameA), importingLibrary)); |
9039 errorListener.assertNoErrors(); | 9039 errorListener.assertNoErrors(); |
9040 JUnitTestCase.assertEquals(typeC, scope.lookup(ASTFactory.identifier3(type
NameC), importingLibrary)); | 9040 JUnitTestCase.assertEquals(typeC, scope.lookup(ASTFactory.identifier3(type
NameC), importingLibrary)); |
9041 errorListener.assertNoErrors(); | 9041 errorListener.assertNoErrors(); |
9042 Element element = scope.lookup(ASTFactory.identifier3(typeNameB), importin
gLibrary); | 9042 Element element = scope.lookup(ASTFactory.identifier3(typeNameB), importin
gLibrary); |
9043 errorListener.assertErrors2([CompileTimeErrorCode.AMBIGUOUS_IMPORT]); | 9043 errorListener.assertErrors2([CompileTimeErrorCode.AMBIGUOUS_IMPORT]); |
9044 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, element); | 9044 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, element); |
9045 List<Element> conflictingElements2 = ((element as MultiplyDefinedElement))
.conflictingElements; | 9045 List<Element> conflictingElements = ((element as MultiplyDefinedElement)).
conflictingElements; |
9046 JUnitTestCase.assertEquals(typeB1, conflictingElements2[0]); | 9046 JUnitTestCase.assertEquals(typeB1, conflictingElements[0]); |
9047 JUnitTestCase.assertEquals(typeB2, conflictingElements2[1]); | 9047 JUnitTestCase.assertEquals(typeB2, conflictingElements[1]); |
9048 JUnitTestCase.assertEquals(2, conflictingElements2.length); | 9048 JUnitTestCase.assertEquals(2, conflictingElements.length); |
9049 } | 9049 } |
9050 { | 9050 { |
9051 GatheringErrorListener errorListener = new GatheringErrorListener(); | 9051 GatheringErrorListener errorListener = new GatheringErrorListener(); |
9052 Scope scope = new LibraryImportScope(importingLibrary, errorListener); | 9052 Scope scope = new LibraryImportScope(importingLibrary, errorListener); |
9053 Identifier identifier = ASTFactory.identifier3(typeNameB); | 9053 Identifier identifier = ASTFactory.identifier3(typeNameB); |
9054 ASTFactory.methodDeclaration(null, ASTFactory.typeName3(identifier, []), n
ull, null, ASTFactory.identifier3("foo"), null); | 9054 ASTFactory.methodDeclaration(null, ASTFactory.typeName3(identifier, []), n
ull, null, ASTFactory.identifier3("foo"), null); |
9055 Element element = scope.lookup(identifier, importingLibrary); | 9055 Element element = scope.lookup(identifier, importingLibrary); |
9056 errorListener.assertErrors2([StaticWarningCode.AMBIGUOUS_IMPORT]); | 9056 errorListener.assertErrors2([StaticWarningCode.AMBIGUOUS_IMPORT]); |
9057 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, element); | 9057 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, element); |
9058 } | 9058 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9227 _wrongTypedNodes.add(node); | 9227 _wrongTypedNodes.add(node); |
9228 } | 9228 } |
9229 return null; | 9229 return null; |
9230 } | 9230 } |
9231 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { | 9231 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
9232 node.visitChildren(this); | 9232 node.visitChildren(this); |
9233 return checkResolved2(node, node.element, FunctionElement); | 9233 return checkResolved2(node, node.element, FunctionElement); |
9234 } | 9234 } |
9235 Object visitImportDirective(ImportDirective node) { | 9235 Object visitImportDirective(ImportDirective node) { |
9236 checkResolved2(node, node.element, ImportElement); | 9236 checkResolved2(node, node.element, ImportElement); |
9237 SimpleIdentifier prefix2 = node.prefix; | 9237 SimpleIdentifier prefix = node.prefix; |
9238 if (prefix2 == null) { | 9238 if (prefix == null) { |
9239 return null; | 9239 return null; |
9240 } | 9240 } |
9241 return checkResolved2(prefix2, prefix2.element, PrefixElement); | 9241 return checkResolved2(prefix, prefix.element, PrefixElement); |
9242 } | 9242 } |
9243 Object visitIndexExpression(IndexExpression node) { | 9243 Object visitIndexExpression(IndexExpression node) { |
9244 node.visitChildren(this); | 9244 node.visitChildren(this); |
9245 return checkResolved2(node, node.element, MethodElement); | 9245 return checkResolved2(node, node.element, MethodElement); |
9246 } | 9246 } |
9247 Object visitLibraryDirective(LibraryDirective node) => checkResolved2(node, no
de.element, LibraryElement); | 9247 Object visitLibraryDirective(LibraryDirective node) => checkResolved2(node, no
de.element, LibraryElement); |
9248 Object visitPartDirective(PartDirective node) => checkResolved2(node, node.ele
ment, CompilationUnitElement); | 9248 Object visitPartDirective(PartDirective node) => checkResolved2(node, node.ele
ment, CompilationUnitElement); |
9249 Object visitPartOfDirective(PartOfDirective node) => checkResolved2(node, node
.element, LibraryElement); | 9249 Object visitPartOfDirective(PartOfDirective node) => checkResolved2(node, node
.element, LibraryElement); |
9250 Object visitPostfixExpression(PostfixExpression node) { | 9250 Object visitPostfixExpression(PostfixExpression node) { |
9251 node.visitChildren(this); | 9251 node.visitChildren(this); |
(...skipping 26 matching lines...) Expand all Loading... |
9278 } | 9278 } |
9279 } else if (expectedClass != null) { | 9279 } else if (expectedClass != null) { |
9280 if (!isInstanceOf(element, expectedClass)) { | 9280 if (!isInstanceOf(element, expectedClass)) { |
9281 _wrongTypedNodes.add(node); | 9281 _wrongTypedNodes.add(node); |
9282 } | 9282 } |
9283 } | 9283 } |
9284 return null; | 9284 return null; |
9285 } | 9285 } |
9286 String getFileName(ASTNode node) { | 9286 String getFileName(ASTNode node) { |
9287 if (node != null) { | 9287 if (node != null) { |
9288 ASTNode root2 = node.root; | 9288 ASTNode root = node.root; |
9289 if (root2 is CompilationUnit) { | 9289 if (root is CompilationUnit) { |
9290 CompilationUnit rootCU = (root2 as CompilationUnit); | 9290 CompilationUnit rootCU = (root as CompilationUnit); |
9291 if (rootCU.element != null) { | 9291 if (rootCU.element != null) { |
9292 return rootCU.element.source.fullName; | 9292 return rootCU.element.source.fullName; |
9293 } else { | 9293 } else { |
9294 return "<unknown file- CompilationUnit.getElement() returned null>"; | 9294 return "<unknown file- CompilationUnit.getElement() returned null>"; |
9295 } | 9295 } |
9296 } else { | 9296 } else { |
9297 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni
t>"; | 9297 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni
t>"; |
9298 } | 9298 } |
9299 } | 9299 } |
9300 return "<unknown file- ASTNode is null>"; | 9300 return "<unknown file- ASTNode is null>"; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9414 } | 9414 } |
9415 void test_visitAsExpression() { | 9415 void test_visitAsExpression() { |
9416 ClassElement superclass = ElementFactory.classElement2("A", []); | 9416 ClassElement superclass = ElementFactory.classElement2("A", []); |
9417 InterfaceType superclassType = superclass.type; | 9417 InterfaceType superclassType = superclass.type; |
9418 ClassElement subclass = ElementFactory.classElement("B", superclassType, [])
; | 9418 ClassElement subclass = ElementFactory.classElement("B", superclassType, [])
; |
9419 Expression node = ASTFactory.asExpression(ASTFactory.thisExpression(), ASTFa
ctory.typeName(subclass, [])); | 9419 Expression node = ASTFactory.asExpression(ASTFactory.thisExpression(), ASTFa
ctory.typeName(subclass, [])); |
9420 JUnitTestCase.assertSame(subclass.type, analyze2(node, superclassType)); | 9420 JUnitTestCase.assertSame(subclass.type, analyze2(node, superclassType)); |
9421 _listener.assertNoErrors(); | 9421 _listener.assertNoErrors(); |
9422 } | 9422 } |
9423 void test_visitAssignmentExpression_compound() { | 9423 void test_visitAssignmentExpression_compound() { |
9424 InterfaceType numType2 = _typeProvider.numType; | 9424 InterfaceType numType = _typeProvider.numType; |
9425 SimpleIdentifier identifier = resolvedVariable(_typeProvider.intType, "i"); | 9425 SimpleIdentifier identifier = resolvedVariable(_typeProvider.intType, "i"); |
9426 AssignmentExpression node = ASTFactory.assignmentExpression(identifier, Toke
nType.PLUS_EQ, resolvedInteger(1)); | 9426 AssignmentExpression node = ASTFactory.assignmentExpression(identifier, Toke
nType.PLUS_EQ, resolvedInteger(1)); |
9427 MethodElement plusMethod = getMethod(numType2, "+"); | 9427 MethodElement plusMethod = getMethod(numType, "+"); |
9428 node.staticElement = plusMethod; | 9428 node.staticElement = plusMethod; |
9429 node.element = plusMethod; | 9429 node.element = plusMethod; |
9430 JUnitTestCase.assertSame(numType2, analyze(node)); | 9430 JUnitTestCase.assertSame(numType, analyze(node)); |
9431 _listener.assertNoErrors(); | 9431 _listener.assertNoErrors(); |
9432 } | 9432 } |
9433 void test_visitAssignmentExpression_simple() { | 9433 void test_visitAssignmentExpression_simple() { |
9434 InterfaceType intType2 = _typeProvider.intType; | 9434 InterfaceType intType = _typeProvider.intType; |
9435 Expression node = ASTFactory.assignmentExpression(resolvedVariable(intType2,
"i"), TokenType.EQ, resolvedInteger(0)); | 9435 Expression node = ASTFactory.assignmentExpression(resolvedVariable(intType,
"i"), TokenType.EQ, resolvedInteger(0)); |
9436 JUnitTestCase.assertSame(intType2, analyze(node)); | 9436 JUnitTestCase.assertSame(intType, analyze(node)); |
9437 _listener.assertNoErrors(); | 9437 _listener.assertNoErrors(); |
9438 } | 9438 } |
9439 void test_visitBinaryExpression_equals() { | 9439 void test_visitBinaryExpression_equals() { |
9440 Expression node = ASTFactory.binaryExpression(resolvedInteger(2), TokenType.
EQ_EQ, resolvedInteger(3)); | 9440 Expression node = ASTFactory.binaryExpression(resolvedInteger(2), TokenType.
EQ_EQ, resolvedInteger(3)); |
9441 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); | 9441 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); |
9442 _listener.assertNoErrors(); | 9442 _listener.assertNoErrors(); |
9443 } | 9443 } |
9444 void test_visitBinaryExpression_logicalAnd() { | 9444 void test_visitBinaryExpression_logicalAnd() { |
9445 Expression node = ASTFactory.binaryExpression(ASTFactory.booleanLiteral(fals
e), TokenType.AMPERSAND_AMPERSAND, ASTFactory.booleanLiteral(true)); | 9445 Expression node = ASTFactory.binaryExpression(ASTFactory.booleanLiteral(fals
e), TokenType.AMPERSAND_AMPERSAND, ASTFactory.booleanLiteral(true)); |
9446 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); | 9446 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9504 Expression node = ASTFactory.conditionalExpression(ASTFactory.booleanLiteral
(true), resolvedInteger(1), resolvedInteger(0)); | 9504 Expression node = ASTFactory.conditionalExpression(ASTFactory.booleanLiteral
(true), resolvedInteger(1), resolvedInteger(0)); |
9505 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); | 9505 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); |
9506 _listener.assertNoErrors(); | 9506 _listener.assertNoErrors(); |
9507 } | 9507 } |
9508 void test_visitDoubleLiteral() { | 9508 void test_visitDoubleLiteral() { |
9509 Expression node = ASTFactory.doubleLiteral(4.33); | 9509 Expression node = ASTFactory.doubleLiteral(4.33); |
9510 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node)); | 9510 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node)); |
9511 _listener.assertNoErrors(); | 9511 _listener.assertNoErrors(); |
9512 } | 9512 } |
9513 void test_visitFunctionExpression_named_block() { | 9513 void test_visitFunctionExpression_named_block() { |
9514 Type2 dynamicType2 = _typeProvider.dynamicType; | 9514 Type2 dynamicType = _typeProvider.dynamicType; |
9515 FormalParameter p1 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p1"), resolvedInteger(0)); | 9515 FormalParameter p1 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p1"), resolvedInteger(0)); |
9516 setType(p1, dynamicType2); | 9516 setType(p1, dynamicType); |
9517 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p2"), resolvedInteger(0)); | 9517 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p2"), resolvedInteger(0)); |
9518 setType(p2, dynamicType2); | 9518 setType(p2, dynamicType); |
9519 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody([])); | 9519 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody([])); |
9520 analyze3(p1); | 9520 analyze3(p1); |
9521 analyze3(p2); | 9521 analyze3(p2); |
9522 Type2 resultType = analyze(node); | 9522 Type2 resultType = analyze(node); |
9523 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); | 9523 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); |
9524 expectedNamedTypes["p1"] = dynamicType2; | 9524 expectedNamedTypes["p1"] = dynamicType; |
9525 expectedNamedTypes["p2"] = dynamicType2; | 9525 expectedNamedTypes["p2"] = dynamicType; |
9526 assertFunctionType(dynamicType2, null, null, expectedNamedTypes, resultType)
; | 9526 assertFunctionType(dynamicType, null, null, expectedNamedTypes, resultType); |
9527 _listener.assertNoErrors(); | 9527 _listener.assertNoErrors(); |
9528 } | 9528 } |
9529 void test_visitFunctionExpression_named_expression() { | 9529 void test_visitFunctionExpression_named_expression() { |
9530 Type2 dynamicType2 = _typeProvider.dynamicType; | 9530 Type2 dynamicType = _typeProvider.dynamicType; |
9531 FormalParameter p = ASTFactory.namedFormalParameter(ASTFactory.simpleFormalP
arameter3("p"), resolvedInteger(0)); | 9531 FormalParameter p = ASTFactory.namedFormalParameter(ASTFactory.simpleFormalP
arameter3("p"), resolvedInteger(0)); |
9532 setType(p, dynamicType2); | 9532 setType(p, dynamicType); |
9533 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); | 9533 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); |
9534 analyze3(p); | 9534 analyze3(p); |
9535 Type2 resultType = analyze(node); | 9535 Type2 resultType = analyze(node); |
9536 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); | 9536 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); |
9537 expectedNamedTypes["p"] = dynamicType2; | 9537 expectedNamedTypes["p"] = dynamicType; |
9538 assertFunctionType(_typeProvider.intType, null, null, expectedNamedTypes, re
sultType); | 9538 assertFunctionType(_typeProvider.intType, null, null, expectedNamedTypes, re
sultType); |
9539 _listener.assertNoErrors(); | 9539 _listener.assertNoErrors(); |
9540 } | 9540 } |
9541 void test_visitFunctionExpression_normal_block() { | 9541 void test_visitFunctionExpression_normal_block() { |
9542 Type2 dynamicType2 = _typeProvider.dynamicType; | 9542 Type2 dynamicType = _typeProvider.dynamicType; |
9543 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); | 9543 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); |
9544 setType(p1, dynamicType2); | 9544 setType(p1, dynamicType); |
9545 FormalParameter p2 = ASTFactory.simpleFormalParameter3("p2"); | 9545 FormalParameter p2 = ASTFactory.simpleFormalParameter3("p2"); |
9546 setType(p2, dynamicType2); | 9546 setType(p2, dynamicType); |
9547 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody([])); | 9547 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody([])); |
9548 analyze3(p1); | 9548 analyze3(p1); |
9549 analyze3(p2); | 9549 analyze3(p2); |
9550 Type2 resultType = analyze(node); | 9550 Type2 resultType = analyze(node); |
9551 assertFunctionType(dynamicType2, <Type2> [dynamicType2, dynamicType2], null,
null, resultType); | 9551 assertFunctionType(dynamicType, <Type2> [dynamicType, dynamicType], null, nu
ll, resultType); |
9552 _listener.assertNoErrors(); | 9552 _listener.assertNoErrors(); |
9553 } | 9553 } |
9554 void test_visitFunctionExpression_normal_expression() { | 9554 void test_visitFunctionExpression_normal_expression() { |
9555 Type2 dynamicType2 = _typeProvider.dynamicType; | 9555 Type2 dynamicType = _typeProvider.dynamicType; |
9556 FormalParameter p = ASTFactory.simpleFormalParameter3("p"); | 9556 FormalParameter p = ASTFactory.simpleFormalParameter3("p"); |
9557 setType(p, dynamicType2); | 9557 setType(p, dynamicType); |
9558 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); | 9558 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); |
9559 analyze3(p); | 9559 analyze3(p); |
9560 Type2 resultType = analyze(node); | 9560 Type2 resultType = analyze(node); |
9561 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType2], null, null
, resultType); | 9561 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType], null, null,
resultType); |
9562 _listener.assertNoErrors(); | 9562 _listener.assertNoErrors(); |
9563 } | 9563 } |
9564 void test_visitFunctionExpression_normalAndNamed_block() { | 9564 void test_visitFunctionExpression_normalAndNamed_block() { |
9565 Type2 dynamicType2 = _typeProvider.dynamicType; | 9565 Type2 dynamicType = _typeProvider.dynamicType; |
9566 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); | 9566 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); |
9567 setType(p1, dynamicType2); | 9567 setType(p1, dynamicType); |
9568 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p2"), resolvedInteger(0)); | 9568 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p2"), resolvedInteger(0)); |
9569 setType(p2, dynamicType2); | 9569 setType(p2, dynamicType); |
9570 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody([])); | 9570 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody([])); |
9571 analyze3(p2); | 9571 analyze3(p2); |
9572 Type2 resultType = analyze(node); | 9572 Type2 resultType = analyze(node); |
9573 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); | 9573 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); |
9574 expectedNamedTypes["p2"] = dynamicType2; | 9574 expectedNamedTypes["p2"] = dynamicType; |
9575 assertFunctionType(dynamicType2, <Type2> [dynamicType2], null, expectedNamed
Types, resultType); | 9575 assertFunctionType(dynamicType, <Type2> [dynamicType], null, expectedNamedTy
pes, resultType); |
9576 _listener.assertNoErrors(); | 9576 _listener.assertNoErrors(); |
9577 } | 9577 } |
9578 void test_visitFunctionExpression_normalAndNamed_expression() { | 9578 void test_visitFunctionExpression_normalAndNamed_expression() { |
9579 Type2 dynamicType2 = _typeProvider.dynamicType; | 9579 Type2 dynamicType = _typeProvider.dynamicType; |
9580 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); | 9580 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); |
9581 setType(p1, dynamicType2); | 9581 setType(p1, dynamicType); |
9582 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p2"), resolvedInteger(0)); | 9582 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p2"), resolvedInteger(0)); |
9583 setType(p2, dynamicType2); | 9583 setType(p2, dynamicType); |
9584 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); | 9584 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); |
9585 analyze3(p2); | 9585 analyze3(p2); |
9586 Type2 resultType = analyze(node); | 9586 Type2 resultType = analyze(node); |
9587 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); | 9587 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); |
9588 expectedNamedTypes["p2"] = dynamicType2; | 9588 expectedNamedTypes["p2"] = dynamicType; |
9589 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType2], null, expe
ctedNamedTypes, resultType); | 9589 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType], null, expec
tedNamedTypes, resultType); |
9590 _listener.assertNoErrors(); | 9590 _listener.assertNoErrors(); |
9591 } | 9591 } |
9592 void test_visitFunctionExpression_normalAndPositional_block() { | 9592 void test_visitFunctionExpression_normalAndPositional_block() { |
9593 Type2 dynamicType2 = _typeProvider.dynamicType; | 9593 Type2 dynamicType = _typeProvider.dynamicType; |
9594 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); | 9594 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); |
9595 setType(p1, dynamicType2); | 9595 setType(p1, dynamicType); |
9596 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p2"), resolvedInteger(0)); | 9596 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p2"), resolvedInteger(0)); |
9597 setType(p2, dynamicType2); | 9597 setType(p2, dynamicType); |
9598 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody([])); | 9598 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody([])); |
9599 analyze3(p1); | 9599 analyze3(p1); |
9600 analyze3(p2); | 9600 analyze3(p2); |
9601 Type2 resultType = analyze(node); | 9601 Type2 resultType = analyze(node); |
9602 assertFunctionType(dynamicType2, <Type2> [dynamicType2], <Type2> [dynamicTyp
e2], null, resultType); | 9602 assertFunctionType(dynamicType, <Type2> [dynamicType], <Type2> [dynamicType]
, null, resultType); |
9603 _listener.assertNoErrors(); | 9603 _listener.assertNoErrors(); |
9604 } | 9604 } |
9605 void test_visitFunctionExpression_normalAndPositional_expression() { | 9605 void test_visitFunctionExpression_normalAndPositional_expression() { |
9606 Type2 dynamicType2 = _typeProvider.dynamicType; | 9606 Type2 dynamicType = _typeProvider.dynamicType; |
9607 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); | 9607 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); |
9608 setType(p1, dynamicType2); | 9608 setType(p1, dynamicType); |
9609 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p2"), resolvedInteger(0)); | 9609 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p2"), resolvedInteger(0)); |
9610 setType(p2, dynamicType2); | 9610 setType(p2, dynamicType); |
9611 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); | 9611 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); |
9612 analyze3(p1); | 9612 analyze3(p1); |
9613 analyze3(p2); | 9613 analyze3(p2); |
9614 Type2 resultType = analyze(node); | 9614 Type2 resultType = analyze(node); |
9615 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType2], <Type2> [d
ynamicType2], null, resultType); | 9615 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType], <Type2> [dy
namicType], null, resultType); |
9616 _listener.assertNoErrors(); | 9616 _listener.assertNoErrors(); |
9617 } | 9617 } |
9618 void test_visitFunctionExpression_positional_block() { | 9618 void test_visitFunctionExpression_positional_block() { |
9619 Type2 dynamicType2 = _typeProvider.dynamicType; | 9619 Type2 dynamicType = _typeProvider.dynamicType; |
9620 FormalParameter p1 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p1"), resolvedInteger(0)); | 9620 FormalParameter p1 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p1"), resolvedInteger(0)); |
9621 setType(p1, dynamicType2); | 9621 setType(p1, dynamicType); |
9622 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p2"), resolvedInteger(0)); | 9622 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p2"), resolvedInteger(0)); |
9623 setType(p2, dynamicType2); | 9623 setType(p2, dynamicType); |
9624 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody([])); | 9624 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody([])); |
9625 analyze3(p1); | 9625 analyze3(p1); |
9626 analyze3(p2); | 9626 analyze3(p2); |
9627 Type2 resultType = analyze(node); | 9627 Type2 resultType = analyze(node); |
9628 assertFunctionType(dynamicType2, null, <Type2> [dynamicType2, dynamicType2],
null, resultType); | 9628 assertFunctionType(dynamicType, null, <Type2> [dynamicType, dynamicType], nu
ll, resultType); |
9629 _listener.assertNoErrors(); | 9629 _listener.assertNoErrors(); |
9630 } | 9630 } |
9631 void test_visitFunctionExpression_positional_expression() { | 9631 void test_visitFunctionExpression_positional_expression() { |
9632 Type2 dynamicType2 = _typeProvider.dynamicType; | 9632 Type2 dynamicType = _typeProvider.dynamicType; |
9633 FormalParameter p = ASTFactory.positionalFormalParameter(ASTFactory.simpleFo
rmalParameter3("p"), resolvedInteger(0)); | 9633 FormalParameter p = ASTFactory.positionalFormalParameter(ASTFactory.simpleFo
rmalParameter3("p"), resolvedInteger(0)); |
9634 setType(p, dynamicType2); | 9634 setType(p, dynamicType); |
9635 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); | 9635 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); |
9636 analyze3(p); | 9636 analyze3(p); |
9637 Type2 resultType = analyze(node); | 9637 Type2 resultType = analyze(node); |
9638 assertFunctionType(_typeProvider.intType, null, <Type2> [dynamicType2], null
, resultType); | 9638 assertFunctionType(_typeProvider.intType, null, <Type2> [dynamicType], null,
resultType); |
9639 _listener.assertNoErrors(); | 9639 _listener.assertNoErrors(); |
9640 } | 9640 } |
9641 void test_visitIndexExpression_getter() { | 9641 void test_visitIndexExpression_getter() { |
9642 InterfaceType listType2 = _typeProvider.listType; | 9642 InterfaceType listType = _typeProvider.listType; |
9643 SimpleIdentifier identifier = resolvedVariable(listType2, "a"); | 9643 SimpleIdentifier identifier = resolvedVariable(listType, "a"); |
9644 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege
r(2)); | 9644 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege
r(2)); |
9645 MethodElement indexMethod = listType2.element.methods[0]; | 9645 MethodElement indexMethod = listType.element.methods[0]; |
9646 node.staticElement = indexMethod; | 9646 node.staticElement = indexMethod; |
9647 node.element = indexMethod; | 9647 node.element = indexMethod; |
9648 JUnitTestCase.assertSame(listType2.typeArguments[0], analyze(node)); | 9648 JUnitTestCase.assertSame(listType.typeArguments[0], analyze(node)); |
9649 _listener.assertNoErrors(); | 9649 _listener.assertNoErrors(); |
9650 } | 9650 } |
9651 void test_visitIndexExpression_setter() { | 9651 void test_visitIndexExpression_setter() { |
9652 InterfaceType listType2 = _typeProvider.listType; | 9652 InterfaceType listType = _typeProvider.listType; |
9653 SimpleIdentifier identifier = resolvedVariable(listType2, "a"); | 9653 SimpleIdentifier identifier = resolvedVariable(listType, "a"); |
9654 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege
r(2)); | 9654 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege
r(2)); |
9655 MethodElement indexMethod = listType2.element.methods[1]; | 9655 MethodElement indexMethod = listType.element.methods[1]; |
9656 node.staticElement = indexMethod; | 9656 node.staticElement = indexMethod; |
9657 node.element = indexMethod; | 9657 node.element = indexMethod; |
9658 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0)); | 9658 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0)); |
9659 JUnitTestCase.assertSame(listType2.typeArguments[0], analyze(node)); | 9659 JUnitTestCase.assertSame(listType.typeArguments[0], analyze(node)); |
9660 _listener.assertNoErrors(); | 9660 _listener.assertNoErrors(); |
9661 } | 9661 } |
9662 void test_visitIndexExpression_typeParameters() { | 9662 void test_visitIndexExpression_typeParameters() { |
9663 InterfaceType intType2 = _typeProvider.intType; | 9663 InterfaceType intType = _typeProvider.intType; |
9664 InterfaceType listType2 = _typeProvider.listType; | 9664 InterfaceType listType = _typeProvider.listType; |
9665 MethodElement methodElement = getMethod(listType2, "[]"); | 9665 MethodElement methodElement = getMethod(listType, "[]"); |
9666 SimpleIdentifier identifier = ASTFactory.identifier3("list"); | 9666 SimpleIdentifier identifier = ASTFactory.identifier3("list"); |
9667 InterfaceType listOfIntType = listType2.substitute5(<Type2> [intType2]); | 9667 InterfaceType listOfIntType = listType.substitute5(<Type2> [intType]); |
9668 identifier.staticType = listOfIntType; | 9668 identifier.staticType = listOfIntType; |
9669 IndexExpression indexExpression2 = ASTFactory.indexExpression(identifier, AS
TFactory.integer(0)); | 9669 IndexExpression indexExpression = ASTFactory.indexExpression(identifier, AST
Factory.integer(0)); |
9670 MethodElement indexMethod = MethodMember.from(methodElement, listOfIntType); | 9670 MethodElement indexMethod = MethodMember.from(methodElement, listOfIntType); |
9671 indexExpression2.staticElement = indexMethod; | 9671 indexExpression.staticElement = indexMethod; |
9672 indexExpression2.element = indexMethod; | 9672 indexExpression.element = indexMethod; |
9673 JUnitTestCase.assertSame(intType2, analyze(indexExpression2)); | 9673 JUnitTestCase.assertSame(intType, analyze(indexExpression)); |
9674 _listener.assertNoErrors(); | 9674 _listener.assertNoErrors(); |
9675 } | 9675 } |
9676 void test_visitIndexExpression_typeParameters_inSetterContext() { | 9676 void test_visitIndexExpression_typeParameters_inSetterContext() { |
9677 InterfaceType intType2 = _typeProvider.intType; | 9677 InterfaceType intType = _typeProvider.intType; |
9678 InterfaceType listType2 = _typeProvider.listType; | 9678 InterfaceType listType = _typeProvider.listType; |
9679 MethodElement methodElement = getMethod(listType2, "[]="); | 9679 MethodElement methodElement = getMethod(listType, "[]="); |
9680 SimpleIdentifier identifier = ASTFactory.identifier3("list"); | 9680 SimpleIdentifier identifier = ASTFactory.identifier3("list"); |
9681 InterfaceType listOfIntType = listType2.substitute5(<Type2> [intType2]); | 9681 InterfaceType listOfIntType = listType.substitute5(<Type2> [intType]); |
9682 identifier.staticType = listOfIntType; | 9682 identifier.staticType = listOfIntType; |
9683 IndexExpression indexExpression2 = ASTFactory.indexExpression(identifier, AS
TFactory.integer(0)); | 9683 IndexExpression indexExpression = ASTFactory.indexExpression(identifier, AST
Factory.integer(0)); |
9684 MethodElement indexMethod = MethodMember.from(methodElement, listOfIntType); | 9684 MethodElement indexMethod = MethodMember.from(methodElement, listOfIntType); |
9685 indexExpression2.staticElement = indexMethod; | 9685 indexExpression.staticElement = indexMethod; |
9686 indexExpression2.element = indexMethod; | 9686 indexExpression.element = indexMethod; |
9687 ASTFactory.assignmentExpression(indexExpression2, TokenType.EQ, ASTFactory.i
nteger(0)); | 9687 ASTFactory.assignmentExpression(indexExpression, TokenType.EQ, ASTFactory.in
teger(0)); |
9688 JUnitTestCase.assertSame(intType2, analyze(indexExpression2)); | 9688 JUnitTestCase.assertSame(intType, analyze(indexExpression)); |
9689 _listener.assertNoErrors(); | 9689 _listener.assertNoErrors(); |
9690 } | 9690 } |
9691 void test_visitInstanceCreationExpression_named() { | 9691 void test_visitInstanceCreationExpression_named() { |
9692 ClassElementImpl classElement = ElementFactory.classElement2("C", []); | 9692 ClassElementImpl classElement = ElementFactory.classElement2("C", []); |
9693 String constructorName = "m"; | 9693 String constructorName = "m"; |
9694 ConstructorElementImpl constructor = ElementFactory.constructorElement(class
Element, constructorName); | 9694 ConstructorElementImpl constructor = ElementFactory.constructorElement(class
Element, constructorName); |
9695 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); | 9695 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); |
9696 constructorType.returnType = classElement.type; | 9696 constructorType.returnType = classElement.type; |
9697 constructor.type = constructorType; | 9697 constructor.type = constructorType; |
9698 classElement.constructors = <ConstructorElement> [constructor]; | 9698 classElement.constructors = <ConstructorElement> [constructor]; |
9699 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul
l, ASTFactory.typeName(classElement, []), [ASTFactory.identifier3(constructorNam
e)]); | 9699 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul
l, ASTFactory.typeName(classElement, []), [ASTFactory.identifier3(constructorNam
e)]); |
9700 node.element = constructor; | 9700 node.element = constructor; |
9701 JUnitTestCase.assertSame(classElement.type, analyze(node)); | 9701 JUnitTestCase.assertSame(classElement.type, analyze(node)); |
9702 _listener.assertNoErrors(); | 9702 _listener.assertNoErrors(); |
9703 } | 9703 } |
9704 void test_visitInstanceCreationExpression_typeParameters() { | 9704 void test_visitInstanceCreationExpression_typeParameters() { |
9705 ClassElementImpl elementC = ElementFactory.classElement2("C", ["E"]); | 9705 ClassElementImpl elementC = ElementFactory.classElement2("C", ["E"]); |
9706 ClassElementImpl elementI = ElementFactory.classElement2("I", []); | 9706 ClassElementImpl elementI = ElementFactory.classElement2("I", []); |
9707 ConstructorElementImpl constructor = ElementFactory.constructorElement(eleme
ntC, null); | 9707 ConstructorElementImpl constructor = ElementFactory.constructorElement(eleme
ntC, null); |
9708 elementC.constructors = <ConstructorElement> [constructor]; | 9708 elementC.constructors = <ConstructorElement> [constructor]; |
9709 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); | 9709 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); |
9710 constructorType.returnType = elementC.type; | 9710 constructorType.returnType = elementC.type; |
9711 constructor.type = constructorType; | 9711 constructor.type = constructorType; |
9712 TypeName typeName2 = ASTFactory.typeName(elementC, [ASTFactory.typeName(elem
entI, [])]); | 9712 TypeName typeName = ASTFactory.typeName(elementC, [ASTFactory.typeName(eleme
ntI, [])]); |
9713 typeName2.type = elementC.type.substitute5(<Type2> [elementI.type]); | 9713 typeName.type = elementC.type.substitute5(<Type2> [elementI.type]); |
9714 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul
l, typeName2, []); | 9714 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul
l, typeName, []); |
9715 node.element = constructor; | 9715 node.element = constructor; |
9716 InterfaceType interfaceType = analyze(node) as InterfaceType; | 9716 InterfaceType interfaceType = analyze(node) as InterfaceType; |
9717 List<Type2> typeArgs = interfaceType.typeArguments; | 9717 List<Type2> typeArgs = interfaceType.typeArguments; |
9718 JUnitTestCase.assertEquals(1, typeArgs.length); | 9718 JUnitTestCase.assertEquals(1, typeArgs.length); |
9719 JUnitTestCase.assertEquals(elementI.type, typeArgs[0]); | 9719 JUnitTestCase.assertEquals(elementI.type, typeArgs[0]); |
9720 _listener.assertNoErrors(); | 9720 _listener.assertNoErrors(); |
9721 } | 9721 } |
9722 void test_visitInstanceCreationExpression_unnamed() { | 9722 void test_visitInstanceCreationExpression_unnamed() { |
9723 ClassElementImpl classElement = ElementFactory.classElement2("C", []); | 9723 ClassElementImpl classElement = ElementFactory.classElement2("C", []); |
9724 ConstructorElementImpl constructor = ElementFactory.constructorElement(class
Element, null); | 9724 ConstructorElementImpl constructor = ElementFactory.constructorElement(class
Element, null); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9789 PostfixExpression node = ASTFactory.postfixExpression(resolvedInteger(0), To
kenType.MINUS_MINUS); | 9789 PostfixExpression node = ASTFactory.postfixExpression(resolvedInteger(0), To
kenType.MINUS_MINUS); |
9790 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); | 9790 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); |
9791 _listener.assertNoErrors(); | 9791 _listener.assertNoErrors(); |
9792 } | 9792 } |
9793 void test_visitPostfixExpression_plusPlus() { | 9793 void test_visitPostfixExpression_plusPlus() { |
9794 PostfixExpression node = ASTFactory.postfixExpression(resolvedInteger(0), To
kenType.PLUS_PLUS); | 9794 PostfixExpression node = ASTFactory.postfixExpression(resolvedInteger(0), To
kenType.PLUS_PLUS); |
9795 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); | 9795 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); |
9796 _listener.assertNoErrors(); | 9796 _listener.assertNoErrors(); |
9797 } | 9797 } |
9798 void test_visitPrefixedIdentifier_getter() { | 9798 void test_visitPrefixedIdentifier_getter() { |
9799 Type2 boolType2 = _typeProvider.boolType; | 9799 Type2 boolType = _typeProvider.boolType; |
9800 PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false
, boolType2); | 9800 PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false
, boolType); |
9801 PrefixedIdentifier node = ASTFactory.identifier5("a", "b"); | 9801 PrefixedIdentifier node = ASTFactory.identifier5("a", "b"); |
9802 node.identifier.element = getter; | 9802 node.identifier.element = getter; |
9803 JUnitTestCase.assertSame(boolType2, analyze(node)); | 9803 JUnitTestCase.assertSame(boolType, analyze(node)); |
9804 _listener.assertNoErrors(); | 9804 _listener.assertNoErrors(); |
9805 } | 9805 } |
9806 void test_visitPrefixedIdentifier_setter() { | 9806 void test_visitPrefixedIdentifier_setter() { |
9807 Type2 boolType2 = _typeProvider.boolType; | 9807 Type2 boolType = _typeProvider.boolType; |
9808 FieldElementImpl field = ElementFactory.fieldElement("b", false, false, fals
e, boolType2); | 9808 FieldElementImpl field = ElementFactory.fieldElement("b", false, false, fals
e, boolType); |
9809 PropertyAccessorElement setter2 = field.setter; | 9809 PropertyAccessorElement setter = field.setter; |
9810 PrefixedIdentifier node = ASTFactory.identifier5("a", "b"); | 9810 PrefixedIdentifier node = ASTFactory.identifier5("a", "b"); |
9811 node.identifier.element = setter2; | 9811 node.identifier.element = setter; |
9812 JUnitTestCase.assertSame(boolType2, analyze(node)); | 9812 JUnitTestCase.assertSame(boolType, analyze(node)); |
9813 _listener.assertNoErrors(); | 9813 _listener.assertNoErrors(); |
9814 } | 9814 } |
9815 void test_visitPrefixedIdentifier_variable() { | 9815 void test_visitPrefixedIdentifier_variable() { |
9816 VariableElementImpl variable = ElementFactory.localVariableElement2("b"); | 9816 VariableElementImpl variable = ElementFactory.localVariableElement2("b"); |
9817 variable.type = _typeProvider.boolType; | 9817 variable.type = _typeProvider.boolType; |
9818 PrefixedIdentifier node = ASTFactory.identifier5("a", "b"); | 9818 PrefixedIdentifier node = ASTFactory.identifier5("a", "b"); |
9819 node.identifier.element = variable; | 9819 node.identifier.element = variable; |
9820 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); | 9820 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); |
9821 _listener.assertNoErrors(); | 9821 _listener.assertNoErrors(); |
9822 } | 9822 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9856 } | 9856 } |
9857 void test_visitPrefixExpression_tilde() { | 9857 void test_visitPrefixExpression_tilde() { |
9858 PrefixExpression node = ASTFactory.prefixExpression(TokenType.TILDE, resolve
dInteger(0)); | 9858 PrefixExpression node = ASTFactory.prefixExpression(TokenType.TILDE, resolve
dInteger(0)); |
9859 MethodElement tildeMethod = getMethod(_typeProvider.intType, "~"); | 9859 MethodElement tildeMethod = getMethod(_typeProvider.intType, "~"); |
9860 node.staticElement = tildeMethod; | 9860 node.staticElement = tildeMethod; |
9861 node.element = tildeMethod; | 9861 node.element = tildeMethod; |
9862 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); | 9862 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); |
9863 _listener.assertNoErrors(); | 9863 _listener.assertNoErrors(); |
9864 } | 9864 } |
9865 void test_visitPropertyAccess_getter() { | 9865 void test_visitPropertyAccess_getter() { |
9866 Type2 boolType2 = _typeProvider.boolType; | 9866 Type2 boolType = _typeProvider.boolType; |
9867 PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false
, boolType2); | 9867 PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false
, boolType); |
9868 PropertyAccess node = ASTFactory.propertyAccess2(ASTFactory.identifier3("a")
, "b"); | 9868 PropertyAccess node = ASTFactory.propertyAccess2(ASTFactory.identifier3("a")
, "b"); |
9869 node.propertyName.element = getter; | 9869 node.propertyName.element = getter; |
9870 JUnitTestCase.assertSame(boolType2, analyze(node)); | 9870 JUnitTestCase.assertSame(boolType, analyze(node)); |
9871 _listener.assertNoErrors(); | 9871 _listener.assertNoErrors(); |
9872 } | 9872 } |
9873 void test_visitPropertyAccess_setter() { | 9873 void test_visitPropertyAccess_setter() { |
9874 Type2 boolType2 = _typeProvider.boolType; | 9874 Type2 boolType = _typeProvider.boolType; |
9875 FieldElementImpl field = ElementFactory.fieldElement("b", false, false, fals
e, boolType2); | 9875 FieldElementImpl field = ElementFactory.fieldElement("b", false, false, fals
e, boolType); |
9876 PropertyAccessorElement setter2 = field.setter; | 9876 PropertyAccessorElement setter = field.setter; |
9877 PropertyAccess node = ASTFactory.propertyAccess2(ASTFactory.identifier3("a")
, "b"); | 9877 PropertyAccess node = ASTFactory.propertyAccess2(ASTFactory.identifier3("a")
, "b"); |
9878 node.propertyName.element = setter2; | 9878 node.propertyName.element = setter; |
9879 JUnitTestCase.assertSame(boolType2, analyze(node)); | 9879 JUnitTestCase.assertSame(boolType, analyze(node)); |
9880 _listener.assertNoErrors(); | 9880 _listener.assertNoErrors(); |
9881 } | 9881 } |
9882 void test_visitSimpleStringLiteral() { | 9882 void test_visitSimpleStringLiteral() { |
9883 Expression node = resolvedString("a"); | 9883 Expression node = resolvedString("a"); |
9884 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node)); | 9884 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node)); |
9885 _listener.assertNoErrors(); | 9885 _listener.assertNoErrors(); |
9886 } | 9886 } |
9887 void test_visitStringInterpolation() { | 9887 void test_visitStringInterpolation() { |
9888 Expression node = ASTFactory.string([ASTFactory.interpolationString("a", "a"
), ASTFactory.interpolationExpression(resolvedString("b")), ASTFactory.interpola
tionString("c", "c")]); | 9888 Expression node = ASTFactory.string([ASTFactory.interpolationString("a", "a"
), ASTFactory.interpolationExpression(resolvedString("b")), ASTFactory.interpola
tionString("c", "c")]); |
9889 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node)); | 9889 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node)); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9988 for (MapEntry<String, Type2> entry in getMapEntrySet(expectedNamedTypes))
{ | 9988 for (MapEntry<String, Type2> entry in getMapEntrySet(expectedNamedTypes))
{ |
9989 JUnitTestCase.assertSame(entry.getValue(), namedTypes[entry.getKey()]); | 9989 JUnitTestCase.assertSame(entry.getValue(), namedTypes[entry.getKey()]); |
9990 } | 9990 } |
9991 } | 9991 } |
9992 JUnitTestCase.assertSame(expectedReturnType, functionType.returnType); | 9992 JUnitTestCase.assertSame(expectedReturnType, functionType.returnType); |
9993 } | 9993 } |
9994 void assertType(InterfaceTypeImpl expectedType, InterfaceTypeImpl actualType)
{ | 9994 void assertType(InterfaceTypeImpl expectedType, InterfaceTypeImpl actualType)
{ |
9995 JUnitTestCase.assertEquals(expectedType.displayName, actualType.displayName)
; | 9995 JUnitTestCase.assertEquals(expectedType.displayName, actualType.displayName)
; |
9996 JUnitTestCase.assertEquals(expectedType.element, actualType.element); | 9996 JUnitTestCase.assertEquals(expectedType.element, actualType.element); |
9997 List<Type2> expectedArguments = expectedType.typeArguments; | 9997 List<Type2> expectedArguments = expectedType.typeArguments; |
9998 int length2 = expectedArguments.length; | 9998 int length = expectedArguments.length; |
9999 List<Type2> actualArguments = actualType.typeArguments; | 9999 List<Type2> actualArguments = actualType.typeArguments; |
10000 EngineTestCase.assertLength(length2, actualArguments); | 10000 EngineTestCase.assertLength(length, actualArguments); |
10001 for (int i = 0; i < length2; i++) { | 10001 for (int i = 0; i < length; i++) { |
10002 assertType2(expectedArguments[i], actualArguments[i]); | 10002 assertType2(expectedArguments[i], actualArguments[i]); |
10003 } | 10003 } |
10004 } | 10004 } |
10005 void assertType2(Type2 expectedType, Type2 actualType) { | 10005 void assertType2(Type2 expectedType, Type2 actualType) { |
10006 if (expectedType is InterfaceTypeImpl) { | 10006 if (expectedType is InterfaceTypeImpl) { |
10007 EngineTestCase.assertInstanceOf(InterfaceTypeImpl, actualType); | 10007 EngineTestCase.assertInstanceOf(InterfaceTypeImpl, actualType); |
10008 assertType((expectedType as InterfaceTypeImpl), (actualType as InterfaceTy
peImpl)); | 10008 assertType((expectedType as InterfaceTypeImpl), (actualType as InterfaceTy
peImpl)); |
10009 } | 10009 } |
10010 } | 10010 } |
10011 | 10011 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10110 node.staticElement = element2; | 10110 node.staticElement = element2; |
10111 node.element = element2; | 10111 node.element = element2; |
10112 } | 10112 } |
10113 | 10113 |
10114 /** | 10114 /** |
10115 * Set the type of the given parameter to the given type. | 10115 * Set the type of the given parameter to the given type. |
10116 * @param parameter the parameter whose type is to be set | 10116 * @param parameter the parameter whose type is to be set |
10117 * @param type the new type of the given parameter | 10117 * @param type the new type of the given parameter |
10118 */ | 10118 */ |
10119 void setType(FormalParameter parameter, Type2 type2) { | 10119 void setType(FormalParameter parameter, Type2 type2) { |
10120 SimpleIdentifier identifier2 = parameter.identifier; | 10120 SimpleIdentifier identifier = parameter.identifier; |
10121 Element element2 = identifier2.element; | 10121 Element element = identifier.element; |
10122 if (element2 is! ParameterElement) { | 10122 if (element is! ParameterElement) { |
10123 element2 = new ParameterElementImpl(identifier2); | 10123 element = new ParameterElementImpl(identifier); |
10124 identifier2.element = element2; | 10124 identifier.element = element; |
10125 } | 10125 } |
10126 ((element2 as ParameterElementImpl)).type = type2; | 10126 ((element as ParameterElementImpl)).type = type2; |
10127 } | 10127 } |
10128 static dartSuite() { | 10128 static dartSuite() { |
10129 _ut.group('StaticTypeAnalyzerTest', () { | 10129 _ut.group('StaticTypeAnalyzerTest', () { |
10130 _ut.test('test_visitAdjacentStrings', () { | 10130 _ut.test('test_visitAdjacentStrings', () { |
10131 final __test = new StaticTypeAnalyzerTest(); | 10131 final __test = new StaticTypeAnalyzerTest(); |
10132 runJUnitTest(__test, __test.test_visitAdjacentStrings); | 10132 runJUnitTest(__test, __test.test_visitAdjacentStrings); |
10133 }); | 10133 }); |
10134 _ut.test('test_visitArgumentDefinitionTest', () { | 10134 _ut.test('test_visitArgumentDefinitionTest', () { |
10135 final __test = new StaticTypeAnalyzerTest(); | 10135 final __test = new StaticTypeAnalyzerTest(); |
10136 runJUnitTest(__test, __test.test_visitArgumentDefinitionTest); | 10136 runJUnitTest(__test, __test.test_visitArgumentDefinitionTest); |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10540 return source; | 10540 return source; |
10541 } | 10541 } |
10542 | 10542 |
10543 /** | 10543 /** |
10544 * Ensure that there are elements representing all of the types in the given a
rray of type names. | 10544 * Ensure that there are elements representing all of the types in the given a
rray of type names. |
10545 * @param unit the compilation unit containing the types | 10545 * @param unit the compilation unit containing the types |
10546 * @param typeNames the names of the types that should be found | 10546 * @param typeNames the names of the types that should be found |
10547 */ | 10547 */ |
10548 void assertTypes(CompilationUnitElement unit, List<String> typeNames) { | 10548 void assertTypes(CompilationUnitElement unit, List<String> typeNames) { |
10549 JUnitTestCase.assertNotNull(unit); | 10549 JUnitTestCase.assertNotNull(unit); |
10550 List<ClassElement> types2 = unit.types; | 10550 List<ClassElement> types = unit.types; |
10551 EngineTestCase.assertLength(typeNames.length, types2); | 10551 EngineTestCase.assertLength(typeNames.length, types); |
10552 for (ClassElement type in types2) { | 10552 for (ClassElement type in types) { |
10553 JUnitTestCase.assertNotNull(type); | 10553 JUnitTestCase.assertNotNull(type); |
10554 String actualTypeName = type.displayName; | 10554 String actualTypeName = type.displayName; |
10555 bool wasExpected = false; | 10555 bool wasExpected = false; |
10556 for (String expectedTypeName in typeNames) { | 10556 for (String expectedTypeName in typeNames) { |
10557 if (expectedTypeName == actualTypeName) { | 10557 if (expectedTypeName == actualTypeName) { |
10558 wasExpected = true; | 10558 wasExpected = true; |
10559 } | 10559 } |
10560 } | 10560 } |
10561 if (!wasExpected) { | 10561 if (!wasExpected) { |
10562 JUnitTestCase.fail("Found unexpected type ${actualTypeName}"); | 10562 JUnitTestCase.fail("Found unexpected type ${actualTypeName}"); |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11038 * error can be denoted by including a negative index in the array of indices. | 11038 * error can be denoted by including a negative index in the array of indices. |
11039 * @param source the source to be resolved | 11039 * @param source the source to be resolved |
11040 * @param indices the array of indices used to associate arguments with parame
ters | 11040 * @param indices the array of indices used to associate arguments with parame
ters |
11041 * @throws Exception if the source could not be resolved or if the structure o
f the source is not | 11041 * @throws Exception if the source could not be resolved or if the structure o
f the source is not |
11042 * valid | 11042 * valid |
11043 */ | 11043 */ |
11044 void validateArgumentResolution(Source source, List<int> indices) { | 11044 void validateArgumentResolution(Source source, List<int> indices) { |
11045 LibraryElement library = resolve(source); | 11045 LibraryElement library = resolve(source); |
11046 JUnitTestCase.assertNotNull(library); | 11046 JUnitTestCase.assertNotNull(library); |
11047 ClassElement classElement = library.definingCompilationUnit.types[0]; | 11047 ClassElement classElement = library.definingCompilationUnit.types[0]; |
11048 List<ParameterElement> parameters2 = classElement.methods[1].parameters; | 11048 List<ParameterElement> parameters = classElement.methods[1].parameters; |
11049 CompilationUnit unit = resolveCompilationUnit(source, library); | 11049 CompilationUnit unit = resolveCompilationUnit(source, library); |
11050 JUnitTestCase.assertNotNull(unit); | 11050 JUnitTestCase.assertNotNull(unit); |
11051 ClassDeclaration classDeclaration = unit.declarations[0] as ClassDeclaration
; | 11051 ClassDeclaration classDeclaration = unit.declarations[0] as ClassDeclaration
; |
11052 MethodDeclaration methodDeclaration = (classDeclaration.members[0] as Method
Declaration); | 11052 MethodDeclaration methodDeclaration = (classDeclaration.members[0] as Method
Declaration); |
11053 Block block2 = ((methodDeclaration.body as BlockFunctionBody)).block; | 11053 Block block = ((methodDeclaration.body as BlockFunctionBody)).block; |
11054 ExpressionStatement statement = block2.statements[0] as ExpressionStatement; | 11054 ExpressionStatement statement = block.statements[0] as ExpressionStatement; |
11055 MethodInvocation invocation = statement.expression as MethodInvocation; | 11055 MethodInvocation invocation = statement.expression as MethodInvocation; |
11056 NodeList<Expression> arguments2 = invocation.argumentList.arguments; | 11056 NodeList<Expression> arguments = invocation.argumentList.arguments; |
11057 int argumentCount = arguments2.length; | 11057 int argumentCount = arguments.length; |
11058 JUnitTestCase.assertEquals(indices.length, argumentCount); | 11058 JUnitTestCase.assertEquals(indices.length, argumentCount); |
11059 for (int i = 0; i < argumentCount; i++) { | 11059 for (int i = 0; i < argumentCount; i++) { |
11060 Expression argument = arguments2[i]; | 11060 Expression argument = arguments[i]; |
11061 ParameterElement element = argument.staticParameterElement; | 11061 ParameterElement element = argument.staticParameterElement; |
11062 int index = indices[i]; | 11062 int index = indices[i]; |
11063 if (index < 0) { | 11063 if (index < 0) { |
11064 JUnitTestCase.assertNull(element); | 11064 JUnitTestCase.assertNull(element); |
11065 } else { | 11065 } else { |
11066 JUnitTestCase.assertSame(parameters2[index], element); | 11066 JUnitTestCase.assertSame(parameters[index], element); |
11067 } | 11067 } |
11068 } | 11068 } |
11069 } | 11069 } |
11070 static dartSuite() { | 11070 static dartSuite() { |
11071 _ut.group('SimpleResolverTest', () { | 11071 _ut.group('SimpleResolverTest', () { |
11072 _ut.test('test_argumentResolution_requiredAndNamed_extra', () { | 11072 _ut.test('test_argumentResolution_requiredAndNamed_extra', () { |
11073 final __test = new SimpleResolverTest(); | 11073 final __test = new SimpleResolverTest(); |
11074 runJUnitTest(__test, __test.test_argumentResolution_requiredAndNamed_ext
ra); | 11074 runJUnitTest(__test, __test.test_argumentResolution_requiredAndNamed_ext
ra); |
11075 }); | 11075 }); |
11076 _ut.test('test_argumentResolution_requiredAndNamed_matching', () { | 11076 _ut.test('test_argumentResolution_requiredAndNamed_matching', () { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11242 runJUnitTest(__test, __test.test_setter_inherited); | 11242 runJUnitTest(__test, __test.test_setter_inherited); |
11243 }); | 11243 }); |
11244 _ut.test('test_setter_static', () { | 11244 _ut.test('test_setter_static', () { |
11245 final __test = new SimpleResolverTest(); | 11245 final __test = new SimpleResolverTest(); |
11246 runJUnitTest(__test, __test.test_setter_static); | 11246 runJUnitTest(__test, __test.test_setter_static); |
11247 }); | 11247 }); |
11248 }); | 11248 }); |
11249 } | 11249 } |
11250 } | 11250 } |
11251 main() { | 11251 main() { |
11252 // ElementResolverTest.dartSuite(); | 11252 ElementResolverTest.dartSuite(); |
11253 // InheritanceManagerTest.dartSuite(); | 11253 InheritanceManagerTest.dartSuite(); |
11254 // LibraryElementBuilderTest.dartSuite(); | 11254 LibraryElementBuilderTest.dartSuite(); |
11255 // LibraryTest.dartSuite(); | 11255 LibraryTest.dartSuite(); |
11256 // StaticTypeAnalyzerTest.dartSuite(); | 11256 StaticTypeAnalyzerTest.dartSuite(); |
11257 // TypeOverrideManagerTest.dartSuite(); | 11257 TypeOverrideManagerTest.dartSuite(); |
11258 // TypeProviderImplTest.dartSuite(); | 11258 TypeProviderImplTest.dartSuite(); |
11259 // TypeResolverVisitorTest.dartSuite(); | 11259 TypeResolverVisitorTest.dartSuite(); |
11260 // EnclosedScopeTest.dartSuite(); | 11260 EnclosedScopeTest.dartSuite(); |
11261 // LibraryImportScopeTest.dartSuite(); | 11261 LibraryImportScopeTest.dartSuite(); |
11262 // LibraryScopeTest.dartSuite(); | 11262 LibraryScopeTest.dartSuite(); |
11263 // ScopeTest.dartSuite(); | 11263 ScopeTest.dartSuite(); |
11264 // CompileTimeErrorCodeTest.dartSuite(); | 11264 CompileTimeErrorCodeTest.dartSuite(); |
11265 // ErrorResolverTest.dartSuite(); | 11265 ErrorResolverTest.dartSuite(); |
11266 // NonErrorResolverTest.dartSuite(); | 11266 NonErrorResolverTest.dartSuite(); |
11267 // PubSuggestionCodeTest.dartSuite(); | 11267 PubSuggestionCodeTest.dartSuite(); |
11268 // SimpleResolverTest.dartSuite(); | 11268 SimpleResolverTest.dartSuite(); |
11269 // StaticTypeWarningCodeTest.dartSuite(); | 11269 StaticTypeWarningCodeTest.dartSuite(); |
11270 // StaticWarningCodeTest.dartSuite(); | 11270 StaticWarningCodeTest.dartSuite(); |
11271 // StrictModeTest.dartSuite(); | 11271 StrictModeTest.dartSuite(); |
11272 // TypePropagationTest.dartSuite(); | 11272 TypePropagationTest.dartSuite(); |
11273 } | 11273 } |
OLD | NEW |