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

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

Issue 13723002: dart2js: Fix SSA corner case with always breaking loop and failing assert (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Dart test program to test check that we don't fail to compile when an
ngeoffray 2013/04/07 09:48:50 test check -> check
6 // inlinable method contains a throw.
7
8 var x = false;
9
10 bool called;
11
12 bool callMeTrue() {
13 called = true;
14 return true;
15 }
16
17 bool callMeFalse() {
18 called = true;
19 return false;
20 }
21
22 void callMe() {
23 called = true;
24 }
25
26 testCallThenThrow(fn) {
27 called = false;
28 Expect.throws(() => fn());
29 Expect.isTrue(called);
30 }
31
32 testCall(fn) {
33 called = false;
34 fn();
35 Expect.isTrue(called);
36 }
37
38 testNoThrow(fn) {
39 called = false;
40 Expect.throws(() => fn());
41 Expect.isFalse(called);
42 }
43
44 kast(x) {
45 throw x;
46 }
47
48 ternary(a, b, c) {
49 if (x == 2) throw "ternary";
50 }
51
52 hest() => kast("hest");
53 hest2() { return kast("hest2"); }
54 foo() => true || kast("foo");
55 bar() => false || kast("foo");
56 barc() => callMeTrue() || kast("foo");
57 barCallThrow() => callMeFalse() || kast("foo");
58 baz(x) => x ? kast("baz") : 0;
59 bazc() => callMeFalse() ? kast("baz") : 0;
60 bazCallThrow() => callMeTrue() ? kast("baz") : 0;
61 fizz(x) => x ? 0 : kast("baz");
62 fizzc() => callMeTrue() ? 0 : kast("baz");
63 fizzCallThrow() => callMeFalse() ? 0 : kast("baz");
64 fuzz() => kast("baz") ? 0 : 1;
65 farce() => !kast("baz");
66 unary() => ~(kast("baz"));
67 boo() {
68 callMe();
69 x = kast("boo");
70 }
71 yo() {
72 throw kast("yo");
73 }
74 hoo() {
75 x[kast("hoo")] = 0;
76 x[kast("hoo")];
77 kast("hoo").x = 0;
78 kast("hoo").x;
79 }
80
81 switcheroo(x) {
82 switch (kast("switcheroo")) {
83 case 0:
84 boo();
85 }
86 }
87 switchertoo(x) {
88 switch (kast("switcheroo")) {
89 case boo():
90 foo();
91 }
92 }
93
94 switchenoo(x) {
95 switch (x) {
96 case callMeTrue():
97 break;
98 case kast("switchenoo"):
99 break;
100 case 42:
101 return 42;
102 }
103 }
104
105 interpole() => "inter${kast('tada!')}pole";
106 interpoleCallThrow() => "inter${callMeTrue()}...${kast('tada!')}pole";
107
108 call1() => ternary(0, kast("call1"), 1);
109 call2() => ternary(kast("call2"), 0, 1);
110 call3() => ternary(0, 1, kast("call3"));
111 call1c() => ternary(callMe(), kast("call1"), 1);
112 call3c() => ternary(callMeTrue(), 1, kast("call3"));
113 call4c() => ternary(0, callMeTrue(), kast("call3"));
114
115 sendSet() {
116 var x = kast("sendSet");
117 }
118
119 sendSetCallThrow() {
120 var x = callMe(), y = kast("sendSet");
121 }
122
123 isSend() => kast("isSend") is int;
124
125 vile() {
126 while (kast("vile")) {
127 callMe();
128 }
129 }
130
131 dovile() {
132 var x = 0;
133 do {
134 callMe();
135 x = 1;
136 } while (kast("vile"));
137 print(x);
138 }
139
140 dovileBreak() {
141 var x = 0;
142 do {
143 callMe();
144 x = 1;
145 break;
146 } while (kast("vile"));
147 return(x);
148 }
149
150 dovileContinue() {
151 var x = 0;
152 do {
153 callMe();
154 x = 1;
155 continue;
156 } while (kast("vile"));
157 return(x);
158 }
159
160 main() {
161 Expect.throws(hest);
162 Expect.throws(hest2);
163 foo();
164 Expect.throws(bar);
165 testCall(barc);
166 testCallThenThrow(barCallThrow);
167 Expect.equals(0, baz(false));
168 Expect.throws(() => baz(true));
169 testCall(bazc);
170 testCallThenThrow(bazCallThrow);
171 Expect.throws(() => fizz(false));
172 testCall(fizzc);
173 testCallThenThrow(fizzCallThrow);
174 Expect.throws(fuzz);
175 Expect.throws(farce);
176 Expect.throws(unary);
177 testCallThenThrow(boo);
178 Expect.throws(yo);
179 Expect.throws(hoo);
180 Expect.throws(switcheroo);
181 Expect.throws(switchertoo);
182 testCallThenThrow(() => switchenoo(false));
183 switchenoo(true);
184 testCall(() { try { switchenoo(x); } catch(e) { } });
185 Expect.throws(interpole);
186 testCallThenThrow(interpoleCallThrow);
187 Expect.throws(call1);
188 Expect.throws(call2);
189 Expect.throws(call3);
190 testCallThenThrow(call1c);
191 testCallThenThrow(call3c);
192 testCallThenThrow(call4c);
193 Expect.throws(sendSet);
194 testCallThenThrow(sendSetCallThrow);
195 Expect.throws(isSend);
196 testNoThrow(vile);
197 testCallThenThrow(dovile);
198 testCall(dovileBreak);
199 testCallThenThrow(dovileContinue);
200 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698