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

Side by Side Diff: tests/language/inlined_throw_test.dart

Issue 13947004: dart2js: Allow 'throw' when inlining (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Nicolas' Code review feedback Created 7 years, 8 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // Dart test program to test check that we don't fail to compile when an 5 // Dart test program to test check that we don't fail to compile when an
6 // inlinable method contains a throw. 6 // inlinable method contains a throw.
7 7
8 import 'package:expect/expect.dart'; 8 import 'package:expect/expect.dart';
9 9
10 var x = false; 10 var x = false;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 fuzz() => kast("baz") ? 0 : 1; 66 fuzz() => kast("baz") ? 0 : 1;
67 farce() => !kast("baz"); 67 farce() => !kast("baz");
68 unary() => ~(kast("baz")); 68 unary() => ~(kast("baz"));
69 boo() { 69 boo() {
70 callMe(); 70 callMe();
71 x = kast("boo"); 71 x = kast("boo");
72 } 72 }
73 yo() { 73 yo() {
74 throw kast("yo"); 74 throw kast("yo");
75 } 75 }
76 bin() {
77 return 5 * kast("bin");
78 }
79 binCallThrow() {
80 return callMe() * kast("binct");
81 }
76 hoo() { 82 hoo() {
77 x[kast("hoo")] = 0; 83 x[kast("hoo")] = 0;
78 x[kast("hoo")]; 84 x[kast("hoo")];
79 kast("hoo").x = 0; 85 kast("hoo").x = 0;
80 kast("hoo").x; 86 kast("hoo").x;
81 } 87 }
82 88
83 switcheroo() { 89 switcheroo() {
84 switch (kast("switcheroo")) { 90 switch (kast("switcheroo")) {
85 case 0: 91 case 0:
86 boo(); 92 boo();
87 } 93 }
88 } 94 }
89 95
96 class ThrowConstructor {
97 ThrowConstructor() :
98 foo = callMeTrue(),
99 bar = kast("ThrowConstructor") {
100 called = false;
101 }
102
103 bool foo;
104 var bar;
105 }
106
107 throwConstructor() {
108 called = false;
109 return new ThrowConstructor();
110 }
111
112 cascade() {
113 return new List()..add(callMeTrue())..add(kast("cascade"));
114 }
115
90 interpole() => "inter${kast('tada!')}pole"; 116 interpole() => "inter${kast('tada!')}pole";
91 interpoleCallThrow() => "inter${callMeTrue()}...${kast('tada!')}pole"; 117 interpoleCallThrow() => "inter${callMeTrue()}...${kast('tada!')}pole";
92 118
93 call1() => ternary(0, kast("call1"), 1); 119 call1() => ternary(0, kast("call1"), 1);
94 call2() => ternary(kast("call2"), 0, 1); 120 call2() => ternary(kast("call2"), 0, 1);
95 call3() => ternary(0, 1, kast("call3")); 121 call3() => ternary(0, 1, kast("call3"));
96 call1c() => ternary(callMe(), kast("call1"), 1); 122 call1c() => ternary(callMe(), kast("call1"), 1);
97 call3c() => ternary(callMeTrue(), 1, kast("call3")); 123 call3c() => ternary(callMeTrue(), 1, kast("call3"));
98 call4c() => ternary(0, callMeTrue(), kast("call3")); 124 call4c() => ternary(0, callMeTrue(), kast("call3"));
99 125
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 dovileContinue() { 161 dovileContinue() {
136 var x = 0; 162 var x = 0;
137 do { 163 do {
138 callMe(); 164 callMe();
139 x = 1; 165 x = 1;
140 continue; 166 continue;
141 } while (kast("vile")); 167 } while (kast("vile"));
142 return(x); 168 return(x);
143 } 169 }
144 170
171 dovileBreakContinue(x) {
172 do {
173 callMe();
174 if (x == 1) break;
175 continue;
176 } while (kast("vile"));
177 return(x);
178 }
179
180 faar1() {
181 callMe();
182 for (kast("faar"); called = false; called = false) {
183 called = false;
184 }
185 }
186
187 faar2() {
188 for (callMe(); kast("faar"); called = false) {
189 called = false;
190 }
191 }
192
193 faar3() {
194 for (; true; kast("faar")) {
195 callMe();
196 }
197 called = false;
198 }
199
200 faar4() {
201 callMe();
202 for (kast("faar"); called = false; called = false) {
203 called = false;
204 continue;
205 }
206 }
207
208 faar5() {
209 for (callMe(); kast("faar"); called = false) {
210 called = false;
211 continue;
212 }
213 }
214
215 faar6() {
216 for (; true; kast("faar")) {
217 callMe();
218 continue;
219 }
220 called = false;
221 }
222
223 faar7() {
224 callMe();
225 for (kast("faar"); called = false; called = false) {
226 called = false;
227 break;
228 }
229 }
230
231 faar8() {
232 for (callMe(); kast("faar"); called = false) {
233 called = false;
234 break;
235 }
236 }
237
238 faar9() {
239 for (; true; kast("faar")) {
240 callMe();
241 break;
242 called = false;
243 }
244 }
245
145 main() { 246 main() {
146 Expect.throws(hest); 247 Expect.throws(hest);
147 Expect.throws(hest2); 248 Expect.throws(hest2);
148 foo(); 249 foo();
149 Expect.throws(bar); 250 Expect.throws(bar);
150 testCall(barc); 251 testCall(barc);
151 testCallThenThrow(barCallThrow); 252 testCallThenThrow(barCallThrow);
152 Expect.equals(0, baz(false)); 253 Expect.equals(0, baz(false));
153 Expect.throws(() => baz(true)); 254 Expect.throws(() => baz(true));
154 testCall(bazc); 255 testCall(bazc);
155 testCallThenThrow(bazCallThrow); 256 testCallThenThrow(bazCallThrow);
156 Expect.throws(() => fizz(false)); 257 Expect.throws(() => fizz(false));
157 testCall(fizzc); 258 testCall(fizzc);
158 testCallThenThrow(fizzCallThrow); 259 testCallThenThrow(fizzCallThrow);
159 Expect.throws(fuzz); 260 Expect.throws(fuzz);
160 Expect.throws(farce); 261 Expect.throws(farce);
161 Expect.throws(unary); 262 Expect.throws(unary);
162 testCallThenThrow(boo); 263 testCallThenThrow(boo);
163 Expect.throws(yo); 264 Expect.throws(yo);
265 Expect.throws(bin);
266 testCallThenThrow(binCallThrow);
164 Expect.throws(hoo); 267 Expect.throws(hoo);
165 Expect.throws(switcheroo); 268 Expect.throws(switcheroo);
166 Expect.throws(interpole); 269 Expect.throws(interpole);
167 testCallThenThrow(interpoleCallThrow); 270 testCallThenThrow(interpoleCallThrow);
168 Expect.throws(call1); 271 Expect.throws(call1);
169 Expect.throws(call2); 272 Expect.throws(call2);
170 Expect.throws(call3); 273 Expect.throws(call3);
171 testCallThenThrow(call1c); 274 testCallThenThrow(call1c);
172 testCallThenThrow(call3c); 275 testCallThenThrow(call3c);
173 testCallThenThrow(call4c); 276 testCallThenThrow(call4c);
174 Expect.throws(sendSet); 277 Expect.throws(sendSet);
175 testCallThenThrow(sendSetCallThrow); 278 testCallThenThrow(sendSetCallThrow);
176 Expect.throws(isSend); 279 Expect.throws(isSend);
177 testNoThrow(vile); 280 testNoThrow(vile);
178 testCallThenThrow(dovile); 281 testCallThenThrow(dovile);
179 testCall(dovileBreak); 282 testCall(dovileBreak);
180 testCallThenThrow(dovileContinue); 283 testCallThenThrow(dovileContinue);
284 testCallThenThrow(throwConstructor);
285 testCallThenThrow(cascade);
286 dovileBreakContinue(1);
287 testCallThenThrow(faar1);
288 testCallThenThrow(faar2);
289 testCallThenThrow(faar3);
290 testCallThenThrow(faar4);
291 testCallThenThrow(faar5);
292 testCallThenThrow(faar6);
293 testCallThenThrow(faar7);
294 testCallThenThrow(faar8);
295 testCall(faar9);
181 } 296 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698