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