Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 // Check that we hoist instructions in a loop condition, even if that | |
| 6 // condition involves control flow. | |
| 7 | |
| 8 import 'package:expect/expect.dart'; | |
| 9 | |
| 10 import 'compiler_helper.dart'; | |
| 11 | |
| 12 const String TEST = ''' | |
| 13 var a = [1]; | |
| 14 | |
| 15 main() { | |
| 16 int count = int.parse('42') == 42 ? 42 : null; | |
| 17 for (int i = 0; i < count && i < a[0]; i++) { | |
| 18 print(i); | |
| 19 } | |
| 20 a.removeLast(); | |
| 21 // Ensure we don't try to generate a bailout method based on a check | |
| 22 // of [count]. | |
| 23 count.removeLast(); | |
| 24 } | |
| 25 '''; | |
| 26 | |
| 27 main() { | |
| 28 String generated = compile(TEST, entry: 'main'); | |
| 29 int checkIndex = generated.indexOf('if (count == null)'); | |
|
karlklose
2013/08/15 12:58:02
Consider testing this with a regular expression li
ngeoffray
2013/08/15 13:55:29
Done.
| |
| 30 int loopIndex = generated.indexOf('while (true)'); | |
| 31 Expect.isTrue(checkIndex != -1); | |
| 32 Expect.isTrue(loopIndex != -1); | |
| 33 Expect.isTrue(checkIndex < loopIndex); | |
| 34 } | |
| OLD | NEW |