| 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 // Check that we hoist instructions in a loop condition, even if that | 5 // Check that we hoist instructions in a loop condition, even if that |
| 6 // condition involves control flow. | 6 // condition involves control flow. |
| 7 | 7 |
| 8 import 'package:expect/expect.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
| 9 | |
| 10 import 'compiler_helper.dart'; | 9 import 'compiler_helper.dart'; |
| 11 | 10 |
| 12 const String TEST = ''' | 11 const String TEST = ''' |
| 13 var a = [1]; | 12 var a = [1]; |
| 14 | 13 |
| 15 main() { | 14 main() { |
| 16 int count = int.parse('42') == 42 ? 42 : null; | 15 int count = int.parse('42') == 42 ? 42 : null; |
| 17 for (int i = 0; i < count && i < a[0]; i++) { | 16 for (int i = 0; i < count && i < a[0]; i++) { |
| 18 print(i); | 17 print(i); |
| 19 } | 18 } |
| 20 a.removeLast(); | 19 a.removeLast(); |
| 21 // Ensure we don't try to generate a bailout method based on a check | 20 // Ensure we don't try to generate a bailout method based on a check |
| 22 // of [count]. | 21 // of [count]. |
| 23 count.removeLast(); | 22 count.removeLast(); |
| 24 } | 23 } |
| 25 '''; | 24 '''; |
| 26 | 25 |
| 27 main() { | 26 main() { |
| 28 compileAndMatch(TEST, 'main', | 27 asyncTest(() => compileAndMatch(TEST, 'main', |
| 29 new RegExp('if \\(typeof count !== "number"\\)(.|\\n)*while')); | 28 new RegExp('if \\(typeof count !== "number"\\)(.|\\n)*while'))); |
| 30 } | 29 } |
| OLD | NEW |