| 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 // VMOptions=-DUSE_CPS_IR=true | 4 // VMOptions=-DUSE_CPS_IR=true |
| 5 | 5 |
| 6 // Tests of closures. | 6 // Tests of closures. |
| 7 | 7 |
| 8 library closures_test; | 8 library closures_test; |
| 9 | 9 |
| 10 import 'js_backend_cps_ir.dart'; | 10 import 'js_backend_cps_ir.dart'; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 main() { | 95 main() { |
| 96 var a; | 96 var a; |
| 97 for (var i=0; i<10; i++) { | 97 for (var i=0; i<10; i++) { |
| 98 a = () => i; | 98 a = () => i; |
| 99 } | 99 } |
| 100 print(a()); | 100 print(a()); |
| 101 } | 101 } |
| 102 """, | 102 """, |
| 103 r""" | 103 r""" |
| 104 function() { | 104 function() { |
| 105 var a, box_0, i, v0, box_01, v1; | 105 var a, i, v0, v1; |
| 106 a = null; | 106 a = null; |
| 107 box_0 = {}; | 107 i = 0; |
| 108 box_0.i_0 = 0; | |
| 109 while (true) { | 108 while (true) { |
| 110 i = box_0.i_0; | |
| 111 v0 = 10; | 109 v0 = 10; |
| 112 if (P.identical(J.getInterceptor(i).$lt(i, v0), true)) { | 110 if (P.identical(J.getInterceptor(i).$lt(i, v0), true)) { |
| 113 a = new V.main_closure(box_0); | 111 a = new V.main_closure(i); |
| 114 box_01 = {}; | |
| 115 box_01.i_0 = box_0.i_0; | |
| 116 i = box_01.i_0; | |
| 117 v1 = 1; | 112 v1 = 1; |
| 118 box_01.i_0 = J.getInterceptor(i).$add(i, v1); | 113 i = J.getInterceptor(i).$add(i, v1); |
| 119 box_0 = box_01; | |
| 120 } else { | 114 } else { |
| 121 P.print(a.call$0()); | 115 P.print(a.call$0()); |
| 122 return null; | 116 return null; |
| 123 } | 117 } |
| 124 } | 118 } |
| 125 }"""), | 119 }"""), |
| 126 ]; | 120 ]; |
| 127 | 121 |
| 128 void main() { | 122 void main() { |
| 129 runTests(tests); | 123 runTests(tests); |
| 130 } | 124 } |
| OLD | NEW |