exercise-2.scm (662B)
1 (define-library (sicp tests chapter-3 exercise-2) 2 (import (scheme base) 3 (only (scheme inexact) sqrt) 4 (srfi :64) 5 (sicp solutions chapter-3 exercise-2)) 6 7 (begin 8 (define s (make-monitored sqrt)) 9 10 (test-begin "chapter-3-exercise-2") 11 (test-equal 12 0 13 (s 'how-many-calls?)) 14 (test-equal 15 10 16 (s 100)) 17 (test-equal 18 1 19 (s 'how-many-calls?)) 20 (s 100) 21 (s 100) 22 (test-equal 23 3 24 (s 'how-many-calls?)) 25 (s 'reset-count) 26 (s 100) 27 (s 100) 28 (s 100) 29 (s 100) 30 (test-equal 31 4 32 (s 'how-many-calls?)) 33 (test-end "chapter-3-exercise-2")))