OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // VMOptions=--enable_type_checks --enable_asserts | 4 // VMOptions=--enable_type_checks --enable_asserts |
5 // | 5 // |
6 // Dart test program testing type checks. | 6 // Dart test program testing type checks. |
7 | 7 |
8 class TypeTest { | 8 class TypeTest { |
9 static test() { | 9 static test() { |
10 int result = 0; | 10 int result = 0; |
11 try { | 11 try { |
12 int i = "hello"; // Throws a TypeError if type checks are enabled. | 12 int i = "hello"; // Throws a TypeError if type checks are enabled. |
13 } catch (TypeError error) { | 13 } catch (TypeError error) { |
14 result = 1; | 14 result = 1; |
15 Expect.equals("int", error.dstType); | 15 Expect.equals("int", error.dstType); |
16 Expect.equals("OneByteString", error.srcType); | 16 Expect.equals("OneByteString", error.srcType); |
17 Expect.equals("i", error.dstName); | 17 Expect.equals("i", error.dstName); |
18 int pos = error.url.lastIndexOf("/", error.url.length); | 18 int pos = error.url.lastIndexOf("/", error.url.length); |
19 if (pos == -1) { | 19 if (pos == -1) { |
20 pos = error.url.lastIndexOf("\\", error.url.length); | 20 pos = error.url.lastIndexOf("\\", error.url.length); |
21 } | 21 } |
22 String subs = error.url.substring(pos + 1, error.url.length); | 22 String subs = error.url.substring(pos + 1, error.url.length); |
23 Expect.equals("TypeVMTest.dart", subs); | 23 Expect.equals("type_vm_test.dart", subs); |
24 Expect.equals(12, error.line); | 24 Expect.equals(12, error.line); |
25 Expect.equals(15, error.column); | 25 Expect.equals(15, error.column); |
26 } | 26 } |
27 return result; | 27 return result; |
28 } | 28 } |
29 | 29 |
30 static testSideEffect() { | 30 static testSideEffect() { |
31 int result = 0; | 31 int result = 0; |
32 int index() { | 32 int index() { |
33 result++; | 33 result++; |
(...skipping 20 matching lines...) Expand all Loading... |
54 } catch (TypeError error) { | 54 } catch (TypeError error) { |
55 result = 1; | 55 result = 1; |
56 Expect.equals("int", error.dstType); | 56 Expect.equals("int", error.dstType); |
57 Expect.equals("OneByteString", error.srcType); | 57 Expect.equals("OneByteString", error.srcType); |
58 Expect.equals("i", error.dstName); | 58 Expect.equals("i", error.dstName); |
59 int pos = error.url.lastIndexOf("/", error.url.length); | 59 int pos = error.url.lastIndexOf("/", error.url.length); |
60 if (pos == -1) { | 60 if (pos == -1) { |
61 pos = error.url.lastIndexOf("\\", error.url.length); | 61 pos = error.url.lastIndexOf("\\", error.url.length); |
62 } | 62 } |
63 String subs = error.url.substring(pos + 1, error.url.length); | 63 String subs = error.url.substring(pos + 1, error.url.length); |
64 Expect.equals("TypeVMTest.dart", subs); | 64 Expect.equals("type_vm_test.dart", subs); |
65 Expect.equals(49, error.line); | 65 Expect.equals(49, error.line); |
66 Expect.equals(15, error.column); | 66 Expect.equals(15, error.column); |
67 } | 67 } |
68 return result; | 68 return result; |
69 } | 69 } |
70 | 70 |
71 static testReturn() { | 71 static testReturn() { |
72 int result = 0; | 72 int result = 0; |
73 int f(String s) { | 73 int f(String s) { |
74 return s; | 74 return s; |
75 } | 75 } |
76 try { | 76 try { |
77 int i = f("hello"); // Throws a TypeError if type checks are enabled. | 77 int i = f("hello"); // Throws a TypeError if type checks are enabled. |
78 } catch (TypeError error) { | 78 } catch (TypeError error) { |
79 result = 1; | 79 result = 1; |
80 Expect.equals("int", error.dstType); | 80 Expect.equals("int", error.dstType); |
81 Expect.equals("OneByteString", error.srcType); | 81 Expect.equals("OneByteString", error.srcType); |
82 Expect.equals("function result", error.dstName); | 82 Expect.equals("function result", error.dstName); |
83 int pos = error.url.lastIndexOf("/", error.url.length); | 83 int pos = error.url.lastIndexOf("/", error.url.length); |
84 if (pos == -1) { | 84 if (pos == -1) { |
85 pos = error.url.lastIndexOf("\\", error.url.length); | 85 pos = error.url.lastIndexOf("\\", error.url.length); |
86 } | 86 } |
87 String subs = error.url.substring(pos + 1, error.url.length); | 87 String subs = error.url.substring(pos + 1, error.url.length); |
88 Expect.equals("TypeVMTest.dart", subs); | 88 Expect.equals("type_vm_test.dart", subs); |
89 Expect.equals(74, error.line); | 89 Expect.equals(74, error.line); |
90 Expect.equals(14, error.column); | 90 Expect.equals(14, error.column); |
91 } | 91 } |
92 return result; | 92 return result; |
93 } | 93 } |
94 | 94 |
95 static int field; | 95 static int field; |
96 static testField() { | 96 static testField() { |
97 int result = 0; | 97 int result = 0; |
98 try { | 98 try { |
99 field = "hello"; // Throws a TypeError if type checks are enabled. | 99 field = "hello"; // Throws a TypeError if type checks are enabled. |
100 } catch (TypeError error) { | 100 } catch (TypeError error) { |
101 result = 1; | 101 result = 1; |
102 Expect.equals("int", error.dstType); | 102 Expect.equals("int", error.dstType); |
103 Expect.equals("OneByteString", error.srcType); | 103 Expect.equals("OneByteString", error.srcType); |
104 Expect.equals("field", error.dstName); | 104 Expect.equals("field", error.dstName); |
105 int pos = error.url.lastIndexOf("/", error.url.length); | 105 int pos = error.url.lastIndexOf("/", error.url.length); |
106 if (pos == -1) { | 106 if (pos == -1) { |
107 pos = error.url.lastIndexOf("\\", error.url.length); | 107 pos = error.url.lastIndexOf("\\", error.url.length); |
108 } | 108 } |
109 String subs = error.url.substring(pos + 1, error.url.length); | 109 String subs = error.url.substring(pos + 1, error.url.length); |
110 Expect.equals("TypeVMTest.dart", subs); | 110 Expect.equals("type_vm_test.dart", subs); |
111 Expect.equals(99, error.line); | 111 Expect.equals(99, error.line); |
112 Expect.equals(15, error.column); | 112 Expect.equals(15, error.column); |
113 } | 113 } |
114 return result; | 114 return result; |
115 } | 115 } |
116 | 116 |
117 static testAnyFunction() { | 117 static testAnyFunction() { |
118 int result = 0; | 118 int result = 0; |
119 Function anyFunction; | 119 Function anyFunction; |
120 f() { }; | 120 f() { }; |
121 anyFunction = f; // No error. | 121 anyFunction = f; // No error. |
122 try { | 122 try { |
123 int i = f; // Throws a TypeError if type checks are enabled. | 123 int i = f; // Throws a TypeError if type checks are enabled. |
124 } catch (TypeError error) { | 124 } catch (TypeError error) { |
125 result = 1; | 125 result = 1; |
126 Expect.equals("int", error.dstType); | 126 Expect.equals("int", error.dstType); |
127 Expect.equals("() => Dynamic", error.srcType); | 127 Expect.equals("() => Dynamic", error.srcType); |
128 Expect.equals("i", error.dstName); | 128 Expect.equals("i", error.dstName); |
129 int pos = error.url.lastIndexOf("/", error.url.length); | 129 int pos = error.url.lastIndexOf("/", error.url.length); |
130 if (pos == -1) { | 130 if (pos == -1) { |
131 pos = error.url.lastIndexOf("\\", error.url.length); | 131 pos = error.url.lastIndexOf("\\", error.url.length); |
132 } | 132 } |
133 String subs = error.url.substring(pos + 1, error.url.length); | 133 String subs = error.url.substring(pos + 1, error.url.length); |
134 Expect.equals("TypeVMTest.dart", subs); | 134 Expect.equals("type_vm_test.dart", subs); |
135 Expect.equals(123, error.line); | 135 Expect.equals(123, error.line); |
136 Expect.equals(15, error.column); | 136 Expect.equals(15, error.column); |
137 } | 137 } |
138 return result; | 138 return result; |
139 } | 139 } |
140 | 140 |
141 static testVoidFunction() { | 141 static testVoidFunction() { |
142 int result = 0; | 142 int result = 0; |
143 Function anyFunction; | 143 Function anyFunction; |
144 void acceptVoidFunObj(void voidFunObj(Object obj)) { }; | 144 void acceptVoidFunObj(void voidFunObj(Object obj)) { }; |
(...skipping 10 matching lines...) Expand all Loading... |
155 } catch (TypeError error) { | 155 } catch (TypeError error) { |
156 result = 1; | 156 result = 1; |
157 Expect.equals("(Object) => Object", error.dstType); | 157 Expect.equals("(Object) => Object", error.dstType); |
158 Expect.equals("(Object) => void", error.srcType); | 158 Expect.equals("(Object) => void", error.srcType); |
159 Expect.equals("objFunObj", error.dstName); | 159 Expect.equals("objFunObj", error.dstName); |
160 int pos = error.url.lastIndexOf("/", error.url.length); | 160 int pos = error.url.lastIndexOf("/", error.url.length); |
161 if (pos == -1) { | 161 if (pos == -1) { |
162 pos = error.url.lastIndexOf("\\", error.url.length); | 162 pos = error.url.lastIndexOf("\\", error.url.length); |
163 } | 163 } |
164 String subs = error.url.substring(pos + 1, error.url.length); | 164 String subs = error.url.substring(pos + 1, error.url.length); |
165 Expect.equals("TypeVMTest.dart", subs); | 165 Expect.equals("type_vm_test.dart", subs); |
166 Expect.equals(145, error.line); | 166 Expect.equals(145, error.line); |
167 Expect.equals(33, error.column); | 167 Expect.equals(33, error.column); |
168 } | 168 } |
169 return result; | 169 return result; |
170 } | 170 } |
171 | 171 |
172 static testFunctionNum() { | 172 static testFunctionNum() { |
173 int result = 0; | 173 int result = 0; |
174 Function anyFunction; | 174 Function anyFunction; |
175 void acceptFunNum(void funNum(num num)) { }; | 175 void acceptFunNum(void funNum(num num)) { }; |
(...skipping 13 matching lines...) Expand all Loading... |
189 } catch (TypeError error) { | 189 } catch (TypeError error) { |
190 result = 1; | 190 result = 1; |
191 Expect.equals("(num) => void", error.dstType); | 191 Expect.equals("(num) => void", error.dstType); |
192 Expect.equals("(String) => void", error.srcType); | 192 Expect.equals("(String) => void", error.srcType); |
193 Expect.equals("funNum", error.dstName); | 193 Expect.equals("funNum", error.dstName); |
194 int pos = error.url.lastIndexOf("/", error.url.length); | 194 int pos = error.url.lastIndexOf("/", error.url.length); |
195 if (pos == -1) { | 195 if (pos == -1) { |
196 pos = error.url.lastIndexOf("\\", error.url.length); | 196 pos = error.url.lastIndexOf("\\", error.url.length); |
197 } | 197 } |
198 String subs = error.url.substring(pos + 1, error.url.length); | 198 String subs = error.url.substring(pos + 1, error.url.length); |
199 Expect.equals("TypeVMTest.dart", subs); | 199 Expect.equals("type_vm_test.dart", subs); |
200 Expect.equals(175, error.line); | 200 Expect.equals(175, error.line); |
201 Expect.equals(28, error.column); | 201 Expect.equals(28, error.column); |
202 } | 202 } |
203 return result; | 203 return result; |
204 } | 204 } |
205 | 205 |
206 static testBoolCheck() { | 206 static testBoolCheck() { |
207 int result = 0; | 207 int result = 0; |
208 try { | 208 try { |
209 bool i = !"hello"; // Throws a TypeError if type checks are enabled. | 209 bool i = !"hello"; // Throws a TypeError if type checks are enabled. |
210 } catch (TypeError error) { | 210 } catch (TypeError error) { |
211 result++; | 211 result++; |
212 Expect.equals("bool", error.dstType); | 212 Expect.equals("bool", error.dstType); |
213 Expect.equals("OneByteString", error.srcType); | 213 Expect.equals("OneByteString", error.srcType); |
214 Expect.equals("boolean expression", error.dstName); | 214 Expect.equals("boolean expression", error.dstName); |
215 int pos = error.url.lastIndexOf("/", error.url.length); | 215 int pos = error.url.lastIndexOf("/", error.url.length); |
216 if (pos == -1) { | 216 if (pos == -1) { |
217 pos = error.url.lastIndexOf("\\", error.url.length); | 217 pos = error.url.lastIndexOf("\\", error.url.length); |
218 } | 218 } |
219 String subs = error.url.substring(pos + 1, error.url.length); | 219 String subs = error.url.substring(pos + 1, error.url.length); |
220 Expect.equals("TypeVMTest.dart", subs); | 220 Expect.equals("type_vm_test.dart", subs); |
221 Expect.equals(209, error.line); | 221 Expect.equals(209, error.line); |
222 Expect.equals(17, error.column); | 222 Expect.equals(17, error.column); |
223 } | 223 } |
224 try { | 224 try { |
225 while ("hello") {}; // Throws a TypeError if type checks are enabled. | 225 while ("hello") {}; // Throws a TypeError if type checks are enabled. |
226 } catch (TypeError error) { | 226 } catch (TypeError error) { |
227 result++; | 227 result++; |
228 Expect.equals("bool", error.dstType); | 228 Expect.equals("bool", error.dstType); |
229 Expect.equals("OneByteString", error.srcType); | 229 Expect.equals("OneByteString", error.srcType); |
230 Expect.equals("boolean expression", error.dstName); | 230 Expect.equals("boolean expression", error.dstName); |
231 int pos = error.url.lastIndexOf("/", error.url.length); | 231 int pos = error.url.lastIndexOf("/", error.url.length); |
232 if (pos == -1) { | 232 if (pos == -1) { |
233 pos = error.url.lastIndexOf("\\", error.url.length); | 233 pos = error.url.lastIndexOf("\\", error.url.length); |
234 } | 234 } |
235 String subs = error.url.substring(pos + 1, error.url.length); | 235 String subs = error.url.substring(pos + 1, error.url.length); |
236 Expect.equals("TypeVMTest.dart", subs); | 236 Expect.equals("type_vm_test.dart", subs); |
237 Expect.equals(225, error.line); | 237 Expect.equals(225, error.line); |
238 Expect.equals(14, error.column); | 238 Expect.equals(14, error.column); |
239 } | 239 } |
240 try { | 240 try { |
241 do {} while ("hello"); // Throws a TypeError if type checks are enabled. | 241 do {} while ("hello"); // Throws a TypeError if type checks are enabled. |
242 } catch (TypeError error) { | 242 } catch (TypeError error) { |
243 result++; | 243 result++; |
244 Expect.equals("bool", error.dstType); | 244 Expect.equals("bool", error.dstType); |
245 Expect.equals("OneByteString", error.srcType); | 245 Expect.equals("OneByteString", error.srcType); |
246 Expect.equals("boolean expression", error.dstName); | 246 Expect.equals("boolean expression", error.dstName); |
247 int pos = error.url.lastIndexOf("/", error.url.length); | 247 int pos = error.url.lastIndexOf("/", error.url.length); |
248 if (pos == -1) { | 248 if (pos == -1) { |
249 pos = error.url.lastIndexOf("\\", error.url.length); | 249 pos = error.url.lastIndexOf("\\", error.url.length); |
250 } | 250 } |
251 String subs = error.url.substring(pos + 1, error.url.length); | 251 String subs = error.url.substring(pos + 1, error.url.length); |
252 Expect.equals("TypeVMTest.dart", subs); | 252 Expect.equals("type_vm_test.dart", subs); |
253 Expect.equals(241, error.line); | 253 Expect.equals(241, error.line); |
254 Expect.equals(20, error.column); | 254 Expect.equals(20, error.column); |
255 } | 255 } |
256 try { | 256 try { |
257 for (;"hello";) {}; // Throws a TypeError if type checks are enabled. | 257 for (;"hello";) {}; // Throws a TypeError if type checks are enabled. |
258 } catch (TypeError error) { | 258 } catch (TypeError error) { |
259 result++; | 259 result++; |
260 Expect.equals("bool", error.dstType); | 260 Expect.equals("bool", error.dstType); |
261 Expect.equals("OneByteString", error.srcType); | 261 Expect.equals("OneByteString", error.srcType); |
262 Expect.equals("boolean expression", error.dstName); | 262 Expect.equals("boolean expression", error.dstName); |
263 int pos = error.url.lastIndexOf("/", error.url.length); | 263 int pos = error.url.lastIndexOf("/", error.url.length); |
264 if (pos == -1) { | 264 if (pos == -1) { |
265 pos = error.url.lastIndexOf("\\", error.url.length); | 265 pos = error.url.lastIndexOf("\\", error.url.length); |
266 } | 266 } |
267 String subs = error.url.substring(pos + 1, error.url.length); | 267 String subs = error.url.substring(pos + 1, error.url.length); |
268 Expect.equals("TypeVMTest.dart", subs); | 268 Expect.equals("type_vm_test.dart", subs); |
269 Expect.equals(257, error.line); | 269 Expect.equals(257, error.line); |
270 Expect.equals(13, error.column); | 270 Expect.equals(13, error.column); |
271 } | 271 } |
272 try { | 272 try { |
273 int i = "hello" ? 1 : 0; // Throws a TypeError if type checks are enabled
. | 273 int i = "hello" ? 1 : 0; // Throws a TypeError if type checks are enabled
. |
274 } catch (TypeError error) { | 274 } catch (TypeError error) { |
275 result++; | 275 result++; |
276 Expect.equals("bool", error.dstType); | 276 Expect.equals("bool", error.dstType); |
277 Expect.equals("OneByteString", error.srcType); | 277 Expect.equals("OneByteString", error.srcType); |
278 Expect.equals("boolean expression", error.dstName); | 278 Expect.equals("boolean expression", error.dstName); |
279 int pos = error.url.lastIndexOf("/", error.url.length); | 279 int pos = error.url.lastIndexOf("/", error.url.length); |
280 if (pos == -1) { | 280 if (pos == -1) { |
281 pos = error.url.lastIndexOf("\\", error.url.length); | 281 pos = error.url.lastIndexOf("\\", error.url.length); |
282 } | 282 } |
283 String subs = error.url.substring(pos + 1, error.url.length); | 283 String subs = error.url.substring(pos + 1, error.url.length); |
284 Expect.equals("TypeVMTest.dart", subs); | 284 Expect.equals("type_vm_test.dart", subs); |
285 Expect.equals(273, error.line); | 285 Expect.equals(273, error.line); |
286 Expect.equals(15, error.column); | 286 Expect.equals(15, error.column); |
287 } | 287 } |
288 try { | 288 try { |
289 if ("hello") {}; // Throws a TypeError if type checks are enabled. | 289 if ("hello") {}; // Throws a TypeError if type checks are enabled. |
290 } catch (TypeError error) { | 290 } catch (TypeError error) { |
291 result++; | 291 result++; |
292 Expect.equals("bool", error.dstType); | 292 Expect.equals("bool", error.dstType); |
293 Expect.equals("OneByteString", error.srcType); | 293 Expect.equals("OneByteString", error.srcType); |
294 Expect.equals("boolean expression", error.dstName); | 294 Expect.equals("boolean expression", error.dstName); |
295 int pos = error.url.lastIndexOf("/", error.url.length); | 295 int pos = error.url.lastIndexOf("/", error.url.length); |
296 if (pos == -1) { | 296 if (pos == -1) { |
297 pos = error.url.lastIndexOf("\\", error.url.length); | 297 pos = error.url.lastIndexOf("\\", error.url.length); |
298 } | 298 } |
299 String subs = error.url.substring(pos + 1, error.url.length); | 299 String subs = error.url.substring(pos + 1, error.url.length); |
300 Expect.equals("TypeVMTest.dart", subs); | 300 Expect.equals("type_vm_test.dart", subs); |
301 Expect.equals(289, error.line); | 301 Expect.equals(289, error.line); |
302 Expect.equals(11, error.column); | 302 Expect.equals(11, error.column); |
303 } | 303 } |
304 try { | 304 try { |
305 if ("hello" || false) {}; // Throws a TypeError if type checks are enable
d. | 305 if ("hello" || false) {}; // Throws a TypeError if type checks are enable
d. |
306 } catch (TypeError error) { | 306 } catch (TypeError error) { |
307 result++; | 307 result++; |
308 Expect.equals("bool", error.dstType); | 308 Expect.equals("bool", error.dstType); |
309 Expect.equals("OneByteString", error.srcType); | 309 Expect.equals("OneByteString", error.srcType); |
310 Expect.equals("boolean expression", error.dstName); | 310 Expect.equals("boolean expression", error.dstName); |
311 int pos = error.url.lastIndexOf("/", error.url.length); | 311 int pos = error.url.lastIndexOf("/", error.url.length); |
312 if (pos == -1) { | 312 if (pos == -1) { |
313 pos = error.url.lastIndexOf("\\", error.url.length); | 313 pos = error.url.lastIndexOf("\\", error.url.length); |
314 } | 314 } |
315 String subs = error.url.substring(pos + 1, error.url.length); | 315 String subs = error.url.substring(pos + 1, error.url.length); |
316 Expect.equals("TypeVMTest.dart", subs); | 316 Expect.equals("type_vm_test.dart", subs); |
317 Expect.equals(305, error.line); | 317 Expect.equals(305, error.line); |
318 Expect.equals(11, error.column); | 318 Expect.equals(11, error.column); |
319 } | 319 } |
320 try { | 320 try { |
321 if (false || "hello") {}; // Throws a TypeError if type checks are enable
d. | 321 if (false || "hello") {}; // Throws a TypeError if type checks are enable
d. |
322 } catch (TypeError error) { | 322 } catch (TypeError error) { |
323 result++; | 323 result++; |
324 Expect.equals("bool", error.dstType); | 324 Expect.equals("bool", error.dstType); |
325 Expect.equals("OneByteString", error.srcType); | 325 Expect.equals("OneByteString", error.srcType); |
326 Expect.equals("boolean expression", error.dstName); | 326 Expect.equals("boolean expression", error.dstName); |
327 int pos = error.url.lastIndexOf("/", error.url.length); | 327 int pos = error.url.lastIndexOf("/", error.url.length); |
328 if (pos == -1) { | 328 if (pos == -1) { |
329 pos = error.url.lastIndexOf("\\", error.url.length); | 329 pos = error.url.lastIndexOf("\\", error.url.length); |
330 } | 330 } |
331 String subs = error.url.substring(pos + 1, error.url.length); | 331 String subs = error.url.substring(pos + 1, error.url.length); |
332 Expect.equals("TypeVMTest.dart", subs); | 332 Expect.equals("type_vm_test.dart", subs); |
333 Expect.equals(321, error.line); | 333 Expect.equals(321, error.line); |
334 Expect.equals(20, error.column); | 334 Expect.equals(20, error.column); |
335 } | 335 } |
336 try { | 336 try { |
337 if (null) {}; // Throws a TypeError if type checks are enabled. | 337 if (null) {}; // Throws a TypeError if type checks are enabled. |
338 } catch (TypeError error) { | 338 } catch (TypeError error) { |
339 result++; | 339 result++; |
340 Expect.equals("bool", error.dstType); | 340 Expect.equals("bool", error.dstType); |
341 Expect.equals("Null", error.srcType); | 341 Expect.equals("Null", error.srcType); |
342 Expect.equals("boolean expression", error.dstName); | 342 Expect.equals("boolean expression", error.dstName); |
343 int pos = error.url.lastIndexOf("/", error.url.length); | 343 int pos = error.url.lastIndexOf("/", error.url.length); |
344 if (pos == -1) { | 344 if (pos == -1) { |
345 pos = error.url.lastIndexOf("\\", error.url.length); | 345 pos = error.url.lastIndexOf("\\", error.url.length); |
346 } | 346 } |
347 String subs = error.url.substring(pos + 1, error.url.length); | 347 String subs = error.url.substring(pos + 1, error.url.length); |
348 Expect.equals("TypeVMTest.dart", subs); | 348 Expect.equals("type_vm_test.dart", subs); |
349 Expect.equals(337, error.line); | 349 Expect.equals(337, error.line); |
350 Expect.equals(11, error.column); | 350 Expect.equals(11, error.column); |
351 } | 351 } |
352 return result; | 352 return result; |
353 } | 353 } |
354 | 354 |
355 | 355 |
356 static int testFactory() { | 356 static int testFactory() { |
357 int result = 0; | 357 int result = 0; |
358 try { | 358 try { |
359 var x = new C(); | 359 var x = new C(); |
360 } catch (TypeError error) { | 360 } catch (TypeError error) { |
361 result++; | 361 result++; |
362 Expect.equals("C", error.dstType); | 362 Expect.equals("C", error.dstType); |
363 Expect.equals("int", error.srcType); | 363 Expect.equals("int", error.srcType); |
364 Expect.equals("function result", error.dstName); | 364 Expect.equals("function result", error.dstName); |
365 int pos = error.url.lastIndexOf("/", error.url.length); | 365 int pos = error.url.lastIndexOf("/", error.url.length); |
366 if (pos == -1) { | 366 if (pos == -1) { |
367 pos = error.url.lastIndexOf("\\", error.url.length); | 367 pos = error.url.lastIndexOf("\\", error.url.length); |
368 } | 368 } |
369 String subs = error.url.substring(pos + 1, error.url.length); | 369 String subs = error.url.substring(pos + 1, error.url.length); |
370 Expect.equals("TypeVMTest.dart", subs); | 370 Expect.equals("type_vm_test.dart", subs); |
371 Expect.equals(472, error.line); | 371 Expect.equals(472, error.line); |
372 Expect.equals(12, error.column); | 372 Expect.equals(12, error.column); |
373 } | 373 } |
374 return result; | 374 return result; |
375 } | 375 } |
376 | 376 |
377 static int testListAssigment() { | 377 static int testListAssigment() { |
378 int result = 0; | 378 int result = 0; |
379 { | 379 { |
380 var a = new List(5); | 380 var a = new List(5); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 class C { | 470 class C { |
471 factory C() { | 471 factory C() { |
472 return 1; // Implicit result type is 'C', not int. | 472 return 1; // Implicit result type is 'C', not int. |
473 } | 473 } |
474 } | 474 } |
475 | 475 |
476 | 476 |
477 main() { | 477 main() { |
478 TypeTest.testMain(); | 478 TypeTest.testMain(); |
479 } | 479 } |
OLD | NEW |