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 unittest.breath_test; |
| 6 |
5 import 'dart:async'; | 7 import 'dart:async'; |
6 | 8 |
7 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
8 | 10 |
9 main() { | 11 void main() { |
10 // Test the sync test 'breath' feature of unittest. | 12 // Test the sync test 'breath' feature of unittest. |
11 | 13 |
12 group('breath', () { | 14 group('breath', () { |
13 var sentinel = 0; | 15 var sentinel = 0; |
14 var start; | 16 var start; |
15 | 17 |
16 test('initial', () { | 18 test('initial', () { |
17 Timer.run(() { sentinel = 1; }); | 19 Timer.run(() { sentinel = 1; }); |
18 }); | 20 }); |
19 | 21 |
20 test('starve', () { | 22 test('starve', () { |
21 start = new DateTime.now().millisecondsSinceEpoch; | 23 start = new DateTime.now().millisecondsSinceEpoch; |
22 var now; | 24 var now; |
23 do { | 25 do { |
24 expect(sentinel, 0); | 26 expect(sentinel, 0); |
25 now = new DateTime.now().millisecondsSinceEpoch; | 27 now = new DateTime.now().millisecondsSinceEpoch; |
26 } while (now - start <= BREATH_INTERVAL); | 28 } while (now - start <= BREATH_INTERVAL); |
27 }); | 29 }); |
28 | 30 |
29 test('breathed', () { | 31 test('breathed', () { |
30 expect(sentinel, 1); | 32 expect(sentinel, 1); |
31 }); | 33 }); |
32 }); | 34 }); |
33 } | 35 } |
34 | |
OLD | NEW |