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

Side by Side Diff: tests/lib/async/timer_regress22626_test.dart

Issue 971193002: - Make sure we schedule another wakeup when handling a timeout (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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
« runtime/lib/timer_impl.dart ('K') | « runtime/lib/timer_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
koda 2015/03/03 18:58:51 2011 -> 2015
Ivan Posva 2015/03/03 19:14:18 Done.
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 // Test that no wakeups are being dropped if we cancel timers.
6 // WARNING: For this test to work it cannot rely on any other async features
7 // and will just timeout if it is failing.
8
9 library timer_regress22626_test;
10
11 import 'dart:async';
12 import 'dart:math';
13 import 'package:expect/expect.dart';
14
15 int countdown = 10;
16 var rng = new Random(1234);
17
18 void test(int delay, int delta) {
19 var t0 = new Timer(new Duration(milliseconds: delay + delta),
20 () => Expect.fail("should have been cancelled by now"));
21 new Timer(Duration.ZERO, () => t0.cancel());
22 new Timer(Duration.ZERO,
23 () => new Timer(new Duration(milliseconds: delay),
24 () {
25 if (--countdown == 0) {
26 print("done");
27 } else {
28 test(delay, max(0, delta + rng.nextInt(2) - 1));
29 }
30 }));
31 }
32
33 void main() {
34 test(50, 2);
35 }
OLDNEW
« runtime/lib/timer_impl.dart ('K') | « runtime/lib/timer_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698