OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'package:async_helper/async_helper.dart'; | 5 import 'package:async_helper/async_helper.dart'; |
6 import 'package:compiler/src/common_elements.dart'; | 6 import 'package:compiler/src/common_elements.dart'; |
7 import 'package:compiler/src/compiler.dart'; | 7 import 'package:compiler/src/compiler.dart'; |
8 import 'package:compiler/src/elements/entities.dart'; | 8 import 'package:compiler/src/elements/entities.dart'; |
9 import 'package:compiler/src/js_backend/no_such_method_registry.dart'; | 9 import 'package:compiler/src/js_backend/no_such_method_registry.dart'; |
10 import 'package:compiler/src/world.dart'; | 10 import 'package:compiler/src/world.dart'; |
(...skipping 28 matching lines...) Expand all Loading... |
39 class NoSuchMethodTest { | 39 class NoSuchMethodTest { |
40 final String code; | 40 final String code; |
41 final List<NoSuchMethodInfo> methods; | 41 final List<NoSuchMethodInfo> methods; |
42 final bool isNoSuchMethodUsed; | 42 final bool isNoSuchMethodUsed; |
43 | 43 |
44 const NoSuchMethodTest(this.code, this.methods, | 44 const NoSuchMethodTest(this.code, this.methods, |
45 {this.isNoSuchMethodUsed: false}); | 45 {this.isNoSuchMethodUsed: false}); |
46 } | 46 } |
47 | 47 |
48 const List<NoSuchMethodTest> TESTS = const <NoSuchMethodTest>[ | 48 const List<NoSuchMethodTest> TESTS = const <NoSuchMethodTest>[ |
49 const NoSuchMethodTest( | 49 const NoSuchMethodTest(""" |
50 """ | |
51 class A { | 50 class A { |
52 foo() => 3; | 51 foo() => 3; |
53 noSuchMethod(x) => super.noSuchMethod(x); | 52 noSuchMethod(x) => super.noSuchMethod(x); |
54 } | 53 } |
55 main() { | 54 main() { |
56 print(new A().foo()); | 55 print(new A().foo()); |
57 } | 56 } |
58 """, | 57 """, const <NoSuchMethodInfo>[ |
59 const <NoSuchMethodInfo>[ | 58 const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true), |
60 const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true), | 59 ]), |
61 ]), | 60 const NoSuchMethodTest(""" |
62 const NoSuchMethodTest( | |
63 """ | |
64 class A extends B { | 61 class A extends B { |
65 foo() => 3; | 62 foo() => 3; |
66 noSuchMethod(x) => super.noSuchMethod(x); | 63 noSuchMethod(x) => super.noSuchMethod(x); |
67 } | 64 } |
68 class B {} | 65 class B {} |
69 main() { | 66 main() { |
70 print(new A().foo()); | 67 print(new A().foo()); |
71 } | 68 } |
72 """, | 69 """, const <NoSuchMethodInfo>[ |
73 const <NoSuchMethodInfo>[ | 70 const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true), |
74 const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true), | 71 ]), |
75 ]), | 72 const NoSuchMethodTest(""" |
76 const NoSuchMethodTest( | |
77 """ | |
78 class A extends B { | 73 class A extends B { |
79 foo() => 3; | 74 foo() => 3; |
80 noSuchMethod(x) { | 75 noSuchMethod(x) { |
81 return super.noSuchMethod(x); | 76 return super.noSuchMethod(x); |
82 } | 77 } |
83 } | 78 } |
84 class B {} | 79 class B {} |
85 main() { | 80 main() { |
86 print(new A().foo()); | 81 print(new A().foo()); |
87 } | 82 } |
88 """, | 83 """, const <NoSuchMethodInfo>[ |
89 const <NoSuchMethodInfo>[ | 84 const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true), |
90 const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true), | 85 ]), |
91 ]), | 86 const NoSuchMethodTest(""" |
92 const NoSuchMethodTest( | |
93 """ | |
94 class A extends B { | 87 class A extends B { |
95 foo() => 3; | 88 foo() => 3; |
96 noSuchMethod(x) => super.noSuchMethod(x); | 89 noSuchMethod(x) => super.noSuchMethod(x); |
97 } | 90 } |
98 class B { | 91 class B { |
99 noSuchMethod(x) => super.noSuchMethod(x); | 92 noSuchMethod(x) => super.noSuchMethod(x); |
100 } | 93 } |
101 main() { | 94 main() { |
102 print(new A().foo()); | 95 print(new A().foo()); |
103 } | 96 } |
104 """, | 97 """, const <NoSuchMethodInfo>[ |
105 const <NoSuchMethodInfo>[ | 98 const NoSuchMethodInfo('A', |
106 const NoSuchMethodInfo('A', | 99 superClassName: 'B', hasForwardingSyntax: true, isDefault: true), |
107 superClassName: 'B', hasForwardingSyntax: true, isDefault: true), | 100 const NoSuchMethodInfo('B', hasForwardingSyntax: true, isDefault: true), |
108 const NoSuchMethodInfo('B', hasForwardingSyntax: true, isDefault: true), | 101 ]), |
109 ]), | 102 const NoSuchMethodTest(""" |
110 const NoSuchMethodTest( | |
111 """ | |
112 class A extends B { | 103 class A extends B { |
113 foo() => 3; | 104 foo() => 3; |
114 noSuchMethod(x) => super.noSuchMethod(x); | 105 noSuchMethod(x) => super.noSuchMethod(x); |
115 } | 106 } |
116 class B { | 107 class B { |
117 noSuchMethod(x) => throw 'foo'; | 108 noSuchMethod(x) => throw 'foo'; |
118 } | 109 } |
119 main() { | 110 main() { |
120 print(new A().foo()); | 111 print(new A().foo()); |
121 } | 112 } |
122 """, | 113 """, const <NoSuchMethodInfo>[ |
123 const <NoSuchMethodInfo>[ | 114 const NoSuchMethodInfo('A', |
124 const NoSuchMethodInfo('A', | 115 superClassName: 'B', hasForwardingSyntax: true, isThrowing: true), |
125 superClassName: 'B', hasForwardingSyntax: true, isThrowing: true), | 116 const NoSuchMethodInfo('B', hasThrowingSyntax: true, isThrowing: true), |
126 const NoSuchMethodInfo('B', hasThrowingSyntax: true, isThrowing: true), | 117 ], isNoSuchMethodUsed: true), |
127 ], | 118 const NoSuchMethodTest(""" |
128 isNoSuchMethodUsed: true), | |
129 const NoSuchMethodTest( | |
130 """ | |
131 class A { | 119 class A { |
132 noSuchMethod(x) => 3; | 120 noSuchMethod(x) => 3; |
133 } | 121 } |
134 main() { | 122 main() { |
135 print(new A().foo()); | 123 print(new A().foo()); |
136 } | 124 } |
137 """, | 125 """, const <NoSuchMethodInfo>[ |
138 const <NoSuchMethodInfo>[ | 126 const NoSuchMethodInfo('A', isOther: true, isComplexReturn: true), |
139 const NoSuchMethodInfo('A', isOther: true, isComplexReturn: true), | 127 ], isNoSuchMethodUsed: true), |
140 ], | 128 const NoSuchMethodTest(""" |
141 isNoSuchMethodUsed: true), | |
142 const NoSuchMethodTest( | |
143 """ | |
144 class A { | 129 class A { |
145 noSuchMethod(x, [y]) => super.noSuchMethod(x); | 130 noSuchMethod(x, [y]) => super.noSuchMethod(x); |
146 } | 131 } |
147 main() { | 132 main() { |
148 print(new A().foo()); | 133 print(new A().foo()); |
149 } | 134 } |
150 """, | 135 """, const <NoSuchMethodInfo>[ |
151 const <NoSuchMethodInfo>[ | 136 const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true), |
152 const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true), | 137 ]), |
153 ]), | 138 const NoSuchMethodTest(""" |
154 const NoSuchMethodTest( | |
155 """ | |
156 class A { | 139 class A { |
157 noSuchMethod(x, [y]) => super.noSuchMethod(x, y); | 140 noSuchMethod(x, [y]) => super.noSuchMethod(x, y); |
158 } | 141 } |
159 main() { | 142 main() { |
160 print(new A().foo()); | 143 print(new A().foo()); |
161 } | 144 } |
162 """, | 145 """, const <NoSuchMethodInfo>[ |
163 const <NoSuchMethodInfo>[ | 146 const NoSuchMethodInfo('A', isOther: true, isComplexNoReturn: true), |
164 const NoSuchMethodInfo('A', isOther: true, isComplexNoReturn: true), | 147 ], isNoSuchMethodUsed: true), |
165 ], | 148 const NoSuchMethodTest(""" |
166 isNoSuchMethodUsed: true), | |
167 const NoSuchMethodTest( | |
168 """ | |
169 class A { | 149 class A { |
170 noSuchMethod(x, y) => super.noSuchMethod(x); | 150 noSuchMethod(x, y) => super.noSuchMethod(x); |
171 } | 151 } |
172 main() { | 152 main() { |
173 print(new A().foo()); | 153 print(new A().foo()); |
174 } | 154 } |
175 """, | 155 """, const <NoSuchMethodInfo>[ |
176 const <NoSuchMethodInfo>[ | 156 const NoSuchMethodInfo('A', |
177 const NoSuchMethodInfo('A', | 157 hasForwardingSyntax: true, isNotApplicable: true), |
178 hasForwardingSyntax: true, isNotApplicable: true), | 158 ]), |
179 ]), | 159 const NoSuchMethodTest(""" |
180 const NoSuchMethodTest( | |
181 """ | |
182 class A { | 160 class A { |
183 noSuchMethod(Invocation x) { | 161 noSuchMethod(Invocation x) { |
184 throw new UnsupportedException(); | 162 throw new UnsupportedException(); |
185 } | 163 } |
186 } | 164 } |
187 main() { | 165 main() { |
188 print(new A().foo()); | 166 print(new A().foo()); |
189 } | 167 } |
190 """, | 168 """, const <NoSuchMethodInfo>[ |
191 const <NoSuchMethodInfo>[ | 169 const NoSuchMethodInfo('A', hasThrowingSyntax: true, isThrowing: true), |
192 const NoSuchMethodInfo('A', hasThrowingSyntax: true, isThrowing: true), | 170 ], isNoSuchMethodUsed: true), |
193 ], | 171 const NoSuchMethodTest(""" |
194 isNoSuchMethodUsed: true), | |
195 const NoSuchMethodTest( | |
196 """ | |
197 class A { | 172 class A { |
198 noSuchMethod(Invocation x) { | 173 noSuchMethod(Invocation x) { |
199 print('foo'); | 174 print('foo'); |
200 throw 'foo'; | 175 throw 'foo'; |
201 } | 176 } |
202 } | 177 } |
203 main() { | 178 main() { |
204 print(new A().foo()); | 179 print(new A().foo()); |
205 } | 180 } |
206 """, | 181 """, const <NoSuchMethodInfo>[ |
207 const <NoSuchMethodInfo>[ | 182 const NoSuchMethodInfo('A', isOther: true, isComplexNoReturn: true), |
208 const NoSuchMethodInfo('A', isOther: true, isComplexNoReturn: true), | 183 ], isNoSuchMethodUsed: true), |
209 ], | 184 const NoSuchMethodTest(""" |
210 isNoSuchMethodUsed: true), | |
211 const NoSuchMethodTest( | |
212 """ | |
213 class A { | 185 class A { |
214 noSuchMethod(Invocation x) { | 186 noSuchMethod(Invocation x) { |
215 return toString(); | 187 return toString(); |
216 } | 188 } |
217 } | 189 } |
218 main() { | 190 main() { |
219 print(new A().foo()); | 191 print(new A().foo()); |
220 } | 192 } |
221 """, | 193 """, const <NoSuchMethodInfo>[ |
222 const <NoSuchMethodInfo>[ | 194 const NoSuchMethodInfo('A', isOther: true, isComplexReturn: true), |
223 const NoSuchMethodInfo('A', isOther: true, isComplexReturn: true), | 195 ], isNoSuchMethodUsed: true), |
224 ], | 196 const NoSuchMethodTest(""" |
225 isNoSuchMethodUsed: true), | |
226 const NoSuchMethodTest( | |
227 """ | |
228 class A { | 197 class A { |
229 noSuchMethod(x) => super.noSuchMethod(x) as dynamic; | 198 noSuchMethod(x) => super.noSuchMethod(x) as dynamic; |
230 } | 199 } |
231 main() { | 200 main() { |
232 print(new A().foo()); | 201 print(new A().foo()); |
233 } | 202 } |
234 """, | 203 """, const <NoSuchMethodInfo>[ |
235 const <NoSuchMethodInfo>[ | 204 const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true), |
236 const NoSuchMethodInfo('A', hasForwardingSyntax: true, isDefault: true), | 205 ]), |
237 ]), | |
238 ]; | 206 ]; |
239 | 207 |
240 main() { | 208 main() { |
241 asyncTest(() async { | 209 asyncTest(() async { |
242 for (NoSuchMethodTest test in TESTS) { | 210 for (NoSuchMethodTest test in TESTS) { |
243 print('---- testing -------------------------------------------------'); | 211 print('---- testing -------------------------------------------------'); |
244 print(test.code); | 212 print(test.code); |
245 Uri uri = new Uri(scheme: 'source'); | 213 Uri uri = new Uri(scheme: 'source'); |
246 Compiler compiler = compilerFor(test.code, uri); | 214 Compiler compiler = compilerFor(test.code, uri); |
247 await compiler.run(uri); | 215 await compiler.run(uri); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 registry.complexReturningImpls.contains(noSuchMethod), | 313 registry.complexReturningImpls.contains(noSuchMethod), |
346 "Unexpected isComplexReturn result on $noSuchMethod."); | 314 "Unexpected isComplexReturn result on $noSuchMethod."); |
347 } | 315 } |
348 } | 316 } |
349 | 317 |
350 Expect.equals( | 318 Expect.equals( |
351 test.isNoSuchMethodUsed, | 319 test.isNoSuchMethodUsed, |
352 closedWorld.backendUsage.isNoSuchMethodUsed, | 320 closedWorld.backendUsage.isNoSuchMethodUsed, |
353 "Unexpected isNoSuchMethodUsed result."); | 321 "Unexpected isNoSuchMethodUsed result."); |
354 } | 322 } |
OLD | NEW |