Index: pkg/unittest/test/breath_test.dart |
diff --git a/pkg/unittest/test/breath_test.dart b/pkg/unittest/test/breath_test.dart |
index 23eec84b1dde14692eae6ce6a6665dee7414d996..1d6325116898df7b896386ef486ee03909b2e307 100644 |
--- a/pkg/unittest/test/breath_test.dart |
+++ b/pkg/unittest/test/breath_test.dart |
@@ -16,18 +16,28 @@ void main() { |
var start; |
test('initial', () { |
+ start = new DateTime.now().millisecondsSinceEpoch; |
Timer.run(() { |
sentinel = 1; |
}); |
}); |
test('starve', () { |
- start = new DateTime.now().millisecondsSinceEpoch; |
- var now; |
- do { |
+ var now = new DateTime.now().millisecondsSinceEpoch; |
+ while (now - start <= BREATH_INTERVAL) { |
+ // If less than BREATH_INTERVAL time has passed since |
+ // we scheduled the 'initial' timer it implies the |
+ // current test is being run as a microtask which is |
+ // again run before any timer callbacks. Hence the |
+ // sentinel should not be 1. |
expect(sentinel, 0); |
now = new DateTime.now().millisecondsSinceEpoch; |
- } while (now - start <= BREATH_INTERVAL); |
+ }; |
+ // At this point we know at least BREATH_INTERVAL time has |
+ // passed since we scheduled the Timer with the sentinel |
+ // assignment. This means the next test should be scheduled |
+ // using a timer as well. This ensures it will run after the |
+ // timer scheduled in the 'initial' test. |
kustermann
2014/11/17 12:32:02
This is not completely correct.
If test 'initial'
|
}); |
test('breathed', () { |