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 // Tests of control flow statements. | 5 // Tests of control flow statements. |
6 | 6 |
7 library control_flow_tests; | 7 library control_flow_tests; |
8 | 8 |
9 import 'js_backend_cps_ir.dart'; | 9 import 'js_backend_cps_ir.dart'; |
10 | 10 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 if (foo()) { | 120 if (foo()) { |
121 print('bad'); | 121 print('bad'); |
122 } else { | 122 } else { |
123 print('good'); | 123 print('good'); |
124 } | 124 } |
125 }""",""" | 125 }""",""" |
126 function() { | 126 function() { |
127 V.foo(); | 127 V.foo(); |
128 P.print("good"); | 128 P.print("good"); |
129 }"""), | 129 }"""), |
| 130 const TestEntry(""" |
| 131 main() { |
| 132 var list = [1,2,3,4,5,6]; |
| 133 for (var x in list) { |
| 134 print(x); |
| 135 } |
| 136 }""",r""" |
| 137 function() { |
| 138 var list = [1, 2, 3, 4, 5, 6], $length = list.length, i = 0; |
| 139 while (i < list.length) { |
| 140 P.print(list[i]); |
| 141 if ($length !== list.length) |
| 142 H.throwConcurrentModificationError(list); |
| 143 i = i + 1; |
| 144 } |
| 145 }"""), |
| 146 const TestEntry(""" |
| 147 main() { |
| 148 var xs = ['x', 'y', 'z'], ys = ['A', 'B', 'C']; |
| 149 var xit = xs.iterator, yit = ys.iterator; |
| 150 while (xit.moveNext() && yit.moveNext()) { |
| 151 print(xit.current); |
| 152 print(yit.current); |
| 153 } |
| 154 }""",r""" |
| 155 function() { |
| 156 var xs = ["x", "y", "z"], ys = ["A", "B", "C"], $length = xs.length, length1 =
ys.length, i, i1, current, current1; |
| 157 if ($length !== xs.length) |
| 158 H.throwConcurrentModificationError(xs); |
| 159 i = 0; |
| 160 i1 = 0; |
| 161 while (i < xs.length) { |
| 162 current = xs[i]; |
| 163 if (length1 !== ys.length) |
| 164 H.throwConcurrentModificationError(ys); |
| 165 if (!(i1 < ys.length)) |
| 166 break; |
| 167 current1 = ys[i1]; |
| 168 P.print(current); |
| 169 P.print(current1); |
| 170 if ($length !== xs.length) |
| 171 H.throwConcurrentModificationError(xs); |
| 172 i = i + 1; |
| 173 i1 = i1 + 1; |
| 174 } |
| 175 }"""), |
130 ]; | 176 ]; |
131 | 177 |
132 void main() { | 178 void main() { |
133 runTests(tests); | 179 runTests(tests); |
134 } | 180 } |
OLD | NEW |