Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 import 'expect.dart'; | |
|
Kevin Millikin (Google)
2016/10/21 09:10:57
Copyright header.
Vyacheslav Egorov (Google)
2016/10/21 13:39:43
Done.
| |
| 2 | |
| 3 testFor() { | |
| 4 int current; | |
| 5 for (int i = 0; i < 100; i++) { | |
| 6 current = i; | |
| 7 if (i > 41) break; | |
| 8 } | |
| 9 Expect.isTrue(current == 42); | |
| 10 } | |
| 11 | |
| 12 testWhile() { | |
| 13 int i = 0; | |
| 14 while (i < 100) { | |
| 15 if (++i > 41) break; | |
| 16 } | |
| 17 Expect.isTrue(i == 42); | |
| 18 } | |
| 19 | |
| 20 testDoWhile() { | |
| 21 int i = 0; | |
| 22 do { | |
| 23 if (++i > 41) break; | |
| 24 } while (i < 100); | |
| 25 Expect.isTrue(i == 42); | |
| 26 } | |
| 27 | |
| 28 testLabledBreakOutermost() { | |
| 29 int i = 0; | |
| 30 outer: { | |
| 31 middle: { | |
| 32 while (i < 100) { | |
| 33 if (++i > 41) break outer; | |
| 34 } | |
| 35 i++; | |
| 36 } | |
| 37 i++; | |
| 38 } | |
| 39 Expect.isTrue(i == 42); | |
| 40 } | |
| 41 | |
| 42 testLabledBreakMiddle() { | |
| 43 int i = 0; | |
| 44 outer: { | |
| 45 middle: { | |
| 46 while (i < 100) { | |
| 47 if (++i > 41) break middle; | |
| 48 } | |
| 49 i++; | |
| 50 } | |
| 51 i++; | |
| 52 } | |
| 53 Expect.isTrue(i == 43); | |
| 54 } | |
| 55 | |
| 56 testLabledBreakInner() { | |
| 57 int i = 0; | |
| 58 outer: { | |
| 59 middle: { | |
| 60 while (i < 100) { | |
| 61 if (++i > 41) break; | |
| 62 } | |
| 63 i++; | |
| 64 } | |
| 65 i++; | |
| 66 } | |
| 67 Expect.isTrue(i == 44); | |
| 68 } | |
| 69 | |
| 70 main() { | |
| 71 testFor(); | |
| 72 testWhile(); | |
| 73 testDoWhile(); | |
| 74 testLabledBreakOutermost(); | |
| 75 testLabledBreakMiddle(); | |
| 76 testLabledBreakInner(); | |
| 77 } | |
| OLD | NEW |