| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 }"""), | 146 }"""), |
| 147 const TestEntry(""" | 147 const TestEntry(""" |
| 148 main() { | 148 main() { |
| 149 var list = [1,2,3,4,5,6]; | 149 var list = [1,2,3,4,5,6]; |
| 150 for (var x in list) { | 150 for (var x in list) { |
| 151 print(x); | 151 print(x); |
| 152 } | 152 } |
| 153 }""",r""" | 153 }""",r""" |
| 154 function() { | 154 function() { |
| 155 var list = [1, 2, 3, 4, 5, 6], i = 0, v0; | 155 var list = [1, 2, 3, 4, 5, 6], i = 0, v0; |
| 156 for (; i < 6; i = i + 1) { | 156 for (; i < 6; ++i) { |
| 157 v0 = H.S(list[i]); | 157 v0 = H.S(list[i]); |
| 158 if (typeof dartPrint == "function") | 158 if (typeof dartPrint == "function") |
| 159 dartPrint(v0); | 159 dartPrint(v0); |
| 160 else if (typeof console == "object" && typeof console.log != "undefined") | 160 else if (typeof console == "object" && typeof console.log != "undefined") |
| 161 console.log(v0); | 161 console.log(v0); |
| 162 else if (!(typeof window == "object")) { | 162 else if (!(typeof window == "object")) { |
| 163 if (!(typeof print == "function")) | 163 if (!(typeof print == "function")) |
| 164 throw "Unable to print message: " + String(v0); | 164 throw "Unable to print message: " + String(v0); |
| 165 print(v0); | 165 print(v0); |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 }"""), | 168 }"""), |
| 169 const TestEntry(""" | 169 const TestEntry(""" |
| 170 main() { | 170 main() { |
| 171 var xs = ['x', 'y', 'z'], ys = ['A', 'B', 'C']; | 171 var xs = ['x', 'y', 'z'], ys = ['A', 'B', 'C']; |
| 172 var xit = xs.iterator, yit = ys.iterator; | 172 var xit = xs.iterator, yit = ys.iterator; |
| 173 while (xit.moveNext() && yit.moveNext()) { | 173 while (xit.moveNext() && yit.moveNext()) { |
| 174 print(xit.current); | 174 print(xit.current); |
| 175 print(yit.current); | 175 print(yit.current); |
| 176 } | 176 } |
| 177 }""",r""" | 177 }""",r""" |
| 178 function() { | 178 function() { |
| 179 var xs = ["x", "y", "z"], ys = ["A", "B", "C"], i = 0, i1 = 0, current, curren
t1; | 179 var xs = ["x", "y", "z"], ys = ["A", "B", "C"], i = 0, i1 = 0, current, curren
t1; |
| 180 for (; i < 3; i = i + 1, i1 = i1 + 1) { | 180 for (; i < 3; ++i, ++i1) { |
| 181 current = xs[i]; | 181 current = xs[i]; |
| 182 if (!(i1 < 3)) | 182 if (!(i1 < 3)) |
| 183 break; | 183 break; |
| 184 current1 = ys[i1]; | 184 current1 = ys[i1]; |
| 185 P.print(current); | 185 P.print(current); |
| 186 P.print(current1); | 186 P.print(current1); |
| 187 } | 187 } |
| 188 }"""), | 188 }"""), |
| 189 ]; | 189 ]; |
| 190 | 190 |
| 191 void main() { | 191 void main() { |
| 192 runTests(tests); | 192 runTests(tests); |
| 193 } | 193 } |
| OLD | NEW |