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 |
11 const List<TestEntry> tests = const [ | 11 const List<TestEntry> tests = const [ |
12 const TestEntry(""" | 12 const TestEntry(""" |
13 main(x) { | 13 main(x) { |
14 a() { | 14 a() { |
15 return x; | 15 return x; |
16 } | 16 } |
17 x = x + '1'; | 17 x = x + '1'; |
18 print(a()); | 18 print(a()); |
19 } | 19 } |
20 """, | 20 """, |
21 r""" | 21 r""" |
22 function(x) { | 22 function(x) { |
23 P.print(J.getInterceptor$ns(x).$add(x, "1")); | 23 P.print(J.$add$ns(x, "1")); |
24 }"""), | 24 }"""), |
25 | 25 |
26 const TestEntry(""" | 26 const TestEntry(""" |
27 main(x) { | 27 main(x) { |
28 a() { | 28 a() { |
29 return x; | 29 return x; |
30 } | 30 } |
31 x = x + '1'; | 31 x = x + '1'; |
32 print(a()); | 32 print(a()); |
33 return a; | 33 return a; |
34 } | 34 } |
35 """, | 35 """, |
36 r""" | 36 r""" |
37 function(x) { | 37 function(x) { |
38 var _box_0 = {}, a = new V.main_a(_box_0); | 38 var _box_0 = {}, a = new V.main_a(_box_0); |
39 _box_0.x = x; | 39 _box_0.x = x; |
40 _box_0.x = J.getInterceptor$ns(x = _box_0.x).$add(x, "1"); | 40 _box_0.x = J.$add$ns(_box_0.x, "1"); |
41 P.print(a.call$0()); | 41 P.print(a.call$0()); |
42 return a; | 42 return a; |
43 }"""), | 43 }"""), |
44 | 44 |
45 const TestEntry(""" | 45 const TestEntry(""" |
46 main(x) { | 46 main(x) { |
47 a() { | 47 a() { |
48 return x; | 48 return x; |
49 } | 49 } |
50 print(a()); | 50 print(a()); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 """, | 247 """, |
248 r""" | 248 r""" |
249 function(x) { | 249 function(x) { |
250 P.print(V.Foo$().get$getter().call$1(123)); | 250 P.print(V.Foo$().get$getter().call$1(123)); |
251 }"""), | 251 }"""), |
252 ]; | 252 ]; |
253 | 253 |
254 void main() { | 254 void main() { |
255 runTests(tests); | 255 runTests(tests); |
256 } | 256 } |
OLD | NEW |