| OLD | NEW |
| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:fake_async/fake_async.dart'; | 7 import 'package:fake_async/fake_async.dart'; |
| 8 import 'package:pool/pool.dart'; | 8 import 'package:pool/pool.dart'; |
| 9 import 'package:stack_trace/stack_trace.dart'; | 9 import 'package:stack_trace/stack_trace.dart'; |
| 10 import 'package:test/test.dart'; | 10 import 'package:test/test.dart'; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 }); | 269 }); |
| 270 | 270 |
| 271 pool.request(); | 271 pool.request(); |
| 272 }); | 272 }); |
| 273 }); | 273 }); |
| 274 | 274 |
| 275 group("close()", () { | 275 group("close()", () { |
| 276 test("disallows request() and withResource()", () { | 276 test("disallows request() and withResource()", () { |
| 277 var pool = new Pool(1)..close(); | 277 var pool = new Pool(1)..close(); |
| 278 expect(pool.request, throwsStateError); | 278 expect(pool.request, throwsStateError); |
| 279 expect(() => pool.withResource(() {}), throwsStateError); | 279 expect(pool.withResource(() {}), throwsStateError); |
| 280 }); | 280 }); |
| 281 | 281 |
| 282 test("pending requests are fulfilled", () async { | 282 test("pending requests are fulfilled", () async { |
| 283 var pool = new Pool(1); | 283 var pool = new Pool(1); |
| 284 var resource1 = await pool.request(); | 284 var resource1 = await pool.request(); |
| 285 expect(pool.request().then((resource2) { | 285 expect(pool.request().then((resource2) { |
| 286 resource2.release(); | 286 resource2.release(); |
| 287 }), completes); | 287 }), completes); |
| 288 expect(pool.close(), completes); | 288 expect(pool.close(), completes); |
| 289 resource1.release(); | 289 resource1.release(); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 /// | 419 /// |
| 420 /// This should only be called within a [FakeAsync.run] zone. | 420 /// This should only be called within a [FakeAsync.run] zone. |
| 421 Matcher get doesNotComplete => predicate((future) { | 421 Matcher get doesNotComplete => predicate((future) { |
| 422 expect(future, new isInstanceOf<Future>()); | 422 expect(future, new isInstanceOf<Future>()); |
| 423 | 423 |
| 424 var stack = new Trace.current(1); | 424 var stack = new Trace.current(1); |
| 425 future.then((_) => registerException( | 425 future.then((_) => registerException( |
| 426 new TestFailure("Expected future not to complete."), stack)); | 426 new TestFailure("Expected future not to complete."), stack)); |
| 427 return true; | 427 return true; |
| 428 }); | 428 }); |
| OLD | NEW |