On Mon, Jul 28, 2014 at 9:30 PM, John Cowan <co...@mercury.ccil.org> wrote:

> Alex Shinn scripsit:
>
> > The solution is definitely not to write your own comparison function,
> > and trust that the test egg is doing the right thing.
>
> It isn't, though, not quite.  What it needs to do is not a dichotomy of
> "if inexact, use epsilon, otherwise use `equal?`" but rather to have
> a version of `equal?` that uses epsilon when it comes to a float.
> That way comparisons against list or vector structure that contains
> floats (as in the OP's case) will work correctly.
>

I meant the right thing wrt comparing two inexacts, as
opposed to trying to come up with your own inexact=? logic.

It's easy to make it handle nested pairs and vectors correctly,
would require lolevel hackery to handle records, and in general
can't support ffi struct types.  So at some point you need to
provide your own structure comparison, and I chose to make
the rule simple:

  If you explicitly expect a single inexact value, assume
  the result should also be inexact and approximately equal.
  Otherwise use equal?.

If people think it's useful I'd consider walking pairs and vectors.

Regardless, I'll add a utility to make defining tests with your
own comparator easier, and explicitly export test-approx-equal?
so you don't have to capture the initial test comparator.

-- 
Alex
_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to