[plt-dev] Re: [plt-scheme] Time Base
Attached is a patch that fixes this test case, and passes all the
others. Does anyone see anything wrong? If not, I'll commit it.
sam th
On Wed, Dec 16, 2009 at 1:30 AM, John Clements
<clements at brinckerhoff.org> wrote:
>
> On Dec 15, 2009, at 6:01 PM, Doug Williams wrote:
>
>> The easiest thing to see immediately is that (date-nanosecond (current-date)) always returns a value smaller than 10,000,000, which is 100 times to small. Try the following which returns the minimum and maximum such values - it takes a while because of the random sleeps.
>>
>> (for/fold ((minimum +inf.0)
>> (maximum -inf.0))
>> ((i (in-range 1000)))
>> (let ((nanosecond (date-nanosecond (current-date))))
>> (sleep (/ (random) 10.0))
>> (values (min nanosecond minimum) (max nanosecond maximum))))
>>
>> You'll get something like:
>>
>> 0.0
>> 9840000.0
>
> Many thanks. I massaged this into this test case
>
> (check-within (let ([t (date-nanosecond (current-date))])
> (sleep 0.5)
> (abs (- (date-nanosecond (current-date)) t)))
> (* 1/2 (expt 10 9))
> (* 1/10 (expt 10 9)))
>
> ... which fails, as expected.
>
> John Clements
>
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>
--
sam th
samth at ccs.neu.edu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: srfi-patch
Type: application/octet-stream
Size: 1966 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20100226/4bbcd9bf/attachment.obj>