Index: test.lisp =================================================================== --- test.lisp (revision 0) +++ test.lisp (revision 0) @@ -0,0 +1,90 @@ +(in-package #:cl-user) + +(defpackage #:cl-who-test + (:use #:cl #:cl-who)) + +(in-package #:cl-who-test) + +(defmacro with-html (&body body) + `(with-html-output-to-string + (*standard-output* nil :prologue nil :indent nil) + ,@body)) + +(defmacro test= (result &rest args) + `(assert (string= ,result + (with-html ,@args)))) + +(defmacro test/= (result &rest args) + `(assert (string/= ,result + (with-html ,@args)))) + +(format t "~&Start running test...~%") + +(eval-when (:compile-toplevel :load-toplevel :execute) + (setq *downcase-tags-p* t) + (setf (html-mode) :xml) + (setq *attribute-quote-char* #\') + (setq *html-empty-tag-aware-p* t)) + +(test= "&" (esc "&")) +(test= "<" (esc "<")) +(test= ">" (esc ">")) +(test= "'" (esc "'")) +(test= """ (esc "\"")) +(test= "✓" (esc (string (code-char #x2713)))) + +(eval-when (:compile-toplevel :load-toplevel :execute) + (setf (html-mode) :sgml)) + +(test= "✓" (esc (string (code-char #x2713)))) + +(test= "" + (:input :type "checkbox" :checked t)) + +(eval-when (:compile-toplevel :load-toplevel :execute) + (setf (html-mode) :xml)) + +(test= "" + (:input :type "checkbox" :checked t)) + +(test= "
" + (:div)) + +(test= "
" + (:br)) + +(test= "" + (:script :src "http://www.yahoo.com/yui.js")) + +(defun lookup-author () + (values "Zappa")) + +(test= "123456Zappa" + (:|Item| + (:|ASIN| "123456") + (:|Item-Attributes| + (:|Author| (str (lookup-author)))))) + +(eval-when (:compile-toplevel :load-toplevel :execute) + (setq *downcase-tags-p* nil)) + +(test= "123456Zappa" + (:|Item| + (:|ASIN| "123456") + (:|Item-Attributes| + (:|Author| (str (lookup-author)))))) + +;; we're generating xml that happens to have these html tags
and +;;