307742d07e
Since unittest is known to work with test.dart as a test runner and is strong mode clean, it's a safer bet than test. Change-Id: Id120d4f871827b1f131dff2a5ef2f7efb15a8382 Reviewed-on: https://dart-review.googlesource.com/12125 Reviewed-by: Terry Lucas <terry@google.com>
31 lines
822 B
Dart
31 lines
822 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_cancel1_test;
|
|
|
|
import 'dart:async';
|
|
|
|
import 'package:unittest/unittest.dart';
|
|
|
|
main() {
|
|
// Test that a timeout handler can cancel another.
|
|
test("timer cancel1 test", () {
|
|
var canceleeTimer;
|
|
var cancelerTimer;
|
|
|
|
void unreachable() {
|
|
fail("A canceled timeout handler should be unreachable.");
|
|
}
|
|
|
|
void handler() {
|
|
canceleeTimer.cancel();
|
|
}
|
|
|
|
cancelerTimer =
|
|
new Timer(const Duration(milliseconds: 1), expectAsync(handler));
|
|
canceleeTimer = new Timer(
|
|
const Duration(milliseconds: 1000), expectAsync(unreachable, count: 0));
|
|
});
|
|
}
|