preprocess-test.ss
;;;
;;; Time-stamp: <06/02/06 20:34:23 noel>
;;;
;;; Copyright (C) 2005 by Noel Welsh.
;;;

;;; This library is free software; you can redistribute it
;;; and/or modify it under the terms of the GNU Lesser
;;; General Public License as published by the Free Software
;;; Foundation; either version 2.1 of the License, or (at
;;; your option) any later version.

;;; This library is distributed in the hope that it will be
;;; useful, but WITHOUT ANY WARRANTY; without even the
;;; implied warranty of MERCHANTABILITY or FITNESS FOR A
;;; PARTICULAR PURPOSE.  See the GNU Lesser General Public
;;; License for more details.

;;; You should have received a copy of the GNU Lesser
;;; General Public License along with this library; if not,
;;; write to the Free Software Foundation, Inc., 59 Temple
;;; Place, Suite 330, Boston, MA 02111-1307 USA

;;; Author: Noel Welsh <noelwelsh@yahoo.com>
;;
;;
;; Commentary:

(module preprocess-test mzscheme
  
  (require (planet "test.ss" ("schematics" "schemeunit.plt" 2)))
  (require "preprocess.ss")
  
  (provide preprocess-tests)
  
  (define preprocess-tests
    (test-suite
     "All tests for preprocess"
     (test-case
      "Applying a template returns the expected result"
      (let ((tmpl (open-input-string "<< (+ 1 2) >>")))
        (check string=?
                (apply-template tmpl '())
                "3\n")))

     (test-case
      "Template bindings don't affect the current environment"
      (let ((dummy #f)
            (tmpl (open-input-string "<< (set! dummy 2) dummy >>")))
        (check string=?
                (apply-template tmpl '((dummy . 3)))
                "2\n")
        (check-equal? dummy #f)))

     (test-case
      "Template bindings are passed to the template"
      (let ((tmpl (open-input-string "<< dummy >>")))
        (check string=?
                (apply-template tmpl '((dummy . 3)))
                "3\n")))
     ))
  )