[plt-scheme] testing local functions

From: Scott Hickey (jshickey at yahoo.com)
Date: Tue Sep 22 15:55:51 EDT 2009

I am working through the web server tutorial. I was wondering if there is a way to write tests for functions like parse-post in the code below. It seems like there are two issues to resolve: 1) the scope of parse-post 2) constructing a test binding.

(define (render-blog-page request)
  (local [(define (response-generator make-url)
            `(html (head (title "My Blog"))
                    (h1 "My Blog")
                    ,(render-posts make-url)
                    (form ((action
                            ,(make-url insert-post-handler)))
                          (input ((name "title")))
                          (input ((name "body")))
                          (input ((type "submit")))))))
          (define (parse-post bindings)
            (make-post (extract-binding/single 'title' bindings)
                       (extract-binding/single 'body' bindings)))
          (define (insert-post-handler request)
             BLOG (parse-post (request-bindings request)))
            (render-blog-page request))]
    (send/suspend/dispatch response-generator)))
 Scott Hickey
Senior Consultant
Object Partners, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090922/f1f7b3cd/attachment.html>

Posted on the users mailing list.