| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #library('timer_cancel2_test'); | 5 #library('timer_cancel2_test'); |
| 6 | 6 |
| 7 #import("dart:isolate"); | 7 #import("dart:isolate"); |
| 8 #import('../../pkg/unittest/unittest.dart'); |
| 8 | 9 |
| 9 // Test that a timeout handler can cancel itself. | 10 main() { |
| 10 class TimerCancel2Test { | 11 // Test that a timeout handler can cancel itself. |
| 11 static void testSelfCancel() { | 12 test("timer cancel test 2", () { |
| 12 var cancelTimer; | 13 var cancelTimer; |
| 13 | 14 |
| 14 void cancelHandler(Timer timer) { | 15 void cancelHandler(Timer timer) { |
| 15 cancelTimer.cancel(); | 16 cancelTimer.cancel(); |
| 16 } | 17 } |
| 17 | 18 |
| 18 cancelTimer = new Timer.repeating(1, cancelHandler); | 19 cancelTimer = new Timer.repeating(1, expectAsync1(cancelHandler)); |
| 19 } | 20 }); |
| 20 | |
| 21 static void testMain() { | |
| 22 testSelfCancel(); | |
| 23 } | |
| 24 } | 21 } |
| 25 | |
| 26 main() { | |
| 27 TimerCancel2Test.testMain(); | |
| 28 } | |
| OLD | NEW |