2 ; Test code for all basic alsa lisp commands.
3 ; The test is indended to find memory leaks.
5 ; Copyright (c) 2003 Jaroslav Kysela <perex@perex.cz>
6 ; License: GPL v2 (http://www.gnu.org/licenses/gpl.html)
14 (!= 0) (&check-memory)
15 (!= 0 1) (&check-memory)
16 (!= 1 1) (&check-memory)
17 (!= 0 1 2) (&check-memory)
18 (!= 'aaaa 'bbbb) (&check-memory)
21 (% 11) (&check-memory)
22 (% 11 5) (&check-memory)
23 (% 11.5 5.1) (&check-memory)
24 (% 11.5 5.1 2.2) (&check-memory)
25 (% 'aaaa 'bbbb) (&check-memory)
27 (&check-memory) (&check-memory)
28 (&check-memory "abcd") (&check-memory)
29 (&dump-memory "-") (&check-memory)
30 (&dump-memory) (&check-memory)
31 (&dump-objects "-") (&check-memory)
32 (&dump-objects) (&check-memory)
33 (&stat-memory) (&check-memory)
34 (&stat-memory "abcd") (&check-memory)
38 (* 1 2) (&check-memory)
39 (* 1.1 2.2) (&check-memory)
40 (* 1.1 2.2 3.3) (&check-memory)
41 (* 'aaaa) (&check-memory)
45 (+ 1 2) (&check-memory)
46 (+ 1.1 2.2) (&check-memory)
47 (+ 1.1 2.2 3.3) (&check-memory)
48 (+ 'aaaa) (&check-memory)
49 (+ 'aaaa 'bbbb) (&check-memory)
50 (+ "aaaa") (&check-memory)
51 (+ "aaaa" "bbbb") (&check-memory)
52 (+ "aaaa" "bbbb" "cccc") (&check-memory)
56 (- 1 2) (&check-memory)
57 (- 1.1 2.2) (&check-memory)
58 (- 1.1 2.2 3.3) (&check-memory)
59 (- 'aaaa) (&check-memory)
60 (- 'aaaa 'bbbb) (&check-memory)
64 (/ 1 2) (&check-memory)
65 (/ 1.1 2.2) (&check-memory)
66 (/ 1.1 2.2 3.3) (&check-memory)
67 (/ 'aaaa) (&check-memory)
68 (/ 'aaaa 'bbbb) (&check-memory)
72 (< 0 1) (&check-memory)
73 (< 1 0) (&check-memory)
74 (< 0 1 2) (&check-memory)
77 (<= 0) (&check-memory)
78 (<= 0 1) (&check-memory)
79 (<= 1 0) (&check-memory)
80 (<= 0 1 2) (&check-memory)
84 (= 0 1) (&check-memory)
85 (= 1 1) (&check-memory)
86 (= 0 1 2) (&check-memory)
90 (> 0 1) (&check-memory)
91 (> 1 0) (&check-memory)
92 (> 0 1 2) (&check-memory)
94 (>= 0) (&check-memory)
95 (>= 0 1) (&check-memory)
96 (>= 1 0) (&check-memory)
97 (>= 0 1 2) (&check-memory)
100 (and 0) (&check-memory)
101 (and 1) (&check-memory)
102 (and 0 0 0) (&check-memory)
104 (quote a) (&check-memory)
106 (assoc) (&check-memory)
107 (assoc 'one) (&check-memory)
108 (assoc 'one '((one . first))) (&check-memory)
109 (assoc 'one '((two . second))) (&check-memory)
110 (assoc 'one '((one . first) (two . second))) (&check-memory)
112 (assq) (&check-memory)
113 (assq 'one) (&check-memory)
114 (assq "one" '(("one" . "first"))) (&check-memory)
115 (assq "one" '(("two" . "second"))) (&check-memory)
116 (assq "one" '(("one" . "first") ("two" . "second"))) (&check-memory)
118 (atom) (&check-memory)
119 (atom 'one) (&check-memory)
120 (atom "one") (&check-memory)
121 (atom "one" 'two) (&check-memory)
123 (funcall) (&check-memory)
125 (car) (&check-memory)
126 (car '(one . two)) (&check-memory)
128 (cdr) (&check-memory)
129 (cdr '(one . two)) (&check-memory)
131 (concat) (&check-memory)
132 (concat 'aaaa) (&check-memory)
133 (concat 'aaaa 'bbbb) (&check-memory)
134 (concat "aaaa") (&check-memory)
135 (concat "aaaa" "bbbb") (&check-memory)
136 (concat "aaaa" "bbbb" "cccc") (&check-memory)
138 (cond) (&check-memory)
139 (cond 0) (&check-memory)
140 (cond 0 1) (&check-memory)
141 (cond 0 1 2) (&check-memory)
142 (cond 0 1 2 3) (&check-memory)
143 (cond (0 'a) (1 'b) (0 'd)) (&check-memory)
144 (cond 1) (&check-memory)
145 (cond 1 1) (&check-memory)
146 (cond 1 1 2) (&check-memory)
147 (cond 1 1 2 3) (&check-memory)
149 (cons) (&check-memory)
150 (cons "a") (&check-memory)
151 (cons "a" "b") (&check-memory)
152 (cons "a" "b" "c") (&check-memory)
155 (eq 1) (&check-memory)
156 (eq 0 0) (&check-memory)
157 (eq "a" "b") (&check-memory)
158 (eq "a" "b" "c") (&check-memory)
160 (equal) (&check-memory)
161 (equal 1) (&check-memory)
162 (equal 0 0) (&check-memory)
163 (equal "a" "b") (&check-memory)
164 (equal "a" "b" "c") (&check-memory)
166 (exfun) (&check-memory)
167 (exfun 'abcd) (&check-memory)
168 (exfun 'abcd 'ijkl) (&check-memory)
170 (format) (&check-memory)
171 (format 1) (&check-memory)
172 (format 'a) (&check-memory)
173 (format "a" "b" "c") (&check-memory)
174 (format "1.2") (&check-memory)
175 (format "%c" 43) (&check-memory)
176 (format "%d" 12) (&check-memory)
177 (format "%i" 12) (&check-memory)
178 (format "%f" 12.1) (&check-memory)
179 (format "%s" "abcd") (&check-memory)
180 (format "%s %i %i" "abcd" 1 2) (&check-memory)
182 (garbage-collect) (&check-memory)
186 (if t) (&check-memory)
187 (if t 'a) (&check-memory)
188 (if t 'a 'b) (&check-memory)
189 (if nil) (&check-memory)
190 (if nil 'a) (&check-memory)
191 (if nil 'a 'b) (&check-memory)
193 (include "itest.lisp") (&check-memory)
195 (list) (&check-memory)
196 (list "a") (&check-memory)
197 (list "a" "b") (&check-memory)
198 (list "a" "b" "c") (&check-memory)
200 (not) (&check-memory)
201 (not 0) (&check-memory)
202 (not nil) (&check-memory)
203 (not t) (&check-memory)
204 (not 'a) (&check-memory)
205 (not 'a 'b 'c 'd) (&check-memory)
207 (nth) (&check-memory)
208 (nth 2) (&check-memory)
209 (nth 2 nil) (&check-memory)
210 (nth 2 '(('one 'two 'three))) (&check-memory)
212 (null) (&check-memory)
213 (null 0) (&check-memory)
214 (null nil) (&check-memory)
215 (null t) (&check-memory)
216 (null 'a) (&check-memory)
217 (null 'a 'b 'c 'd) (&check-memory)
220 (or 0) (&check-memory)
221 (or 1) (&check-memory)
222 (or 0 0 0) (&check-memory)
224 (path) (&check-memory)
225 (path 0) (&check-memory)
226 (path 1) (&check-memory)
227 (path 0 0 0) (&check-memory)
228 (path "data") (&check-memory)
230 (princ) (&check-memory)
231 (princ "\nabcd\n") (&check-memory)
232 (princ "a" "b" "c\n") (&check-memory)
234 (prog1) (&check-memory)
235 (prog1 1) (&check-memory)
236 (prog1 1 2 3 4) (&check-memory)
238 (prog2) (&check-memory)
239 (prog2 1) (&check-memory)
240 (prog2 1 2 3 4) (&check-memory)
242 (progn) (&check-memory)
243 (progn 1) (&check-memory)
244 (progn 1 2 3 4) (&check-memory)
246 (quote) (&check-memory)
247 (quote a) (&check-memory)
249 (rassoc) (&check-memory)
250 (rassoc 'first) (&check-memory)
251 (rassoc 'first '((one . first))) (&check-memory)
252 (rassoc 'first '((two . second))) (&check-memory)
253 (rassoc 'first '((one . first) (two . second))) (&check-memory)
255 (rassq) (&check-memory)
256 (rassq "first") (&check-memory)
257 (rassq "first" '(("one" . "first"))) (&check-memory)
258 (rassq "first" '(("two" . "second"))) (&check-memory)
259 (rassq "first" '(("one" . "first") ("two" . "second"))) (&check-memory)
261 (set) (&check-memory)
262 (set "a") (unset "a") (&check-memory)
263 (set "a" 1) (unset "a") (&check-memory)
264 (set a 1) (unset a) (&check-memory)
265 (set "a" 1 2) (unset "a") (&check-memory)
267 (setf) (&check-memory)
268 (setf a) (unsetf a) (&check-memory)
269 (setf a 1) (unsetf a) (&check-memory)
270 (setf a 1 2) (unsetf a) (&check-memory)
272 (setq) (&check-memory)
273 (setq a) (unsetq a) (&check-memory)
274 (setq a 1) (unsetq a) (&check-memory)
275 (setq a 1 2) (unsetq a) (&check-memory)
277 (string-equal) (&check-memory)
278 (string-equal 1) (&check-memory)
279 (string-equal "a") (&check-memory)
280 (string-equal "a" "a") (&check-memory)
281 (string-equal "a" "b") (&check-memory)
282 (string-equal "a" "b" "c") (&check-memory)
284 (string-to-integer) (&check-memory)
285 (string-to-integer 1) (&check-memory)
286 (string-to-integer 1.5) (&check-memory)
287 (string-to-integer "a") (&check-memory)
288 (string-to-integer "a" "a") (&check-memory)
289 (string-to-integer "a" "b") (&check-memory)
290 (string-to-integer "a" "b" "c") (&check-memory)
292 (string-to-float) (&check-memory)
293 (string-to-float 1) (&check-memory)
294 (string-to-float 1.5) (&check-memory)
295 (string-to-float "a") (&check-memory)
296 (string-to-float "a" "a") (&check-memory)
297 (string-to-float "a" "b") (&check-memory)
298 (string-to-float "a" "b" "c") (&check-memory)
300 (string=) (&check-memory)
301 (string= 1) (&check-memory)
302 (string= "a") (&check-memory)
303 (string= "a" "a") (&check-memory)
304 (string= "a" "b") (&check-memory)
305 (string= "a" "b" "c") (&check-memory)
307 (unless) (&check-memory)
308 (unless 1) (&check-memory)
309 (unless 0 1 2) (&check-memory)
310 (unless t 2 3 4) (&check-memory)
311 (unless nil 2 3 4) (&check-memory)
313 (unset) (&check-memory)
314 (unset "a") (&check-memory)
316 (unsetf) (&check-memory)
317 (unsetf a) (&check-memory)
318 (unsetf a b) (&check-memory)
320 (unsetq) (&check-memory)
321 (unsetq a) (&check-memory)
322 (unsetq a b) (&check-memory)
324 (when) (&check-memory)
325 (when 0) (&check-memory)
326 (when 0 1) (&check-memory)
327 (when t 1) (&check-memory)
328 (when nil 1) (&check-memory)
330 (while) (&check-memory)
331 (while nil) (&check-memory)
332 (while nil 1) (&check-memory)
333 (while nil 1 2 3 4) (&check-memory)
336 ; more complex command sequences
343 (setq abcd (("abcd" . "efgh") ("1234" . "5678")))
347 (defun myfun () (princ "a\n"))
352 (defun myfun () (princ "a\n"))
354 (funcall 'myfun 'aaaaa)
358 (defun myfun (o) (princ o "a\n"))
360 (funcall 'myfun 'aaaaa)
364 (defun myfun (o p) (princ o p "\n"))
366 (funcall 'myfun 'aaaaa)
367 (funcall 'myfun 'aaaaa 'bbbbb)
371 (defun printnum (from to) (while (<= from to) (princ " " from) (setq from (+ from 1))))
372 (princ "Numbers 1-10:") (printnum 1 10) (princ "\n")
379 (princ "*********************\n")
380 (princ "OK, all tests passed!\n")
381 (princ "*********************\n")