OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 'dart:async'; | 5 import 'dart:async'; |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 import "package:async_helper/async_helper.dart"; | 7 import "package:async_helper/async_helper.dart"; |
8 import 'compiler_helper.dart'; | 8 import 'compiler_helper.dart'; |
9 | 9 |
10 const String TEST_1 = """ | 10 const String TEST_1 = """ |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 var a = [42, true]; | 227 var a = [42, true]; |
228 if (a[1]) { | 228 if (a[1]) { |
229 a[0] = 1; | 229 a[0] = 1; |
230 } else { | 230 } else { |
231 a[0] = 2; | 231 a[0] = 2; |
232 } | 232 } |
233 return a[0]; | 233 return a[0]; |
234 } | 234 } |
235 """; | 235 """; |
236 | 236 |
237 | |
238 main() { | 237 main() { |
239 test(String code, String expected) { | 238 test(String code, String expected) { |
240 return () => compileAll(code, disableInlining: false).then((generated) { | 239 return () => compileAll(code, disableInlining: false).then((generated) { |
241 Expect.isTrue(generated.contains(expected), | 240 Expect.isTrue( |
242 "Generated code didn't contain '$expected'.\n" | 241 generated.contains(expected), |
243 "Test:\n$code, Generated:\n$generated"); | 242 "Generated code didn't contain '$expected'.\n" |
244 }); | 243 "Test:\n$code, Generated:\n$generated"); |
| 244 }); |
245 } | 245 } |
| 246 |
246 asyncTest(() => Future.forEach([ | 247 asyncTest(() => Future.forEach([ |
247 test(TEST_1, 'return 42'), | 248 test(TEST_1, 'return 42'), |
248 test(TEST_2, 'return 42'), | 249 test(TEST_2, 'return 42'), |
249 test(TEST_3, 'return 84'), | 250 test(TEST_3, 'return 84'), |
250 test(TEST_4, 'return t1 + t1'), | 251 test(TEST_4, 'return t1 + t1'), |
251 test(TEST_5, 'return 84'), | 252 test(TEST_5, 'return 84'), |
252 test(TEST_6, 'return 84'), | 253 test(TEST_6, 'return 84'), |
253 test(TEST_7, 'return 32'), | 254 test(TEST_7, 'return 32'), |
254 test(TEST_8, 'return a.a'), | 255 test(TEST_8, 'return a.a'), |
255 test(TEST_9, 'return a.a'), | 256 test(TEST_9, 'return a.a'), |
256 test(TEST_10, 'return 2'), | 257 test(TEST_10, 'return 2'), |
257 test(TEST_11, 'return a.a'), | 258 test(TEST_11, 'return a.a'), |
258 test(TEST_12, 'return 6'), | 259 test(TEST_12, 'return 6'), |
259 test(TEST_13, 'return 6'), | 260 test(TEST_13, 'return 6'), |
260 test(TEST_14, 'return t1[0]'), | 261 test(TEST_14, 'return t1[0]'), |
261 test(TEST_15, 'return 42'), | 262 test(TEST_15, 'return 42'), |
262 test(TEST_16, 'return \$.a'), | 263 test(TEST_16, 'return \$.a'), |
263 test(TEST_17, 'return t1'), | 264 test(TEST_17, 'return t1'), |
264 test(TEST_18, 'return t1'), | 265 test(TEST_18, 'return t1'), |
265 ], (f) => f())); | 266 ], (f) => f())); |
266 } | 267 } |
OLD | NEW |