On Mon, Jul 01, 2002 at 12:51:52PM +0100, Simon Marlow wrote:
> 
> > > I'm shocked that non of the three Haskell implementations had a test
> > > suite that caught this problem.
> > 
> > Take a look at
> > fptools/testsuite/tests/ghc-regress/numeric/should_run/arith0011.hs.
> > There may be one or two wrong answers lurking in there, but 
> > that's a lot
> > of results to check by hand!

However, it's easy to write a program to verify such results, assuming
you trust your addition and multiplication and comparisons:

> verifyDivMod :: Integer -> Integer -> Bool
> verifyDivMod x y = case x `divMod` y of
>    (d,m) -> d*y+m==x && (m == 0 || signum m == signum y)

> verifyQuotRem :: Integer -> Integer -> Bool
> verifyQuotRem x y = case x `divMod` y of
>    (d,m) -> d*y+m==x && (m == 0 || signum m == signum x)

But maybe that doesn't fit in too well with your framework.

Also, looking at arith003, there are a few more test cases I might
include, with quotient/remainder, say, 3/4 or 1/2 of maxInt.  You also
don't seem to test arithmetic with large negative operands in the
cases I saw.
 
Best,
        Dylan

Attachment: msg04910/pgp00000.pgp
Description: PGP signature

Reply via email to