| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 void while1() { | |
| 6 bool cond = true; | |
| 7 var result = 0; | |
| 8 var x = 0; | |
| 9 while (cond) { | |
| 10 if (x == 10) cond = false; | |
| 11 result += x; | |
| 12 x = x + 1; | |
| 13 } | |
| 14 Expect.equals(55, result); | |
| 15 } | |
| 16 | |
| 17 void while2() { | |
| 18 var t = 0; | |
| 19 var i = 0; | |
| 20 while (i == 0) { | |
| 21 t = t + 10; | |
| 22 i++; | |
| 23 } | |
| 24 Expect.equals(10, t); | |
| 25 } | |
| 26 | |
| 27 void while3() { | |
| 28 var i = 0; | |
| 29 while (i == 1) { | |
| 30 Expect.fail('unreachable'); | |
| 31 } | |
| 32 } | |
| 33 | |
| 34 void while4() { | |
| 35 var cond1 = true; | |
| 36 var result = 0; | |
| 37 var i = 0; | |
| 38 while (cond1) { | |
| 39 if (i == 9) cond1 = false; | |
| 40 var cond2 = true; | |
| 41 var j = 0; | |
| 42 while (cond2) { | |
| 43 if (j == 9) cond2 = false; | |
| 44 result = result + 1; | |
| 45 j = j + 1; | |
| 46 } | |
| 47 i = i + 1; | |
| 48 } | |
| 49 Expect.equals(100, result); | |
| 50 } | |
| 51 | |
| 52 int while5_2() { | |
| 53 // The while condition dominates 3 blocks: the body, the block after the loop | |
| 54 // and the exit block. | |
| 55 while (true) { | |
| 56 if (true) { | |
| 57 return 499; | |
| 58 } | |
| 59 } | |
| 60 return 0; | |
| 61 } | |
| 62 | |
| 63 void while5() { | |
| 64 Expect.equals(499, while5_2()); | |
| 65 } | |
| 66 | |
| 67 void main() { | |
| 68 while1(); | |
| 69 while2(); | |
| 70 while3(); | |
| 71 while4(); | |
| 72 while5(); | |
| 73 } | |
| OLD | NEW |