[gambit-list] Proposed patch

Marc Feeley feeley at iro.umontreal.ca
Sun Dec 15 11:56:57 EST 2013


On Dec 14, 2013, at 7:29 PM, Bradley Lucier <lucier at math.purdue.edu> wrote:

> On 12/10/2013 10:27 PM, Marc Feeley wrote:
>> Moreover, it is important to check that the primitive functions raise exceptions correctly.  To give you an idea I have added unit tests for fx+ and fl+.  Here's the unit test for fx+:
>> 
>> 
>> (check-exn type-exception? (lambda () (fx+ 1/2)))
>> (check-exn type-exception? (lambda () (fx+ 1/2 9)))
>> (check-exn type-exception? (lambda () (fx+ 9 1/2)))
>> (check-exn type-exception? (lambda () (fx+ 1/2 3 9)))
>> (check-exn type-exception? (lambda () (fx+ 3 1/2 9)))
>> (check-exn type-exception? (lambda () (fx+ 3 9 1/2)))
>> 
>> (check-exn fixnum-overflow-exception? (lambda () (fx+ ##max-fixnum 1)))
>> (check-exn fixnum-overflow-exception? (lambda () (fx+ ##min-fixnum -1)))
>> 
> 
> How would one deal with this situation:
> 
> firefly:~/programs/gambit/marc/gambit> gsi
> Gambit v4.7.1
> 
> > (atan +i)
> *** ERROR IN (console)@1.1 -- (Argument 1) Out of range
> (atan +i)
> 1> 
> > (atan -i)
> *** ERROR IN ##atan -- (Argument 1) Out of range
> (log 0)
> 1> 
> 
> where an "Out of range" exception is raised, but for the wrong function.
> 
> Brad

I have added a check-tail-exn to verify that the exception is raised in tail position.  This should be the case of all primitives, so check-tail-exn should be used almost exclusively in all the unit tests.  For example:

(check-tail-exn range-exception? (lambda () (atan -i)))

Marc




More information about the Gambit-list mailing list