| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #import("dart:io"); |
| 6 |
| 5 // Test that a timeout handler can cancel another. | 7 // Test that a timeout handler can cancel another. |
| 6 class TimerCancel1Test { | 8 class TimerCancel1Test { |
| 7 static void testOtherCancel() { | 9 static void testOtherCancel() { |
| 8 var canceleeTimer; | 10 var canceleeTimer; |
| 9 var cancelerTimer; | 11 var cancelerTimer; |
| 10 | 12 |
| 11 void timeoutHandlerUnreachable(Timer timer) { | 13 void timeoutHandlerUnreachable(Timer timer) { |
| 12 Expect.fail("A canceled timeout handler should be unreachable."); | 14 Expect.fail("A canceled timeout handler should be unreachable."); |
| 13 } | 15 } |
| 14 | 16 |
| 15 void cancelHandler(Timer timer) { | 17 void cancelHandler(Timer timer) { |
| 16 canceleeTimer.cancel(); | 18 canceleeTimer.cancel(); |
| 17 } | 19 } |
| 18 | 20 |
| 19 cancelerTimer = new Timer(cancelHandler, 1); | 21 cancelerTimer = new Timer(cancelHandler, 1); |
| 20 canceleeTimer = new Timer(timeoutHandlerUnreachable, 1000); | 22 canceleeTimer = new Timer(timeoutHandlerUnreachable, 1000); |
| 21 } | 23 } |
| 22 | 24 |
| 23 static void testMain() { | 25 static void testMain() { |
| 24 testOtherCancel(); | 26 testOtherCancel(); |
| 25 } | 27 } |
| 26 } | 28 } |
| 27 | 29 |
| 28 main() { | 30 main() { |
| 29 TimerCancel1Test.testMain(); | 31 TimerCancel1Test.testMain(); |
| 30 } | 32 } |
| OLD | NEW |