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:
sgjesse@google.com
2013-04-08 10:04:45 +00:00
parent f168de9c51
commit eb76cd907a
2 changed files with 8 additions and 1 deletions
+5 -1
View File
@@ -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);
}
/**
+3
View File
@@ -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);
}