| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012, 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 break1(int x, int y, int ew, int ez) { | |
| 6 int w = 1; | |
| 7 int z = 0; | |
| 8 bk1: if (x == 2) { | |
| 9 z = 1; | |
| 10 if (y == 3) { | |
| 11 w = 2; | |
| 12 break bk1; | |
| 13 } else { | |
| 14 w = 3; | |
| 15 } | |
| 16 } else { | |
| 17 z = 2; | |
| 18 if (y == 3) { | |
| 19 w = 4; | |
| 20 } else { | |
| 21 w = 5; | |
| 22 break bk1; | |
| 23 } | |
| 24 break bk1; | |
| 25 } | |
| 26 Expect.equals(ew, w); | |
| 27 Expect.equals(ez, z); | |
| 28 } | |
| 29 | |
| 30 break2(int x, int y, int ew, int ez) { | |
| 31 int w = 1; | |
| 32 int z = 0; | |
| 33 bk1: do { | |
| 34 if (x == 2) { | |
| 35 z = 1; | |
| 36 if (y == 3) { | |
| 37 w = 2; | |
| 38 break bk1; | |
| 39 } else { | |
| 40 w = 3; | |
| 41 } | |
| 42 } else { | |
| 43 z = 2; | |
| 44 if (y == 3) { | |
| 45 w = 4; | |
| 46 } else { | |
| 47 w = 5; | |
| 48 break bk1; | |
| 49 } | |
| 50 break bk1; | |
| 51 } | |
| 52 } while (false); | |
| 53 Expect.equals(ew, w); | |
| 54 Expect.equals(ez, z); | |
| 55 } | |
| 56 | |
| 57 break3(int x, int y, int ew, int ez) { | |
| 58 int w = 1; | |
| 59 int z = 0; | |
| 60 do { | |
| 61 if (x == 2) { | |
| 62 z = 1; | |
| 63 if (y == 3) { | |
| 64 w = 2; | |
| 65 break; | |
| 66 } else { | |
| 67 w = 3; | |
| 68 } | |
| 69 } else { | |
| 70 z = 2; | |
| 71 if (y == 3) { | |
| 72 w = 4; | |
| 73 } else { | |
| 74 w = 5; | |
| 75 break; | |
| 76 } | |
| 77 break; | |
| 78 } | |
| 79 } while (false); | |
| 80 Expect.equals(ew, w); | |
| 81 Expect.equals(ez, z); | |
| 82 } | |
| 83 | |
| 84 obscureBreaks(x) { | |
| 85 bool result = true; | |
| 86 bar: do { | |
| 87 if (x == 1) { | |
| 88 foo: break; | |
| 89 } else if (x == 2) { | |
| 90 foo: break bar; | |
| 91 } else if (x == 3) { | |
| 92 bar: break; | |
| 93 } else if (x == 4) { | |
| 94 break bar; | |
| 95 } else { | |
| 96 result = false; | |
| 97 } | |
| 98 } while (false); | |
| 99 return result; | |
| 100 } | |
| 101 | |
| 102 ifBreaks(x, y) { | |
| 103 int res = 2; | |
| 104 foo: if (x == 1) bar: { | |
| 105 if (y == 2) { | |
| 106 res = 4; | |
| 107 break foo; | |
| 108 } else if (y == 3) { | |
| 109 res = 5; | |
| 110 break bar; | |
| 111 } | |
| 112 res = 3; | |
| 113 } else baz: { | |
| 114 if (y == 2) { | |
| 115 res = 7; | |
| 116 break foo; | |
| 117 } else if (y == 3) { | |
| 118 res = 8; | |
| 119 break baz; | |
| 120 } | |
| 121 res = 6; | |
| 122 } | |
| 123 return res; | |
| 124 } | |
| 125 | |
| 126 main() { | |
| 127 break1(2, 3, 2, 1); | |
| 128 break1(2, 4, 3, 1); | |
| 129 break1(3, 3, 4, 2); | |
| 130 break1(3, 4, 5, 2); | |
| 131 break2(2, 3, 2, 1); | |
| 132 break2(2, 4, 3, 1); | |
| 133 break2(3, 3, 4, 2); | |
| 134 break2(3, 4, 5, 2); | |
| 135 break3(2, 3, 2, 1); | |
| 136 break3(2, 4, 3, 1); | |
| 137 break3(3, 3, 4, 2); | |
| 138 break3(3, 4, 5, 2); | |
| 139 Expect.isTrue(obscureBreaks(1), "1"); | |
| 140 Expect.isTrue(obscureBreaks(2), "2"); | |
| 141 Expect.isTrue(obscureBreaks(3), "3"); | |
| 142 Expect.isTrue(obscureBreaks(4), "4"); | |
| 143 Expect.isFalse(obscureBreaks(5), "5"); | |
| 144 Expect.equals(3, ifBreaks(1, 4)); | |
| 145 Expect.equals(4, ifBreaks(1, 2)); | |
| 146 Expect.equals(5, ifBreaks(1, 3)); | |
| 147 Expect.equals(6, ifBreaks(2, 4)); | |
| 148 Expect.equals(7, ifBreaks(2, 2)); | |
| 149 Expect.equals(8, ifBreaks(2, 3)); | |
| 150 } | |
| OLD | NEW |