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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 L1: | 60 L1: |
61 while (P.identical(V.foo(true), true)) { | 61 while (P.identical(V.foo(true), true)) { |
62 P.print(1); | 62 P.print(1); |
63 if (!P.identical(V.foo(false), true)) | 63 if (P.identical(V.foo(false), true)) |
64 i = V.foo(i); | |
65 else | |
66 break L1; | 64 break L1; |
| 65 i = V.foo(i); |
67 } | 66 } |
68 P.print(2); | 67 P.print(2); |
69 return null; | |
70 }"""), | 68 }"""), |
71 const TestEntry(""" | 69 const TestEntry(""" |
72 foo(a) => a; | 70 foo(a) => a; |
73 | 71 |
74 main() { | 72 main() { |
75 if (foo(true)) { | 73 if (foo(true)) { |
76 print(1); | 74 print(1); |
77 } else { | 75 } else { |
78 print(2); | 76 print(2); |
79 } | 77 } |
80 print(3); | 78 print(3); |
81 }""", """ | 79 }""", """ |
82 function() { | 80 function() { |
83 V.foo(true) ? P.print(1) : P.print(2); | 81 V.foo(true) ? P.print(1) : P.print(2); |
84 P.print(3); | 82 P.print(3); |
85 return null; | |
86 }"""), | 83 }"""), |
87 const TestEntry(""" | 84 const TestEntry(""" |
88 foo(a) => a; | 85 foo(a) => a; |
89 | 86 |
90 main() { | 87 main() { |
91 if (foo(true)) { | 88 if (foo(true)) { |
92 print(1); | 89 print(1); |
93 print(1); | 90 print(1); |
94 } else { | 91 } else { |
95 print(2); | 92 print(2); |
96 print(2); | 93 print(2); |
97 } | 94 } |
98 print(3); | 95 print(3); |
99 }""", """ | 96 }""", """ |
100 function() { | 97 function() { |
101 if (V.foo(true)) { | 98 if (V.foo(true)) { |
102 P.print(1); | 99 P.print(1); |
103 P.print(1); | 100 P.print(1); |
104 } else { | 101 } else { |
105 P.print(2); | 102 P.print(2); |
106 P.print(2); | 103 P.print(2); |
107 } | 104 } |
108 P.print(3); | 105 P.print(3); |
109 return null; | |
110 }"""), | 106 }"""), |
111 const TestEntry(""" | 107 const TestEntry(""" |
112 main() { | 108 main() { |
113 if (1) { | 109 if (1) { |
114 print('bad'); | 110 print('bad'); |
115 } else { | 111 } else { |
116 print('good'); | 112 print('good'); |
117 } | 113 } |
118 }""",""" | 114 }""",""" |
119 function() { | 115 function() { |
120 P.print("good"); | 116 P.print("good"); |
121 return null; | |
122 }"""), | 117 }"""), |
123 const TestEntry(""" | 118 const TestEntry(""" |
124 foo() => 2; | 119 foo() => 2; |
125 main() { | 120 main() { |
126 if (foo()) { | 121 if (foo()) { |
127 print('bad'); | 122 print('bad'); |
128 } else { | 123 } else { |
129 print('good'); | 124 print('good'); |
130 } | 125 } |
131 }""",""" | 126 }""",""" |
132 function() { | 127 function() { |
133 V.foo(); | 128 V.foo(); |
134 P.print("good"); | 129 P.print("good"); |
135 return null; | |
136 }"""), | 130 }"""), |
137 ]; | 131 ]; |
138 | 132 |
139 void main() { | 133 void main() { |
140 runTests(tests); | 134 runTests(tests); |
141 } | 135 } |
OLD | NEW |