| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 main() { | 51 main() { |
| 52 for (int i = 0; foo(true); i = foo(i)) { | 52 for (int i = 0; foo(true); i = foo(i)) { |
| 53 print(1); | 53 print(1); |
| 54 if (foo(false)) break; | 54 if (foo(false)) break; |
| 55 } | 55 } |
| 56 print(2); | 56 print(2); |
| 57 }""", """ | 57 }""", """ |
| 58 function() { | 58 function() { |
| 59 var i = 0; | 59 var i = 0; |
| 60 while (V.foo(true) === true) { | 60 for (; V.foo(true) === true; i = V.foo(i)) { |
| 61 P.print(1); | 61 P.print(1); |
| 62 if (V.foo(false) === true) | 62 if (V.foo(false) === true) |
| 63 break; | 63 break; |
| 64 i = V.foo(i); | |
| 65 } | 64 } |
| 66 P.print(2); | 65 P.print(2); |
| 67 }"""), | 66 }"""), |
| 68 const TestEntry(""" | 67 const TestEntry(""" |
| 69 foo(a) => a; | 68 foo(a) => a; |
| 70 | 69 |
| 71 main() { | 70 main() { |
| 72 if (foo(true)) { | 71 if (foo(true)) { |
| 73 print(1); | 72 print(1); |
| 74 } else { | 73 } else { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 }"""), | 128 }"""), |
| 130 const TestEntry(""" | 129 const TestEntry(""" |
| 131 main() { | 130 main() { |
| 132 var list = [1,2,3,4,5,6]; | 131 var list = [1,2,3,4,5,6]; |
| 133 for (var x in list) { | 132 for (var x in list) { |
| 134 print(x); | 133 print(x); |
| 135 } | 134 } |
| 136 }""",r""" | 135 }""",r""" |
| 137 function() { | 136 function() { |
| 138 var list = [1, 2, 3, 4, 5, 6], $length = list.length, i = 0; | 137 var list = [1, 2, 3, 4, 5, 6], $length = list.length, i = 0; |
| 139 while (i < list.length) { | 138 for (; i < list.length; i = i + 1) { |
| 140 P.print(list[i]); | 139 P.print(list[i]); |
| 141 if ($length !== list.length) | 140 if ($length !== list.length) |
| 142 H.throwConcurrentModificationError(list); | 141 H.throwConcurrentModificationError(list); |
| 143 i = i + 1; | |
| 144 } | 142 } |
| 145 }"""), | 143 }"""), |
| 146 const TestEntry(""" | 144 const TestEntry(""" |
| 147 main() { | 145 main() { |
| 148 var xs = ['x', 'y', 'z'], ys = ['A', 'B', 'C']; | 146 var xs = ['x', 'y', 'z'], ys = ['A', 'B', 'C']; |
| 149 var xit = xs.iterator, yit = ys.iterator; | 147 var xit = xs.iterator, yit = ys.iterator; |
| 150 while (xit.moveNext() && yit.moveNext()) { | 148 while (xit.moveNext() && yit.moveNext()) { |
| 151 print(xit.current); | 149 print(xit.current); |
| 152 print(yit.current); | 150 print(yit.current); |
| 153 } | 151 } |
| 154 }""",r""" | 152 }""",r""" |
| 155 function() { | 153 function() { |
| 156 var xs = ["x", "y", "z"], ys = ["A", "B", "C"], $length = xs.length, length1 =
ys.length, i, i1, current, current1; | 154 var xs = ["x", "y", "z"], ys = ["A", "B", "C"], $length = xs.length, length1 =
ys.length, i, i1, current, current1; |
| 157 if ($length !== xs.length) | 155 if ($length !== xs.length) |
| 158 H.throwConcurrentModificationError(xs); | 156 H.throwConcurrentModificationError(xs); |
| 159 i = 0; | 157 i = 0; |
| 160 i1 = 0; | 158 i1 = 0; |
| 161 while (i < xs.length) { | 159 for (; i < xs.length; i = i + 1, i1 = i1 + 1) { |
| 162 current = xs[i]; | 160 current = xs[i]; |
| 163 if (length1 !== ys.length) | 161 if (length1 !== ys.length) |
| 164 H.throwConcurrentModificationError(ys); | 162 H.throwConcurrentModificationError(ys); |
| 165 if (!(i1 < ys.length)) | 163 if (!(i1 < ys.length)) |
| 166 break; | 164 break; |
| 167 current1 = ys[i1]; | 165 current1 = ys[i1]; |
| 168 P.print(current); | 166 P.print(current); |
| 169 P.print(current1); | 167 P.print(current1); |
| 170 if ($length !== xs.length) | 168 if ($length !== xs.length) |
| 171 H.throwConcurrentModificationError(xs); | 169 H.throwConcurrentModificationError(xs); |
| 172 i = i + 1; | |
| 173 i1 = i1 + 1; | |
| 174 } | 170 } |
| 175 }"""), | 171 }"""), |
| 176 ]; | 172 ]; |
| 177 | 173 |
| 178 void main() { | 174 void main() { |
| 179 runTests(tests); | 175 runTests(tests); |
| 180 } | 176 } |
| OLD | NEW |