| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 | 4 |
| 5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 | 6 |
| 7 | 7 |
| 8 baz() {} | 8 baz() {} |
| 9 | 9 |
| 10 loop1(x) { | 10 loop1(x) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 if (x < 100) { | 31 if (x < 100) { |
| 32 while (n < x) { | 32 while (n < x) { |
| 33 n = n + 1; | 33 n = n + 1; |
| 34 baz(); | 34 baz(); |
| 35 } | 35 } |
| 36 } | 36 } |
| 37 baz(); | 37 baz(); |
| 38 return n; | 38 return n; |
| 39 } | 39 } |
| 40 | 40 |
| 41 loop4(x) { |
| 42 var n = 0; |
| 43 if (x < 100) { |
| 44 while (n < x) { |
| 45 baz(); |
| 46 n = n + 1; |
| 47 } |
| 48 } |
| 49 baz(); |
| 50 return n; |
| 51 } |
| 52 |
| 41 f1(b) { | 53 f1(b) { |
| 42 while (b) | 54 while (b) |
| 43 return 1; | 55 return 1; |
| 44 | 56 |
| 45 return 2; | 57 return 2; |
| 46 } | 58 } |
| 47 | 59 |
| 48 f2(b) { | 60 f2(b) { |
| 49 while (b) { | 61 while (b) { |
| 50 return 1; | 62 return 1; |
| 51 } | 63 } |
| 52 return 2; | 64 return 2; |
| 53 } | 65 } |
| 54 | 66 |
| 55 main() { | 67 main() { |
| 56 Expect.equals(0, loop1(-10)); | 68 Expect.equals(0, loop1(-10)); |
| 57 Expect.equals(10, loop1(10)); | 69 Expect.equals(10, loop1(10)); |
| 58 | 70 |
| 59 Expect.equals(0, loop2(-10)); | 71 Expect.equals(0, loop2(-10)); |
| 60 Expect.equals(10, loop2(10)); | 72 Expect.equals(10, loop2(10)); |
| 61 Expect.equals(0, loop2(200)); | 73 Expect.equals(0, loop2(200)); |
| 62 | 74 |
| 63 Expect.equals(0, loop3(-10)); | 75 Expect.equals(0, loop3(-10)); |
| 64 Expect.equals(10, loop3(10)); | 76 Expect.equals(10, loop3(10)); |
| 65 Expect.equals(0, loop3(200)); | 77 Expect.equals(0, loop3(200)); |
| 66 | 78 |
| 79 Expect.equals(0, loop4(-10)); |
| 80 Expect.equals(10, loop4(10)); |
| 81 Expect.equals(0, loop4(200)); |
| 82 |
| 67 Expect.equals(1, f1(true)); | 83 Expect.equals(1, f1(true)); |
| 68 Expect.equals(2, f1(false)); | 84 Expect.equals(2, f1(false)); |
| 69 Expect.equals(1, f2(true)); | 85 Expect.equals(1, f2(true)); |
| 70 Expect.equals(2, f2(false)); | 86 Expect.equals(2, f2(false)); |
| 71 } | 87 } |
| OLD | NEW |