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

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

Issue 1175973005: dart2js cps: Introduce some built-in operators in type propagation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Status files Created 5 years, 6 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
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 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 const TestEntry(""" 45 const TestEntry("""
46 main() { 46 main() {
47 var x = 122; 47 var x = 122;
48 var a = () => x; 48 var a = () => x;
49 x = x + 1; 49 x = x + 1;
50 print(a()); 50 print(a());
51 } 51 }
52 """, 52 """,
53 r""" 53 r"""
54 function() { 54 function() {
55 var _box_0 = {}, a, x; 55 var _box_0 = {}, a;
56 _box_0._captured_x_0 = 122; 56 _box_0._captured_x_0 = 122;
57 a = new V.main_closure(_box_0); 57 a = new V.main_closure(_box_0);
58 _box_0._captured_x_0 = J.getInterceptor$ns(x = _box_0._captured_x_0).$add(x, 1 ); 58 _box_0._captured_x_0 = _box_0._captured_x_0 + 1;
59 P.print(a.call$0()); 59 P.print(a.call$0());
60 return null; 60 return null;
61 }"""), 61 }"""),
62 62
63 const TestEntry(""" 63 const TestEntry("""
64 main() { 64 main() {
65 var x = 122; 65 var x = 122;
66 var a = () { 66 var a = () {
67 var y = x; 67 var y = x;
68 return () => y; 68 return () => y;
69 }; 69 };
70 x = x + 1; 70 x = x + 1;
71 print(a()()); 71 print(a()());
72 } 72 }
73 """, 73 """,
74 r""" 74 r"""
75 function() { 75 function() {
76 var _box_0 = {}, a, x; 76 var _box_0 = {}, a;
77 _box_0._captured_x_0 = 122; 77 _box_0._captured_x_0 = 122;
78 a = new V.main_closure(_box_0); 78 a = new V.main_closure(_box_0);
79 _box_0._captured_x_0 = J.getInterceptor$ns(x = _box_0._captured_x_0).$add(x, 1 ); 79 _box_0._captured_x_0 = _box_0._captured_x_0 + 1;
80 P.print(a.call$0().call$0()); 80 P.print(a.call$0().call$0());
81 return null; 81 return null;
82 }"""), 82 }"""),
83 83
84 const TestEntry(""" 84 const TestEntry("""
85 main() { 85 main() {
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 (P.identical(J.getInterceptor$n(i).$lt(i, 10), true)) { 96 while (J.getInterceptor$n(i).$lt(i, 10)) {
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698