Chromium Code Reviews| Index: tests/compiler/dart2js/js_backend_cps_ir_control_flow.dart |
| diff --git a/tests/compiler/dart2js/js_backend_cps_ir_control_flow.dart b/tests/compiler/dart2js/js_backend_cps_ir_control_flow.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e542451c942a60a3635df82f4031146d763c1e62 |
| --- /dev/null |
| +++ b/tests/compiler/dart2js/js_backend_cps_ir_control_flow.dart |
| @@ -0,0 +1,114 @@ |
| +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +// Tests of control flow statements. |
| + |
| +library control_flow_tests; |
| + |
| +import 'js_backend_cps_ir_test.dart'; |
| + |
| +const List<TestEntry> tests = const [ |
| + const TestEntry(""" |
| +main() { |
| + while (true); |
| +} |
| +""", """ |
| +function() { |
| + while (true) |
| + ; |
| +}"""), |
| + const TestEntry(""" |
| +foo(a) => a; |
| + |
| +main() { |
| + while (true) { |
| + l: while (true) { |
| + while (foo(true)) { |
| + if (foo(false)) break l; |
| + } |
| + print(1); |
| + } |
| + print(2); |
| + } |
| +} |
| +""", """ |
| +function() { |
| + L0: |
| + while (true) |
| + while (true) { |
| + while (P.identical(V.foo(true), true)) |
|
floitsch
2014/11/24 16:37:47
That will annoy us when we do optimizations.
I'm n
sigurdm
2014/11/25 08:29:50
Acknowledged.
|
| + if (P.identical(V.foo(false), true)) { |
| + P.print(2); |
| + continue L0; |
| + } |
| + P.print(1); |
| + } |
| +}"""), |
| + const TestEntry(""" |
| +foo(a) => a; |
| + |
| +main() { |
| + for (int i = 0; foo(true); i = foo(i)) { |
| + print(1); |
| + if (foo(false)) break; |
| + } |
| + print(2); |
| +}""", """ |
| +function() { |
| + var i; |
| + i = 0; |
| + L1: |
| + while (true) { |
| + if (P.identical(V.foo(true), true)) { |
| + P.print(1); |
| + if (!P.identical(V.foo(false), true)) { |
| + i = V.foo(i); |
| + continue L1; |
| + } |
| + } |
| + P.print(2); |
| + return null; |
| + } |
| +}"""), |
| +const TestEntry(""" |
| +foo(a) => a; |
| + |
| +main() { |
| + if (foo(true)) { |
| + print(1); |
| + } else { |
| + print(2); |
| + } |
| + print(3); |
| +}""", """ |
| +function() { |
| + P.identical(V.foo(true), true) ? P.print(1) : P.print(2); |
| + P.print(3); |
| + return null; |
| +}"""), |
| +const TestEntry(""" |
| +foo(a) => a; |
| + |
| +main() { |
| + if (foo(true)) { |
| + print(1); |
| + print(1); |
| + } else { |
| + print(2); |
| + print(2); |
| + } |
| + print(3); |
| +}""", """ |
| +function() { |
| + if (P.identical(V.foo(true), true)) { |
| + P.print(1); |
| + P.print(1); |
| + } else { |
| + P.print(2); |
| + P.print(2); |
| + } |
| + P.print(3); |
| + return null; |
| +}"""), |
| +]; |