Hi, everyone!
I am writing a simple statistical package for Racket, and I would like to have
tests within my Scribble documentation (as well as Rackunit tests in the
implementation modules).
For the Scribble tests, I am using `eval:check`. But I have noticed that the
tests do not pass unless the written result is exactly the same floating-point
number coming out of the Racket procedure. In other words, you cannot set a
tolerance for the result, as you can do with Rackunit's `check-=`.
As an example, suppose I have a procedure `t-test`. The checked example in
Scribble would have to be like this:
```
@examples[
#:eval helper-eval
@eval:check[
(t-test bacteria-a bacteria-b)
13.010764773832472
]
]
```
while the Rackunit test can be much less precise
```
(check-= (t-test bacteria-a bacteria-b) 13.0 0.1)
```
I am worried that this is not portable: if my package is installed in another
machine, and the floating-point results are different there, would the examples
fail to pass, even though nothing is incorrect?
Also, the number in `eval:check` has to have the same number of significant
digits: it cannot have the "right sequence" but be truncated at an earlier
point than the result coming out of Racket. This forces me to do something I do
not like: to use the procedure under test in order to see the result, and then
copy&paste that into the test's result. I would prefer to use a different
mechanism (e.g. Julia or Python or hand calculations) to produce results
beforehand, but in most cases I cannot because they provide less significant
digits than Racket. (Which is otherwise a cool thing for Racket :) ).
In short: is there a way to specify tolerance in `eval:check`?
Thanks for any help!
Luis
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.