Add more tests and argument check to Process.sleep
R=ager@google.com Review URL: https://codereview.chromium.org//13497008 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21054 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
@@ -46,7 +46,11 @@ set exitCode(int status) {
|
||||
* in a isolate while it is blocked in a [sleep] call.
|
||||
*/
|
||||
void sleep(Duration duration) {
|
||||
_ProcessUtils._sleep(duration.inMilliseconds);
|
||||
int milliseconds = duration.inMilliseconds;
|
||||
if (milliseconds < 0) {
|
||||
throw new ArgumentError("sleep: duration cannot be negative");
|
||||
}
|
||||
_ProcessUtils._sleep(milliseconds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,7 +13,10 @@ test(int milliseconds) {
|
||||
}
|
||||
|
||||
main() {
|
||||
test(0);
|
||||
test(1);
|
||||
test(10);
|
||||
test(100);
|
||||
Expect.throws(() => sleep(new Duration(milliseconds: -1)),
|
||||
(e) => e is ArgumentError);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user