Ticket #14 (closed defect)
eq/equal on multiple args
|Reported by:||dherman||Owned by:||dherman|
Danny Yoo wrote:
I've repaired memoize.ss so that if there are multiple arguments, and should be eq?, then the elements in the arg list are eq-compared. As a quick brush over it, I defined my own assoc/inner-eq and parameterized the four memoizing macros over their respective 'assocs'.
Here's a hastily-written test case:
(define eq-vs-equal-tests (make-test-suite "eq-vs-equal for multiple args" (make-test-case "simple test" (let ([f (memo-lambda (x y) (increment!) (+ (string-length x) (string-length y)))] [hello "hello"] [world "world"]) (parameterize ([number-of-runs 0]) (f (string-append "h" "ello") (string-append "w" "orld")) (f (string-append "he" "llo") (string-append "wo" "rld")) (with-assertion-info (['ran-twice "did not run exactly twice"]) (unless (= (number-of-runs) 2) (fail-assertion)))) (parameterize ([number-of-runs 0]) (f hello world) (f hello world) (with-assertion-info (['ran-once "did not run exactly once"]) (unless (= (number-of-runs) 1) (fail-assertion))))))))
My apologies for the test case messiness: I wanted to sleep. *grin*
Best of wishes!