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

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

Issue 1203423003: dart2js cps: Better fallthrough analysis and eliminate "return null". (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update tests Created 5 years, 5 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 for basic functionality. 5 // Tests for basic functionality.
6 6
7 library basic_tests; 7 library basic_tests;
8 8
9 import 'js_backend_cps_ir.dart'; 9 import 'js_backend_cps_ir.dart';
10 10
(...skipping 16 matching lines...) Expand all
27 function() { 27 function() {
28 var l = [1, 2, 3], m = P.LinkedHashMap_LinkedHashMap$_literal(["s", 1]); 28 var l = [1, 2, 3], m = P.LinkedHashMap_LinkedHashMap$_literal(["s", 1]);
29 P.print("()"); 29 P.print("()");
30 P.print("(true)"); 30 P.print("(true)");
31 P.print("(1)"); 31 P.print("(1)");
32 P.print("(" + H.S([1, 2, 3]) + ")"); 32 P.print("(" + H.S([1, 2, 3]) + ")");
33 P.print("(" + H.S(P.LinkedHashMap_LinkedHashMap$_literal(["s", 1])) + ")"); 33 P.print("(" + H.S(P.LinkedHashMap_LinkedHashMap$_literal(["s", 1])) + ")");
34 P.print("(1)"); 34 P.print("(1)");
35 P.print("(" + H.S(l) + ")"); 35 P.print("(" + H.S(l) + ")");
36 P.print("(" + H.S(m) + ")"); 36 P.print("(" + H.S(m) + ")");
37 return null;
38 }"""), 37 }"""),
39 const TestEntry(""" 38 const TestEntry("""
40 foo(a, [b = "b"]) => b; 39 foo(a, [b = "b"]) => b;
41 bar(a, {b: "b", c: "c"}) => c; 40 bar(a, {b: "b", c: "c"}) => c;
42 main() { 41 main() {
43 foo(0); 42 foo(0);
44 foo(1, 2); 43 foo(1, 2);
45 bar(3); 44 bar(3);
46 bar(4, b: 5); 45 bar(4, b: 5);
47 bar(6, c: 7); 46 bar(6, c: 7);
48 bar(8, b: 9, c: 10); 47 bar(8, b: 9, c: 10);
49 } 48 }
50 """, 49 """,
51 """ 50 """
52 function() { 51 function() {
53 V.foo(0, "b"); 52 V.foo(0, "b");
54 V.foo(1, 2); 53 V.foo(1, 2);
55 V.bar(3, "b", "c"); 54 V.bar(3, "b", "c");
56 V.bar(4, 5, "c"); 55 V.bar(4, 5, "c");
57 V.bar(6, "b", 7); 56 V.bar(6, "b", 7);
58 V.bar(8, 9, 10); 57 V.bar(8, 9, 10);
59 return null;
60 }"""), 58 }"""),
61 const TestEntry( 59 const TestEntry(
62 """ 60 """
63 foo(a) { 61 foo(a) {
64 return a; 62 return a;
65 } 63 }
66 main() { 64 main() {
67 var a = 10; 65 var a = 10;
68 var b = 1; 66 var b = 1;
69 var t; 67 var t;
70 t = a; 68 t = a;
71 a = b; 69 a = b;
72 b = t; 70 b = t;
73 print(a); 71 print(a);
74 print(b); 72 print(b);
75 print(b); 73 print(b);
76 print(foo(a)); 74 print(foo(a));
77 } 75 }
78 """, 76 """,
79 """ 77 """
80 function() { 78 function() {
81 var a = 10, b = 1; 79 var a = 10, b = 1;
82 P.print(b); 80 P.print(b);
83 P.print(a); 81 P.print(a);
84 P.print(a); 82 P.print(a);
85 P.print(V.foo(b)); 83 P.print(V.foo(b));
86 return null;
87 }"""), 84 }"""),
88 const TestEntry( 85 const TestEntry(
89 """ 86 """
90 foo() { return 42; } 87 foo() { return 42; }
91 main() { return foo(); } 88 main() { return foo(); }
92 """, 89 """,
93 """function() { 90 """function() {
94 return V.foo(); 91 return V.foo();
95 }"""), 92 }"""),
96 const TestEntry("main() {}"), 93 const TestEntry("main() {}"),
97 const TestEntry("main() { return 42; }"), 94 const TestEntry("main() { return 42; }"),
98 const TestEntry("main() { return; }", """ 95 const TestEntry("main() { return; }", """
99 function() { 96 function() {
100 return null;
101 }"""), 97 }"""),
102 // Constructor invocation 98 // Constructor invocation
103 const TestEntry(""" 99 const TestEntry("""
104 main() { 100 main() {
105 print(new Set()); 101 print(new Set());
106 print(new Set.from([1, 2, 3])); 102 print(new Set.from([1, 2, 3]));
107 }""", r""" 103 }""", r"""
108 function() { 104 function() {
109 P.print(P.LinkedHashSet_LinkedHashSet(null, null, null, null)); 105 P.print(P.LinkedHashSet_LinkedHashSet(null, null, null, null));
110 P.print(P.LinkedHashSet_LinkedHashSet$from([1, 2, 3], null)); 106 P.print(P.LinkedHashSet_LinkedHashSet$from([1, 2, 3], null));
111 return null;
112 }"""), 107 }"""),
113 // Call synthetic constructor. 108 // Call synthetic constructor.
114 const TestEntry(""" 109 const TestEntry("""
115 class C {} 110 class C {}
116 main() { 111 main() {
117 print(new C()); 112 print(new C());
118 }"""), 113 }"""),
119 // Method invocation 114 // Method invocation
120 const TestEntry(""" 115 const TestEntry("""
121 main() { 116 main() {
122 print(new DateTime.now().isBefore(new DateTime.now())); 117 print(new DateTime.now().isBefore(new DateTime.now()));
123 }""", r""" 118 }""", r"""
124 function() { 119 function() {
125 P.print(P.DateTime$now().isBefore$1(P.DateTime$now())); 120 P.print(P.DateTime$now().isBefore$1(P.DateTime$now()));
126 return null;
127 }"""), 121 }"""),
128 // Static calls 122 // Static calls
129 const TestEntry(""" 123 const TestEntry("""
130 foo() { print(42); } 124 foo() { print(42); }
131 main() { foo(); } 125 main() { foo(); }
132 """, r""" 126 """, r"""
133 function() { 127 function() {
134 V.foo(); 128 V.foo();
135 return null;
136 }"""), 129 }"""),
137 // Static getters 130 // Static getters
138 const TestEntry(""" 131 const TestEntry("""
139 var foo = 42; 132 var foo = 42;
140 main() { print(foo); } 133 main() { print(foo); }
141 """, r""" 134 """, r"""
142 function() { 135 function() {
143 P.print($.foo); 136 P.print($.foo);
144 return null;
145 }"""), 137 }"""),
146 const TestEntry(""" 138 const TestEntry("""
147 get foo { print(42); } 139 get foo { print(42); }
148 main() { foo; } 140 main() { foo; }
149 """, r""" 141 """, r"""
150 function() { 142 function() {
151 V.foo(); 143 V.foo();
152 return null;
153 }"""), 144 }"""),
154 // Static setters 145 // Static setters
155 const TestEntry(""" 146 const TestEntry("""
156 var foo = 0; 147 var foo = 0;
157 main() { print(foo = 42); } 148 main() { print(foo = 42); }
158 """, r""" 149 """, r"""
159 function() { 150 function() {
160 var v0 = 42; 151 var v0 = 42;
161 $.foo = v0; 152 $.foo = v0;
162 P.print(v0); 153 P.print(v0);
163 return null;
164 }"""), 154 }"""),
165 const TestEntry(""" 155 const TestEntry("""
166 set foo(x) { print(x); } 156 set foo(x) { print(x); }
167 main() { foo = 42; } 157 main() { foo = 42; }
168 """, r""" 158 """, r"""
169 function() { 159 function() {
170 V.foo(42); 160 V.foo(42);
171 return null;
172 }"""), 161 }"""),
173 // Assert 162 // Assert
174 const TestEntry(""" 163 const TestEntry("""
175 foo() { print('X'); } 164 foo() { print('X'); }
176 main() { 165 main() {
177 assert(true); 166 assert(true);
178 assert(false); 167 assert(false);
179 assert(foo()); 168 assert(foo());
180 print('Done'); 169 print('Done');
181 }""", r""" 170 }""", r"""
182 function() { 171 function() {
183 P.print("Done"); 172 P.print("Done");
184 return null;
185 }""") 173 }""")
186 ]; 174 ];
187 175
188 176
189 void main() { 177 void main() {
190 runTests(tests); 178 runTests(tests);
191 } 179 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart ('k') | tests/compiler/dart2js/js_backend_cps_ir_closures_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698