| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 var a; | 79 var a; |
| 80 for (var i=0; i<10; i++) { | 80 for (var i=0; i<10; i++) { |
| 81 a = () => i; | 81 a = () => i; |
| 82 } | 82 } |
| 83 print(a()); | 83 print(a()); |
| 84 } | 84 } |
| 85 """, | 85 """, |
| 86 r""" | 86 r""" |
| 87 function() { | 87 function() { |
| 88 var a = null, i = 0; | 88 var a = null, i = 0; |
| 89 while (i < 10) { | 89 for (; i < 10; a = new V.main_closure(i), i = i + 1) |
| 90 a = new V.main_closure(i); | 90 ; |
| 91 i = i + 1; | |
| 92 } | |
| 93 P.print(a.call$0()); | 91 P.print(a.call$0()); |
| 94 }"""), | 92 }"""), |
| 95 | 93 |
| 96 const TestEntry.forMethod('function(A#b)', """ | 94 const TestEntry.forMethod('function(A#b)', """ |
| 97 class A { | 95 class A { |
| 98 a() => 1; | 96 a() => 1; |
| 99 b() => () => a(); | 97 b() => () => a(); |
| 100 } | 98 } |
| 101 main() { | 99 main() { |
| 102 print(new A().b()()); | 100 print(new A().b()()); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 """, | 182 """, |
| 185 r""" | 183 r""" |
| 186 function(x) { | 184 function(x) { |
| 187 P.print(V.Foo$().getter$1(123)); | 185 P.print(V.Foo$().getter$1(123)); |
| 188 }"""), | 186 }"""), |
| 189 ]; | 187 ]; |
| 190 | 188 |
| 191 void main() { | 189 void main() { |
| 192 runTests(tests); | 190 runTests(tests); |
| 193 } | 191 } |
| OLD | NEW |