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 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 void for1() { | 7 void for1() { |
8 var cond = true; | 8 var cond = true; |
9 var result = 0; | 9 var result = 0; |
10 for (var x = 0; cond; x = x + 1) { | 10 for (var x = 0; cond; x = x + 1) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 for (i = 0; i < 5; i++) { | 48 for (i = 0; i < 5; i++) { |
49 sum += i; | 49 sum += i; |
50 } | 50 } |
51 Expect.equals(5, i); | 51 Expect.equals(5, i); |
52 Expect.equals(10, sum); | 52 Expect.equals(10, sum); |
53 } | 53 } |
54 | 54 |
55 void for6() { | 55 void for6() { |
56 var i = 0; | 56 var i = 0; |
57 var sum = 0; | 57 var sum = 0; |
58 for(; i < 5; i++) { | 58 for (; i < 5; i++) { |
59 sum += i; | 59 sum += i; |
60 } | 60 } |
61 Expect.equals(5, i); | 61 Expect.equals(5, i); |
62 Expect.equals(10, sum); | 62 Expect.equals(10, sum); |
63 | 63 |
64 sum = 0; | 64 sum = 0; |
65 i = 0; | 65 i = 0; |
66 for(; i < 5;) { | 66 for (; i < 5;) { |
67 sum += i; | 67 sum += i; |
68 i++; | 68 i++; |
69 } | 69 } |
70 Expect.equals(5, i); | 70 Expect.equals(5, i); |
71 Expect.equals(10, sum); | 71 Expect.equals(10, sum); |
72 | 72 |
73 sum = 0; | 73 sum = 0; |
74 for(i = 0; i < 5;) { | 74 for (i = 0; i < 5;) { |
75 sum += i; | 75 sum += i; |
76 i++; | 76 i++; |
77 } | 77 } |
78 Expect.equals(5, i); | 78 Expect.equals(5, i); |
79 Expect.equals(10, sum); | 79 Expect.equals(10, sum); |
80 } | 80 } |
81 | 81 |
82 void main() { | 82 void main() { |
83 for1(); | 83 for1(); |
84 for2(); | 84 for2(); |
85 for3(); | 85 for3(); |
86 for4(); | 86 for4(); |
87 for5(); | 87 for5(); |
88 for6(); | 88 for6(); |
89 } | 89 } |
OLD | NEW |