OLD | NEW |
1 // Copyright (c) 2014, the Fletch project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 import 'dart:fletch.os' as os; | 5 import 'dart:fletch.os' as os; |
6 | 6 |
7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 | 8 |
9 void main() { | 9 void main() { |
10 // Sleep 200 ms. | 10 // Sleep 200 ms. |
11 int ms = 200; | 11 int ms = 200; |
12 Stopwatch stopwatch = new Stopwatch()..start(); | 12 Stopwatch stopwatch = new Stopwatch()..start(); |
13 os.sleep(ms); | 13 os.sleep(ms); |
14 // There is a chance that it'll resume slightly early on some system, so we | 14 // There is a chance that it'll resume slightly early on some system, so we |
15 // just ensure that at least 50% of the time is spent sleeping. | 15 // just ensure that at least 50% of the time is spent sleeping. |
16 int elapsed = stopwatch.elapsedMilliseconds; | 16 int elapsed = stopwatch.elapsedMilliseconds; |
17 Expect.isTrue(elapsed >= ms ~/ 2, "$elapsed >= ${ms ~/ 2}"); | 17 Expect.isTrue(elapsed >= ms ~/ 2, "$elapsed >= ${ms ~/ 2}"); |
18 } | 18 } |
OLD | NEW |