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

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

Issue 2802973005: Migrate async tests to strong (Closed)
Patch Set: Created 3 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
OLDNEW
(Empty)
1 // Copyright (c) 2015, 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 // 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 = 5;
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(200, 2);
35 }
OLDNEW
« no previous file with comments | « tests/lib_strong/async/timer_not_available_test.dart ('k') | tests/lib_strong/async/timer_repeat_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698