5013b28bbe
Also updates tests that relied on fuzzy arrows. Change-Id: Ia8df1d8d421e43dfada589223d5e46182b92fa67 Reviewed-on: https://dart-review.googlesource.com/37425 Commit-Queue: Jenny Messerly <jmesserly@google.com> Reviewed-by: Leaf Petersen <leafp@google.com>
25 lines
680 B
Dart
25 lines
680 B
Dart
// Copyright (c) 2012, 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.
|
|
|
|
library timer_cancel2_test;
|
|
|
|
import 'dart:async';
|
|
import 'package:expect/expect.dart';
|
|
|
|
main() {
|
|
// Test that a timeout handler can cancel itself.
|
|
var cancelTimer;
|
|
var completer = new Completer();
|
|
int calls = 0;
|
|
void cancelHandler(Timer timer) {
|
|
Expect.equals(1, ++calls);
|
|
cancelTimer.cancel();
|
|
completer.complete();
|
|
}
|
|
|
|
cancelTimer =
|
|
new Timer.periodic(const Duration(milliseconds: 1), cancelHandler);
|
|
return completer.future;
|
|
}
|