/[clhp]/clhp/tests/clhp-test.lisp
ViewVC logotype

Contents of /clhp/tests/clhp-test.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Tue Oct 21 03:09:20 2003 UTC (10 years, 6 months ago) by aventimiglia
Branch: MAIN
CVS Tags: rel-0-2-1alpha, rel-0-2-0alpha, HEAD
Changes since 1.1: +1 -1 lines
Fixed cvs keywords
1 #+cmu (ext:file-comment "$Id: clhp-test.lisp,v 1.2 2003/10/21 03:09:20 aventimiglia Exp $")
2 ;;
3 ;; CLHP the Common Lisp Hypertext Preprocessor
4 ;; (C) 2003 Anthony J Ventimiglia
5 ;;
6 ;; This library is free software; you can redistribute it and/or
7 ;; modify it under the terms of the GNU Lesser General Public
8 ;; License as published by the Free Software Foundation; either
9 ;; version 2.1 of the License, or (at your option) any later version.
10 ;;
11 ;; This library is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ;; Lesser General Public License for more details.
15 ;;
16 ;; You should have received a copy of the GNU Lesser General Public
17 ;; License along with this library; if not, write to the Free Software
18 ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ;;
20 ;; email: aventimiglia@common-lisp.net
21 ;; HomePage: http://common-lisp.net/project/clhp/
22
23 ;; Test suite to for the :CLHP package. The aim of this is to test all
24 ;; external, and possibly internal symbols in the package
25 (eval-when (:load-toplevel :compile-toplevel)
26 (unless (find-package :cgi)
27 (load "../cgi"))
28 (unless (find-package :clhp)
29 (load "../clhp"))
30 (unless (find-package :net.common-lisp.aventimiglia.test-suite)
31 (load "test-suite")))
32
33 (use-package :test-suite)
34
35 ;; This is used to import internal symbols for some of the macro
36 ;; tests. First we unintern, just to make sure there are no name
37 ;; clashes. You should pass the full name of the symbol to intern,
38 ;; such as clhp::*pi-start*
39 (defmacro import-func (s)
40 `#'(lambda () (unintern ',s) (import ',s)))
41
42 ;; Used to reverse the above
43 (defmacro unintern-func (s)
44 `#'(lambda () (unintern ',s)))
45
46 (defparameter *PI-TEST-STRING*
47 "<tag>starts <?clhp here and ends ?> there <tag>")
48 (defparameter *test-file*
49 "<start>Hello There <?clhp (echo \"All of You\") ?></start>")
50 (defparameter *test-file-name* "parse-test.clhp")
51
52 (defparameter *test-file-include-output*
53 "<start>Hello There All of You</start>")
54
55 (defparameter *test-file-parse-output*
56 (concatenate 'string "X-Powered-By: CLHP/0.1.1alpha Common Lisp Hypertext Preprocessor
57 Content-type: TEXT/HTML
58
59 " *test-file-include-output*))
60
61 (defun make-test-file ()
62 (with-open-file
63 (f *test-file-name*
64 :direction :output
65 :if-exists :overwrite
66 :if-does-not-exist :create)
67 (format f *test-file*)))
68
69 (defun delete-test-file ()
70 (delete-file *test-file-name*))
71
72 ; #:echo #:include #:xml-element
73 ; #:make-xml-element #:copy-xml-element #:xml-element-attributes
74 ; #:xml-element-name #:xml-element-contents #:xml-element-p #:tag
75 (defparameter *clhp-tests*
76 (list
77 ;; I know it's redundant to keep importing the same symbol, but
78 ;; all these tests ahould stand on their own
79 (make-instance 'function-test-data
80 :symbol 'clhp::find-pi-start
81 :pre-function (import-func clhp::*pi-start*)
82 :post-function (unintern-func clhp::*pi-start*)
83 :test-args `(,*pi-test-string*)
84 :result-form 12)
85 (make-instance 'function-test-data
86 :symbol 'clhp::find-pi-start
87 :pre-function (import-func clhp::*pi-start*)
88 :post-function (unintern-func clhp::*pi-start*)
89 :test-args `(,*pi-test-string* :start 14)
90 :result-form nil)
91 (make-instance 'function-test-data
92 :symbol 'clhp::find-pi-start
93 :pre-function (import-func clhp::*pi-start*)
94 :post-function (unintern-func clhp::*pi-start*)
95 :test-args `(,*pi-test-string* :end 8)
96 :result-form nil)
97 (make-instance 'function-test-data
98 :symbol 'clhp::find-pi-end
99 :pre-function (import-func clhp::*pi-end*)
100 :post-function (unintern-func clhp::*pi-end*)
101 :test-args `(,*pi-test-string*)
102 :result-form 33)
103 (make-instance 'function-test-data
104 :symbol 'clhp::find-pi-end
105 :pre-function (import-func clhp::*pi-end*)
106 :post-function (unintern-func clhp::*pi-end*)
107 :test-args `(,*pi-test-string* :start 34)
108 :result-form nil)
109 (make-instance 'function-test-data
110 :symbol 'clhp::find-pi-end
111 :pre-function (import-func clhp::*pi-end*)
112 :post-function (unintern-func clhp::*pi-end*)
113 :test-args `(,*pi-test-string* :end 31)
114 :result-form nil)
115 (make-instance 'output-function-test-data
116 :symbol 'clhp:parse
117 :pre-function #'make-test-file
118 :post-function #'delete-test-file
119 :test-args `(,*test-file-name*)
120 :output *test-file-parse-output*
121 :result-form *test-file*)
122 (make-instance 'output-function-test-data
123 :symbol 'clhp:include
124 :pre-function #'make-test-file
125 :post-function #'delete-test-file
126 :test-args `(,*test-file-name*)
127 :output *test-file-include-output*
128 :result-form *test-file*)
129 ;; PARSE-BUFFER is the core, it should be tested quite thuroughly
130 (make-instance 'output-function-test-data
131 :symbol 'clhp::parse-buffer
132 :test-args '("Hello <?clhp (clhp:echo 'there) ?>" :end 34)
133 :output "Hello THERE")
134 ;; This actually should be tested for all the errors it could produce
135 (make-instance 'output-function-test-data
136 :symbol 'clhp::evaluate-code-block
137 :test-args '("(princ (list 1 2 3 4 5 6))")
138 :result-form nil
139 :output "(1 2 3 4 5 6)")
140 (make-instance 'output-function-test-data
141 :symbol 'clhp:echo
142 :test-args '("One" 'two "Three")
143 :result-form nil
144 :output "OneTWOThree")
145 (make-instance 'output-function-test-data
146 :symbol 'clhp:echo
147 :test-args '('#:|Four| (+ 3 2) (* 2 3))
148 :output "Four56"
149 :result-form nil)
150 ))
151
152
153 (eval-when (load)
154 (unix:unix-exit
155 (cadr (multiple-value-list (run-tests *clhp-tests*)))
156 )
157 )
158
159

  ViewVC Help
Powered by ViewVC 1.1.5