improved testing for record?

This commit is contained in:
Matthias Felleisen 2010-10-27 10:35:11 -04:00
parent 42bceaf900
commit f600531e50
2 changed files with 24 additions and 26 deletions

View File

@ -11,30 +11,23 @@
stop)
(define stop (text "STOP" 44 'red))
;; -> Nat
;; make the clock tick n times, expected expected-n files in dir
(define (create-n-images)
(define dir "images0")
(unless (directory-exists? dir)
(make-directory dir))
(parameterize ([current-directory dir])
(for-each delete-file (directory-list)))
(with-output-to-file (format "./~a/index.html" dir)
(lambda ()
(displayln "<html><body><img src=\"i-animated.gif\" /></body></html>"))
#:exists 'replace)
(define final-world
(big-bang 0
(on-tick add1)
(stop-when (curry = 5) draw-stop)
(on-draw draw-number)
(record? dir)))
(sleep 1)
(parameterize ([current-directory dir])
(define dlst (directory-list))
(displayln dlst)
(length
(filter (lambda (f) (regexp-match "\\.png" (path->string f)))
dlst))))
(create-n-images)
(define dir "images0")
(unless (directory-exists? dir)
(make-directory dir))
(parameterize ([current-directory dir])
(for-each delete-file (directory-list)))
(with-output-to-file (format "./~a/index.html" dir)
(lambda ()
(displayln "<html><body><img src=\"i-animated.gif\" /></body></html>"))
#:exists 'replace)
(define final-world
(big-bang 0
(on-tick add1)
(stop-when (curry = 5) draw-stop)
(on-draw draw-number)
(record? dir)))
(sleep 1)
(unless (image=? (bitmap "images0/i1.png") (draw-number 0))
(printf "this test needs to be revised -- image=? doesn't work\n"))

View File

@ -30,3 +30,8 @@ gracket ufo-rename.rkt
echo "--- ufo-rename.rkt ---" echo ""
gracket world0-stops.rkt
echo "--- record.rkt ---" echo ""
gracket record.rkt
echo "--- record-stop-when.rkt ---" echo ""
gracket record-stop-when.rkt