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