| 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 closures. | 5 // Tests of closures. |
| 6 | 6 |
| 7 library closures_test; | 7 library closures_test; |
| 8 | 8 |
| 9 import 'js_backend_cps_ir.dart'; | 9 import 'js_backend_cps_ir.dart'; |
| 10 | 10 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 var a; | 83 var a; |
| 84 for (var i=0; i<10; i++) { | 84 for (var i=0; i<10; i++) { |
| 85 a = () => i; | 85 a = () => i; |
| 86 } | 86 } |
| 87 print(a()); | 87 print(a()); |
| 88 } | 88 } |
| 89 """, | 89 """, |
| 90 r""" | 90 r""" |
| 91 function() { | 91 function() { |
| 92 var a = null, i = 0; | 92 var a = null, i = 0; |
| 93 while (J.getInterceptor$n(i).$lt(i, 10)) { | 93 while (i < 10) { |
| 94 a = new V.main_closure(i); | 94 a = new V.main_closure(i); |
| 95 i = J.getInterceptor$ns(i).$add(i, 1); | 95 i = i + 1; |
| 96 } | 96 } |
| 97 P.print(a.call$0()); | 97 P.print(a.call$0()); |
| 98 return null; | 98 return null; |
| 99 }"""), | 99 }"""), |
| 100 | 100 |
| 101 const TestEntry.forMethod('function(A#b)', """ | 101 const TestEntry.forMethod('function(A#b)', """ |
| 102 class A { | 102 class A { |
| 103 a() => 1; | 103 a() => 1; |
| 104 b() => () => a(); | 104 b() => () => a(); |
| 105 } | 105 } |
| 106 main() { | 106 main() { |
| 107 print(new A().b()()); | 107 print(new A().b()()); |
| 108 } | 108 } |
| 109 """, | 109 """, |
| 110 r""" | 110 r""" |
| 111 function() { | 111 function() { |
| 112 return new V.A_b_closure(this); | 112 return new V.A_b_closure(this); |
| 113 }"""), | 113 }"""), |
| 114 ]; | 114 ]; |
| 115 | 115 |
| 116 void main() { | 116 void main() { |
| 117 runTests(tests); | 117 runTests(tests); |
| 118 } | 118 } |
| OLD | NEW |