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

Side by Side Diff: tests/stub-generator/src/MintMakerFullyIsolatedTest.dart

Issue 9017015: Dartc was not raising an error if an interface declared constructors without a default clause (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Moved check. Created 9 years 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // IsolateStubs=MintMakerFullyIsolatedTest.dart:Mint,Purse,PowerfulPurse 5 // IsolateStubs=MintMakerFullyIsolatedTest.dart:Mint,Purse,PowerfulPurse
6 #library("MintMakerFullyIsolatedTest-generatedTest"); 6 #library("MintMakerFullyIsolatedTest-generatedTest");
7 #import("../../isolate/src/TestFramework.dart"); 7 #import("../../isolate/src/TestFramework.dart");
8 8
9 interface Purse { 9 interface Purse default PurseImpl{
10 Purse(); 10 Purse();
11 int queryBalance(); 11 int queryBalance();
12 Purse$Proxy sproutPurse(); 12 Purse$Proxy sproutPurse();
13 // The deposit has not completed until the promise completes. If we 13 // The deposit has not completed until the promise completes. If we
14 // supported Promise<void> then this could use that. 14 // supported Promise<void> then this could use that.
15 Promise<int> deposit(int amount, Purse$Proxy source); 15 Promise<int> deposit(int amount, Purse$Proxy source);
16 } 16 }
17 17
18 interface PowerfulPurse extends Purse default PurseImpl { 18 interface PowerfulPurse extends Purse default PurseImpl {
19 PowerfulPurse(); 19 PowerfulPurse();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 s.addCompleteHandler((_) { 114 s.addCompleteHandler((_) {
115 print("PromiseMap.add move to map"); 115 print("PromiseMap.add move to map");
116 _map[s] = t; 116 _map[s] = t;
117 _incomplete.remove(s); 117 _incomplete.remove(s);
118 }); 118 });
119 return t; 119 return t;
120 } 120 }
121 121
122 Promise<T> find(S s) { 122 Promise<T> find(S s) {
123 print("PromiseMap.find"); 123 print("PromiseMap.find");
124 Promise<T> result = new Promise<T>(); 124 Promise<T> findResult = new Promise<T>();
125 s.addCompleteHandler((_) { 125 s.addCompleteHandler((unused) {
126 print("PromiseMap.find s completed"); 126 print("PromiseMap.find s completed");
127 T t = _map[s]; 127 T t = _map[s];
128 if (t != null) { 128 if (t != null) {
129 print(" immediate"); 129 print(" immediate");
130 result.complete(t); 130 findResult.complete(t);
131 return; 131 return;
132 } 132 }
133 // Otherwise, we need to wait for map[s] to complete... 133 // Otherwise, we need to wait for map[s] to complete...
134 int counter = _incomplete.length; 134 int counter = _incomplete.length;
135 if (counter == 0) { 135 if (counter == 0) {
136 print(" none incomplete"); 136 print(" none incomplete");
137 result.complete(null); 137 findResult.complete(null);
138 return; 138 return;
139 } 139 }
140 result.join(_incomplete, bool (S completed) { 140 findResult.join(_incomplete, bool _(S completed) {
141 if (completed != s) { 141 if (completed != s) {
142 if (--counter == 0) { 142 if (--counter == 0) {
143 print("PromiseMap.find failed"); 143 print("PromiseMap.find failed");
144 result.complete(null); 144 findResult.complete(null);
145 return true; 145 return true;
146 } 146 }
147 print("PromiseMap.find miss"); 147 print("PromiseMap.find miss");
148 return false; 148 return false;
149 } 149 }
150 print("PromiseMap.find complete"); 150 print("PromiseMap.find complete");
151 result.complete(_map[s]); 151 findResult.complete(_map[s]);
152 return true; 152 return true;
153 }); 153 });
154 }); 154 });
155 return result; 155 return findResult;
156 } 156 }
157 157
158 PromiseSet<S> _incomplete; 158 PromiseSet<S> _incomplete;
159 Map<S, T> _map; 159 Map<S, T> _map;
160 160
161 } 161 }
162 162
163 163
164 class MintImpl implements Mint { 164 class MintImpl implements Mint {
165 165
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 Promise<int> inner = new Promise<int>(); 265 Promise<int> inner = new Promise<int>();
266 Promise<int> inner2 = new Promise<int>(); 266 Promise<int> inner2 = new Promise<int>();
267 // FIXME(benl): it should not be necessary to wait here, I think, 267 // FIXME(benl): it should not be necessary to wait here, I think,
268 // but without this, the tests seem to execute prematurely. 268 // but without this, the tests seem to execute prematurely.
269 Promise<int> d1 = done.then((val) { 269 Promise<int> d1 = done.then((val) {
270 expect.completesWithValue(sprouted.queryBalance(), 0 + 5); 270 expect.completesWithValue(sprouted.queryBalance(), 0 + 5);
271 expect.completesWithValue(purse.queryBalance(), 100 - 5); 271 expect.completesWithValue(purse.queryBalance(), 100 - 5);
272 272
273 done = sprouted.deposit(42, purse); 273 done = sprouted.deposit(42, purse);
274 expect.completesWithValue(done, 5 + 42); 274 expect.completesWithValue(done, 5 + 42);
275 Promise<int> d2 = done.then((val) { 275 Promise<int> d2 = done.then((val_) {
276 expect.completesWithValue(sprouted.queryBalance(), 0 + 5 + 42) 276 expect.completesWithValue(sprouted.queryBalance(), 0 + 5 + 42)
277 .then((int value) => inner.complete(0)); 277 .then((int value) => inner.complete(0));
278 expect.completesWithValue(purse.queryBalance(), 100 - 5 - 42) 278 expect.completesWithValue(purse.queryBalance(), 100 - 5 - 42)
279 .then((int value) => inner2.complete(0)); 279 .then((int value) => inner2.complete(0));
280 }); 280 });
281 expect.completes(d2); 281 expect.completes(d2);
282 282
283 return 0; 283 return 0;
284 }); 284 });
285 expect.completesWithValue(d1, 0); 285 expect.completesWithValue(d1, 0);
286 Promise<int> allDone = new Promise<int>(); 286 Promise<int> allDone = new Promise<int>();
287 allDone.waitFor([d3, inner, inner2], 3); 287 allDone.waitFor([d3, inner, inner2], 3);
288 allDone.then((_) { 288 allDone.then((_) {
289 expect.succeeded(); 289 expect.succeeded();
290 print("##DONE##"); 290 print("##DONE##");
291 }); 291 });
292 } 292 }
293 293
294 } 294 }
295 295
296 main() { 296 main() {
297 runTests([MintMakerFullyIsolatedTest.testMain]); 297 runTests([MintMakerFullyIsolatedTest.testMain]);
298 } 298 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698