Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: tests/compiler/dart2js/js_backend_cps_ir_closures_test.dart

Issue 1009053005: Do not use the namer for naming closure elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Better naming for closure/box fields. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/compiler/lib/src/js_backend/namer.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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';
11 11
12 const List<TestEntry> tests = const [ 12 const List<TestEntry> tests = const [
13 const TestEntry(""" 13 const TestEntry("""
14 main(x) { 14 main(x) {
15 a() { 15 a() {
16 return x; 16 return x;
17 } 17 }
18 x = x + '1'; 18 x = x + '1';
19 print(a()); 19 print(a());
20 } 20 }
21 """, 21 """,
22 r""" 22 r"""
23 function(x) { 23 function(x) {
24 var box_0, a; 24 var _box_0, a;
25 box_0 = {}; 25 _box_0 = {};
26 box_0.x_0 = x; 26 _box_0._captured_x_0 = x;
27 a = new V.main_a(box_0); 27 a = new V.main_a(_box_0);
28 x = box_0.x_0; 28 x = _box_0._captured_x_0;
29 box_0.x_0 = J.getInterceptor$ns(x).$add(x, "1"); 29 _box_0._captured_x_0 = J.getInterceptor$ns(x).$add(x, "1");
30 P.print(a.call$0()); 30 P.print(a.call$0());
31 return null; 31 return null;
32 }"""), 32 }"""),
33 33
34 const TestEntry(""" 34 const TestEntry("""
35 main(x) { 35 main(x) {
36 a() { 36 a() {
37 return x; 37 return x;
38 } 38 }
39 print(a()); 39 print(a());
40 } 40 }
41 """, 41 """,
42 r""" 42 r"""
43 function(x) { 43 function(x) {
44 P.print(new V.main_a(x).call$0()); 44 P.print(new V.main_a(x).call$0());
45 return null; 45 return null;
46 }"""), 46 }"""),
47 47
48 const TestEntry(""" 48 const TestEntry("""
49 main() { 49 main() {
50 var x = 122; 50 var x = 122;
51 var a = () => x; 51 var a = () => x;
52 x = x + 1; 52 x = x + 1;
53 print(a()); 53 print(a());
54 } 54 }
55 """, 55 """,
56 r""" 56 r"""
57 function() { 57 function() {
58 var box_0, a, x; 58 var _box_0, a, x;
59 box_0 = {}; 59 _box_0 = {};
60 box_0.x_0 = 122; 60 _box_0._captured_x_0 = 122;
61 a = new V.main_closure(box_0); 61 a = new V.main_closure(_box_0);
62 x = box_0.x_0; 62 x = _box_0._captured_x_0;
63 box_0.x_0 = J.getInterceptor$ns(x).$add(x, 1); 63 _box_0._captured_x_0 = J.getInterceptor$ns(x).$add(x, 1);
64 P.print(a.call$0()); 64 P.print(a.call$0());
65 return null; 65 return null;
66 }"""), 66 }"""),
67 67
68 const TestEntry(""" 68 const TestEntry("""
69 main() { 69 main() {
70 var x = 122; 70 var x = 122;
71 var a = () { 71 var a = () {
72 var y = x; 72 var y = x;
73 return () => y; 73 return () => y;
74 }; 74 };
75 x = x + 1; 75 x = x + 1;
76 print(a()()); 76 print(a()());
77 } 77 }
78 """, 78 """,
79 r""" 79 r"""
80 function() { 80 function() {
81 var box_0, a, x; 81 var _box_0, a, x;
82 box_0 = {}; 82 _box_0 = {};
83 box_0.x_0 = 122; 83 _box_0._captured_x_0 = 122;
84 a = new V.main_closure(box_0); 84 a = new V.main_closure(_box_0);
85 x = box_0.x_0; 85 x = _box_0._captured_x_0;
86 box_0.x_0 = J.getInterceptor$ns(x).$add(x, 1); 86 _box_0._captured_x_0 = J.getInterceptor$ns(x).$add(x, 1);
87 P.print(a.call$0().call$0()); 87 P.print(a.call$0().call$0());
88 return null; 88 return null;
89 }"""), 89 }"""),
90 90
91 const TestEntry(""" 91 const TestEntry("""
92 main() { 92 main() {
93 var a; 93 var a;
94 for (var i=0; i<10; i++) { 94 for (var i=0; i<10; i++) {
95 a = () => i; 95 a = () => i;
96 } 96 }
(...skipping 24 matching lines...) Expand all
121 """, 121 """,
122 r""" 122 r"""
123 function() { 123 function() {
124 return new V.A_b_closure(this); 124 return new V.A_b_closure(this);
125 }"""), 125 }"""),
126 ]; 126 ];
127 127
128 void main() { 128 void main() {
129 runTests(tests); 129 runTests(tests);
130 } 130 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/namer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698