X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Fsleep.t;h=3f5bbe0d3fe2f3b3c3ae615e47953ac92b56ddd4;hb=21fa6956243df9cb622bebfa0934ea7923519b4f;hp=c26d397d2f3255fe3efd15b073dadfcdc0428322;hpb=fe14fcc35f78a371a174a1d14256c2f35ae4262b;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/sleep.t b/t/op/sleep.t old mode 100644 new mode 100755 index c26d397..3f5bbe0 --- a/t/op/sleep.t +++ b/t/op/sleep.t @@ -1,8 +1,22 @@ #!./perl -# $Header: sleep.t,v 4.0 91/03/20 01:54:34 lwall Locked $ +BEGIN { + chdir 't' if -d 't'; + @INC = qw(. ../lib); +} -print "1..1\n"; +require "test.pl"; +plan( tests => 4 ); -$x = sleep 2; -if ($x >= 2 && $x <= 10) {print "ok 1\n";} else {print "not ok 1 $x\n";} +use strict; +use warnings; + +my $start = time; +my $sleep_says = sleep 3; +my $diff = time - $start; + +cmp_ok( $sleep_says, '>=', 2, 'Sleep says it slept at least 2 seconds' ); +cmp_ok( $sleep_says, '<=', 10, '... and no more than 10' ); + +cmp_ok( $diff, '>=', 2, 'Actual time diff is at least 2 seconds' ); +cmp_ok( $diff, '<=', 10, '... and no more than 10' );