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

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

Issue 861093002: Support intercepted getters, setters and index operations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Only reject instance members that need interceptors and disable a test that we do not support yet. Created 5 years, 10 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
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, v0; 24 var box_0, a, v0;
25 box_0 = {}; 25 box_0 = {};
26 box_0.x_0 = x; 26 box_0.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.x_0;
29 v0 = "1"; 29 v0 = "1";
30 box_0.x_0 = J.getInterceptor(x).$add(x, v0); 30 box_0.x_0 = J.getInterceptor$ns(x).$add(x, v0);
31 P.print(a.call$0()); 31 P.print(a.call$0());
32 return null; 32 return null;
33 }"""), 33 }"""),
34 34
35 const TestEntry(""" 35 const TestEntry("""
36 main(x) { 36 main(x) {
37 a() { 37 a() {
38 return x; 38 return x;
39 } 39 }
40 print(a()); 40 print(a());
(...skipping 14 matching lines...) Expand all
55 } 55 }
56 """, 56 """,
57 r""" 57 r"""
58 function() { 58 function() {
59 var box_0, a, x, v0; 59 var box_0, a, x, v0;
60 box_0 = {}; 60 box_0 = {};
61 box_0.x_0 = 122; 61 box_0.x_0 = 122;
62 a = new V.main_closure(box_0); 62 a = new V.main_closure(box_0);
63 x = box_0.x_0; 63 x = box_0.x_0;
64 v0 = 1; 64 v0 = 1;
65 box_0.x_0 = J.getInterceptor(x).$add(x, v0); 65 box_0.x_0 = J.getInterceptor$ns(x).$add(x, v0);
66 P.print(a.call$0()); 66 P.print(a.call$0());
67 return null; 67 return null;
68 }"""), 68 }"""),
69 69
70 const TestEntry(""" 70 const TestEntry("""
71 main() { 71 main() {
72 var x = 122; 72 var x = 122;
73 var a = () { 73 var a = () {
74 var y = x; 74 var y = x;
75 return () => y; 75 return () => y;
76 }; 76 };
77 x = x + 1; 77 x = x + 1;
78 print(a()()); 78 print(a()());
79 } 79 }
80 """, 80 """,
81 r""" 81 r"""
82 function() { 82 function() {
83 var box_0, a, x, v0; 83 var box_0, a, x, v0;
84 box_0 = {}; 84 box_0 = {};
85 box_0.x_0 = 122; 85 box_0.x_0 = 122;
86 a = new V.main_closure(box_0); 86 a = new V.main_closure(box_0);
87 x = box_0.x_0; 87 x = box_0.x_0;
88 v0 = 1; 88 v0 = 1;
89 box_0.x_0 = J.getInterceptor(x).$add(x, v0); 89 box_0.x_0 = J.getInterceptor$ns(x).$add(x, v0);
90 P.print(a.call$0().call$0()); 90 P.print(a.call$0().call$0());
91 return null; 91 return null;
92 }"""), 92 }"""),
93 93
94 const TestEntry(""" 94 const TestEntry("""
95 main() { 95 main() {
96 var a; 96 var a;
97 for (var i=0; i<10; i++) { 97 for (var i=0; i<10; i++) {
98 a = () => i; 98 a = () => i;
99 } 99 }
100 print(a()); 100 print(a());
101 } 101 }
102 """, 102 """,
103 r""" 103 r"""
104 function() { 104 function() {
105 var a, i, v0, v1; 105 var a, i, v0, v1;
106 a = null; 106 a = null;
107 i = 0; 107 i = 0;
108 while (true) { 108 while (true) {
109 v0 = 10; 109 v0 = 10;
110 if (P.identical(J.getInterceptor(i).$lt(i, v0), true)) { 110 if (P.identical(J.getInterceptor$n(i).$lt(i, v0), true)) {
111 a = new V.main_closure(i); 111 a = new V.main_closure(i);
112 v1 = 1; 112 v1 = 1;
113 i = J.getInterceptor(i).$add(i, v1); 113 i = J.getInterceptor$ns(i).$add(i, v1);
114 } else { 114 } else {
115 P.print(a.call$0()); 115 P.print(a.call$0());
116 return null; 116 return null;
117 } 117 }
118 } 118 }
119 }"""), 119 }"""),
120 ]; 120 ];
121 121
122 void main() { 122 void main() {
123 runTests(tests); 123 runTests(tests);
124 } 124 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/codegen/unsugar.dart ('k') | tests/compiler/dart2js/js_backend_cps_ir_interceptors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698