OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 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 | 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 // Dart test program for testing do while statement. | 4 // Dart test program for testing do while statement. |
5 | 5 |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 class Helper { | 8 class Helper { |
9 static int f1(bool b) { | 9 static int f1(bool b) { |
10 do return 1; | 10 do return 1; while (b); |
11 while (b); | |
12 return 2; | 11 return 2; |
13 } | 12 } |
14 | 13 |
15 static int f2(bool b) { | 14 static int f2(bool b) { |
16 do { | 15 do { |
17 return 1; | 16 return 1; |
18 } while (b); | 17 } while (b); |
19 return 2; | 18 return 2; |
20 } | 19 } |
21 | 20 |
22 static int f3(bool b) { | 21 static int f3(bool b) { |
23 do | 22 do ; while (b); |
24 ; | |
25 while (b); | |
26 return 2; | 23 return 2; |
27 } | 24 } |
28 | 25 |
29 static int f4(bool b) { | 26 static int f4(bool b) { |
30 do { | 27 do {} while (b); |
31 } while (b); | |
32 return 2; | 28 return 2; |
33 } | 29 } |
34 | 30 |
35 static int f5(int n) { | 31 static int f5(int n) { |
36 int i = 0; | 32 int i = 0; |
37 do { | 33 do { |
38 i++; | 34 i++; |
39 } while (i < n); | 35 } while (i < n); |
40 return i; | 36 return i; |
41 } | 37 } |
(...skipping 12 matching lines...) Expand all Loading... |
54 Expect.equals(1, Helper.f5(0)); | 50 Expect.equals(1, Helper.f5(0)); |
55 Expect.equals(1, Helper.f5(1)); | 51 Expect.equals(1, Helper.f5(1)); |
56 Expect.equals(2, Helper.f5(2)); | 52 Expect.equals(2, Helper.f5(2)); |
57 Expect.equals(3, Helper.f5(3)); | 53 Expect.equals(3, Helper.f5(3)); |
58 } | 54 } |
59 } | 55 } |
60 | 56 |
61 main() { | 57 main() { |
62 DoWhileTest.testMain(); | 58 DoWhileTest.testMain(); |
63 } | 59 } |
OLD | NEW |