Commit | Line | Data |
---|---|---|
500f6a47 AW |
1 | ;; -*- scheme -*- |
2 | ;; guile-lib | |
3 | ;; Copyright (C) 2007, 2009 Andy Wingo <wingo at pobox dot com> | |
4 | ||
5 | ;; This program is free software; you can redistribute it and/or | |
6 | ;; modify it under the terms of the GNU General Public License as | |
7 | ;; published by the Free Software Foundation; either version 2 of | |
8 | ;; the License, or (at your option) any later version. | |
9 | ;; | |
10 | ;; This program is distributed in the hope that it will be useful, | |
11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | ;; GNU General Public License for more details. | |
14 | ;; | |
15 | ;; You should have received a copy of the GNU General Public License | |
16 | ;; along with this program; if not, contact: | |
17 | ;; | |
18 | ;; Free Software Foundation Voice: +1-617-542-5942 | |
19 | ;; 59 Temple Place - Suite 330 Fax: +1-617-542-2652 | |
20 | ;; Boston, MA 02111-1307, USA gnu@gnu.org | |
21 | ||
22 | ;;; Commentary: | |
23 | ;; | |
24 | ;; Unit tests for (texinfo serialize). | |
25 | ;; | |
26 | ;;; Code: | |
27 | ||
28 | (define-module (test-suite texinfo-serialize) | |
29 | #:use-module (test-suite lib) | |
30 | #:use-module (texinfo serialize)) | |
31 | ||
32 | (with-test-prefix "test-serialize" | |
33 | (define (assert-serialize stexi str) | |
34 | (pass-if str (equal? str (stexi->texi stexi)))) | |
35 | ||
36 | (assert-serialize '(para) | |
37 | " | |
38 | ||
39 | ") | |
40 | ||
41 | (assert-serialize '(para "foo") | |
42 | "foo | |
43 | ||
44 | ") | |
45 | ||
46 | (assert-serialize '(var "foo") | |
47 | "@var{foo}") | |
48 | ||
49 | ||
50 | ;; i don't remember why braces exists, but as long as it does, a test | |
51 | ;; is in order | |
52 | (assert-serialize '(*braces* "foo") | |
53 | "@{foo@}") | |
54 | ||
55 | (assert-serialize '(value (% (key "foo"))) | |
56 | "@value{foo}") | |
57 | ||
58 | (assert-serialize '(ref (% (node "foo"))) | |
59 | "@ref{foo}") | |
60 | (assert-serialize '(ref (% (node "foo") (name "bar"))) | |
61 | "@ref{foo,bar}") | |
62 | (assert-serialize '(ref (% (node "foo") (name "bar") | |
63 | (section "qux") (info-file "xyzzy") | |
64 | (manual "zarg"))) | |
65 | "@ref{foo,bar,qux,xyzzy,zarg}") | |
66 | (assert-serialize '(ref (% (section "qux") (info-file "xyzzy") | |
67 | (node "foo") (name "bar") | |
68 | (manual "zarg"))) | |
69 | "@ref{foo,bar,qux,xyzzy,zarg}") | |
70 | (assert-serialize '(ref (% (node "foo") | |
71 | (manual "zarg"))) | |
72 | "@ref{foo,,,,zarg}") | |
73 | ||
74 | (assert-serialize '(dots) "@dots{}") | |
75 | ||
76 | (assert-serialize '(node (% (name "foo"))) | |
77 | "@node foo | |
78 | ") | |
79 | ||
80 | (assert-serialize '(node (% (name "foo bar"))) | |
81 | "@node foo bar | |
82 | ") | |
83 | (assert-serialize '(node (% (name "foo bar") (next "baz"))) | |
84 | "@node foo bar, baz | |
85 | ") | |
86 | ||
87 | (assert-serialize '(title "Foo") | |
88 | "@title Foo | |
89 | ") | |
90 | (assert-serialize '(title "Foo is a " (var "bar")) | |
91 | "@title Foo is a @var{bar} | |
92 | ") | |
93 | ||
94 | (assert-serialize '(title "Foo is a " (var "bar") " baz") | |
95 | "@title Foo is a @var{bar} baz | |
96 | ") | |
97 | ||
98 | (assert-serialize '(cindex (% (entry "Bar baz, foo"))) | |
99 | "@cindex Bar baz, foo | |
100 | ") | |
101 | ||
102 | ;; there is a space after @iftex, doesn't matter tho | |
103 | (assert-serialize '(iftex | |
104 | (para "This is only for tex.") | |
105 | (para "Note. Foo.")) | |
106 | "@iftex | |
107 | This is only for tex. | |
108 | ||
109 | Note. Foo. | |
110 | ||
111 | @end iftex | |
112 | ||
113 | ") | |
114 | ||
115 | (assert-serialize '(defun (% (name "frob")) | |
116 | (para "foo?")) | |
117 | "@defun frob | |
118 | foo? | |
119 | ||
120 | @end defun | |
121 | ||
122 | ") | |
123 | ||
124 | (assert-serialize '(defun (% (name "frob") (arguments "bar")) | |
125 | (para "foo?")) | |
126 | "@defun frob bar | |
127 | foo? | |
128 | ||
129 | @end defun | |
130 | ||
131 | ") | |
132 | ||
133 | (assert-serialize '(defun (% (name "frob") (arguments "bar" " " "baz")) | |
134 | (para "foo?")) | |
135 | "@defun frob bar baz | |
136 | foo? | |
137 | ||
138 | @end defun | |
139 | ||
140 | ") | |
141 | ||
142 | (assert-serialize '(defun (% (name "frob") (arguments (var "bar"))) | |
143 | (para "foo?")) | |
144 | "@defun frob @var{bar} | |
145 | foo? | |
146 | ||
147 | @end defun | |
148 | ||
149 | ") | |
150 | ||
151 | (assert-serialize '(defunx (% (name "frob") (arguments (var "bar")))) | |
152 | "@defunx frob @var{bar} | |
153 | ") | |
154 | ||
155 | (assert-serialize '(table (% (formatter (var))) | |
156 | (entry (% (heading "Foo bar " (code "baz"))) | |
157 | (para "Frobate") | |
158 | (para "zzzzz"))) | |
159 | "@table @var | |
160 | @item Foo bar @code{baz} | |
161 | Frobate | |
162 | ||
163 | zzzzz | |
164 | ||
165 | @end table | |
166 | ||
167 | ") | |
168 | ||
169 | (assert-serialize '(verbatim "foo") | |
170 | "@verbatim | |
171 | foo | |
172 | @end verbatim | |
173 | ||
174 | ") | |
175 | ||
176 | (assert-serialize '(deffnx (% (name "foo") (category "bar"))) | |
177 | "@deffnx bar foo | |
178 | ") | |
179 | ||
180 | (assert-serialize '(deffnx (% (name "foo") (category "bar") (arguments "x" " " "y"))) | |
181 | "@deffnx bar foo x y | |
182 | ") | |
183 | ||
184 | (assert-serialize '(deffnx (% (name "foo") (category "bar") (arguments "(" "x" " " (code "int") ")"))) | |
185 | "@deffnx bar foo (x @code{int}) | |
186 | ") | |
187 | ||
188 | ) |