Re: Some comments on the ansi test suite
Raymond Toy <[email protected]>
| Newsgroups | gmane.lisp.clocc.devel |
|---|---|
| Message-ID | <[email protected]> |
>>>>> "Peter" == Peter Van Eynde <[email protected]> writes: Peter> Replace them with a better test would be nice. As most of them are fp Peter> problems we should (IMHO) replace them with "zero knowledge" tests or Peter> remove them. How about the following tests: ;; sin(8*pi/2) = sin(4*pi) = 0. Assume that our pi is a bit off. Say ;; pi*(1+eps). Then sin(8*pi*(1+eps)/2) = sin(4*pi + 4*pi*eps) = ;; sin(4*pi*eps) ~= 4*pi*eps. Test for this, but allow a fudge factor ;; of 2. (check-for-bug :alltest-legacy-1045 (let ((y (sin (* 8 (/ pi 2)))) (fudge 2)) (< (abs y) (* fudge (* 4 pi long-float-epsilon)))) t) ;; As in 1045, cos(pi*(1+eps)/2) = cos(pi/2+pi*eps/2) = -sin(pi*eps/2) ;; ~= -pi*eps/2. Check that we are close enough. (check-for-bug :alltest-legacy-1061 (let ((y (cos (/ pi 2))) (fudge 2)) (< (abs y) (* fudge (* pi long-float-epsilon 1/2)))) t) ;; As in 1045, tan(x) = sin(x)/cos(x). When x = pi/2+pi*eps/2, sin(x) ;; is essentially 1, but cos(x) is about pi/2*eps. So tan(x) = ;; 1/cos(x). (check-for-bug :alltest-legacy-1073 (zerop (- (tan (/ pi 2)) (/ (cos (/ pi 2))))) t) Perhaps that last test should not test for zerop but some relative error between tan(pi/2) and 1/cos(pi/2)? Ray ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Two, two, TWO treats in one. http://thinkgeek.com/sf