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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/timer_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/async/timer_regress22626_test.dart
===================================================================
--- tests/lib/async/timer_regress22626_test.dart (revision 0)
+++ tests/lib/async/timer_regress22626_test.dart (working copy)
@@ -0,0 +1,35 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Test that no wakeups are being dropped if we cancel timers.
+// WARNING: For this test to work it cannot rely on any other async features
+// and will just timeout if it is failing.
+
+library timer_regress22626_test;
+
+import 'dart:async';
+import 'dart:math';
+import 'package:expect/expect.dart';
+
+int countdown = 10;
+var rng = new Random(1234);
+
+void test(int delay, int delta) {
+ var t0 = new Timer(new Duration(milliseconds: delay + delta),
+ () => Expect.fail("should have been cancelled by now"));
+ new Timer(Duration.ZERO, () => t0.cancel());
+ new Timer(Duration.ZERO,
+ () => new Timer(new Duration(milliseconds: delay),
+ () {
+ if (--countdown == 0) {
+ print("done");
+ } else {
+ test(delay, max(0, delta + rng.nextInt(2) - 1));
+ }
+ }));
+}
+
+void main() {
+ test(50, 2);
+}
« no previous file with comments | « runtime/lib/timer_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698